From 86666cc6ef99fa0a2761dc0c56e30df7cbb8e52c Mon Sep 17 00:00:00 2001 From: Ziyan Date: Sat, 11 Apr 2015 23:15:11 +0200 Subject: Remove common omap4 modules domx: remove for move to omap4-next edid/hwc: remove for move to omap4-next include / kernel-headers: remove for move to omap4-next libcorkscrew: remove for move to omap4-next libion_ti: remove for move to omap4-next libtiutils: remove for move to omap4-next pvr-source / pvrsrvinit: remove for move to omap4-next remove gralloc symlink for move to omap4-next Change-Id: I1ade011fd5e0adedbcb19cbf941fdde5ef4f96b6 symlinks: remove for move to omap4-next --- Android.mk | 15 - camera/ANativeWindowDisplayAdapter.cpp | 1345 ----- camera/Android.mk | 227 - camera/AppCallbackNotifier.cpp | 1923 ------- camera/BaseCameraAdapter.cpp | 2693 ---------- camera/BufferSourceAdapter.cpp | 816 --- camera/CameraHal.cpp | 4333 --------------- camera/CameraHalCommon.cpp | 121 - camera/CameraHalUtilClasses.cpp | 361 -- camera/CameraHal_Module.cpp | 823 --- camera/CameraParameters.cpp | 248 - camera/CameraProperties.cpp | 135 - camera/Encoder_libjpeg.cpp | 543 -- camera/MemoryManager.cpp | 231 - camera/NV12_resize.cpp | 290 - camera/OMXCameraAdapter/OMX3A.cpp | 2005 ------- camera/OMXCameraAdapter/OMXAlgo.cpp | 1261 ----- camera/OMXCameraAdapter/OMXCameraAdapter.cpp | 4721 ----------------- camera/OMXCameraAdapter/OMXCapabilities.cpp | 2647 ---------- camera/OMXCameraAdapter/OMXCapture.cpp | 2096 -------- camera/OMXCameraAdapter/OMXDccDataSave.cpp | 361 -- camera/OMXCameraAdapter/OMXDefaults.cpp | 97 - camera/OMXCameraAdapter/OMXExif.cpp | 845 --- camera/OMXCameraAdapter/OMXFD.cpp | 504 -- camera/OMXCameraAdapter/OMXFocus.cpp | 890 ---- camera/OMXCameraAdapter/OMXMetadata.cpp | 181 - camera/OMXCameraAdapter/OMXReprocess.cpp | 340 -- camera/OMXCameraAdapter/OMXZoom.cpp | 289 - camera/SensorListener.cpp | 232 - camera/TICameraParameters.cpp | 241 - camera/V4LCameraAdapter/V4LCameraAdapter.cpp | 1318 ----- camera/V4LCameraAdapter/V4LCapabilities.cpp | 346 -- camera/inc/ANativeWindowDisplayAdapter.h | 189 - camera/inc/BaseCameraAdapter.h | 306 -- camera/inc/BufferSourceAdapter.h | 190 - camera/inc/CameraHal.h | 1484 ------ camera/inc/CameraProperties.h | 255 - camera/inc/Common.h | 77 - camera/inc/Encoder_libjpeg.h | 226 - camera/inc/General3A_Settings.h | 292 -- camera/inc/NV12_resize.h | 135 - camera/inc/OMXCameraAdapter/OMXCameraAdapter.h | 1245 ----- camera/inc/OMXCameraAdapter/OMXSceneModeTables.h | 553 -- camera/inc/SensorListener.h | 105 - camera/inc/TICameraParameters.h | 269 - camera/inc/V4LCameraAdapter/V4LCameraAdapter.h | 238 - camera/inc/VideoMetadata.h | 32 - domx/Android.mk | 1 - domx/Makefile | 89 - domx/domx/Android.mk | 41 - domx/domx/Makefile | 111 - domx/domx/memmgr_rpc/src/Android.mk | 36 - domx/domx/omx_proxy_common.h | 340 -- domx/domx/omx_proxy_common/src/omx_proxy_common.c | 2563 --------- domx/domx/omx_rpc.h | 149 - domx/domx/omx_rpc/inc/omx_rpc_internal.h | 189 - domx/domx/omx_rpc/inc/omx_rpc_skel.h | 101 - domx/domx/omx_rpc/inc/omx_rpc_stub.h | 145 - domx/domx/omx_rpc/inc/omx_rpc_utils.h | 170 - domx/domx/omx_rpc/src/omx_rpc.c | 410 -- domx/domx/omx_rpc/src/omx_rpc_config.c | 1 - domx/domx/omx_rpc/src/omx_rpc_platform.c | 1 - domx/domx/omx_rpc/src/omx_rpc_skel.c | 329 -- domx/domx/omx_rpc/src/omx_rpc_stub.c | 1489 ------ domx/domx/omx_rpc/src/omx_rpc_utils.c | 446 -- domx/domx/profiling/inc/profile.h | 87 - domx/domx/profiling/src/profile.c | 299 -- domx/domx/rpmsg_omx_defs.h | 54 - domx/make/build.mk | 379 -- domx/make/start.mk | 101 - domx/mm_osal/Android.mk | 30 - domx/mm_osal/Makefile | 61 - domx/mm_osal/inc/timm_osal_error.h | 175 - domx/mm_osal/inc/timm_osal_events.h | 81 - domx/mm_osal/inc/timm_osal_interfaces.h | 72 - domx/mm_osal/inc/timm_osal_memory.h | 105 - domx/mm_osal/inc/timm_osal_mutex.h | 71 - domx/mm_osal/inc/timm_osal_osal.h | 68 - domx/mm_osal/inc/timm_osal_pipes.h | 89 - domx/mm_osal/inc/timm_osal_semaphores.h | 79 - domx/mm_osal/inc/timm_osal_task.h | 89 - domx/mm_osal/inc/timm_osal_trace.h | 217 - domx/mm_osal/inc/timm_osal_types.h | 124 - domx/mm_osal/src/timm_osal.c | 99 - domx/mm_osal/src/timm_osal_events.c | 420 -- domx/mm_osal/src/timm_osal_memory.c | 250 - domx/mm_osal/src/timm_osal_mutex.c | 244 - domx/mm_osal/src/timm_osal_pipes.c | 415 -- domx/mm_osal/src/timm_osal_semaphores.c | 297 -- domx/mm_osal/src/timm_osal_task.c | 262 - domx/mm_osal/src/timm_osal_trace.c | 174 - domx/omx_core/Android.mk | 24 - domx/omx_core/Makefile | 99 - domx/omx_core/inc/OMX_ComponentExt.h | 61 - domx/omx_core/inc/OMX_ComponentRegistry.h | 68 - domx/omx_core/inc/OMX_CoreExt.h | 73 - domx/omx_core/inc/OMX_Core_Wrapper.h | 83 - domx/omx_core/inc/OMX_Debug.h | 170 - domx/omx_core/inc/OMX_DebugMem.h | 71 - domx/omx_core/inc/OMX_TI_Common.h | 221 - domx/omx_core/inc/OMX_TI_Core.h | 107 - domx/omx_core/inc/OMX_TI_IVCommon.h | 2657 ---------- domx/omx_core/inc/OMX_TI_Image.h | 62 - domx/omx_core/inc/OMX_TI_Index.h | 245 - domx/omx_core/inc/OMX_TI_Video.h | 2587 --------- domx/omx_core/src/OMX_Core.c | 953 ---- domx/omx_core/src/OMX_Core_Wrapper.c | 168 - domx/omx_proxy_component/Android.mk | 208 - domx/omx_proxy_component/Makefile | 89 - .../omx_camera/src/omx_proxy_camera.c | 909 ---- domx/omx_proxy_component/omx_h264_enc/Makefile | 103 - .../omx_h264_enc/src/omx_proxy_h264enc.c | 1099 ---- domx/omx_proxy_component/omx_mpeg4_enc/Makefile | 103 - .../omx_mpeg4_enc/src/omx_proxy_mpeg4enc.c | 1050 ---- domx/omx_proxy_component/omx_sample/Makefile | 103 - .../omx_sample/src/omx_proxy_sample.c | 109 - domx/omx_proxy_component/omx_video_dec/Makefile | 103 - .../omx_video_dec/src/omx_proxy_videodec.c | 797 --- .../omx_video_dec/src/omx_proxy_videodec_secure.c | 157 - .../omx_video_dec/src/omx_proxy_videodec_utils.c | 318 -- domx/test/Makefile | 95 - domx/test/sample_proxy/Makefile | 98 - domx/test/sample_proxy/test_sample_proxy.c | 1222 ----- edid/Android.mk | 41 - edid/cmd/parse_hdmi_edid.c | 154 - edid/inc/edid_parser.h | 113 - edid/lib/edid_parser.c | 410 -- edid/lib/edid_parser_priv.h | 31 - hwc/Android.mk | 45 - hwc/dock_image.c | 196 - hwc/dock_image.h | 38 - hwc/hal_public.h | 188 - hwc/hwc.c | 2703 ---------- hwc/hwc_dev.h | 177 - hwc/rgz_2d.c | 1997 ------- hwc/rgz_2d.h | 306 -- hwc/sw_vsync.c | 151 - hwc/sw_vsync.h | 25 - include/camera/VideoMetadata.h | 32 - include/device_perms.h | 17 - include/gralloc/ti_handle_wrapper.h | 85 - include/hardware/camera.h | 384 -- include/hardware/camera_common.h | 434 -- include/hardware/hwcomposer.h | 900 ---- include/ion_ti/ion.h | 49 - include/ion_ti/linux_ion.h | 76 - include/ion_ti/omap_ion.h | 61 - include/system/camera.h | 361 -- include/system/camera_vendor_tags.h | 98 - kernel-headers/linux/bltsville.h | 525 -- kernel-headers/linux/bvblend.h | 210 - kernel-headers/linux/bvbuffdesc.h | 56 - kernel-headers/linux/bvcache.h | 41 - kernel-headers/linux/bventry.h | 39 - kernel-headers/linux/bverror.h | 336 -- kernel-headers/linux/bvfilter.h | 34 - kernel-headers/linux/bvinternal.h | 29 - kernel-headers/linux/bvsurfgeom.h | 34 - kernel-headers/linux/fb.h | 1206 ----- kernel-headers/linux/ocd.h | 624 --- kernel-headers/linux/omap_ion.h | 66 - kernel-headers/linux/omapfb.h | 231 - kernel-headers/linux/rpmsg_omx.h | 51 - kernel-headers/video/dsscomp.h | 414 -- kernel-headers/video/omap_hwc.h | 48 - libcorkscrew/Android.mk | 11 - libcorkscrew/corkscrew.c | 61 - libcorkscrew/corkscrew.h | 56 - libion_ti/Android.mk | 37 - libion_ti/ion.c | 201 - libion_ti/ion.h | 49 - libion_ti/ion_test.c | 319 -- libion_ti/ion_test_2.c | 479 -- libion_ti/linux_ion.h | 76 - libion_ti/omap_ion.h | 61 - libtiutils/Android.mk | 46 - libtiutils/DebugUtils.cpp | 96 - libtiutils/DebugUtils.h | 398 -- libtiutils/ErrorUtils.cpp | 140 - libtiutils/ErrorUtils.h | 56 - libtiutils/MessageQueue.cpp | 419 -- libtiutils/MessageQueue.h | 98 - libtiutils/Semaphore.cpp | 232 - libtiutils/Semaphore.h | 63 - libtiutils/Status.h | 67 - libtiutils/UtilsCommon.h | 99 - pvr-source/GPL-COPYING | 344 -- pvr-source/INSTALL | 72 - pvr-source/MIT-COPYING | 41 - pvr-source/README | 49 - pvr-source/eurasiacon/build/linux2/bits.mk | 112 - pvr-source/eurasiacon/build/linux2/buildvars.mk | 217 - pvr-source/eurasiacon/build/linux2/commands.mk | 219 - .../build/linux2/common/android/arch_common.mk | 61 - .../build/linux2/common/android/armv7-a.mk | 68 - .../build/linux2/common/android/extra_config.mk | 47 - .../build/linux2/common/android/features.mk | 326 -- .../build/linux2/common/android/paths.mk | 53 - .../linux2/common/android/platform_version.mk | 156 - .../eurasiacon/build/linux2/common/dridrm.mk | 63 - pvr-source/eurasiacon/build/linux2/common/omap4.mk | 43 - .../eurasiacon/build/linux2/common/opencl.mk | 40 - pvr-source/eurasiacon/build/linux2/config/core.mk | 604 --- pvr-source/eurasiacon/build/linux2/defs.mk | 140 - .../build/linux2/kbuild/Makefile.template | 92 - .../build/linux2/kbuild/external_tarball.mk | 49 - .../eurasiacon/build/linux2/kbuild/kbuild.mk | 91 - .../eurasiacon/build/linux2/kernel_module.mk | 75 - .../eurasiacon/build/linux2/kernel_version.mk | 100 - pvr-source/eurasiacon/build/linux2/moduledefs.mk | 96 - pvr-source/eurasiacon/build/linux2/modules.mk | 49 - .../build/linux2/omap4430_android/Makefile | 192 - .../build/linux2/omap4430_android/products.mk | 46 - pvr-source/eurasiacon/build/linux2/prepare_tree.mk | 60 - .../eurasiacon/build/linux2/this_makefile.mk | 68 - .../eurasiacon/build/linux2/tools/cc-check.sh | 99 - pvr-source/eurasiacon/build/linux2/toplevel.mk | 226 - pvr-source/include4/dbgdrvif.h | 381 -- pvr-source/include4/img_defs.h | 153 - pvr-source/include4/img_types.h | 214 - pvr-source/include4/pdumpdefs.h | 126 - pvr-source/include4/pvr_debug.h | 235 - pvr-source/include4/pvrmodule.h | 48 - pvr-source/include4/pvrversion.h | 69 - pvr-source/include4/services.h | 1870 ------- pvr-source/include4/servicesext.h | 965 ---- pvr-source/include4/sgx_options.h | 258 - pvr-source/include4/sgxapi_km.h | 524 -- pvr-source/include4/sgxscript.h | 99 - pvr-source/services4/3rdparty/dc_nohw/Kbuild.mk | 47 - pvr-source/services4/3rdparty/dc_nohw/Linux.mk | 45 - pvr-source/services4/3rdparty/dc_nohw/dc_nohw.h | 288 - .../3rdparty/dc_nohw/dc_nohw_displayclass.c | 982 ---- .../services4/3rdparty/dc_nohw/dc_nohw_linux.c | 376 -- .../services4/3rdparty/dc_omapfb3_linux/Kbuild.mk | 48 - .../services4/3rdparty/dc_omapfb3_linux/Linux.mk | 45 - .../services4/3rdparty/dc_omapfb3_linux/omaplfb.h | 323 -- .../dc_omapfb3_linux/omaplfb_displayclass.c | 1722 ------ .../3rdparty/dc_omapfb3_linux/omaplfb_linux.c | 1165 ----- pvr-source/services4/include/kernelbuffer.h | 97 - pvr-source/services4/include/kerneldisplay.h | 243 - pvr-source/services4/include/pdump.h | 51 - pvr-source/services4/include/pvr_bridge.h | 2255 -------- pvr-source/services4/include/pvr_bridge_km.h | 409 -- pvr-source/services4/include/pvrmmap.h | 81 - pvr-source/services4/include/pvrsrv_errors.h | 311 -- pvr-source/services4/include/servicesint.h | 555 -- pvr-source/services4/include/sgx_bridge.h | 779 --- pvr-source/services4/include/sgx_mkif_km.h | 476 -- .../services4/include/sgx_ukernel_status_codes.h | 966 ---- pvr-source/services4/include/sgxinfo.h | 489 -- .../services4/srvkm/bridged/bridged_pvr_bridge.c | 5512 -------------------- .../services4/srvkm/bridged/bridged_pvr_bridge.h | 257 - .../services4/srvkm/bridged/bridged_support.c | 117 - .../services4/srvkm/bridged/bridged_support.h | 72 - .../srvkm/bridged/sgx/bridged_sgx_bridge.c | 3819 -------------- .../srvkm/bridged/sgx/bridged_sgx_bridge.h | 61 - pvr-source/services4/srvkm/common/buffer_manager.c | 3573 ------------- pvr-source/services4/srvkm/common/deviceclass.c | 2864 ---------- pvr-source/services4/srvkm/common/deviceid.h | 51 - pvr-source/services4/srvkm/common/devicemem.c | 2592 --------- pvr-source/services4/srvkm/common/handle.c | 2689 ---------- pvr-source/services4/srvkm/common/hash.c | 738 --- pvr-source/services4/srvkm/common/lists.c | 156 - pvr-source/services4/srvkm/common/mem.c | 175 - pvr-source/services4/srvkm/common/mem_debug.c | 272 - pvr-source/services4/srvkm/common/metrics.c | 209 - pvr-source/services4/srvkm/common/osfunc_common.c | 48 - pvr-source/services4/srvkm/common/pdump_common.c | 2967 ----------- pvr-source/services4/srvkm/common/perproc.c | 398 -- pvr-source/services4/srvkm/common/power.c | 996 ---- pvr-source/services4/srvkm/common/pvrsrv.c | 1846 ------- pvr-source/services4/srvkm/common/queue.c | 1503 ------ pvr-source/services4/srvkm/common/ra.c | 2427 --------- pvr-source/services4/srvkm/common/refcount.c | 588 --- pvr-source/services4/srvkm/common/resman.c | 985 ---- pvr-source/services4/srvkm/common/ttrace.c | 597 --- pvr-source/services4/srvkm/devices/sgx/mmu.c | 4601 ---------------- pvr-source/services4/srvkm/devices/sgx/mmu.h | 501 -- pvr-source/services4/srvkm/devices/sgx/pb.c | 493 -- .../services4/srvkm/devices/sgx/sgx_bridge_km.h | 279 - pvr-source/services4/srvkm/devices/sgx/sgxconfig.h | 481 -- pvr-source/services4/srvkm/devices/sgx/sgxinfokm.h | 606 --- pvr-source/services4/srvkm/devices/sgx/sgxinit.c | 3431 ------------ pvr-source/services4/srvkm/devices/sgx/sgxkick.c | 918 ---- pvr-source/services4/srvkm/devices/sgx/sgxpower.c | 660 --- pvr-source/services4/srvkm/devices/sgx/sgxreset.c | 808 --- .../services4/srvkm/devices/sgx/sgxtransfer.c | 814 --- pvr-source/services4/srvkm/devices/sgx/sgxutils.c | 1914 ------- pvr-source/services4/srvkm/devices/sgx/sgxutils.h | 195 - pvr-source/services4/srvkm/env/linux/Kbuild.mk | 166 - pvr-source/services4/srvkm/env/linux/Linux.mk | 45 - pvr-source/services4/srvkm/env/linux/env_data.h | 93 - pvr-source/services4/srvkm/env/linux/env_perproc.h | 79 - pvr-source/services4/srvkm/env/linux/event.c | 414 -- pvr-source/services4/srvkm/env/linux/event.h | 48 - .../services4/srvkm/env/linux/gc_bvmapping.c | 147 - .../services4/srvkm/env/linux/gc_bvmapping.h | 27 - pvr-source/services4/srvkm/env/linux/ion.c | 363 -- pvr-source/services4/srvkm/env/linux/ion.h | 74 - pvr-source/services4/srvkm/env/linux/linkage.h | 72 - pvr-source/services4/srvkm/env/linux/lock.h | 56 - pvr-source/services4/srvkm/env/linux/mm.c | 2945 ----------- pvr-source/services4/srvkm/env/linux/mm.h | 751 --- pvr-source/services4/srvkm/env/linux/mmap.c | 1656 ------ pvr-source/services4/srvkm/env/linux/mmap.h | 240 - pvr-source/services4/srvkm/env/linux/module.c | 1214 ----- pvr-source/services4/srvkm/env/linux/mutex.c | 163 - pvr-source/services4/srvkm/env/linux/mutex.h | 97 - pvr-source/services4/srvkm/env/linux/mutils.c | 166 - pvr-source/services4/srvkm/env/linux/mutils.h | 119 - pvr-source/services4/srvkm/env/linux/osfunc.c | 4714 ----------------- pvr-source/services4/srvkm/env/linux/osperproc.c | 146 - pvr-source/services4/srvkm/env/linux/pdump.c | 804 --- .../services4/srvkm/env/linux/private_data.h | 95 - pvr-source/services4/srvkm/env/linux/proc.c | 1414 ----- pvr-source/services4/srvkm/env/linux/proc.h | 127 - .../services4/srvkm/env/linux/pvr_bridge_k.c | 524 -- pvr-source/services4/srvkm/env/linux/pvr_debug.c | 506 -- pvr-source/services4/srvkm/env/linux/pvr_uaccess.h | 88 - pvr-source/services4/srvkm/env/linux/sysfs.c | 90 - pvr-source/services4/srvkm/env/linux/sysfs.h | 22 - pvr-source/services4/srvkm/hwdefs/mnemedefs.h | 117 - pvr-source/services4/srvkm/hwdefs/ocpdefs.h | 308 -- pvr-source/services4/srvkm/hwdefs/sgx520defs.h | 555 -- pvr-source/services4/srvkm/hwdefs/sgx530defs.h | 542 -- pvr-source/services4/srvkm/hwdefs/sgx531defs.h | 601 --- pvr-source/services4/srvkm/hwdefs/sgx535defs.h | 739 --- pvr-source/services4/srvkm/hwdefs/sgx540defs.h | 605 --- .../services4/srvkm/hwdefs/sgx543_v1.164defs.h | 1396 ----- pvr-source/services4/srvkm/hwdefs/sgx543defs.h | 1487 ------ pvr-source/services4/srvkm/hwdefs/sgx544defs.h | 1487 ------ pvr-source/services4/srvkm/hwdefs/sgx545defs.h | 1290 ----- pvr-source/services4/srvkm/hwdefs/sgxdefs.h | 112 - pvr-source/services4/srvkm/hwdefs/sgxerrata.h | 495 -- pvr-source/services4/srvkm/hwdefs/sgxfeaturedefs.h | 274 - pvr-source/services4/srvkm/hwdefs/sgxmmu.h | 99 - pvr-source/services4/srvkm/hwdefs/sgxmpdefs.h | 365 -- .../services4/srvkm/include/buffer_manager.h | 674 --- pvr-source/services4/srvkm/include/device.h | 409 -- pvr-source/services4/srvkm/include/handle.h | 567 -- pvr-source/services4/srvkm/include/hash.h | 277 - pvr-source/services4/srvkm/include/lists.h | 349 -- pvr-source/services4/srvkm/include/metrics.h | 146 - pvr-source/services4/srvkm/include/osfunc.h | 799 --- pvr-source/services4/srvkm/include/osperproc.h | 94 - pvr-source/services4/srvkm/include/pdump_int.h | 100 - pvr-source/services4/srvkm/include/pdump_km.h | 441 -- pvr-source/services4/srvkm/include/pdump_osfunc.h | 337 -- pvr-source/services4/srvkm/include/perfkm.h | 53 - pvr-source/services4/srvkm/include/perproc.h | 150 - pvr-source/services4/srvkm/include/power.h | 140 - pvr-source/services4/srvkm/include/queue.h | 145 - pvr-source/services4/srvkm/include/ra.h | 293 -- pvr-source/services4/srvkm/include/refcount.h | 203 - pvr-source/services4/srvkm/include/resman.h | 152 - .../services4/srvkm/include/services_headers.h | 68 - pvr-source/services4/srvkm/include/srvkm.h | 129 - pvr-source/services4/srvkm/include/ttrace.h | 200 - pvr-source/services4/srvkm/include/ttrace_common.h | 146 - pvr-source/services4/srvkm/include/ttrace_tokens.h | 119 - pvr-source/services4/system/include/syscommon.h | 397 -- pvr-source/services4/system/omap4/oemfuncs.h | 80 - pvr-source/services4/system/omap4/sgxfreq.c | 610 --- pvr-source/services4/system/omap4/sgxfreq.h | 97 - .../services4/system/omap4/sgxfreq_activeidle.c | 181 - pvr-source/services4/system/omap4/sgxfreq_cool.c | 104 - .../services4/system/omap4/sgxfreq_on3demand.c | 324 -- pvr-source/services4/system/omap4/sgxfreq_onoff.c | 180 - .../services4/system/omap4/sgxfreq_userspace.c | 124 - pvr-source/services4/system/omap4/sysconfig.c | 1333 ----- pvr-source/services4/system/omap4/sysconfig.h | 110 - pvr-source/services4/system/omap4/sysinfo.h | 64 - pvr-source/services4/system/omap4/syslocal.h | 265 - pvr-source/services4/system/omap4/sysutils.c | 59 - pvr-source/services4/system/omap4/sysutils_linux.c | 746 --- pvr-source/tools/intern/debug/client/linuxsrv.h | 64 - pvr-source/tools/intern/debug/dbgdriv/Kbuild.mk | 51 - pvr-source/tools/intern/debug/dbgdriv/Linux.mk | 45 - .../tools/intern/debug/dbgdriv/common/dbgdriv.c | 2883 ---------- .../tools/intern/debug/dbgdriv/common/dbgdriv.h | 155 - .../intern/debug/dbgdriv/common/dbgdriv_ioctl.h | 57 - .../tools/intern/debug/dbgdriv/common/handle.c | 141 - .../tools/intern/debug/dbgdriv/common/hostfunc.h | 82 - .../tools/intern/debug/dbgdriv/common/hotkey.c | 199 - .../tools/intern/debug/dbgdriv/common/hotkey.h | 82 - .../tools/intern/debug/dbgdriv/common/ioctl.c | 827 --- .../tools/intern/debug/dbgdriv/linux/hostfunc.c | 395 -- pvr-source/tools/intern/debug/dbgdriv/linux/main.c | 355 -- pvrsrvinit/Android.mk | 33 - pvrsrvinit/pvrsrvinit.c | 10 - symlinks/Android.mk | 20 - 392 files changed, 195126 deletions(-) delete mode 100644 camera/ANativeWindowDisplayAdapter.cpp delete mode 100644 camera/Android.mk delete mode 100644 camera/AppCallbackNotifier.cpp delete mode 100644 camera/BaseCameraAdapter.cpp delete mode 100644 camera/BufferSourceAdapter.cpp delete mode 100644 camera/CameraHal.cpp delete mode 100644 camera/CameraHalCommon.cpp delete mode 100644 camera/CameraHalUtilClasses.cpp delete mode 100644 camera/CameraHal_Module.cpp delete mode 100644 camera/CameraParameters.cpp delete mode 100644 camera/CameraProperties.cpp delete mode 100644 camera/Encoder_libjpeg.cpp delete mode 100644 camera/MemoryManager.cpp delete mode 100644 camera/NV12_resize.cpp delete mode 100644 camera/OMXCameraAdapter/OMX3A.cpp delete mode 100644 camera/OMXCameraAdapter/OMXAlgo.cpp delete mode 100644 camera/OMXCameraAdapter/OMXCameraAdapter.cpp delete mode 100644 camera/OMXCameraAdapter/OMXCapabilities.cpp delete mode 100644 camera/OMXCameraAdapter/OMXCapture.cpp delete mode 100644 camera/OMXCameraAdapter/OMXDccDataSave.cpp delete mode 100644 camera/OMXCameraAdapter/OMXDefaults.cpp delete mode 100644 camera/OMXCameraAdapter/OMXExif.cpp delete mode 100644 camera/OMXCameraAdapter/OMXFD.cpp delete mode 100644 camera/OMXCameraAdapter/OMXFocus.cpp delete mode 100644 camera/OMXCameraAdapter/OMXMetadata.cpp delete mode 100644 camera/OMXCameraAdapter/OMXReprocess.cpp delete mode 100644 camera/OMXCameraAdapter/OMXZoom.cpp delete mode 100644 camera/SensorListener.cpp delete mode 100644 camera/TICameraParameters.cpp delete mode 100644 camera/V4LCameraAdapter/V4LCameraAdapter.cpp delete mode 100644 camera/V4LCameraAdapter/V4LCapabilities.cpp delete mode 100644 camera/inc/ANativeWindowDisplayAdapter.h delete mode 100644 camera/inc/BaseCameraAdapter.h delete mode 100644 camera/inc/BufferSourceAdapter.h delete mode 100644 camera/inc/CameraHal.h delete mode 100644 camera/inc/CameraProperties.h delete mode 100644 camera/inc/Common.h delete mode 100644 camera/inc/Encoder_libjpeg.h delete mode 100644 camera/inc/General3A_Settings.h delete mode 100644 camera/inc/NV12_resize.h delete mode 100644 camera/inc/OMXCameraAdapter/OMXCameraAdapter.h delete mode 100644 camera/inc/OMXCameraAdapter/OMXSceneModeTables.h delete mode 100644 camera/inc/SensorListener.h delete mode 100644 camera/inc/TICameraParameters.h delete mode 100644 camera/inc/V4LCameraAdapter/V4LCameraAdapter.h delete mode 100644 camera/inc/VideoMetadata.h delete mode 100644 domx/Android.mk delete mode 100644 domx/Makefile delete mode 100644 domx/domx/Android.mk delete mode 100644 domx/domx/Makefile delete mode 100755 domx/domx/memmgr_rpc/src/Android.mk delete mode 100755 domx/domx/omx_proxy_common.h delete mode 100644 domx/domx/omx_proxy_common/src/omx_proxy_common.c delete mode 100755 domx/domx/omx_rpc.h delete mode 100755 domx/domx/omx_rpc/inc/omx_rpc_internal.h delete mode 100755 domx/domx/omx_rpc/inc/omx_rpc_skel.h delete mode 100755 domx/domx/omx_rpc/inc/omx_rpc_stub.h delete mode 100755 domx/domx/omx_rpc/inc/omx_rpc_utils.h delete mode 100755 domx/domx/omx_rpc/src/omx_rpc.c delete mode 100755 domx/domx/omx_rpc/src/omx_rpc_config.c delete mode 100755 domx/domx/omx_rpc/src/omx_rpc_platform.c delete mode 100755 domx/domx/omx_rpc/src/omx_rpc_skel.c delete mode 100755 domx/domx/omx_rpc/src/omx_rpc_stub.c delete mode 100755 domx/domx/omx_rpc/src/omx_rpc_utils.c delete mode 100644 domx/domx/profiling/inc/profile.h delete mode 100644 domx/domx/profiling/src/profile.c delete mode 100644 domx/domx/rpmsg_omx_defs.h delete mode 100644 domx/make/build.mk delete mode 100644 domx/make/start.mk delete mode 100644 domx/mm_osal/Android.mk delete mode 100644 domx/mm_osal/Makefile delete mode 100755 domx/mm_osal/inc/timm_osal_error.h delete mode 100755 domx/mm_osal/inc/timm_osal_events.h delete mode 100755 domx/mm_osal/inc/timm_osal_interfaces.h delete mode 100755 domx/mm_osal/inc/timm_osal_memory.h delete mode 100755 domx/mm_osal/inc/timm_osal_mutex.h delete mode 100755 domx/mm_osal/inc/timm_osal_osal.h delete mode 100755 domx/mm_osal/inc/timm_osal_pipes.h delete mode 100755 domx/mm_osal/inc/timm_osal_semaphores.h delete mode 100755 domx/mm_osal/inc/timm_osal_task.h delete mode 100755 domx/mm_osal/inc/timm_osal_trace.h delete mode 100755 domx/mm_osal/inc/timm_osal_types.h delete mode 100755 domx/mm_osal/src/timm_osal.c delete mode 100755 domx/mm_osal/src/timm_osal_events.c delete mode 100755 domx/mm_osal/src/timm_osal_memory.c delete mode 100755 domx/mm_osal/src/timm_osal_mutex.c delete mode 100755 domx/mm_osal/src/timm_osal_pipes.c delete mode 100755 domx/mm_osal/src/timm_osal_semaphores.c delete mode 100755 domx/mm_osal/src/timm_osal_task.c delete mode 100755 domx/mm_osal/src/timm_osal_trace.c delete mode 100644 domx/omx_core/Android.mk delete mode 100644 domx/omx_core/Makefile delete mode 100755 domx/omx_core/inc/OMX_ComponentExt.h delete mode 100755 domx/omx_core/inc/OMX_ComponentRegistry.h delete mode 100755 domx/omx_core/inc/OMX_CoreExt.h delete mode 100755 domx/omx_core/inc/OMX_Core_Wrapper.h delete mode 100755 domx/omx_core/inc/OMX_Debug.h delete mode 100755 domx/omx_core/inc/OMX_DebugMem.h delete mode 100755 domx/omx_core/inc/OMX_TI_Common.h delete mode 100755 domx/omx_core/inc/OMX_TI_Core.h delete mode 100755 domx/omx_core/inc/OMX_TI_IVCommon.h delete mode 100755 domx/omx_core/inc/OMX_TI_Image.h delete mode 100755 domx/omx_core/inc/OMX_TI_Index.h delete mode 100755 domx/omx_core/inc/OMX_TI_Video.h delete mode 100755 domx/omx_core/src/OMX_Core.c delete mode 100755 domx/omx_core/src/OMX_Core_Wrapper.c delete mode 100644 domx/omx_proxy_component/Android.mk delete mode 100755 domx/omx_proxy_component/Makefile delete mode 100755 domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c delete mode 100755 domx/omx_proxy_component/omx_h264_enc/Makefile delete mode 100644 domx/omx_proxy_component/omx_h264_enc/src/omx_proxy_h264enc.c delete mode 100644 domx/omx_proxy_component/omx_mpeg4_enc/Makefile delete mode 100644 domx/omx_proxy_component/omx_mpeg4_enc/src/omx_proxy_mpeg4enc.c delete mode 100755 domx/omx_proxy_component/omx_sample/Makefile delete mode 100755 domx/omx_proxy_component/omx_sample/src/omx_proxy_sample.c delete mode 100755 domx/omx_proxy_component/omx_video_dec/Makefile delete mode 100755 domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c delete mode 100644 domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c delete mode 100755 domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_utils.c delete mode 100644 domx/test/Makefile delete mode 100644 domx/test/sample_proxy/Makefile delete mode 100755 domx/test/sample_proxy/test_sample_proxy.c delete mode 100755 edid/Android.mk delete mode 100755 edid/cmd/parse_hdmi_edid.c delete mode 100755 edid/inc/edid_parser.h delete mode 100755 edid/lib/edid_parser.c delete mode 100755 edid/lib/edid_parser_priv.h delete mode 100755 hwc/Android.mk delete mode 100755 hwc/dock_image.c delete mode 100755 hwc/dock_image.h delete mode 100755 hwc/hal_public.h delete mode 100755 hwc/hwc.c delete mode 100755 hwc/hwc_dev.h delete mode 100755 hwc/rgz_2d.c delete mode 100755 hwc/rgz_2d.h delete mode 100755 hwc/sw_vsync.c delete mode 100755 hwc/sw_vsync.h delete mode 100755 include/camera/VideoMetadata.h delete mode 100755 include/device_perms.h delete mode 100755 include/gralloc/ti_handle_wrapper.h delete mode 100755 include/hardware/camera.h delete mode 100644 include/hardware/camera_common.h delete mode 100644 include/hardware/hwcomposer.h delete mode 100755 include/ion_ti/ion.h delete mode 100755 include/ion_ti/linux_ion.h delete mode 100755 include/ion_ti/omap_ion.h delete mode 100644 include/system/camera.h delete mode 100644 include/system/camera_vendor_tags.h delete mode 100755 kernel-headers/linux/bltsville.h delete mode 100755 kernel-headers/linux/bvblend.h delete mode 100755 kernel-headers/linux/bvbuffdesc.h delete mode 100755 kernel-headers/linux/bvcache.h delete mode 100755 kernel-headers/linux/bventry.h delete mode 100755 kernel-headers/linux/bverror.h delete mode 100755 kernel-headers/linux/bvfilter.h delete mode 100755 kernel-headers/linux/bvinternal.h delete mode 100755 kernel-headers/linux/bvsurfgeom.h delete mode 100644 kernel-headers/linux/fb.h delete mode 100755 kernel-headers/linux/ocd.h delete mode 100755 kernel-headers/linux/omap_ion.h delete mode 100755 kernel-headers/linux/omapfb.h delete mode 100755 kernel-headers/linux/rpmsg_omx.h delete mode 100755 kernel-headers/video/dsscomp.h delete mode 100755 kernel-headers/video/omap_hwc.h delete mode 100644 libcorkscrew/Android.mk delete mode 100644 libcorkscrew/corkscrew.c delete mode 100644 libcorkscrew/corkscrew.h delete mode 100755 libion_ti/Android.mk delete mode 100755 libion_ti/ion.c delete mode 100755 libion_ti/ion.h delete mode 100755 libion_ti/ion_test.c delete mode 100755 libion_ti/ion_test_2.c delete mode 100755 libion_ti/linux_ion.h delete mode 100755 libion_ti/omap_ion.h delete mode 100644 libtiutils/Android.mk delete mode 100644 libtiutils/DebugUtils.cpp delete mode 100644 libtiutils/DebugUtils.h delete mode 100644 libtiutils/ErrorUtils.cpp delete mode 100644 libtiutils/ErrorUtils.h delete mode 100644 libtiutils/MessageQueue.cpp delete mode 100644 libtiutils/MessageQueue.h delete mode 100644 libtiutils/Semaphore.cpp delete mode 100644 libtiutils/Semaphore.h delete mode 100644 libtiutils/Status.h delete mode 100644 libtiutils/UtilsCommon.h delete mode 100755 pvr-source/GPL-COPYING delete mode 100755 pvr-source/INSTALL delete mode 100755 pvr-source/MIT-COPYING delete mode 100755 pvr-source/README delete mode 100755 pvr-source/eurasiacon/build/linux2/bits.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/buildvars.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/commands.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/common/android/arch_common.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/common/android/armv7-a.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/common/android/extra_config.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/common/android/features.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/common/android/paths.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/common/android/platform_version.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/common/dridrm.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/common/omap4.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/common/opencl.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/config/core.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/defs.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/kbuild/Makefile.template delete mode 100755 pvr-source/eurasiacon/build/linux2/kbuild/external_tarball.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/kbuild/kbuild.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/kernel_module.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/kernel_version.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/moduledefs.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/modules.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/omap4430_android/Makefile delete mode 100755 pvr-source/eurasiacon/build/linux2/omap4430_android/products.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/prepare_tree.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/this_makefile.mk delete mode 100755 pvr-source/eurasiacon/build/linux2/tools/cc-check.sh delete mode 100755 pvr-source/eurasiacon/build/linux2/toplevel.mk delete mode 100755 pvr-source/include4/dbgdrvif.h delete mode 100755 pvr-source/include4/img_defs.h delete mode 100755 pvr-source/include4/img_types.h delete mode 100755 pvr-source/include4/pdumpdefs.h delete mode 100755 pvr-source/include4/pvr_debug.h delete mode 100755 pvr-source/include4/pvrmodule.h delete mode 100755 pvr-source/include4/pvrversion.h delete mode 100755 pvr-source/include4/services.h delete mode 100755 pvr-source/include4/servicesext.h delete mode 100755 pvr-source/include4/sgx_options.h delete mode 100755 pvr-source/include4/sgxapi_km.h delete mode 100755 pvr-source/include4/sgxscript.h delete mode 100755 pvr-source/services4/3rdparty/dc_nohw/Kbuild.mk delete mode 100755 pvr-source/services4/3rdparty/dc_nohw/Linux.mk delete mode 100755 pvr-source/services4/3rdparty/dc_nohw/dc_nohw.h delete mode 100755 pvr-source/services4/3rdparty/dc_nohw/dc_nohw_displayclass.c delete mode 100755 pvr-source/services4/3rdparty/dc_nohw/dc_nohw_linux.c delete mode 100755 pvr-source/services4/3rdparty/dc_omapfb3_linux/Kbuild.mk delete mode 100755 pvr-source/services4/3rdparty/dc_omapfb3_linux/Linux.mk delete mode 100755 pvr-source/services4/3rdparty/dc_omapfb3_linux/omaplfb.h delete mode 100755 pvr-source/services4/3rdparty/dc_omapfb3_linux/omaplfb_displayclass.c delete mode 100755 pvr-source/services4/3rdparty/dc_omapfb3_linux/omaplfb_linux.c delete mode 100755 pvr-source/services4/include/kernelbuffer.h delete mode 100755 pvr-source/services4/include/kerneldisplay.h delete mode 100755 pvr-source/services4/include/pdump.h delete mode 100755 pvr-source/services4/include/pvr_bridge.h delete mode 100755 pvr-source/services4/include/pvr_bridge_km.h delete mode 100755 pvr-source/services4/include/pvrmmap.h delete mode 100755 pvr-source/services4/include/pvrsrv_errors.h delete mode 100755 pvr-source/services4/include/servicesint.h delete mode 100755 pvr-source/services4/include/sgx_bridge.h delete mode 100755 pvr-source/services4/include/sgx_mkif_km.h delete mode 100755 pvr-source/services4/include/sgx_ukernel_status_codes.h delete mode 100755 pvr-source/services4/include/sgxinfo.h delete mode 100755 pvr-source/services4/srvkm/bridged/bridged_pvr_bridge.c delete mode 100755 pvr-source/services4/srvkm/bridged/bridged_pvr_bridge.h delete mode 100755 pvr-source/services4/srvkm/bridged/bridged_support.c delete mode 100755 pvr-source/services4/srvkm/bridged/bridged_support.h delete mode 100755 pvr-source/services4/srvkm/bridged/sgx/bridged_sgx_bridge.c delete mode 100755 pvr-source/services4/srvkm/bridged/sgx/bridged_sgx_bridge.h delete mode 100755 pvr-source/services4/srvkm/common/buffer_manager.c delete mode 100755 pvr-source/services4/srvkm/common/deviceclass.c delete mode 100755 pvr-source/services4/srvkm/common/deviceid.h delete mode 100755 pvr-source/services4/srvkm/common/devicemem.c delete mode 100755 pvr-source/services4/srvkm/common/handle.c delete mode 100755 pvr-source/services4/srvkm/common/hash.c delete mode 100755 pvr-source/services4/srvkm/common/lists.c delete mode 100755 pvr-source/services4/srvkm/common/mem.c delete mode 100755 pvr-source/services4/srvkm/common/mem_debug.c delete mode 100755 pvr-source/services4/srvkm/common/metrics.c delete mode 100755 pvr-source/services4/srvkm/common/osfunc_common.c delete mode 100755 pvr-source/services4/srvkm/common/pdump_common.c delete mode 100755 pvr-source/services4/srvkm/common/perproc.c delete mode 100755 pvr-source/services4/srvkm/common/power.c delete mode 100755 pvr-source/services4/srvkm/common/pvrsrv.c delete mode 100755 pvr-source/services4/srvkm/common/queue.c delete mode 100755 pvr-source/services4/srvkm/common/ra.c delete mode 100755 pvr-source/services4/srvkm/common/refcount.c delete mode 100755 pvr-source/services4/srvkm/common/resman.c delete mode 100755 pvr-source/services4/srvkm/common/ttrace.c delete mode 100755 pvr-source/services4/srvkm/devices/sgx/mmu.c delete mode 100755 pvr-source/services4/srvkm/devices/sgx/mmu.h delete mode 100755 pvr-source/services4/srvkm/devices/sgx/pb.c delete mode 100755 pvr-source/services4/srvkm/devices/sgx/sgx_bridge_km.h delete mode 100755 pvr-source/services4/srvkm/devices/sgx/sgxconfig.h delete mode 100755 pvr-source/services4/srvkm/devices/sgx/sgxinfokm.h delete mode 100755 pvr-source/services4/srvkm/devices/sgx/sgxinit.c delete mode 100755 pvr-source/services4/srvkm/devices/sgx/sgxkick.c delete mode 100755 pvr-source/services4/srvkm/devices/sgx/sgxpower.c delete mode 100755 pvr-source/services4/srvkm/devices/sgx/sgxreset.c delete mode 100755 pvr-source/services4/srvkm/devices/sgx/sgxtransfer.c delete mode 100755 pvr-source/services4/srvkm/devices/sgx/sgxutils.c delete mode 100755 pvr-source/services4/srvkm/devices/sgx/sgxutils.h delete mode 100755 pvr-source/services4/srvkm/env/linux/Kbuild.mk delete mode 100755 pvr-source/services4/srvkm/env/linux/Linux.mk delete mode 100755 pvr-source/services4/srvkm/env/linux/env_data.h delete mode 100755 pvr-source/services4/srvkm/env/linux/env_perproc.h delete mode 100755 pvr-source/services4/srvkm/env/linux/event.c delete mode 100755 pvr-source/services4/srvkm/env/linux/event.h delete mode 100755 pvr-source/services4/srvkm/env/linux/gc_bvmapping.c delete mode 100755 pvr-source/services4/srvkm/env/linux/gc_bvmapping.h delete mode 100755 pvr-source/services4/srvkm/env/linux/ion.c delete mode 100755 pvr-source/services4/srvkm/env/linux/ion.h delete mode 100755 pvr-source/services4/srvkm/env/linux/linkage.h delete mode 100755 pvr-source/services4/srvkm/env/linux/lock.h delete mode 100755 pvr-source/services4/srvkm/env/linux/mm.c delete mode 100755 pvr-source/services4/srvkm/env/linux/mm.h delete mode 100755 pvr-source/services4/srvkm/env/linux/mmap.c delete mode 100755 pvr-source/services4/srvkm/env/linux/mmap.h delete mode 100755 pvr-source/services4/srvkm/env/linux/module.c delete mode 100755 pvr-source/services4/srvkm/env/linux/mutex.c delete mode 100755 pvr-source/services4/srvkm/env/linux/mutex.h delete mode 100755 pvr-source/services4/srvkm/env/linux/mutils.c delete mode 100755 pvr-source/services4/srvkm/env/linux/mutils.h delete mode 100755 pvr-source/services4/srvkm/env/linux/osfunc.c delete mode 100755 pvr-source/services4/srvkm/env/linux/osperproc.c delete mode 100755 pvr-source/services4/srvkm/env/linux/pdump.c delete mode 100755 pvr-source/services4/srvkm/env/linux/private_data.h delete mode 100755 pvr-source/services4/srvkm/env/linux/proc.c delete mode 100755 pvr-source/services4/srvkm/env/linux/proc.h delete mode 100755 pvr-source/services4/srvkm/env/linux/pvr_bridge_k.c delete mode 100755 pvr-source/services4/srvkm/env/linux/pvr_debug.c delete mode 100755 pvr-source/services4/srvkm/env/linux/pvr_uaccess.h delete mode 100755 pvr-source/services4/srvkm/env/linux/sysfs.c delete mode 100755 pvr-source/services4/srvkm/env/linux/sysfs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/mnemedefs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/ocpdefs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgx520defs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgx530defs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgx531defs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgx535defs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgx540defs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgx543_v1.164defs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgx543defs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgx544defs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgx545defs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgxdefs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgxerrata.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgxfeaturedefs.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgxmmu.h delete mode 100755 pvr-source/services4/srvkm/hwdefs/sgxmpdefs.h delete mode 100755 pvr-source/services4/srvkm/include/buffer_manager.h delete mode 100755 pvr-source/services4/srvkm/include/device.h delete mode 100755 pvr-source/services4/srvkm/include/handle.h delete mode 100755 pvr-source/services4/srvkm/include/hash.h delete mode 100755 pvr-source/services4/srvkm/include/lists.h delete mode 100755 pvr-source/services4/srvkm/include/metrics.h delete mode 100755 pvr-source/services4/srvkm/include/osfunc.h delete mode 100755 pvr-source/services4/srvkm/include/osperproc.h delete mode 100755 pvr-source/services4/srvkm/include/pdump_int.h delete mode 100755 pvr-source/services4/srvkm/include/pdump_km.h delete mode 100755 pvr-source/services4/srvkm/include/pdump_osfunc.h delete mode 100755 pvr-source/services4/srvkm/include/perfkm.h delete mode 100755 pvr-source/services4/srvkm/include/perproc.h delete mode 100755 pvr-source/services4/srvkm/include/power.h delete mode 100755 pvr-source/services4/srvkm/include/queue.h delete mode 100755 pvr-source/services4/srvkm/include/ra.h delete mode 100755 pvr-source/services4/srvkm/include/refcount.h delete mode 100755 pvr-source/services4/srvkm/include/resman.h delete mode 100755 pvr-source/services4/srvkm/include/services_headers.h delete mode 100755 pvr-source/services4/srvkm/include/srvkm.h delete mode 100755 pvr-source/services4/srvkm/include/ttrace.h delete mode 100755 pvr-source/services4/srvkm/include/ttrace_common.h delete mode 100755 pvr-source/services4/srvkm/include/ttrace_tokens.h delete mode 100755 pvr-source/services4/system/include/syscommon.h delete mode 100755 pvr-source/services4/system/omap4/oemfuncs.h delete mode 100755 pvr-source/services4/system/omap4/sgxfreq.c delete mode 100755 pvr-source/services4/system/omap4/sgxfreq.h delete mode 100755 pvr-source/services4/system/omap4/sgxfreq_activeidle.c delete mode 100755 pvr-source/services4/system/omap4/sgxfreq_cool.c delete mode 100755 pvr-source/services4/system/omap4/sgxfreq_on3demand.c delete mode 100755 pvr-source/services4/system/omap4/sgxfreq_onoff.c delete mode 100755 pvr-source/services4/system/omap4/sgxfreq_userspace.c delete mode 100755 pvr-source/services4/system/omap4/sysconfig.c delete mode 100755 pvr-source/services4/system/omap4/sysconfig.h delete mode 100755 pvr-source/services4/system/omap4/sysinfo.h delete mode 100755 pvr-source/services4/system/omap4/syslocal.h delete mode 100755 pvr-source/services4/system/omap4/sysutils.c delete mode 100755 pvr-source/services4/system/omap4/sysutils_linux.c delete mode 100755 pvr-source/tools/intern/debug/client/linuxsrv.h delete mode 100755 pvr-source/tools/intern/debug/dbgdriv/Kbuild.mk delete mode 100755 pvr-source/tools/intern/debug/dbgdriv/Linux.mk delete mode 100755 pvr-source/tools/intern/debug/dbgdriv/common/dbgdriv.c delete mode 100755 pvr-source/tools/intern/debug/dbgdriv/common/dbgdriv.h delete mode 100755 pvr-source/tools/intern/debug/dbgdriv/common/dbgdriv_ioctl.h delete mode 100755 pvr-source/tools/intern/debug/dbgdriv/common/handle.c delete mode 100755 pvr-source/tools/intern/debug/dbgdriv/common/hostfunc.h delete mode 100755 pvr-source/tools/intern/debug/dbgdriv/common/hotkey.c delete mode 100755 pvr-source/tools/intern/debug/dbgdriv/common/hotkey.h delete mode 100755 pvr-source/tools/intern/debug/dbgdriv/common/ioctl.c delete mode 100755 pvr-source/tools/intern/debug/dbgdriv/linux/hostfunc.c delete mode 100755 pvr-source/tools/intern/debug/dbgdriv/linux/main.c delete mode 100644 pvrsrvinit/Android.mk delete mode 100644 pvrsrvinit/pvrsrvinit.c delete mode 100755 symlinks/Android.mk diff --git a/Android.mk b/Android.mk index c724383..0e3f37d 100755 --- a/Android.mk +++ b/Android.mk @@ -44,21 +44,6 @@ $(LOCAL_BUILT_MODULE): $(hide) ln -sf $(HDCP_KEYS_FILE) $(SYMLINK) $(hide) touch $@ - -#Creating Gralloc SymLink -GRALLOC_SYMLINK := $(TARGET_OUT_VENDOR)/lib/hw/gralloc.$(TARGET_BOARD_PLATFORM).so -$(GRALLOC_SYMLINK): GRALLOC_FILE := gralloc.omap$(TARGET_BOARD_OMAP_CPU).so -$(GRALLOC_SYMLINK): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk - @echo "Symlink: $@ -> $(GRALLOC_FILE)" - @mkdir -p $(TARGET_OUT_VENDOR)/lib/hw - @rm -rf $@ - $(hide) ln -fs $(GRALLOC_FILE) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(GRALLOC_SYMLINK) - -# for mm/mmm -all_modules: $(GRALLOC_SYMLINK) - include $(call all-makefiles-under,$(LOCAL_PATH)) endif diff --git a/camera/ANativeWindowDisplayAdapter.cpp b/camera/ANativeWindowDisplayAdapter.cpp deleted file mode 100644 index f144327..0000000 --- a/camera/ANativeWindowDisplayAdapter.cpp +++ /dev/null @@ -1,1345 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ANativeWindowDisplayAdapter.h" -#include -#include -#include -#include - -namespace Ti { -namespace Camera { - -///Constant declarations -///@todo Check the time units -const int ANativeWindowDisplayAdapter::DISPLAY_TIMEOUT = 1000; // seconds - -//Suspends buffers after given amount of failed dq's -const int ANativeWindowDisplayAdapter::FAILED_DQS_TO_SUSPEND = 3; - - -OMX_COLOR_FORMATTYPE toOMXPixFormat(const char* parameters_format) -{ - OMX_COLOR_FORMATTYPE pixFormat; - - if ( parameters_format != NULL ) - { - if (strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) - { - CAMHAL_LOGDA("CbYCrY format selected"); - pixFormat = OMX_COLOR_FormatCbYCrY; - } - else if(strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) - { - CAMHAL_LOGDA("YUV420SP format selected"); - pixFormat = OMX_COLOR_FormatYUV420SemiPlanar; - } - else if(strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_RGB565) == 0) - { - CAMHAL_LOGDA("RGB565 format selected"); - pixFormat = OMX_COLOR_Format16bitRGB565; - } - else - { - CAMHAL_LOGDA("Invalid format, NV12 format selected as default"); - pixFormat = OMX_COLOR_FormatYUV420SemiPlanar; - } - } - else { - CAMHAL_LOGEA("Preview format is NULL, defaulting to NV12"); - pixFormat = OMX_COLOR_FormatYUV420SemiPlanar; - } - - return pixFormat; -} - -const char* DisplayAdapter::getPixFormatConstant(const char* parameters_format) const -{ - const char* pixFormat; - - if ( parameters_format != NULL ) - { - if (strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) - { - CAMHAL_LOGVA("CbYCrY format selected"); - pixFormat = android::CameraParameters::PIXEL_FORMAT_YUV422I; - } - else if(strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0 || - strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_YUV420P) == 0) - { - // TODO(XXX): We are treating YV12 the same as YUV420SP - CAMHAL_LOGVA("YUV420SP format selected"); - pixFormat = android::CameraParameters::PIXEL_FORMAT_YUV420SP; - } - else if(strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_RGB565) == 0) - { - CAMHAL_LOGVA("RGB565 format selected"); - pixFormat = android::CameraParameters::PIXEL_FORMAT_RGB565; - } - else if(strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB) == 0) - { - CAMHAL_LOGVA("BAYER format selected"); - pixFormat = android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB; - } - else - { - CAMHAL_LOGEA("Invalid format, NV12 format selected as default"); - pixFormat = android::CameraParameters::PIXEL_FORMAT_YUV420SP; - } - } - else - { - CAMHAL_LOGEA("Preview format is NULL, defaulting to NV12"); - pixFormat = android::CameraParameters::PIXEL_FORMAT_YUV420SP; - } - - return pixFormat; -} - -size_t DisplayAdapter::getBufSize(const char* parameters_format, int width, int height) const -{ - int buf_size; - - if ( parameters_format != NULL ) { - if (strcmp(parameters_format, - android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { - buf_size = width * height * 2; - } - else if((strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) || - (strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_YUV420P) == 0)) { - buf_size = width * height * 3 / 2; - } - else if(strcmp(parameters_format, - android::CameraParameters::PIXEL_FORMAT_RGB565) == 0) { - buf_size = width * height * 2; - } - else if (strcmp(parameters_format, - android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB) == 0) { - buf_size = width * height * 2; - } else { - CAMHAL_LOGEA("Invalid format"); - buf_size = 0; - } - } else { - CAMHAL_LOGEA("Preview format is NULL"); - buf_size = 0; - } - - return buf_size; -} -/*--------------------ANativeWindowDisplayAdapter Class STARTS here-----------------------------*/ - - -/** - * Display Adapter class STARTS here.. - */ -ANativeWindowDisplayAdapter::ANativeWindowDisplayAdapter():mDisplayThread(NULL), - mDisplayState(ANativeWindowDisplayAdapter::DISPLAY_INIT), - mDisplayEnabled(false), - mBufferCount(0) - - - -{ - LOG_FUNCTION_NAME; - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - mShotToShot = false; - mStartCapture.tv_sec = 0; - mStartCapture.tv_usec = 0; - mStandbyToShot.tv_sec = 0; - mStandbyToShot.tv_usec = 0; - mMeasureStandby = false; -#endif - - mPixelFormat = NULL; - mBuffers = NULL; - mOffsetsMap = NULL; - mFrameProvider = NULL; - mANativeWindow = NULL; - - mFrameWidth = 0; - mFrameHeight = 0; - mPreviewWidth = 0; - mPreviewHeight = 0; - - mSuspend = false; - mFailedDQs = 0; - - mPaused = false; - mXOff = -1; - mYOff = -1; - mFirstInit = false; - - mFD = -1; - - LOG_FUNCTION_NAME_EXIT; -} - -ANativeWindowDisplayAdapter::~ANativeWindowDisplayAdapter() -{ - Utils::Semaphore sem; - Utils::Message msg; - - LOG_FUNCTION_NAME; - - ///If Frame provider exists - if (mFrameProvider) { - // Unregister with the frame provider - mFrameProvider->disableFrameNotification(CameraFrame::ALL_FRAMES); - delete mFrameProvider; - mFrameProvider = NULL; - } - - ///The ANativeWindow object will get destroyed here - destroy(); - - ///If Display thread exists - if(mDisplayThread.get()) - { - ///Kill the display thread - sem.Create(); - msg.command = DisplayThread::DISPLAY_EXIT; - - // Send the semaphore to signal once the command is completed - msg.arg1 = &sem; - - ///Post the message to display thread - mDisplayThread->msgQ().put(&msg); - - ///Wait for the ACK - implies that the thread is now started and waiting for frames - sem.Wait(); - - // Exit and cleanup the thread - mDisplayThread->requestExitAndWait(); - - // Delete the display thread - mDisplayThread.clear(); - } - - LOG_FUNCTION_NAME_EXIT; - -} - -status_t ANativeWindowDisplayAdapter::initialize() -{ - LOG_FUNCTION_NAME; - - ///Create the display thread - mDisplayThread = new DisplayThread(this); - if ( !mDisplayThread.get() ) - { - CAMHAL_LOGEA("Couldn't create display thread"); - LOG_FUNCTION_NAME_EXIT; - return NO_MEMORY; - } - - ///Start the display thread - status_t ret = mDisplayThread->run("DisplayThread", android::PRIORITY_URGENT_DISPLAY); - if ( ret != NO_ERROR ) - { - CAMHAL_LOGEA("Couldn't run display thread"); - LOG_FUNCTION_NAME_EXIT; - return ret; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -int ANativeWindowDisplayAdapter::setPreviewWindow(preview_stream_ops_t* window) -{ - LOG_FUNCTION_NAME; - ///Note that Display Adapter cannot work without a valid window object - if ( !window) - { - CAMHAL_LOGEA("NULL window object passed to DisplayAdapter"); - LOG_FUNCTION_NAME_EXIT; - return BAD_VALUE; - } - - if ( window == mANativeWindow ) { - return ALREADY_EXISTS; - } - - ///Destroy the existing window object, if it exists - destroy(); - - ///Move to new window obj - mANativeWindow = window; - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -int ANativeWindowDisplayAdapter::setFrameProvider(FrameNotifier *frameProvider) -{ - LOG_FUNCTION_NAME; - - // Check for NULL pointer - if ( !frameProvider ) { - CAMHAL_LOGEA("NULL passed for frame provider"); - LOG_FUNCTION_NAME_EXIT; - return BAD_VALUE; - } - - //Release any previous frame providers - if ( NULL != mFrameProvider ) { - delete mFrameProvider; - } - - /** Dont do anything here, Just save the pointer for use when display is - actually enabled or disabled - */ - mFrameProvider = new FrameProvider(frameProvider, this, frameCallbackRelay); - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -int ANativeWindowDisplayAdapter::setErrorHandler(ErrorNotifier *errorNotifier) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( NULL == errorNotifier ) { - CAMHAL_LOGEA("Invalid Error Notifier reference"); - ret = BAD_VALUE; - } - - if ( NO_ERROR == ret ) - { - mErrorNotifier = errorNotifier; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - -status_t ANativeWindowDisplayAdapter::setSnapshotTimeRef(struct timeval *refTime) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( NULL != refTime ) - { - android::AutoMutex lock(mLock); - memcpy(&mStartCapture, refTime, sizeof(struct timeval)); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -#endif - - -int ANativeWindowDisplayAdapter::enableDisplay(int width, int height, struct timeval *refTime) -{ - Utils::Semaphore sem; - Utils::Message msg; - - LOG_FUNCTION_NAME; - - if ( mDisplayEnabled ) - { - CAMHAL_LOGDA("Display is already enabled"); - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; - } - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - if ( NULL != refTime ) - { - android::AutoMutex lock(mLock); - memcpy(&mStandbyToShot, refTime, sizeof(struct timeval)); - mMeasureStandby = true; - } - -#endif - - //Send START_DISPLAY COMMAND to display thread. Display thread will start and then wait for a message - sem.Create(); - msg.command = DisplayThread::DISPLAY_START; - - // Send the semaphore to signal once the command is completed - msg.arg1 = &sem; - - ///Post the message to display thread - mDisplayThread->msgQ().put(&msg); - - ///Wait for the ACK - implies that the thread is now started and waiting for frames - sem.Wait(); - - // Register with the frame provider for frames - mFrameProvider->enableFrameNotification(CameraFrame::PREVIEW_FRAME_SYNC); - mFrameProvider->enableFrameNotification(CameraFrame::SNAPSHOT_FRAME); - - mDisplayEnabled = true; - mPreviewWidth = width; - mPreviewHeight = height; - - CAMHAL_LOGVB("mPreviewWidth = %d mPreviewHeight = %d", mPreviewWidth, mPreviewHeight); - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -int ANativeWindowDisplayAdapter::disableDisplay(bool cancel_buffer) -{ - status_t ret = NO_ERROR; - android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get(); - - LOG_FUNCTION_NAME; - - if(!mDisplayEnabled) - { - CAMHAL_LOGDA("Display is already disabled"); - LOG_FUNCTION_NAME_EXIT; - return ALREADY_EXISTS; - } - - // Unregister with the frame provider here - mFrameProvider->disableFrameNotification(CameraFrame::PREVIEW_FRAME_SYNC); - mFrameProvider->disableFrameNotification(CameraFrame::SNAPSHOT_FRAME); - mFrameProvider->removeFramePointers(); - - if ( NULL != mDisplayThread.get() ) - { - //Send STOP_DISPLAY COMMAND to display thread. Display thread will stop and dequeue all messages - // and then wait for message - Utils::Semaphore sem; - sem.Create(); - Utils::Message msg; - msg.command = DisplayThread::DISPLAY_STOP; - - // Send the semaphore to signal once the command is completed - msg.arg1 = &sem; - - ///Post the message to display thread - mDisplayThread->msgQ().put(&msg); - - ///Wait for the ACK for display to be disabled - - sem.Wait(); - - } - - android::AutoMutex lock(mLock); - { - ///Reset the display enabled flag - mDisplayEnabled = false; - - // Reset pause flag since display is being disabled - mPaused = false; - - ///Reset the offset values - mXOff = -1; - mYOff = -1; - - ///Reset the frame width and height values - mFrameWidth =0; - mFrameHeight = 0; - mPreviewWidth = 0; - mPreviewHeight = 0; - - if(cancel_buffer) - { - // Return the buffers to ANativeWindow here, the mFramesWithCameraAdapterMap is also cleared inside - returnBuffersToWindow(); - } - else - { - mANativeWindow = NULL; - // Clear the frames with camera adapter map - mFramesWithCameraAdapterMap.clear(); - } - - - } - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -status_t ANativeWindowDisplayAdapter::pauseDisplay(bool pause) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - { - android::AutoMutex lock(mLock); - mPaused = pause; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - - -void ANativeWindowDisplayAdapter::destroy() -{ - LOG_FUNCTION_NAME; - - ///Check if the display is disabled, if not disable it - if ( mDisplayEnabled ) - { - CAMHAL_LOGDA("WARNING: Calling destroy of Display adapter when display enabled. Disabling display.."); - disableDisplay(false); - } - - mBufferCount = 0; - - LOG_FUNCTION_NAME_EXIT; -} - -// Implementation of inherited interfaces -CameraBuffer* ANativeWindowDisplayAdapter::allocateBufferList(int width, int height, const char* format, int &bytes, int numBufs) -{ - LOG_FUNCTION_NAME; - status_t err; - int i = -1; - const int lnumBufs = numBufs; - int undequeued = 0; - android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get(); - android::Rect bounds; - - mBuffers = new CameraBuffer [lnumBufs]; - memset (mBuffers, 0, sizeof(CameraBuffer) * lnumBufs); - - mFramesType.clear(); - - if ( NULL == mANativeWindow ) { - return NULL; - } - - // Set gralloc usage bits for window. - err = mANativeWindow->set_usage(mANativeWindow, CAMHAL_GRALLOC_USAGE); - if ( NO_ERROR != err ) { - CAMHAL_LOGE("Surface::setUsage failed: %s (%d)", strerror(-err), -err); - - if ( NO_INIT == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mANativeWindow = NULL; - } - - return NULL; - } - - CAMHAL_LOGDB("Number of buffers set to ANativeWindow %d", numBufs); - ///Set the number of buffers needed for camera preview - err = mANativeWindow->set_buffer_count(mANativeWindow, numBufs); - if ( NO_ERROR != err ) { - CAMHAL_LOGE("Surface::setBufferCount failed: %s (%d)", strerror(-err), -err); - - if ( NO_INIT == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mANativeWindow = NULL; - } - - return NULL; - } - CAMHAL_LOGDB("Configuring %d buffers for ANativeWindow", numBufs); - mBufferCount = numBufs; - - - // Set window geometry - err = mANativeWindow->set_buffers_geometry( - mANativeWindow, - width, - height, - /*toOMXPixFormat(format)*/HAL_PIXEL_FORMAT_TI_NV12); // Gralloc only supports NV12 alloc! - - if ( NO_ERROR != err ) { - CAMHAL_LOGE("native_window_set_buffers_geometry failed: %s (%d)", strerror(-err), -err); - - if ( NO_INIT == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mANativeWindow = NULL; - } - - return NULL; - } - - ///We just return the buffers from ANativeWindow, if the width and height are same, else (vstab, vnf case) - ///re-allocate buffers using ANativeWindow and then get them - ///@todo - Re-allocate buffers for vnf and vstab using the width, height, format, numBufs etc - if ( mBuffers == NULL ) - { - CAMHAL_LOGEA("Couldn't create array for ANativeWindow buffers"); - LOG_FUNCTION_NAME_EXIT; - return NULL; - } - - mANativeWindow->get_min_undequeued_buffer_count(mANativeWindow, &undequeued); - - for ( i=0; i < mBufferCount; i++ ) - { - buffer_handle_t *handle; - int stride; // dummy variable to get stride - // TODO(XXX): Do we need to keep stride information in camera hal? - - err = mANativeWindow->dequeue_buffer(mANativeWindow, &handle, &stride); - - if ( NO_ERROR != err ) { - CAMHAL_LOGE("Surface::dequeueBuffer failed: %s (%d)", strerror(-err), -err); - - if ( NO_INIT == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mANativeWindow = NULL; - } - - goto fail; - } - - CAMHAL_LOGDB("got handle %p", handle); - mBuffers[i].opaque = (void *)handle; - mBuffers[i].type = CAMERA_BUFFER_ANW; - mFramesWithCameraAdapterMap.add(handle, i); - - // Tag remaining preview buffers as preview frames - if ( i >= ( mBufferCount - undequeued ) ) { - mFramesType.add( (int) mBuffers[i].opaque, - CameraFrame::PREVIEW_FRAME_SYNC); - } - - bytes = getBufSize(format, width, height); - - } - - // lock the initial queueable buffers - bounds.left = 0; - bounds.top = 0; - bounds.right = width; - bounds.bottom = height; - - for( i = 0; i < mBufferCount-undequeued; i++ ) - { - void *y_uv[2]; - buffer_handle_t *handle = (buffer_handle_t *) mBuffers[i].opaque; - - mANativeWindow->lock_buffer(mANativeWindow, handle); - - mapper.lock(*handle, CAMHAL_GRALLOC_USAGE, bounds, y_uv); - mBuffers[i].mapped = y_uv[0]; - mFrameProvider->addFramePointers(&mBuffers[i], y_uv); - } - - // return the rest of the buffers back to ANativeWindow - for(i = (mBufferCount-undequeued); i >= 0 && i < mBufferCount; i++) - { - buffer_handle_t *handle = (buffer_handle_t *) mBuffers[i].opaque; - err = mANativeWindow->cancel_buffer(mANativeWindow, handle); - if ( NO_ERROR != err ) { - CAMHAL_LOGE("Surface::cancelBuffer failed: %s (%d)", strerror(-err), -err); - - if ( NO_INIT == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mANativeWindow = NULL; - } - - goto fail; - } - mFramesWithCameraAdapterMap.removeItem((buffer_handle_t *) mBuffers[i].opaque); - //LOCK UNLOCK TO GET YUV POINTERS - void *y_uv[2]; - mapper.lock(*(buffer_handle_t *) mBuffers[i].opaque, CAMHAL_GRALLOC_USAGE, bounds, y_uv); - mBuffers[i].mapped = y_uv[0]; - mFrameProvider->addFramePointers(&mBuffers[i], y_uv); - mapper.unlock(*(buffer_handle_t *) mBuffers[i].opaque); - } - - mFirstInit = true; - mPixelFormat = getPixFormatConstant(format); - mFrameWidth = width; - mFrameHeight = height; - - return mBuffers; - - fail: - // need to cancel buffers if any were dequeued - for (int start = 0; start < i && i > 0; start++) { - status_t err = mANativeWindow->cancel_buffer(mANativeWindow, - (buffer_handle_t *) mBuffers[start].opaque); - if ( NO_ERROR != err ) { - CAMHAL_LOGE("Surface::cancelBuffer failed w/ error 0x%08x", err); - break; - } - mFramesWithCameraAdapterMap.removeItem((buffer_handle_t *) mBuffers[start].opaque); - } - - freeBufferList(mBuffers); - - CAMHAL_LOGEA("Error occurred, performing cleanup"); - - if ( NULL != mErrorNotifier.get() ) { - mErrorNotifier->errorNotify(NO_MEMORY); - } - - LOG_FUNCTION_NAME_EXIT; - return NULL; - -} - -CameraBuffer* ANativeWindowDisplayAdapter::getBufferList(int *numBufs) { - LOG_FUNCTION_NAME; - if (numBufs) *numBufs = -1; - - return NULL; -} - -uint32_t * ANativeWindowDisplayAdapter::getOffsets() -{ - const int lnumBufs = mBufferCount; - - LOG_FUNCTION_NAME; - - // TODO(XXX): Need to remove getOffsets from the API. No longer needed - - if ( NULL == mANativeWindow ) - { - CAMHAL_LOGEA("mANativeWindow reference is missing"); - goto fail; - } - - if( mBuffers == NULL) - { - CAMHAL_LOGEA("Buffers not allocated yet!!"); - goto fail; - } - - if(mOffsetsMap == NULL) - { - mOffsetsMap = new uint32_t[lnumBufs]; - for(int i = 0; i < mBufferCount; i++) - { - mOffsetsMap[i] = 0; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return mOffsetsMap; - - fail: - - if ( NULL != mOffsetsMap ) - { - delete [] mOffsetsMap; - mOffsetsMap = NULL; - } - - if ( NULL != mErrorNotifier.get() ) { - mErrorNotifier->errorNotify(INVALID_OPERATION); - } - - LOG_FUNCTION_NAME_EXIT; - - return NULL; -} - -status_t ANativeWindowDisplayAdapter::minUndequeueableBuffers(int& undequeueable) { - LOG_FUNCTION_NAME; - status_t ret = NO_ERROR; - - if(!mANativeWindow) { - ret = INVALID_OPERATION; - goto end; - } - - ret = mANativeWindow->get_min_undequeued_buffer_count(mANativeWindow, &undequeueable); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("get_min_undequeued_buffer_count failed: %s (%d)", strerror(-ret), -ret); - - if ( NO_INIT == ret ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mANativeWindow = NULL; - } - - return ret; - } - - end: - return ret; - LOG_FUNCTION_NAME_EXIT; - -} - -status_t ANativeWindowDisplayAdapter::maxQueueableBuffers(unsigned int& queueable) -{ - LOG_FUNCTION_NAME; - status_t ret = NO_ERROR; - int undequeued = 0; - - if(mBufferCount == 0) - { - ret = INVALID_OPERATION; - goto end; - } - - ret = minUndequeueableBuffers(undequeued); - if (ret != NO_ERROR) { - goto end; - } - - queueable = mBufferCount - undequeued; - - end: - return ret; - LOG_FUNCTION_NAME_EXIT; -} - -int ANativeWindowDisplayAdapter::getFd() -{ - LOG_FUNCTION_NAME; - - if(mFD == -1) - { - buffer_handle_t *handle = (buffer_handle_t *)mBuffers[0].opaque; - IMG_native_handle_t *img = (IMG_native_handle_t *)handle; - // TODO: should we dup the fd? not really necessary and another thing for ANativeWindow - // to manage and close... - - mFD = dup(img->fd[0]); - } - - LOG_FUNCTION_NAME_EXIT; - - return mFD; - -} - -status_t ANativeWindowDisplayAdapter::returnBuffersToWindow() -{ - status_t ret = NO_ERROR; - - android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get(); - //Give the buffers back to display here - sort of free it - if (mANativeWindow) - for(unsigned int i = 0; i < mFramesWithCameraAdapterMap.size(); i++) { - int value = mFramesWithCameraAdapterMap.valueAt(i); - buffer_handle_t *handle = (buffer_handle_t *) mBuffers[value].opaque; - - // if buffer index is out of bounds skip - if ((value < 0) || (value >= mBufferCount)) { - CAMHAL_LOGEA("Potential out bounds access to handle...skipping"); - continue; - } - - // unlock buffer before giving it up - mapper.unlock(*handle); - - ret = mANativeWindow->cancel_buffer(mANativeWindow, handle); - if ( NO_INIT == ret ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mANativeWindow = NULL; - return ret; - } else if ( NO_ERROR != ret ) { - CAMHAL_LOGE("Surface::cancelBuffer() failed: %s (%d)", - strerror(-ret), - -ret); - return ret; - } - } - else - CAMHAL_LOGE("mANativeWindow is NULL"); - - ///Clear the frames with camera adapter map - mFramesWithCameraAdapterMap.clear(); - - return ret; - -} - -int ANativeWindowDisplayAdapter::freeBufferList(CameraBuffer * buflist) -{ - LOG_FUNCTION_NAME; - - status_t ret = NO_ERROR; - - android::AutoMutex lock(mLock); - - if(mBuffers != buflist) - { - CAMHAL_LOGEA("CameraHal passed wrong set of buffers to free!!!"); - if (mBuffers != NULL) - delete []mBuffers; - mBuffers = NULL; - } - - /* FIXME this will probably want the list that was just deleted */ - returnBuffersToWindow(); - - if ( NULL != buflist ) - { - delete [] buflist; - mBuffers = NULL; - } - - if( mBuffers != NULL) - { - delete [] mBuffers; - mBuffers = NULL; - } - - if ( NULL != mOffsetsMap ) - { - delete [] mOffsetsMap; - mOffsetsMap = NULL; - } - - if( mFD != -1) - { - close(mFD); // close duped handle - mFD = -1; - } - - mFramesType.clear(); - - return NO_ERROR; -} - - -bool ANativeWindowDisplayAdapter::supportsExternalBuffering() -{ - return false; -} - -void ANativeWindowDisplayAdapter::displayThread() -{ - bool shouldLive = true; - int timeout = 0; - status_t ret; - - LOG_FUNCTION_NAME; - - while(shouldLive) - { - ret = Utils::MessageQueue::waitForMsg(&mDisplayThread->msgQ() - , &mDisplayQ - , NULL - , ANativeWindowDisplayAdapter::DISPLAY_TIMEOUT); - - if ( !mDisplayThread->msgQ().isEmpty() ) - { - ///Received a message from CameraHal, process it - shouldLive = processHalMsg(); - - } - else if( !mDisplayQ.isEmpty()) - { - if ( mDisplayState== ANativeWindowDisplayAdapter::DISPLAY_INIT ) - { - - ///If display adapter is not started, continue - continue; - - } - else - { - Utils::Message msg; - ///Get the dummy msg from the displayQ - if(mDisplayQ.get(&msg)!=NO_ERROR) - { - CAMHAL_LOGEA("Error in getting message from display Q"); - continue; - } - - // There is a frame from ANativeWindow for us to dequeue - // We dequeue and return the frame back to Camera adapter - if(mDisplayState == ANativeWindowDisplayAdapter::DISPLAY_STARTED) - { - handleFrameReturn(); - } - - if (mDisplayState == ANativeWindowDisplayAdapter::DISPLAY_EXITED) - { - ///we exit the thread even though there are frames still to dequeue. They will be dequeued - ///in disableDisplay - shouldLive = false; - } - } - } - } - - LOG_FUNCTION_NAME_EXIT; -} - - -bool ANativeWindowDisplayAdapter::processHalMsg() -{ - Utils::Message msg; - - LOG_FUNCTION_NAME; - - - mDisplayThread->msgQ().get(&msg); - bool ret = true, invalidCommand = false; - - switch ( msg.command ) - { - - case DisplayThread::DISPLAY_START: - - CAMHAL_LOGDA("Display thread received DISPLAY_START command from Camera HAL"); - mDisplayState = ANativeWindowDisplayAdapter::DISPLAY_STARTED; - - break; - - case DisplayThread::DISPLAY_STOP: - - ///@bug There is no API to disable SF without destroying it - ///@bug Buffers might still be w/ display and will get displayed - ///@remarks Ideal seqyence should be something like this - ///mOverlay->setParameter("enabled", false); - CAMHAL_LOGDA("Display thread received DISPLAY_STOP command from Camera HAL"); - mDisplayState = ANativeWindowDisplayAdapter::DISPLAY_STOPPED; - - // flush frame message queue - while ( !mDisplayQ.isEmpty() ) { - Utils::Message message; - mDisplayQ.get(&message); - } - - break; - - case DisplayThread::DISPLAY_EXIT: - - CAMHAL_LOGDA("Display thread received DISPLAY_EXIT command from Camera HAL."); - CAMHAL_LOGDA("Stopping display thread..."); - mDisplayState = ANativeWindowDisplayAdapter::DISPLAY_EXITED; - ///Note that the SF can have pending buffers when we disable the display - ///This is normal and the expectation is that they may not be displayed. - ///This is to ensure that the user experience is not impacted - ret = false; - break; - - default: - - CAMHAL_LOGEB("Invalid Display Thread Command 0x%x.", msg.command); - invalidCommand = true; - - break; - } - - ///Signal the semaphore if it is sent as part of the message - if ( ( msg.arg1 ) && ( !invalidCommand ) ) - { - - CAMHAL_LOGDA("+Signalling display semaphore"); - Utils::Semaphore &sem = *((Utils::Semaphore*)msg.arg1); - - sem.Signal(); - - CAMHAL_LOGDA("-Signalling display semaphore"); - } - - - LOG_FUNCTION_NAME_EXIT; - return ret; -} - - -status_t ANativeWindowDisplayAdapter::PostFrame(ANativeWindowDisplayAdapter::DisplayFrame &dispFrame) -{ - status_t ret = NO_ERROR; - uint32_t actualFramesWithDisplay = 0; - android_native_buffer_t *buffer = NULL; - android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get(); - int i; - - ///@todo Do cropping based on the stabilized frame coordinates - ///@todo Insert logic to drop frames here based on refresh rate of - ///display or rendering rate whichever is lower - ///Queue the buffer to overlay - - if ( NULL == mANativeWindow ) { - return NO_INIT; - } - - if (!mBuffers || !dispFrame.mBuffer) { - CAMHAL_LOGEA("NULL sent to PostFrame"); - return BAD_VALUE; - } - - for ( i = 0; i < mBufferCount; i++ ) - { - if ( dispFrame.mBuffer == &mBuffers[i] ) - { - break; - } - } - - - android::AutoMutex lock(mLock); - - mFramesType.add( (int)mBuffers[i].opaque, dispFrame.mType); - - if ( mDisplayState == ANativeWindowDisplayAdapter::DISPLAY_STARTED && - (!mPaused || CameraFrame::CameraFrame::SNAPSHOT_FRAME == dispFrame.mType) && - !mSuspend) - { - uint32_t xOff = (dispFrame.mOffset% PAGE_SIZE); - uint32_t yOff = (dispFrame.mOffset / PAGE_SIZE); - - // Set crop only if current x and y offsets do not match with frame offsets - if((mXOff!=xOff) || (mYOff!=yOff)) - { - CAMHAL_LOGDB("Offset %d xOff = %d, yOff = %d", dispFrame.mOffset, xOff, yOff); - uint8_t bytesPerPixel; - ///Calculate bytes per pixel based on the pixel format - if(strcmp(mPixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) - { - bytesPerPixel = 2; - } - else if(strcmp(mPixelFormat, android::CameraParameters::PIXEL_FORMAT_RGB565) == 0) - { - bytesPerPixel = 2; - } - else if(strcmp(mPixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) - { - bytesPerPixel = 1; - } - else - { - bytesPerPixel = 1; - } - - CAMHAL_LOGVB(" crop.left = %d crop.top = %d crop.right = %d crop.bottom = %d", - xOff/bytesPerPixel, yOff , (xOff/bytesPerPixel)+mPreviewWidth, yOff+mPreviewHeight); - // We'll ignore any errors here, if the surface is - // already invalid, we'll know soon enough. - mANativeWindow->set_crop(mANativeWindow, xOff/bytesPerPixel, yOff, - (xOff/bytesPerPixel)+mPreviewWidth, yOff+mPreviewHeight); - - ///Update the current x and y offsets - mXOff = xOff; - mYOff = yOff; - } - - { - buffer_handle_t *handle = (buffer_handle_t *) mBuffers[i].opaque; - // unlock buffer before sending to display - mapper.unlock(*handle); - ret = mANativeWindow->enqueue_buffer(mANativeWindow, handle); - } - if ( NO_ERROR != ret ) { - CAMHAL_LOGE("Surface::queueBuffer returned error %d", ret); - } - - mFramesWithCameraAdapterMap.removeItem((buffer_handle_t *) dispFrame.mBuffer->opaque); - - - // HWComposer has not minimum buffer requirement. We should be able to dequeue - // the buffer immediately - Utils::Message msg; - mDisplayQ.put(&msg); - - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - if ( mMeasureStandby ) - { - CameraHal::PPM("Standby to first shot: Sensor Change completed - ", &mStandbyToShot); - mMeasureStandby = false; - } - else if (CameraFrame::CameraFrame::SNAPSHOT_FRAME == dispFrame.mType) - { - CameraHal::PPM("Shot to snapshot: ", &mStartCapture); - mShotToShot = true; - } - else if ( mShotToShot ) - { - CameraHal::PPM("Shot to shot: ", &mStartCapture); - mShotToShot = false; - } -#endif - - } - else - { - buffer_handle_t *handle = (buffer_handle_t *) mBuffers[i].opaque; - - // unlock buffer before giving it up - mapper.unlock(*handle); - - // cancel buffer and dequeue another one - ret = mANativeWindow->cancel_buffer(mANativeWindow, handle); - if ( NO_ERROR != ret ) { - CAMHAL_LOGE("Surface::cancelBuffer returned error %d", ret); - } - - mFramesWithCameraAdapterMap.removeItem((buffer_handle_t *) dispFrame.mBuffer->opaque); - - Utils::Message msg; - mDisplayQ.put(&msg); - ret = NO_ERROR; - } - - return ret; -} - - -bool ANativeWindowDisplayAdapter::handleFrameReturn() -{ - status_t err; - buffer_handle_t *buf; - int i = 0; - unsigned int k; - int stride; // dummy variable to get stride - android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get(); - android::Rect bounds; - CameraFrame::FrameType frameType = CameraFrame::PREVIEW_FRAME_SYNC; - - void *y_uv[2]; - - // TODO(XXX): Do we need to keep stride information in camera hal? - - if ( NULL == mANativeWindow ) { - return false; - } - - err = mANativeWindow->dequeue_buffer(mANativeWindow, &buf, &stride); - if (err != 0) { - CAMHAL_LOGE("Surface::dequeueBuffer failed: %s (%d)", strerror(-err), -err); - - if ( NO_INIT == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mANativeWindow = NULL; - } - - return false; - } - - err = mANativeWindow->lock_buffer(mANativeWindow, buf); - if ( NO_ERROR != err ) { - CAMHAL_LOGE("Surface::lockBuffer failed: %s (%d)", strerror(-err), -err); - - if ( NO_INIT == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mANativeWindow = NULL; - } - - return false; - } - - for(i = 0; i < mBufferCount; i++) - { - if (mBuffers[i].opaque == buf) - break; - } - if (i == mBufferCount) { - CAMHAL_LOGEB("Failed to find handle %p", buf); - } - - // lock buffer before sending to FrameProvider for filling - bounds.left = 0; - bounds.top = 0; - bounds.right = mFrameWidth; - bounds.bottom = mFrameHeight; - - int lock_try_count = 0; - while (mapper.lock(*(buffer_handle_t *) mBuffers[i].opaque, CAMHAL_GRALLOC_USAGE, bounds, y_uv) < 0){ - if (++lock_try_count > LOCK_BUFFER_TRIES){ - if ( NULL != mErrorNotifier.get() ){ - mErrorNotifier->errorNotify(CAMERA_ERROR_UNKNOWN); - } - return false; - } - CAMHAL_LOGEA("Gralloc Lock FrameReturn Error: Sleeping 15ms"); - usleep(15000); - } - - { - android::AutoMutex lock(mLock); - mFramesWithCameraAdapterMap.add((buffer_handle_t *) mBuffers[i].opaque, i); - - for( k = 0; k < mFramesType.size() ; k++) { - if(mFramesType.keyAt(k) == (int)mBuffers[i].opaque) - break; - } - - if ( k == mFramesType.size() ) { - CAMHAL_LOGE("Frame type for preview buffer 0%x not found!!", mBuffers[i].opaque); - return false; - } - - frameType = (CameraFrame::FrameType) mFramesType.valueAt(k); - mFramesType.removeItem((int) mBuffers[i].opaque); - } - - CAMHAL_LOGSVB("handleFrameReturn: found graphic buffer %d of %d", i, mBufferCount-1); - mFrameProvider->returnFrame(&mBuffers[i], frameType); - - return true; -} - -void ANativeWindowDisplayAdapter::frameCallbackRelay(CameraFrame* caFrame) -{ - - if ( NULL != caFrame ) - { - if ( NULL != caFrame->mCookie ) - { - ANativeWindowDisplayAdapter *da = (ANativeWindowDisplayAdapter*) caFrame->mCookie; - da->frameCallback(caFrame); - } - else - { - CAMHAL_LOGEB("Invalid Cookie in Camera Frame = %p, Cookie = %p", caFrame, caFrame->mCookie); - } - } - else - { - CAMHAL_LOGEB("Invalid Camera Frame = %p", caFrame); - } - -} - -void ANativeWindowDisplayAdapter::frameCallback(CameraFrame* caFrame) -{ - ///Call queueBuffer of overlay in the context of the callback thread - DisplayFrame df; - df.mBuffer = caFrame->mBuffer; - df.mType = (CameraFrame::FrameType) caFrame->mFrameType; - df.mOffset = caFrame->mOffset; - df.mWidthStride = caFrame->mAlignment; - df.mLength = caFrame->mLength; - df.mWidth = caFrame->mWidth; - df.mHeight = caFrame->mHeight; - PostFrame(df); -} - - -/*--------------------ANativeWindowDisplayAdapter Class ENDS here-----------------------------*/ - -} // namespace Camera -} // namespace Ti diff --git a/camera/Android.mk b/camera/Android.mk deleted file mode 100644 index 7d4c066..0000000 --- a/camera/Android.mk +++ /dev/null @@ -1,227 +0,0 @@ -LOCAL_PATH:= $(call my-dir) - -TI_CAMERAHAL_DEBUG_ENABLED := true -TI_CAMERAHAL_VERBOSE_DEBUG_ENABLED := true -#TI_CAMERAHAL_DEBUG_FUNCTION_NAMES := true -TI_CAMERAHAL_DONT_USE_RAW_IMAGE_SAVING := true - -OMAP4_CAMERA_HAL_USES:= OMX -#OMAP4_CAMERA_HAL_USES:= USB -#OMAP4_CAMERA_HAL_USES:= ALL - -CAMERAHAL_CFLAGS += $(ANDROID_API_CFLAGS) -DANDROID_API_JB_OR_LATER - -ifdef TI_CAMERAHAL_DEBUG_ENABLED - # Enable CameraHAL debug logs - CAMERAHAL_CFLAGS += -DCAMERAHAL_DEBUG -endif - -ifdef TI_CAMERAHAL_VERBOSE_DEBUG_ENABLED - # Enable CameraHAL verbose debug logs - CAMERAHAL_CFLAGS += -DCAMERAHAL_DEBUG_VERBOSE -endif - -ifdef TI_CAMERAHAL_DEBUG_FUNCTION_NAMES - # Enable CameraHAL function enter/exit logging - CAMERAHAL_CFLAGS += -DTI_UTILS_FUNCTION_LOGGER_ENABLE -endif - -ifdef TI_CAMERAHAL_DEBUG_TIMESTAMPS - # Enable timestamp logging - CAMERAHAL_CFLAGS += -DTI_UTILS_DEBUG_USE_TIMESTAMPS -endif - -ifndef TI_CAMERAHAL_DONT_USE_RAW_IMAGE_SAVING - # Enabled saving RAW images to file - CAMERAHAL_CFLAGS += -DCAMERAHAL_USE_RAW_IMAGE_SAVING -endif - -ifdef TI_CAMERAHAL_PROFILING - # Enable OMX Camera component profiling - CAMERAHAL_CFLAGS += -DCAMERAHAL_OMX_PROFILING -endif - -ifeq ($(ENHANCED_DOMX),true) - CAMERAHAL_CFLAGS += -DENHANCED_DOMX -endif - -CAMERAHAL_CFLAGS += -DLOG_TAG=\"CameraHal\" - -TI_CAMERAHAL_COMMON_INCLUDES := \ - $(DEVICE_FOLDER)/hwc \ - external/jpeg \ - external/jhead \ - $(LOCAL_PATH)/../libtiutils \ - $(LOCAL_PATH)/inc \ - frameworks/native/include/media/hardware \ - system/media/camera/include \ - $(DOMX_PATH)/mm_osal/inc \ - $(DOMX_PATH)/omx_core/inc \ - frameworks/native/include/media/openmax - -TI_CAMERAHAL_COMMON_SRC := \ - CameraHal_Module.cpp \ - CameraHal.cpp \ - CameraHalUtilClasses.cpp \ - AppCallbackNotifier.cpp \ - ANativeWindowDisplayAdapter.cpp \ - BufferSourceAdapter.cpp \ - CameraProperties.cpp \ - BaseCameraAdapter.cpp \ - MemoryManager.cpp \ - Encoder_libjpeg.cpp \ - SensorListener.cpp \ - NV12_resize.cpp \ - CameraParameters.cpp \ - TICameraParameters.cpp \ - CameraHalCommon.cpp - -TI_CAMERAHAL_OMX_SRC := \ - OMXCameraAdapter/OMX3A.cpp \ - OMXCameraAdapter/OMXAlgo.cpp \ - OMXCameraAdapter/OMXCameraAdapter.cpp \ - OMXCameraAdapter/OMXCapabilities.cpp \ - OMXCameraAdapter/OMXCapture.cpp \ - OMXCameraAdapter/OMXReprocess.cpp \ - OMXCameraAdapter/OMXDefaults.cpp \ - OMXCameraAdapter/OMXExif.cpp \ - OMXCameraAdapter/OMXFD.cpp \ - OMXCameraAdapter/OMXFocus.cpp \ - OMXCameraAdapter/OMXMetadata.cpp \ - OMXCameraAdapter/OMXZoom.cpp - -ifndef OMAP_TUNA -TI_CAMERAHAL_OMX_SRC += \ - OMXCameraAdapter/OMXDccDataSave.cpp -endif - -TI_CAMERAHAL_USB_SRC := \ - V4LCameraAdapter/V4LCameraAdapter.cpp \ - V4LCameraAdapter/V4LCapabilities.cpp - -TI_CAMERAHAL_COMMON_SHARED_LIBRARIES := \ - libui \ - libbinder \ - libutils \ - libcutils \ - libtiutils_$(TARGET_BOOTLOADER_BOARD_NAME) \ - libcamera_client \ - libgui \ - libion_ti \ - libjpeg \ - libjhead - -ifdef OMAP_ENHANCEMENT_CPCAM -TI_CAMERAHAL_COMMON_STATIC_LIBRARIES += \ - libcpcamcamera_client -endif - - -# ==================== -# OMX Camera Adapter -# -------------------- - -ifeq ($(OMAP4_CAMERA_HAL_USES),OMX) - -include $(CLEAR_VARS) - -CAMERAHAL_CFLAGS += -DOMX_CAMERA_ADAPTER - -LOCAL_SRC_FILES:= \ - $(TI_CAMERAHAL_COMMON_SRC) \ - $(TI_CAMERAHAL_OMX_SRC) - -LOCAL_C_INCLUDES += \ - $(TI_CAMERAHAL_COMMON_INCLUDES) \ - $(LOCAL_PATH)/inc/OMXCameraAdapter - -LOCAL_SHARED_LIBRARIES:= \ - $(TI_CAMERAHAL_COMMON_SHARED_LIBRARIES) \ - libmm_osal \ - libOMX_Core \ - libdomx - -LOCAL_STATIC_LIBRARIES := $(TI_CAMERAHAL_COMMON_STATIC_LIBRARIES) - -LOCAL_CFLAGS := -fno-short-enums -DCOPY_IMAGE_BUFFER $(CAMERAHAL_CFLAGS) - -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw -LOCAL_MODULE:= camera.$(TARGET_BOOTLOADER_BOARD_NAME) -LOCAL_MODULE_TAGS:= optional - -include $(BUILD_SHARED_LIBRARY) - -else -ifeq ($(OMAP4_CAMERA_HAL_USES),USB) - - -# ==================== -# USB Camera Adapter -# -------------------- - -include $(CLEAR_VARS) - -CAMERAHAL_CFLAGS += -DV4L_CAMERA_ADAPTER - -LOCAL_SRC_FILES:= \ - $(TI_CAMERAHAL_COMMON_SRC) \ - $(TI_CAMERAHAL_USB_SRC) - -LOCAL_C_INCLUDES += \ - $(TI_CAMERAHAL_COMMON_INCLUDES) \ - $(LOCAL_PATH)/inc/V4LCameraAdapter - -LOCAL_SHARED_LIBRARIES:= \ - $(TI_CAMERAHAL_COMMON_SHARED_LIBRARIES) - -LOCAL_STATIC_LIBRARIES := $(TI_CAMERAHAL_COMMON_STATIC_LIBRARIES) - -LOCAL_CFLAGS := -fno-short-enums -DCOPY_IMAGE_BUFFER $(CAMERAHAL_CFLAGS) - -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw -LOCAL_MODULE:= camera.$(TARGET_BOOTLOADER_BOARD_NAME) -LOCAL_MODULE_TAGS:= optional - -include $(BUILD_SHARED_LIBRARY) - -else -ifeq ($(OMAP4_CAMERA_HAL_USES),ALL) - - -# ===================== -# ALL Camera Adapters -# --------------------- - -include $(CLEAR_VARS) - -CAMERAHAL_CFLAGS += -DOMX_CAMERA_ADAPTER -DV4L_CAMERA_ADAPTER - -LOCAL_SRC_FILES:= \ - $(TI_CAMERAHAL_COMMON_SRC) \ - $(TI_CAMERAHAL_OMX_SRC) \ - $(TI_CAMERAHAL_USB_SRC) - -LOCAL_C_INCLUDES += \ - $(TI_CAMERAHAL_COMMON_INCLUDES) \ - $(LOCAL_PATH)/inc/OMXCameraAdapter \ - $(LOCAL_PATH)/inc/V4LCameraAdapter - -LOCAL_SHARED_LIBRARIES:= \ - $(TI_CAMERAHAL_COMMON_SHARED_LIBRARIES) \ - libmm_osal \ - libOMX_Core \ - libdomx - -LOCAL_STATIC_LIBRARIES := $(TI_CAMERAHAL_COMMON_STATIC_LIBRARIES) - -LOCAL_CFLAGS := -fno-short-enums -DCOPY_IMAGE_BUFFER $(CAMERAHAL_CFLAGS) - -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw -LOCAL_MODULE:= camera.$(TARGET_BOOTLOADER_BOARD_NAME) -LOCAL_MODULE_TAGS:= optional - -include $(BUILD_SHARED_LIBRARY) - -endif -endif -endif diff --git a/camera/AppCallbackNotifier.cpp b/camera/AppCallbackNotifier.cpp deleted file mode 100644 index 90f63a9..0000000 --- a/camera/AppCallbackNotifier.cpp +++ /dev/null @@ -1,1923 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "CameraHal.h" -#include "VideoMetadata.h" -#include "Encoder_libjpeg.h" -#include -#include -#include -#include "NV12_resize.h" -#include "TICameraParameters.h" - -namespace Ti { -namespace Camera { - -const int AppCallbackNotifier::NOTIFIER_TIMEOUT = -1; -android::KeyedVector > gEncoderQueue; - -void AppCallbackNotifierEncoderCallback(void* main_jpeg, - void* thumb_jpeg, - CameraFrame::FrameType type, - void* cookie1, - void* cookie2, - void* cookie3, - void* cookie4, - bool canceled) -{ - if (cookie1 && !canceled) { - AppCallbackNotifier* cb = (AppCallbackNotifier*) cookie1; - cb->EncoderDoneCb(main_jpeg, thumb_jpeg, type, cookie2, cookie3, cookie4); - } - - if (main_jpeg) { - free(main_jpeg); - } - - if (thumb_jpeg) { - if (((Encoder_libjpeg::params *) thumb_jpeg)->dst) { - free(((Encoder_libjpeg::params *) thumb_jpeg)->dst); - } - free(thumb_jpeg); - } -} - -/*--------------------NotificationHandler Class STARTS here-----------------------------*/ - -void AppCallbackNotifier::EncoderDoneCb(void* main_jpeg, void* thumb_jpeg, CameraFrame::FrameType type, void* cookie1, void* cookie2, void *cookie3) -{ - camera_memory_t* encoded_mem = NULL; - Encoder_libjpeg::params *main_param = NULL, *thumb_param = NULL; - size_t jpeg_size; - uint8_t* src = NULL; - CameraBuffer *camera_buffer = NULL; - android::sp encoder = NULL; - - LOG_FUNCTION_NAME; - - camera_memory_t* picture = NULL; - - { - android::AutoMutex lock(mLock); - - if (!main_jpeg) { - goto exit; - } - - encoded_mem = (camera_memory_t*) cookie1; - main_param = (Encoder_libjpeg::params *) main_jpeg; - jpeg_size = main_param->jpeg_size; - camera_buffer = (CameraBuffer *)cookie3; - src = main_param->src; - - if(encoded_mem && encoded_mem->data && (jpeg_size > 0)) { - if (cookie2) { - ExifElementsTable* exif = (ExifElementsTable*) cookie2; - Section_t* exif_section = NULL; - - exif->insertExifToJpeg((unsigned char*) encoded_mem->data, jpeg_size); - - if(thumb_jpeg) { - thumb_param = (Encoder_libjpeg::params *) thumb_jpeg; - exif->insertExifThumbnailImage((const char*)thumb_param->dst, - (int)thumb_param->jpeg_size); - } - - exif_section = FindSection(M_EXIF); - - if (exif_section) { - picture = mRequestMemory(-1, jpeg_size + exif_section->Size, 1, NULL); - if (picture && picture->data) { - exif->saveJpeg((unsigned char*) picture->data, jpeg_size + exif_section->Size); - } - } - delete exif; - cookie2 = NULL; - } else { - picture = mRequestMemory(-1, jpeg_size, 1, NULL); - if (picture && picture->data) { - memcpy(picture->data, encoded_mem->data, jpeg_size); - } - } - } - } // scope for mutex lock - - if (!mRawAvailable) { - dummyRaw(); - } else { - mRawAvailable = false; - } - - // Send the callback to the application only if the notifier is started and the message is enabled - if(picture && (mNotifierState==AppCallbackNotifier::NOTIFIER_STARTED) && - (mCameraHal->msgTypeEnabled(CAMERA_MSG_COMPRESSED_IMAGE))) - { - android::AutoMutex lock(mBurstLock); - -#ifdef OMAP_ENHANCEMENT_BURST_CAPTURE - if ( mBurst ) - { - mDataCb(CAMERA_MSG_COMPRESSED_BURST_IMAGE, picture, 0, NULL, mCallbackCookie); - - } - else -#endif - { - mDataCb(CAMERA_MSG_COMPRESSED_IMAGE, picture, 0, NULL, mCallbackCookie); - } - } - - exit: - - if (picture) { - picture->release(picture); - } - - if (mNotifierState == AppCallbackNotifier::NOTIFIER_STARTED) { - if (encoded_mem) { - encoded_mem->release(encoded_mem); - } - if (cookie2) { - delete (ExifElementsTable*) cookie2; - } - encoder = gEncoderQueue.valueFor(src); - if (encoder.get()) { - gEncoderQueue.removeItem(src); - encoder.clear(); - } - mFrameProvider->returnFrame(camera_buffer, type); - } - - LOG_FUNCTION_NAME_EXIT; -} - -/** - * NotificationHandler class - */ - -///Initialization function for AppCallbackNotifier -status_t AppCallbackNotifier::initialize() -{ - LOG_FUNCTION_NAME; - - mPreviewMemory = 0; - - mMeasurementEnabled = false; - - mNotifierState = NOTIFIER_STOPPED; - - ///Create the app notifier thread - mNotificationThread = new NotificationThread(this); - if(!mNotificationThread.get()) - { - CAMHAL_LOGEA("Couldn't create Notification thread"); - return NO_MEMORY; - } - - ///Start the display thread - status_t ret = mNotificationThread->run("NotificationThread", android::PRIORITY_URGENT_DISPLAY); - if(ret!=NO_ERROR) - { - CAMHAL_LOGEA("Couldn't run NotificationThread"); - mNotificationThread.clear(); - return ret; - } - - mUseMetaDataBufferMode = true; - mRawAvailable = false; - - mRecording = false; - mPreviewing = false; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -void AppCallbackNotifier::setCallbacks(CameraHal* cameraHal, - camera_notify_callback notify_cb, - camera_data_callback data_cb, - camera_data_timestamp_callback data_cb_timestamp, - camera_request_memory get_memory, - void *user) -{ - android::AutoMutex lock(mLock); - - LOG_FUNCTION_NAME; - - mCameraHal = cameraHal; - mNotifyCb = notify_cb; - mDataCb = data_cb; - mDataCbTimestamp = data_cb_timestamp; - mRequestMemory = get_memory; - mCallbackCookie = user; - - LOG_FUNCTION_NAME_EXIT; -} - -void AppCallbackNotifier::setMeasurements(bool enable) -{ - android::AutoMutex lock(mLock); - - LOG_FUNCTION_NAME; - - mMeasurementEnabled = enable; - - if ( enable ) - { - mFrameProvider->enableFrameNotification(CameraFrame::FRAME_DATA_SYNC); - } - - LOG_FUNCTION_NAME_EXIT; -} - - -//All sub-components of Camera HAL call this whenever any error happens -void AppCallbackNotifier::errorNotify(int error) -{ - LOG_FUNCTION_NAME; - - CAMHAL_LOGEB("AppCallbackNotifier received error %d", error); - - // If it is a fatal error abort here! - // If TILER is Out of memory we notify Mediaserver so that Memory is cleared and we can restart usecase - if((error == CAMERA_ERROR_FATAL) || (error == CAMERA_ERROR_HARD) || (error == -ENOMEM)) - { - //We kill media server if we encounter these errors as there is - //no point continuing and apps also don't handle errors other - //than media server death always. - abort(); - return; - } - - if ( ( NULL != mCameraHal ) && - ( NULL != mNotifyCb ) && - ( mCameraHal->msgTypeEnabled(CAMERA_MSG_ERROR) ) ) - { - CAMHAL_LOGEB("AppCallbackNotifier mNotifyCb %d", error); - mNotifyCb(CAMERA_MSG_ERROR, CAMERA_ERROR_UNKNOWN, 0, mCallbackCookie); - } - - LOG_FUNCTION_NAME_EXIT; -} - -bool AppCallbackNotifier::notificationThread() -{ - bool shouldLive = true; - status_t ret; - - LOG_FUNCTION_NAME; - - //CAMHAL_LOGDA("Notification Thread waiting for message"); - ret = Utils::MessageQueue::waitForMsg(&mNotificationThread->msgQ(), - &mEventQ, - &mFrameQ, - AppCallbackNotifier::NOTIFIER_TIMEOUT); - - //CAMHAL_LOGDA("Notification Thread received message"); - - if (mNotificationThread->msgQ().hasMsg()) { - ///Received a message from CameraHal, process it - CAMHAL_LOGDA("Notification Thread received message from Camera HAL"); - shouldLive = processMessage(); - if(!shouldLive) { - CAMHAL_LOGDA("Notification Thread exiting."); - return shouldLive; - } - } - - if(mEventQ.hasMsg()) { - ///Received an event from one of the event providers - CAMHAL_LOGSVA("Notification Thread received an event from event provider (CameraAdapter)"); - notifyEvent(); - } - - if(mFrameQ.hasMsg()) { - ///Received a frame from one of the frame providers - CAMHAL_LOGSVA("Notification Thread received a frame from frame provider (CameraAdapter)"); - notifyFrame(); - } - - LOG_FUNCTION_NAME_EXIT; - return shouldLive; -} - -void AppCallbackNotifier::notifyEvent() -{ - ///Receive and send the event notifications to app - Utils::Message msg; - LOG_FUNCTION_NAME; - { - android::AutoMutex lock(mLock); - if ( !mEventQ.hasMsg() ) { - return; - } else { - mEventQ.get(&msg); - } - } - bool ret = true; - CameraHalEvent *evt = NULL; - CameraHalEvent::FocusEventData *focusEvtData; - CameraHalEvent::ZoomEventData *zoomEvtData; - CameraHalEvent::MetaEventData metaEvtData; - - if(mNotifierState != AppCallbackNotifier::NOTIFIER_STARTED) - { - return; - } - - switch(msg.command) - { - case AppCallbackNotifier::NOTIFIER_CMD_PROCESS_EVENT: - - evt = ( CameraHalEvent * ) msg.arg1; - - if ( NULL == evt ) - { - CAMHAL_LOGEA("Invalid CameraHalEvent"); - return; - } - - switch(evt->mEventType) - { - case CameraHalEvent::EVENT_SHUTTER: - - if ( ( NULL != mCameraHal ) && - ( NULL != mNotifyCb ) && - ( mCameraHal->msgTypeEnabled(CAMERA_MSG_SHUTTER) ) ) - { - mNotifyCb(CAMERA_MSG_SHUTTER, 0, 0, mCallbackCookie); - } - mRawAvailable = false; - - break; - - case CameraHalEvent::EVENT_FOCUS_LOCKED: - case CameraHalEvent::EVENT_FOCUS_ERROR: - if ( mCameraHal && mNotifyCb ) { - focusEvtData = &evt->mEventData->focusEvent; - - switch ( focusEvtData->focusStatus ) { - case CameraHalEvent::FOCUS_STATUS_SUCCESS: - if ( mCameraHal->msgTypeEnabled(CAMERA_MSG_FOCUS) ) { - mCameraHal->disableMsgType(CAMERA_MSG_FOCUS); - mNotifyCb(CAMERA_MSG_FOCUS, true, 0, mCallbackCookie); - } - break; - - case CameraHalEvent::FOCUS_STATUS_FAIL: - if ( mCameraHal->msgTypeEnabled(CAMERA_MSG_FOCUS) ) { - mCameraHal->disableMsgType(CAMERA_MSG_FOCUS); - mNotifyCb(CAMERA_MSG_FOCUS, false, 0, mCallbackCookie); - } - break; - -#ifdef ANDROID_API_JB_OR_LATER - case CameraHalEvent::FOCUS_STATUS_PENDING: - if ( mCameraHal->msgTypeEnabled(CAMERA_MSG_FOCUS_MOVE) ) { - mNotifyCb(CAMERA_MSG_FOCUS_MOVE, true, 0, mCallbackCookie); - } - break; - - case CameraHalEvent::FOCUS_STATUS_DONE: - if ( mCameraHal->msgTypeEnabled(CAMERA_MSG_FOCUS_MOVE) ) { - mNotifyCb(CAMERA_MSG_FOCUS_MOVE, false, 0, mCallbackCookie); - } - break; -#endif - } - } - - break; - - case CameraHalEvent::EVENT_ZOOM_INDEX_REACHED: - - zoomEvtData = &evt->mEventData->zoomEvent; - - if ( ( NULL != mCameraHal ) && - ( NULL != mNotifyCb) && - ( mCameraHal->msgTypeEnabled(CAMERA_MSG_ZOOM) ) ) - { - mNotifyCb(CAMERA_MSG_ZOOM, zoomEvtData->currentZoomIndex, zoomEvtData->targetZoomIndexReached, mCallbackCookie); - } - - break; - - case CameraHalEvent::EVENT_METADATA: - - metaEvtData = evt->mEventData->metadataEvent; - - if ( ( NULL != mCameraHal ) && - ( NULL != mNotifyCb) && - ( mCameraHal->msgTypeEnabled(CAMERA_MSG_PREVIEW_METADATA) ) ) - { - // WA for an issue inside CameraService - camera_memory_t *tmpBuffer = mRequestMemory(-1, 1, 1, NULL); - - mDataCb(CAMERA_MSG_PREVIEW_METADATA, - tmpBuffer, - 0, - metaEvtData->getMetadataResult(), - mCallbackCookie); - - metaEvtData.clear(); - - if ( NULL != tmpBuffer ) { - tmpBuffer->release(tmpBuffer); - } - - } - - break; - - case CameraHalEvent::ALL_EVENTS: - break; - default: - break; - } - - break; - } - - if ( NULL != evt ) - { - delete evt; - } - - - LOG_FUNCTION_NAME_EXIT; - -} - -static void alignYV12(int width, - int height, - size_t &yStride, - size_t &uvStride, - size_t &ySize, - size_t &uvSize, - size_t &size) -{ - yStride = ( width + 0xF ) & ~0xF; - uvStride = ( yStride / 2 + 0xF ) & ~0xF; - ySize = yStride * height; - uvSize = uvStride * height / 2; - size = ySize + uvSize * 2; -} - -static void copy2Dto1D(void *dst, - void *src, - int width, - int height, - size_t stride, - uint32_t offset, - unsigned int bytesPerPixel, - size_t length, - const char *pixelFormat) -{ - unsigned int alignedRow, row; - unsigned char *bufferDst, *bufferSrc; - unsigned char *bufferDstEnd, *bufferSrcEnd; - uint16_t *bufferSrc_UV; - - unsigned int *y_uv = (unsigned int *)src; - - CAMHAL_LOGVB("copy2Dto1D() y= %p ; uv=%p.",y_uv[0], y_uv[1]); - CAMHAL_LOGVB("pixelFormat = %s; offset=%d",pixelFormat,offset); - - if (pixelFormat!=NULL) { - if (strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { - bytesPerPixel = 2; - bufferSrc = ( unsigned char * ) y_uv[0] + offset; - uint32_t xOff = offset % stride; - uint32_t yOff = offset / stride; - uint8_t *bufferSrcUV = ((uint8_t*)y_uv[1] + (stride/2)*yOff + xOff); - uint8_t *bufferSrcUVEven = bufferSrcUV; - - uint8_t *bufferDstY = ( uint8_t * ) dst; - uint8_t *bufferDstU = bufferDstY + 1; - uint8_t *bufferDstV = bufferDstY + 3; - - // going to convert from NV12 here and return - for ( int i = 0 ; i < height; i ++ ) { - for ( int j = 0 ; j < width / 2 ; j++ ) { - - // Y - *bufferDstY = *bufferSrc; - bufferSrc++; - bufferDstY += 2; - - *bufferDstY = *bufferSrc; - bufferSrc++; - bufferDstY += 2; - - // V - *bufferDstV = *(bufferSrcUV + 1); - bufferDstV += 4; - - // U - *bufferDstU = *bufferSrcUV; - bufferDstU += 4; - - bufferSrcUV += 2; - } - if ( i % 2 ) { - bufferSrcUV += ( stride - width); - bufferSrcUVEven = bufferSrcUV; - } else { - bufferSrcUV = bufferSrcUVEven; - } - bufferSrc += ( stride - width); - } - - return; - } else if (strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0 || - strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV420P) == 0) { - bytesPerPixel = 1; - bufferDst = ( unsigned char * ) dst; - bufferDstEnd = ( unsigned char * ) dst + width*height*bytesPerPixel; - bufferSrc = ( unsigned char * ) y_uv[0] + offset; - bufferSrcEnd = ( unsigned char * ) ( ( size_t ) y_uv[0] + length + offset); - row = width*bytesPerPixel; - alignedRow = stride-width; - int stride_bytes = stride / 8; - uint32_t xOff = offset % stride; - uint32_t yOff = offset / stride; - - // going to convert from NV12 here and return - // Step 1: Y plane: iterate through each row and copy - for ( int i = 0 ; i < height ; i++) { - memcpy(bufferDst, bufferSrc, row); - bufferSrc += stride; - bufferDst += row; - if ( ( bufferSrc > bufferSrcEnd ) || ( bufferDst > bufferDstEnd ) ) { - break; - } - } - - bufferSrc_UV = ( uint16_t * ) ((uint8_t*)y_uv[1] + (stride/2)*yOff + xOff); - - if (strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { - uint16_t *bufferDst_UV; - - // Step 2: UV plane: convert NV12 to NV21 by swapping U & V - bufferDst_UV = (uint16_t *) (((uint8_t*)dst)+row*height); - - for (int i = 0 ; i < height/2 ; i++, bufferSrc_UV += alignedRow/2) { - int n = width; - asm volatile ( - " pld [%[src], %[src_stride], lsl #2] \n\t" - " cmp %[n], #32 \n\t" - " blt 1f \n\t" - "0: @ 32 byte swap \n\t" - " sub %[n], %[n], #32 \n\t" - " vld2.8 {q0, q1} , [%[src]]! \n\t" - " vswp q0, q1 \n\t" - " cmp %[n], #32 \n\t" - " vst2.8 {q0,q1},[%[dst]]! \n\t" - " bge 0b \n\t" - "1: @ Is there enough data? \n\t" - " cmp %[n], #16 \n\t" - " blt 3f \n\t" - "2: @ 16 byte swap \n\t" - " sub %[n], %[n], #16 \n\t" - " vld2.8 {d0, d1} , [%[src]]! \n\t" - " vswp d0, d1 \n\t" - " cmp %[n], #16 \n\t" - " vst2.8 {d0,d1},[%[dst]]! \n\t" - " bge 2b \n\t" - "3: @ Is there enough data? \n\t" - " cmp %[n], #8 \n\t" - " blt 5f \n\t" - "4: @ 8 byte swap \n\t" - " sub %[n], %[n], #8 \n\t" - " vld2.8 {d0, d1} , [%[src]]! \n\t" - " vswp d0, d1 \n\t" - " cmp %[n], #8 \n\t" - " vst2.8 {d0[0],d1[0]},[%[dst]]! \n\t" - " bge 4b \n\t" - "5: @ end \n\t" -#ifdef NEEDS_ARM_ERRATA_754319_754320 - " vmov s0,s0 @ add noop for errata item \n\t" -#endif - : [dst] "+r" (bufferDst_UV), [src] "+r" (bufferSrc_UV), [n] "+r" (n) - : [src_stride] "r" (stride_bytes) - : "cc", "memory", "q0", "q1" - ); - } - } else if (strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV420P) == 0) { - uint16_t *bufferDst_U; - uint16_t *bufferDst_V; - - // Step 2: UV plane: convert NV12 to YV12 by de-interleaving U & V - // TODO(XXX): This version of CameraHal assumes NV12 format it set at - // camera adapter to support YV12. Need to address for - // USBCamera - - size_t yStride, uvStride, ySize, uvSize, size; - alignYV12(width, height, yStride, uvStride, ySize, uvSize, size); - - bufferDst_V = (uint16_t *) (((uint8_t*)dst) + ySize); - bufferDst_U = (uint16_t *) (((uint8_t*)dst) + ySize + uvSize); - int inc = (uvStride - width/2)/2; - - for (int i = 0 ; i < height/2 ; i++, bufferSrc_UV += alignedRow/2) { - int n = width; - asm volatile ( - " pld [%[src], %[src_stride], lsl #2] \n\t" - " cmp %[n], #32 \n\t" - " blt 1f \n\t" - "0: @ 32 byte swap \n\t" - " sub %[n], %[n], #32 \n\t" - " vld2.8 {q0, q1} , [%[src]]! \n\t" - " cmp %[n], #32 \n\t" - " vst1.8 {q1},[%[dst_v]]! \n\t" - " vst1.8 {q0},[%[dst_u]]! \n\t" - " bge 0b \n\t" - "1: @ Is there enough data? \n\t" - " cmp %[n], #16 \n\t" - " blt 3f \n\t" - "2: @ 16 byte swap \n\t" - " sub %[n], %[n], #16 \n\t" - " vld2.8 {d0, d1} , [%[src]]! \n\t" - " cmp %[n], #16 \n\t" - " vst1.8 {d1},[%[dst_v]]! \n\t" - " vst1.8 {d0},[%[dst_u]]! \n\t" - " bge 2b \n\t" - "3: @ Is there enough data? \n\t" - " cmp %[n], #8 \n\t" - " blt 5f \n\t" - "4: @ 8 byte swap \n\t" - " sub %[n], %[n], #8 \n\t" - " vld2.8 {d0, d1} , [%[src]]! \n\t" - " cmp %[n], #8 \n\t" - " vst1.8 {d1[0]},[%[dst_v]]! \n\t" - " vst1.8 {d0[0]},[%[dst_u]]! \n\t" - " bge 4b \n\t" - "5: @ end \n\t" -#ifdef NEEDS_ARM_ERRATA_754319_754320 - " vmov s0,s0 @ add noop for errata item \n\t" -#endif - : [dst_u] "+r" (bufferDst_U), [dst_v] "+r" (bufferDst_V), - [src] "+r" (bufferSrc_UV), [n] "+r" (n) - : [src_stride] "r" (stride_bytes) - : "cc", "memory", "q0", "q1" - ); - - bufferDst_U += inc; - bufferDst_V += inc; - } - - } - return ; - - } else if(strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_RGB565) == 0) { - bytesPerPixel = 2; - } - } - - bufferDst = ( unsigned char * ) dst; - bufferSrc = ( unsigned char * ) y_uv[0]; - row = width*bytesPerPixel; - alignedRow = ( row + ( stride -1 ) ) & ( ~ ( stride -1 ) ); - - //iterate through each row - for ( int i = 0 ; i < height ; i++, bufferSrc += alignedRow, bufferDst += row) { - memcpy(bufferDst, bufferSrc, row); - } -} - -void AppCallbackNotifier::copyAndSendPictureFrame(CameraFrame* frame, int32_t msgType) -{ - camera_memory_t* picture = NULL; - void *dest = NULL, *src = NULL; - - // scope for lock - if (mCameraHal->msgTypeEnabled(msgType)) { - android::AutoMutex lock(mLock); - - if(mNotifierState != AppCallbackNotifier::NOTIFIER_STARTED) { - goto exit; - } - - picture = mRequestMemory(-1, frame->mLength, 1, NULL); - - if (NULL != picture) { - dest = picture->data; - if (NULL != dest) { - src = (void *) ((unsigned int) frame->mBuffer->mapped + frame->mOffset); - memcpy(dest, src, frame->mLength); - } - } - } - - exit: - mFrameProvider->returnFrame(frame->mBuffer, (CameraFrame::FrameType) frame->mFrameType); - - if(picture) { - if((mNotifierState == AppCallbackNotifier::NOTIFIER_STARTED) && - mCameraHal->msgTypeEnabled(msgType)) { - mDataCb(msgType, picture, 0, NULL, mCallbackCookie); - } - picture->release(picture); - } -} - -void AppCallbackNotifier::copyAndSendPreviewFrame(CameraFrame* frame, int32_t msgType) -{ - camera_memory_t* picture = NULL; - CameraBuffer * dest = NULL; - - // scope for lock - { - android::AutoMutex lock(mLock); - - if(mNotifierState != AppCallbackNotifier::NOTIFIER_STARTED) { - goto exit; - } - - if (!mPreviewMemory || !frame->mBuffer) { - CAMHAL_LOGDA("Error! One of the buffer is NULL"); - goto exit; - } - - dest = &mPreviewBuffers[mPreviewBufCount]; - - CAMHAL_LOGVB("%d:copy2Dto1D(%p, %p, %d, %d, %d, %d, %d,%s)", - __LINE__, - dest, - frame->mBuffer, - mPreviewWidth, - mPreviewHeight, - mPreviewStride, - 2, - frame->mLength, - mPreviewPixelFormat); - - /* FIXME map dest */ - if ( NULL != dest && dest->mapped != NULL ) { - // data sync frames don't need conversion - if (CameraFrame::FRAME_DATA_SYNC == frame->mFrameType) { - if ( (mPreviewMemory->size / MAX_BUFFERS) >= frame->mLength ) { - memcpy(dest->mapped, (void*) frame->mBuffer->mapped, frame->mLength); - } else { - memset(dest->mapped, 0, (mPreviewMemory->size / MAX_BUFFERS)); - } - } else { - if ((0 == frame->mYuv[0]) || (0 == frame->mYuv[1])){ //NULL == frame->mYuv - CAMHAL_LOGEA("Error! One of the YUV Pointer is 0"); //is NULL - goto exit; - } - else{ - copy2Dto1D(dest->mapped, - frame->mYuv, - mPreviewWidth, - mPreviewHeight, - mPreviewStride, - frame->mOffset, - 2, - frame->mLength, - mPreviewPixelFormat); - } - } - } - } - - exit: - mFrameProvider->returnFrame(frame->mBuffer, (CameraFrame::FrameType) frame->mFrameType); - - if((mNotifierState == AppCallbackNotifier::NOTIFIER_STARTED) && - mCameraHal->msgTypeEnabled(msgType) && - (dest != NULL) && (dest->mapped != NULL)) { - android::AutoMutex locker(mLock); - if ( mPreviewMemory ) - mDataCb(msgType, mPreviewMemory, mPreviewBufCount, NULL, mCallbackCookie); - } - - // increment for next buffer - mPreviewBufCount = (mPreviewBufCount + 1) % AppCallbackNotifier::MAX_BUFFERS; -} - -status_t AppCallbackNotifier::dummyRaw() -{ - LOG_FUNCTION_NAME; - - if ( NULL == mRequestMemory ) { - CAMHAL_LOGEA("Can't allocate memory for dummy raw callback!"); - return NO_INIT; - } - - if ( ( NULL != mCameraHal ) && - ( NULL != mDataCb) && - ( NULL != mNotifyCb ) ){ - - if ( mCameraHal->msgTypeEnabled(CAMERA_MSG_RAW_IMAGE) ) { - camera_memory_t *dummyRaw = mRequestMemory(-1, 1, 1, NULL); - - if ( NULL == dummyRaw ) { - CAMHAL_LOGEA("Dummy raw buffer allocation failed!"); - return NO_MEMORY; - } - - mDataCb(CAMERA_MSG_RAW_IMAGE, dummyRaw, 0, NULL, mCallbackCookie); - - dummyRaw->release(dummyRaw); - } else if ( mCameraHal->msgTypeEnabled(CAMERA_MSG_RAW_IMAGE_NOTIFY) ) { - mNotifyCb(CAMERA_MSG_RAW_IMAGE_NOTIFY, 0, 0, mCallbackCookie); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -void AppCallbackNotifier::notifyFrame() -{ - ///Receive and send the frame notifications to app - Utils::Message msg; - CameraFrame *frame; - android::MemoryHeapBase *heap; - android::MemoryBase *buffer = NULL; - android::sp memBase; - void *buf = NULL; - - LOG_FUNCTION_NAME; - - { - android::AutoMutex lock(mLock); - if(!mFrameQ.isEmpty()) { - mFrameQ.get(&msg); - } else { - return; - } - } - - bool ret = true; - - frame = NULL; - switch(msg.command) - { - case AppCallbackNotifier::NOTIFIER_CMD_PROCESS_FRAME: - - frame = (CameraFrame *) msg.arg1; - if(!frame) - { - break; - } - - if ( (CameraFrame::RAW_FRAME == frame->mFrameType )&& - ( NULL != mCameraHal ) && - ( NULL != mDataCb) && - ( NULL != mNotifyCb ) ) - { - - if ( mCameraHal->msgTypeEnabled(CAMERA_MSG_RAW_IMAGE) ) - { -#ifdef COPY_IMAGE_BUFFER - copyAndSendPictureFrame(frame, CAMERA_MSG_RAW_IMAGE); -#else - //TODO: Find a way to map a Tiler buffer to a MemoryHeapBase -#endif - } - else { - if ( mCameraHal->msgTypeEnabled(CAMERA_MSG_RAW_IMAGE_NOTIFY) ) { - mNotifyCb(CAMERA_MSG_RAW_IMAGE_NOTIFY, 0, 0, mCallbackCookie); - } - mFrameProvider->returnFrame(frame->mBuffer, - (CameraFrame::FrameType) frame->mFrameType); - } - - mRawAvailable = true; - - } - else if ( (CameraFrame::IMAGE_FRAME == frame->mFrameType) && - (NULL != mCameraHal) && - (NULL != mDataCb) && - (CameraFrame::ENCODE_RAW_YUV422I_TO_JPEG & frame->mQuirks) ) - { - - int encode_quality = 100, tn_quality = 100; - int tn_width, tn_height; - unsigned int current_snapshot = 0; - Encoder_libjpeg::params *main_jpeg = NULL, *tn_jpeg = NULL; - void* exif_data = NULL; - const char *previewFormat = NULL; - camera_memory_t* raw_picture = mRequestMemory(-1, frame->mLength, 1, NULL); - - if(raw_picture) { - buf = raw_picture->data; - } - - android::CameraParameters parameters; - char *params = mCameraHal->getParameters(); - const android::String8 strParams(params); - parameters.unflatten(strParams); - - encode_quality = parameters.getInt(android::CameraParameters::KEY_JPEG_QUALITY); - if (encode_quality < 0 || encode_quality > 100) { - encode_quality = 100; - } - - tn_quality = parameters.getInt(android::CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY); - if (tn_quality < 0 || tn_quality > 100) { - tn_quality = 100; - } - - if (CameraFrame::HAS_EXIF_DATA & frame->mQuirks) { - exif_data = frame->mCookie2; - } - - main_jpeg = (Encoder_libjpeg::params*) - malloc(sizeof(Encoder_libjpeg::params)); - - // Video snapshot with LDCNSF on adds a few bytes start offset - // and a few bytes on every line. They must be skipped. - int rightCrop = frame->mAlignment/2 - frame->mWidth; - - CAMHAL_LOGDB("Video snapshot right crop = %d", rightCrop); - CAMHAL_LOGDB("Video snapshot offset = %d", frame->mOffset); - - if (main_jpeg) { - main_jpeg->src = (uint8_t *)frame->mBuffer->mapped; - main_jpeg->src_size = frame->mLength; - main_jpeg->dst = (uint8_t*) buf; - main_jpeg->dst_size = frame->mLength; - main_jpeg->quality = encode_quality; - main_jpeg->in_width = frame->mAlignment/2; // use stride here - main_jpeg->in_height = frame->mHeight; - main_jpeg->out_width = frame->mAlignment/2; - main_jpeg->out_height = frame->mHeight; - main_jpeg->right_crop = rightCrop; - main_jpeg->start_offset = frame->mOffset; - if ( CameraFrame::FORMAT_YUV422I_UYVY & frame->mQuirks) { - main_jpeg->format = TICameraParameters::PIXEL_FORMAT_YUV422I_UYVY; - } - else { //if ( CameraFrame::FORMAT_YUV422I_YUYV & frame->mQuirks) - main_jpeg->format = android::CameraParameters::PIXEL_FORMAT_YUV422I; - } - } - - tn_width = parameters.getInt(android::CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH); - tn_height = parameters.getInt(android::CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT); - previewFormat = parameters.getPreviewFormat(); - - if ((tn_width > 0) && (tn_height > 0) && ( NULL != previewFormat )) { - tn_jpeg = (Encoder_libjpeg::params*) - malloc(sizeof(Encoder_libjpeg::params)); - // if malloc fails just keep going and encode main jpeg - if (!tn_jpeg) { - tn_jpeg = NULL; - } - } - - if (tn_jpeg) { - int width, height; - parameters.getPreviewSize(&width,&height); - current_snapshot = (mPreviewBufCount + MAX_BUFFERS - 1) % MAX_BUFFERS; - tn_jpeg->src = (uint8_t *)mPreviewBuffers[current_snapshot].mapped; - tn_jpeg->src_size = mPreviewMemory->size / MAX_BUFFERS; - tn_jpeg->dst_size = calculateBufferSize(tn_width, - tn_height, - previewFormat); - tn_jpeg->dst = (uint8_t*) malloc(tn_jpeg->dst_size); - tn_jpeg->quality = tn_quality; - tn_jpeg->in_width = width; - tn_jpeg->in_height = height; - tn_jpeg->out_width = tn_width; - tn_jpeg->out_height = tn_height; - tn_jpeg->right_crop = 0; - tn_jpeg->start_offset = 0; - tn_jpeg->format = android::CameraParameters::PIXEL_FORMAT_YUV420SP;; - } - - android::sp encoder = new Encoder_libjpeg(main_jpeg, - tn_jpeg, - AppCallbackNotifierEncoderCallback, - (CameraFrame::FrameType)frame->mFrameType, - this, - raw_picture, - exif_data, frame->mBuffer); - gEncoderQueue.add(frame->mBuffer->mapped, encoder); - encoder->run(); - encoder.clear(); - if (params != NULL) - { - mCameraHal->putParameters(params); - } - } - else if ( ( CameraFrame::IMAGE_FRAME == frame->mFrameType ) && - ( NULL != mCameraHal ) && - ( NULL != mDataCb) ) - { - - // CTS, MTS requirements: Every 'takePicture()' call - // who registers a raw callback should receive one - // as well. This is not always the case with - // CameraAdapters though. - if (!mCameraHal->msgTypeEnabled(CAMERA_MSG_RAW_IMAGE)) { - dummyRaw(); - } else { - mRawAvailable = false; - } - -#ifdef COPY_IMAGE_BUFFER - { - android::AutoMutex lock(mBurstLock); -#ifdef OMAP_ENHANCEMENT_BURST_CAPTURE - if ( mBurst ) - { - copyAndSendPictureFrame(frame, CAMERA_MSG_COMPRESSED_BURST_IMAGE); - } - else -#endif - { - copyAndSendPictureFrame(frame, CAMERA_MSG_COMPRESSED_IMAGE); - } - } -#else - //TODO: Find a way to map a Tiler buffer to a MemoryHeapBase -#endif - } - else if ( ( CameraFrame::VIDEO_FRAME_SYNC == frame->mFrameType ) && - ( NULL != mCameraHal ) && - ( NULL != mDataCb) && - ( mCameraHal->msgTypeEnabled(CAMERA_MSG_VIDEO_FRAME) ) ) - { - android::AutoMutex locker(mRecordingLock); - if(mRecording) - { - if(mUseMetaDataBufferMode) - { - camera_memory_t *videoMedatadaBufferMemory = - mVideoMetadataBufferMemoryMap.valueFor(frame->mBuffer->opaque); - video_metadata_t *videoMetadataBuffer = (video_metadata_t *) videoMedatadaBufferMemory->data; - - if( (NULL == videoMedatadaBufferMemory) || (NULL == videoMetadataBuffer) || (NULL == frame->mBuffer) ) - { - CAMHAL_LOGEA("Error! One of the video buffers is NULL"); - break; - } - - if ( mUseVideoBuffers ) - { - CameraBuffer *vBuf = mVideoMap.valueFor(frame->mBuffer->opaque); - android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get(); - android::Rect bounds; - bounds.left = 0; - bounds.top = 0; - bounds.right = mVideoWidth; - bounds.bottom = mVideoHeight; - - void *y_uv[2]; - mapper.lock((buffer_handle_t)vBuf, CAMHAL_GRALLOC_USAGE, bounds, y_uv); - y_uv[1] = y_uv[0] + mVideoHeight*4096; - - structConvImage input = {(mmInt32)frame->mWidth, - (mmInt32)frame->mHeight, - 4096, - IC_FORMAT_YCbCr420_lp, - (mmByte *)frame->mYuv[0], - (mmByte *)frame->mYuv[1], - (mmInt32)frame->mOffset}; - - structConvImage output = {mVideoWidth, - mVideoHeight, - 4096, - IC_FORMAT_YCbCr420_lp, - (mmByte *)y_uv[0], - (mmByte *)y_uv[1], - 0}; - - VT_resizeFrame_Video_opt2_lp(&input, &output, NULL, 0); - mapper.unlock((buffer_handle_t)vBuf->opaque); - videoMetadataBuffer->metadataBufferType = (int) android::kMetadataBufferTypeCameraSource; - /* FIXME remove cast */ - videoMetadataBuffer->handle = (void *)vBuf->opaque; - videoMetadataBuffer->offset = 0; - } - else - { - videoMetadataBuffer->metadataBufferType = (int) android::kMetadataBufferTypeCameraSource; - videoMetadataBuffer->handle = camera_buffer_get_omx_ptr(frame->mBuffer); - videoMetadataBuffer->offset = frame->mOffset; - } - - CAMHAL_LOGVB("mDataCbTimestamp : frame->mBuffer=0x%x, videoMetadataBuffer=0x%x, videoMedatadaBufferMemory=0x%x", - frame->mBuffer->opaque, videoMetadataBuffer, videoMedatadaBufferMemory); - - mDataCbTimestamp(frame->mTimestamp, CAMERA_MSG_VIDEO_FRAME, - videoMedatadaBufferMemory, 0, mCallbackCookie); - } - else - { - //TODO: Need to revisit this, should ideally be mapping the TILER buffer using mRequestMemory - camera_memory_t* fakebuf = mRequestMemory(-1, sizeof(buffer_handle_t), 1, NULL); - if( (NULL == fakebuf) || ( NULL == fakebuf->data) || ( NULL == frame->mBuffer)) - { - CAMHAL_LOGEA("Error! One of the video buffers is NULL"); - break; - } - - *reinterpret_cast(fakebuf->data) = reinterpret_cast(frame->mBuffer->mapped); - mDataCbTimestamp(frame->mTimestamp, CAMERA_MSG_VIDEO_FRAME, fakebuf, 0, mCallbackCookie); - fakebuf->release(fakebuf); - } - } - } - else if(( CameraFrame::SNAPSHOT_FRAME == frame->mFrameType ) && - ( NULL != mCameraHal ) && - ( NULL != mDataCb) && - ( NULL != mNotifyCb)) { - //When enabled, measurement data is sent instead of video data - if ( !mMeasurementEnabled ) { - copyAndSendPreviewFrame(frame, CAMERA_MSG_POSTVIEW_FRAME); - } else { - mFrameProvider->returnFrame(frame->mBuffer, - (CameraFrame::FrameType) frame->mFrameType); - } - } - else if ( ( CameraFrame::PREVIEW_FRAME_SYNC== frame->mFrameType ) && - ( NULL != mCameraHal ) && - ( NULL != mDataCb) && - ( mCameraHal->msgTypeEnabled(CAMERA_MSG_PREVIEW_FRAME)) ) { - //When enabled, measurement data is sent instead of video data - if ( !mMeasurementEnabled ) { - copyAndSendPreviewFrame(frame, CAMERA_MSG_PREVIEW_FRAME); - } else { - mFrameProvider->returnFrame(frame->mBuffer, - (CameraFrame::FrameType) frame->mFrameType); - } - } - else if ( ( CameraFrame::FRAME_DATA_SYNC == frame->mFrameType ) && - ( NULL != mCameraHal ) && - ( NULL != mDataCb) && - ( mCameraHal->msgTypeEnabled(CAMERA_MSG_PREVIEW_FRAME)) ) { - copyAndSendPreviewFrame(frame, CAMERA_MSG_PREVIEW_FRAME); - } else { - mFrameProvider->returnFrame(frame->mBuffer, - ( CameraFrame::FrameType ) frame->mFrameType); - CAMHAL_LOGDB("Frame type 0x%x is still unsupported!", frame->mFrameType); - } - - break; - - default: - - break; - - }; - -exit: - - if ( NULL != frame ) - { - delete frame; - } - - LOG_FUNCTION_NAME_EXIT; -} - -void AppCallbackNotifier::frameCallbackRelay(CameraFrame* caFrame) -{ - LOG_FUNCTION_NAME; - AppCallbackNotifier *appcbn = (AppCallbackNotifier*) (caFrame->mCookie); - appcbn->frameCallback(caFrame); - LOG_FUNCTION_NAME_EXIT; -} - -void AppCallbackNotifier::frameCallback(CameraFrame* caFrame) -{ - ///Post the event to the event queue of AppCallbackNotifier - Utils::Message msg; - CameraFrame *frame; - - LOG_FUNCTION_NAME; - - if ( NULL != caFrame ) - { - - frame = new CameraFrame(*caFrame); - if ( NULL != frame ) - { - msg.command = AppCallbackNotifier::NOTIFIER_CMD_PROCESS_FRAME; - msg.arg1 = frame; - mFrameQ.put(&msg); - } - else - { - CAMHAL_LOGEA("Not enough resources to allocate CameraFrame"); - } - - } - - LOG_FUNCTION_NAME_EXIT; -} - -void AppCallbackNotifier::flushAndReturnFrames() -{ - LOG_FUNCTION_NAME; - - Utils::Message msg; - CameraFrame *frame; - - android::AutoMutex lock(mLock); - while (!mFrameQ.isEmpty()) { - mFrameQ.get(&msg); - frame = (CameraFrame*) msg.arg1; - if (frame) { - mFrameProvider->returnFrame(frame->mBuffer, - (CameraFrame::FrameType) frame->mFrameType); - } - } - - LOG_FUNCTION_NAME_EXIT; -} - -void AppCallbackNotifier::eventCallbackRelay(CameraHalEvent* chEvt) -{ - LOG_FUNCTION_NAME; - AppCallbackNotifier *appcbn = (AppCallbackNotifier*) (chEvt->mCookie); - appcbn->eventCallback(chEvt); - LOG_FUNCTION_NAME_EXIT; -} - -void AppCallbackNotifier::eventCallback(CameraHalEvent* chEvt) -{ - - ///Post the event to the event queue of AppCallbackNotifier - Utils::Message msg; - CameraHalEvent *event; - - - LOG_FUNCTION_NAME; - - if ( NULL != chEvt ) - { - - event = new CameraHalEvent(*chEvt); - if ( NULL != event ) - { - msg.command = AppCallbackNotifier::NOTIFIER_CMD_PROCESS_EVENT; - msg.arg1 = event; - { - android::AutoMutex lock(mLock); - mEventQ.put(&msg); - } - } - else - { - CAMHAL_LOGEA("Not enough resources to allocate CameraHalEvent"); - } - - } - - LOG_FUNCTION_NAME_EXIT; -} - - -void AppCallbackNotifier::flushEventQueue() -{ - - { - android::AutoMutex lock(mLock); - mEventQ.clear(); - } -} - - -bool AppCallbackNotifier::processMessage() -{ - ///Retrieve the command from the command queue and process it - Utils::Message msg; - - LOG_FUNCTION_NAME; - - CAMHAL_LOGDA("+Msg get..."); - mNotificationThread->msgQ().get(&msg); - CAMHAL_LOGDA("-Msg get..."); - bool ret = true; - - switch(msg.command) - { - case NotificationThread::NOTIFIER_EXIT: - { - CAMHAL_LOGD("Received NOTIFIER_EXIT command from Camera HAL"); - mNotifierState = AppCallbackNotifier::NOTIFIER_EXITED; - ret = false; - break; - } - default: - { - CAMHAL_LOGEA("Error: ProcessMsg() command from Camera HAL"); - break; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; - - -} - -AppCallbackNotifier::~AppCallbackNotifier() -{ - LOG_FUNCTION_NAME; - - ///Stop app callback notifier if not already stopped - stop(); - - ///Unregister with the frame provider - if ( NULL != mFrameProvider ) - { - mFrameProvider->disableFrameNotification(CameraFrame::ALL_FRAMES); - } - - //unregister with the event provider - if ( NULL != mEventProvider ) - { - mEventProvider->disableEventNotification(CameraHalEvent::ALL_EVENTS); - } - - Utils::Message msg = {0,0,0,0,0,0}; - msg.command = NotificationThread::NOTIFIER_EXIT; - - ///Post the message to display thread - mNotificationThread->msgQ().put(&msg); - - //Exit and cleanup the thread - mNotificationThread->requestExit(); - mNotificationThread->join(); - - //Delete the display thread - mNotificationThread.clear(); - - - ///Free the event and frame providers - if ( NULL != mEventProvider ) - { - ///Deleting the event provider - CAMHAL_LOGDA("Stopping Event Provider"); - delete mEventProvider; - mEventProvider = NULL; - } - - if ( NULL != mFrameProvider ) - { - ///Deleting the frame provider - CAMHAL_LOGDA("Stopping Frame Provider"); - delete mFrameProvider; - mFrameProvider = NULL; - } - - releaseSharedVideoBuffers(); - - LOG_FUNCTION_NAME_EXIT; -} - -//Free all video heaps and buffers -void AppCallbackNotifier::releaseSharedVideoBuffers() -{ - LOG_FUNCTION_NAME; - - if(mUseMetaDataBufferMode) - { - camera_memory_t* videoMedatadaBufferMemory; - for (unsigned int i = 0; i < mVideoMetadataBufferMemoryMap.size(); i++) - { - videoMedatadaBufferMemory = mVideoMetadataBufferMemoryMap.valueAt(i); - if(NULL != videoMedatadaBufferMemory) - { - videoMedatadaBufferMemory->release(videoMedatadaBufferMemory); - CAMHAL_LOGDB("Released videoMedatadaBufferMemory=%p", videoMedatadaBufferMemory); - } - } - - mVideoMetadataBufferMemoryMap.clear(); - mVideoMetadataBufferReverseMap.clear(); - if (mUseVideoBuffers) - { - mVideoMap.clear(); - } - } - - LOG_FUNCTION_NAME_EXIT; -} - -void AppCallbackNotifier::setEventProvider(int32_t eventMask, MessageNotifier * eventNotifier) -{ - - LOG_FUNCTION_NAME; - ///@remarks There is no NULL check here. We will check - ///for NULL when we get start command from CameraHal - ///@Remarks Currently only one event provider (CameraAdapter) is supported - ///@todo Have an array of event providers for each event bitmask - mEventProvider = new EventProvider(eventNotifier, this, eventCallbackRelay); - if ( NULL == mEventProvider ) - { - CAMHAL_LOGEA("Error in creating EventProvider"); - } - else - { - mEventProvider->enableEventNotification(eventMask); - } - - LOG_FUNCTION_NAME_EXIT; -} - -void AppCallbackNotifier::setFrameProvider(FrameNotifier *frameNotifier) -{ - LOG_FUNCTION_NAME; - ///@remarks There is no NULL check here. We will check - ///for NULL when we get the start command from CameraAdapter - mFrameProvider = new FrameProvider(frameNotifier, this, frameCallbackRelay); - if ( NULL == mFrameProvider ) - { - CAMHAL_LOGEA("Error in creating FrameProvider"); - } - else - { - //Register only for captured images and RAW for now - //TODO: Register for and handle all types of frames - mFrameProvider->enableFrameNotification(CameraFrame::IMAGE_FRAME); - mFrameProvider->enableFrameNotification(CameraFrame::RAW_FRAME); - } - - LOG_FUNCTION_NAME_EXIT; -} - -size_t AppCallbackNotifier::calculateBufferSize(size_t width, size_t height, const char *pixelFormat) -{ - size_t res = 0; - - LOG_FUNCTION_NAME - - if(strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { - res = width*height*2; - } else if(strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { - res = (width*height*3)/2; - } else if(strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_RGB565) == 0) { - res = width*height*2; - } else if (strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV420P) == 0) { - size_t yStride, uvStride, ySize, uvSize; - alignYV12(width, height, yStride, uvStride, ySize, uvSize, res); - mPreviewPixelFormat = android::CameraParameters::PIXEL_FORMAT_YUV420P; - } - - LOG_FUNCTION_NAME_EXIT; - - return res; -} - -const char* AppCallbackNotifier::getContstantForPixelFormat(const char *pixelFormat) { - if (!pixelFormat) { - // returning NV12 as default - return android::CameraParameters::PIXEL_FORMAT_YUV420SP; - } - - if(strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { - return android::CameraParameters::PIXEL_FORMAT_YUV422I; - } else if(strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0 ) { - return android::CameraParameters::PIXEL_FORMAT_YUV420SP; - } else if(strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_RGB565) == 0) { - return android::CameraParameters::PIXEL_FORMAT_RGB565; - } else if(strcmp(pixelFormat, android::CameraParameters::PIXEL_FORMAT_YUV420P) == 0) { - return android::CameraParameters::PIXEL_FORMAT_YUV420P; - } else { - // returning NV12 as default - return android::CameraParameters::PIXEL_FORMAT_YUV420SP; - } -} - -status_t AppCallbackNotifier::startPreviewCallbacks(android::CameraParameters ¶ms, CameraBuffer *buffers, uint32_t *offsets, int fd, size_t length, size_t count) -{ - unsigned int *bufArr; - int size = 0; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mLock); - - if ( NULL == mFrameProvider ) - { - CAMHAL_LOGEA("Trying to start video recording without FrameProvider"); - return -EINVAL; - } - - if ( mPreviewing ) - { - CAMHAL_LOGDA("+Already previewing"); - return NO_INIT; - } - - int w,h; - ///Get preview size - params.getPreviewSize(&w, &h); - - // save preview pixel format, size and stride - mPreviewWidth = w; - mPreviewHeight = h; - mPreviewStride = 4096; - mPreviewPixelFormat = getContstantForPixelFormat(params.getPreviewFormat()); - size = calculateBufferSize(w, h, mPreviewPixelFormat); - - mPreviewMemory = mRequestMemory(-1, size, AppCallbackNotifier::MAX_BUFFERS, NULL); - if (!mPreviewMemory) { - return NO_MEMORY; - } - - for (int i=0; i < AppCallbackNotifier::MAX_BUFFERS; i++) { - mPreviewBuffers[i].type = CAMERA_BUFFER_MEMORY; - mPreviewBuffers[i].opaque = (unsigned char*) mPreviewMemory->data + (i*size); - mPreviewBuffers[i].mapped = mPreviewBuffers[i].opaque; - } - - if ( mCameraHal->msgTypeEnabled(CAMERA_MSG_PREVIEW_FRAME ) ) { - mFrameProvider->enableFrameNotification(CameraFrame::PREVIEW_FRAME_SYNC); - } - - if ( mCameraHal->msgTypeEnabled(CAMERA_MSG_POSTVIEW_FRAME) ) { - mFrameProvider->enableFrameNotification(CameraFrame::SNAPSHOT_FRAME); - } - - mPreviewBufCount = 0; - - mPreviewing = true; - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -void AppCallbackNotifier::setBurst(bool burst) -{ - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mBurstLock); - - mBurst = burst; - - LOG_FUNCTION_NAME_EXIT; -} - -void AppCallbackNotifier::useVideoBuffers(bool useVideoBuffers) -{ - LOG_FUNCTION_NAME; - - mUseVideoBuffers = useVideoBuffers; - - LOG_FUNCTION_NAME_EXIT; -} - -bool AppCallbackNotifier::getUesVideoBuffers() -{ - return mUseVideoBuffers; -} - -void AppCallbackNotifier::setVideoRes(int width, int height) -{ - LOG_FUNCTION_NAME; - - mVideoWidth = width; - mVideoHeight = height; - - LOG_FUNCTION_NAME_EXIT; -} - -status_t AppCallbackNotifier::stopPreviewCallbacks() -{ - LOG_FUNCTION_NAME; - - if ( NULL == mFrameProvider ) - { - CAMHAL_LOGEA("Trying to stop preview callbacks without FrameProvider"); - return -EINVAL; - } - - if ( !mPreviewing ) - { - return NO_INIT; - } - - mFrameProvider->disableFrameNotification(CameraFrame::PREVIEW_FRAME_SYNC); - mFrameProvider->disableFrameNotification(CameraFrame::SNAPSHOT_FRAME); - - { - android::AutoMutex lock(mLock); - mPreviewMemory->release(mPreviewMemory); - mPreviewMemory = 0; - } - - mPreviewing = false; - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; - -} - -status_t AppCallbackNotifier::useMetaDataBufferMode(bool enable) -{ - mUseMetaDataBufferMode = enable; - - return NO_ERROR; -} - - -status_t AppCallbackNotifier::startRecording() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mRecordingLock); - - if ( NULL == mFrameProvider ) - { - CAMHAL_LOGEA("Trying to start video recording without FrameProvider"); - ret = -1; - } - - if(mRecording) - { - return NO_INIT; - } - - if ( NO_ERROR == ret ) - { - mFrameProvider->enableFrameNotification(CameraFrame::VIDEO_FRAME_SYNC); - } - - mRecording = true; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -//Allocate metadata buffers for video recording -status_t AppCallbackNotifier::initSharedVideoBuffers(CameraBuffer *buffers, uint32_t *offsets, int fd, size_t length, size_t count, CameraBuffer *vidBufs) -{ - status_t ret = NO_ERROR; - LOG_FUNCTION_NAME; - - if(mUseMetaDataBufferMode) - { - camera_memory_t* videoMedatadaBufferMemory = NULL; - - if(NULL == buffers) - { - CAMHAL_LOGEA("Error! Video buffers are NULL"); - return BAD_VALUE; - } - - for (uint32_t i = 0; i < count; i++) - { - videoMedatadaBufferMemory = mRequestMemory(-1, sizeof(video_metadata_t), 1, NULL); - if((NULL == videoMedatadaBufferMemory) || (NULL == videoMedatadaBufferMemory->data)) - { - CAMHAL_LOGEA("Error! Could not allocate memory for Video Metadata Buffers"); - return NO_MEMORY; - } - - // FIXME remove cast - mVideoMetadataBufferMemoryMap.add((void *)buffers[i].opaque, videoMedatadaBufferMemory); - mVideoMetadataBufferReverseMap.add(videoMedatadaBufferMemory->data, &buffers[i]); - CAMHAL_LOGDB("buffers[%d]=%p, videoMedatadaBufferMemory=%p, videoMedatadaBufferMemory->data=%p", - i, &buffers[i], videoMedatadaBufferMemory, videoMedatadaBufferMemory->data); - - if (vidBufs != NULL) - { - //ASSERT(buffers[i].type == CAMERA_BUFFER_GRALLOC); - // FIXME remove cast - mVideoMap.add((void *)buffers[i].opaque, &vidBufs[i]); - CAMHAL_LOGVB("buffers[%d]=%p, vBuffArr[%d]=%p", i, &buffers[i], i, &vidBufs[i]); - } - } - } - -exit: - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t AppCallbackNotifier::stopRecording() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mRecordingLock); - - if ( NULL == mFrameProvider ) - { - CAMHAL_LOGEA("Trying to stop video recording without FrameProvider"); - ret = -1; - } - - if(!mRecording) - { - return NO_INIT; - } - - if ( NO_ERROR == ret ) - { - mFrameProvider->disableFrameNotification(CameraFrame::VIDEO_FRAME_SYNC); - } - - ///Release the shared video buffers - releaseSharedVideoBuffers(); - - mRecording = false; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t AppCallbackNotifier::releaseRecordingFrame(const void* mem) -{ - status_t ret = NO_ERROR; - CameraBuffer *frame = NULL; - - LOG_FUNCTION_NAME; - if ( NULL == mFrameProvider ) - { - CAMHAL_LOGEA("Trying to stop video recording without FrameProvider"); - ret = -1; - } - - if ( NULL == mem ) - { - CAMHAL_LOGEA("Video Frame released is invalid"); - ret = -1; - } - - if( NO_ERROR != ret ) - { - return ret; - } - - if(mUseMetaDataBufferMode) - { - video_metadata_t *videoMetadataBuffer = (video_metadata_t *) mem ; - /* FIXME remove cast */ - frame = mVideoMetadataBufferReverseMap.valueFor(videoMetadataBuffer); - CAMHAL_LOGVB("Releasing frame with videoMetadataBuffer=0x%x, videoMetadataBuffer->handle=0x%x & frame handle=0x%x\n", - videoMetadataBuffer, videoMetadataBuffer->handle, frame); - } - else - { - /* FIXME this won't work */ - frame = (CameraBuffer *)(void*)(*((uint32_t *)mem)); - } - - if ( NO_ERROR == ret ) - { - ret = mFrameProvider->returnFrame(frame, CameraFrame::VIDEO_FRAME_SYNC); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t AppCallbackNotifier::enableMsgType(int32_t msgType) -{ - if( msgType & CAMERA_MSG_PREVIEW_FRAME ) { - mFrameProvider->enableFrameNotification(CameraFrame::PREVIEW_FRAME_SYNC); - } - - if( msgType & CAMERA_MSG_POSTVIEW_FRAME ) { - mFrameProvider->enableFrameNotification(CameraFrame::SNAPSHOT_FRAME); - } - - if(msgType & CAMERA_MSG_RAW_IMAGE) { - mFrameProvider->enableFrameNotification(CameraFrame::RAW_FRAME); - } - - return NO_ERROR; -} - -status_t AppCallbackNotifier::disableMsgType(int32_t msgType) -{ - if( msgType & CAMERA_MSG_PREVIEW_FRAME ) { - mFrameProvider->disableFrameNotification(CameraFrame::PREVIEW_FRAME_SYNC); - } - - if( msgType & CAMERA_MSG_POSTVIEW_FRAME ) { - mFrameProvider->disableFrameNotification(CameraFrame::SNAPSHOT_FRAME); - } - - if(msgType & CAMERA_MSG_RAW_IMAGE) { - mFrameProvider->disableFrameNotification(CameraFrame::RAW_FRAME); - } - - return NO_ERROR; - -} - -status_t AppCallbackNotifier::start() -{ - LOG_FUNCTION_NAME; - if(mNotifierState==AppCallbackNotifier::NOTIFIER_STARTED) - { - CAMHAL_LOGDA("AppCallbackNotifier already running"); - LOG_FUNCTION_NAME_EXIT; - return ALREADY_EXISTS; - } - - ///Check whether initial conditions are met for us to start - ///A frame provider should be available, if not return error - if(!mFrameProvider) - { - ///AppCallbackNotifier not properly initialized - CAMHAL_LOGEA("AppCallbackNotifier not properly initialized - Frame provider is NULL"); - LOG_FUNCTION_NAME_EXIT; - return NO_INIT; - } - - ///At least one event notifier should be available, if not return error - ///@todo Modify here when there is an array of event providers - if(!mEventProvider) - { - CAMHAL_LOGEA("AppCallbackNotifier not properly initialized - Event provider is NULL"); - LOG_FUNCTION_NAME_EXIT; - ///AppCallbackNotifier not properly initialized - return NO_INIT; - } - - mNotifierState = AppCallbackNotifier::NOTIFIER_STARTED; - CAMHAL_LOGDA(" --> AppCallbackNotifier NOTIFIER_STARTED \n"); - - gEncoderQueue.clear(); - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; - -} - -status_t AppCallbackNotifier::stop() -{ - LOG_FUNCTION_NAME; - - if(mNotifierState!=AppCallbackNotifier::NOTIFIER_STARTED) - { - CAMHAL_LOGDA("AppCallbackNotifier already in stopped state"); - LOG_FUNCTION_NAME_EXIT; - return ALREADY_EXISTS; - } - { - android::AutoMutex lock(mLock); - - mNotifierState = AppCallbackNotifier::NOTIFIER_STOPPED; - CAMHAL_LOGDA(" --> AppCallbackNotifier NOTIFIER_STOPPED \n"); - } - - while(!gEncoderQueue.isEmpty()) { - android::sp encoder = gEncoderQueue.valueAt(0); - camera_memory_t* encoded_mem = NULL; - ExifElementsTable* exif = NULL; - - if(encoder.get()) { - encoder->cancel(); - - encoder->getCookies(NULL, (void**) &encoded_mem, (void**) &exif); - if (encoded_mem) { - encoded_mem->release(encoded_mem); - } - if (exif) { - delete exif; - } - - encoder.clear(); - } - gEncoderQueue.removeItemsAt(0); - } - - LOG_FUNCTION_NAME_EXIT; - return NO_ERROR; -} - - -/*--------------------NotificationHandler Class ENDS here-----------------------------*/ - - - -} // namespace Camera -} // namespace Ti diff --git a/camera/BaseCameraAdapter.cpp b/camera/BaseCameraAdapter.cpp deleted file mode 100644 index b3a47d1..0000000 --- a/camera/BaseCameraAdapter.cpp +++ /dev/null @@ -1,2693 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "BaseCameraAdapter.h" - -const int EVENT_MASK = 0xffff; - -namespace Ti { -namespace Camera { - -const LUT cameraCommandsUserToHAL[] = { - { "CAMERA_START_PREVIEW", CameraAdapter::CAMERA_START_PREVIEW }, - { "CAMERA_STOP_PREVIEW", CameraAdapter::CAMERA_STOP_PREVIEW }, - { "CAMERA_START_VIDEO", CameraAdapter::CAMERA_START_VIDEO }, - { "CAMERA_STOP_VIDEO", CameraAdapter::CAMERA_STOP_VIDEO }, - { "CAMERA_START_IMAGE_CAPTURE", CameraAdapter::CAMERA_START_IMAGE_CAPTURE }, - { "CAMERA_STOP_IMAGE_CAPTURE", CameraAdapter::CAMERA_STOP_IMAGE_CAPTURE }, - { "CAMERA_PERFORM_AUTOFOCUS", CameraAdapter::CAMERA_PERFORM_AUTOFOCUS }, - { "CAMERA_CANCEL_AUTOFOCUS", CameraAdapter::CAMERA_CANCEL_AUTOFOCUS }, - { "CAMERA_PREVIEW_FLUSH_BUFFERS", CameraAdapter::CAMERA_PREVIEW_FLUSH_BUFFERS }, - { "CAMERA_START_SMOOTH_ZOOM", CameraAdapter::CAMERA_START_SMOOTH_ZOOM }, - { "CAMERA_STOP_SMOOTH_ZOOM", CameraAdapter::CAMERA_STOP_SMOOTH_ZOOM }, - { "CAMERA_USE_BUFFERS_PREVIEW", CameraAdapter::CAMERA_USE_BUFFERS_PREVIEW }, - { "CAMERA_SET_TIMEOUT", CameraAdapter::CAMERA_SET_TIMEOUT }, - { "CAMERA_CANCEL_TIMEOUT", CameraAdapter::CAMERA_CANCEL_TIMEOUT }, - { "CAMERA_START_BRACKET_CAPTURE", CameraAdapter::CAMERA_START_BRACKET_CAPTURE }, - { "CAMERA_STOP_BRACKET_CAPTURE", CameraAdapter::CAMERA_STOP_BRACKET_CAPTURE }, - { "CAMERA_QUERY_RESOLUTION_PREVIEW", CameraAdapter::CAMERA_QUERY_RESOLUTION_PREVIEW }, - { "CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE", CameraAdapter::CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE }, - { "CAMERA_QUERY_BUFFER_SIZE_PREVIEW_DATA", CameraAdapter::CAMERA_QUERY_BUFFER_SIZE_PREVIEW_DATA }, - { "CAMERA_USE_BUFFERS_IMAGE_CAPTURE", CameraAdapter::CAMERA_USE_BUFFERS_IMAGE_CAPTURE }, - { "CAMERA_USE_BUFFERS_PREVIEW_DATA", CameraAdapter::CAMERA_USE_BUFFERS_PREVIEW_DATA }, - { "CAMERA_TIMEOUT_EXPIRED", CameraAdapter::CAMERA_TIMEOUT_EXPIRED }, - { "CAMERA_START_FD", CameraAdapter::CAMERA_START_FD }, - { "CAMERA_STOP_FD", CameraAdapter::CAMERA_STOP_FD }, - { "CAMERA_SWITCH_TO_EXECUTING", CameraAdapter::CAMERA_SWITCH_TO_EXECUTING }, - { "CAMERA_USE_BUFFERS_VIDEO_CAPTURE", CameraAdapter::CAMERA_USE_BUFFERS_VIDEO_CAPTURE }, -#ifdef OMAP_ENHANCEMENT_CPCAM - { "CAMERA_USE_BUFFERS_REPROCESS", CameraAdapter::CAMERA_USE_BUFFERS_REPROCESS }, - { "CAMERA_START_REPROCESS", CameraAdapter::CAMERA_START_REPROCESS }, -#endif -}; - -const LUTtypeHAL CamCommandsLUT = { - sizeof(cameraCommandsUserToHAL)/sizeof(cameraCommandsUserToHAL[0]), - cameraCommandsUserToHAL -}; - -/*--------------------Camera Adapter Class STARTS here-----------------------------*/ - -BaseCameraAdapter::BaseCameraAdapter() -{ - mReleaseImageBuffersCallback = NULL; - mEndImageCaptureCallback = NULL; - mErrorNotifier = NULL; - mEndCaptureData = NULL; - mReleaseData = NULL; - mRecording = false; - - mPreviewBuffers = NULL; - mPreviewBufferCount = 0; - mPreviewBuffersLength = 0; - - mVideoBuffers = NULL; - mVideoBuffersCount = 0; - mVideoBuffersLength = 0; - - mCaptureBuffers = NULL; - mCaptureBuffersCount = 0; - mCaptureBuffersLength = 0; - - mPreviewDataBuffers = NULL; - mPreviewDataBuffersCount = 0; - mPreviewDataBuffersLength = 0; - - mAdapterState = INTIALIZED_STATE; - - mSharedAllocator = NULL; - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - mStartFocus.tv_sec = 0; - mStartFocus.tv_usec = 0; - mStartCapture.tv_sec = 0; - mStartCapture.tv_usec = 0; -#endif - -} - -BaseCameraAdapter::~BaseCameraAdapter() -{ - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mSubscriberLock); - - mFrameSubscribers.clear(); - mImageSubscribers.clear(); - mRawSubscribers.clear(); - mVideoSubscribers.clear(); - mVideoInSubscribers.clear(); - mFocusSubscribers.clear(); - mShutterSubscribers.clear(); - mZoomSubscribers.clear(); - mSnapshotSubscribers.clear(); - mMetadataSubscribers.clear(); - - LOG_FUNCTION_NAME_EXIT; -} - -status_t BaseCameraAdapter::registerImageReleaseCallback(release_image_buffers_callback callback, void *user_data) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - mReleaseImageBuffersCallback = callback; - mReleaseData = user_data; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::registerEndCaptureCallback(end_image_capture_callback callback, void *user_data) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - mEndImageCaptureCallback= callback; - mEndCaptureData = user_data; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::setErrorHandler(ErrorNotifier *errorNotifier) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( NULL == errorNotifier ) - { - CAMHAL_LOGEA("Invalid Error Notifier reference"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) - { - mErrorNotifier = errorNotifier; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -void BaseCameraAdapter::enableMsgType(int32_t msgs, frame_callback callback, event_callback eventCb, void* cookie) -{ - android::AutoMutex lock(mSubscriberLock); - - LOG_FUNCTION_NAME; - - int32_t frameMsg = ((msgs >> MessageNotifier::FRAME_BIT_FIELD_POSITION) & EVENT_MASK); - int32_t eventMsg = ((msgs >> MessageNotifier::EVENT_BIT_FIELD_POSITION) & EVENT_MASK); - - if ( frameMsg != 0 ) - { - CAMHAL_LOGVB("Frame message type id=0x%x subscription request", frameMsg); - switch ( frameMsg ) - { - case CameraFrame::PREVIEW_FRAME_SYNC: - mFrameSubscribers.add((int) cookie, callback); - break; - case CameraFrame::FRAME_DATA_SYNC: - mFrameDataSubscribers.add((int) cookie, callback); - break; - case CameraFrame::SNAPSHOT_FRAME: - mSnapshotSubscribers.add((int) cookie, callback); - break; - case CameraFrame::IMAGE_FRAME: - mImageSubscribers.add((int) cookie, callback); - break; - case CameraFrame::RAW_FRAME: - mRawSubscribers.add((int) cookie, callback); - break; - case CameraFrame::VIDEO_FRAME_SYNC: - mVideoSubscribers.add((int) cookie, callback); - break; - case CameraFrame::REPROCESS_INPUT_FRAME: - mVideoInSubscribers.add((int) cookie, callback); - break; - default: - CAMHAL_LOGEA("Frame message type id=0x%x subscription no supported yet!", frameMsg); - break; - } - } - - if ( eventMsg != 0) - { - CAMHAL_LOGVB("Event message type id=0x%x subscription request", eventMsg); - if ( CameraHalEvent::ALL_EVENTS == eventMsg ) - { - mFocusSubscribers.add((int) cookie, eventCb); - mShutterSubscribers.add((int) cookie, eventCb); - mZoomSubscribers.add((int) cookie, eventCb); - mMetadataSubscribers.add((int) cookie, eventCb); - } - else - { - CAMHAL_LOGEA("Event message type id=0x%x subscription no supported yet!", eventMsg); - } - } - - LOG_FUNCTION_NAME_EXIT; -} - -void BaseCameraAdapter::disableMsgType(int32_t msgs, void* cookie) -{ - android::AutoMutex lock(mSubscriberLock); - - LOG_FUNCTION_NAME; - - int32_t frameMsg = ((msgs >> MessageNotifier::FRAME_BIT_FIELD_POSITION) & EVENT_MASK); - int32_t eventMsg = ((msgs >> MessageNotifier::EVENT_BIT_FIELD_POSITION) & EVENT_MASK); - - if ( frameMsg != 0 ) - { - CAMHAL_LOGVB("Frame message type id=0x%x remove subscription request", frameMsg); - switch ( frameMsg ) - { - case CameraFrame::PREVIEW_FRAME_SYNC: - mFrameSubscribers.removeItem((int) cookie); - break; - case CameraFrame::FRAME_DATA_SYNC: - mFrameDataSubscribers.removeItem((int) cookie); - break; - case CameraFrame::SNAPSHOT_FRAME: - mSnapshotSubscribers.removeItem((int) cookie); - break; - case CameraFrame::IMAGE_FRAME: - mImageSubscribers.removeItem((int) cookie); - break; - case CameraFrame::RAW_FRAME: - mRawSubscribers.removeItem((int) cookie); - break; - case CameraFrame::VIDEO_FRAME_SYNC: - mVideoSubscribers.removeItem((int) cookie); - break; - case CameraFrame::REPROCESS_INPUT_FRAME: - mVideoInSubscribers.removeItem((int) cookie); - break; - case CameraFrame::ALL_FRAMES: - mFrameSubscribers.removeItem((int) cookie); - mFrameDataSubscribers.removeItem((int) cookie); - mSnapshotSubscribers.removeItem((int) cookie); - mImageSubscribers.removeItem((int) cookie); - mRawSubscribers.removeItem((int) cookie); - mVideoSubscribers.removeItem((int) cookie); - mVideoInSubscribers.removeItem((int) cookie); - break; - default: - CAMHAL_LOGEA("Frame message type id=0x%x subscription remove not supported yet!", frameMsg); - break; - } - } - - if ( eventMsg != 0 ) - { - CAMHAL_LOGVB("Event message type id=0x%x remove subscription request", eventMsg); - if ( CameraHalEvent::ALL_EVENTS == eventMsg) - { - //TODO: Process case by case - mFocusSubscribers.removeItem((int) cookie); - mShutterSubscribers.removeItem((int) cookie); - mZoomSubscribers.removeItem((int) cookie); - mMetadataSubscribers.removeItem((int) cookie); - } - else - { - CAMHAL_LOGEA("Event message type id=0x%x subscription remove not supported yet!", eventMsg); - } - } - - LOG_FUNCTION_NAME_EXIT; -} - -void BaseCameraAdapter::addFramePointers(CameraBuffer *frameBuf, void *buf) -{ - unsigned int *pBuf = (unsigned int *)buf; - android::AutoMutex lock(mSubscriberLock); - - if ((frameBuf != NULL) && ( pBuf != NULL) ) - { - CameraFrame *frame = new CameraFrame; - frame->mBuffer = frameBuf; - frame->mYuv[0] = pBuf[0]; - frame->mYuv[1] = pBuf[1]; - mFrameQueue.add(frameBuf, frame); - - CAMHAL_LOGVB("Adding Frame=0x%x Y=0x%x UV=0x%x", frame->mBuffer, frame->mYuv[0], frame->mYuv[1]); - } -} - -void BaseCameraAdapter::removeFramePointers() -{ - android::AutoMutex lock(mSubscriberLock); - - int size = mFrameQueue.size(); - CAMHAL_LOGVB("Removing %d Frames = ", size); - for (int i = 0; i < size; i++) - { - CameraFrame *frame = (CameraFrame *)mFrameQueue.valueAt(i); - CAMHAL_LOGVB("Free Frame=0x%x Y=0x%x UV=0x%x", frame->mBuffer, frame->mYuv[0], frame->mYuv[1]); - delete frame; - } - mFrameQueue.clear(); -} - -void BaseCameraAdapter::returnFrame(CameraBuffer * frameBuf, CameraFrame::FrameType frameType) -{ - status_t res = NO_ERROR; - size_t subscriberCount = 0; - int refCount = -1; - - if ( NULL == frameBuf ) - { - CAMHAL_LOGEA("Invalid frameBuf"); - return; - } - - if ( NO_ERROR == res) - { - android::AutoMutex lock(mReturnFrameLock); - - refCount = getFrameRefCount(frameBuf, frameType); - - if(frameType == CameraFrame::PREVIEW_FRAME_SYNC) - { - mFramesWithDisplay--; - } - else if(frameType == CameraFrame::VIDEO_FRAME_SYNC) - { - mFramesWithEncoder--; - } - - if ( 0 < refCount ) - { - - refCount--; - setFrameRefCount(frameBuf, frameType, refCount); - - - if ( mRecording && (CameraFrame::VIDEO_FRAME_SYNC == frameType) ) { - refCount += getFrameRefCount(frameBuf, CameraFrame::PREVIEW_FRAME_SYNC); - } else if ( mRecording && (CameraFrame::PREVIEW_FRAME_SYNC == frameType) ) { - refCount += getFrameRefCount(frameBuf, CameraFrame::VIDEO_FRAME_SYNC); - } else if ( mRecording && (CameraFrame::SNAPSHOT_FRAME == frameType) ) { - refCount += getFrameRefCount(frameBuf, CameraFrame::VIDEO_FRAME_SYNC); - } - - - } - else - { - CAMHAL_LOGDA("Frame returned when ref count is already zero!!"); - return; - } - } - - CAMHAL_LOGSVB("REFCOUNT 0x%x %d", frameBuf, refCount); - - if ( NO_ERROR == res ) - { - //check if someone is holding this buffer - if ( 0 == refCount ) - { -#ifdef CAMERAHAL_DEBUG - if((mBuffersWithDucati.indexOfKey((int)camera_buffer_get_omx_ptr(frameBuf)) >= 0) && - ((CameraFrame::PREVIEW_FRAME_SYNC == frameType) || - (CameraFrame::SNAPSHOT_FRAME == frameType))) - { - CAMHAL_LOGE("Buffer already with Ducati!! 0x%x", frameBuf); - for(unsigned int i=0;imBuffers; - mPreviewBuffersLength = desc->mLength; - mPreviewBuffersAvailable.clear(); - mSnapshotBuffersAvailable.clear(); - for ( uint32_t i = 0 ; i < desc->mMaxQueueable ; i++ ) - { - mPreviewBuffersAvailable.add(&mPreviewBuffers[i], 0); - } - // initial ref count for undeqeueued buffers is 1 since buffer provider - // is still holding on to it - for ( uint32_t i = desc->mMaxQueueable ; i < desc->mCount ; i++ ) - { - mPreviewBuffersAvailable.add(&mPreviewBuffers[i], 1); - } - } - - if ( NULL != desc ) - { - ret = useBuffers(CameraAdapter::CAMERA_PREVIEW, - desc->mBuffers, - desc->mCount, - desc->mLength, - desc->mMaxQueueable); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - case CameraAdapter::CAMERA_USE_BUFFERS_PREVIEW_DATA: - CAMHAL_LOGDA("Use buffers for preview data"); - desc = ( BuffersDescriptor * ) value1; - - if ( NULL == desc ) - { - CAMHAL_LOGEA("Invalid preview data buffers!"); - return -EINVAL; - } - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - android::AutoMutex lock(mPreviewDataBufferLock); - mPreviewDataBuffers = desc->mBuffers; - mPreviewDataBuffersLength = desc->mLength; - mPreviewDataBuffersAvailable.clear(); - for ( uint32_t i = 0 ; i < desc->mMaxQueueable ; i++ ) - { - mPreviewDataBuffersAvailable.add(&mPreviewDataBuffers[i], 0); - } - // initial ref count for undeqeueued buffers is 1 since buffer provider - // is still holding on to it - for ( uint32_t i = desc->mMaxQueueable ; i < desc->mCount ; i++ ) - { - mPreviewDataBuffersAvailable.add(&mPreviewDataBuffers[i], 1); - } - } - - if ( NULL != desc ) - { - ret = useBuffers(CameraAdapter::CAMERA_MEASUREMENT, - desc->mBuffers, - desc->mCount, - desc->mLength, - desc->mMaxQueueable); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - case CameraAdapter::CAMERA_USE_BUFFERS_IMAGE_CAPTURE: - CAMHAL_LOGDA("Use buffers for image capture"); - desc = ( BuffersDescriptor * ) value1; - - if ( NULL == desc ) - { - CAMHAL_LOGEA("Invalid capture buffers!"); - return -EINVAL; - } - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - android::AutoMutex lock(mCaptureBufferLock); - mCaptureBuffers = desc->mBuffers; - mCaptureBuffersLength = desc->mLength; - mCaptureBuffersAvailable.clear(); - for ( uint32_t i = 0 ; i < desc->mMaxQueueable ; i++ ) - { - mCaptureBuffersAvailable.add(&mCaptureBuffers[i], 0); - } - // initial ref count for undeqeueued buffers is 1 since buffer provider - // is still holding on to it - for ( uint32_t i = desc->mMaxQueueable ; i < desc->mCount ; i++ ) - { - mCaptureBuffersAvailable.add(&mCaptureBuffers[i], 1); - } - } - - if ( NULL != desc ) - { - ret = useBuffers(CameraAdapter::CAMERA_IMAGE_CAPTURE, - desc->mBuffers, - desc->mCount, - desc->mLength, - desc->mMaxQueueable); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - -#ifdef OMAP_ENHANCEMENT_CPCAM - case CameraAdapter::CAMERA_USE_BUFFERS_REPROCESS: - CAMHAL_LOGDA("Use buffers for reprocessing"); - desc = (BuffersDescriptor *) value1; - - if (NULL == desc) { - CAMHAL_LOGEA("Invalid capture buffers!"); - return -EINVAL; - } - - if (ret == NO_ERROR) { - ret = setState(operation); - } - - if (ret == NO_ERROR) { - android::AutoMutex lock(mVideoInBufferLock); - mVideoInBuffers = desc->mBuffers; - mVideoInBuffersAvailable.clear(); - for (uint32_t i = 0 ; i < desc->mMaxQueueable ; i++) { - mVideoInBuffersAvailable.add(&mVideoInBuffers[i], 0); - } - // initial ref count for undeqeueued buffers is 1 since buffer provider - // is still holding on to it - for ( uint32_t i = desc->mMaxQueueable ; i < desc->mCount ; i++ ) { - mVideoInBuffersAvailable.add(&mVideoInBuffers[i], 1); - } - ret = useBuffers(CameraAdapter::CAMERA_REPROCESS, - desc->mBuffers, - desc->mCount, - desc->mLength, - desc->mMaxQueueable); - } - - if ( ret == NO_ERROR ) { - ret = commitState(); - } else { - ret |= rollbackState(); - } - - break; -#endif - - case CameraAdapter::CAMERA_START_SMOOTH_ZOOM: - { - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - ret = startSmoothZoom(value1); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - } - - case CameraAdapter::CAMERA_STOP_SMOOTH_ZOOM: - { - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - ret = stopSmoothZoom(); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - } - - case CameraAdapter::CAMERA_START_PREVIEW: - { - - CAMHAL_LOGDA("Start Preview"); - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - ret = startPreview(); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - } - - case CameraAdapter::CAMERA_STOP_PREVIEW: - { - - CAMHAL_LOGDA("Stop Preview"); - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - ret = stopPreview(); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - } - - case CameraAdapter::CAMERA_START_VIDEO: - { - - CAMHAL_LOGDA("Start video recording"); - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - ret = startVideoCapture(); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - } - - case CameraAdapter::CAMERA_STOP_VIDEO: - { - - CAMHAL_LOGDA("Stop video recording"); - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - ret = stopVideoCapture(); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - } - - case CameraAdapter::CAMERA_START_IMAGE_CAPTURE: - { - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - refTimestamp = ( struct timeval * ) value1; - if ( NULL != refTimestamp ) - { - memcpy( &mStartCapture, refTimestamp, sizeof( struct timeval )); - } - -#endif - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - ret = takePicture(); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - } - - case CameraAdapter::CAMERA_STOP_IMAGE_CAPTURE: - { - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - ret = stopImageCapture(); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - } - - case CameraAdapter::CAMERA_START_BRACKET_CAPTURE: - { - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - refTimestamp = ( struct timeval * ) value2; - if ( NULL != refTimestamp ) - { - memcpy( &mStartCapture, refTimestamp, sizeof( struct timeval )); - } - -#endif - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - ret = startBracketing(value1); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - } - - case CameraAdapter::CAMERA_STOP_BRACKET_CAPTURE: - { - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - ret = stopBracketing(); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - } - - case CameraAdapter::CAMERA_PERFORM_AUTOFOCUS: - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - refTimestamp = ( struct timeval * ) value1; - if ( NULL != refTimestamp ) - { - memcpy( &mStartFocus, refTimestamp, sizeof( struct timeval )); - } - -#endif - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - ret = autoFocus(); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - case CameraAdapter::CAMERA_CANCEL_AUTOFOCUS: - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - ret = cancelAutoFocus(); - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - case CameraAdapter::CAMERA_QUERY_RESOLUTION_PREVIEW: - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - frame = ( CameraFrame * ) value1; - - if ( NULL != frame ) - { - ret = getFrameSize(frame->mWidth, frame->mHeight); - } - else - { - ret = -EINVAL; - } - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - case CameraAdapter::CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE: - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - frame = ( CameraFrame * ) value1; - - if ( NULL != frame ) - { - ret = getPictureBufferSize(*frame, value2); - } - else - { - ret = -EINVAL; - } - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - case CameraAdapter::CAMERA_QUERY_BUFFER_SIZE_PREVIEW_DATA: - - if ( ret == NO_ERROR ) - { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) - { - frame = ( CameraFrame * ) value1; - - if ( NULL != frame ) - { - ret = getFrameDataSize(frame->mLength, value2); - } - else - { - ret = -EINVAL; - } - } - - if ( ret == NO_ERROR ) - { - ret = commitState(); - } - else - { - ret |= rollbackState(); - } - - break; - - case CameraAdapter::CAMERA_START_FD: - - ret = startFaceDetection(); - - break; - - case CameraAdapter::CAMERA_STOP_FD: - - ret = stopFaceDetection(); - - break; - - case CameraAdapter::CAMERA_USE_BUFFERS_VIDEO_CAPTURE: - - CAMHAL_LOGDA("Use buffers for video (RAW + JPEG) capture"); - desc = ( BuffersDescriptor * ) value1; - - if ( NULL == desc ) { - CAMHAL_LOGEA("Invalid capture buffers!"); - return -EINVAL; - } - - if ( ret == NO_ERROR ) { - ret = setState(operation); - } - - if ( ret == NO_ERROR ) { - android::AutoMutex lock(mVideoBufferLock); - mVideoBuffers = desc->mBuffers; - mVideoBuffersLength = desc->mLength; - mVideoBuffersAvailable.clear(); - for ( uint32_t i = 0 ; i < desc->mMaxQueueable ; i++ ) { - mVideoBuffersAvailable.add(&mVideoBuffers[i], 1); - } - // initial ref count for undeqeueued buffers is 1 since buffer provider - // is still holding on to it - for ( uint32_t i = desc->mMaxQueueable ; i < desc->mCount ; i++ ) { - mVideoBuffersAvailable.add(&mVideoBuffers[i], 1); - } - } - - if ( NULL != desc ) { - ret = useBuffers(CameraAdapter::CAMERA_VIDEO, - desc->mBuffers, - desc->mCount, - desc->mLength, - desc->mMaxQueueable); - } - - if ( ret == NO_ERROR ) { - ret = commitState(); - } else { - ret |= rollbackState(); - } - - break; - - case CameraAdapter::CAMERA_SWITCH_TO_EXECUTING: - ret = switchToExecuting(); - break; - -#ifdef OMAP_ENHANCEMENT_VTC - case CameraAdapter::CAMERA_SETUP_TUNNEL: - ret = setupTunnel(value1, value2, value3, value4); - break; - - case CameraAdapter::CAMERA_DESTROY_TUNNEL: - ret = destroyTunnel(); - break; -#endif - - case CameraAdapter::CAMERA_PREVIEW_INITIALIZATION: - ret = cameraPreviewInitialization(); - break; - - default: - CAMHAL_LOGEB("Command 0x%x unsupported!", operation); - break; - }; - - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -status_t BaseCameraAdapter::notifyFocusSubscribers(CameraHalEvent::FocusStatus status) -{ - event_callback eventCb; - CameraHalEvent focusEvent; - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( mFocusSubscribers.size() == 0 ) { - CAMHAL_LOGDA("No Focus Subscribers!"); - return NO_INIT; - } - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - if (status == CameraHalEvent::FOCUS_STATUS_PENDING) { - gettimeofday(&mStartFocus, NULL); - } else { - //dump the AF latency - CameraHal::PPM("Focus finished in: ", &mStartFocus); - } -#endif - - focusEvent.mEventData = new CameraHalEvent::CameraHalEventData(); - if ( NULL == focusEvent.mEventData.get() ) { - return -ENOMEM; - } - - focusEvent.mEventType = CameraHalEvent::EVENT_FOCUS_LOCKED; - focusEvent.mEventData->focusEvent.focusStatus = status; - - for (unsigned int i = 0 ; i < mFocusSubscribers.size(); i++ ) - { - focusEvent.mCookie = (void *) mFocusSubscribers.keyAt(i); - eventCb = (event_callback) mFocusSubscribers.valueAt(i); - eventCb ( &focusEvent ); - } - - focusEvent.mEventData.clear(); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::notifyShutterSubscribers() -{ - CameraHalEvent shutterEvent; - event_callback eventCb; - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( mShutterSubscribers.size() == 0 ) - { - CAMHAL_LOGEA("No shutter Subscribers!"); - return NO_INIT; - } - - shutterEvent.mEventData = new CameraHalEvent::CameraHalEventData(); - if ( NULL == shutterEvent.mEventData.get() ) { - return -ENOMEM; - } - - shutterEvent.mEventType = CameraHalEvent::EVENT_SHUTTER; - shutterEvent.mEventData->shutterEvent.shutterClosed = true; - - for (unsigned int i = 0 ; i < mShutterSubscribers.size() ; i++ ) { - shutterEvent.mCookie = ( void * ) mShutterSubscribers.keyAt(i); - eventCb = ( event_callback ) mShutterSubscribers.valueAt(i); - - CAMHAL_LOGD("Sending shutter callback"); - - eventCb ( &shutterEvent ); - } - - shutterEvent.mEventData.clear(); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::notifyZoomSubscribers(int zoomIdx, bool targetReached) -{ - event_callback eventCb; - CameraHalEvent zoomEvent; - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( mZoomSubscribers.size() == 0 ) { - CAMHAL_LOGDA("No zoom Subscribers!"); - return NO_INIT; - } - - zoomEvent.mEventData = new CameraHalEvent::CameraHalEventData(); - if ( NULL == zoomEvent.mEventData.get() ) { - return -ENOMEM; - } - - zoomEvent.mEventType = CameraHalEvent::EVENT_ZOOM_INDEX_REACHED; - zoomEvent.mEventData->zoomEvent.currentZoomIndex = zoomIdx; - zoomEvent.mEventData->zoomEvent.targetZoomIndexReached = targetReached; - - for (unsigned int i = 0 ; i < mZoomSubscribers.size(); i++ ) { - zoomEvent.mCookie = (void *) mZoomSubscribers.keyAt(i); - eventCb = (event_callback) mZoomSubscribers.valueAt(i); - - eventCb ( &zoomEvent ); - } - - zoomEvent.mEventData.clear(); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::notifyMetadataSubscribers(android::sp &meta) -{ - event_callback eventCb; - CameraHalEvent metaEvent; - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( mMetadataSubscribers.size() == 0 ) { - CAMHAL_LOGDA("No preview metadata subscribers!"); - return NO_INIT; - } - - metaEvent.mEventData = new CameraHalEvent::CameraHalEventData(); - if ( NULL == metaEvent.mEventData.get() ) { - return -ENOMEM; - } - - metaEvent.mEventType = CameraHalEvent::EVENT_METADATA; - metaEvent.mEventData->metadataEvent = meta; - - for (unsigned int i = 0 ; i < mMetadataSubscribers.size(); i++ ) { - metaEvent.mCookie = (void *) mMetadataSubscribers.keyAt(i); - eventCb = (event_callback) mMetadataSubscribers.valueAt(i); - - eventCb ( &metaEvent ); - } - - metaEvent.mEventData.clear(); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::sendFrameToSubscribers(CameraFrame *frame) -{ - status_t ret = NO_ERROR; - unsigned int mask; - - if ( NULL == frame ) - { - CAMHAL_LOGEA("Invalid CameraFrame"); - return -EINVAL; - } - - for( mask = 1; mask < CameraFrame::ALL_FRAMES; mask <<= 1){ - if( mask & frame->mFrameMask ){ - switch( mask ){ - - case CameraFrame::IMAGE_FRAME: - { -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - CameraHal::PPM("Shot to Jpeg: ", &mStartCapture); -#endif - ret = __sendFrameToSubscribers(frame, &mImageSubscribers, CameraFrame::IMAGE_FRAME); - } - break; - case CameraFrame::RAW_FRAME: - { - ret = __sendFrameToSubscribers(frame, &mRawSubscribers, CameraFrame::RAW_FRAME); - } - break; - case CameraFrame::PREVIEW_FRAME_SYNC: - { - ret = __sendFrameToSubscribers(frame, &mFrameSubscribers, CameraFrame::PREVIEW_FRAME_SYNC); - } - break; - case CameraFrame::SNAPSHOT_FRAME: - { - ret = __sendFrameToSubscribers(frame, &mSnapshotSubscribers, CameraFrame::SNAPSHOT_FRAME); - } - break; - case CameraFrame::VIDEO_FRAME_SYNC: - { - ret = __sendFrameToSubscribers(frame, &mVideoSubscribers, CameraFrame::VIDEO_FRAME_SYNC); - } - break; - case CameraFrame::FRAME_DATA_SYNC: - { - ret = __sendFrameToSubscribers(frame, &mFrameDataSubscribers, CameraFrame::FRAME_DATA_SYNC); - } - break; - case CameraFrame::REPROCESS_INPUT_FRAME: - { - ret = __sendFrameToSubscribers(frame, &mVideoInSubscribers, CameraFrame::REPROCESS_INPUT_FRAME); - } - break; - default: - CAMHAL_LOGEB("FRAMETYPE NOT SUPPORTED 0x%x", mask); - break; - }//SWITCH - frame->mFrameMask &= ~mask; - - if (ret != NO_ERROR) { - goto EXIT; - } - }//IF - }//FOR - - EXIT: - return ret; -} - -status_t BaseCameraAdapter::__sendFrameToSubscribers(CameraFrame* frame, - android::KeyedVector *subscribers, - CameraFrame::FrameType frameType) -{ - size_t refCount = 0; - status_t ret = NO_ERROR; - frame_callback callback = NULL; - - frame->mFrameType = frameType; - - if ( (frameType == CameraFrame::PREVIEW_FRAME_SYNC) || - (frameType == CameraFrame::VIDEO_FRAME_SYNC) || - (frameType == CameraFrame::SNAPSHOT_FRAME) ){ - if (mFrameQueue.size() > 0){ - CameraFrame *lframe = (CameraFrame *)mFrameQueue.valueFor(frame->mBuffer); - frame->mYuv[0] = lframe->mYuv[0]; - frame->mYuv[1] = frame->mYuv[0] + (frame->mLength + frame->mOffset)*2/3; - } - else{ - CAMHAL_LOGDA("Empty Frame Queue"); - return -EINVAL; - } - } - - if (NULL != subscribers) { - refCount = getFrameRefCount(frame->mBuffer, frameType); - - if (refCount == 0) { - CAMHAL_LOGDA("Invalid ref count of 0"); - return -EINVAL; - } - - if (refCount > subscribers->size()) { - CAMHAL_LOGEB("Invalid ref count for frame type: 0x%x", frameType); - return -EINVAL; - } - - CAMHAL_LOGSVB("Type of Frame: 0x%x address: 0x%x refCount start %d", - frame->mFrameType, - ( uint32_t ) frame->mBuffer, - refCount); - - for ( unsigned int i = 0 ; i < refCount; i++ ) { - frame->mCookie = ( void * ) subscribers->keyAt(i); - callback = (frame_callback) subscribers->valueAt(i); - - if (!callback) { - CAMHAL_LOGEB("callback not set for frame type: 0x%x", frameType); - return -EINVAL; - } - - callback(frame); - } - } else { - CAMHAL_LOGEA("Subscribers is null??"); - return -EINVAL; - } - - return ret; -} - -int BaseCameraAdapter::setInitFrameRefCount(CameraBuffer * buf, unsigned int mask) -{ - int ret = NO_ERROR; - unsigned int lmask; - - LOG_FUNCTION_NAME; - - if (buf == NULL) - { - return -EINVAL; - } - - for( lmask = 1; lmask < CameraFrame::ALL_FRAMES; lmask <<= 1){ - if( lmask & mask ){ - switch( lmask ){ - - case CameraFrame::IMAGE_FRAME: - { - setFrameRefCount(buf, CameraFrame::IMAGE_FRAME, (int) mImageSubscribers.size()); - } - break; - case CameraFrame::RAW_FRAME: - { - setFrameRefCount(buf, CameraFrame::RAW_FRAME, mRawSubscribers.size()); - } - break; - case CameraFrame::PREVIEW_FRAME_SYNC: - { - setFrameRefCount(buf, CameraFrame::PREVIEW_FRAME_SYNC, mFrameSubscribers.size()); - } - break; - case CameraFrame::SNAPSHOT_FRAME: - { - setFrameRefCount(buf, CameraFrame::SNAPSHOT_FRAME, mSnapshotSubscribers.size()); - } - break; - case CameraFrame::VIDEO_FRAME_SYNC: - { - setFrameRefCount(buf,CameraFrame::VIDEO_FRAME_SYNC, mVideoSubscribers.size()); - } - break; - case CameraFrame::FRAME_DATA_SYNC: - { - setFrameRefCount(buf, CameraFrame::FRAME_DATA_SYNC, mFrameDataSubscribers.size()); - } - break; - case CameraFrame::REPROCESS_INPUT_FRAME: - { - setFrameRefCount(buf,CameraFrame::REPROCESS_INPUT_FRAME, mVideoInSubscribers.size()); - } - break; - default: - CAMHAL_LOGEB("FRAMETYPE NOT SUPPORTED 0x%x", lmask); - break; - }//SWITCH - mask &= ~lmask; - }//IF - }//FOR - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -int BaseCameraAdapter::getFrameRefCount(CameraBuffer * frameBuf, CameraFrame::FrameType frameType) -{ - int res = -1; - - LOG_FUNCTION_NAME; - - switch ( frameType ) - { - case CameraFrame::IMAGE_FRAME: - case CameraFrame::RAW_FRAME: - { - android::AutoMutex lock(mCaptureBufferLock); - res = mCaptureBuffersAvailable.valueFor(frameBuf ); - } - break; - case CameraFrame::SNAPSHOT_FRAME: - { - android::AutoMutex lock(mSnapshotBufferLock); - res = mSnapshotBuffersAvailable.valueFor( ( unsigned int ) frameBuf ); - } - break; - case CameraFrame::PREVIEW_FRAME_SYNC: - { - android::AutoMutex lock(mPreviewBufferLock); - res = mPreviewBuffersAvailable.valueFor(frameBuf ); - } - break; - case CameraFrame::FRAME_DATA_SYNC: - { - android::AutoMutex lock(mPreviewDataBufferLock); - res = mPreviewDataBuffersAvailable.valueFor(frameBuf ); - } - break; - case CameraFrame::VIDEO_FRAME_SYNC: - { - android::AutoMutex lock(mVideoBufferLock); - res = mVideoBuffersAvailable.valueFor(frameBuf ); - } - break; - case CameraFrame::REPROCESS_INPUT_FRAME: { - android::AutoMutex lock(mVideoInBufferLock); - res = mVideoInBuffersAvailable.valueFor(frameBuf ); - } - break; - default: - break; - }; - - LOG_FUNCTION_NAME_EXIT; - - return res; -} - -void BaseCameraAdapter::setFrameRefCount(CameraBuffer * frameBuf, CameraFrame::FrameType frameType, int refCount) -{ - - LOG_FUNCTION_NAME; - - switch ( frameType ) - { - case CameraFrame::IMAGE_FRAME: - case CameraFrame::RAW_FRAME: - { - android::AutoMutex lock(mCaptureBufferLock); - mCaptureBuffersAvailable.replaceValueFor(frameBuf, refCount); - } - break; - case CameraFrame::SNAPSHOT_FRAME: - { - android::AutoMutex lock(mSnapshotBufferLock); - mSnapshotBuffersAvailable.replaceValueFor( ( unsigned int ) frameBuf, refCount); - } - break; - case CameraFrame::PREVIEW_FRAME_SYNC: - { - android::AutoMutex lock(mPreviewBufferLock); - mPreviewBuffersAvailable.replaceValueFor(frameBuf, refCount); - } - break; - case CameraFrame::FRAME_DATA_SYNC: - { - android::AutoMutex lock(mPreviewDataBufferLock); - mPreviewDataBuffersAvailable.replaceValueFor(frameBuf, refCount); - } - break; - case CameraFrame::VIDEO_FRAME_SYNC: - { - android::AutoMutex lock(mVideoBufferLock); - mVideoBuffersAvailable.replaceValueFor(frameBuf, refCount); - } - break; - case CameraFrame::REPROCESS_INPUT_FRAME: { - android::AutoMutex lock(mVideoInBufferLock); - mVideoInBuffersAvailable.replaceValueFor(frameBuf, refCount); - } - break; - default: - break; - }; - - LOG_FUNCTION_NAME_EXIT; - -} - -status_t BaseCameraAdapter::startVideoCapture() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mVideoBufferLock); - - //If the capture is already ongoing, return from here. - if ( mRecording ) - { - ret = NO_INIT; - } - - - if ( NO_ERROR == ret ) - { - - for ( unsigned int i = 0 ; i < mPreviewBuffersAvailable.size() ; i++ ) - { - mVideoBuffersAvailable.add(mPreviewBuffersAvailable.keyAt(i), 0); - } - - mRecording = true; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::stopVideoCapture() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( !mRecording ) - { - ret = NO_INIT; - } - - if ( NO_ERROR == ret ) - { - for ( unsigned int i = 0 ; i < mVideoBuffersAvailable.size() ; i++ ) - { - CameraBuffer *frameBuf = mVideoBuffersAvailable.keyAt(i); - if( getFrameRefCount(frameBuf, CameraFrame::VIDEO_FRAME_SYNC) > 0) - { - returnFrame(frameBuf, CameraFrame::VIDEO_FRAME_SYNC); - } - } - - mVideoBuffersAvailable.clear(); - - mRecording = false; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -//-----------------Stub implementation of the interface ------------------------------ - -status_t BaseCameraAdapter::takePicture() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::stopImageCapture() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::startBracketing(int range) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::stopBracketing() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::autoFocus() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - notifyFocusSubscribers(CameraHalEvent::FOCUS_STATUS_FAIL); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::cancelAutoFocus() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::startSmoothZoom(int targetIdx) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::stopSmoothZoom() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::startPreview() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::stopPreview() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::useBuffers(CameraMode mode, CameraBuffer* bufArr, int num, size_t length, unsigned int queueable) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::fillThisBuffer(CameraBuffer * frameBuf, CameraFrame::FrameType frameType) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::getFrameSize(size_t &width, size_t &height) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::getFrameDataSize(size_t &dataFrameSize, size_t bufferCount) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::getPictureBufferSize(CameraFrame &frame, size_t bufferCount) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::startFaceDetection() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::stopFaceDetection() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::switchToExecuting() -{ - status_t ret = NO_ERROR; - LOG_FUNCTION_NAME; - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -const char* BaseCameraAdapter::getLUTvalue_translateHAL(int Value, LUTtypeHAL LUT) { - int LUTsize = LUT.size; - for(int i = 0; i < LUTsize; i++) - if( LUT.Table[i].halDefinition == Value ) - return LUT.Table[i].userDefinition; - - return NULL; -} - -status_t BaseCameraAdapter::setupTunnel(uint32_t SliceHeight, uint32_t EncoderHandle, uint32_t width, uint32_t height) { - status_t ret = NO_ERROR; - LOG_FUNCTION_NAME; - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -status_t BaseCameraAdapter::destroyTunnel() { - status_t ret = NO_ERROR; - LOG_FUNCTION_NAME; - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -status_t BaseCameraAdapter::cameraPreviewInitialization() { - status_t ret = NO_ERROR; - LOG_FUNCTION_NAME; - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -status_t BaseCameraAdapter::setState(CameraCommands operation) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - const char *printState = getLUTvalue_translateHAL(operation, CamCommandsLUT); - - mLock.lock(); - - switch ( mAdapterState ) - { - - case INTIALIZED_STATE: - - switch ( operation ) - { - - case CAMERA_USE_BUFFERS_PREVIEW: - CAMHAL_LOGDB("Adapter state switch INTIALIZED_STATE->LOADED_PREVIEW_STATE event = %s", - printState); - mNextState = LOADED_PREVIEW_STATE; - break; - - //These events don't change the current state - case CAMERA_QUERY_RESOLUTION_PREVIEW: - case CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE: - case CAMERA_QUERY_BUFFER_SIZE_PREVIEW_DATA: - CAMHAL_LOGDB("Adapter state switch INTIALIZED_STATE->INTIALIZED_STATE event = %s", - printState); - mNextState = INTIALIZED_STATE; - break; - case CAMERA_STOP_BRACKET_CAPTURE: - case CAMERA_STOP_IMAGE_CAPTURE: - ret = INVALID_OPERATION; - break; - case CAMERA_CANCEL_AUTOFOCUS: - ret = INVALID_OPERATION; - break; - - default: - CAMHAL_LOGEB("Adapter state switch INTIALIZED_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case LOADED_PREVIEW_STATE: - - switch ( operation ) - { - - case CAMERA_START_PREVIEW: - CAMHAL_LOGDB("Adapter state switch LOADED_PREVIEW_STATE->PREVIEW_STATE event = %s", - printState); - mNextState = PREVIEW_STATE; - break; - - case CAMERA_STOP_PREVIEW: - CAMHAL_LOGDB("Adapter state switch LOADED_PREVIEW_STATE->INTIALIZED_STATE event = 0x%x", - operation); - mNextState = INTIALIZED_STATE; - break; - - //These events don't change the current state - case CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE: - case CAMERA_QUERY_BUFFER_SIZE_PREVIEW_DATA: - case CAMERA_USE_BUFFERS_PREVIEW_DATA: - CAMHAL_LOGDB("Adapter state switch LOADED_PREVIEW_STATE->LOADED_PREVIEW_STATE event = %s", - printState); - mNextState = LOADED_PREVIEW_STATE; - break; - - default: - CAMHAL_LOGDB("Adapter state switch LOADED_PREVIEW Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case PREVIEW_STATE: - - switch ( operation ) - { - - case CAMERA_STOP_PREVIEW: - CAMHAL_LOGDB("Adapter state switch PREVIEW_STATE->INTIALIZED_STATE event = %s", - printState); - mNextState = INTIALIZED_STATE; - break; - - case CAMERA_PERFORM_AUTOFOCUS: - CAMHAL_LOGDB("Adapter state switch PREVIEW_STATE->AF_STATE event = %s", - printState); - mNextState = AF_STATE; - break; - - case CAMERA_START_SMOOTH_ZOOM: - CAMHAL_LOGDB("Adapter state switch PREVIEW_STATE->ZOOM_STATE event = %s", - printState); - mNextState = ZOOM_STATE; - break; - - case CAMERA_USE_BUFFERS_IMAGE_CAPTURE: - CAMHAL_LOGDB("Adapter state switch PREVIEW_STATE->LOADED_CAPTURE_STATE event = %s", - printState); - mNextState = LOADED_CAPTURE_STATE; - break; - -#ifdef OMAP_ENHANCEMENT_CPCAM - case CAMERA_USE_BUFFERS_REPROCESS: - CAMHAL_LOGDB("Adapter state switch PREVIEW_STATE->LOADED_REPROCESS_STATE event = %s", - printState); - mNextState = LOADED_REPROCESS_STATE; - break; -#endif - - case CAMERA_START_VIDEO: - CAMHAL_LOGDB("Adapter state switch PREVIEW_STATE->VIDEO_STATE event = %s", - printState); - mNextState = VIDEO_STATE; - break; - - case CAMERA_CANCEL_AUTOFOCUS: - case CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE: - case CAMERA_STOP_SMOOTH_ZOOM: - CAMHAL_LOGDB("Adapter state switch PREVIEW_ACTIVE->PREVIEW_ACTIVE event = %s", - printState); - mNextState = PREVIEW_STATE; - break; - - case CAMERA_STOP_IMAGE_CAPTURE: - case CAMERA_STOP_BRACKET_CAPTURE: - CAMHAL_LOGDB("Adapter state switch PREVIEW_ACTIVE->PREVIEW_ACTIVE event = %s", - printState); - ret = INVALID_OPERATION; - break; - - default: - CAMHAL_LOGEB("Adapter state switch PREVIEW_ACTIVE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - -#ifdef OMAP_ENHANCEMENT_CPCAM - case LOADED_REPROCESS_STATE: - switch (operation) { - case CAMERA_USE_BUFFERS_IMAGE_CAPTURE: - CAMHAL_LOGDB("Adapter state switch LOADED_REPROCESS_STATE->LOADED_REPROCESS_CAPTURE_STATE event = %s", - printState); - mNextState = LOADED_REPROCESS_CAPTURE_STATE; - break; - case CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE: - CAMHAL_LOGDB("Adapter state switch LOADED_REPROCESS_STATE->LOADED_REPROCESS_STATE event = %s", - printState); - mNextState = LOADED_REPROCESS_STATE; - break; - default: - CAMHAL_LOGEB("Adapter state switch LOADED_REPROCESS_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - } - - break; - - case LOADED_REPROCESS_CAPTURE_STATE: - switch (operation) { - case CAMERA_START_IMAGE_CAPTURE: - CAMHAL_LOGDB("Adapter state switch LOADED_REPROCESS_CAPTURE_STATE->REPROCESS_STATE event = %s", - printState); - mNextState = REPROCESS_STATE; - break; - default: - CAMHAL_LOGEB("Adapter state switch LOADED_REPROCESS_CAPTURE_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - } - break; -#endif - - case LOADED_CAPTURE_STATE: - - switch ( operation ) - { - - case CAMERA_START_IMAGE_CAPTURE: - CAMHAL_LOGDB("Adapter state switch LOADED_CAPTURE_STATE->CAPTURE_STATE event = %s", - printState); - mNextState = CAPTURE_STATE; - break; - - case CAMERA_START_BRACKET_CAPTURE: - CAMHAL_LOGDB("Adapter state switch LOADED_CAPTURE_STATE->BRACKETING_STATE event = %s", - printState); - mNextState = BRACKETING_STATE; - break; - - case CAMERA_USE_BUFFERS_VIDEO_CAPTURE: - //Hadnle this state for raw capture path. - //Just need to keep the same state. - //The next CAMERA_START_IMAGE_CAPTURE command will assign the mNextState. - CAMHAL_LOGDB("Adapter state switch LOADED_CAPTURE_STATE->LOADED_CAPTURE_STATE event = %s", - printState); - break; - - default: - CAMHAL_LOGEB("Adapter state switch LOADED_CAPTURE_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case CAPTURE_STATE: - - switch ( operation ) - { - case CAMERA_STOP_IMAGE_CAPTURE: - case CAMERA_STOP_BRACKET_CAPTURE: - CAMHAL_LOGDB("Adapter state switch CAPTURE_STATE->PREVIEW_STATE event = %s", - printState); - mNextState = PREVIEW_STATE; - break; - - case CAMERA_START_IMAGE_CAPTURE: - CAMHAL_LOGDB("Adapter state switch CAPTURE_STATE->CAPTURE_STATE event = %s", - printState); - mNextState = CAPTURE_STATE; - break; - -#ifdef OMAP_ENHANCEMENT_CPCAM - case CAMERA_USE_BUFFERS_REPROCESS: - CAMHAL_LOGDB("Adapter state switch CAPTURE_STATE->->LOADED_REPROCESS_STATE event = %s", - printState); - mNextState = LOADED_REPROCESS_STATE; - break; -#endif - - default: - CAMHAL_LOGEB("Adapter state switch CAPTURE_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case BRACKETING_STATE: - - switch ( operation ) - { - - case CAMERA_STOP_IMAGE_CAPTURE: - case CAMERA_STOP_BRACKET_CAPTURE: - CAMHAL_LOGDB("Adapter state switch BRACKETING_STATE->PREVIEW_STATE event = %s", - printState); - mNextState = PREVIEW_STATE; - break; - - case CAMERA_START_IMAGE_CAPTURE: - CAMHAL_LOGDB("Adapter state switch BRACKETING_STATE->CAPTURE_STATE event = %s", - printState); - mNextState = CAPTURE_STATE; - break; - - default: - CAMHAL_LOGEB("Adapter state switch BRACKETING_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case AF_STATE: - - switch ( operation ) - { - - case CAMERA_CANCEL_AUTOFOCUS: - CAMHAL_LOGDB("Adapter state switch AF_STATE->PREVIEW_STATE event = %s", - printState); - mNextState = PREVIEW_STATE; - break; - - case CAMERA_START_SMOOTH_ZOOM: - CAMHAL_LOGDB("Adapter state switch AF_STATE->AF_ZOOM_STATE event = %s", - printState); - mNextState = AF_ZOOM_STATE; - break; - - default: - CAMHAL_LOGEB("Adapter state switch AF_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case ZOOM_STATE: - - switch ( operation ) - { - - case CAMERA_CANCEL_AUTOFOCUS: - CAMHAL_LOGDB("Adapter state switch AF_STATE->PREVIEW_STATE event = %s", - printState); - mNextState = ZOOM_STATE; - break; - - case CAMERA_STOP_SMOOTH_ZOOM: - CAMHAL_LOGDB("Adapter state switch ZOOM_STATE->PREVIEW_STATE event = %s", - printState); - mNextState = PREVIEW_STATE; - break; - - case CAMERA_PERFORM_AUTOFOCUS: - CAMHAL_LOGDB("Adapter state switch ZOOM_STATE->AF_ZOOM_STATE event = %s", - printState); - mNextState = AF_ZOOM_STATE; - break; - - case CAMERA_START_VIDEO: - CAMHAL_LOGDB("Adapter state switch ZOOM_STATE->VIDEO_ZOOM_STATE event = %s", - printState); - mNextState = VIDEO_ZOOM_STATE; - break; - - default: - CAMHAL_LOGEB("Adapter state switch ZOOM_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case VIDEO_STATE: - - switch ( operation ) - { - - case CAMERA_STOP_VIDEO: - CAMHAL_LOGDB("Adapter state switch VIDEO_STATE->PREVIEW_STATE event = %s", - printState); - mNextState = PREVIEW_STATE; - break; - - case CAMERA_PERFORM_AUTOFOCUS: - CAMHAL_LOGDB("Adapter state switch VIDEO_STATE->VIDEO_AF_STATE event = %s", - printState); - mNextState = VIDEO_AF_STATE; - break; - - case CAMERA_START_SMOOTH_ZOOM: - CAMHAL_LOGDB("Adapter state switch VIDEO_STATE->VIDEO_ZOOM_STATE event = %s", - printState); - mNextState = VIDEO_ZOOM_STATE; - break; - - case CAMERA_USE_BUFFERS_IMAGE_CAPTURE: - CAMHAL_LOGDB("Adapter state switch VIDEO_STATE->VIDEO_LOADED_CAPTURE_STATE event = %s", - printState); - mNextState = VIDEO_LOADED_CAPTURE_STATE; - break; - - case CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE: - CAMHAL_LOGDB("Adapter state switch VIDEO_STATE->VIDEO_STATE event = %s", - printState); - mNextState = VIDEO_STATE; - break; - - default: - CAMHAL_LOGEB("Adapter state switch VIDEO_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case VIDEO_AF_STATE: - - switch ( operation ) - { - - case CAMERA_CANCEL_AUTOFOCUS: - CAMHAL_LOGDB("Adapter state switch VIDEO_AF_STATE->VIDEO_STATE event = %s", - printState); - mNextState = VIDEO_STATE; - break; - - default: - CAMHAL_LOGEB("Adapter state switch VIDEO_AF_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case VIDEO_LOADED_CAPTURE_STATE: - - switch ( operation ) - { - - case CAMERA_START_IMAGE_CAPTURE: - CAMHAL_LOGDB("Adapter state switch LOADED_CAPTURE_STATE->CAPTURE_STATE event = %s", - printState); - mNextState = VIDEO_CAPTURE_STATE; - break; - - default: - CAMHAL_LOGEB("Adapter state switch LOADED_CAPTURE_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case VIDEO_CAPTURE_STATE: - - switch ( operation ) - { - case CAMERA_STOP_IMAGE_CAPTURE: - CAMHAL_LOGDB("Adapter state switch CAPTURE_STATE->PREVIEW_STATE event = %s", - printState); - mNextState = VIDEO_STATE; - break; - - default: - CAMHAL_LOGEB("Adapter state switch CAPTURE_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case AF_ZOOM_STATE: - - switch ( operation ) - { - - case CAMERA_STOP_SMOOTH_ZOOM: - CAMHAL_LOGDB("Adapter state switch AF_ZOOM_STATE->AF_STATE event = %s", - printState); - mNextState = AF_STATE; - break; - - case CAMERA_CANCEL_AUTOFOCUS: - CAMHAL_LOGDB("Adapter state switch AF_ZOOM_STATE->ZOOM_STATE event = %s", - printState); - mNextState = ZOOM_STATE; - break; - - default: - CAMHAL_LOGEB("Adapter state switch AF_ZOOM_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case VIDEO_ZOOM_STATE: - - switch ( operation ) - { - - case CAMERA_STOP_SMOOTH_ZOOM: - CAMHAL_LOGDB("Adapter state switch VIDEO_ZOOM_STATE->VIDEO_STATE event = %s", - printState); - mNextState = VIDEO_STATE; - break; - - case CAMERA_STOP_VIDEO: - CAMHAL_LOGDB("Adapter state switch VIDEO_ZOOM_STATE->ZOOM_STATE event = %s", - printState); - mNextState = ZOOM_STATE; - break; - - default: - CAMHAL_LOGEB("Adapter state switch VIDEO_ZOOM_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - - case BRACKETING_ZOOM_STATE: - - switch ( operation ) - { - - case CAMERA_STOP_SMOOTH_ZOOM: - CAMHAL_LOGDB("Adapter state switch BRACKETING_ZOOM_STATE->BRACKETING_STATE event = %s", - printState); - mNextState = BRACKETING_STATE; - break; - - default: - CAMHAL_LOGEB("Adapter state switch BRACKETING_ZOOM_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; - -#ifdef OMAP_ENHANCEMENT_CPCAM - case REPROCESS_STATE: - switch (operation) { - case CAMERA_STOP_IMAGE_CAPTURE: - CAMHAL_LOGDB("Adapter state switch REPROCESS_STATE->PREVIEW_STATE event = %s", - printState); - mNextState = PREVIEW_STATE; - break; - case CAMERA_START_IMAGE_CAPTURE: - case CAMERA_USE_BUFFERS_REPROCESS: - CAMHAL_LOGDB("Adapter state switch REPROCESS_STATE->REPROCESS_STATE event = %s", - printState); - mNextState = REPROCESS_STATE; - break; - - default: - CAMHAL_LOGEB("Adapter state switch REPROCESS_STATE Invalid Op! event = %s", - printState); - ret = INVALID_OPERATION; - break; - - } - - break; -#endif - - - default: - CAMHAL_LOGEA("Invalid Adapter state!"); - ret = INVALID_OPERATION; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::rollbackToInitializedState() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - while ((getState() != INTIALIZED_STATE) && (ret == NO_ERROR)) { - ret = rollbackToPreviousState(); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::rollbackToPreviousState() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - CameraAdapter::AdapterState currentState = getState(); - - switch (currentState) { - case INTIALIZED_STATE: - return NO_ERROR; - - case PREVIEW_STATE: - ret = sendCommand(CAMERA_STOP_PREVIEW); - break; - - case CAPTURE_STATE: -#ifdef OMAP_ENHANCEMENT_CPCAM - case REPROCESS_STATE: -#endif - ret = sendCommand(CAMERA_STOP_IMAGE_CAPTURE); - break; - - case BRACKETING_STATE: - ret = sendCommand(CAMERA_STOP_BRACKET_CAPTURE); - break; - - case AF_STATE: - ret = sendCommand(CAMERA_CANCEL_AUTOFOCUS); - break; - - case ZOOM_STATE: - ret = sendCommand(CAMERA_STOP_SMOOTH_ZOOM); - break; - - case VIDEO_STATE: - ret = sendCommand(CAMERA_STOP_VIDEO); - break; - - case VIDEO_AF_STATE: - ret = sendCommand(CAMERA_CANCEL_AUTOFOCUS); - break; - - case VIDEO_CAPTURE_STATE: - ret = sendCommand(CAMERA_STOP_IMAGE_CAPTURE); - break; - - case AF_ZOOM_STATE: - ret = sendCommand(CAMERA_STOP_SMOOTH_ZOOM); - break; - - case VIDEO_ZOOM_STATE: - ret = sendCommand(CAMERA_STOP_SMOOTH_ZOOM); - break; - - case BRACKETING_ZOOM_STATE: - ret = sendCommand(CAMERA_STOP_SMOOTH_ZOOM); - break; - - default: - CAMHAL_LOGEA("Invalid Adapter state!"); - ret = INVALID_OPERATION; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -//State transition finished successfully. -//Commit the state and unlock the adapter state. -status_t BaseCameraAdapter::commitState() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - mAdapterState = mNextState; - - mLock.unlock(); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::rollbackState() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - mNextState = mAdapterState; - - mLock.unlock(); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -// getNextState() and getState() -// publicly exposed functions to retrieve the adapter states -// please notice that these functions are locked -CameraAdapter::AdapterState BaseCameraAdapter::getState() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mLock); - - LOG_FUNCTION_NAME_EXIT; - - return mAdapterState; -} - -CameraAdapter::AdapterState BaseCameraAdapter::getNextState() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mLock); - - LOG_FUNCTION_NAME_EXIT; - - return mNextState; -} - -// getNextState() and getState() -// internal protected functions to retrieve the adapter states -// please notice that these functions are NOT locked to help -// internal functions query state in the middle of state -// transition -status_t BaseCameraAdapter::getState(AdapterState &state) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - state = mAdapterState; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t BaseCameraAdapter::getNextState(AdapterState &state) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - state = mNextState; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -void BaseCameraAdapter::onOrientationEvent(uint32_t orientation, uint32_t tilt) -{ - LOG_FUNCTION_NAME; - LOG_FUNCTION_NAME_EXIT; -} - -//----------------------------------------------------------------------------- - -extern "C" status_t OMXCameraAdapter_Capabilities( - CameraProperties::Properties * const properties_array, - const int starting_camera, const int max_camera, int & supportedCameras); -extern "C" status_t V4LCameraAdapter_Capabilities( - CameraProperties::Properties * const properties_array, - const int starting_camera, const int max_camera, int & supportedCameras); - -extern "C" status_t CameraAdapter_Capabilities( - CameraProperties::Properties * const properties_array, - const int starting_camera, const int max_camera, int & supportedCameras) -{ - - status_t ret = NO_ERROR; - status_t err = NO_ERROR; - int num_cameras_supported = 0; - - LOG_FUNCTION_NAME; - - supportedCameras = 0; -#ifdef OMX_CAMERA_ADAPTER - //Query OMX cameras - err = OMXCameraAdapter_Capabilities( properties_array, starting_camera, - max_camera, supportedCameras); - if(err != NO_ERROR) { - CAMHAL_LOGEA("error while getting OMXCameraAdapter capabilities"); - ret = UNKNOWN_ERROR; - } -#endif -#ifdef V4L_CAMERA_ADAPTER - //Query V4L cameras - err = V4LCameraAdapter_Capabilities( properties_array, (const int) supportedCameras, - max_camera, num_cameras_supported); - if(err != NO_ERROR) { - CAMHAL_LOGEA("error while getting V4LCameraAdapter capabilities"); - ret = UNKNOWN_ERROR; - } -#endif - - supportedCameras += num_cameras_supported; - CAMHAL_LOGEB("supportedCameras= %d\n", supportedCameras); - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -//----------------------------------------------------------------------------- - -} // namespace Camera -} // namespace Ti - -/*--------------------Camera Adapter Class ENDS here-----------------------------*/ - diff --git a/camera/BufferSourceAdapter.cpp b/camera/BufferSourceAdapter.cpp deleted file mode 100644 index 7a57b4b..0000000 --- a/camera/BufferSourceAdapter.cpp +++ /dev/null @@ -1,816 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef OMAP_ENHANCEMENT_CPCAM - -#include "BufferSourceAdapter.h" -#include -#include -#include - -namespace Ti { -namespace Camera { - -static int getANWFormat(const char* parameters_format) -{ - int format = HAL_PIXEL_FORMAT_TI_NV12; - - if (parameters_format != NULL) { - if (strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { - CAMHAL_LOGDA("CbYCrY format selected"); - // TODO(XXX): not defined yet - format = -1; - } else if (strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { - CAMHAL_LOGDA("YUV420SP format selected"); - format = HAL_PIXEL_FORMAT_TI_NV12; - } else if (strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_RGB565) == 0) { - CAMHAL_LOGDA("RGB565 format selected"); - // TODO(XXX): not defined yet - format = -1; - } else if (strcmp(parameters_format, android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB) == 0) { - format = HAL_PIXEL_FORMAT_TI_Y16; - } else { - CAMHAL_LOGDA("Invalid format, NV12 format selected as default"); - format = HAL_PIXEL_FORMAT_TI_NV12; - } - } - - return format; -} - -static int getUsageFromANW(int format) -{ - int usage = GRALLOC_USAGE_SW_READ_RARELY | - GRALLOC_USAGE_SW_WRITE_NEVER; - - switch (format) { - case HAL_PIXEL_FORMAT_TI_NV12: - // This usage flag indicates to gralloc we want the - // buffers to come from system heap - usage |= GRALLOC_USAGE_PRIVATE_0; - break; - case HAL_PIXEL_FORMAT_TI_Y16: - default: - // No special flags needed - break; - } - return usage; -} - -static const char* getFormatFromANW(int format) -{ - switch (format) { - case HAL_PIXEL_FORMAT_TI_NV12: - // Assuming NV12 1D is RAW or Image frame - return android::CameraParameters::PIXEL_FORMAT_YUV420SP; - case HAL_PIXEL_FORMAT_TI_Y16: - return android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB; - default: - break; - } - return android::CameraParameters::PIXEL_FORMAT_YUV420SP; -} - -static CameraFrame::FrameType formatToOutputFrameType(const char* format) { - switch (getANWFormat(format)) { - case HAL_PIXEL_FORMAT_TI_NV12: - case HAL_PIXEL_FORMAT_TI_Y16: - // Assuming NV12 1D is RAW or Image frame - return CameraFrame::RAW_FRAME; - default: - break; - } - return CameraFrame::RAW_FRAME; -} - -static int getHeightFromFormat(const char* format, int stride, int size) { - CAMHAL_ASSERT((NULL != format) && (0 <= stride) && (0 <= size)); - switch (getANWFormat(format)) { - case HAL_PIXEL_FORMAT_TI_NV12: - return (size / (3 * stride)) * 2; - case HAL_PIXEL_FORMAT_TI_Y16: - return (size / stride) / 2; - default: - break; - } - return 0; -} - -/*--------------------BufferSourceAdapter Class STARTS here-----------------------------*/ - - -/** - * Display Adapter class STARTS here.. - */ -BufferSourceAdapter::BufferSourceAdapter() : mBufferCount(0) -{ - LOG_FUNCTION_NAME; - - mPixelFormat = NULL; - mBuffers = NULL; - mFrameProvider = NULL; - mBufferSource = NULL; - - mFrameWidth = 0; - mFrameHeight = 0; - mPreviewWidth = 0; - mPreviewHeight = 0; - - LOG_FUNCTION_NAME_EXIT; -} - -BufferSourceAdapter::~BufferSourceAdapter() -{ - LOG_FUNCTION_NAME; - - destroy(); - - if (mFrameProvider) { - // Unregister with the frame provider - mFrameProvider->disableFrameNotification(CameraFrame::ALL_FRAMES); - delete mFrameProvider; - mFrameProvider = NULL; - } - - if (mQueueFrame.get()) { - mQueueFrame->requestExit(); - mQueueFrame.clear(); - } - - if (mReturnFrame.get()) { - mReturnFrame->requestExit(); - mReturnFrame.clear(); - } - - if( mBuffers != NULL) - { - delete [] mBuffers; - mBuffers = NULL; - } - - LOG_FUNCTION_NAME_EXIT; -} - -status_t BufferSourceAdapter::initialize() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - mReturnFrame.clear(); - mReturnFrame = new ReturnFrame(this); - mReturnFrame->run(); - - mQueueFrame.clear(); - mQueueFrame = new QueueFrame(this); - mQueueFrame->run(); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -int BufferSourceAdapter::setPreviewWindow(preview_stream_ops_t *source) -{ - LOG_FUNCTION_NAME; - - if (!source) { - CAMHAL_LOGEA("NULL window object passed to DisplayAdapter"); - LOG_FUNCTION_NAME_EXIT; - return BAD_VALUE; - } - - if ( source == mBufferSource ) { - return ALREADY_EXISTS; - } - - // Destroy the existing source, if it exists - destroy(); - - // Move to new source obj - mBufferSource = source; - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -int BufferSourceAdapter::setFrameProvider(FrameNotifier *frameProvider) -{ - LOG_FUNCTION_NAME; - - if ( !frameProvider ) { - CAMHAL_LOGEA("NULL passed for frame provider"); - LOG_FUNCTION_NAME_EXIT; - return BAD_VALUE; - } - - if ( NULL != mFrameProvider ) { - delete mFrameProvider; - } - - mFrameProvider = new FrameProvider(frameProvider, this, frameCallback); - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -int BufferSourceAdapter::setErrorHandler(ErrorNotifier *errorNotifier) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( NULL == errorNotifier ) { - CAMHAL_LOGEA("Invalid Error Notifier reference"); - return -EINVAL; - } - - mErrorNotifier = errorNotifier; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -int BufferSourceAdapter::enableDisplay(int width, int height, - struct timeval *refTime) -{ - LOG_FUNCTION_NAME; - CameraFrame::FrameType frameType; - - if (mFrameProvider == NULL) { - // no-op frame provider not set yet - return NO_ERROR; - } - - if (mBufferSourceDirection == BUFFER_SOURCE_TAP_IN) { - // only supporting one type of input frame - frameType = CameraFrame::REPROCESS_INPUT_FRAME; - } else { - frameType = formatToOutputFrameType(mPixelFormat); - } - - mFrameProvider->enableFrameNotification(frameType); - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -int BufferSourceAdapter::disableDisplay(bool cancel_buffer) -{ - LOG_FUNCTION_NAME; - - if (mFrameProvider) mFrameProvider->disableFrameNotification(CameraFrame::ALL_FRAMES); - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -status_t BufferSourceAdapter::pauseDisplay(bool pause) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - // no-op for BufferSourceAdapter - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - - -void BufferSourceAdapter::destroy() -{ - LOG_FUNCTION_NAME; - - mBufferCount = 0; - - LOG_FUNCTION_NAME_EXIT; -} - -CameraBuffer* BufferSourceAdapter::allocateBufferList(int width, int dummyHeight, const char* format, - int &bytes, int numBufs) -{ - LOG_FUNCTION_NAME; - status_t err; - int i = -1; - const int lnumBufs = numBufs; - int undequeued = 0; - android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get(); - - mBuffers = new CameraBuffer [lnumBufs]; - memset (mBuffers, 0, sizeof(CameraBuffer) * lnumBufs); - - if ( NULL == mBufferSource ) { - return NULL; - } - - int pixFormat = getANWFormat(format); - int usage = getUsageFromANW(pixFormat); - - // Set gralloc usage bits for window. - err = mBufferSource->set_usage(mBufferSource, usage); - if (err != 0) { - CAMHAL_LOGE("native_window_set_usage failed: %s (%d)", strerror(-err), -err); - - if ( ENODEV == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mBufferSource = NULL; - } - - return NULL; - } - - CAMHAL_LOGDB("Number of buffers set to ANativeWindow %d", numBufs); - // Set the number of buffers needed for this buffer source - err = mBufferSource->set_buffer_count(mBufferSource, numBufs); - if (err != 0) { - CAMHAL_LOGE("native_window_set_buffer_count failed: %s (%d)", strerror(-err), -err); - - if ( ENODEV == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mBufferSource = NULL; - } - - return NULL; - } - - CAMHAL_LOGDB("Configuring %d buffers for ANativeWindow", numBufs); - mBufferCount = numBufs; - - // re-calculate height depending on stride and size - int height = getHeightFromFormat(format, width, bytes); - - // Set window geometry - err = mBufferSource->set_buffers_geometry(mBufferSource, - width, height, - pixFormat); - - if (err != 0) { - CAMHAL_LOGE("native_window_set_buffers_geometry failed: %s (%d)", strerror(-err), -err); - if ( ENODEV == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mBufferSource = NULL; - } - return NULL; - } - - if ( mBuffers == NULL ) { - CAMHAL_LOGEA("Couldn't create array for ANativeWindow buffers"); - LOG_FUNCTION_NAME_EXIT; - return NULL; - } - - mBufferSource->get_min_undequeued_buffer_count(mBufferSource, &undequeued); - - for (i = 0; i < mBufferCount; i++ ) { - buffer_handle_t *handle; - int stride; // dummy variable to get stride - // TODO(XXX): Do we need to keep stride information in camera hal? - - err = mBufferSource->dequeue_buffer(mBufferSource, &handle, &stride); - - if (err != 0) { - CAMHAL_LOGEB("dequeueBuffer failed: %s (%d)", strerror(-err), -err); - if ( ENODEV == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mBufferSource = NULL; - } - goto fail; - } - - CAMHAL_LOGDB("got handle %p", handle); - mBuffers[i].opaque = (void *)handle; - mBuffers[i].type = CAMERA_BUFFER_ANW; - mFramesWithCameraAdapterMap.add(handle, i); - - bytes = getBufSize(format, width, height); - } - - for( i = 0; i < mBufferCount-undequeued; i++ ) { - void *y_uv[2]; - android::Rect bounds(width, height); - - buffer_handle_t *handle = (buffer_handle_t *) mBuffers[i].opaque; - mBufferSource->lock_buffer(mBufferSource, handle); - mapper.lock(*handle, CAMHAL_GRALLOC_USAGE, bounds, y_uv); - mBuffers[i].mapped = y_uv[0]; - } - - // return the rest of the buffers back to ANativeWindow - for(i = (mBufferCount-undequeued); i >= 0 && i < mBufferCount; i++) { - buffer_handle_t *handle = (buffer_handle_t *) mBuffers[i].opaque; - void *y_uv[2]; - android::Rect bounds(width, height); - - mapper.lock(*handle, CAMHAL_GRALLOC_USAGE, bounds, y_uv); - mBuffers[i].mapped = y_uv[0]; - mapper.unlock(*handle); - - err = mBufferSource->cancel_buffer(mBufferSource, handle); - if (err != 0) { - CAMHAL_LOGEB("cancel_buffer failed: %s (%d)", strerror(-err), -err); - if ( ENODEV == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mBufferSource = NULL; - } - goto fail; - } - mFramesWithCameraAdapterMap.removeItem((buffer_handle_t *) mBuffers[i].opaque); - } - - mPixelFormat = getPixFormatConstant(format); - mFrameWidth = width; - mFrameHeight = height; - mBufferSourceDirection = BUFFER_SOURCE_TAP_OUT; - - return mBuffers; - - fail: - // need to cancel buffers if any were dequeued - for (int start = 0; start < i && i > 0; start++) { - int err = mBufferSource->cancel_buffer(mBufferSource, - (buffer_handle_t *) mBuffers[start].opaque); - if (err != 0) { - CAMHAL_LOGEB("cancelBuffer failed w/ error 0x%08x", err); - break; - } - mFramesWithCameraAdapterMap.removeItem((buffer_handle_t *) mBuffers[start].opaque); - } - - freeBufferList(mBuffers); - - CAMHAL_LOGEA("Error occurred, performing cleanup"); - - if (NULL != mErrorNotifier.get()) { - mErrorNotifier->errorNotify(-ENOMEM); - } - - LOG_FUNCTION_NAME_EXIT; - return NULL; - -} - -CameraBuffer* BufferSourceAdapter::getBufferList(int *num) { - LOG_FUNCTION_NAME; - status_t err; - const int lnumBufs = 1; - int formatSource; - android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get(); - buffer_handle_t *handle; - - // TODO(XXX): Only supporting one input buffer at a time right now - *num = 1; - mBuffers = new CameraBuffer [lnumBufs]; - memset (mBuffers, 0, sizeof(CameraBuffer) * lnumBufs); - - if ( NULL == mBufferSource ) { - return NULL; - } - - err = extendedOps()->update_and_get_buffer(mBufferSource, &handle, &mBuffers[0].stride); - if (err != 0) { - CAMHAL_LOGEB("update and get buffer failed: %s (%d)", strerror(-err), -err); - if ( ENODEV == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mBufferSource = NULL; - } - goto fail; - } - - CAMHAL_LOGD("got handle %p", handle); - mBuffers[0].opaque = (void *)handle; - mBuffers[0].type = CAMERA_BUFFER_ANW; - mFramesWithCameraAdapterMap.add(handle, 0); - - err = extendedOps()->get_buffer_dimension(mBufferSource, &mBuffers[0].width, &mBuffers[0].height); - err = extendedOps()->get_buffer_format(mBufferSource, &formatSource); - - // lock buffer - { - void *y_uv[2]; - android::Rect bounds(mBuffers[0].width, mBuffers[0].height); - mapper.lock(*handle, CAMHAL_GRALLOC_USAGE, bounds, y_uv); - mBuffers[0].mapped = y_uv[0]; - } - - mFrameWidth = mBuffers[0].width; - mFrameHeight = mBuffers[0].height; - mPixelFormat = getFormatFromANW(formatSource); - - mBuffers[0].format = mPixelFormat; - mBufferSourceDirection = BUFFER_SOURCE_TAP_IN; - - return mBuffers; - - fail: - // need to cancel buffers if any were dequeued - freeBufferList(mBuffers); - - if (NULL != mErrorNotifier.get()) { - mErrorNotifier->errorNotify(-ENOMEM); - } - - LOG_FUNCTION_NAME_EXIT; - return NULL; -} - -uint32_t * BufferSourceAdapter::getOffsets() -{ - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return NULL; -} - -int BufferSourceAdapter::minUndequeueableBuffers(int& undequeueable) { - LOG_FUNCTION_NAME; - int ret = NO_ERROR; - - if(!mBufferSource) - { - ret = INVALID_OPERATION; - goto end; - } - - ret = mBufferSource->get_min_undequeued_buffer_count(mBufferSource, &undequeueable); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("get_min_undequeued_buffer_count failed: %s (%d)", strerror(-ret), -ret); - if ( ENODEV == ret ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mBufferSource = NULL; - } - return -ret; - } - - end: - return ret; - LOG_FUNCTION_NAME_EXIT; - -} - -int BufferSourceAdapter::maxQueueableBuffers(unsigned int& queueable) -{ - LOG_FUNCTION_NAME; - int ret = NO_ERROR; - int undequeued = 0; - - if(mBufferCount == 0) { - ret = INVALID_OPERATION; - goto end; - } - - ret = minUndequeueableBuffers(undequeued); - if (ret != NO_ERROR) { - goto end; - } - - queueable = mBufferCount - undequeued; - - end: - return ret; - LOG_FUNCTION_NAME_EXIT; -} - -int BufferSourceAdapter::getFd() -{ - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return -1; - -} - -status_t BufferSourceAdapter::returnBuffersToWindow() -{ - status_t ret = NO_ERROR; - android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get(); - - //Give the buffers back to display here - sort of free it - if (mBufferSource) { - for(unsigned int i = 0; i < mFramesWithCameraAdapterMap.size(); i++) { - int value = mFramesWithCameraAdapterMap.valueAt(i); - buffer_handle_t *handle = (buffer_handle_t *) mBuffers[value].opaque; - - // if buffer index is out of bounds skip - if ((value < 0) || (value >= mBufferCount)) { - CAMHAL_LOGEA("Potential out bounds access to handle...skipping"); - continue; - } - - // unlock buffer before giving it up - mapper.unlock(*handle); - - ret = mBufferSource->cancel_buffer(mBufferSource, handle); - if ( ENODEV == ret ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mBufferSource = NULL; - return -ret; - } else if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("cancel_buffer() failed: %s (%d)", - strerror(-ret), - -ret); - return -ret; - } - } - } else { - CAMHAL_LOGE("mBufferSource is NULL"); - } - - ///Clear the frames with camera adapter map - mFramesWithCameraAdapterMap.clear(); - - return ret; - -} - -int BufferSourceAdapter::freeBufferList(CameraBuffer * buflist) -{ - LOG_FUNCTION_NAME; - - status_t ret = NO_ERROR; - - android::AutoMutex lock(mLock); - - if (mBufferSourceDirection == BUFFER_SOURCE_TAP_OUT) returnBuffersToWindow(); - - if ( NULL != buflist ) - { - delete [] buflist; - mBuffers = NULL; - } - - if( mBuffers != NULL) - { - delete [] mBuffers; - mBuffers = NULL; - } - - return NO_ERROR; -} - - -bool BufferSourceAdapter::supportsExternalBuffering() -{ - return false; -} - -void BufferSourceAdapter::addFrame(CameraFrame* frame) -{ - if (mQueueFrame.get()) { - mQueueFrame->addFrame(frame); - } -} - -void BufferSourceAdapter::handleFrameCallback(CameraFrame* frame) -{ - status_t ret = NO_ERROR; - buffer_handle_t *handle = NULL; - int i; - android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get(); - - if (!mBuffers || !frame->mBuffer) { - CAMHAL_LOGEA("Adapter sent BufferSourceAdapter a NULL frame?"); - return; - } - - android::AutoMutex lock(mLock); - - for ( i = 0; i < mBufferCount; i++ ) { - if (frame->mBuffer == &mBuffers[i]) { - break; - } - } - - handle = (buffer_handle_t *) mBuffers[i].opaque; - - // Handle input buffers - // TODO(XXX): Move handling of input buffers out of here if - // it becomes more complex - if (frame->mFrameType == CameraFrame::REPROCESS_INPUT_FRAME) { - CAMHAL_LOGD("Unlock %p (buffer #%d)", handle, i); - mapper.unlock(*handle); - return; - } - - if ( NULL != frame->mMetaData.get() ) { - camera_memory_t *extMeta = frame->mMetaData->getExtendedMetadata(); - if ( NULL != extMeta ) { - camera_metadata_t *metaData = static_cast (extMeta->data); - metaData->timestamp = frame->mTimestamp; - ret = extendedOps()->set_metadata(mBufferSource, extMeta); - if (ret != 0) { - CAMHAL_LOGE("Surface::set_metadata returned error %d", ret); - } - } - } - - // unlock buffer before enqueueing - mapper.unlock(*handle); - - ret = mBufferSource->enqueue_buffer(mBufferSource, handle); - if (ret != 0) { - CAMHAL_LOGE("Surface::queueBuffer returned error %d", ret); - } - - mFramesWithCameraAdapterMap.removeItem((buffer_handle_t *) frame->mBuffer->opaque); - - // signal return frame thread that it can dequeue a buffer now - mReturnFrame->signal(); -} - - -bool BufferSourceAdapter::handleFrameReturn() -{ - status_t err; - buffer_handle_t *buf; - int i = 0; - int stride; // dummy variable to get stride - CameraFrame::FrameType type; - android::GraphicBufferMapper &mapper = android::GraphicBufferMapper::get(); - void *y_uv[2]; - android::Rect bounds(mFrameWidth, mFrameHeight); - - if ( NULL == mBufferSource ) { - return false; - } - - err = mBufferSource->dequeue_buffer(mBufferSource, &buf, &stride); - if (err != 0) { - CAMHAL_LOGEB("dequeueBuffer failed: %s (%d)", strerror(-err), -err); - - if ( ENODEV == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mBufferSource = NULL; - } - - return false; - } - - err = mBufferSource->lock_buffer(mBufferSource, buf); - if (err != 0) { - CAMHAL_LOGEB("lockbuffer failed: %s (%d)", strerror(-err), -err); - - if ( ENODEV == err ) { - CAMHAL_LOGEA("Preview surface abandoned!"); - mBufferSource = NULL; - } - - return false; - } - - mapper.lock(*buf, CAMHAL_GRALLOC_USAGE, bounds, y_uv); - - for(i = 0; i < mBufferCount; i++) { - if (mBuffers[i].opaque == buf) - break; - } - - if (i >= mBufferCount) { - CAMHAL_LOGEB("Failed to find handle %p", buf); - } - - mFramesWithCameraAdapterMap.add((buffer_handle_t *) mBuffers[i].opaque, i); - - CAMHAL_LOGSVB("handleFrameReturn: found graphic buffer %d of %d", i, mBufferCount - 1); - - mFrameProvider->returnFrame(&mBuffers[i], formatToOutputFrameType(mPixelFormat)); - return true; -} - -void BufferSourceAdapter::frameCallback(CameraFrame* caFrame) -{ - if ((NULL != caFrame) && (NULL != caFrame->mCookie)) { - BufferSourceAdapter *da = (BufferSourceAdapter*) caFrame->mCookie; - da->addFrame(caFrame); - } else { - CAMHAL_LOGEB("Invalid Cookie in Camera Frame = %p, Cookie = %p", - caFrame, caFrame ? caFrame->mCookie : NULL); - } -} - -/*--------------------BufferSourceAdapter Class ENDS here-----------------------------*/ - -} // namespace Camera -} // namespace Ti - -#endif diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp deleted file mode 100644 index a1920c5..0000000 --- a/camera/CameraHal.cpp +++ /dev/null @@ -1,4333 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file CameraHal.cpp -* -* This file maps the Camera Hardware Interface to V4L2. -* -*/ - -#include "CameraHal.h" -#include "ANativeWindowDisplayAdapter.h" -#include "BufferSourceAdapter.h" -#include "TICameraParameters.h" -#include "CameraProperties.h" -#include - -#include -#include - -namespace Ti { -namespace Camera { - -extern "C" CameraAdapter* OMXCameraAdapter_Factory(size_t); -extern "C" CameraAdapter* V4LCameraAdapter_Factory(size_t); - -/*****************************************************************************/ - -////Constant definitions and declarations -////@todo Have a CameraProperties class to store these parameters as constants for every camera -//// Currently, they are hard-coded - -const int CameraHal::NO_BUFFERS_PREVIEW = MAX_CAMERA_BUFFERS; -const int CameraHal::NO_BUFFERS_IMAGE_CAPTURE = 5; -const int CameraHal::SW_SCALING_FPS_LIMIT = 15; - -const uint32_t MessageNotifier::EVENT_BIT_FIELD_POSITION = 16; - -const uint32_t MessageNotifier::FRAME_BIT_FIELD_POSITION = 0; - -// TODO(XXX): Temporarily increase number of buffers we can allocate from ANW -// until faux-NPA mode is implemented -const int CameraHal::NO_BUFFERS_IMAGE_CAPTURE_SYSTEM_HEAP = 15; - -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING -// HACK: Default path to directory where RAW images coming from video port will be saved to. -// If directory not exists the saving is skipped and video port frame is ignored. -// The directory name is choosed in so weird way to enable RAW images saving only when -// directory has been created explicitly by user. -extern const char * const kRawImagesOutputDirPath = "/data/misc/camera/RaW_PiCtUrEs"; -extern const char * const kYuvImagesOutputDirPath = "/data/misc/camera/YuV_PiCtUrEs"; -#endif - -/******************************************************************************/ - - -#ifdef OMAP_ENHANCEMENT_CPCAM -static int dummy_update_and_get_buffer(preview_stream_ops_t*, buffer_handle_t**, int*) { - return INVALID_OPERATION; -} - -static int dummy_get_buffer_dimension(preview_stream_ops_t*, int*, int*) { - return INVALID_OPERATION; -} - -static int dummy_get_buffer_format(preview_stream_ops_t*, int*) { - return INVALID_OPERATION; -} - -static int dummy_set_metadata(preview_stream_ops_t*, const camera_memory_t*) { - return INVALID_OPERATION; -} -#endif - -#ifdef OMAP_ENHANCEMENT -static preview_stream_extended_ops_t dummyPreviewStreamExtendedOps = { -#ifdef OMAP_ENHANCEMENT_CPCAM - dummy_update_and_get_buffer, - dummy_get_buffer_dimension, - dummy_get_buffer_format, - dummy_set_metadata, -#endif -}; -#endif - - -DisplayAdapter::DisplayAdapter() -{ -#ifdef OMAP_ENHANCEMENT - mExtendedOps = &dummyPreviewStreamExtendedOps; -#endif -} - -#ifdef OMAP_ENHANCEMENT -void DisplayAdapter::setExtendedOps(preview_stream_extended_ops_t * extendedOps) { - mExtendedOps = extendedOps ? extendedOps : &dummyPreviewStreamExtendedOps; -} -#endif - - - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - -struct timeval CameraHal::mStartPreview; -struct timeval CameraHal::mStartFocus; -struct timeval CameraHal::mStartCapture; - -#endif - -static void orientation_cb(uint32_t orientation, uint32_t tilt, void* cookie) { - CameraHal *camera = NULL; - - if (cookie) { - camera = (CameraHal*) cookie; - camera->onOrientationEvent(orientation, tilt); - } - -} -/*-------------Camera Hal Interface Method definitions STARTS here--------------------*/ - -/** - Callback function to receive orientation events from SensorListener - */ -void CameraHal::onOrientationEvent(uint32_t orientation, uint32_t tilt) { - LOG_FUNCTION_NAME; - - if ( NULL != mCameraAdapter ) { - mCameraAdapter->onOrientationEvent(orientation, tilt); - } - - LOG_FUNCTION_NAME_EXIT; -} - -/** - @brief Set the notification and data callbacks - - @param[in] notify_cb Notify callback for notifying the app about events and errors - @param[in] data_cb Buffer callback for sending the preview/raw frames to the app - @param[in] data_cb_timestamp Buffer callback for sending the video frames w/ timestamp - @param[in] user Callback cookie - @return none - - */ -void CameraHal::setCallbacks(camera_notify_callback notify_cb, - camera_data_callback data_cb, - camera_data_timestamp_callback data_cb_timestamp, - camera_request_memory get_memory, - void *user) -{ - LOG_FUNCTION_NAME; - - if ( NULL != mAppCallbackNotifier.get() ) - { - mAppCallbackNotifier->setCallbacks(this, - notify_cb, - data_cb, - data_cb_timestamp, - get_memory, - user); - } - - if ( NULL != mCameraAdapter ) { - mCameraAdapter->setSharedAllocator(get_memory); - } - - LOG_FUNCTION_NAME_EXIT; -} - -/** - @brief Enable a message, or set of messages. - - @param[in] msgtype Bitmask of the messages to enable (defined in include/ui/Camera.h) - @return none - - */ -void CameraHal::enableMsgType(int32_t msgType) -{ - LOG_FUNCTION_NAME; - - if ( ( msgType & CAMERA_MSG_SHUTTER ) && ( !mShutterEnabled ) ) - { - msgType &= ~CAMERA_MSG_SHUTTER; - } - - // ignoring enable focus message from camera service - // we will enable internally in autoFocus call - msgType &= ~CAMERA_MSG_FOCUS; -#ifdef ANDROID_API_JB_OR_LATER - msgType &= ~CAMERA_MSG_FOCUS_MOVE; -#endif - - { - android::AutoMutex lock(mLock); - mMsgEnabled |= msgType; - } - - if(mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME) - { - if(mDisplayPaused) - { - CAMHAL_LOGDA("Preview currently paused...will enable preview callback when restarted"); - msgType &= ~CAMERA_MSG_PREVIEW_FRAME; - }else - { - CAMHAL_LOGDA("Enabling Preview Callback"); - } - } - else - { - CAMHAL_LOGDB("Preview callback not enabled %x", msgType); - } - - - ///Configure app callback notifier with the message callback required - mAppCallbackNotifier->enableMsgType (msgType); - - LOG_FUNCTION_NAME_EXIT; -} - -/** - @brief Disable a message, or set of messages. - - @param[in] msgtype Bitmask of the messages to disable (defined in include/ui/Camera.h) - @return none - - */ -void CameraHal::disableMsgType(int32_t msgType) -{ - LOG_FUNCTION_NAME; - - { - android::AutoMutex lock(mLock); - mMsgEnabled &= ~msgType; - } - - if( msgType & CAMERA_MSG_PREVIEW_FRAME) - { - CAMHAL_LOGDA("Disabling Preview Callback"); - } - - ///Configure app callback notifier - mAppCallbackNotifier->disableMsgType (msgType); - - LOG_FUNCTION_NAME_EXIT; -} - -/** - @brief Query whether a message, or a set of messages, is enabled. - - Note that this is operates as an AND, if any of the messages queried are off, this will - return false. - - @param[in] msgtype Bitmask of the messages to query (defined in include/ui/Camera.h) - @return true If all message types are enabled - false If any message type - - */ -int CameraHal::msgTypeEnabled(int32_t msgType) -{ - int32_t msgEnabled = 0; - - LOG_FUNCTION_NAME; - android::AutoMutex lock(mLock); - - msgEnabled = mMsgEnabled; - if (!previewEnabled() && !mPreviewInitializationDone) { - msgEnabled &= ~(CAMERA_MSG_PREVIEW_FRAME | CAMERA_MSG_PREVIEW_METADATA); - } - - LOG_FUNCTION_NAME_EXIT; - return (msgEnabled & msgType); -} - -/** - @brief Set the camera parameters. - - @param[in] params Camera parameters to configure the camera - @return NO_ERROR - @todo Define error codes - - */ -int CameraHal::setParameters(const char* parameters) -{ - - LOG_FUNCTION_NAME; - - android::CameraParameters params; - - android::String8 str_params(parameters); - params.unflatten(str_params); - - LOG_FUNCTION_NAME_EXIT; - - return setParameters(params); -} - -/** - @brief Set the camera parameters. - - @param[in] params Camera parameters to configure the camera - @return NO_ERROR - @todo Define error codes - - */ -int CameraHal::setParameters(const android::CameraParameters& params) -{ - - LOG_FUNCTION_NAME; - - int w, h; - int framerate; - int maxFPS, minFPS; - const char *valstr = NULL; - int varint = 0; - status_t ret = NO_ERROR; - // Needed for KEY_RECORDING_HINT - bool restartPreviewRequired = false; - bool updateRequired = false; - android::CameraParameters oldParams = mParameters; - -#ifdef V4L_CAMERA_ADAPTER - if (strcmp (V4L_CAMERA_NAME_USB, mCameraProperties->get(CameraProperties::CAMERA_NAME)) == 0 ) { - updateRequired = true; - } -#endif - - { - android::AutoMutex lock(mLock); - - ///Ensure that preview is not enabled when the below parameters are changed. - if(!previewEnabled()) - { - if ((valstr = params.getPreviewFormat()) != NULL) { - if ( isParameterValid(valstr, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FORMATS))) { - mParameters.setPreviewFormat(valstr); - CAMHAL_LOGDB("PreviewFormat set %s", valstr); - } else { - CAMHAL_LOGEB("Invalid preview format: %s. Supported: %s", valstr, - mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FORMATS)); - return BAD_VALUE; - } - } - - if ((valstr = params.get(TICameraParameters::KEY_VNF)) != NULL) { - if (strcmp(mCameraProperties->get(CameraProperties::VNF_SUPPORTED), - android::CameraParameters::TRUE) == 0) { - CAMHAL_LOGDB("VNF %s", valstr); - mParameters.set(TICameraParameters::KEY_VNF, valstr); - } else if (strcmp(valstr, android::CameraParameters::TRUE) == 0) { - CAMHAL_LOGEB("ERROR: Invalid VNF: %s", valstr); - return BAD_VALUE; - } else { - mParameters.set(TICameraParameters::KEY_VNF, - android::CameraParameters::FALSE); - } - } - - if ((valstr = params.get(android::CameraParameters::KEY_VIDEO_STABILIZATION)) != NULL) { - // make sure we support vstab...if we don't and application is trying to set - // vstab then return an error - if (strcmp(mCameraProperties->get(CameraProperties::VSTAB_SUPPORTED), - android::CameraParameters::TRUE) == 0) { - CAMHAL_LOGDB("VSTAB %s", valstr); - mParameters.set(android::CameraParameters::KEY_VIDEO_STABILIZATION, valstr); - } else if (strcmp(valstr, android::CameraParameters::TRUE) == 0) { - CAMHAL_LOGEB("ERROR: Invalid VSTAB: %s", valstr); - return BAD_VALUE; - } else { - mParameters.set(android::CameraParameters::KEY_VIDEO_STABILIZATION, - android::CameraParameters::FALSE); - } - } - - if( (valstr = params.get(TICameraParameters::KEY_CAP_MODE)) != NULL) { - - if (strcmp(TICameraParameters::VIDEO_MODE, valstr)) { - mCapModeBackup = valstr; - } - - CAMHAL_LOGDB("Capture mode set %s", valstr); - - const char *currentMode = mParameters.get(TICameraParameters::KEY_CAP_MODE); - if ( NULL != currentMode ) { - if ( strcmp(currentMode, valstr) != 0 ) { - updateRequired = true; - } - } else { - updateRequired = true; - } - - mParameters.set(TICameraParameters::KEY_CAP_MODE, valstr); - } else if (!mCapModeBackup.isEmpty()) { - // Restore previous capture mode after stopPreview() - mParameters.set(TICameraParameters::KEY_CAP_MODE, - mCapModeBackup.string()); - updateRequired = true; - } - - if ((valstr = params.get(TICameraParameters::KEY_IPP)) != NULL) { - if (isParameterValid(valstr,mCameraProperties->get(CameraProperties::SUPPORTED_IPP_MODES))) { - CAMHAL_LOGDB("IPP mode set %s", valstr); - mParameters.set(TICameraParameters::KEY_IPP, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid IPP mode: %s", valstr); - return BAD_VALUE; - } - } - -#ifdef OMAP_ENHANCEMENT_VTC - if ((valstr = params.get(TICameraParameters::KEY_VTC_HINT)) != NULL ) { - mParameters.set(TICameraParameters::KEY_VTC_HINT, valstr); - if (strcmp(valstr, android::CameraParameters::TRUE) == 0) { - mVTCUseCase = true; - } else { - mVTCUseCase = false; - } - CAMHAL_LOGDB("VTC Hint = %d", mVTCUseCase); - } - - if (mVTCUseCase) { - if ((valstr = params.get(TICameraParameters::KEY_VIDEO_ENCODER_HANDLE)) != NULL ) { - mParameters.set(TICameraParameters::KEY_VIDEO_ENCODER_HANDLE, valstr); - } - - if ((valstr = params.get(TICameraParameters::KEY_VIDEO_ENCODER_SLICE_HEIGHT)) != NULL ) { - mParameters.set(TICameraParameters::KEY_VIDEO_ENCODER_SLICE_HEIGHT, valstr); - } - } -#endif - } - -#ifndef OMAP_TUNA - if ( (valstr = params.get(TICameraParameters::KEY_S3D_PRV_FRAME_LAYOUT)) != NULL ) - { - if (strcmp(valstr, mParameters.get(TICameraParameters::KEY_S3D_PRV_FRAME_LAYOUT))) - { - CAMHAL_LOGDB("Stereo 3D preview image layout is %s", valstr); - mParameters.set(TICameraParameters::KEY_S3D_PRV_FRAME_LAYOUT, valstr); - restartPreviewRequired = true; - } - } -#endif - -#ifdef OMAP_ENHANCEMENT - int orientation =0; - if((valstr = params.get(TICameraParameters::KEY_SENSOR_ORIENTATION)) != NULL) - { - doesSetParameterNeedUpdate(valstr, - mParameters.get(TICameraParameters::KEY_SENSOR_ORIENTATION), - updateRequired); - - orientation = params.getInt(TICameraParameters::KEY_SENSOR_ORIENTATION); - if ( orientation < 0 || orientation >= 360 || (orientation%90) != 0 ) { - CAMHAL_LOGE("Invalid sensor orientation: %s. Value must be one of: [0, 90, 180, 270]", valstr); - return BAD_VALUE; - } - - CAMHAL_LOGD("Sensor Orientation is set to %d", orientation); - mParameters.set(TICameraParameters::KEY_SENSOR_ORIENTATION, valstr); - } -#endif - - params.getPreviewSize(&w, &h); - if (w == -1 && h == -1) { - CAMHAL_LOGEA("Unable to get preview size"); - return BAD_VALUE; - } - - mVideoWidth = w; - mVideoHeight = h; - - // Handle RECORDING_HINT to Set/Reset Video Mode Parameters - valstr = params.get(android::CameraParameters::KEY_RECORDING_HINT); - if(valstr != NULL) - { - CAMHAL_LOGDB("Recording Hint is set to %s", valstr); - if(strcmp(valstr, android::CameraParameters::TRUE) == 0) - { - CAMHAL_LOGVB("Video Resolution: %d x %d", mVideoWidth, mVideoHeight); -#ifdef OMAP_ENHANCEMENT_VTC - if (!mVTCUseCase) -#endif - { - int maxFPS, minFPS; - - params.getPreviewFpsRange(&minFPS, &maxFPS); - maxFPS /= CameraHal::VFR_SCALE; - if ( ( maxFPS <= SW_SCALING_FPS_LIMIT ) ) { - getPreferredPreviewRes(&w, &h); - } - } - mParameters.set(android::CameraParameters::KEY_RECORDING_HINT, valstr); - restartPreviewRequired |= setVideoModeParameters(params); - } - else if(strcmp(valstr, android::CameraParameters::FALSE) == 0) - { - mParameters.set(android::CameraParameters::KEY_RECORDING_HINT, valstr); - restartPreviewRequired |= resetVideoModeParameters(); - } - else - { - CAMHAL_LOGEA("Invalid RECORDING_HINT"); - return BAD_VALUE; - } - } - else - { - // This check is required in following case. - // If VideoRecording activity sets KEY_RECORDING_HINT to TRUE and - // ImageCapture activity doesnot set KEY_RECORDING_HINT to FALSE (i.e. simply NULL), - // then Video Mode parameters may remain present in ImageCapture activity as well. - CAMHAL_LOGDA("Recording Hint is set to NULL"); - mParameters.set(android::CameraParameters::KEY_RECORDING_HINT, ""); - restartPreviewRequired |= resetVideoModeParameters(); - } - - if ( (!isResolutionValid(w, h, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_SIZES))) -#ifndef OMAP_TUNA - && (!isResolutionValid(w, h, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_SUBSAMPLED_SIZES))) - && (!isResolutionValid(w, h, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES))) - && (!isResolutionValid(w, h, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_TOPBOTTOM_SIZES))) -#endif - ) { - CAMHAL_LOGEB("Invalid preview resolution %d x %d", w, h); - return BAD_VALUE; - } - - int oldWidth, oldHeight; - mParameters.getPreviewSize(&oldWidth, &oldHeight); - if ( ( oldWidth != w ) || ( oldHeight != h ) ) - { - mParameters.setPreviewSize(w, h); - restartPreviewRequired = true; - } - - CAMHAL_LOGDB("Preview Resolution: %d x %d", w, h); - - if ((valstr = params.get(android::CameraParameters::KEY_FOCUS_MODE)) != NULL) { - if (isParameterValid(valstr, mCameraProperties->get(CameraProperties::SUPPORTED_FOCUS_MODES))) { - CAMHAL_LOGDB("Focus mode set %s", valstr); - - // we need to take a decision on the capture mode based on whether CAF picture or - // video is chosen so the behavior of each is consistent to the application - if(strcmp(valstr, android::CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE) == 0){ - restartPreviewRequired |= resetVideoModeParameters(); - } else if (strcmp(valstr, android::CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO) == 0){ - restartPreviewRequired |= setVideoModeParameters(params); - } - - mParameters.set(android::CameraParameters::KEY_FOCUS_MODE, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid FOCUS mode = %s", valstr); - return BAD_VALUE; - } - } - - mRawCapture = false; - -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING - valstr = params.get(TICameraParameters::KEY_CAP_MODE); - if ( (!valstr || strcmp(valstr, TICameraParameters::HIGH_QUALITY_MODE) == 0) && - access(kRawImagesOutputDirPath, F_OK) != -1 ) { - mRawCapture = true; - } -#endif - -#ifndef OMAP_TUNA - if ( (valstr = params.get(TICameraParameters::KEY_S3D_CAP_FRAME_LAYOUT)) != NULL ) - { - CAMHAL_LOGDB("Stereo 3D capture image layout is %s", valstr); - mParameters.set(TICameraParameters::KEY_S3D_CAP_FRAME_LAYOUT, valstr); - } -#endif - - params.getPictureSize(&w, &h); - if ( (isResolutionValid(w, h, mCameraProperties->get(CameraProperties::SUPPORTED_PICTURE_SIZES))) -#ifndef OMAP_TUNA - || (isResolutionValid(w, h, mCameraProperties->get(CameraProperties::SUPPORTED_PICTURE_SUBSAMPLED_SIZES))) - || (isResolutionValid(w, h, mCameraProperties->get(CameraProperties::SUPPORTED_PICTURE_TOPBOTTOM_SIZES))) - || (isResolutionValid(w, h, mCameraProperties->get(CameraProperties::SUPPORTED_PICTURE_SIDEBYSIDE_SIZES))) -#endif - ) { - mParameters.setPictureSize(w, h); - } else { - CAMHAL_LOGEB("ERROR: Invalid picture resolution %d x %d", w, h); - return BAD_VALUE; - } - - CAMHAL_LOGDB("Picture Size by App %d x %d", w, h); - - if ( (valstr = params.getPictureFormat()) != NULL ) { - if (isParameterValid(valstr,mCameraProperties->get(CameraProperties::SUPPORTED_PICTURE_FORMATS))) { - if ((strcmp(valstr, android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB) == 0) && - mCameraProperties->get(CameraProperties::MAX_PICTURE_WIDTH) && - mCameraProperties->get(CameraProperties::MAX_PICTURE_HEIGHT)) { - unsigned int width = 0, height = 0; - // Set picture size to full frame for raw bayer capture - width = atoi(mCameraProperties->get(CameraProperties::MAX_PICTURE_WIDTH)); - height = atoi(mCameraProperties->get(CameraProperties::MAX_PICTURE_HEIGHT)); - mParameters.setPictureSize(width,height); - } - mParameters.setPictureFormat(valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid picture format: %s",valstr); - ret = BAD_VALUE; - } - } - -#ifdef OMAP_ENHANCEMENT_BURST_CAPTURE - if ((valstr = params.get(TICameraParameters::KEY_BURST)) != NULL) { - if (params.getInt(TICameraParameters::KEY_BURST) >=0) { - CAMHAL_LOGDB("Burst set %s", valstr); - mParameters.set(TICameraParameters::KEY_BURST, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid Burst value: %s",valstr); - return BAD_VALUE; - } - } -#endif - - // Variable framerate ranges have higher priority over - // deprecated constant FPS. "KEY_PREVIEW_FPS_RANGE" should - // be cleared by the client in order for constant FPS to get - // applied. - // If Port FPS needs to be used for configuring, then FPS RANGE should not be set by the APP. - valstr = params.get(android::CameraParameters::KEY_PREVIEW_FPS_RANGE); - if (valstr != NULL && strlen(valstr)) { - int curMaxFPS = 0; - int curMinFPS = 0; - - // APP wants to set FPS range - // Set framerate = MAXFPS - CAMHAL_LOGDA("APP IS CHANGING FRAME RATE RANGE"); - - mParameters.getPreviewFpsRange(&curMinFPS, &curMaxFPS); - CAMHAL_LOGDB("## current minFPS = %d; maxFPS=%d",curMinFPS, curMaxFPS); - - params.getPreviewFpsRange(&minFPS, &maxFPS); - CAMHAL_LOGDB("## requested minFPS = %d; maxFPS=%d",minFPS, maxFPS); - // Validate VFR - if (!isFpsRangeValid(minFPS, maxFPS, params.get(android::CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE)) && - !isFpsRangeValid(minFPS, maxFPS, params.get(TICameraParameters::KEY_FRAMERATE_RANGES_EXT_SUPPORTED))) { - CAMHAL_LOGEA("Invalid FPS Range"); - return BAD_VALUE; - } else { - framerate = maxFPS / CameraHal::VFR_SCALE; - mParameters.setPreviewFrameRate(framerate); - CAMHAL_LOGDB("SET FRAMERATE %d", framerate); - mParameters.set(android::CameraParameters::KEY_PREVIEW_FPS_RANGE, valstr); - CAMHAL_LOGDB("FPS Range = %s", valstr); - if ( curMaxFPS == (FRAME_RATE_HIGH_HD * CameraHal::VFR_SCALE) && - (unsigned int)maxFPS < (FRAME_RATE_HIGH_HD * CameraHal::VFR_SCALE) ) { - restartPreviewRequired = true; - } - } - } else { - framerate = params.getPreviewFrameRate(); - if (!isParameterValid(framerate, params.get(android::CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES)) && - !isParameterValid(framerate, params.get(TICameraParameters::KEY_FRAMERATES_EXT_SUPPORTED))) { - CAMHAL_LOGEA("Invalid frame rate"); - return BAD_VALUE; - } - char tmpBuffer[MAX_PROP_VALUE_LENGTH]; - - sprintf(tmpBuffer, "%d,%d", framerate * CameraHal::VFR_SCALE, framerate * CameraHal::VFR_SCALE); - mParameters.setPreviewFrameRate(framerate); - CAMHAL_LOGDB("SET FRAMERATE %d", framerate); - mParameters.set(android::CameraParameters::KEY_PREVIEW_FPS_RANGE, tmpBuffer); - CAMHAL_LOGDB("FPS Range = %s", tmpBuffer); - } - - if ((valstr = params.get(TICameraParameters::KEY_GBCE)) != NULL) { - if (strcmp(mCameraProperties->get(CameraProperties::SUPPORTED_GBCE), - android::CameraParameters::TRUE) == 0) { - CAMHAL_LOGDB("GBCE %s", valstr); - mParameters.set(TICameraParameters::KEY_GBCE, valstr); - } else if (strcmp(valstr, android::CameraParameters::TRUE) == 0) { - CAMHAL_LOGEB("ERROR: Invalid GBCE: %s", valstr); - return BAD_VALUE; - } else { - mParameters.set(TICameraParameters::KEY_GBCE, android::CameraParameters::FALSE); - } - } else { - mParameters.set(TICameraParameters::KEY_GBCE, android::CameraParameters::FALSE); - } - - if ((valstr = params.get(TICameraParameters::KEY_GLBCE)) != NULL) { - if (strcmp(mCameraProperties->get(CameraProperties::SUPPORTED_GLBCE), - android::CameraParameters::TRUE) == 0) { - CAMHAL_LOGDB("GLBCE %s", valstr); - mParameters.set(TICameraParameters::KEY_GLBCE, valstr); - } else if (strcmp(valstr, android::CameraParameters::TRUE) == 0) { - CAMHAL_LOGEB("ERROR: Invalid GLBCE: %s", valstr); - return BAD_VALUE; - } else { - mParameters.set(TICameraParameters::KEY_GLBCE, android::CameraParameters::FALSE); - } - } else { - mParameters.set(TICameraParameters::KEY_GLBCE, android::CameraParameters::FALSE); - } - -#ifdef OMAP_ENHANCEMENT_S3D - ///Update the current parameter set - if ( (valstr = params.get(TICameraParameters::KEY_AUTOCONVERGENCE_MODE)) != NULL ) { - CAMHAL_LOGDB("AutoConvergence mode set = %s", valstr); - mParameters.set(TICameraParameters::KEY_AUTOCONVERGENCE_MODE, valstr); - } - - if ( (valstr = params.get(TICameraParameters::KEY_MANUAL_CONVERGENCE)) != NULL ) { - int manualConvergence = (int)strtol(valstr, 0, 0); - - if ( ( manualConvergence < strtol(mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_MIN), 0, 0) ) || - ( manualConvergence > strtol(mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_MAX), 0, 0) ) ) { - CAMHAL_LOGEB("ERROR: Invalid Manual Convergence = %d", manualConvergence); - return BAD_VALUE; - } else { - CAMHAL_LOGDB("ManualConvergence Value = %d", manualConvergence); - mParameters.set(TICameraParameters::KEY_MANUAL_CONVERGENCE, valstr); - } - } - -#ifndef OMAP_TUNA - if((valstr = params.get(TICameraParameters::KEY_MECHANICAL_MISALIGNMENT_CORRECTION)) != NULL) { - if ( strcmp(mCameraProperties->get(CameraProperties::MECHANICAL_MISALIGNMENT_CORRECTION_SUPPORTED), - android::CameraParameters::TRUE) == 0 ) { - CAMHAL_LOGDB("Mechanical Mialignment Correction is %s", valstr); - mParameters.set(TICameraParameters::KEY_MECHANICAL_MISALIGNMENT_CORRECTION, valstr); - } else { - mParameters.remove(TICameraParameters::KEY_MECHANICAL_MISALIGNMENT_CORRECTION); - } - } -#endif - - if ((valstr = params.get(TICameraParameters::KEY_EXPOSURE_MODE)) != NULL) { - if (isParameterValid(valstr, mCameraProperties->get(CameraProperties::SUPPORTED_EXPOSURE_MODES))) { - CAMHAL_LOGDB("Exposure mode set = %s", valstr); - mParameters.set(TICameraParameters::KEY_EXPOSURE_MODE, valstr); - if (!strcmp(valstr, TICameraParameters::EXPOSURE_MODE_MANUAL)) { - int manualVal; - if ((valstr = params.get(TICameraParameters::KEY_MANUAL_EXPOSURE)) != NULL) { - manualVal = params.getInt(TICameraParameters::KEY_MANUAL_EXPOSURE); - if (manualVal < mParameters.getInt(TICameraParameters::KEY_SUPPORTED_MANUAL_EXPOSURE_MIN) || - manualVal > mParameters.getInt(TICameraParameters::KEY_SUPPORTED_MANUAL_EXPOSURE_MAX)) { - CAMHAL_LOGEB("ERROR: Manual Exposure = %s is out of range - " - "setting minimum supported value", valstr); - valstr = mParameters.get(TICameraParameters::KEY_SUPPORTED_MANUAL_EXPOSURE_MIN); - } - CAMHAL_LOGDB("Manual Exposure = %s", valstr); - mParameters.set(TICameraParameters::KEY_MANUAL_EXPOSURE, valstr); - } - if ((valstr = params.get(TICameraParameters::KEY_MANUAL_EXPOSURE_RIGHT)) != NULL) { - manualVal = params.getInt(TICameraParameters::KEY_MANUAL_EXPOSURE_RIGHT); - if (manualVal < mParameters.getInt(TICameraParameters::KEY_SUPPORTED_MANUAL_EXPOSURE_MIN) || - manualVal > mParameters.getInt(TICameraParameters::KEY_SUPPORTED_MANUAL_EXPOSURE_MAX)) { - CAMHAL_LOGEB("ERROR: Manual Exposure right = %s is out of range - " - "setting minimum supported value", valstr); - valstr = mParameters.get(TICameraParameters::KEY_SUPPORTED_MANUAL_EXPOSURE_MIN); - } - CAMHAL_LOGDB("Manual Exposure right = %s", valstr); - mParameters.set(TICameraParameters::KEY_MANUAL_EXPOSURE_RIGHT, valstr); - } - if ((valstr = params.get(TICameraParameters::KEY_MANUAL_GAIN_ISO)) != NULL) { - manualVal = params.getInt(TICameraParameters::KEY_MANUAL_GAIN_ISO); - if (manualVal < mParameters.getInt(TICameraParameters::KEY_SUPPORTED_MANUAL_GAIN_ISO_MIN) || - manualVal > mParameters.getInt(TICameraParameters::KEY_SUPPORTED_MANUAL_GAIN_ISO_MAX)) { - CAMHAL_LOGEB("ERROR: Manual Gain = %s is out of range - " - "setting minimum supported value", valstr); - valstr = mParameters.get(TICameraParameters::KEY_SUPPORTED_MANUAL_GAIN_ISO_MIN); - } - CAMHAL_LOGDB("Manual Gain = %s", valstr); - mParameters.set(TICameraParameters::KEY_MANUAL_GAIN_ISO, valstr); - } - if ((valstr = params.get(TICameraParameters::KEY_MANUAL_GAIN_ISO_RIGHT)) != NULL) { - manualVal = params.getInt(TICameraParameters::KEY_MANUAL_GAIN_ISO_RIGHT); - if (manualVal < mParameters.getInt(TICameraParameters::KEY_SUPPORTED_MANUAL_GAIN_ISO_MIN) || - manualVal > mParameters.getInt(TICameraParameters::KEY_SUPPORTED_MANUAL_GAIN_ISO_MAX)) { - CAMHAL_LOGEB("ERROR: Manual Gain right = %s is out of range - " - "setting minimum supported value", valstr); - valstr = mParameters.get(TICameraParameters::KEY_SUPPORTED_MANUAL_GAIN_ISO_MIN); - } - CAMHAL_LOGDB("Manual Gain right = %s", valstr); - mParameters.set(TICameraParameters::KEY_MANUAL_GAIN_ISO_RIGHT, valstr); - } - } - } else { - CAMHAL_LOGEB("ERROR: Invalid Exposure mode = %s", valstr); - return BAD_VALUE; - } - } -#endif - - if ((valstr = params.get(android::CameraParameters::KEY_WHITE_BALANCE)) != NULL) { - if ( isParameterValid(valstr, mCameraProperties->get(CameraProperties::SUPPORTED_WHITE_BALANCE))) { - CAMHAL_LOGDB("White balance set %s", valstr); - mParameters.set(android::CameraParameters::KEY_WHITE_BALANCE, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid white balance = %s", valstr); - return BAD_VALUE; - } - } - -#ifdef OMAP_ENHANCEMENT - if ((valstr = params.get(TICameraParameters::KEY_CONTRAST)) != NULL) { - if (params.getInt(TICameraParameters::KEY_CONTRAST) >= 0 ) { - CAMHAL_LOGDB("Contrast set %s", valstr); - mParameters.set(TICameraParameters::KEY_CONTRAST, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid Contrast = %s", valstr); - return BAD_VALUE; - } - } - - if ((valstr =params.get(TICameraParameters::KEY_SHARPNESS)) != NULL) { - if (params.getInt(TICameraParameters::KEY_SHARPNESS) >= 0 ) { - CAMHAL_LOGDB("Sharpness set %s", valstr); - mParameters.set(TICameraParameters::KEY_SHARPNESS, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid Sharpness = %s", valstr); - return BAD_VALUE; - } - } - - if ((valstr = params.get(TICameraParameters::KEY_SATURATION)) != NULL) { - if (params.getInt(TICameraParameters::KEY_SATURATION) >= 0 ) { - CAMHAL_LOGDB("Saturation set %s", valstr); - mParameters.set(TICameraParameters::KEY_SATURATION, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid Saturation = %s", valstr); - return BAD_VALUE; - } - } - - if ((valstr = params.get(TICameraParameters::KEY_BRIGHTNESS)) != NULL) { - if (params.getInt(TICameraParameters::KEY_BRIGHTNESS) >= 0 ) { - CAMHAL_LOGDB("Brightness set %s", valstr); - mParameters.set(TICameraParameters::KEY_BRIGHTNESS, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid Brightness = %s", valstr); - return BAD_VALUE; - } - } -#endif - - if ((valstr = params.get(android::CameraParameters::KEY_ANTIBANDING)) != NULL) { - if (isParameterValid(valstr, mCameraProperties->get(CameraProperties::SUPPORTED_ANTIBANDING))) { - CAMHAL_LOGDB("Antibanding set %s", valstr); - mParameters.set(android::CameraParameters::KEY_ANTIBANDING, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid Antibanding = %s", valstr); - return BAD_VALUE; - } - } - -#ifdef OMAP_ENHANCEMENT - if ((valstr = params.get(TICameraParameters::KEY_ISO)) != NULL) { - if (isParameterValid(valstr, mCameraProperties->get(CameraProperties::SUPPORTED_ISO_VALUES))) { - CAMHAL_LOGDB("ISO set %s", valstr); - mParameters.set(TICameraParameters::KEY_ISO, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid ISO = %s", valstr); - return BAD_VALUE; - } - } -#endif - - if( (valstr = params.get(android::CameraParameters::KEY_FOCUS_AREAS)) != NULL ) - { - CAMHAL_LOGDB("Focus areas position set %s", params.get(android::CameraParameters::KEY_FOCUS_AREAS)); - mParameters.set(android::CameraParameters::KEY_FOCUS_AREAS, valstr); - } - -#ifdef OMAP_ENHANCEMENT - if( (valstr = params.get(TICameraParameters::KEY_MEASUREMENT_ENABLE)) != NULL ) - { - CAMHAL_LOGDB("Measurements set to %s", valstr); - mParameters.set(TICameraParameters::KEY_MEASUREMENT_ENABLE, valstr); - - if (strcmp(valstr, android::CameraParameters::TRUE) == 0) - { - mMeasurementEnabled = true; - } - else if (strcmp(valstr, android::CameraParameters::FALSE) == 0) - { - mMeasurementEnabled = false; - } - else - { - mMeasurementEnabled = false; - } - - } -#endif - - if( (valstr = params.get(android::CameraParameters::KEY_EXPOSURE_COMPENSATION)) != NULL) - { - CAMHAL_LOGDB("Exposure compensation set %s", params.get(android::CameraParameters::KEY_EXPOSURE_COMPENSATION)); - mParameters.set(android::CameraParameters::KEY_EXPOSURE_COMPENSATION, valstr); - } - - if ((valstr = params.get(android::CameraParameters::KEY_SCENE_MODE)) != NULL) { - if (isParameterValid(valstr, mCameraProperties->get(CameraProperties::SUPPORTED_SCENE_MODES))) { - CAMHAL_LOGDB("Scene mode set %s", valstr); - doesSetParameterNeedUpdate(valstr, - mParameters.get(android::CameraParameters::KEY_SCENE_MODE), - updateRequired); - mParameters.set(android::CameraParameters::KEY_SCENE_MODE, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid Scene mode = %s", valstr); - return BAD_VALUE; - } - } - - if ((valstr = params.get(android::CameraParameters::KEY_FLASH_MODE)) != NULL) { - if (isParameterValid(valstr, mCameraProperties->get(CameraProperties::SUPPORTED_FLASH_MODES))) { - CAMHAL_LOGDB("Flash mode set %s", valstr); - mParameters.set(android::CameraParameters::KEY_FLASH_MODE, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid Flash mode = %s", valstr); - return BAD_VALUE; - } - } - - if ((valstr = params.get(android::CameraParameters::KEY_EFFECT)) != NULL) { - if (isParameterValid(valstr, mCameraProperties->get(CameraProperties::SUPPORTED_EFFECTS))) { - CAMHAL_LOGDB("Effect set %s", valstr); - mParameters.set(android::CameraParameters::KEY_EFFECT, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid Effect = %s", valstr); - return BAD_VALUE; - } - } - - varint = params.getInt(android::CameraParameters::KEY_ROTATION); - if ( varint >= 0 ) { - CAMHAL_LOGDB("Rotation set %d", varint); - mParameters.set(android::CameraParameters::KEY_ROTATION, varint); - } - - varint = params.getInt(android::CameraParameters::KEY_JPEG_QUALITY); - if ( varint >= 0 ) { - CAMHAL_LOGDB("Jpeg quality set %d", varint); - mParameters.set(android::CameraParameters::KEY_JPEG_QUALITY, varint); - } - - varint = params.getInt(android::CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH); - if ( varint >= 0 ) { - CAMHAL_LOGDB("Thumbnail width set %d", varint); - mParameters.set(android::CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, varint); - } - - varint = params.getInt(android::CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT); - if ( varint >= 0 ) { - CAMHAL_LOGDB("Thumbnail width set %d", varint); - mParameters.set(android::CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, varint); - } - - varint = params.getInt(android::CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY); - if ( varint >= 0 ) { - CAMHAL_LOGDB("Thumbnail quality set %d", varint); - mParameters.set(android::CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY, varint); - } - - if( (valstr = params.get(android::CameraParameters::KEY_GPS_LATITUDE)) != NULL ) - { - CAMHAL_LOGDB("GPS latitude set %s", params.get(android::CameraParameters::KEY_GPS_LATITUDE)); - mParameters.set(android::CameraParameters::KEY_GPS_LATITUDE, valstr); - }else{ - mParameters.remove(android::CameraParameters::KEY_GPS_LATITUDE); - } - - if( (valstr = params.get(android::CameraParameters::KEY_GPS_LONGITUDE)) != NULL ) - { - CAMHAL_LOGDB("GPS longitude set %s", params.get(android::CameraParameters::KEY_GPS_LONGITUDE)); - mParameters.set(android::CameraParameters::KEY_GPS_LONGITUDE, valstr); - }else{ - mParameters.remove(android::CameraParameters::KEY_GPS_LONGITUDE); - } - - if( (valstr = params.get(android::CameraParameters::KEY_GPS_ALTITUDE)) != NULL ) - { - CAMHAL_LOGDB("GPS altitude set %s", params.get(android::CameraParameters::KEY_GPS_ALTITUDE)); - mParameters.set(android::CameraParameters::KEY_GPS_ALTITUDE, valstr); - }else{ - mParameters.remove(android::CameraParameters::KEY_GPS_ALTITUDE); - } - - if( (valstr = params.get(android::CameraParameters::KEY_GPS_TIMESTAMP)) != NULL ) - { - CAMHAL_LOGDB("GPS timestamp set %s", params.get(android::CameraParameters::KEY_GPS_TIMESTAMP)); - mParameters.set(android::CameraParameters::KEY_GPS_TIMESTAMP, valstr); - }else{ - mParameters.remove(android::CameraParameters::KEY_GPS_TIMESTAMP); - } - - if( (valstr = params.get(TICameraParameters::KEY_GPS_DATESTAMP)) != NULL ) - { - CAMHAL_LOGDB("GPS datestamp set %s", valstr); - mParameters.set(TICameraParameters::KEY_GPS_DATESTAMP, valstr); - }else{ - mParameters.remove(TICameraParameters::KEY_GPS_DATESTAMP); - } - - if( (valstr = params.get(android::CameraParameters::KEY_GPS_PROCESSING_METHOD)) != NULL ) - { - CAMHAL_LOGDB("GPS processing method set %s", params.get(android::CameraParameters::KEY_GPS_PROCESSING_METHOD)); - mParameters.set(android::CameraParameters::KEY_GPS_PROCESSING_METHOD, valstr); - }else{ - mParameters.remove(android::CameraParameters::KEY_GPS_PROCESSING_METHOD); - } - - if( (valstr = params.get(TICameraParameters::KEY_GPS_MAPDATUM )) != NULL ) - { - CAMHAL_LOGDB("GPS MAPDATUM set %s", valstr); - mParameters.set(TICameraParameters::KEY_GPS_MAPDATUM, valstr); - }else{ - mParameters.remove(TICameraParameters::KEY_GPS_MAPDATUM); - } - - if( (valstr = params.get(TICameraParameters::KEY_GPS_VERSION)) != NULL ) - { - CAMHAL_LOGDB("GPS MAPDATUM set %s", valstr); - mParameters.set(TICameraParameters::KEY_GPS_VERSION, valstr); - }else{ - mParameters.remove(TICameraParameters::KEY_GPS_VERSION); - } - - if( (valstr = params.get(TICameraParameters::KEY_EXIF_MODEL)) != NULL ) - { - CAMHAL_LOGDB("EXIF Model set %s", valstr); - mParameters.set(TICameraParameters::KEY_EXIF_MODEL, valstr); - } - - if( (valstr = params.get(TICameraParameters::KEY_EXIF_MAKE)) != NULL ) - { - CAMHAL_LOGDB("EXIF Make set %s", valstr); - mParameters.set(TICameraParameters::KEY_EXIF_MAKE, valstr); - } - -#ifdef OMAP_ENHANCEMENT - if( (valstr = params.get(TICameraParameters::KEY_EXP_BRACKETING_RANGE)) != NULL ) - { - CAMHAL_LOGDB("Exposure Bracketing set %s", params.get(TICameraParameters::KEY_EXP_BRACKETING_RANGE)); - mParameters.set(TICameraParameters::KEY_EXP_BRACKETING_RANGE, valstr); - mParameters.remove(TICameraParameters::KEY_EXP_GAIN_BRACKETING_RANGE); - } - else if ((valstr = params.get(TICameraParameters::KEY_EXP_GAIN_BRACKETING_RANGE)) != NULL) { - CAMHAL_LOGDB("ABS Exposure+Gain Bracketing set %s", params.get(TICameraParameters::KEY_EXP_GAIN_BRACKETING_RANGE)); - mParameters.set(TICameraParameters::KEY_EXP_GAIN_BRACKETING_RANGE, valstr); - mParameters.remove(TICameraParameters::KEY_EXP_BRACKETING_RANGE); - } else - { - mParameters.remove(TICameraParameters::KEY_EXP_BRACKETING_RANGE); - } - - if( (valstr = params.get(TICameraParameters::KEY_ZOOM_BRACKETING_RANGE)) != NULL ) { - CAMHAL_LOGDB("Zoom Bracketing range %s", valstr); - mParameters.set(TICameraParameters::KEY_ZOOM_BRACKETING_RANGE, valstr); - } else { - mParameters.remove(TICameraParameters::KEY_ZOOM_BRACKETING_RANGE); - } -#endif - - if ((valstr = params.get(android::CameraParameters::KEY_ZOOM)) != NULL ) { - varint = atoi(valstr); - if ( varint >= 0 && varint <= mMaxZoomSupported ) { - CAMHAL_LOGDB("Zoom set %d", varint); - doesSetParameterNeedUpdate(valstr, - mParameters.get(android::CameraParameters::KEY_ZOOM), - updateRequired); - mParameters.set(android::CameraParameters::KEY_ZOOM, valstr); - } else { - CAMHAL_LOGEB("ERROR: Invalid Zoom: %s", valstr); - return BAD_VALUE; - } - } - - if( (valstr = params.get(android::CameraParameters::KEY_AUTO_EXPOSURE_LOCK)) != NULL ) - { - CAMHAL_LOGDB("Auto Exposure Lock set %s", valstr); - doesSetParameterNeedUpdate(valstr, - mParameters.get(android::CameraParameters::KEY_AUTO_EXPOSURE_LOCK), - updateRequired); - mParameters.set(android::CameraParameters::KEY_AUTO_EXPOSURE_LOCK, valstr); - } - - if( (valstr = params.get(android::CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK)) != NULL ) - { - CAMHAL_LOGDB("Auto WhiteBalance Lock set %s", valstr); - doesSetParameterNeedUpdate(valstr, - mParameters.get(android::CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK), - updateRequired); - mParameters.set(android::CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK, valstr); - } - if( (valstr = params.get(android::CameraParameters::KEY_METERING_AREAS)) != NULL ) - { - CAMHAL_LOGDB("Metering areas position set %s", params.get(android::CameraParameters::KEY_METERING_AREAS)); - mParameters.set(android::CameraParameters::KEY_METERING_AREAS, valstr); - } - - if( (valstr = params.get(TICameraParameters::RAW_WIDTH)) != NULL ) { - CAMHAL_LOGDB("Raw image width set %s", params.get(TICameraParameters::RAW_WIDTH)); - mParameters.set(TICameraParameters::RAW_WIDTH, valstr); - } - - if( (valstr = params.get(TICameraParameters::RAW_HEIGHT)) != NULL ) { - CAMHAL_LOGDB("Raw image height set %s", params.get(TICameraParameters::RAW_HEIGHT)); - mParameters.set(TICameraParameters::RAW_HEIGHT, valstr); - } - -#ifndef OMAP_TUNA - //TI extensions for enable/disable algos - if( (valstr = params.get(TICameraParameters::KEY_ALGO_FIXED_GAMMA)) != NULL ) - { - CAMHAL_LOGDB("Fixed Gamma set %s", valstr); - mParameters.set(TICameraParameters::KEY_ALGO_FIXED_GAMMA, valstr); - } - - if( (valstr = params.get(TICameraParameters::KEY_ALGO_NSF1)) != NULL ) - { - CAMHAL_LOGDB("NSF1 set %s", valstr); - mParameters.set(TICameraParameters::KEY_ALGO_NSF1, valstr); - } - - if( (valstr = params.get(TICameraParameters::KEY_ALGO_NSF2)) != NULL ) - { - CAMHAL_LOGDB("NSF2 set %s", valstr); - mParameters.set(TICameraParameters::KEY_ALGO_NSF2, valstr); - } - - if( (valstr = params.get(TICameraParameters::KEY_ALGO_SHARPENING)) != NULL ) - { - CAMHAL_LOGDB("Sharpening set %s", valstr); - mParameters.set(TICameraParameters::KEY_ALGO_SHARPENING, valstr); - } - - if( (valstr = params.get(TICameraParameters::KEY_ALGO_THREELINCOLORMAP)) != NULL ) - { - CAMHAL_LOGDB("Color Conversion set %s", valstr); - mParameters.set(TICameraParameters::KEY_ALGO_THREELINCOLORMAP, valstr); - } - - if( (valstr = params.get(TICameraParameters::KEY_ALGO_GIC)) != NULL ) - { - CAMHAL_LOGDB("Green Inballance Correction set %s", valstr); - mParameters.set(TICameraParameters::KEY_ALGO_GIC, valstr); - } -#endif - - android::CameraParameters adapterParams = mParameters; - -#ifdef OMAP_ENHANCEMENT - if( NULL != params.get(TICameraParameters::KEY_TEMP_BRACKETING_RANGE_POS) ) - { - int posBracketRange = params.getInt(TICameraParameters::KEY_TEMP_BRACKETING_RANGE_POS); - if ( 0 < posBracketRange ) - { - mBracketRangePositive = posBracketRange; - } - } - CAMHAL_LOGDB("Positive bracketing range %d", mBracketRangePositive); - - - if( NULL != params.get(TICameraParameters::KEY_TEMP_BRACKETING_RANGE_NEG) ) - { - int negBracketRange = params.getInt(TICameraParameters::KEY_TEMP_BRACKETING_RANGE_NEG); - if ( 0 < negBracketRange ) - { - mBracketRangeNegative = negBracketRange; - } - } - CAMHAL_LOGDB("Negative bracketing range %d", mBracketRangeNegative); - - if( ( (valstr = params.get(TICameraParameters::KEY_TEMP_BRACKETING)) != NULL) && - ( strcmp(valstr, android::CameraParameters::TRUE) == 0 )) { - if ( !mBracketingEnabled ) { - CAMHAL_LOGDA("Enabling bracketing"); - mBracketingEnabled = true; - } else { - CAMHAL_LOGDA("Bracketing already enabled"); - } - adapterParams.set(TICameraParameters::KEY_TEMP_BRACKETING, valstr); - mParameters.set(TICameraParameters::KEY_TEMP_BRACKETING, valstr); - } else if ( ( (valstr = params.get(TICameraParameters::KEY_TEMP_BRACKETING)) != NULL ) && - ( strcmp(valstr, android::CameraParameters::FALSE) == 0 )) { - CAMHAL_LOGDA("Disabling bracketing"); - - adapterParams.set(TICameraParameters::KEY_TEMP_BRACKETING, valstr); - mParameters.set(TICameraParameters::KEY_TEMP_BRACKETING, valstr); - mBracketingEnabled = false; - if ( mBracketingRunning ) { - stopImageBracketing(); - } - - } else { - adapterParams.remove(TICameraParameters::KEY_TEMP_BRACKETING); - mParameters.remove(TICameraParameters::KEY_TEMP_BRACKETING); - } -#endif - -#ifdef OMAP_ENHANCEMENT_VTC - if (mVTCUseCase && !mTunnelSetup && (mCameraAdapter != NULL) && - ((mParameters.get(TICameraParameters::KEY_VIDEO_ENCODER_HANDLE)) != NULL )&& - ((mParameters.get(TICameraParameters::KEY_VIDEO_ENCODER_SLICE_HEIGHT)) != NULL )) { - - uint32_t sliceHeight = mParameters.getInt(TICameraParameters::KEY_VIDEO_ENCODER_SLICE_HEIGHT); - uint32_t encoderHandle = mParameters.getInt(TICameraParameters::KEY_VIDEO_ENCODER_HANDLE); - int w, h; - mParameters.getPreviewSize(&w, &h); - status_t done = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_SETUP_TUNNEL, sliceHeight, encoderHandle, w, h); - if (done == NO_ERROR) mTunnelSetup = true; - ret |= done; - } -#endif - - // Only send parameters to adapter if preview is already - // enabled or doesSetParameterNeedUpdate says so. Initial setParameters to camera adapter, - // will be called in startPreview() - // TODO(XXX): Need to identify other parameters that need update from camera adapter - if ( (NULL != mCameraAdapter) && (mPreviewEnabled || updateRequired) && !restartPreviewRequired ) { - ret |= mCameraAdapter->setParameters(adapterParams); - } - -#ifdef OMAP_ENHANCEMENT - if( ( (valstr = params.get(TICameraParameters::KEY_SHUTTER_ENABLE)) != NULL ) && - ( strcmp(valstr, android::CameraParameters::TRUE) == 0 )) - { - CAMHAL_LOGDA("Enabling shutter sound"); - - mShutterEnabled = true; - mMsgEnabled |= CAMERA_MSG_SHUTTER; - mParameters.set(TICameraParameters::KEY_SHUTTER_ENABLE, valstr); - } - else if ( ( (valstr = params.get(TICameraParameters::KEY_SHUTTER_ENABLE)) != NULL ) && - ( strcmp(valstr, android::CameraParameters::FALSE) == 0 )) - { - CAMHAL_LOGDA("Disabling shutter sound"); - - mShutterEnabled = false; - mMsgEnabled &= ~CAMERA_MSG_SHUTTER; - mParameters.set(TICameraParameters::KEY_SHUTTER_ENABLE, valstr); - } -#endif - } - - //On fail restore old parameters - if ( NO_ERROR != ret ) { - mParameters = oldParams; - } - - // Restart Preview if needed by KEY_RECODING_HINT only if preview is already running. - // If preview is not started yet, Video Mode parameters will take effect on next startPreview() - if (restartPreviewRequired && previewEnabled() && !mRecordingEnabled) { - CAMHAL_LOGDA("Restarting Preview"); - ret = restartPreview(); - } else if (restartPreviewRequired && !previewEnabled() && - mDisplayPaused && !mRecordingEnabled) { - CAMHAL_LOGDA("Stopping Preview"); - forceStopPreview(); - } - - if ( !mBracketingRunning && mBracketingEnabled ) { - startImageBracketing(); - } - - if (ret != NO_ERROR) - { - CAMHAL_LOGEA("Failed to restart Preview"); - return ret; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t CameraHal::allocPreviewBufs(int width, int height, const char* previewFormat, - unsigned int buffercount, unsigned int &max_queueable) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if(mDisplayAdapter.get() == NULL) - { - // Memory allocation of preview buffers is now placed in gralloc - // CameraHal should not allocate preview buffers without DisplayAdapter - return NO_MEMORY; - } - - if(!mPreviewBuffers) - { - mPreviewLength = 0; - mPreviewBuffers = mDisplayAdapter->allocateBufferList(width, height, - previewFormat, - mPreviewLength, - buffercount); - if (NULL == mPreviewBuffers ) { - CAMHAL_LOGEA("Couldn't allocate preview buffers"); - return NO_MEMORY; - } - - mPreviewOffsets = (uint32_t *) mDisplayAdapter->getOffsets(); - if ( NULL == mPreviewOffsets ) { - CAMHAL_LOGEA("Buffer mapping failed"); - return BAD_VALUE; - } - - mBufProvider = (BufferProvider*) mDisplayAdapter.get(); - - ret = mDisplayAdapter->maxQueueableBuffers(max_queueable); - if (ret != NO_ERROR) { - return ret; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t CameraHal::freePreviewBufs() -{ - status_t ret = NO_ERROR; - LOG_FUNCTION_NAME; - - CAMHAL_LOGDB("mPreviewBuffers = %p", mPreviewBuffers); - if(mPreviewBuffers) - { - ret = mBufProvider->freeBufferList(mPreviewBuffers); - mPreviewBuffers = NULL; - LOG_FUNCTION_NAME_EXIT; - return ret; - } - LOG_FUNCTION_NAME_EXIT; - return ret; -} - - -status_t CameraHal::allocPreviewDataBufs(size_t size, size_t bufferCount) -{ - status_t ret = NO_ERROR; - int bytes; - - LOG_FUNCTION_NAME; - - bytes = size; - - if ( NO_ERROR == ret ) - { - if( NULL != mPreviewDataBuffers ) - { - ret = freePreviewDataBufs(); - } - } - - if ( NO_ERROR == ret ) - { - bytes = ((bytes+4095)/4096)*4096; - mPreviewDataBuffers = mMemoryManager->allocateBufferList(0, 0, NULL, bytes, bufferCount); - - CAMHAL_LOGDB("Size of Preview data buffer = %d", bytes); - if( NULL == mPreviewDataBuffers ) - { - CAMHAL_LOGEA("Couldn't allocate image buffers using memory manager"); - ret = -NO_MEMORY; - } - else - { - bytes = size; - } - } - - if ( NO_ERROR == ret ) - { - mPreviewDataFd = mMemoryManager->getFd(); - mPreviewDataLength = bytes; - mPreviewDataOffsets = mMemoryManager->getOffsets(); - } - else - { - mPreviewDataFd = -1; - mPreviewDataLength = 0; - mPreviewDataOffsets = NULL; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t CameraHal::freePreviewDataBufs() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( NO_ERROR == ret ) - { - - if( NULL != mPreviewDataBuffers ) - { - - ret = mMemoryManager->freeBufferList(mPreviewDataBuffers); - mPreviewDataBuffers = NULL; - - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t CameraHal::allocImageBufs(unsigned int width, unsigned int height, size_t size, - const char* previewFormat, unsigned int bufferCount, - unsigned int *max_queueable) -{ - status_t ret = NO_ERROR; - int bytes; - - LOG_FUNCTION_NAME; - - bytes = size; - - // allocate image buffers only if not already allocated - if(NULL != mImageBuffers) { - if (mBufferSourceAdapter_Out.get()) { - mBufferSourceAdapter_Out->maxQueueableBuffers(*max_queueable); - } else { - *max_queueable = bufferCount; - } - return NO_ERROR; - } - - if (mBufferSourceAdapter_Out.get()) { - mImageBuffers = mBufferSourceAdapter_Out->allocateBufferList(width, height, previewFormat, - bytes, bufferCount); - mBufferSourceAdapter_Out->maxQueueableBuffers(*max_queueable); - } else { - bytes = ((bytes + 4095) / 4096) * 4096; - mImageBuffers = mMemoryManager->allocateBufferList(0, 0, previewFormat, bytes, bufferCount); - *max_queueable = bufferCount; - } - - CAMHAL_LOGDB("Size of Image cap buffer = %d", bytes); - if ( NULL == mImageBuffers ) { - CAMHAL_LOGEA("Couldn't allocate image buffers using memory manager"); - ret = -NO_MEMORY; - } else { - bytes = size; - } - - if ( NO_ERROR == ret ) { - mImageFd = mMemoryManager->getFd(); - mImageLength = bytes; - mImageOffsets = mMemoryManager->getOffsets(); - } else { - mImageFd = -1; - mImageLength = 0; - mImageOffsets = NULL; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t CameraHal::allocVideoBufs(uint32_t width, uint32_t height, uint32_t bufferCount) -{ - status_t ret = NO_ERROR; - LOG_FUNCTION_NAME; - - if( NULL != mVideoBuffers ){ - ret = freeVideoBufs(mVideoBuffers); - mVideoBuffers = NULL; - } - - if ( NO_ERROR == ret ){ - int32_t stride; - CameraBuffer *buffers = new CameraBuffer [bufferCount]; - - memset (buffers, 0, sizeof(CameraBuffer) * bufferCount); - - if (buffers != NULL){ - for (unsigned int i = 0; i< bufferCount; i++){ - android::GraphicBufferAllocator &GrallocAlloc = android::GraphicBufferAllocator::get(); - buffer_handle_t handle; - ret = GrallocAlloc.alloc(width, height, HAL_PIXEL_FORMAT_NV12, CAMHAL_GRALLOC_USAGE, &handle, &stride); - if (ret != NO_ERROR){ - CAMHAL_LOGEA("Couldn't allocate video buffers using Gralloc"); - ret = -NO_MEMORY; - for (unsigned int j=0; j< i; j++){ - CAMHAL_LOGEB("Freeing Gralloc Buffer %p", buffers[i].opaque); - GrallocAlloc.free((buffer_handle_t)buffers[i].opaque); - } - delete [] buffers; - goto exit; - } - buffers[i].type = CAMERA_BUFFER_GRALLOC; - buffers[i].opaque = (void *)handle; - CAMHAL_LOGVB("*** Gralloc Handle =0x%x ***", handle); - } - - mVideoBuffers = buffers; - } - else{ - CAMHAL_LOGEA("Couldn't allocate video buffers "); - ret = -NO_MEMORY; - } - } - - exit: - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t CameraHal::allocRawBufs(int width, int height, const char* previewFormat, int bufferCount) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME - - - ///@todo Enhance this method allocImageBufs() to take in a flag for burst capture - ///Always allocate the buffers for image capture using MemoryManager - if (NO_ERROR == ret) { - if(( NULL != mVideoBuffers )) { - // Re-use the buffer for raw capture. - return ret; - } - } - - if ( NO_ERROR == ret ) { - mVideoLength = 0; - mVideoLength = (((width * height * 2) + 4095)/4096)*4096; - mVideoBuffers = mMemoryManager->allocateBufferList(width, height, previewFormat, - mVideoLength, bufferCount); - - CAMHAL_LOGDB("Size of Video cap buffer (used for RAW capture) %d", mVideoLength); - if( NULL == mVideoBuffers ) { - CAMHAL_LOGEA("Couldn't allocate Video buffers using memory manager"); - ret = -NO_MEMORY; - } - } - - if ( NO_ERROR == ret ) { - mVideoFd = mMemoryManager->getFd(); - mVideoOffsets = mMemoryManager->getOffsets(); - } else { - mVideoFd = -1; - mVideoOffsets = NULL; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -void endImageCapture( void *userData) -{ - LOG_FUNCTION_NAME; - - if ( NULL != userData ) - { - CameraHal *c = reinterpret_cast(userData); - c->signalEndImageCapture(); - } - - LOG_FUNCTION_NAME_EXIT; -} - -void releaseImageBuffers(void *userData) -{ - LOG_FUNCTION_NAME; - - if (NULL != userData) { - CameraHal *c = reinterpret_cast(userData); - c->freeImageBufs(); - } - - LOG_FUNCTION_NAME_EXIT; -} - -status_t CameraHal::signalEndImageCapture() -{ - status_t ret = NO_ERROR; - int w,h; - android::AutoMutex lock(mLock); - - LOG_FUNCTION_NAME; - - if (mBufferSourceAdapter_Out.get()) { - mBufferSourceAdapter_Out->disableDisplay(); - } - - if (mBufferSourceAdapter_In.get()) { - mBufferSourceAdapter_In->disableDisplay(); - } - - if ( mBracketingRunning ) { - stopImageBracketing(); - } else { - mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_IMAGE_CAPTURE); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t CameraHal::freeImageBufs() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if (NULL == mImageBuffers) { - return -EINVAL; - } - - if (mBufferSourceAdapter_Out.get()) { - ret = mBufferSourceAdapter_Out->freeBufferList(mImageBuffers); - } else { - ret = mMemoryManager->freeBufferList(mImageBuffers); - } - - if (ret == NO_ERROR) { - mImageBuffers = NULL; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t CameraHal::freeVideoBufs(CameraBuffer *bufs) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - int count = atoi(mCameraProperties->get(CameraProperties::REQUIRED_PREVIEW_BUFS)); - if(bufs == NULL) - { - CAMHAL_LOGEA("NULL pointer passed to freeVideoBuffer"); - LOG_FUNCTION_NAME_EXIT; - return BAD_VALUE; - } - - android::GraphicBufferAllocator &GrallocAlloc = android::GraphicBufferAllocator::get(); - - for(int i = 0; i < count; i++){ - CAMHAL_LOGVB("Free Video Gralloc Handle 0x%x", bufs[i].opaque); - GrallocAlloc.free((buffer_handle_t)bufs[i].opaque); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t CameraHal::freeRawBufs() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME - - if ( NO_ERROR == ret ) { - if( NULL != mVideoBuffers ) { - ///@todo Pluralise the name of this method to freeBuffers - ret = mMemoryManager->freeBufferList(mVideoBuffers); - mVideoBuffers = NULL; - } else { - ret = -EINVAL; - } - } - - LOG_FUNCTION_NAME_EXIT - - return ret; -} - -/** - @brief Start preview mode. - - @param none - @return NO_ERROR Camera switched to VF mode - @todo Update function header with the different errors that are possible - - */ -status_t CameraHal::startPreview() { - LOG_FUNCTION_NAME; - - // When tunneling is enabled during VTC, startPreview happens in 2 steps: - // When the application sends the command CAMERA_CMD_PREVIEW_INITIALIZATION, - // cameraPreviewInitialization() is called, which in turn causes the CameraAdapter - // to move from loaded to idle state. And when the application calls startPreview, - // the CameraAdapter moves from idle to executing state. - // - // If the application calls startPreview() without sending the command - // CAMERA_CMD_PREVIEW_INITIALIZATION, then the function cameraPreviewInitialization() - // AND startPreview() are executed. In other words, if the application calls - // startPreview() without sending the command CAMERA_CMD_PREVIEW_INITIALIZATION, - // then the CameraAdapter moves from loaded to idle to executing state in one shot. - status_t ret = cameraPreviewInitialization(); - - // The flag mPreviewInitializationDone is set to true at the end of the function - // cameraPreviewInitialization(). Therefore, if everything goes alright, then the - // flag will be set. Sometimes, the function cameraPreviewInitialization() may - // return prematurely if all the resources are not available for starting preview. - // For example, if the preview window is not set, then it would return NO_ERROR. - // Under such circumstances, one should return from startPreview as well and should - // not continue execution. That is why, we check the flag and not the return value. - if (!mPreviewInitializationDone) return ret; - - // Once startPreview is called, there is no need to continue to remember whether - // the function cameraPreviewInitialization() was called earlier or not. And so - // the flag mPreviewInitializationDone is reset here. Plus, this preserves the - // current behavior of startPreview under the circumstances where the application - // calls startPreview twice or more. - mPreviewInitializationDone = false; - - ///Enable the display adapter if present, actual overlay enable happens when we post the buffer - if(mDisplayAdapter.get() != NULL) { - CAMHAL_LOGDA("Enabling display"); - int width, height; - mParameters.getPreviewSize(&width, &height); - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - ret = mDisplayAdapter->enableDisplay(width, height, &mStartPreview); -#else - ret = mDisplayAdapter->enableDisplay(width, height, NULL); -#endif - - if ( ret != NO_ERROR ) { - CAMHAL_LOGEA("Couldn't enable display"); - - // FIXME: At this stage mStateSwitchLock is locked and unlock is supposed to be called - // only from mCameraAdapter->sendCommand(CameraAdapter::CAMERA_START_PREVIEW) - // below. But this will never happen because of goto error. Thus at next - // startPreview() call CameraHAL will be deadlocked. - // Need to revisit mStateSwitch lock, for now just abort the process. - CAMHAL_ASSERT_X(false, - "At this stage mCameraAdapter->mStateSwitchLock is still locked, " - "deadlock is guaranteed"); - - goto error; - } - - } - - ///Send START_PREVIEW command to adapter - CAMHAL_LOGDA("Starting CameraAdapter preview mode"); - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_START_PREVIEW); - - if(ret!=NO_ERROR) { - CAMHAL_LOGEA("Couldn't start preview w/ CameraAdapter"); - goto error; - } - CAMHAL_LOGDA("Started preview"); - - mPreviewEnabled = true; - mPreviewStartInProgress = false; - return ret; - - error: - - CAMHAL_LOGEA("Performing cleanup after error"); - - //Do all the cleanup - freePreviewBufs(); - mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_PREVIEW); - if(mDisplayAdapter.get() != NULL) { - mDisplayAdapter->disableDisplay(false); - } - mAppCallbackNotifier->stop(); - mPreviewStartInProgress = false; - mPreviewEnabled = false; - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -//////////// -/** - @brief Set preview mode related initialization - -> Camera Adapter set params - -> Allocate buffers - -> Set use buffers for preview - @param none - @return NO_ERROR - @todo Update function header with the different errors that are possible - - */ -status_t CameraHal::cameraPreviewInitialization() -{ - - status_t ret = NO_ERROR; - CameraAdapter::BuffersDescriptor desc; - CameraFrame frame; - unsigned int required_buffer_count; - unsigned int max_queueble_buffers; - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - gettimeofday(&mStartPreview, NULL); -#endif - - LOG_FUNCTION_NAME; - - if (mPreviewInitializationDone) { - return NO_ERROR; - } - - if ( mPreviewEnabled ){ - CAMHAL_LOGDA("Preview already running"); - LOG_FUNCTION_NAME_EXIT; - return ALREADY_EXISTS; - } - - if ( NULL != mCameraAdapter ) { - ret = mCameraAdapter->setParameters(mParameters); - } - - if ((mPreviewStartInProgress == false) && (mDisplayPaused == false)){ - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_QUERY_RESOLUTION_PREVIEW,( int ) &frame); - if ( NO_ERROR != ret ){ - CAMHAL_LOGEB("Error: CAMERA_QUERY_RESOLUTION_PREVIEW %d", ret); - return ret; - } - - ///Update the current preview width and height - mPreviewWidth = frame.mWidth; - mPreviewHeight = frame.mHeight; - } - - ///If we don't have the preview callback enabled and display adapter, - if(!mSetPreviewWindowCalled || (mDisplayAdapter.get() == NULL)){ - CAMHAL_LOGD("Preview not started. Preview in progress flag set"); - mPreviewStartInProgress = true; - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_SWITCH_TO_EXECUTING); - if ( NO_ERROR != ret ){ - CAMHAL_LOGEB("Error: CAMERA_SWITCH_TO_EXECUTING %d", ret); - return ret; - } - return NO_ERROR; - } - - if( (mDisplayAdapter.get() != NULL) && ( !mPreviewEnabled ) && ( mDisplayPaused ) ) - { - CAMHAL_LOGDA("Preview is in paused state"); - - mDisplayPaused = false; - mPreviewEnabled = true; - if ( NO_ERROR == ret ) - { - ret = mDisplayAdapter->pauseDisplay(mDisplayPaused); - - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Display adapter resume failed %x", ret); - } - } - //restart preview callbacks - if(mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME) - { - mAppCallbackNotifier->enableMsgType (CAMERA_MSG_PREVIEW_FRAME); - } - - signalEndImageCapture(); - return ret; - } - - required_buffer_count = atoi(mCameraProperties->get(CameraProperties::REQUIRED_PREVIEW_BUFS)); - - ///Allocate the preview buffers - ret = allocPreviewBufs(mPreviewWidth, mPreviewHeight, mParameters.getPreviewFormat(), required_buffer_count, max_queueble_buffers); - - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEA("Couldn't allocate buffers for Preview"); - goto error; - } - - if ( mMeasurementEnabled ) - { - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_QUERY_BUFFER_SIZE_PREVIEW_DATA, - ( int ) &frame, - required_buffer_count); - if ( NO_ERROR != ret ) - { - return ret; - } - - ///Allocate the preview data buffers - ret = allocPreviewDataBufs(frame.mLength, required_buffer_count); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEA("Couldn't allocate preview data buffers"); - goto error; - } - - if ( NO_ERROR == ret ) - { - desc.mBuffers = mPreviewDataBuffers; - desc.mOffsets = mPreviewDataOffsets; - desc.mFd = mPreviewDataFd; - desc.mLength = mPreviewDataLength; - desc.mCount = ( size_t ) required_buffer_count; - desc.mMaxQueueable = (size_t) required_buffer_count; - - mCameraAdapter->sendCommand(CameraAdapter::CAMERA_USE_BUFFERS_PREVIEW_DATA, - ( int ) &desc); - } - - } - - ///Pass the buffers to Camera Adapter - desc.mBuffers = mPreviewBuffers; - desc.mOffsets = mPreviewOffsets; - desc.mFd = mPreviewFd; - desc.mLength = mPreviewLength; - desc.mCount = ( size_t ) required_buffer_count; - desc.mMaxQueueable = (size_t) max_queueble_buffers; - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_USE_BUFFERS_PREVIEW, - ( int ) &desc); - - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Failed to register preview buffers: 0x%x", ret); - freePreviewBufs(); - return ret; - } - - ///Start the callback notifier - ret = mAppCallbackNotifier->start(); - - if( ALREADY_EXISTS == ret ) - { - //Already running, do nothing - CAMHAL_LOGDA("AppCallbackNotifier already running"); - ret = NO_ERROR; - } - else if ( NO_ERROR == ret ) { - CAMHAL_LOGDA("Started AppCallbackNotifier.."); - mAppCallbackNotifier->setMeasurements(mMeasurementEnabled); - } - else - { - CAMHAL_LOGDA("Couldn't start AppCallbackNotifier"); - goto error; - } - - if (ret == NO_ERROR) mPreviewInitializationDone = true; - - mAppCallbackNotifier->startPreviewCallbacks(mParameters, mPreviewBuffers, mPreviewOffsets, mPreviewFd, mPreviewLength, required_buffer_count); - - return ret; - - error: - - CAMHAL_LOGEA("Performing cleanup after error"); - - //Do all the cleanup - freePreviewBufs(); - mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_PREVIEW); - if(mDisplayAdapter.get() != NULL) - { - mDisplayAdapter->disableDisplay(false); - } - mAppCallbackNotifier->stop(); - mPreviewStartInProgress = false; - mPreviewEnabled = false; - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -/** - @brief Sets ANativeWindow object. - - Preview buffers provided to CameraHal via this object. DisplayAdapter will be interfacing with it - to render buffers to display. - - @param[in] window The ANativeWindow object created by Surface flinger - @return NO_ERROR If the ANativeWindow object passes validation criteria - @todo Define validation criteria for ANativeWindow object. Define error codes for scenarios - - */ -status_t CameraHal::setPreviewWindow(struct preview_stream_ops *window) -{ - status_t ret = NO_ERROR; - CameraAdapter::BuffersDescriptor desc; - - LOG_FUNCTION_NAME; - mSetPreviewWindowCalled = true; - - ///If the Camera service passes a null window, we destroy existing window and free the DisplayAdapter - if(!window) - { - if(mDisplayAdapter.get() != NULL) - { - ///NULL window passed, destroy the display adapter if present - CAMHAL_LOGD("NULL window passed, destroying display adapter"); - mDisplayAdapter.clear(); - ///@remarks If there was a window previously existing, we usually expect another valid window to be passed by the client - ///@remarks so, we will wait until it passes a valid window to begin the preview again - mSetPreviewWindowCalled = false; - } - CAMHAL_LOGD("NULL ANativeWindow passed to setPreviewWindow"); - return NO_ERROR; - }else if(mDisplayAdapter.get() == NULL) - { - // Need to create the display adapter since it has not been created - // Create display adapter - mDisplayAdapter = new ANativeWindowDisplayAdapter(); -#ifdef OMAP_ENHANCEMENT - mDisplayAdapter->setExtendedOps(mExtendedPreviewStreamOps); -#endif - ret = NO_ERROR; - if(!mDisplayAdapter.get() || ((ret=mDisplayAdapter->initialize())!=NO_ERROR)) - { - if(ret!=NO_ERROR) - { - mDisplayAdapter.clear(); - CAMHAL_LOGEA("DisplayAdapter initialize failed"); - LOG_FUNCTION_NAME_EXIT; - return ret; - } - else - { - CAMHAL_LOGEA("Couldn't create DisplayAdapter"); - LOG_FUNCTION_NAME_EXIT; - return NO_MEMORY; - } - } - - // DisplayAdapter needs to know where to get the CameraFrames from inorder to display - // Since CameraAdapter is the one that provides the frames, set it as the frame provider for DisplayAdapter - mDisplayAdapter->setFrameProvider(mCameraAdapter); - - // Any dynamic errors that happen during the camera use case has to be propagated back to the application - // via CAMERA_MSG_ERROR. AppCallbackNotifier is the class that notifies such errors to the application - // Set it as the error handler for the DisplayAdapter - mDisplayAdapter->setErrorHandler(mAppCallbackNotifier.get()); - - // Update the display adapter with the new window that is passed from CameraService - ret = mDisplayAdapter->setPreviewWindow(window); - if(ret!=NO_ERROR) - { - CAMHAL_LOGEB("DisplayAdapter setPreviewWindow returned error %d", ret); - } - - if(mPreviewStartInProgress) - { - CAMHAL_LOGDA("setPreviewWindow called when preview running"); - // Start the preview since the window is now available - ret = startPreview(); - } - } else { - // Update the display adapter with the new window that is passed from CameraService - ret = mDisplayAdapter->setPreviewWindow(window); - if ( (NO_ERROR == ret) && previewEnabled() ) { - restartPreview(); - } else if (ret == ALREADY_EXISTS) { - // ALREADY_EXISTS should be treated as a noop in this case - ret = NO_ERROR; - } - } - LOG_FUNCTION_NAME_EXIT; - - return ret; - -} - - -#ifdef OMAP_ENHANCEMENT_CPCAM -void CameraHal::setExtendedPreviewStreamOps(preview_stream_extended_ops_t *ops) -{ - mExtendedPreviewStreamOps = ops; -} - -/** - @brief Sets ANativeWindow object. - - Buffers provided to CameraHal via this object for tap-in/tap-out - functionality. - - TODO(XXX): this is just going to use preview_stream_ops for now, but we - most likely need to extend it when we want more functionality - - @param[in] window The ANativeWindow object created by Surface flinger - @return NO_ERROR If the ANativeWindow object passes validation criteria - @todo Define validation criteria for ANativeWindow object. Define error codes for scenarios - - */ -status_t CameraHal::setBufferSource(struct preview_stream_ops *tapin, struct preview_stream_ops *tapout) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - // If either a tapin or tapout was previously set - // we need to clean up and clear capturing - if ((!tapout && mBufferSourceAdapter_Out.get()) || - (!tapin && mBufferSourceAdapter_In.get())) { - signalEndImageCapture(); - } - - // Set tapout point - // destroy current buffer tapout if NULL tapout is passed - if (!tapout) { - if (mBufferSourceAdapter_Out.get() != NULL) { - CAMHAL_LOGD("NULL tapout passed, destroying buffer tapout adapter"); - mBufferSourceAdapter_Out.clear(); - mBufferSourceAdapter_Out = 0; - } - ret = NO_ERROR; - } else if (mBufferSourceAdapter_Out.get() == NULL) { - mBufferSourceAdapter_Out = new BufferSourceAdapter(); - mBufferSourceAdapter_Out->setExtendedOps(mExtendedPreviewStreamOps); - if(!mBufferSourceAdapter_Out.get()) { - CAMHAL_LOGEA("Couldn't create DisplayAdapter"); - ret = NO_MEMORY; - goto exit; - } - - ret = mBufferSourceAdapter_Out->initialize(); - if (ret != NO_ERROR) - { - mBufferSourceAdapter_Out.clear(); - mBufferSourceAdapter_Out = 0; - CAMHAL_LOGEA("DisplayAdapter initialize failed"); - goto exit; - } - - // CameraAdapter will be the frame provider for BufferSourceAdapter - mBufferSourceAdapter_Out->setFrameProvider(mCameraAdapter); - - // BufferSourceAdapter will use ErrorHandler to send errors back to - // the application - mBufferSourceAdapter_Out->setErrorHandler(mAppCallbackNotifier.get()); - - // Update the display adapter with the new window that is passed from CameraService - ret = mBufferSourceAdapter_Out->setPreviewWindow(tapout); - if(ret != NO_ERROR) { - CAMHAL_LOGEB("DisplayAdapter setPreviewWindow returned error %d", ret); - goto exit; - } - } else { - // Update the display adapter with the new window that is passed from CameraService - freeImageBufs(); - ret = mBufferSourceAdapter_Out->setPreviewWindow(tapout); - if (ret == ALREADY_EXISTS) { - // ALREADY_EXISTS should be treated as a noop in this case - ret = NO_ERROR; - } - } - - if (ret != NO_ERROR) { - CAMHAL_LOGE("Error while trying to set tapout point"); - goto exit; - } - - // 1. Set tapin point - if (!tapin) { - if (mBufferSourceAdapter_In.get() != NULL) { - CAMHAL_LOGD("NULL tapin passed, destroying buffer tapin adapter"); - mBufferSourceAdapter_In.clear(); - mBufferSourceAdapter_In = 0; - } - ret = NO_ERROR; - } else if (mBufferSourceAdapter_In.get() == NULL) { - mBufferSourceAdapter_In = new BufferSourceAdapter(); - mBufferSourceAdapter_In->setExtendedOps(mExtendedPreviewStreamOps); - if(!mBufferSourceAdapter_In.get()) { - CAMHAL_LOGEA("Couldn't create DisplayAdapter"); - ret = NO_MEMORY; - goto exit; - } - - ret = mBufferSourceAdapter_In->initialize(); - if (ret != NO_ERROR) - { - mBufferSourceAdapter_In.clear(); - mBufferSourceAdapter_In = 0; - CAMHAL_LOGEA("DisplayAdapter initialize failed"); - goto exit; - } - - // We need to set a frame provider so camera adapter can return the frame back to us - mBufferSourceAdapter_In->setFrameProvider(mCameraAdapter); - - // BufferSourceAdapter will use ErrorHandler to send errors back to - // the application - mBufferSourceAdapter_In->setErrorHandler(mAppCallbackNotifier.get()); - - // Update the display adapter with the new window that is passed from CameraService - ret = mBufferSourceAdapter_In->setPreviewWindow(tapin); - if(ret != NO_ERROR) { - CAMHAL_LOGEB("DisplayAdapter setPreviewWindow returned error %d", ret); - goto exit; - } - } else { - // Update the display adapter with the new window that is passed from CameraService - ret = mBufferSourceAdapter_In->setPreviewWindow(tapin); - if (ret == ALREADY_EXISTS) { - // ALREADY_EXISTS should be treated as a noop in this case - ret = NO_ERROR; - } - } - - exit: - return ret; -} -#endif - - -/** - @brief Stop a previously started preview. - - @param none - @return none - - */ -void CameraHal::stopPreview() -{ - LOG_FUNCTION_NAME; - - if( (!previewEnabled() && !mDisplayPaused) || mRecordingEnabled) - { - LOG_FUNCTION_NAME_EXIT; - return; - } - - bool imageCaptureRunning = (mCameraAdapter->getState() & CameraAdapter::CAPTURE_STATE) && - (mCameraAdapter->getNextState() != CameraAdapter::PREVIEW_STATE); - if(mDisplayPaused && !imageCaptureRunning) - { - // Display is paused, which essentially means there is no preview active. - // Note: this is done so that when stopPreview is called by client after - // an image capture, we do not de-initialize the camera adapter and - // restart over again. - - return; - } - - forceStopPreview(); - - // Reset Capture-Mode to default, so that when we switch from VideoRecording - // to ImageCapture, CAPTURE_MODE is not left to VIDEO_MODE. - CAMHAL_LOGDA("Resetting Capture-Mode to default"); - mParameters.set(TICameraParameters::KEY_CAP_MODE, ""); - - LOG_FUNCTION_NAME_EXIT; -} - -/** - @brief Returns true if preview is enabled - - @param none - @return true If preview is running currently - false If preview has been stopped - - */ -bool CameraHal::previewEnabled() -{ - LOG_FUNCTION_NAME; - - return (mPreviewEnabled || mPreviewStartInProgress); -} - -/** - @brief Start record mode. - - When a record image is available a CAMERA_MSG_VIDEO_FRAME message is sent with - the corresponding frame. Every record frame must be released by calling - releaseRecordingFrame(). - - @param none - @return NO_ERROR If recording could be started without any issues - @todo Update the header with possible error values in failure scenarios - - */ -status_t CameraHal::startRecording( ) -{ - int w, h; - const char *valstr = NULL; - bool restartPreviewRequired = false; - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - gettimeofday(&mStartPreview, NULL); - -#endif - - if(!previewEnabled()) - { - return NO_INIT; - } - - // set internal recording hint in case camera adapter needs to make some - // decisions....(will only be sent to camera adapter if camera restart is required) - mParameters.set(TICameraParameters::KEY_RECORDING_HINT, android::CameraParameters::TRUE); - - // if application starts recording in continuous focus picture mode... - // then we need to force default capture mode (as opposed to video mode) - if ( ((valstr = mParameters.get(android::CameraParameters::KEY_FOCUS_MODE)) != NULL) && - (strcmp(valstr, android::CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE) == 0) ){ - restartPreviewRequired = resetVideoModeParameters(); - } - - // only need to check recording hint if preview restart is not already needed - valstr = mParameters.get(android::CameraParameters::KEY_RECORDING_HINT); - if ( !restartPreviewRequired && - (!valstr || (valstr && (strcmp(valstr, android::CameraParameters::TRUE) != 0))) ) { - restartPreviewRequired = setVideoModeParameters(mParameters); - } - - if (restartPreviewRequired) { - { - android::AutoMutex lock(mLock); - mCapModeBackup = mParameters.get(TICameraParameters::KEY_CAP_MODE); - } - ret = restartPreview(); - } - - if ( NO_ERROR == ret ) - { - int count = atoi(mCameraProperties->get(CameraProperties::REQUIRED_PREVIEW_BUFS)); - mParameters.getPreviewSize(&w, &h); - CAMHAL_LOGDB("%s Video Width=%d Height=%d", __FUNCTION__, mVideoWidth, mVideoHeight); - - if ((w != mVideoWidth) && (h != mVideoHeight)) - { - ret = allocVideoBufs(mVideoWidth, mVideoHeight, count); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("allocImageBufs returned error 0x%x", ret); - mParameters.remove(TICameraParameters::KEY_RECORDING_HINT); - return ret; - } - - mAppCallbackNotifier->useVideoBuffers(true); - mAppCallbackNotifier->setVideoRes(mVideoWidth, mVideoHeight); - ret = mAppCallbackNotifier->initSharedVideoBuffers(mPreviewBuffers, mPreviewOffsets, mPreviewFd, mPreviewLength, count, mVideoBuffers); - } - else - { - mAppCallbackNotifier->useVideoBuffers(false); - mAppCallbackNotifier->setVideoRes(mPreviewWidth, mPreviewHeight); - ret = mAppCallbackNotifier->initSharedVideoBuffers(mPreviewBuffers, mPreviewOffsets, mPreviewFd, mPreviewLength, count, NULL); - } - } - - if ( NO_ERROR == ret ) - { - ret = mAppCallbackNotifier->startRecording(); - } - - if ( NO_ERROR == ret ) - { - ///Buffers for video capture (if different from preview) are expected to be allocated within CameraAdapter - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_START_VIDEO); - } - - if ( NO_ERROR == ret ) - { - mRecordingEnabled = true; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -/** - @brief Set the camera parameters specific to Video Recording. - - This function checks for the camera parameters which have to be set for recording. - Video Recording needs CAPTURE_MODE to be VIDEO_MODE. This function sets it. - This function also enables Video Recording specific functions like VSTAB & VNF. - - @param none - @return true if preview needs to be restarted for VIDEO_MODE parameters to take effect. - @todo Modify the policies for enabling VSTAB & VNF usecase based later. - - */ -bool CameraHal::setVideoModeParameters(const android::CameraParameters& params) -{ - const char *valstr = NULL; - const char *valstrRemote = NULL; - bool restartPreviewRequired = false; - - LOG_FUNCTION_NAME; - - // Set CAPTURE_MODE to VIDEO_MODE, if not set already and Restart Preview - valstr = mParameters.get(TICameraParameters::KEY_CAP_MODE); - if ( (valstr == NULL) || - ( (valstr != NULL) && (strcmp(valstr, (const char *) TICameraParameters::VIDEO_MODE) != 0) ) ) - { - CAMHAL_LOGDA("Set CAPTURE_MODE to VIDEO_MODE"); - mParameters.set(TICameraParameters::KEY_CAP_MODE, (const char *) TICameraParameters::VIDEO_MODE); - restartPreviewRequired = true; - } - - // set VSTAB. restart is required if vstab value has changed - if ( (valstrRemote = params.get(android::CameraParameters::KEY_VIDEO_STABILIZATION)) != NULL ) { - // make sure we support vstab - if (strcmp(mCameraProperties->get(CameraProperties::VSTAB_SUPPORTED), - android::CameraParameters::TRUE) == 0) { - valstr = mParameters.get(android::CameraParameters::KEY_VIDEO_STABILIZATION); - // vstab value has changed - if ((valstr != NULL) && - strcmp(valstr, valstrRemote) != 0) { - restartPreviewRequired = true; - } - mParameters.set(android::CameraParameters::KEY_VIDEO_STABILIZATION, - valstrRemote); - } - } else if (mParameters.get(android::CameraParameters::KEY_VIDEO_STABILIZATION)) { - // vstab was configured but now unset - restartPreviewRequired = true; - mParameters.remove(android::CameraParameters::KEY_VIDEO_STABILIZATION); - } - - // Set VNF - if ((valstrRemote = params.get(TICameraParameters::KEY_VNF)) == NULL) { - CAMHAL_LOGDA("Enable VNF"); - mParameters.set(TICameraParameters::KEY_VNF, android::CameraParameters::TRUE); - restartPreviewRequired = true; - } else { - valstr = mParameters.get(TICameraParameters::KEY_VNF); - if (valstr && strcmp(valstr, valstrRemote) != 0) { - restartPreviewRequired = true; - } - mParameters.set(TICameraParameters::KEY_VNF, valstrRemote); - } - -#if !defined(OMAP_ENHANCEMENT) && !defined(ENHANCED_DOMX) - // For VSTAB alone for 1080p resolution, padded width goes > 2048, which cannot be rendered by GPU. - // In such case, there is support in Ducati for combination of VSTAB & VNF requiring padded width < 2048. - // So we are forcefully enabling VNF, if VSTAB is enabled for 1080p resolution. - int w, h; - params.getPreviewSize(&w, &h); - valstr = mParameters.get(android::CameraParameters::KEY_VIDEO_STABILIZATION); - if (valstr && (strcmp(valstr, android::CameraParameters::TRUE) == 0) && (w == 1920)) { - CAMHAL_LOGDA("Force Enable VNF for 1080p"); - const char *valKeyVnf = mParameters.get(TICameraParameters::KEY_VNF); - if(!valKeyVnf || (strcmp(valKeyVnf, android::CameraParameters::TRUE) != 0)) { - mParameters.set(TICameraParameters::KEY_VNF, android::CameraParameters::TRUE); - restartPreviewRequired = true; - } - } -#endif - - LOG_FUNCTION_NAME_EXIT; - - return restartPreviewRequired; -} - -/** - @brief Reset the camera parameters specific to Video Recording. - - This function resets CAPTURE_MODE and disables Recording specific functions like VSTAB & VNF. - - @param none - @return true if preview needs to be restarted for VIDEO_MODE parameters to take effect. - - */ -bool CameraHal::resetVideoModeParameters() -{ - const char *valstr = NULL; - bool restartPreviewRequired = false; - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - // ignore this if we are already recording - if (mRecordingEnabled) { - return false; - } - - // Set CAPTURE_MODE to VIDEO_MODE, if not set already and Restart Preview - valstr = mParameters.get(TICameraParameters::KEY_CAP_MODE); - if ((valstr != NULL) && (strcmp(valstr, TICameraParameters::VIDEO_MODE) == 0)) { - CAMHAL_LOGDA("Reset Capture-Mode to default"); - mParameters.set(TICameraParameters::KEY_CAP_MODE, ""); - restartPreviewRequired = true; - } - - LOG_FUNCTION_NAME_EXIT; - - return restartPreviewRequired; -} - -/** - @brief Restart the preview with setParameter. - - This function restarts preview, for some VIDEO_MODE parameters to take effect. - - @param none - @return NO_ERROR If recording parameters could be set without any issues - - */ -status_t CameraHal::restartPreview() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - // Retain CAPTURE_MODE before calling stopPreview(), since it is reset in stopPreview(). - - forceStopPreview(); - - { - android::AutoMutex lock(mLock); - if (!mCapModeBackup.isEmpty()) { - mParameters.set(TICameraParameters::KEY_CAP_MODE, mCapModeBackup.string()); - mCapModeBackup = ""; - } else { - mParameters.set(TICameraParameters::KEY_CAP_MODE, ""); - } - mCameraAdapter->setParameters(mParameters); - } - - ret = startPreview(); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -/** - @brief Stop a previously started recording. - - @param none - @return none - - */ -void CameraHal::stopRecording() -{ - CameraAdapter::AdapterState currentState; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mLock); - - if (!mRecordingEnabled ) - { - return; - } - - currentState = mCameraAdapter->getState(); - if (currentState == CameraAdapter::VIDEO_CAPTURE_STATE) { - mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_IMAGE_CAPTURE); - } - - mAppCallbackNotifier->stopRecording(); - - mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_VIDEO); - - mRecordingEnabled = false; - - if ( mAppCallbackNotifier->getUesVideoBuffers() ){ - freeVideoBufs(mVideoBuffers); - if (mVideoBuffers){ - CAMHAL_LOGVB(" FREEING mVideoBuffers %p", mVideoBuffers); - delete [] mVideoBuffers; - } - mVideoBuffers = NULL; - } - - // reset internal recording hint in case camera adapter needs to make some - // decisions....(will only be sent to camera adapter if camera restart is required) - mParameters.remove(TICameraParameters::KEY_RECORDING_HINT); - - LOG_FUNCTION_NAME_EXIT; -} - -/** - @brief Returns true if recording is enabled. - - @param none - @return true If recording is currently running - false If recording has been stopped - - */ -int CameraHal::recordingEnabled() -{ - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return mRecordingEnabled; -} - -/** - @brief Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME. - - @param[in] mem MemoryBase pointer to the frame being released. Must be one of the buffers - previously given by CameraHal - @return none - - */ -void CameraHal::releaseRecordingFrame(const void* mem) -{ - LOG_FUNCTION_NAME; - - //CAMHAL_LOGDB(" 0x%x", mem->pointer()); - - if ( ( mRecordingEnabled ) && mem != NULL) - { - mAppCallbackNotifier->releaseRecordingFrame(mem); - } - - LOG_FUNCTION_NAME_EXIT; - - return; -} - -/** - @brief Start auto focus - - This call asynchronous. - The notification callback routine is called with CAMERA_MSG_FOCUS once when - focusing is complete. autoFocus() will be called again if another auto focus is - needed. - - @param none - @return NO_ERROR - @todo Define the error codes if the focus is not locked - - */ -status_t CameraHal::autoFocus() -{ - status_t ret = NO_ERROR; - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - gettimeofday(&mStartFocus, NULL); - -#endif - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mLock); - - mMsgEnabled |= CAMERA_MSG_FOCUS; - - if ( NULL == mCameraAdapter ) - { - ret = -1; - goto EXIT; - } - - CameraAdapter::AdapterState state; - ret = mCameraAdapter->getState(state); - if (ret != NO_ERROR) - { - goto EXIT; - } - - if (state == CameraAdapter::AF_STATE) - { - CAMHAL_LOGI("Ignoring start-AF (already in progress)"); - goto EXIT; - } - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - //pass the autoFocus timestamp along with the command to camera adapter - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_PERFORM_AUTOFOCUS, ( int ) &mStartFocus); - -#else - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_PERFORM_AUTOFOCUS); - -#endif - -EXIT: - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -/** - @brief Cancels auto-focus function. - - If the auto-focus is still in progress, this function will cancel it. - Whether the auto-focus is in progress or not, this function will return the - focus position to the default. If the camera does not support auto-focus, this is a no-op. - - - @param none - @return NO_ERROR If the cancel succeeded - @todo Define error codes if cancel didnt succeed - - */ -status_t CameraHal::cancelAutoFocus() -{ - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mLock); - android::CameraParameters adapterParams = mParameters; - mMsgEnabled &= ~CAMERA_MSG_FOCUS; - - if( NULL != mCameraAdapter ) - { - adapterParams.set(TICameraParameters::KEY_AUTO_FOCUS_LOCK, android::CameraParameters::FALSE); - mCameraAdapter->setParameters(adapterParams); - mCameraAdapter->sendCommand(CameraAdapter::CAMERA_CANCEL_AUTOFOCUS); - mAppCallbackNotifier->flushEventQueue(); - } - - LOG_FUNCTION_NAME_EXIT; - return NO_ERROR; -} - -void CameraHal::setEventProvider(int32_t eventMask, MessageNotifier * eventNotifier) -{ - - LOG_FUNCTION_NAME; - - if ( NULL != mEventProvider ) - { - mEventProvider->disableEventNotification(CameraHalEvent::ALL_EVENTS); - delete mEventProvider; - mEventProvider = NULL; - } - - mEventProvider = new EventProvider(eventNotifier, this, eventCallbackRelay); - if ( NULL == mEventProvider ) - { - CAMHAL_LOGEA("Error in creating EventProvider"); - } - else - { - mEventProvider->enableEventNotification(eventMask); - } - - LOG_FUNCTION_NAME_EXIT; -} - -void CameraHal::eventCallbackRelay(CameraHalEvent* event) -{ - LOG_FUNCTION_NAME; - - CameraHal *appcbn = ( CameraHal * ) (event->mCookie); - appcbn->eventCallback(event ); - - LOG_FUNCTION_NAME_EXIT; -} - -void CameraHal::eventCallback(CameraHalEvent* event) -{ - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; -} - -status_t CameraHal::startImageBracketing() -{ - status_t ret = NO_ERROR; - CameraFrame frame; - CameraAdapter::BuffersDescriptor desc; - unsigned int max_queueable = 0; - - - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - gettimeofday(&mStartCapture, NULL); - -#endif - - LOG_FUNCTION_NAME; - - if(!previewEnabled() && !mDisplayPaused) - { - LOG_FUNCTION_NAME_EXIT; - return NO_INIT; - } - - if ( !mBracketingEnabled ) - { - return ret; - } - - if ( NO_ERROR == ret ) - { - mBracketingRunning = true; - } - - if ( (NO_ERROR == ret) && ( NULL != mCameraAdapter ) ) - { - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE, - ( int ) &frame, - ( mBracketRangeNegative + 1 )); - - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE returned error 0x%x", ret); - } - } - - if ( NO_ERROR == ret ) - { - if ( NULL != mAppCallbackNotifier.get() ) - { - mAppCallbackNotifier->setBurst(true); - } - } - - if ( NO_ERROR == ret ) - { - unsigned int bufferCount = mBracketRangeNegative + 1; - mParameters.getPictureSize(( int * ) &frame.mWidth, - ( int * ) &frame.mHeight); - - ret = allocImageBufs(frame.mWidth, - frame.mHeight, - frame.mLength, - mParameters.getPictureFormat(), - bufferCount, - &max_queueable); - mBracketRangeNegative = bufferCount - 1; - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("allocImageBufs returned error 0x%x", ret); - } - } - - if ( (NO_ERROR == ret) && ( NULL != mCameraAdapter ) ) - { - - desc.mBuffers = mImageBuffers; - desc.mOffsets = mImageOffsets; - desc.mFd = mImageFd; - desc.mLength = mImageLength; - desc.mCount = ( size_t ) ( mBracketRangeNegative + 1 ); - desc.mMaxQueueable = ( size_t) max_queueable; - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_USE_BUFFERS_IMAGE_CAPTURE, - ( int ) &desc); - - if ( NO_ERROR == ret ) - { - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - //pass capture timestamp along with the camera adapter command - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_START_BRACKET_CAPTURE, ( mBracketRangePositive + 1 ), (int) &mStartCapture); - -#else - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_START_BRACKET_CAPTURE, ( mBracketRangePositive + 1 )); - -#endif - - } - } - - return ret; -} - -status_t CameraHal::stopImageBracketing() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if( !previewEnabled() ) - { - return NO_INIT; - } - - mBracketingRunning = false; - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_BRACKET_CAPTURE); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -/** - @brief Take a picture. - - @param none - @return NO_ERROR If able to switch to image capture - @todo Define error codes if unable to switch to image capture - - */ -status_t CameraHal::takePicture(const char *params) -{ - android::AutoMutex lock(mLock); - return __takePicture(params); -} - -/** - @brief Internal function for getting a captured image. - shared by takePicture and reprocess. - @param none - @return NO_ERROR If able to switch to image capture - @todo Define error codes if unable to switch to image capture - - */ -status_t CameraHal::__takePicture(const char *params) -{ - // cancel AF state if needed (before any operation and mutex lock) - if (mCameraAdapter->getState() == CameraAdapter::AF_STATE) { - cancelAutoFocus(); - } - - status_t ret = NO_ERROR; - CameraFrame frame; - CameraAdapter::BuffersDescriptor desc; - int burst = -1; - const char *valstr = NULL; - unsigned int bufferCount = 1; - unsigned int max_queueable = 0; - unsigned int rawBufferCount = 1; - bool isCPCamMode = false; - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - gettimeofday(&mStartCapture, NULL); - -#endif - - LOG_FUNCTION_NAME; - - if(!previewEnabled() && !mDisplayPaused) - { - LOG_FUNCTION_NAME_EXIT; - CAMHAL_LOGEA("Preview not started..."); - return NO_INIT; - } - - valstr = mParameters.get(TICameraParameters::KEY_CAP_MODE); - - isCPCamMode = valstr && !strcmp(valstr, TICameraParameters::CP_CAM_MODE); - - // return error if we are already capturing - // however, we can queue a capture when in cpcam mode - if ( ((mCameraAdapter->getState() == CameraAdapter::CAPTURE_STATE && - mCameraAdapter->getNextState() != CameraAdapter::PREVIEW_STATE) || - (mCameraAdapter->getState() == CameraAdapter::VIDEO_CAPTURE_STATE && - mCameraAdapter->getNextState() != CameraAdapter::VIDEO_STATE)) && - !isCPCamMode) { - CAMHAL_LOGEA("Already capturing an image..."); - return NO_INIT; - } - - // we only support video snapshot if we are in video mode (recording hint is set) - if ( (mCameraAdapter->getState() == CameraAdapter::VIDEO_STATE) && - (valstr && strcmp(valstr, TICameraParameters::VIDEO_MODE)) ) { - CAMHAL_LOGEA("Trying to capture while recording without recording hint set..."); - return INVALID_OPERATION; - } - -#ifdef OMAP_ENHANCEMENT_CPCAM - // check if camera application is using shots parameters - // api. parameters set here override anything set using setParameters - // TODO(XXX): Just going to use legacy TI parameters for now. Need - // add new APIs in CameraHal to utilize ShotParameters later, so - // we don't have to parse through the whole set of parameters - // in camera adapter - if (strlen(params) > 0) { - android::ShotParameters shotParams; - const char *valStr; - const char *valExpComp, *valExpGain; - int valNum; - - android::String8 shotParams8(params); - - shotParams.unflatten(shotParams8); - mParameters.remove(TICameraParameters::KEY_EXP_GAIN_BRACKETING_RANGE); - mParameters.remove(TICameraParameters::KEY_EXP_BRACKETING_RANGE); - - valExpGain = shotParams.get(android::ShotParameters::KEY_EXP_GAIN_PAIRS); - valExpComp = shotParams.get(android::ShotParameters::KEY_EXP_COMPENSATION); - if (NULL != valExpComp) { - mParameters.set(TICameraParameters::KEY_EXP_BRACKETING_RANGE, valExpComp); - } else if (NULL != valExpGain) { - mParameters.set(TICameraParameters::KEY_EXP_GAIN_BRACKETING_RANGE, valExpGain); - } - - valNum = shotParams.getInt(android::ShotParameters::KEY_BURST); - if (valNum >= 0) { - mParameters.set(TICameraParameters::KEY_BURST, valNum); - burst = valNum; - } - - valStr = shotParams.get(android::ShotParameters::KEY_FLUSH_CONFIG); - if (valStr!= NULL) { - if ( 0 == strcmp(valStr, android::ShotParameters::TRUE) ) { - mParameters.set(TICameraParameters::KEY_FLUSH_SHOT_CONFIG_QUEUE, - android::CameraParameters::TRUE); - } else if ( 0 == strcmp(valStr, android::ShotParameters::FALSE) ) { - mParameters.set(TICameraParameters::KEY_FLUSH_SHOT_CONFIG_QUEUE, - android::CameraParameters::FALSE); - } - } - - mCameraAdapter->setParameters(mParameters); - } else -#endif - { - // TODO(XXX): Should probably reset burst and bracketing params - // when we remove legacy TI parameters implementation - } - - // if we are already in the middle of a capture...then we just need - // setParameters and start image capture to queue more shots - if (((mCameraAdapter->getState() & CameraAdapter::CAPTURE_STATE) == - CameraAdapter::CAPTURE_STATE) && - (mCameraAdapter->getNextState() != CameraAdapter::PREVIEW_STATE)) { -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - //pass capture timestamp along with the camera adapter command - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_START_IMAGE_CAPTURE, - (int) &mStartCapture); -#else - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_START_IMAGE_CAPTURE); -#endif - return ret; - } - - if ( !mBracketingRunning ) - { - // if application didn't set burst through ShotParameters - // then query from TICameraParameters - if ((burst == -1) && (NO_ERROR == ret)) { - burst = mParameters.getInt(TICameraParameters::KEY_BURST); - } - - //Allocate all buffers only in burst capture case - if ( burst > 0 ) { - // For CPCam mode...allocate for worst case burst - bufferCount = isCPCamMode || (burst > CameraHal::NO_BUFFERS_IMAGE_CAPTURE) ? - CameraHal::NO_BUFFERS_IMAGE_CAPTURE : burst; - - if (mBufferSourceAdapter_Out.get()) { - // TODO(XXX): Temporarily increase number of buffers we can allocate from ANW - // until faux-NPA mode is implemented - bufferCount = NO_BUFFERS_IMAGE_CAPTURE_SYSTEM_HEAP; - } - - if ( NULL != mAppCallbackNotifier.get() ) { - mAppCallbackNotifier->setBurst(true); - } - } else if ( mBracketingEnabled ) { - bufferCount = mBracketRangeNegative + 1; - if ( NULL != mAppCallbackNotifier.get() ) { - mAppCallbackNotifier->setBurst(false); - } - } else { - if ( NULL != mAppCallbackNotifier.get() ) { - mAppCallbackNotifier->setBurst(false); - } - } - - // pause preview during normal image capture - // do not pause preview if recording (video state) - if ( (NO_ERROR == ret) && (NULL != mDisplayAdapter.get()) ) { - if (mCameraAdapter->getState() != CameraAdapter::VIDEO_STATE) { - mDisplayPaused = true; - mPreviewEnabled = false; - ret = mDisplayAdapter->pauseDisplay(mDisplayPaused); - // since preview is paused we should stop sending preview frames too - if(mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME) { - mAppCallbackNotifier->disableMsgType (CAMERA_MSG_PREVIEW_FRAME); - } - } - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - mDisplayAdapter->setSnapshotTimeRef(&mStartCapture); -#endif - } - - // if we taking video snapshot... - if ((NO_ERROR == ret) && (mCameraAdapter->getState() == CameraAdapter::VIDEO_STATE)) { - // enable post view frames if not already enabled so we can internally - // save snapshot frames for generating thumbnail - if((mMsgEnabled & CAMERA_MSG_POSTVIEW_FRAME) == 0) { - mAppCallbackNotifier->enableMsgType(CAMERA_MSG_POSTVIEW_FRAME); - } - } - - if ( (NO_ERROR == ret) && (NULL != mCameraAdapter) ) - { - if ( NO_ERROR == ret ) - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE, - ( int ) &frame, - bufferCount); - - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE returned error 0x%x", ret); - } - } - - if ( NO_ERROR == ret ) - { - ret = allocImageBufs(frame.mAlignment, - frame.mHeight, - frame.mLength, - mParameters.getPictureFormat(), - bufferCount, - &max_queueable); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("allocImageBufs returned error 0x%x", ret); - } - } - - if ( (NO_ERROR == ret) && ( NULL != mCameraAdapter ) ) - { - desc.mBuffers = mImageBuffers; - desc.mOffsets = mImageOffsets; - desc.mFd = mImageFd; - desc.mLength = mImageLength; - desc.mCount = ( size_t ) bufferCount; - desc.mMaxQueueable = ( size_t ) max_queueable; - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_USE_BUFFERS_IMAGE_CAPTURE, - ( int ) &desc); - } - if (mRawCapture) { - if ( NO_ERROR == ret ) { - CAMHAL_LOGDB("Raw capture buffers setup - %s", mParameters.getPictureFormat()); - ret = allocRawBufs(mParameters.getInt(TICameraParameters::RAW_WIDTH), - mParameters.getInt(TICameraParameters::RAW_HEIGHT), - android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB, - rawBufferCount); - - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("allocRawBufs (for RAW capture) returned error 0x%x", ret); - } - } - - if ((NO_ERROR == ret) && ( NULL != mCameraAdapter )) { - desc.mBuffers = mVideoBuffers; - desc.mOffsets = mVideoOffsets; - desc.mFd = mVideoFd; - desc.mLength = mVideoLength; - desc.mCount = ( size_t ) rawBufferCount; - desc.mMaxQueueable = ( size_t ) rawBufferCount; - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_USE_BUFFERS_VIDEO_CAPTURE, - ( int ) &desc); - } - } - } - - if ((ret == NO_ERROR) && mBufferSourceAdapter_Out.get()) { - mBufferSourceAdapter_Out->enableDisplay(0, 0, NULL); - } - - if ((NO_ERROR == ret) && (NULL != mCameraAdapter)) { - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - //pass capture timestamp along with the camera adapter command - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_START_IMAGE_CAPTURE, (int) &mStartCapture); - -#else - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_START_IMAGE_CAPTURE); - -#endif - - } - - return ret; -} - -/** - @brief Cancel a picture that was started with takePicture. - - Calling this method when no picture is being taken is a no-op. - - @param none - @return NO_ERROR If cancel succeeded. Cancel can succeed if image callback is not sent - @todo Define error codes - - */ -status_t CameraHal::cancelPicture( ) -{ - LOG_FUNCTION_NAME; - status_t ret = NO_ERROR; - - ret = signalEndImageCapture(); - return NO_ERROR; -} - -/** - @brief Return the camera parameters. - - @param none - @return Currently configured camera parameters - - */ -char* CameraHal::getParameters() -{ - android::String8 params_str8; - char* params_string; - const char * valstr = NULL; - - LOG_FUNCTION_NAME; - - if( NULL != mCameraAdapter ) - { - mCameraAdapter->getParameters(mParameters); - } - -#ifndef OMAP_TUNA - if ( (valstr = mParameters.get(TICameraParameters::KEY_S3D_CAP_FRAME_LAYOUT)) != NULL ) { - if (!strcmp(TICameraParameters::S3D_TB_FULL, valstr)) { - mParameters.set(android::CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, mParameters.get(TICameraParameters::KEY_SUPPORTED_PICTURE_TOPBOTTOM_SIZES)); - } else if (!strcmp(TICameraParameters::S3D_SS_FULL, valstr)) { - mParameters.set(android::CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, mParameters.get(TICameraParameters::KEY_SUPPORTED_PICTURE_SIDEBYSIDE_SIZES)); - } else if ((!strcmp(TICameraParameters::S3D_TB_SUBSAMPLED, valstr)) - || (!strcmp(TICameraParameters::S3D_SS_SUBSAMPLED, valstr))) { - mParameters.set(android::CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, mParameters.get(TICameraParameters::KEY_SUPPORTED_PICTURE_SUBSAMPLED_SIZES)); - } - } - - if ( (valstr = mParameters.get(TICameraParameters::KEY_S3D_PRV_FRAME_LAYOUT)) != NULL ) { - if (!strcmp(TICameraParameters::S3D_TB_FULL, valstr)) { - mParameters.set(android::CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, mParameters.get(TICameraParameters::KEY_SUPPORTED_PREVIEW_TOPBOTTOM_SIZES)); - } else if (!strcmp(TICameraParameters::S3D_SS_FULL, valstr)) { - mParameters.set(android::CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, mParameters.get(TICameraParameters::KEY_SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES)); - } else if ((!strcmp(TICameraParameters::S3D_TB_SUBSAMPLED, valstr)) - || (!strcmp(TICameraParameters::S3D_SS_SUBSAMPLED, valstr))) { - mParameters.set(android::CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, mParameters.get(TICameraParameters::KEY_SUPPORTED_PREVIEW_SUBSAMPLED_SIZES)); - } - } -#endif - - android::CameraParameters mParams = mParameters; - - // Handle RECORDING_HINT to Set/Reset Video Mode Parameters - valstr = mParameters.get(android::CameraParameters::KEY_RECORDING_HINT); - if(valstr != NULL) - { - if(strcmp(valstr, android::CameraParameters::TRUE) == 0) - { - //HACK FOR MMS MODE - resetPreviewRes(&mParams); - } - } - - // do not send internal parameters to upper layers - mParams.remove(TICameraParameters::KEY_RECORDING_HINT); - mParams.remove(TICameraParameters::KEY_AUTO_FOCUS_LOCK); - - params_str8 = mParams.flatten(); - - // camera service frees this string... - params_string = (char*) malloc(sizeof(char) * (params_str8.length()+1)); - strcpy(params_string, params_str8.string()); - - LOG_FUNCTION_NAME_EXIT; - - ///Return the current set of parameters - - return params_string; -} - - -#ifdef OMAP_ENHANCEMENT_CPCAM -/** - @brief Starts reprocessing operation. - */ -status_t CameraHal::reprocess(const char *params) -{ - status_t ret = NO_ERROR; - int bufferCount = 0; - CameraAdapter::BuffersDescriptor desc; - CameraBuffer *reprocBuffers = NULL; - android::ShotParameters shotParams; - - android::AutoMutex lock(mLock); - - LOG_FUNCTION_NAME; - - // 1. Get buffers - if (mBufferSourceAdapter_In.get()) { - reprocBuffers = mBufferSourceAdapter_In->getBufferList(&bufferCount); - } - - if (!reprocBuffers) { - CAMHAL_LOGE("Error: couldn't get input buffers for reprocess()"); - goto exit; - } - - // 2. Get buffer information and parse parameters - { - shotParams.setBurst(bufferCount); - } - - // 3. Give buffer to camera adapter - desc.mBuffers = reprocBuffers; - desc.mOffsets = 0; - desc.mFd = 0; - desc.mLength = 0; - desc.mCount = (size_t) bufferCount; - desc.mMaxQueueable = (size_t) bufferCount; - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_USE_BUFFERS_REPROCESS, (int) &desc); - if (ret != NO_ERROR) { - CAMHAL_LOGE("Error calling camera use buffers"); - goto exit; - } - - // 4. Start reprocessing - ret = mBufferSourceAdapter_In->enableDisplay(0, 0, NULL); - if (ret != NO_ERROR) { - CAMHAL_LOGE("Error enabling tap in point"); - goto exit; - } - - // 5. Start capturing - ret = __takePicture(shotParams.flatten().string()); - - exit: - return ret; -} - -/** - @brief Cancels current reprocessing operation - - */ -status_t CameraHal::cancel_reprocess( ) -{ - LOG_FUNCTION_NAME; - status_t ret = NO_ERROR; - - ret = signalEndImageCapture(); - return NO_ERROR; -} -#endif - - -void CameraHal::putParameters(char *parms) -{ - free(parms); -} - -/** - @brief Send command to camera driver. - - @param none - @return NO_ERROR If the command succeeds - @todo Define the error codes that this function can return - - */ -status_t CameraHal::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( ( NO_ERROR == ret ) && ( NULL == mCameraAdapter ) ) - { - CAMHAL_LOGEA("No CameraAdapter instance"); - return -EINVAL; - } - - /////////////////////////////////////////////////////// - // Following commands do NOT need preview to be started - /////////////////////////////////////////////////////// - - switch ( cmd ) { -#ifdef ANDROID_API_JB_OR_LATER - case CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG: - { - const bool enable = static_cast(arg1); - android::AutoMutex lock(mLock); - if ( enable ) { - mMsgEnabled |= CAMERA_MSG_FOCUS_MOVE; - } else { - mMsgEnabled &= ~CAMERA_MSG_FOCUS_MOVE; - } - } - return OK; -#endif - } - - if ( ret == OK && !previewEnabled() -#ifdef OMAP_ENHANCEMENT_VTC - && (cmd != CAMERA_CMD_PREVIEW_INITIALIZATION) -#endif - ) { - CAMHAL_LOGEA("Preview is not running"); - ret = -EINVAL; - } - - /////////////////////////////////////////////////////// - // Following commands NEED preview to be started - /////////////////////////////////////////////////////// - - if ( NO_ERROR == ret ) - { - switch(cmd) - { - case CAMERA_CMD_START_SMOOTH_ZOOM: - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_START_SMOOTH_ZOOM, arg1); - - break; - case CAMERA_CMD_STOP_SMOOTH_ZOOM: - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_SMOOTH_ZOOM); - break; - - case CAMERA_CMD_START_FACE_DETECTION: - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_START_FD); - - break; - - case CAMERA_CMD_STOP_FACE_DETECTION: - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_FD); - - break; - -#ifdef OMAP_ENHANCEMENT_VTC - case CAMERA_CMD_PREVIEW_DEINITIALIZATION: - if(mDisplayAdapter.get() != NULL) { - ///Stop the buffer display first - mDisplayAdapter->disableDisplay(); - } - - if(mAppCallbackNotifier.get() != NULL) { - //Stop the callback sending - mAppCallbackNotifier->stop(); - mAppCallbackNotifier->flushAndReturnFrames(); - mAppCallbackNotifier->stopPreviewCallbacks(); - } - - ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_DESTROY_TUNNEL); - mTunnelSetup = false; - - break; - - case CAMERA_CMD_PREVIEW_INITIALIZATION: - ret = cameraPreviewInitialization(); - - break; -#endif - - default: - break; - }; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -/** - @brief Release the hardware resources owned by this object. - - Note that this is *not* done in the destructor. - - @param none - @return none - - */ -void CameraHal::release() -{ - LOG_FUNCTION_NAME; - ///@todo Investigate on how release is used by CameraService. Vaguely remember that this is called - ///just before CameraHal object destruction - deinitialize(); - LOG_FUNCTION_NAME_EXIT; -} - - -/** - @brief Dump state of the camera hardware - - @param[in] fd File descriptor - @param[in] args Arguments - @return NO_ERROR Dump succeeded - @todo Error codes for dump fail - - */ -status_t CameraHal::dump(int fd) const -{ - LOG_FUNCTION_NAME; - ///Implement this method when the h/w dump function is supported on Ducati side - return NO_ERROR; -} - -/*-------------Camera Hal Interface Method definitions ENDS here--------------------*/ - - - - -/*-------------Camera Hal Internal Method definitions STARTS here--------------------*/ - -/** - @brief Constructor of CameraHal - - Member variables are initialized here. No allocations should be done here as we - don't use c++ exceptions in the code. - - */ -CameraHal::CameraHal(int cameraId) -{ - LOG_FUNCTION_NAME; - - ///Initialize all the member variables to their defaults - mPreviewEnabled = false; - mPreviewBuffers = NULL; - mImageBuffers = NULL; - mBufProvider = NULL; - mPreviewStartInProgress = false; - mVideoBuffers = NULL; - mVideoBufProvider = NULL; - mRecordingEnabled = false; - mDisplayPaused = false; - mSetPreviewWindowCalled = false; - mMsgEnabled = 0; - mAppCallbackNotifier = NULL; - mMemoryManager = NULL; - mCameraAdapter = NULL; - mBracketingEnabled = false; - mBracketingRunning = false; - mEventProvider = NULL; - mBracketRangePositive = 1; - mBracketRangeNegative = 1; - mMaxZoomSupported = 0; - mShutterEnabled = true; - mMeasurementEnabled = false; - mPreviewDataBuffers = NULL; - mCameraProperties = NULL; - mCurrentTime = 0; - mFalsePreview = 0; - mImageOffsets = NULL; - mImageLength = 0; - mImageFd = 0; - mVideoOffsets = NULL; - mVideoFd = 0; - mVideoLength = 0; - mPreviewDataOffsets = NULL; - mPreviewDataFd = 0; - mPreviewDataLength = 0; - mPreviewFd = 0; - mPreviewWidth = 0; - mPreviewHeight = 0; - mPreviewLength = 0; - mPreviewOffsets = NULL; - mPreviewRunning = 0; - mPreviewStateOld = 0; - mRecordingEnabled = 0; - mRecordEnabled = 0; - mSensorListener = NULL; - mVideoWidth = 0; - mVideoHeight = 0; -#ifdef OMAP_ENHANCEMENT_VTC - mVTCUseCase = false; - mTunnelSetup = false; -#endif - mPreviewInitializationDone = false; - -#ifdef OMAP_ENHANCEMENT_CPCAM - mExtendedPreviewStreamOps = 0; -#endif - - //These values depends on the sensor characteristics - - mRawCapture = false; - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - //Initialize the CameraHAL constructor timestamp, which is used in the - // PPM() method as time reference if the user does not supply one. - gettimeofday(&ppm_start, NULL); - -#endif - - mCameraIndex = cameraId; - - LOG_FUNCTION_NAME_EXIT; -} - -/** - @brief Destructor of CameraHal - - This function simply calls deinitialize() to free up memory allocate during construct - phase - */ -CameraHal::~CameraHal() -{ - LOG_FUNCTION_NAME; - - ///Call de-initialize here once more - it is the last chance for us to relinquish all the h/w and s/w resources - deinitialize(); - - if ( NULL != mEventProvider ) - { - mEventProvider->disableEventNotification(CameraHalEvent::ALL_EVENTS); - delete mEventProvider; - mEventProvider = NULL; - } - - /// Free the callback notifier - mAppCallbackNotifier.clear(); - - /// Free the display adapter - mDisplayAdapter.clear(); - - if ( NULL != mCameraAdapter ) { - int strongCount = mCameraAdapter->getStrongCount(); - - mCameraAdapter->decStrong(mCameraAdapter); - - mCameraAdapter = NULL; - } - - freeImageBufs(); - freeRawBufs(); - - /// Free the memory manager - mMemoryManager.clear(); - - LOG_FUNCTION_NAME_EXIT; -} - -/** - @brief Initialize the Camera HAL - - Creates CameraAdapter, AppCallbackNotifier, DisplayAdapter and MemoryManager - - @param None - @return NO_ERROR - On success - NO_MEMORY - On failure to allocate memory for any of the objects - @remarks Camera Hal internal function - - */ - -status_t CameraHal::initialize(CameraProperties::Properties* properties) -{ - LOG_FUNCTION_NAME; - - int sensor_index = 0; - const char* sensor_name = NULL; - - ///Initialize the event mask used for registering an event provider for AppCallbackNotifier - ///Currently, registering all events as to be coming from CameraAdapter - int32_t eventMask = CameraHalEvent::ALL_EVENTS; - - // Get my camera properties - mCameraProperties = properties; - - if(!mCameraProperties) - { - goto fail_loop; - } - - // Dump the properties of this Camera - // will only print if DEBUG macro is defined - mCameraProperties->dump(); - - if (strcmp(CameraProperties::DEFAULT_VALUE, mCameraProperties->get(CameraProperties::CAMERA_SENSOR_INDEX)) != 0 ) - { - sensor_index = atoi(mCameraProperties->get(CameraProperties::CAMERA_SENSOR_INDEX)); - } - - if (strcmp(CameraProperties::DEFAULT_VALUE, mCameraProperties->get(CameraProperties::CAMERA_NAME)) != 0 ) { - sensor_name = mCameraProperties->get(CameraProperties::CAMERA_NAME); - } - CAMHAL_LOGDB("Sensor index= %d; Sensor name= %s", sensor_index, sensor_name); - - if (strcmp(sensor_name, V4L_CAMERA_NAME_USB) == 0) { -#ifdef V4L_CAMERA_ADAPTER - mCameraAdapter = V4LCameraAdapter_Factory(sensor_index); -#endif - } - else { -#ifdef OMX_CAMERA_ADAPTER - mCameraAdapter = OMXCameraAdapter_Factory(sensor_index); -#endif - } - - if ( ( NULL == mCameraAdapter ) || (mCameraAdapter->initialize(properties)!=NO_ERROR)) - { - CAMHAL_LOGEA("Unable to create or initialize CameraAdapter"); - mCameraAdapter = NULL; - goto fail_loop; - } - - mCameraAdapter->incStrong(mCameraAdapter); - mCameraAdapter->registerImageReleaseCallback(releaseImageBuffers, (void *) this); - mCameraAdapter->registerEndCaptureCallback(endImageCapture, (void *)this); - - if(!mAppCallbackNotifier.get()) - { - /// Create the callback notifier - mAppCallbackNotifier = new AppCallbackNotifier(); - if( ( NULL == mAppCallbackNotifier.get() ) || ( mAppCallbackNotifier->initialize() != NO_ERROR)) - { - CAMHAL_LOGEA("Unable to create or initialize AppCallbackNotifier"); - goto fail_loop; - } - } - - if(!mMemoryManager.get()) - { - /// Create Memory Manager - mMemoryManager = new MemoryManager(); - if( ( NULL == mMemoryManager.get() ) || ( mMemoryManager->initialize() != NO_ERROR)) - { - CAMHAL_LOGEA("Unable to create or initialize MemoryManager"); - goto fail_loop; - } - } - - ///Setup the class dependencies... - - ///AppCallbackNotifier has to know where to get the Camera frames and the events like auto focus lock etc from. - ///CameraAdapter is the one which provides those events - ///Set it as the frame and event providers for AppCallbackNotifier - ///@remarks setEventProvider API takes in a bit mask of events for registering a provider for the different events - /// That way, if events can come from DisplayAdapter in future, we will be able to add it as provider - /// for any event - mAppCallbackNotifier->setEventProvider(eventMask, mCameraAdapter); - mAppCallbackNotifier->setFrameProvider(mCameraAdapter); - - ///Any dynamic errors that happen during the camera use case has to be propagated back to the application - ///via CAMERA_MSG_ERROR. AppCallbackNotifier is the class that notifies such errors to the application - ///Set it as the error handler for CameraAdapter - mCameraAdapter->setErrorHandler(mAppCallbackNotifier.get()); - - ///Start the callback notifier - if(mAppCallbackNotifier->start() != NO_ERROR) - { - CAMHAL_LOGEA("Couldn't start AppCallbackNotifier"); - goto fail_loop; - } - - CAMHAL_LOGDA("Started AppCallbackNotifier.."); - mAppCallbackNotifier->setMeasurements(mMeasurementEnabled); - - ///Initialize default parameters - initDefaultParameters(); - - - if ( setParameters(mParameters) != NO_ERROR ) - { - CAMHAL_LOGEA("Failed to set default parameters?!"); - } - - // register for sensor events - mSensorListener = new SensorListener(); - if (mSensorListener.get()) { - if (mSensorListener->initialize() == NO_ERROR) { - mSensorListener->setCallbacks(orientation_cb, this); - mSensorListener->enableSensor(SensorListener::SENSOR_ORIENTATION); - } else { - CAMHAL_LOGEA("Error initializing SensorListener. not fatal, continuing"); - mSensorListener.clear(); - mSensorListener = NULL; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; - - fail_loop: - - ///Free up the resources because we failed somewhere up - deinitialize(); - LOG_FUNCTION_NAME_EXIT; - - return NO_MEMORY; - -} - -bool CameraHal::isResolutionValid(unsigned int width, unsigned int height, const char *supportedResolutions) -{ - bool ret = false; - status_t status = NO_ERROR; - char tmpBuffer[MAX_PROP_VALUE_LENGTH]; - char *pos = NULL; - - LOG_FUNCTION_NAME; - - if (NULL == supportedResolutions) { - CAMHAL_LOGEA("Invalid supported resolutions string"); - goto exit; - } - - status = snprintf(tmpBuffer, MAX_PROP_VALUE_LENGTH - 1, "%dx%d", width, height); - if (0 > status) { - CAMHAL_LOGEA("Error encountered while generating validation string"); - goto exit; - } - - ret = isParameterValid(tmpBuffer, supportedResolutions); - -exit: - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -bool CameraHal::isFpsRangeValid(int fpsMin, int fpsMax, const char *supportedFpsRanges) -{ - bool ret = false; - char supported[MAX_PROP_VALUE_LENGTH]; - char *pos; - int suppFpsRangeArray[2]; - int i = 0; - - LOG_FUNCTION_NAME; - - if ( NULL == supportedFpsRanges ) { - CAMHAL_LOGEA("Invalid supported FPS ranges string"); - return false; - } - - if (fpsMin <= 0 || fpsMax <= 0 || fpsMin > fpsMax) { - return false; - } - - strncpy(supported, supportedFpsRanges, MAX_PROP_VALUE_LENGTH); - pos = strtok(supported, " (,)"); - while (pos != NULL) { - suppFpsRangeArray[i] = atoi(pos); - if (i++) { - if (fpsMin >= suppFpsRangeArray[0] && fpsMax <= suppFpsRangeArray[1]) { - ret = true; - break; - } - i = 0; - } - pos = strtok(NULL, " (,)"); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -bool CameraHal::isParameterValid(const char *param, const char *supportedParams) -{ - bool ret = false; - char *pos; - char supported[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - - if (NULL == supportedParams) { - CAMHAL_LOGEA("Invalid supported parameters string"); - goto exit; - } - - if (NULL == param) { - CAMHAL_LOGEA("Invalid parameter string"); - goto exit; - } - - strncpy(supported, supportedParams, MAX_PROP_VALUE_LENGTH - 1); - - pos = strtok(supported, ","); - while (pos != NULL) { - if (!strcmp(pos, param)) { - ret = true; - break; - } - pos = strtok(NULL, ","); - } - -exit: - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -bool CameraHal::isParameterValid(int param, const char *supportedParams) -{ - bool ret = false; - status_t status; - char tmpBuffer[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - - if (NULL == supportedParams) { - CAMHAL_LOGEA("Invalid supported parameters string"); - goto exit; - } - - status = snprintf(tmpBuffer, MAX_PROP_VALUE_LENGTH - 1, "%d", param); - if (0 > status) { - CAMHAL_LOGEA("Error encountered while generating validation string"); - goto exit; - } - - ret = isParameterValid(tmpBuffer, supportedParams); - -exit: - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t CameraHal::doesSetParameterNeedUpdate(const char* new_param, const char* old_param, bool& update) { - if (!new_param || !old_param) { - return -EINVAL; - } - - // if params mismatch we should update parameters for camera adapter - if ((strcmp(new_param, old_param) != 0)) { - update = true; - } - - return NO_ERROR; -} - -status_t CameraHal::parseResolution(const char *resStr, int &width, int &height) -{ - status_t ret = NO_ERROR; - char *ctx, *pWidth, *pHeight; - const char *sep = "x"; - - LOG_FUNCTION_NAME; - - if ( NULL == resStr ) - { - return -EINVAL; - } - - //This fixes "Invalid input resolution" - char *resStr_copy = (char *)malloc(strlen(resStr) + 1); - if ( NULL != resStr_copy ) - { - strcpy(resStr_copy, resStr); - pWidth = strtok_r(resStr_copy, sep, &ctx); - - if ( NULL != pWidth ) - { - width = atoi(pWidth); - } - else - { - CAMHAL_LOGEB("Invalid input resolution %s", resStr); - ret = -EINVAL; - } - } - - if ( NO_ERROR == ret ) - { - pHeight = strtok_r(NULL, sep, &ctx); - - if ( NULL != pHeight ) - { - height = atoi(pHeight); - } - else - { - CAMHAL_LOGEB("Invalid input resolution %s", resStr); - ret = -EINVAL; - } - } - - free(resStr_copy); - resStr_copy = NULL; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -void CameraHal::insertSupportedParams() -{ - LOG_FUNCTION_NAME; - - android::CameraParameters &p = mParameters; - - ///Set the name of the camera - p.set(TICameraParameters::KEY_CAMERA_NAME, mCameraProperties->get(CameraProperties::CAMERA_NAME)); - - mMaxZoomSupported = atoi(mCameraProperties->get(CameraProperties::SUPPORTED_ZOOM_STAGES)); - - p.set(android::CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, mCameraProperties->get(CameraProperties::SUPPORTED_PICTURE_SIZES)); - p.set(android::CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS, mCameraProperties->get(CameraProperties::SUPPORTED_PICTURE_FORMATS)); - p.set(android::CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_SIZES)); - p.set(android::CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FORMATS)); -#ifndef OMAP_TUNA - p.set(TICameraParameters::KEY_SUPPORTED_PICTURE_SUBSAMPLED_SIZES, mCameraProperties->get(CameraProperties::SUPPORTED_PICTURE_SUBSAMPLED_SIZES)); - p.set(TICameraParameters::KEY_SUPPORTED_PICTURE_SIDEBYSIDE_SIZES, mCameraProperties->get(CameraProperties::SUPPORTED_PICTURE_SIDEBYSIDE_SIZES)); - p.set(TICameraParameters::KEY_SUPPORTED_PICTURE_TOPBOTTOM_SIZES, mCameraProperties->get(CameraProperties::SUPPORTED_PICTURE_TOPBOTTOM_SIZES)); - p.set(TICameraParameters::KEY_SUPPORTED_PREVIEW_SUBSAMPLED_SIZES, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_SUBSAMPLED_SIZES)); - p.set(TICameraParameters::KEY_SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES)); - p.set(TICameraParameters::KEY_SUPPORTED_PREVIEW_TOPBOTTOM_SIZES, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_TOPBOTTOM_SIZES)); -#endif - p.set(android::CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES)); - p.set(TICameraParameters::KEY_FRAMERATES_EXT_SUPPORTED, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES_EXT)); - p.set(android::CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, mCameraProperties->get(CameraProperties::FRAMERATE_RANGE_SUPPORTED)); - p.set(TICameraParameters::KEY_FRAMERATE_RANGES_EXT_SUPPORTED, mCameraProperties->get(CameraProperties::FRAMERATE_RANGE_EXT_SUPPORTED)); - p.set(android::CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, mCameraProperties->get(CameraProperties::SUPPORTED_THUMBNAIL_SIZES)); - p.set(android::CameraParameters::KEY_SUPPORTED_WHITE_BALANCE, mCameraProperties->get(CameraProperties::SUPPORTED_WHITE_BALANCE)); - p.set(android::CameraParameters::KEY_SUPPORTED_EFFECTS, mCameraProperties->get(CameraProperties::SUPPORTED_EFFECTS)); - p.set(android::CameraParameters::KEY_SUPPORTED_SCENE_MODES, mCameraProperties->get(CameraProperties::SUPPORTED_SCENE_MODES)); - p.set(android::CameraParameters::KEY_SUPPORTED_FLASH_MODES, mCameraProperties->get(CameraProperties::SUPPORTED_FLASH_MODES)); - p.set(android::CameraParameters::KEY_SUPPORTED_FOCUS_MODES, mCameraProperties->get(CameraProperties::SUPPORTED_FOCUS_MODES)); - p.set(android::CameraParameters::KEY_SUPPORTED_ANTIBANDING, mCameraProperties->get(CameraProperties::SUPPORTED_ANTIBANDING)); - p.set(android::CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, mCameraProperties->get(CameraProperties::SUPPORTED_EV_MAX)); - p.set(android::CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, mCameraProperties->get(CameraProperties::SUPPORTED_EV_MIN)); - p.set(android::CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, mCameraProperties->get(CameraProperties::SUPPORTED_EV_STEP)); - p.set(TICameraParameters::KEY_SUPPORTED_EXPOSURE, mCameraProperties->get(CameraProperties::SUPPORTED_EXPOSURE_MODES)); - p.set(TICameraParameters::KEY_SUPPORTED_MANUAL_EXPOSURE_MIN, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MIN)); - p.set(TICameraParameters::KEY_SUPPORTED_MANUAL_EXPOSURE_MAX, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MAX)); - p.set(TICameraParameters::KEY_SUPPORTED_MANUAL_EXPOSURE_STEP, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_STEP)); - p.set(TICameraParameters::KEY_SUPPORTED_MANUAL_GAIN_ISO_MIN, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MIN)); - p.set(TICameraParameters::KEY_SUPPORTED_MANUAL_GAIN_ISO_MAX, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MAX)); - p.set(TICameraParameters::KEY_SUPPORTED_MANUAL_GAIN_ISO_STEP, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_STEP)); - p.set(TICameraParameters::KEY_SUPPORTED_ISO_VALUES, mCameraProperties->get(CameraProperties::SUPPORTED_ISO_VALUES)); - p.set(android::CameraParameters::KEY_ZOOM_RATIOS, mCameraProperties->get(CameraProperties::SUPPORTED_ZOOM_RATIOS)); - p.set(android::CameraParameters::KEY_MAX_ZOOM, mCameraProperties->get(CameraProperties::SUPPORTED_ZOOM_STAGES)); - p.set(android::CameraParameters::KEY_ZOOM_SUPPORTED, mCameraProperties->get(CameraProperties::ZOOM_SUPPORTED)); - p.set(android::CameraParameters::KEY_SMOOTH_ZOOM_SUPPORTED, mCameraProperties->get(CameraProperties::SMOOTH_ZOOM_SUPPORTED)); - p.set(TICameraParameters::KEY_SUPPORTED_IPP, mCameraProperties->get(CameraProperties::SUPPORTED_IPP_MODES)); -#ifndef OMAP_TUNA - p.set(TICameraParameters::KEY_S3D_PRV_FRAME_LAYOUT_VALUES, mCameraProperties->get(CameraProperties::S3D_PRV_FRAME_LAYOUT_VALUES)); - p.set(TICameraParameters::KEY_S3D_CAP_FRAME_LAYOUT_VALUES, mCameraProperties->get(CameraProperties::S3D_CAP_FRAME_LAYOUT_VALUES)); -#endif - p.set(TICameraParameters::KEY_AUTOCONVERGENCE_MODE_VALUES, mCameraProperties->get(CameraProperties::AUTOCONVERGENCE_MODE_VALUES)); - p.set(TICameraParameters::KEY_SUPPORTED_MANUAL_CONVERGENCE_MIN, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_MIN)); - p.set(TICameraParameters::KEY_SUPPORTED_MANUAL_CONVERGENCE_MAX, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_MAX)); - p.set(TICameraParameters::KEY_SUPPORTED_MANUAL_CONVERGENCE_STEP, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_STEP)); - p.set(android::CameraParameters::KEY_VIDEO_STABILIZATION_SUPPORTED, mCameraProperties->get(CameraProperties::VSTAB_SUPPORTED)); - p.set(TICameraParameters::KEY_VNF_SUPPORTED, mCameraProperties->get(CameraProperties::VNF_SUPPORTED)); - p.set(android::CameraParameters::KEY_AUTO_EXPOSURE_LOCK_SUPPORTED, mCameraProperties->get(CameraProperties::AUTO_EXPOSURE_LOCK_SUPPORTED)); - p.set(android::CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED, mCameraProperties->get(CameraProperties::AUTO_WHITEBALANCE_LOCK_SUPPORTED)); - p.set(android::CameraParameters::KEY_VIDEO_SNAPSHOT_SUPPORTED, mCameraProperties->get(CameraProperties::VIDEO_SNAPSHOT_SUPPORTED)); -#ifndef OMAP_TUNA - p.set(TICameraParameters::KEY_MECHANICAL_MISALIGNMENT_CORRECTION_SUPPORTED, mCameraProperties->get(CameraProperties::MECHANICAL_MISALIGNMENT_CORRECTION_SUPPORTED)); -#endif - p.set(TICameraParameters::KEY_CAP_MODE_VALUES, mCameraProperties->get(CameraProperties::CAP_MODE_VALUES)); - - LOG_FUNCTION_NAME_EXIT; - -} - -void CameraHal::initDefaultParameters() -{ - //Purpose of this function is to initialize the default current and supported parameters for the currently - //selected camera. - - android::CameraParameters &p = mParameters; - int currentRevision, adapterRevision; - status_t ret = NO_ERROR; - int width, height; - const char *valstr; - - LOG_FUNCTION_NAME; - - insertSupportedParams(); - - ret = parseResolution(mCameraProperties->get(CameraProperties::PREVIEW_SIZE), width, height); - - if ( NO_ERROR == ret ) - { - p.setPreviewSize(width, height); - } - else - { - p.setPreviewSize(MIN_WIDTH, MIN_HEIGHT); - } - - ret = parseResolution(mCameraProperties->get(CameraProperties::PICTURE_SIZE), width, height); - - if ( NO_ERROR == ret ) - { - p.setPictureSize(width, height); - } - else - { - p.setPictureSize(PICTURE_WIDTH, PICTURE_HEIGHT); - } - - ret = parseResolution(mCameraProperties->get(CameraProperties::JPEG_THUMBNAIL_SIZE), width, height); - - if ( NO_ERROR == ret ) - { - p.set(android::CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, width); - p.set(android::CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, height); - } - else - { - p.set(android::CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, MIN_WIDTH); - p.set(android::CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, MIN_HEIGHT); - } - - //Insert default values - p.setPreviewFrameRate(atoi(mCameraProperties->get(CameraProperties::PREVIEW_FRAME_RATE))); - p.set(android::CameraParameters::KEY_PREVIEW_FPS_RANGE, mCameraProperties->get(CameraProperties::FRAMERATE_RANGE)); - p.setPreviewFormat(mCameraProperties->get(CameraProperties::PREVIEW_FORMAT)); - p.setPictureFormat(mCameraProperties->get(CameraProperties::PICTURE_FORMAT)); - p.set(android::CameraParameters::KEY_JPEG_QUALITY, mCameraProperties->get(CameraProperties::JPEG_QUALITY)); - p.set(android::CameraParameters::KEY_WHITE_BALANCE, mCameraProperties->get(CameraProperties::WHITEBALANCE)); - p.set(android::CameraParameters::KEY_EFFECT, mCameraProperties->get(CameraProperties::EFFECT)); - p.set(android::CameraParameters::KEY_ANTIBANDING, mCameraProperties->get(CameraProperties::ANTIBANDING)); - p.set(android::CameraParameters::KEY_FLASH_MODE, mCameraProperties->get(CameraProperties::FLASH_MODE)); - p.set(android::CameraParameters::KEY_FOCUS_MODE, mCameraProperties->get(CameraProperties::FOCUS_MODE)); - p.set(android::CameraParameters::KEY_EXPOSURE_COMPENSATION, mCameraProperties->get(CameraProperties::EV_COMPENSATION)); - p.set(android::CameraParameters::KEY_SCENE_MODE, mCameraProperties->get(CameraProperties::SCENE_MODE)); - p.set(android::CameraParameters::KEY_ZOOM, mCameraProperties->get(CameraProperties::ZOOM)); - p.set(TICameraParameters::KEY_CONTRAST, mCameraProperties->get(CameraProperties::CONTRAST)); - p.set(TICameraParameters::KEY_SATURATION, mCameraProperties->get(CameraProperties::SATURATION)); - p.set(TICameraParameters::KEY_BRIGHTNESS, mCameraProperties->get(CameraProperties::BRIGHTNESS)); - p.set(TICameraParameters::KEY_SHARPNESS, mCameraProperties->get(CameraProperties::SHARPNESS)); - p.set(TICameraParameters::KEY_EXPOSURE_MODE, mCameraProperties->get(CameraProperties::EXPOSURE_MODE)); - p.set(TICameraParameters::KEY_MANUAL_EXPOSURE, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MIN)); - p.set(TICameraParameters::KEY_MANUAL_EXPOSURE_RIGHT, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MIN)); - p.set(TICameraParameters::KEY_MANUAL_GAIN_ISO, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MIN)); - p.set(TICameraParameters::KEY_MANUAL_GAIN_ISO_RIGHT, mCameraProperties->get(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MIN)); - p.set(TICameraParameters::KEY_ISO, mCameraProperties->get(CameraProperties::ISO_MODE)); - p.set(TICameraParameters::KEY_IPP, mCameraProperties->get(CameraProperties::IPP)); - p.set(TICameraParameters::KEY_GBCE, mCameraProperties->get(CameraProperties::GBCE)); - p.set(TICameraParameters::KEY_GBCE_SUPPORTED, mCameraProperties->get(CameraProperties::SUPPORTED_GBCE)); - p.set(TICameraParameters::KEY_GLBCE, mCameraProperties->get(CameraProperties::GLBCE)); - p.set(TICameraParameters::KEY_GLBCE_SUPPORTED, mCameraProperties->get(CameraProperties::SUPPORTED_GLBCE)); -#ifndef OMAP_TUNA - p.set(TICameraParameters::KEY_S3D_PRV_FRAME_LAYOUT, mCameraProperties->get(CameraProperties::S3D_PRV_FRAME_LAYOUT)); - p.set(TICameraParameters::KEY_S3D_CAP_FRAME_LAYOUT, mCameraProperties->get(CameraProperties::S3D_CAP_FRAME_LAYOUT)); -#endif - p.set(TICameraParameters::KEY_AUTOCONVERGENCE_MODE, mCameraProperties->get(CameraProperties::AUTOCONVERGENCE_MODE)); - p.set(TICameraParameters::KEY_MANUAL_CONVERGENCE, mCameraProperties->get(CameraProperties::MANUAL_CONVERGENCE)); - p.set(android::CameraParameters::KEY_VIDEO_STABILIZATION, mCameraProperties->get(CameraProperties::VSTAB)); - p.set(TICameraParameters::KEY_VNF, mCameraProperties->get(CameraProperties::VNF)); - p.set(android::CameraParameters::KEY_FOCAL_LENGTH, mCameraProperties->get(CameraProperties::FOCAL_LENGTH)); - p.set(android::CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE, mCameraProperties->get(CameraProperties::HOR_ANGLE)); - p.set(android::CameraParameters::KEY_VERTICAL_VIEW_ANGLE, mCameraProperties->get(CameraProperties::VER_ANGLE)); - p.set(TICameraParameters::KEY_SENSOR_ORIENTATION, mCameraProperties->get(CameraProperties::SENSOR_ORIENTATION)); - p.set(TICameraParameters::KEY_EXIF_MAKE, mCameraProperties->get(CameraProperties::EXIF_MAKE)); - p.set(TICameraParameters::KEY_EXIF_MODEL, mCameraProperties->get(CameraProperties::EXIF_MODEL)); - p.set(android::CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY, mCameraProperties->get(CameraProperties::JPEG_THUMBNAIL_QUALITY)); - p.set(android::CameraParameters::KEY_VIDEO_FRAME_FORMAT, "OMX_TI_COLOR_FormatYUV420PackedSemiPlanar"); - p.set(android::CameraParameters::KEY_MAX_NUM_DETECTED_FACES_HW, mCameraProperties->get(CameraProperties::MAX_FD_HW_FACES)); - p.set(android::CameraParameters::KEY_MAX_NUM_DETECTED_FACES_SW, mCameraProperties->get(CameraProperties::MAX_FD_SW_FACES)); -#ifndef OMAP_TUNA - p.set(TICameraParameters::KEY_MECHANICAL_MISALIGNMENT_CORRECTION, mCameraProperties->get(CameraProperties::MECHANICAL_MISALIGNMENT_CORRECTION)); -#endif - // Only one area a.k.a Touch AF for now. - // TODO: Add support for multiple focus areas. - p.set(android::CameraParameters::KEY_MAX_NUM_FOCUS_AREAS, mCameraProperties->get(CameraProperties::MAX_FOCUS_AREAS)); - p.set(android::CameraParameters::KEY_AUTO_EXPOSURE_LOCK, mCameraProperties->get(CameraProperties::AUTO_EXPOSURE_LOCK)); - p.set(android::CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK, mCameraProperties->get(CameraProperties::AUTO_WHITEBALANCE_LOCK)); - p.set(android::CameraParameters::KEY_MAX_NUM_METERING_AREAS, mCameraProperties->get(CameraProperties::MAX_NUM_METERING_AREAS)); - p.set(TICameraParameters::RAW_WIDTH, mCameraProperties->get(CameraProperties::RAW_WIDTH)); - p.set(TICameraParameters::RAW_HEIGHT,mCameraProperties->get(CameraProperties::RAW_HEIGHT)); - -#ifndef OMAP_TUNA - // TI extensions for enable/disable algos - // Hadcoded for now - p.set(TICameraParameters::KEY_ALGO_FIXED_GAMMA, android::CameraParameters::TRUE); - p.set(TICameraParameters::KEY_ALGO_NSF1, android::CameraParameters::TRUE); - p.set(TICameraParameters::KEY_ALGO_NSF2, android::CameraParameters::TRUE); - p.set(TICameraParameters::KEY_ALGO_SHARPENING, android::CameraParameters::TRUE); - p.set(TICameraParameters::KEY_ALGO_THREELINCOLORMAP, android::CameraParameters::TRUE); - p.set(TICameraParameters::KEY_ALGO_GIC, android::CameraParameters::TRUE); -#endif - - LOG_FUNCTION_NAME_EXIT; -} - -/** - @brief Stop a previously started preview. - @param none - @return none - - */ -void CameraHal::forceStopPreview() -{ - LOG_FUNCTION_NAME; - - // stop bracketing if it is running - if ( mBracketingRunning ) { - stopImageBracketing(); - } - - if(mDisplayAdapter.get() != NULL) { - ///Stop the buffer display first - mDisplayAdapter->disableDisplay(); - } - - if(mAppCallbackNotifier.get() != NULL) { - //Stop the callback sending - mAppCallbackNotifier->stop(); - mAppCallbackNotifier->flushAndReturnFrames(); - mAppCallbackNotifier->stopPreviewCallbacks(); - } - - if ( NULL != mCameraAdapter ) { - // only need to send these control commands to state machine if we are - // passed the LOADED_PREVIEW_STATE - if (mCameraAdapter->getState() > CameraAdapter::LOADED_PREVIEW_STATE) { - // according to javadoc...FD should be stopped in stopPreview - // and application needs to call startFaceDection again - // to restart FD - mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_FD); - } - - mCameraAdapter->rollbackToInitializedState(); - - } - - freePreviewBufs(); - freePreviewDataBufs(); - - mPreviewEnabled = false; - mDisplayPaused = false; - mPreviewStartInProgress = false; - - LOG_FUNCTION_NAME_EXIT; -} - -/** - @brief Deallocates memory for all the resources held by Camera HAL. - - Frees the following objects- CameraAdapter, AppCallbackNotifier, DisplayAdapter, - and Memory Manager - - @param none - @return none - - */ -void CameraHal::deinitialize() -{ - LOG_FUNCTION_NAME; - - if ( mPreviewEnabled || mDisplayPaused ) { - forceStopPreview(); - } - - mSetPreviewWindowCalled = false; - - if (mSensorListener.get()) { - mSensorListener->disableSensor(SensorListener::SENSOR_ORIENTATION); - mSensorListener.clear(); - mSensorListener = NULL; - } - - LOG_FUNCTION_NAME_EXIT; - -} - -status_t CameraHal::storeMetaDataInBuffers(bool enable) -{ - LOG_FUNCTION_NAME; - - return mAppCallbackNotifier->useMetaDataBufferMode(enable); - - LOG_FUNCTION_NAME_EXIT; -} - -void CameraHal::getPreferredPreviewRes(int *width, int *height) -{ - LOG_FUNCTION_NAME; - - // We request Ducati for a higher resolution so preview looks better and then downscale the frame before the callback. - // TODO: This should be moved to configuration constants and boolean flag whether to provide such optimization - // Also consider providing this configurability of the desired display resolution from the application - if ( ( *width == 320 ) && ( *height == 240 ) ) { - *width = 640; - *height = 480; - } else if ( ( *width == 176 ) && ( *height == 144 ) ) { - *width = 704; - *height = 576; - } - - LOG_FUNCTION_NAME_EXIT; -} - -void CameraHal::resetPreviewRes(android::CameraParameters *params) -{ - LOG_FUNCTION_NAME; - - if ( (mVideoWidth <= 320) && (mVideoHeight <= 240)){ - params->setPreviewSize(mVideoWidth, mVideoHeight); - } - - LOG_FUNCTION_NAME_EXIT; -} - -void * -camera_buffer_get_omx_ptr (CameraBuffer *buffer) -{ - CAMHAL_LOGSV("buffer_type %d opaque %p", buffer->type, buffer->opaque); - - if (buffer->type == CAMERA_BUFFER_ANW) { - buffer_handle_t *handle = (buffer_handle_t *)buffer->opaque; - CAMHAL_LOGSV("anw %08x", *handle); - return (void *)*handle; - } else if (buffer->type == CAMERA_BUFFER_ION) { - return (void *)buffer->fd; - } else { - CAMHAL_LOGSV("other %08x", buffer->opaque); - return (void *)buffer->opaque; - } -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/CameraHalCommon.cpp b/camera/CameraHalCommon.cpp deleted file mode 100644 index 1cad4cb..0000000 --- a/camera/CameraHalCommon.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "CameraHal.h" - -namespace Ti { -namespace Camera { - -const char CameraHal::PARAMS_DELIMITER []= ","; - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - -struct timeval CameraHal::ppm_start; - -#endif - -#if PPM_INSTRUMENTATION - -/** - @brief PPM instrumentation - - Dumps the current time offset. The time reference point - lies within the CameraHAL constructor. - - @param str - log message - @return none - - */ -void CameraHal::PPM(const char* str){ - struct timeval ppm; - - gettimeofday(&ppm, NULL); - ppm.tv_sec = ppm.tv_sec - ppm_start.tv_sec; - ppm.tv_sec = ppm.tv_sec * 1000000; - ppm.tv_sec = ppm.tv_sec + ppm.tv_usec - ppm_start.tv_usec; - - CAMHAL_LOGI("PPM: %s :%ld.%ld ms", str, ( ppm.tv_sec /1000 ), ( ppm.tv_sec % 1000 )); -} - -#elif PPM_INSTRUMENTATION_ABS - -/** - @brief PPM instrumentation - - Dumps the current time offset. The time reference point - lies within the CameraHAL constructor. This implemetation - will also dump the abosolute timestamp, which is useful when - post calculation is done with data coming from the upper - layers (Camera application etc.) - - @param str - log message - @return none - - */ -void CameraHal::PPM(const char* str){ - struct timeval ppm; - - unsigned long long elapsed, absolute; - gettimeofday(&ppm, NULL); - elapsed = ppm.tv_sec - ppm_start.tv_sec; - elapsed *= 1000000; - elapsed += ppm.tv_usec - ppm_start.tv_usec; - absolute = ppm.tv_sec; - absolute *= 1000; - absolute += ppm.tv_usec /1000; - - CAMHAL_LOGI("PPM: %s :%llu.%llu ms : %llu ms", str, ( elapsed /1000 ), ( elapsed % 1000 ), absolute); -} - -#endif - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - -/** - @brief PPM instrumentation - - Calculates and dumps the elapsed time using 'ppm_first' as - reference. - - @param str - log message - @return none - - */ -void CameraHal::PPM(const char* str, struct timeval* ppm_first, ...){ - char temp_str[256]; - struct timeval ppm; - unsigned long long absolute; - va_list args; - - va_start(args, ppm_first); - vsprintf(temp_str, str, args); - gettimeofday(&ppm, NULL); - absolute = ppm.tv_sec; - absolute *= 1000; - absolute += ppm.tv_usec /1000; - ppm.tv_sec = ppm.tv_sec - ppm_first->tv_sec; - ppm.tv_sec = ppm.tv_sec * 1000000; - ppm.tv_sec = ppm.tv_sec + ppm.tv_usec - ppm_first->tv_usec; - - CAMHAL_LOGI("PPM: %s :%ld.%ld ms : %llu ms", temp_str, ( ppm.tv_sec /1000 ), ( ppm.tv_sec % 1000 ), absolute); - - va_end(args); -} - -#endif - -} // namespace Camera -} // namespace Ti diff --git a/camera/CameraHalUtilClasses.cpp b/camera/CameraHalUtilClasses.cpp deleted file mode 100644 index 274f0f8..0000000 --- a/camera/CameraHalUtilClasses.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file CameraHalUtilClasses.cpp -* -* This file maps the CameraHardwareInterface to the Camera interfaces on OMAP4 (mainly OMX). -* -*/ - -#include "CameraHal.h" - -namespace Ti { -namespace Camera { - -/*--------------------FrameProvider Class STARTS here-----------------------------*/ - -int FrameProvider::enableFrameNotification(int32_t frameTypes) -{ - LOG_FUNCTION_NAME; - status_t ret = NO_ERROR; - - ///Enable the frame notification to CameraAdapter (which implements FrameNotifier interface) - mFrameNotifier->enableMsgType(frameTypes<disableMsgType(frameTypes<returnFrame(frameBuf, frameType); - - return ret; -} - -void FrameProvider::addFramePointers(CameraBuffer *frameBuf, void *buf) -{ - mFrameNotifier->addFramePointers(frameBuf, buf); - return; -} - -void FrameProvider::removeFramePointers() -{ - mFrameNotifier->removeFramePointers(); - return; -} - -/*--------------------FrameProvider Class ENDS here-----------------------------*/ - -/*--------------------EventProvider Class STARTS here-----------------------------*/ - -int EventProvider::enableEventNotification(int32_t frameTypes) -{ - LOG_FUNCTION_NAME; - status_t ret = NO_ERROR; - - ///Enable the frame notification to CameraAdapter (which implements FrameNotifier interface) - mEventNotifier->enableMsgType(frameTypes<disableMsgType(frameTypes< weight ) || ( CameraArea::WEIGHT_MAX < weight ) ) { - CAMHAL_LOGEB("Camera area weight is invalid %d", weight); - return -EINVAL; - } - - if ( ( CameraArea::TOP > top ) || ( CameraArea::BOTTOM < top ) ) { - CAMHAL_LOGEB("Camera area top coordinate is invalid %d", top ); - return -EINVAL; - } - - if ( ( CameraArea::TOP > bottom ) || ( CameraArea::BOTTOM < bottom ) ) { - CAMHAL_LOGEB("Camera area bottom coordinate is invalid %d", bottom ); - return -EINVAL; - } - - if ( ( CameraArea::LEFT > left ) || ( CameraArea::RIGHT < left ) ) { - CAMHAL_LOGEB("Camera area left coordinate is invalid %d", left ); - return -EINVAL; - } - - if ( ( CameraArea::LEFT > right ) || ( CameraArea::RIGHT < right ) ) { - CAMHAL_LOGEB("Camera area right coordinate is invalid %d", right ); - return -EINVAL; - } - - if ( left >= right ) { - CAMHAL_LOGEA("Camera area left larger than right"); - return -EINVAL; - } - - if ( top >= bottom ) { - CAMHAL_LOGEA("Camera area top larger than bottom"); - return -EINVAL; - } - - return NO_ERROR; -} - -status_t CameraArea::parseAreas(const char *area, - size_t areaLength, - android::Vector > &areas) -{ - status_t ret = NO_ERROR; - char *ctx; - char *pArea = NULL; - char *pStart = NULL; - char *pEnd = NULL; - const char *startToken = "("; - const char endToken = ')'; - const char sep = ','; - ssize_t top, left, bottom, right, weight; - char *tmpBuffer = NULL; - android::sp currentArea; - - LOG_FUNCTION_NAME - - if ( ( NULL == area ) || - ( 0 >= areaLength ) ) - { - return -EINVAL; - } - - tmpBuffer = ( char * ) malloc(areaLength); - if ( NULL == tmpBuffer ) - { - return -ENOMEM; - } - - memcpy(tmpBuffer, area, areaLength); - - pArea = strtok_r(tmpBuffer, startToken, &ctx); - - do - { - - pStart = pArea; - if ( NULL == pStart ) - { - CAMHAL_LOGEA("Parsing of the left area coordinate failed!"); - ret = -EINVAL; - break; - } - else - { - left = static_cast(strtol(pStart, &pEnd, 10)); - } - - if ( sep != *pEnd ) - { - CAMHAL_LOGEA("Parsing of the top area coordinate failed!"); - ret = -EINVAL; - break; - } - else - { - top = static_cast(strtol(pEnd+1, &pEnd, 10)); - } - - if ( sep != *pEnd ) - { - CAMHAL_LOGEA("Parsing of the right area coordinate failed!"); - ret = -EINVAL; - break; - } - else - { - right = static_cast(strtol(pEnd+1, &pEnd, 10)); - } - - if ( sep != *pEnd ) - { - CAMHAL_LOGEA("Parsing of the bottom area coordinate failed!"); - ret = -EINVAL; - break; - } - else - { - bottom = static_cast(strtol(pEnd+1, &pEnd, 10)); - } - - if ( sep != *pEnd ) - { - CAMHAL_LOGEA("Parsing of the weight area coordinate failed!"); - ret = -EINVAL; - break; - } - else - { - weight = static_cast(strtol(pEnd+1, &pEnd, 10)); - } - - if ( endToken != *pEnd ) - { - CAMHAL_LOGEA("Malformed area!"); - ret = -EINVAL; - break; - } - - ret = checkArea(top, left, bottom, right, weight); - if ( NO_ERROR != ret ) { - break; - } - - currentArea = new CameraArea(top, left, bottom, right, weight); - CAMHAL_LOGDB("Area parsed [%dx%d, %dx%d] %d", - ( int ) top, - ( int ) left, - ( int ) bottom, - ( int ) right, - ( int ) weight); - if ( NULL != currentArea.get() ) - { - areas.add(currentArea); - } - else - { - ret = -ENOMEM; - break; - } - - pArea = strtok_r(NULL, startToken, &ctx); - - } - while ( NULL != pArea ); - - if ( NULL != tmpBuffer ) - { - free(tmpBuffer); - } - - LOG_FUNCTION_NAME_EXIT - - return ret; -} - -bool CameraArea::areAreasDifferent(android::Vector< android::sp > &area1, - android::Vector< android::sp > &area2) { - if (area1.size() != area2.size()) { - return true; - } - - // not going to care about sorting order for now - for (unsigned int i = 0; i < area1.size(); i++) { - if (!area1.itemAt(i)->compare(area2.itemAt(i))) { - return true; - } - } - - return false; -} - -bool CameraArea::compare(const android::sp &area) { - return ((mTop == area->mTop) && (mLeft == area->mLeft) && - (mBottom == area->mBottom) && (mRight == area->mRight) && - (mWeight == area->mWeight)); -} - - -/*--------------------CameraArea Class ENDS here-----------------------------*/ - -} // namespace Camera -} // namespace Ti diff --git a/camera/CameraHal_Module.cpp b/camera/CameraHal_Module.cpp deleted file mode 100644 index 3e75af9..0000000 --- a/camera/CameraHal_Module.cpp +++ /dev/null @@ -1,823 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file CameraHal.cpp -* -* This file maps the Camera Hardware Interface to V4L2. -* -*/ - -#include - -#include "CameraHal.h" -#include "CameraProperties.h" -#include "TICameraParameters.h" - - -#ifdef CAMERAHAL_DEBUG_VERBOSE -# define CAMHAL_LOG_MODULE_FUNCTION_NAME LOG_FUNCTION_NAME -#else -# define CAMHAL_LOG_MODULE_FUNCTION_NAME -#endif - - -namespace Ti { -namespace Camera { - -static CameraProperties gCameraProperties; -static CameraHal* gCameraHals[MAX_CAMERAS_SUPPORTED]; -static unsigned int gCamerasOpen = 0; -static android::Mutex gCameraHalDeviceLock; - -static int camera_device_open(const hw_module_t* module, const char* name, - hw_device_t** device); -static int camera_device_close(hw_device_t* device); -static int camera_get_number_of_cameras(void); -static int camera_get_camera_info(int camera_id, struct camera_info *info); - -static struct hw_module_methods_t camera_module_methods = { - .open = camera_device_open -}; - -} // namespace Camera -} // namespace Ti - - -camera_module_t HAL_MODULE_INFO_SYM = { - .common = { - .tag = HARDWARE_MODULE_TAG, - .version_major = 1, - .version_minor = 0, - .id = CAMERA_HARDWARE_MODULE_ID, - .name = "TI OMAP CameraHal Module", - .author = "TI", - .methods = &Ti::Camera::camera_module_methods, - .dso = NULL, /* remove compilation warnings */ - .reserved = {0}, /* remove compilation warnings */ - }, - .get_number_of_cameras = Ti::Camera::camera_get_number_of_cameras, - .get_camera_info = Ti::Camera::camera_get_camera_info, - .set_callbacks = NULL, /* remove compilation warnings */ - .get_vendor_tag_ops = NULL, /* remove compilation warnings */ - .open_legacy = NULL, /* remove compilation warnings */ - .reserved = {0}, /* remove compilation warnings */ -}; - - -namespace Ti { -namespace Camera { - -typedef struct ti_camera_device { - camera_device_t base; - /* TI specific "private" data can go here (base.priv) */ - int cameraid; -} ti_camera_device_t; - - -/******************************************************************* - * implementation of camera_device_ops functions - *******************************************************************/ - -int camera_set_preview_window(struct camera_device * device, - struct preview_stream_ops *window) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->setPreviewWindow(window); - - return rv; -} - -#ifdef OMAP_ENHANCEMENT_CPCAM -int camera_set_extended_preview_ops(struct camera_device * device, - preview_stream_extended_ops_t * extendedOps) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - if (!device) { - return BAD_VALUE; - } - - ti_camera_device_t * const tiDevice = reinterpret_cast(device); - gCameraHals[tiDevice->cameraid]->setExtendedPreviewStreamOps(extendedOps); - - return OK; -} - -int camera_set_buffer_source(struct camera_device * device, - struct preview_stream_ops *tapin, - struct preview_stream_ops *tapout) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->setBufferSource(tapin, tapout); - - return rv; -} -#endif - -void camera_set_callbacks(struct camera_device * device, - camera_notify_callback notify_cb, - camera_data_callback data_cb, - camera_data_timestamp_callback data_cb_timestamp, - camera_request_memory get_memory, - void *user) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return; - - ti_dev = (ti_camera_device_t*) device; - - gCameraHals[ti_dev->cameraid]->setCallbacks(notify_cb, data_cb, data_cb_timestamp, get_memory, user); -} - -void camera_enable_msg_type(struct camera_device * device, int32_t msg_type) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return; - - ti_dev = (ti_camera_device_t*) device; - - gCameraHals[ti_dev->cameraid]->enableMsgType(msg_type); -} - -void camera_disable_msg_type(struct camera_device * device, int32_t msg_type) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return; - - ti_dev = (ti_camera_device_t*) device; - - gCameraHals[ti_dev->cameraid]->disableMsgType(msg_type); -} - -int camera_msg_type_enabled(struct camera_device * device, int32_t msg_type) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return 0; - - ti_dev = (ti_camera_device_t*) device; - - return gCameraHals[ti_dev->cameraid]->msgTypeEnabled(msg_type); -} - -int camera_start_preview(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->startPreview(); - - return rv; -} - -void camera_stop_preview(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return; - - ti_dev = (ti_camera_device_t*) device; - - gCameraHals[ti_dev->cameraid]->stopPreview(); -} - -int camera_preview_enabled(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->previewEnabled(); - return rv; -} - -int camera_store_meta_data_in_buffers(struct camera_device * device, int enable) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - // TODO: meta data buffer not current supported - rv = gCameraHals[ti_dev->cameraid]->storeMetaDataInBuffers(enable); - return rv; - //return enable ? android::INVALID_OPERATION: android::OK; -} - -int camera_start_recording(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->startRecording(); - return rv; -} - -void camera_stop_recording(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return; - - ti_dev = (ti_camera_device_t*) device; - - gCameraHals[ti_dev->cameraid]->stopRecording(); -} - -int camera_recording_enabled(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->recordingEnabled(); - return rv; -} - -void camera_release_recording_frame(struct camera_device * device, - const void *opaque) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return; - - ti_dev = (ti_camera_device_t*) device; - - gCameraHals[ti_dev->cameraid]->releaseRecordingFrame(opaque); -} - -int camera_auto_focus(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->autoFocus(); - return rv; -} - -int camera_cancel_auto_focus(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->cancelAutoFocus(); - return rv; -} - -int camera_take_picture(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->takePicture(0); - return rv; -} - -#ifdef OMAP_ENHANCEMENT_CPCAM -int camera_take_picture_with_parameters(struct camera_device * device, const char *params) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->takePicture(params); - return rv; -} -#endif - -int camera_cancel_picture(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->cancelPicture(); - return rv; -} - -#ifdef OMAP_ENHANCEMENT_CPCAM -int camera_reprocess(struct camera_device * device, const char *params) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->reprocess(params); - return rv; -} - -int camera_cancel_reprocess(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->cancel_reprocess(); - return rv; -} -#endif - -int camera_set_parameters(struct camera_device * device, const char *params) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->setParameters(params); - return rv; -} - -char* camera_get_parameters(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - char* param = NULL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return NULL; - - ti_dev = (ti_camera_device_t*) device; - - param = gCameraHals[ti_dev->cameraid]->getParameters(); - - return param; -} - -static void camera_put_parameters(struct camera_device *device, char *parms) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return; - - ti_dev = (ti_camera_device_t*) device; - - gCameraHals[ti_dev->cameraid]->putParameters(parms); -} - -int camera_send_command(struct camera_device * device, - int32_t cmd, int32_t arg1, int32_t arg2) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - -#ifdef OMAP_ENHANCEMENT - if ( cmd == CAMERA_CMD_SETUP_EXTENDED_OPERATIONS ) { - camera_device_extended_ops_t * const ops = static_cast( - camera_cmd_send_command_args_to_pointer(arg1, arg2)); - -#ifdef OMAP_ENHANCEMENT_CPCAM - ops->set_extended_preview_ops = camera_set_extended_preview_ops; - ops->set_buffer_source = camera_set_buffer_source; - ops->take_picture_with_parameters = camera_take_picture_with_parameters; - ops->reprocess = camera_reprocess; - ops->cancel_reprocess = camera_cancel_reprocess; -#endif - - return OK; - } -#endif - - rv = gCameraHals[ti_dev->cameraid]->sendCommand(cmd, arg1, arg2); - return rv; -} - -void camera_release(struct camera_device * device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return; - - ti_dev = (ti_camera_device_t*) device; - - gCameraHals[ti_dev->cameraid]->release(); -} - -int camera_dump(struct camera_device * device, int fd) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int rv = -EINVAL; - ti_camera_device_t* ti_dev = NULL; - - if(!device) - return rv; - - ti_dev = (ti_camera_device_t*) device; - - rv = gCameraHals[ti_dev->cameraid]->dump(fd); - return rv; -} - -extern "C" void heaptracker_free_leaked_memory(void); - -int camera_device_close(hw_device_t* device) -{ - CAMHAL_LOG_MODULE_FUNCTION_NAME; - - int ret = 0; - ti_camera_device_t* ti_dev = NULL; - - android::AutoMutex lock(gCameraHalDeviceLock); - - if (!device) { - ret = -EINVAL; - goto done; - } - - ti_dev = (ti_camera_device_t*) device; - - if (ti_dev) { - if (gCameraHals[ti_dev->cameraid]) { - delete gCameraHals[ti_dev->cameraid]; - gCameraHals[ti_dev->cameraid] = NULL; - gCamerasOpen--; - } - - if (ti_dev->base.ops) { - free(ti_dev->base.ops); - } - free(ti_dev); - } -done: -#ifdef HEAPTRACKER - heaptracker_free_leaked_memory(); -#endif - return ret; -} - -/******************************************************************* - * implementation of camera_module functions - *******************************************************************/ - -/* open device handle to one of the cameras - * - * assume camera service will keep singleton of each camera - * so this function will always only be called once per camera instance - */ - -int camera_device_open(const hw_module_t* module, const char* name, - hw_device_t** device) -{ - int rv = 0; - int num_cameras = 0; - int cameraid; - ti_camera_device_t* camera_device = NULL; - camera_device_ops_t* camera_ops = NULL; - CameraHal* camera = NULL; - CameraProperties::Properties* properties = NULL; - - android::AutoMutex lock(gCameraHalDeviceLock); - - CAMHAL_LOGI("camera_device open"); - - if (name != NULL) { - cameraid = atoi(name); - num_cameras = gCameraProperties.camerasSupported(); - - if(cameraid > num_cameras) - { - CAMHAL_LOGE("camera service provided cameraid out of bounds, " - "cameraid = %d, num supported = %d", - cameraid, num_cameras); - rv = -EINVAL; - goto fail; - } - - if(gCamerasOpen >= MAX_SIMUL_CAMERAS_SUPPORTED) - { - CAMHAL_LOGE("maximum number of cameras already open"); - rv = -ENOMEM; - goto fail; - } - - camera_device = (ti_camera_device_t*)malloc(sizeof(*camera_device)); - if(!camera_device) - { - CAMHAL_LOGE("camera_device allocation fail"); - rv = -ENOMEM; - goto fail; - } - - camera_ops = (camera_device_ops_t*)malloc(sizeof(*camera_ops)); - if(!camera_ops) - { - CAMHAL_LOGE("camera_ops allocation fail"); - rv = -ENOMEM; - goto fail; - } - - memset(camera_device, 0, sizeof(*camera_device)); - memset(camera_ops, 0, sizeof(*camera_ops)); - - camera_device->base.common.tag = HARDWARE_DEVICE_TAG; - camera_device->base.common.version = 0; - camera_device->base.common.module = (hw_module_t *)(module); - camera_device->base.common.close = camera_device_close; - camera_device->base.ops = camera_ops; - - camera_ops->set_preview_window = camera_set_preview_window; - camera_ops->set_callbacks = camera_set_callbacks; - camera_ops->enable_msg_type = camera_enable_msg_type; - camera_ops->disable_msg_type = camera_disable_msg_type; - camera_ops->msg_type_enabled = camera_msg_type_enabled; - camera_ops->start_preview = camera_start_preview; - camera_ops->stop_preview = camera_stop_preview; - camera_ops->preview_enabled = camera_preview_enabled; - camera_ops->store_meta_data_in_buffers = camera_store_meta_data_in_buffers; - camera_ops->start_recording = camera_start_recording; - camera_ops->stop_recording = camera_stop_recording; - camera_ops->recording_enabled = camera_recording_enabled; - camera_ops->release_recording_frame = camera_release_recording_frame; - camera_ops->auto_focus = camera_auto_focus; - camera_ops->cancel_auto_focus = camera_cancel_auto_focus; - camera_ops->take_picture = camera_take_picture; - camera_ops->cancel_picture = camera_cancel_picture; - camera_ops->set_parameters = camera_set_parameters; - camera_ops->get_parameters = camera_get_parameters; - camera_ops->put_parameters = camera_put_parameters; - camera_ops->send_command = camera_send_command; - camera_ops->release = camera_release; - camera_ops->dump = camera_dump; - - *device = &camera_device->base.common; - - // -------- TI specific stuff -------- - - camera_device->cameraid = cameraid; - - if(gCameraProperties.getProperties(cameraid, &properties) < 0) - { - CAMHAL_LOGE("Couldn't get camera properties"); - rv = -ENOMEM; - goto fail; - } - - camera = new CameraHal(cameraid); - - if(!camera) - { - CAMHAL_LOGE("Couldn't create instance of CameraHal class"); - rv = -ENOMEM; - goto fail; - } - - if(properties && (camera->initialize(properties) != NO_ERROR)) - { - CAMHAL_LOGE("Couldn't initialize camera instance"); - rv = -ENODEV; - goto fail; - } - - gCameraHals[cameraid] = camera; - gCamerasOpen++; - } - - return rv; - -fail: - if(camera_device) { - free(camera_device); - camera_device = NULL; - } - if(camera_ops) { - free(camera_ops); - camera_ops = NULL; - } - if(camera) { - delete camera; - camera = NULL; - } - *device = NULL; - return rv; -} - -int camera_get_number_of_cameras(void) -{ - int num_cameras = MAX_CAMERAS_SUPPORTED; - - // this going to be the first call from camera service - // initialize camera properties here... - if(gCameraProperties.initialize() != NO_ERROR) - { - CAMHAL_LOGEA("Unable to create or initialize CameraProperties"); - return 0; - } - - num_cameras = gCameraProperties.camerasSupported(); - - return num_cameras; -} - -int camera_get_camera_info(int camera_id, struct camera_info *info) -{ - int rv = 0; - int face_value = CAMERA_FACING_BACK; - int orientation = 0; - const char *valstr = NULL; - CameraProperties::Properties* properties = NULL; - - // this going to be the first call from camera service - // initialize camera properties here... - if(gCameraProperties.initialize() != NO_ERROR) - { - CAMHAL_LOGEA("Unable to create or initialize CameraProperties"); - rv = -EINVAL; - goto end; - } - - //Get camera properties for camera index - if(gCameraProperties.getProperties(camera_id, &properties) < 0) - { - CAMHAL_LOGE("Couldn't get camera properties"); - rv = -EINVAL; - goto end; - } - - if(properties) - { - valstr = properties->get(CameraProperties::FACING_INDEX); - if(valstr != NULL) - { - if (strcmp(valstr, TICameraParameters::FACING_FRONT) == 0) - { - face_value = CAMERA_FACING_FRONT; - } - else if (strcmp(valstr, TICameraParameters::FACING_BACK) == 0) - { - face_value = CAMERA_FACING_BACK; - } - } - - valstr = properties->get(CameraProperties::ORIENTATION_INDEX); - if(valstr != NULL) - { - orientation = atoi(valstr); - } - } - else - { - CAMHAL_LOGEB("getProperties() returned a NULL property set for Camera id %d", camera_id); - } - - info->facing = face_value; - info->orientation = orientation; - -end: - return rv; -} - - -} // namespace Camera -} // namespace Ti diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp deleted file mode 100644 index 2c008e7..0000000 --- a/camera/CameraParameters.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file CameraProperties.cpp -* -* This file maps the CameraHardwareInterface to the Camera interfaces on OMAP4 (mainly OMX). -* -*/ - -#include "CameraProperties.h" - -namespace Ti { -namespace Camera { - -const char CameraProperties::INVALID[]="prop-invalid-key"; -const char CameraProperties::CAMERA_NAME[]="prop-camera-name"; -const char CameraProperties::CAMERA_SENSOR_INDEX[]="prop-sensor-index"; -const char CameraProperties::CAMERA_SENSOR_ID[] = "prop-sensor-id"; -const char CameraProperties::ORIENTATION_INDEX[]="prop-orientation"; -const char CameraProperties::FACING_INDEX[]="prop-facing"; -const char CameraProperties::SUPPORTED_PREVIEW_SIZES[] = "prop-preview-size-values"; -#ifndef OMAP_TUNA -const char CameraProperties::SUPPORTED_PREVIEW_SUBSAMPLED_SIZES[] = "prop-preview-subsampled-size-values"; -const char CameraProperties::SUPPORTED_PREVIEW_TOPBOTTOM_SIZES[] = "prop-preview-topbottom-size-values"; -const char CameraProperties::SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES[] = "prop-preview-sidebyside-size-values"; -#endif -const char CameraProperties::SUPPORTED_PREVIEW_FORMATS[] = "prop-preview-format-values"; -const char CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES[] = "prop-preview-frame-rate-values"; -const char CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES_EXT[] = "prop-preview-frame-rate-ext-values"; -const char CameraProperties::SUPPORTED_PICTURE_SIZES[] = "prop-picture-size-values"; -#ifndef OMAP_TUNA -const char CameraProperties::SUPPORTED_PICTURE_SUBSAMPLED_SIZES[] = "prop-picture-subsampled-size-values"; -const char CameraProperties::SUPPORTED_PICTURE_TOPBOTTOM_SIZES[] = "prop-picture-topbottom-size-values"; -const char CameraProperties::SUPPORTED_PICTURE_SIDEBYSIDE_SIZES[] = "prop-picture-sidebyside-size-values"; -#endif -const char CameraProperties::SUPPORTED_PICTURE_FORMATS[] = "prop-picture-format-values"; -const char CameraProperties::SUPPORTED_THUMBNAIL_SIZES[] = "prop-jpeg-thumbnail-size-values"; -const char CameraProperties::SUPPORTED_WHITE_BALANCE[] = "prop-whitebalance-values"; -const char CameraProperties::SUPPORTED_EFFECTS[] = "prop-effect-values"; -const char CameraProperties::SUPPORTED_ANTIBANDING[] = "prop-antibanding-values"; -const char CameraProperties::SUPPORTED_EXPOSURE_MODES[] = "prop-exposure-mode-values"; -const char CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MIN[] = "prop-manual-exposure-min"; -const char CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MAX[] = "prop-manual-exposure-max"; -const char CameraProperties::SUPPORTED_MANUAL_EXPOSURE_STEP[] = "prop-manual-exposure-step"; -const char CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MIN[] = "prop-manual-gain-iso-min"; -const char CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MAX[] = "prop-manual-gain-iso-max"; -const char CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_STEP[] = "prop-manual-gain-iso-step"; -const char CameraProperties::SUPPORTED_EV_MAX[] = "prop-ev-compensation-max"; -const char CameraProperties::SUPPORTED_EV_MIN[] = "prop-ev-compensation-min"; -const char CameraProperties::SUPPORTED_EV_STEP[] = "prop-ev-compensation-step"; -const char CameraProperties::SUPPORTED_ISO_VALUES[] = "prop-iso-mode-values"; -const char CameraProperties::SUPPORTED_SCENE_MODES[] = "prop-scene-mode-values"; -const char CameraProperties::SUPPORTED_FLASH_MODES[] = "prop-flash-mode-values"; -const char CameraProperties::SUPPORTED_FOCUS_MODES[] = "prop-focus-mode-values"; -const char CameraProperties::REQUIRED_PREVIEW_BUFS[] = "prop-required-preview-bufs"; -const char CameraProperties::REQUIRED_IMAGE_BUFS[] = "prop-required-image-bufs"; -const char CameraProperties::SUPPORTED_ZOOM_RATIOS[] = "prop-zoom-ratios"; -const char CameraProperties::SUPPORTED_ZOOM_STAGES[] = "prop-zoom-stages"; -const char CameraProperties::SUPPORTED_IPP_MODES[] = "prop-ipp-values"; -const char CameraProperties::SMOOTH_ZOOM_SUPPORTED[] = "prop-smooth-zoom-supported"; -const char CameraProperties::ZOOM_SUPPORTED[] = "prop-zoom-supported"; -const char CameraProperties::PREVIEW_SIZE[] = "prop-preview-size-default"; -const char CameraProperties::PREVIEW_FORMAT[] = "prop-preview-format-default"; -const char CameraProperties::PREVIEW_FRAME_RATE[] = "prop-preview-frame-rate-default"; -const char CameraProperties::ZOOM[] = "prop-zoom-default"; -const char CameraProperties::PICTURE_SIZE[] = "prop-picture-size-default"; -const char CameraProperties::PICTURE_FORMAT[] = "prop-picture-format-default"; -const char CameraProperties::JPEG_THUMBNAIL_SIZE[] = "prop-jpeg-thumbnail-size-default"; -const char CameraProperties::WHITEBALANCE[] = "prop-whitebalance-default"; -const char CameraProperties::EFFECT[] = "prop-effect-default"; -const char CameraProperties::ANTIBANDING[] = "prop-antibanding-default"; -const char CameraProperties::EXPOSURE_MODE[] = "prop-exposure-mode-default"; -const char CameraProperties::EV_COMPENSATION[] = "prop-ev-compensation-default"; -const char CameraProperties::ISO_MODE[] = "prop-iso-mode-default"; -const char CameraProperties::FOCUS_MODE[] = "prop-focus-mode-default"; -const char CameraProperties::SCENE_MODE[] = "prop-scene-mode-default"; -const char CameraProperties::FLASH_MODE[] = "prop-flash-mode-default"; -const char CameraProperties::JPEG_QUALITY[] = "prop-jpeg-quality-default"; -const char CameraProperties::CONTRAST[] = "prop-contrast-default"; -const char CameraProperties::BRIGHTNESS[] = "prop-brightness-default"; -const char CameraProperties::SATURATION[] = "prop-saturation-default"; -const char CameraProperties::SHARPNESS[] = "prop-sharpness-default"; -const char CameraProperties::IPP[] = "prop-ipp-default"; -const char CameraProperties::GBCE[] = "prop-gbce-default"; -const char CameraProperties::SUPPORTED_GBCE[] = "prop-gbce-supported"; -const char CameraProperties::GLBCE[] = "prop-glbce-default"; -const char CameraProperties::SUPPORTED_GLBCE[] = "prop-glbce-supported"; -#ifndef OMAP_TUNA -const char CameraProperties::S3D_PRV_FRAME_LAYOUT[] = "prop-s3d-prv-frame-layout"; -const char CameraProperties::S3D_PRV_FRAME_LAYOUT_VALUES[] = "prop-s3d-prv-frame-layout-values"; -const char CameraProperties::S3D_CAP_FRAME_LAYOUT[] = "prop-s3d-cap-frame-layout"; -const char CameraProperties::S3D_CAP_FRAME_LAYOUT_VALUES[] = "prop-s3d-cap-frame-layout-values"; -#endif -const char CameraProperties::AUTOCONVERGENCE_MODE[] = "prop-auto-convergence-mode"; -const char CameraProperties::AUTOCONVERGENCE_MODE_VALUES[] = "prop-auto-convergence-mode-values"; -const char CameraProperties::MANUAL_CONVERGENCE[] = "prop-manual-convergence"; -const char CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_MIN[] = "prop-supported-manual-convergence-min"; -const char CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_MAX[] = "prop-supported-manual-convergence-max"; -const char CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_STEP[] = "prop-supported-manual-convergence-step"; -const char CameraProperties::VSTAB[] = "prop-vstab-default"; -const char CameraProperties::VSTAB_SUPPORTED[] = "prop-vstab-supported"; -const char CameraProperties::VNF[] = "prop-vnf-default"; -const char CameraProperties::VNF_SUPPORTED[] = "prop-vnf-supported"; -const char CameraProperties::REVISION[] = "prop-revision"; -const char CameraProperties::FOCAL_LENGTH[] = "prop-focal-length"; -const char CameraProperties::HOR_ANGLE[] = "prop-horizontal-angle"; -const char CameraProperties::VER_ANGLE[] = "prop-vertical-angle"; -const char CameraProperties::FRAMERATE_RANGE[] = "prop-framerate-range-default"; -const char CameraProperties::FRAMERATE_RANGE_SUPPORTED[]="prop-framerate-range-values"; -const char CameraProperties::FRAMERATE_RANGE_EXT_SUPPORTED[]="prop-framerate-range-ext-values"; -const char CameraProperties::SENSOR_ORIENTATION[]= "sensor-orientation"; -const char CameraProperties::SENSOR_ORIENTATION_VALUES[]= "sensor-orientation-values"; -const char CameraProperties::EXIF_MAKE[] = "prop-exif-make"; -const char CameraProperties::EXIF_MODEL[] = "prop-exif-model"; -const char CameraProperties::JPEG_THUMBNAIL_QUALITY[] = "prop-jpeg-thumbnail-quality-default"; -const char CameraProperties::MAX_FOCUS_AREAS[] = "prop-max-focus-areas"; -const char CameraProperties::MAX_FD_HW_FACES[] = "prop-max-fd-hw-faces"; -const char CameraProperties::MAX_FD_SW_FACES[] = "prop-max-fd-sw-faces"; -const char CameraProperties::AUTO_EXPOSURE_LOCK[] = "prop-auto-exposure-lock"; -const char CameraProperties::AUTO_EXPOSURE_LOCK_SUPPORTED[] = "prop-auto-exposure-lock-supported"; -const char CameraProperties::AUTO_WHITEBALANCE_LOCK[] = "prop-auto-whitebalance-lock"; -const char CameraProperties::AUTO_WHITEBALANCE_LOCK_SUPPORTED[] = "prop-auto-whitebalance-lock-supported"; -const char CameraProperties::MAX_NUM_METERING_AREAS[] = "prop-max-num-metering-areas"; -const char CameraProperties::METERING_AREAS[] = "prop-metering-areas"; -const char CameraProperties::VIDEO_SNAPSHOT_SUPPORTED[] = "prop-video-snapshot-supported"; -const char CameraProperties::VIDEO_SIZE[] = "video-size"; -const char CameraProperties::SUPPORTED_VIDEO_SIZES[] = "video-size-values"; -#ifndef OMAP_TUNA -const char CameraProperties::MECHANICAL_MISALIGNMENT_CORRECTION_SUPPORTED[] = "prop-mechanical-misalignment-correction-supported"; -const char CameraProperties::MECHANICAL_MISALIGNMENT_CORRECTION[] = "prop-mechanical-misalignment-correction"; -#endif -const char CameraProperties::CAP_MODE_VALUES[] = "prop-mode-values"; -const char CameraProperties::RAW_WIDTH[] = "prop-raw-width-values"; -const char CameraProperties::RAW_HEIGHT[] = "prop-raw-height-values"; -const char CameraProperties::MAX_PICTURE_WIDTH[] = "prop-max-picture-width"; -const char CameraProperties::MAX_PICTURE_HEIGHT[] = "prop-max-picture-height"; - -const char CameraProperties::DEFAULT_VALUE[] = ""; - -const char CameraProperties::PARAMS_DELIMITER []= ","; - -// Returns the properties class for a specific Camera -// Each value is indexed by the CameraProperties::CameraPropertyIndex enum -int CameraProperties::getProperties(int cameraIndex, CameraProperties::Properties** properties) -{ - LOG_FUNCTION_NAME; - - if(cameraIndex >= mCamerasSupported) - { - LOG_FUNCTION_NAME_EXIT; - return -EINVAL; - } - - *properties = mCameraProps+cameraIndex; - - LOG_FUNCTION_NAME_EXIT; - return 0; -} - -void CameraProperties::Properties::set(const char * const prop, const char * const value) { - CAMHAL_ASSERT(prop); - - if ( !value ) { - mProperties[mCurrentMode].removeItem(android::String8(prop)); - } else { - mProperties[mCurrentMode].replaceValueFor(android::String8(prop), android::String8(value)); - } -} - -void CameraProperties::Properties::set(const char * const prop, const int value) { - char s_val[30]; - sprintf(s_val, "%d", value); - set(prop, s_val); -} - -const char* CameraProperties::Properties::get(const char * prop) const { - return mProperties[mCurrentMode].valueFor(android::String8(prop)).string(); -} - -int CameraProperties::Properties::getInt(const char * prop) const { - android::String8 value = mProperties[mCurrentMode].valueFor(android::String8(prop)); - if (value.isEmpty()) { - return -1; - } - return strtol(value, 0, 0); -} - -void CameraProperties::Properties::setSensorIndex(int idx) { - OperatingMode originalMode = getMode(); - for ( int i = 0 ; i < MODE_MAX ; i++ ) { - setMode(static_cast(i)); - set(CAMERA_SENSOR_INDEX, idx); - } - setMode(originalMode); -} - -void CameraProperties::Properties::setMode(OperatingMode mode) { - CAMHAL_ASSERT(mode >= 0 && mode < MODE_MAX); - mCurrentMode = mode; -} - -OperatingMode CameraProperties::Properties::getMode() const { - return mCurrentMode; -} - -void CameraProperties::Properties::dump() { - CAMHAL_LOGD("================================"); - CAMHAL_LOGD("Dumping properties for camera: %d", getInt("prop-sensor-index")); - - for (size_t i = 0; i < mProperties[mCurrentMode].size(); i++) { - CAMHAL_LOGD("%s = %s", - mProperties[mCurrentMode].keyAt(i).string(), - mProperties[mCurrentMode].valueAt(i).string()); - } - - CAMHAL_LOGD("--------------------------------"); -} - -const char* CameraProperties::Properties::keyAt(const unsigned int index) const { - if (index < mProperties[mCurrentMode].size()) { - return mProperties[mCurrentMode].keyAt(index).string(); - } - return NULL; -} - -const char* CameraProperties::Properties::valueAt(const unsigned int index) const { - if (index < mProperties[mCurrentMode].size()) { - return mProperties[mCurrentMode].valueAt(index).string(); - } - return NULL; -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/CameraProperties.cpp b/camera/CameraProperties.cpp deleted file mode 100644 index 93bc953..0000000 --- a/camera/CameraProperties.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file CameraProperties.cpp -* -* This file maps the CameraHardwareInterface to the Camera interfaces on OMAP4 (mainly OMX). -* -*/ - -#include "CameraProperties.h" - -#define CAMERA_ROOT "CameraRoot" -#define CAMERA_INSTANCE "CameraInstance" - -namespace Ti { -namespace Camera { - -// lower entries have higher priority -static const char* g_camera_adapters[] = { -#ifdef OMAP4_SUPPORT_OMX_CAMERA_ADAPTER - "libomxcameraadapter.so", -#endif -#ifdef OMAP4_SUPPORT_USB_CAMERA_ADAPTER - "libusbcameraadapter.so" -#endif -}; - -/********************************************************* - CameraProperties - public function implemetation -**********************************************************/ - -CameraProperties::CameraProperties() : mCamerasSupported(0) -{ - LOG_FUNCTION_NAME; - - mCamerasSupported = 0; - mInitialized = 0; - - LOG_FUNCTION_NAME_EXIT; -} - -CameraProperties::~CameraProperties() -{ - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; -} - - -// Initializes the CameraProperties class -status_t CameraProperties::initialize() -{ - LOG_FUNCTION_NAME; - - status_t ret; - - android::AutoMutex lock(mLock); - - if(mInitialized) - return NO_ERROR; - - ret = loadProperties(); - - if (ret == NO_ERROR) { - mInitialized = 1; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -extern "C" status_t CameraAdapter_Capabilities(CameraProperties::Properties* properties_array, - int starting_camera, int max_camera, int & supported_cameras); - -///Loads all the Camera related properties -status_t CameraProperties::loadProperties() -{ - LOG_FUNCTION_NAME; - - status_t ret = NO_ERROR; - - //Must be re-initialized here, since loadProperties() could potentially be called more than once. - mCamerasSupported = 0; - - // adapter updates capabilities and we update camera count - const status_t err = CameraAdapter_Capabilities(mCameraProps, mCamerasSupported, - MAX_CAMERAS_SUPPORTED, mCamerasSupported); - - if(err != NO_ERROR) { - CAMHAL_LOGE("error while getting capabilities"); - ret = UNKNOWN_ERROR; - } else if (mCamerasSupported == 0) { - CAMHAL_LOGE("camera busy. properties not loaded. num_cameras = %d", mCamerasSupported); - ret = UNKNOWN_ERROR; - } else if (mCamerasSupported > MAX_CAMERAS_SUPPORTED) { - CAMHAL_LOGE("returned too many adapaters"); - ret = UNKNOWN_ERROR; - } else { - CAMHAL_LOGI("num_cameras = %d", mCamerasSupported); - - for (int i = 0; i < mCamerasSupported; i++) { - mCameraProps[i].setSensorIndex(i); - mCameraProps[i].dump(); - } - } - - CAMHAL_LOGV("mCamerasSupported = %d", mCamerasSupported); - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -// Returns the number of Cameras found -int CameraProperties::camerasSupported() -{ - LOG_FUNCTION_NAME; - return mCamerasSupported; -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/Encoder_libjpeg.cpp b/camera/Encoder_libjpeg.cpp deleted file mode 100644 index e11e3bf..0000000 --- a/camera/Encoder_libjpeg.cpp +++ /dev/null @@ -1,543 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file Encoder_libjpeg.cpp -* -* This file encodes a YUV422I buffer to a jpeg -* TODO(XXX): Need to support formats other than yuv422i -* Change interface to pre/post-proc algo framework -* -*/ - -#include "Encoder_libjpeg.h" -#include "NV12_resize.h" -#include "TICameraParameters.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -extern "C" { - #include "jpeglib.h" - #include "jerror.h" -} - -#define ARRAY_SIZE(array) (sizeof((array)) / sizeof((array)[0])) -#define MIN(x,y) ((x < y) ? x : y) - -namespace Ti { -namespace Camera { - -struct integer_string_pair { - unsigned int integer; - const char* string; -}; - -static integer_string_pair degress_to_exif_lut [] = { - // degrees, exif_orientation - {0, "1"}, - {90, "6"}, - {180, "3"}, - {270, "8"}, -}; -struct libjpeg_destination_mgr : jpeg_destination_mgr { - libjpeg_destination_mgr(uint8_t* input, int size); - - uint8_t* buf; - int bufsize; - size_t jpegsize; -}; - -static void libjpeg_init_destination (j_compress_ptr cinfo) { - libjpeg_destination_mgr* dest = (libjpeg_destination_mgr*)cinfo->dest; - - dest->next_output_byte = dest->buf; - dest->free_in_buffer = dest->bufsize; - dest->jpegsize = 0; -} - -static boolean libjpeg_empty_output_buffer(j_compress_ptr cinfo) { - libjpeg_destination_mgr* dest = (libjpeg_destination_mgr*)cinfo->dest; - - dest->next_output_byte = dest->buf; - dest->free_in_buffer = dest->bufsize; - return TRUE; // ? -} - -static void libjpeg_term_destination (j_compress_ptr cinfo) { - libjpeg_destination_mgr* dest = (libjpeg_destination_mgr*)cinfo->dest; - dest->jpegsize = dest->bufsize - dest->free_in_buffer; -} - -libjpeg_destination_mgr::libjpeg_destination_mgr(uint8_t* input, int size) { - this->init_destination = libjpeg_init_destination; - this->empty_output_buffer = libjpeg_empty_output_buffer; - this->term_destination = libjpeg_term_destination; - - this->buf = input; - this->bufsize = size; - - jpegsize = 0; -} - -/* private static functions */ -static void nv21_to_yuv(uint8_t* dst, uint8_t* y, uint8_t* uv, int width) { - if (!dst || !y || !uv) { - return; - } - - while ((width--) > 0) { - uint8_t y0 = y[0]; - uint8_t v0 = uv[0]; - uint8_t u0 = *(uv+1); - dst[0] = y0; - dst[1] = u0; - dst[2] = v0; - dst += 3; - y++; - if(!(width % 2)) uv+=2; - } -} - -static void uyvy_to_yuv(uint8_t* dst, uint32_t* src, int width) { - if (!dst || !src) { - return; - } - - if (width % 2) { - return; // not supporting odd widths - } - - // currently, neon routine only supports multiple of 16 width - if (width % 16) { - while ((width-=2) >= 0) { - uint8_t u0 = (src[0] >> 0) & 0xFF; - uint8_t y0 = (src[0] >> 8) & 0xFF; - uint8_t v0 = (src[0] >> 16) & 0xFF; - uint8_t y1 = (src[0] >> 24) & 0xFF; - dst[0] = y0; - dst[1] = u0; - dst[2] = v0; - dst[3] = y1; - dst[4] = u0; - dst[5] = v0; - dst += 6; - src++; - } - } else { - int n = width; - asm volatile ( - " pld [%[src], %[src_stride], lsl #2] \n\t" - " cmp %[n], #16 \n\t" - " blt 5f \n\t" - "0: @ 16 pixel swap \n\t" - " vld2.8 {q0, q1} , [%[src]]! @ q0 = uv q1 = y \n\t" - " vuzp.8 q0, q2 @ d0 = u d4 = v \n\t" - " vmov d1, d0 @ q0 = u0u1u2..u0u1u2... \n\t" - " vmov d5, d4 @ q2 = v0v1v2..v0v1v2... \n\t" - " vzip.8 d0, d1 @ q0 = u0u0u1u1u2u2... \n\t" - " vzip.8 d4, d5 @ q2 = v0v0v1v1v2v2... \n\t" - " vswp q0, q1 @ now q0 = y q1 = u q2 = v \n\t" - " vst3.8 {d0,d2,d4},[%[dst]]! \n\t" - " vst3.8 {d1,d3,d5},[%[dst]]! \n\t" - " sub %[n], %[n], #16 \n\t" - " cmp %[n], #16 \n\t" - " bge 0b \n\t" - "5: @ end \n\t" -#ifdef NEEDS_ARM_ERRATA_754319_754320 - " vmov s0,s0 @ add noop for errata item \n\t" -#endif - : [dst] "+r" (dst), [src] "+r" (src), [n] "+r" (n) - : [src_stride] "r" (width) - : "cc", "memory", "q0", "q1", "q2" - ); - } -} - -static void yuyv_to_yuv(uint8_t* dst, uint32_t* src, int width) { - if (!dst || !src) { - return; - } - - if (width % 2) { - return; // not supporting odd widths - } - - // currently, neon routine only supports multiple of 16 width - if (width % 16) { - while ((width-=2) >= 0) { - uint8_t y0 = (src[0] >> 0) & 0xFF; - uint8_t u0 = (src[0] >> 8) & 0xFF; - uint8_t y1 = (src[0] >> 16) & 0xFF; - uint8_t v0 = (src[0] >> 24) & 0xFF; - dst[0] = y0; - dst[1] = u0; - dst[2] = v0; - dst[3] = y1; - dst[4] = u0; - dst[5] = v0; - dst += 6; - src++; - } - } else { - int n = width; - asm volatile ( - " pld [%[src], %[src_stride], lsl #2] \n\t" - " cmp %[n], #16 \n\t" - " blt 5f \n\t" - "0: @ 16 pixel swap \n\t" - " vld2.8 {q0, q1} , [%[src]]! @ q0 = yyyy.. q1 = uvuv.. \n\t" - " vuzp.8 q1, q2 @ d2 = u d4 = v \n\t" - " vmov d3, d2 @ q1 = u0u1u2..u0u1u2... \n\t" - " vmov d5, d4 @ q2 = v0v1v2..v0v1v2... \n\t" - " vzip.8 d2, d3 @ q1 = u0u0u1u1u2u2... \n\t" - " vzip.8 d4, d5 @ q2 = v0v0v1v1v2v2... \n\t" - " @ now q0 = y q1 = u q2 = v \n\t" - " vst3.8 {d0,d2,d4},[%[dst]]! \n\t" - " vst3.8 {d1,d3,d5},[%[dst]]! \n\t" - " sub %[n], %[n], #16 \n\t" - " cmp %[n], #16 \n\t" - " bge 0b \n\t" - "5: @ end \n\t" -#ifdef NEEDS_ARM_ERRATA_754319_754320 - " vmov s0,s0 @ add noop for errata item \n\t" -#endif - : [dst] "+r" (dst), [src] "+r" (src), [n] "+r" (n) - : [src_stride] "r" (width) - : "cc", "memory", "q0", "q1", "q2" - ); - } -} - -static void resize_nv12(Encoder_libjpeg::params* params, uint8_t* dst_buffer) { - structConvImage o_img_ptr, i_img_ptr; - - if (!params || !dst_buffer) { - return; - } - - //input - i_img_ptr.uWidth = params->in_width; - i_img_ptr.uStride = i_img_ptr.uWidth; - i_img_ptr.uHeight = params->in_height; - i_img_ptr.eFormat = IC_FORMAT_YCbCr420_lp; - i_img_ptr.imgPtr = (uint8_t*) params->src; - i_img_ptr.clrPtr = i_img_ptr.imgPtr + (i_img_ptr.uWidth * i_img_ptr.uHeight); - i_img_ptr.uOffset = 0; - - //ouput - o_img_ptr.uWidth = params->out_width; - o_img_ptr.uStride = o_img_ptr.uWidth; - o_img_ptr.uHeight = params->out_height; - o_img_ptr.eFormat = IC_FORMAT_YCbCr420_lp; - o_img_ptr.imgPtr = dst_buffer; - o_img_ptr.clrPtr = o_img_ptr.imgPtr + (o_img_ptr.uWidth * o_img_ptr.uHeight); - o_img_ptr.uOffset = 0; - - VT_resizeFrame_Video_opt2_lp(&i_img_ptr, &o_img_ptr, NULL, 0); -} - -/* public static functions */ -const char* ExifElementsTable::degreesToExifOrientation(unsigned int degrees) { - for (unsigned int i = 0; i < ARRAY_SIZE(degress_to_exif_lut); i++) { - if (degrees == degress_to_exif_lut[i].integer) { - return degress_to_exif_lut[i].string; - } - } - return NULL; -} - -void ExifElementsTable::stringToRational(const char* str, unsigned int* num, unsigned int* den) { - int len; - char * tempVal = NULL; - - if (str != NULL) { - len = strlen(str); - tempVal = (char*) malloc( sizeof(char) * (len + 1)); - } - - if (tempVal != NULL) { - // convert the decimal string into a rational - size_t den_len; - char *ctx; - unsigned int numerator = 0; - unsigned int denominator = 0; - char* temp = NULL; - - memset(tempVal, '\0', len + 1); - strncpy(tempVal, str, len); - temp = strtok_r(tempVal, ".", &ctx); - - if (temp != NULL) - numerator = atoi(temp); - - if (!numerator) - numerator = 1; - - temp = strtok_r(NULL, ".", &ctx); - if (temp != NULL) { - den_len = strlen(temp); - if(HUGE_VAL == den_len ) { - den_len = 0; - } - - denominator = static_cast(pow(10, den_len)); - numerator = numerator * denominator + atoi(temp); - } else { - denominator = 1; - } - - free(tempVal); - - *num = numerator; - *den = denominator; - } -} - -bool ExifElementsTable::isAsciiTag(const char* tag) { - // TODO(XXX): Add tags as necessary - return (strcmp(tag, TAG_GPS_PROCESSING_METHOD) == 0); -} - -void ExifElementsTable::insertExifToJpeg(unsigned char* jpeg, size_t jpeg_size) { - ReadMode_t read_mode = (ReadMode_t)(READ_METADATA | READ_IMAGE); - - ResetJpgfile(); - if (ReadJpegSectionsFromBuffer(jpeg, jpeg_size, read_mode)) { - jpeg_opened = true; -#ifdef ANDROID_API_JB_OR_LATER - create_EXIF(table, exif_tag_count, gps_tag_count, has_datetime_tag); -#else - create_EXIF(table, exif_tag_count, gps_tag_count); -#endif - } -} - -status_t ExifElementsTable::insertExifThumbnailImage(const char* thumb, int len) { - status_t ret = NO_ERROR; - - if ((len > 0) && jpeg_opened) { - ret = ReplaceThumbnailFromBuffer(thumb, len) ? NO_ERROR : UNKNOWN_ERROR; - CAMHAL_LOGDB("insertExifThumbnailImage. ReplaceThumbnail(). ret=%d", ret); - } - - return ret; -} - -void ExifElementsTable::saveJpeg(unsigned char* jpeg, size_t jpeg_size) { - if (jpeg_opened) { - WriteJpegToBuffer(jpeg, jpeg_size); - DiscardData(); - jpeg_opened = false; - } -} - -/* public functions */ -ExifElementsTable::~ExifElementsTable() { - int num_elements = gps_tag_count + exif_tag_count; - - for (int i = 0; i < num_elements; i++) { - if (table[i].Value) { - free(table[i].Value); - } - } - - if (jpeg_opened) { - DiscardData(); - } -} - -status_t ExifElementsTable::insertElement(const char* tag, const char* value) { - unsigned int value_length = 0; - status_t ret = NO_ERROR; - - if (!value || !tag) { - return -EINVAL; - } - - if (position >= MAX_EXIF_TAGS_SUPPORTED) { - CAMHAL_LOGEA("Max number of EXIF elements already inserted"); - return NO_MEMORY; - } - - if (isAsciiTag(tag)) { - value_length = sizeof(ExifAsciiPrefix) + strlen(value + sizeof(ExifAsciiPrefix)); - } else { - value_length = strlen(value); - } - - if (IsGpsTag(tag)) { - table[position].GpsTag = TRUE; - table[position].Tag = GpsTagNameToValue(tag); - gps_tag_count++; - } else { - table[position].GpsTag = FALSE; - table[position].Tag = TagNameToValue(tag); - exif_tag_count++; - - if (strcmp(tag, TAG_DATETIME) == 0) { -#ifdef ANDROID_API_JB_OR_LATER - has_datetime_tag = true; -#else - // jhead isn't taking datetime tag...this is a WA - ImageInfo.numDateTimeTags = 1; - memcpy(ImageInfo.DateTime, value, - MIN(ARRAY_SIZE(ImageInfo.DateTime), value_length + 1)); -#endif - } - } - - table[position].DataLength = 0; - table[position].Value = (char*) malloc(sizeof(char) * (value_length + 1)); - - if (table[position].Value) { - memcpy(table[position].Value, value, value_length + 1); - table[position].DataLength = value_length + 1; - } - - position++; - return ret; -} - -/* private member functions */ -size_t Encoder_libjpeg::encode(params* input) { - jpeg_compress_struct cinfo; - jpeg_error_mgr jerr; - jpeg_destination_mgr jdest; - uint8_t* src = NULL, *resize_src = NULL; - uint8_t* row_tmp = NULL; - uint8_t* row_src = NULL; - uint8_t* row_uv = NULL; // used only for NV12 - int out_width = 0, in_width = 0; - int out_height = 0, in_height = 0; - int bpp = 2; // for uyvy - int right_crop = 0, start_offset = 0; - - if (!input) { - return 0; - } - - out_width = input->out_width; - in_width = input->in_width; - out_height = input->out_height; - in_height = input->in_height; - right_crop = input->right_crop; - start_offset = input->start_offset; - src = input->src; - input->jpeg_size = 0; - - libjpeg_destination_mgr dest_mgr(input->dst, input->dst_size); - - // param check... - if ((in_width < 2) || (out_width < 2) || (in_height < 2) || (out_height < 2) || - (src == NULL) || (input->dst == NULL) || (input->quality < 1) || (input->src_size < 1) || - (input->dst_size < 1) || (input->format == NULL)) { - goto exit; - } - - if (strcmp(input->format, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { - bpp = 1; - if ((in_width != out_width) || (in_height != out_height)) { - resize_src = (uint8_t*) malloc(input->dst_size); - resize_nv12(input, resize_src); - if (resize_src) src = resize_src; - } - } else if (strcmp(input->format, android::CameraParameters::PIXEL_FORMAT_YUV422I) && - strcmp(input->format, TICameraParameters::PIXEL_FORMAT_YUV422I_UYVY)) { - // we currently only support yuv422i and yuv420sp - CAMHAL_LOGEB("Encoder: format not supported: %s", input->format); - goto exit; - } else if ((in_width != out_width) || (in_height != out_height)) { - CAMHAL_LOGEB("Encoder: resizing is not supported for this format: %s", input->format); - goto exit; - } - - cinfo.err = jpeg_std_error(&jerr); - - jpeg_create_compress(&cinfo); - - CAMHAL_LOGDB("encoding... \n\t" - "width: %d \n\t" - "height:%d \n\t" - "dest %p \n\t" - "dest size:%d \n\t" - "mSrc %p \n\t" - "format: %s", - out_width, out_height, input->dst, - input->dst_size, src, input->format); - - cinfo.dest = &dest_mgr; - cinfo.image_width = out_width - right_crop; - cinfo.image_height = out_height; - cinfo.input_components = 3; - cinfo.in_color_space = JCS_YCbCr; - cinfo.input_gamma = 1; - - jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, input->quality, TRUE); - cinfo.dct_method = JDCT_IFAST; - - jpeg_start_compress(&cinfo, TRUE); - - row_tmp = (uint8_t*)malloc((out_width - right_crop) * 3); - row_src = src + start_offset; - row_uv = src + out_width * out_height * bpp; - - while ((cinfo.next_scanline < cinfo.image_height) && !mCancelEncoding) { - JSAMPROW row[1]; /* pointer to JSAMPLE row[s] */ - - // convert input yuv format to yuv444 - if (strcmp(input->format, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { - nv21_to_yuv(row_tmp, row_src, row_uv, out_width - right_crop); - } else if (strcmp(input->format, TICameraParameters::PIXEL_FORMAT_YUV422I_UYVY) == 0) { - uyvy_to_yuv(row_tmp, (uint32_t*)row_src, out_width - right_crop); - } else if (strcmp(input->format, android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { - yuyv_to_yuv(row_tmp, (uint32_t*)row_src, out_width - right_crop); - } - - row[0] = row_tmp; - jpeg_write_scanlines(&cinfo, row, 1); - row_src = row_src + out_width*bpp; - - // move uv row if input format needs it - if (strcmp(input->format, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { - if (!(cinfo.next_scanline % 2)) - row_uv = row_uv + out_width * bpp; - } - } - - // no need to finish encoding routine if we are prematurely stopping - // we will end up crashing in dest_mgr since data is incomplete - if (!mCancelEncoding) - jpeg_finish_compress(&cinfo); - jpeg_destroy_compress(&cinfo); - - if (resize_src) free(resize_src); - if (row_tmp) free(row_tmp); - - exit: - input->jpeg_size = dest_mgr.jpegsize; - return dest_mgr.jpegsize; -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/MemoryManager.cpp b/camera/MemoryManager.cpp deleted file mode 100644 index d466f52..0000000 --- a/camera/MemoryManager.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "CameraHal.h" -#include "TICameraParameters.h" - -extern "C" { - -//#include -//#include - - -}; - -namespace Ti { -namespace Camera { - -///@todo Move these constants to a common header file, preferably in tiler.h -#define STRIDE_8BIT (4 * 1024) -#define STRIDE_16BIT (4 * 1024) - -#define ALLOCATION_2D 2 - -///Utility Macro Declarations - -/*--------------------MemoryManager Class STARTS here-----------------------------*/ -MemoryManager::MemoryManager() { - mIonFd = -1; -} - -MemoryManager::~MemoryManager() { - if ( mIonFd >= 0 ) { - ion_close(mIonFd); - mIonFd = -1; - } -} - -status_t MemoryManager::initialize() { - if ( mIonFd == -1 ) { - mIonFd = ion_open(); - if ( mIonFd < 0 ) { - CAMHAL_LOGE("ion_open() failed, error: %d", mIonFd); - mIonFd = -1; - return NO_INIT; - } - } - - return OK; -} - -CameraBuffer* MemoryManager::allocateBufferList(int width, int height, const char* format, int &size, int numBufs) -{ - LOG_FUNCTION_NAME; - - CAMHAL_ASSERT(mIonFd != -1); - - ///We allocate numBufs+1 because the last entry will be marked NULL to indicate end of array, which is used when freeing - ///the buffers - const uint numArrayEntriesC = (uint)(numBufs+1); - - ///Allocate a buffer array - CameraBuffer *buffers = new CameraBuffer [numArrayEntriesC]; - if(!buffers) { - CAMHAL_LOGEB("Allocation failed when creating buffers array of %d CameraBuffer elements", numArrayEntriesC); - goto error; - } - - ///Initialize the array with zeros - this will help us while freeing the array in case of error - ///If a value of an array element is NULL, it means we didnt allocate it - memset(buffers, 0, sizeof(CameraBuffer) * numArrayEntriesC); - - //2D Allocations are not supported currently - if(size != 0) { - struct ion_handle *handle; - int mmap_fd; - size_t stride; - - ///1D buffers - for (int i = 0; i < numBufs; i++) { - unsigned char *data; - int ret = ion_alloc(mIonFd, size, 0, 1 << ION_HEAP_TYPE_CARVEOUT, - &handle); - if((ret < 0) || ((int)handle == -ENOMEM)) { - ret = ion_alloc_tiler(mIonFd, (size_t)size, 1, TILER_PIXEL_FMT_PAGE, - OMAP_ION_HEAP_TILER_MASK, &handle, &stride); - } - - if((ret < 0) || ((int)handle == -ENOMEM)) { - CAMHAL_LOGEB("FAILED to allocate ion buffer of size=%d. ret=%d(0x%x)", size, ret, ret); - goto error; - } - - CAMHAL_LOGDB("Before mapping, handle = %p, nSize = %d", handle, size); - if ((ret = ion_map(mIonFd, handle, size, PROT_READ | PROT_WRITE, MAP_SHARED, 0, - &data, &mmap_fd)) < 0) { - CAMHAL_LOGEB("Userspace mapping of ION buffers returned error %d", ret); - ion_free(mIonFd, handle); - goto error; - } - - buffers[i].type = CAMERA_BUFFER_ION; - buffers[i].opaque = data; - buffers[i].mapped = data; - buffers[i].ion_handle = handle; - buffers[i].ion_fd = mIonFd; - buffers[i].fd = mmap_fd; - buffers[i].size = size; - - } - } - - LOG_FUNCTION_NAME_EXIT; - - return buffers; - -error: - - CAMHAL_LOGE("Freeing buffers already allocated after error occurred"); - if(buffers) - freeBufferList(buffers); - - if ( NULL != mErrorNotifier.get() ) - mErrorNotifier->errorNotify(-ENOMEM); - LOG_FUNCTION_NAME_EXIT; - - return NULL; -} - -CameraBuffer* MemoryManager::getBufferList(int *numBufs) { - LOG_FUNCTION_NAME; - if (numBufs) *numBufs = -1; - - return NULL; -} - -//TODO: Get needed data to map tiler buffers -//Return dummy data for now -uint32_t * MemoryManager::getOffsets() -{ - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return NULL; -} - -int MemoryManager::getFd() -{ - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return -1; -} - -int MemoryManager::freeBufferList(CameraBuffer *buffers) -{ - status_t ret = NO_ERROR; - LOG_FUNCTION_NAME; - - int i; - - if(!buffers) - { - CAMHAL_LOGEA("NULL pointer passed to freebuffer"); - LOG_FUNCTION_NAME_EXIT; - return BAD_VALUE; - } - - i = 0; - while(buffers[i].type == CAMERA_BUFFER_ION) - { - if(buffers[i].size) - { - munmap(buffers[i].opaque, buffers[i].size); - close(buffers[i].fd); - ion_free(mIonFd, buffers[i].ion_handle); - } - else - { - CAMHAL_LOGEA("Not a valid Memory Manager buffer"); - } - i++; - } - - delete [] buffers; - - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -status_t MemoryManager::setErrorHandler(ErrorNotifier *errorNotifier) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( NULL == errorNotifier ) - { - CAMHAL_LOGEA("Invalid Error Notifier reference"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) - { - mErrorNotifier = errorNotifier; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -} // namespace Camera -} // namespace Ti - - -/*--------------------MemoryManager Class ENDS here-----------------------------*/ diff --git a/camera/NV12_resize.cpp b/camera/NV12_resize.cpp deleted file mode 100644 index 971ee38..0000000 --- a/camera/NV12_resize.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "NV12_resize.h" - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "NV12_resize" - -#define STRIDE 4096 - -/*========================================================================== -* Function Name : VT_resizeFrame_Video_opt2_lp -* -* Description : Resize a yuv frame. -* -* Input(s) : input_img_ptr -> Input Image Structure -* : output_img_ptr -> Output Image Structure -* : cropout -> crop structure -* -* Value Returned : mmBool -> FALSE on error TRUE on success -* NOTE: -* Not tested for crop funtionallity. -* faster version. -============================================================================*/ -mmBool -VT_resizeFrame_Video_opt2_lp( - structConvImage* i_img_ptr, /* Points to the input image */ - structConvImage* o_img_ptr, /* Points to the output image */ - IC_rect_type* cropout, /* how much to resize to in final image */ - mmUint16 dummy /* Transparent pixel value */ - ) { - LOG_FUNCTION_NAME; - - mmUint16 row,col; - mmUint32 resizeFactorX; - mmUint32 resizeFactorY; - - mmUint16 x, y; - - mmUchar* ptr8; - mmUchar *ptr8Cb, *ptr8Cr; - - mmUint16 xf, yf; - mmUchar* inImgPtrY; - mmUchar* inImgPtrU; - mmUchar* inImgPtrV; - mmUint32 cox, coy, codx, cody; - mmUint16 idx,idy, idxC; - - if ( i_img_ptr->uWidth == o_img_ptr->uWidth ) { - if ( i_img_ptr->uHeight == o_img_ptr->uHeight ) { - CAMHAL_LOGV("************************f(i_img_ptr->uHeight == o_img_ptr->uHeight) are same *********************\n"); - CAMHAL_LOGV("************************(i_img_ptr->width == %d" , i_img_ptr->uWidth ); - CAMHAL_LOGV("************************(i_img_ptr->uHeight == %d" , i_img_ptr->uHeight ); - CAMHAL_LOGV("************************(o_img_ptr->width == %d" ,o_img_ptr->uWidth ); - CAMHAL_LOGV("************************(o_img_ptr->uHeight == %d" , o_img_ptr->uHeight ); - } - } - - if ( !i_img_ptr || !i_img_ptr->imgPtr || !o_img_ptr || !o_img_ptr->imgPtr ) { - CAMHAL_LOGE("Image Point NULL"); - return false; - } - - inImgPtrY = (mmUchar *) i_img_ptr->imgPtr + i_img_ptr->uOffset; - inImgPtrU = (mmUchar *) i_img_ptr->clrPtr + i_img_ptr->uOffset/2; - inImgPtrV = (mmUchar*)inImgPtrU + 1; - - if ( !cropout ) { - cox = 0; - coy = 0; - codx = o_img_ptr->uWidth; - cody = o_img_ptr->uHeight; - } else { - cox = cropout->x; - coy = cropout->y; - codx = cropout->uWidth; - cody = cropout->uHeight; - } - idx = i_img_ptr->uWidth; - idy = i_img_ptr->uHeight; - - /* make sure valid input size */ - if ( idx < 1 || idy < 1 || i_img_ptr->uStride < 1 ) { - CAMHAL_LOGE("idx or idy less then 1 idx = %d idy = %d stride = %d", idx, idy, i_img_ptr->uStride); - return false; - } - - resizeFactorX = ((idx-1)<<9) / codx; - resizeFactorY = ((idy-1)<<9) / cody; - - if( i_img_ptr->eFormat != IC_FORMAT_YCbCr420_lp || - o_img_ptr->eFormat != IC_FORMAT_YCbCr420_lp ) { - CAMHAL_LOGE("eFormat not supported"); - return false; - } - - ptr8 = (mmUchar*)o_img_ptr->imgPtr + cox + coy*o_img_ptr->uWidth; - - ////////////////////////////for Y////////////////////////// - for ( row = 0; row < cody; row++ ) { - mmUchar *pu8Yrow1 = NULL; - mmUchar *pu8Yrow2 = NULL; - y = (mmUint16) ((mmUint32) (row*resizeFactorY) >> 9); - yf = (mmUchar) ((mmUint32)((row*resizeFactorY) >> 6) & 0x7); - pu8Yrow1 = inImgPtrY + (y) * i_img_ptr->uStride; - pu8Yrow2 = pu8Yrow1 + i_img_ptr->uStride; - - for ( col = 0; col < codx; col++ ) { - mmUchar in11, in12, in21, in22; - mmUchar *pu8ptr1 = NULL; - mmUchar *pu8ptr2 = NULL; - mmUchar w; - mmUint16 accum_1; - //mmUint32 accum_W; - - x = (mmUint16) ((mmUint32) (col*resizeFactorX) >> 9); - xf = (mmUchar) ((mmUint32) ((col*resizeFactorX) >> 6) & 0x7); - - //accum_W = 0; - accum_1 = 0; - - pu8ptr1 = pu8Yrow1 + (x); - pu8ptr2 = pu8Yrow2 + (x); - - /* A pixel */ - //in = *(inImgPtrY + (y)*idx + (x)); - in11 = *(pu8ptr1); - - w = bWeights[xf][yf][0]; - accum_1 = (w * in11); - //accum_W += (w); - - /* B pixel */ - //in = *(inImgPtrY + (y)*idx + (x+1)); - in12 = *(pu8ptr1+1); - w = bWeights[xf][yf][1]; - accum_1 += (w * in12); - //accum_W += (w); - - /* C pixel */ - //in = *(inImgPtrY + (y+1)*idx + (x)); - in21 = *(pu8ptr2); - w = bWeights[xf][yf][3]; - accum_1 += (w * in21); - //accum_W += (w); - - /* D pixel */ - //in = *(inImgPtrY + (y+1)*idx + (x+1)); - in22 = *(pu8ptr2+1); - w = bWeights[xf][yf][2]; - accum_1 += (w * in22); - //accum_W += (w); - - /* divide by sum of the weights */ - //accum_1 /= (accum_W); - //accum_1 = (accum_1/64); - accum_1 = (accum_1>>6); - *ptr8 = (mmUchar)accum_1 ; - - ptr8++; - } - ptr8 = ptr8 + (o_img_ptr->uStride - codx); - } - ////////////////////////////for Y////////////////////////// - - ///////////////////////////////for Cb-Cr////////////////////// - - ptr8Cb = (mmUchar*)o_img_ptr->clrPtr + cox + coy*o_img_ptr->uWidth; - - ptr8Cr = (mmUchar*)(ptr8Cb+1); - - idxC = (idx>>1); - for ( row = 0; row < (((cody)>>1)); row++ ) { - mmUchar *pu8Cbr1 = NULL; - mmUchar *pu8Cbr2 = NULL; - mmUchar *pu8Crr1 = NULL; - mmUchar *pu8Crr2 = NULL; - - y = (mmUint16) ((mmUint32) (row*resizeFactorY) >> 9); - yf = (mmUchar) ((mmUint32)((row*resizeFactorY) >> 6) & 0x7); - - pu8Cbr1 = inImgPtrU + (y) * i_img_ptr->uStride; - pu8Cbr2 = pu8Cbr1 + i_img_ptr->uStride; - pu8Crr1 = inImgPtrV + (y) * i_img_ptr->uStride; - pu8Crr2 = pu8Crr1 + i_img_ptr->uStride; - - for ( col = 0; col < (((codx)>>1)); col++ ) { - mmUchar in11, in12, in21, in22; - mmUchar *pu8Cbc1 = NULL; - mmUchar *pu8Cbc2 = NULL; - mmUchar *pu8Crc1 = NULL; - mmUchar *pu8Crc2 = NULL; - - mmUchar w; - mmUint16 accum_1Cb, accum_1Cr; - //mmUint32 accum_WCb, accum_WCr; - - x = (mmUint16) ((mmUint32) (col*resizeFactorX) >> 9); - xf = (mmUchar) ((mmUint32) ((col*resizeFactorX) >> 6) & 0x7); - - //accum_WCb = accum_WCr = 0; - accum_1Cb = accum_1Cr = 0; - - pu8Cbc1 = pu8Cbr1 + (x*2); - pu8Cbc2 = pu8Cbr2 + (x*2); - pu8Crc1 = pu8Crr1 + (x*2); - pu8Crc2 = pu8Crr2 + (x*2); - - /* A pixel */ - w = bWeights[xf][yf][0]; - - in11 = *(pu8Cbc1); - accum_1Cb = (w * in11); - // accum_WCb += (w); - - in11 = *(pu8Crc1); - accum_1Cr = (w * in11); - //accum_WCr += (w); - - /* B pixel */ - w = bWeights[xf][yf][1]; - - in12 = *(pu8Cbc1+2); - accum_1Cb += (w * in12); - //accum_WCb += (w); - - in12 = *(pu8Crc1+2); - accum_1Cr += (w * in12); - //accum_WCr += (w); - - /* C pixel */ - w = bWeights[xf][yf][3]; - - in21 = *(pu8Cbc2); - accum_1Cb += (w * in21); - //accum_WCb += (w); - - in21 = *(pu8Crc2); - accum_1Cr += (w * in21); - //accum_WCr += (w); - - /* D pixel */ - w = bWeights[xf][yf][2]; - - in22 = *(pu8Cbc2+2); - accum_1Cb += (w * in22); - //accum_WCb += (w); - - in22 = *(pu8Crc2+2); - accum_1Cr += (w * in22); - //accum_WCr += (w); - - /* divide by sum of the weights */ - //accum_1Cb /= (accum_WCb); - accum_1Cb = (accum_1Cb>>6); - *ptr8Cb = (mmUchar)accum_1Cb ; - - accum_1Cr = (accum_1Cr >> 6); - *ptr8Cr = (mmUchar)accum_1Cr ; - - ptr8Cb++; - ptr8Cr++; - - ptr8Cb++; - ptr8Cr++; - } - ptr8Cb = ptr8Cb + (o_img_ptr->uStride-codx); - ptr8Cr = ptr8Cr + (o_img_ptr->uStride-codx); - } - ///////////////////For Cb- Cr//////////////////////////////////////// - - CAMHAL_LOGV("success"); - return true; -} diff --git a/camera/OMXCameraAdapter/OMX3A.cpp b/camera/OMXCameraAdapter/OMX3A.cpp deleted file mode 100644 index 040d816..0000000 --- a/camera/OMXCameraAdapter/OMX3A.cpp +++ /dev/null @@ -1,2005 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMX3A.cpp -* -* This file contains functionality for handling 3A configurations. -* -*/ - -#include "CameraHal.h" -#include "OMXCameraAdapter.h" -#include "ErrorUtils.h" - -#include - -#define METERING_AREAS_RANGE 0xFF - -static const char PARAM_SEP[] = ","; - -namespace Ti { -namespace Camera { - -const SceneModesEntry* OMXCameraAdapter::getSceneModeEntry(const char* name, - OMX_SCENEMODETYPE scene) { - const SceneModesEntry* cameraLUT = NULL; - const SceneModesEntry* entry = NULL; - unsigned int numEntries = 0; - - // 1. Find camera's scene mode LUT - for (unsigned int i = 0; i < ARRAY_SIZE(CameraToSensorModesLUT); i++) { - if (strcmp(CameraToSensorModesLUT[i].name, name) == 0) { - cameraLUT = CameraToSensorModesLUT[i].Table; - numEntries = CameraToSensorModesLUT[i].size; - break; - } - } - - // 2. Find scene mode entry in table - if (!cameraLUT) { - goto EXIT; - } - - for (unsigned int i = 0; i < numEntries; i++) { - if(cameraLUT[i].scene == scene) { - entry = cameraLUT + i; - break; - } - } - EXIT: - return entry; -} - -status_t OMXCameraAdapter::setParameters3A(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state) -{ - status_t ret = NO_ERROR; - int mode = 0; - const char *str = NULL; - int varint = 0; - BaseCameraAdapter::AdapterState nextState; - BaseCameraAdapter::getNextState(nextState); - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(m3ASettingsUpdateLock); - - str = params.get(android::CameraParameters::KEY_SCENE_MODE); - mode = getLUTvalue_HALtoOMX( str, SceneLUT); - if ( mFirstTimeInit || ((str != NULL) && ( mParameters3A.SceneMode != mode )) ) { - if ( 0 <= mode ) { - mParameters3A.SceneMode = mode; - if ((mode == OMX_Manual) && (mFirstTimeInit == false)){//Auto mode - mFirstTimeInit = true; - } - if ((mode != OMX_Manual) && - (state & PREVIEW_ACTIVE) && !(nextState & CAPTURE_ACTIVE)) { - // if setting preset scene mode, previewing, and not in the middle of capture - // set preset scene mode immediately instead of in next FBD - // for feedback params to work properly since they need to be read - // by application in subsequent getParameters() - ret |= setScene(mParameters3A); - // re-apply EV compensation after setting scene mode since it probably reset it - if(mParameters3A.EVCompensation) { - setEVCompensation(mParameters3A); - } - return ret; - } else { - mPending3Asettings |= SetSceneMode; - } - } else { - mParameters3A.SceneMode = OMX_Manual; - } - CAMHAL_LOGVB("SceneMode %d", mParameters3A.SceneMode); - } - -#ifdef OMAP_ENHANCEMENT - if ( (str = params.get(TICameraParameters::KEY_EXPOSURE_MODE)) != NULL ) { - mode = getLUTvalue_HALtoOMX(str, ExpLUT); - if ( mParameters3A.Exposure != mode ) { - // If either the new or the old exposure mode is manual set also - // the SetManualExposure flag to call setManualExposureVal where - // the auto gain and exposure flags are configured - if ( mParameters3A.Exposure == OMX_ExposureControlOff || - mode == OMX_ExposureControlOff ) { - mPending3Asettings |= SetManualExposure; - } - mParameters3A.Exposure = mode; - CAMHAL_LOGDB("Exposure mode %d", mode); - if ( 0 <= mParameters3A.Exposure ) { - mPending3Asettings |= SetExpMode; - } - } - if ( mode == OMX_ExposureControlOff ) { - mode = params.getInt(TICameraParameters::KEY_MANUAL_EXPOSURE); - if ( mParameters3A.ManualExposure != mode ) { - mParameters3A.ManualExposure = mode; - CAMHAL_LOGDB("Manual Exposure = %d", mode); - mPending3Asettings |= SetManualExposure; - } - mode = params.getInt(TICameraParameters::KEY_MANUAL_EXPOSURE_RIGHT); - if ( mParameters3A.ManualExposureRight != mode ) { - mParameters3A.ManualExposureRight = mode; - CAMHAL_LOGDB("Manual Exposure right = %d", mode); - mPending3Asettings |= SetManualExposure; - } - mode = params.getInt(TICameraParameters::KEY_MANUAL_GAIN_ISO); - if ( mParameters3A.ManualGain != mode ) { - mParameters3A.ManualGain = mode; - CAMHAL_LOGDB("Manual Gain = %d", mode); - mPending3Asettings |= SetManualExposure; - } - mode = params.getInt(TICameraParameters::KEY_MANUAL_GAIN_ISO_RIGHT); - if ( mParameters3A.ManualGainRight != mode ) { - mParameters3A.ManualGainRight = mode; - CAMHAL_LOGDB("Manual Gain right = %d", mode); - mPending3Asettings |= SetManualExposure; - } - } - } -#endif - - str = params.get(android::CameraParameters::KEY_WHITE_BALANCE); - mode = getLUTvalue_HALtoOMX( str, WBalLUT); - if (mFirstTimeInit || ((str != NULL) && (mode != mParameters3A.WhiteBallance))) - { - mParameters3A.WhiteBallance = mode; - CAMHAL_LOGDB("Whitebalance mode %d", mode); - if ( 0 <= mParameters3A.WhiteBallance ) - { - mPending3Asettings |= SetWhiteBallance; - } - } - -#ifdef OMAP_ENHANCEMENT - varint = params.getInt(TICameraParameters::KEY_CONTRAST); - if ( 0 <= varint ) - { - if ( mFirstTimeInit || - ( (mParameters3A.Contrast + CONTRAST_OFFSET) != varint ) ) - { - mParameters3A.Contrast = varint - CONTRAST_OFFSET; - CAMHAL_LOGDB("Contrast %d", mParameters3A.Contrast); - mPending3Asettings |= SetContrast; - } - } - - varint = params.getInt(TICameraParameters::KEY_SHARPNESS); - if ( 0 <= varint ) - { - if ( mFirstTimeInit || - ((mParameters3A.Sharpness + SHARPNESS_OFFSET) != varint )) - { - mParameters3A.Sharpness = varint - SHARPNESS_OFFSET; - CAMHAL_LOGDB("Sharpness %d", mParameters3A.Sharpness); - mPending3Asettings |= SetSharpness; - } - } - - varint = params.getInt(TICameraParameters::KEY_SATURATION); - if ( 0 <= varint ) - { - if ( mFirstTimeInit || - ((mParameters3A.Saturation + SATURATION_OFFSET) != varint ) ) - { - mParameters3A.Saturation = varint - SATURATION_OFFSET; - CAMHAL_LOGDB("Saturation %d", mParameters3A.Saturation); - mPending3Asettings |= SetSaturation; - } - } - - varint = params.getInt(TICameraParameters::KEY_BRIGHTNESS); - if ( 0 <= varint ) - { - if ( mFirstTimeInit || - (( mParameters3A.Brightness != varint )) ) - { - mParameters3A.Brightness = (unsigned) varint; - CAMHAL_LOGDB("Brightness %d", mParameters3A.Brightness); - mPending3Asettings |= SetBrightness; - } - } -#endif - - str = params.get(android::CameraParameters::KEY_ANTIBANDING); - mode = getLUTvalue_HALtoOMX(str,FlickerLUT); - if ( mFirstTimeInit || ( ( str != NULL ) && ( mParameters3A.Flicker != mode ) )) - { - mParameters3A.Flicker = mode; - CAMHAL_LOGDB("Flicker %d", mParameters3A.Flicker); - if ( 0 <= mParameters3A.Flicker ) - { - mPending3Asettings |= SetFlicker; - } - } - -#ifdef OMAP_ENHANCEMENT - str = params.get(TICameraParameters::KEY_ISO); - mode = getLUTvalue_HALtoOMX(str, IsoLUT); - CAMHAL_LOGVB("ISO mode arrived in HAL : %s", str); - if ( mFirstTimeInit || ( ( str != NULL ) && ( mParameters3A.ISO != mode )) ) - { - mParameters3A.ISO = mode; - CAMHAL_LOGDB("ISO %d", mParameters3A.ISO); - if ( 0 <= mParameters3A.ISO ) - { - mPending3Asettings |= SetISO; - } - } -#endif - - str = params.get(android::CameraParameters::KEY_FOCUS_MODE); - mode = getLUTvalue_HALtoOMX(str, FocusLUT); - if ( (mFirstTimeInit || ((str != NULL) && (mParameters3A.Focus != mode)))) - { - mPending3Asettings |= SetFocus; - - mParameters3A.Focus = mode; - - // if focus mode is set to infinity...update focus distance immediately - if (mode == OMX_IMAGE_FocusControlAutoInfinity) { - updateFocusDistances(mParameters); - } - - CAMHAL_LOGDB("Focus %x", mParameters3A.Focus); - } - - str = params.get(android::CameraParameters::KEY_EXPOSURE_COMPENSATION); - varint = params.getInt(android::CameraParameters::KEY_EXPOSURE_COMPENSATION); - if ( mFirstTimeInit || (str && (mParameters3A.EVCompensation != varint))) { - CAMHAL_LOGDB("Setting EV Compensation to %d", varint); - mParameters3A.EVCompensation = varint; - mPending3Asettings |= SetEVCompensation; - } - - str = params.get(android::CameraParameters::KEY_FLASH_MODE); - mode = getLUTvalue_HALtoOMX( str, FlashLUT); - if ( mFirstTimeInit || (( str != NULL ) && ( mParameters3A.FlashMode != mode )) ) - { - if ( 0 <= mode ) - { - mParameters3A.FlashMode = mode; - mPending3Asettings |= SetFlash; - } - else - { - mParameters3A.FlashMode = OMX_IMAGE_FlashControlAuto; - } - } - - CAMHAL_LOGVB("Flash Setting %s", str); - CAMHAL_LOGVB("FlashMode %d", mParameters3A.FlashMode); - - str = params.get(android::CameraParameters::KEY_EFFECT); - mode = getLUTvalue_HALtoOMX( str, EffLUT); - if ( mFirstTimeInit || (( str != NULL ) && ( mParameters3A.Effect != mode )) ) - { - mParameters3A.Effect = mode; - CAMHAL_LOGDB("Effect %d", mParameters3A.Effect); - if ( 0 <= mParameters3A.Effect ) - { - mPending3Asettings |= SetEffect; - } - } - - str = params.get(android::CameraParameters::KEY_AUTO_EXPOSURE_LOCK_SUPPORTED); - if ( (str != NULL) && (!strcmp(str, android::CameraParameters::TRUE)) ) - { - OMX_BOOL lock = OMX_FALSE; - mUserSetExpLock = OMX_FALSE; - str = params.get(android::CameraParameters::KEY_AUTO_EXPOSURE_LOCK); - if (str && ((strcmp(str, android::CameraParameters::TRUE)) == 0)) - { - CAMHAL_LOGVA("Locking Exposure"); - lock = OMX_TRUE; - mUserSetExpLock = OMX_TRUE; - } - else - { - CAMHAL_LOGVA("UnLocking Exposure"); - } - - if (mParameters3A.ExposureLock != lock) - { - mParameters3A.ExposureLock = lock; - CAMHAL_LOGDB("ExposureLock %d", lock); - mPending3Asettings |= SetExpLock; - } - } - - str = params.get(android::CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED); - if ( (str != NULL) && (!strcmp(str, android::CameraParameters::TRUE)) ) - { - OMX_BOOL lock = OMX_FALSE; - mUserSetWbLock = OMX_FALSE; - str = params.get(android::CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK); - if (str && ((strcmp(str, android::CameraParameters::TRUE)) == 0)) - { - CAMHAL_LOGVA("Locking WhiteBalance"); - lock = OMX_TRUE; - mUserSetWbLock = OMX_TRUE; - } - else - { - CAMHAL_LOGVA("UnLocking WhiteBalance"); - } - if (mParameters3A.WhiteBalanceLock != lock) - { - mParameters3A.WhiteBalanceLock = lock; - CAMHAL_LOGDB("WhiteBalanceLock %d", lock); - mPending3Asettings |= SetWBLock; - } - } - - str = params.get(TICameraParameters::KEY_AUTO_FOCUS_LOCK); - if (str && (strcmp(str, android::CameraParameters::TRUE) == 0) && (mParameters3A.FocusLock != OMX_TRUE)) { - CAMHAL_LOGVA("Locking Focus"); - mParameters3A.FocusLock = OMX_TRUE; - setFocusLock(mParameters3A); - } else if (str && (strcmp(str, android::CameraParameters::FALSE) == 0) && (mParameters3A.FocusLock != OMX_FALSE)) { - CAMHAL_LOGVA("UnLocking Focus"); - mParameters3A.FocusLock = OMX_FALSE; - setFocusLock(mParameters3A); - } - - str = params.get(android::CameraParameters::KEY_METERING_AREAS); - if ( (str != NULL) ) { - size_t MAX_METERING_AREAS; - android::Vector > tempAreas; - - MAX_METERING_AREAS = atoi(params.get(android::CameraParameters::KEY_MAX_NUM_METERING_AREAS)); - - android::AutoMutex lock(mMeteringAreasLock); - - ret = CameraArea::parseAreas(str, ( strlen(str) + 1 ), tempAreas); - - CAMHAL_LOGVB("areAreasDifferent? = %d", - CameraArea::areAreasDifferent(mMeteringAreas, tempAreas)); - - if ( (NO_ERROR == ret) && CameraArea::areAreasDifferent(mMeteringAreas, tempAreas) ) { - mMeteringAreas.clear(); - mMeteringAreas = tempAreas; - - if ( MAX_METERING_AREAS >= mMeteringAreas.size() ) { - CAMHAL_LOGDB("Setting Metering Areas %s", - params.get(android::CameraParameters::KEY_METERING_AREAS)); - - mPending3Asettings |= SetMeteringAreas; - } else { - CAMHAL_LOGEB("Metering areas supported %d, metering areas set %d", - MAX_METERING_AREAS, mMeteringAreas.size()); - ret = -EINVAL; - } - } - } - -// TI extensions for enable/disable algos -#ifndef OMAP_TUNA - declareParameter3ABool(params, TICameraParameters::KEY_ALGO_FIXED_GAMMA, - mParameters3A.AlgoFixedGamma, SetAlgoFixedGamma, "Fixed Gamma"); - declareParameter3ABool(params, TICameraParameters::KEY_ALGO_NSF1, - mParameters3A.AlgoNSF1, SetAlgoNSF1, "NSF1"); - declareParameter3ABool(params, TICameraParameters::KEY_ALGO_NSF2, - mParameters3A.AlgoNSF2, SetAlgoNSF2, "NSF2"); - declareParameter3ABool(params, TICameraParameters::KEY_ALGO_SHARPENING, - mParameters3A.AlgoSharpening, SetAlgoSharpening, "Sharpening"); - declareParameter3ABool(params, TICameraParameters::KEY_ALGO_THREELINCOLORMAP, - mParameters3A.AlgoThreeLinColorMap, SetAlgoThreeLinColorMap, "ThreeLinColorMap"); - declareParameter3ABool(params, TICameraParameters::KEY_ALGO_GIC, mParameters3A.AlgoGIC, SetAlgoGIC, "GIC"); -#endif - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -void OMXCameraAdapter::declareParameter3ABool(const android::CameraParameters ¶ms, const char *key, - OMX_BOOL ¤t_setting, E3ASettingsFlags pending, - const char *msg) -{ - OMX_BOOL val = OMX_TRUE; - const char *str = params.get(key); - - if (str && ((strcmp(str, android::CameraParameters::FALSE)) == 0)) - { - CAMHAL_LOGVB("Disabling %s", msg); - val = OMX_FALSE; - } - else - { - CAMHAL_LOGVB("Enabling %s", msg); - } - if (current_setting != val) - { - current_setting = val; - CAMHAL_LOGDB("%s %s", msg, current_setting ? "enabled" : "disabled"); - mPending3Asettings |= pending; - } -} - -int OMXCameraAdapter::getLUTvalue_HALtoOMX(const char * HalValue, LUTtype LUT) -{ - int LUTsize = LUT.size; - if( HalValue ) - for(int i = 0; i < LUTsize; i++) - if( 0 == strcmp(LUT.Table[i].userDefinition, HalValue) ) - return LUT.Table[i].omxDefinition; - - return -ENOENT; -} - -const char* OMXCameraAdapter::getLUTvalue_OMXtoHAL(int OMXValue, LUTtype LUT) -{ - int LUTsize = LUT.size; - for(int i = 0; i < LUTsize; i++) - if( LUT.Table[i].omxDefinition == OMXValue ) - return LUT.Table[i].userDefinition; - - return NULL; -} - -int OMXCameraAdapter::getMultipleLUTvalue_OMXtoHAL(int OMXValue, LUTtype LUT, char * supported) -{ - int num = 0; - int remaining_size; - int LUTsize = LUT.size; - for(int i = 0; i < LUTsize; i++) - if( LUT.Table[i].omxDefinition == OMXValue ) - { - num++; - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - remaining_size = ((((int)MAX_PROP_VALUE_LENGTH - 1 - (int)strlen(supported)) < 0) ? 0 : (MAX_PROP_VALUE_LENGTH - 1 - strlen(supported))); - strncat(supported, LUT.Table[i].userDefinition, remaining_size); - } - - return num; -} - -status_t OMXCameraAdapter::setExposureMode(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_EXPOSURECONTROLTYPE exp; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&exp, OMX_CONFIG_EXPOSURECONTROLTYPE); - exp.nPortIndex = OMX_ALL; - exp.eExposureControl = (OMX_EXPOSURECONTROLTYPE)Gen3A.Exposure; - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonExposure, - &exp); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring exposure mode 0x%x", eError); - } - else - { - CAMHAL_LOGDA("Camera exposure mode configured successfully"); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -#ifndef OMAP_TUNA -static bool isFlashDisabled() { -#if (PROPERTY_VALUE_MAX < 5) -#error "PROPERTY_VALUE_MAX must be at least 5" -#endif - - // Ignore flash_off system property for user build. - char buildType[PROPERTY_VALUE_MAX]; - if (property_get("ro.build.type", buildType, NULL) && - !strcasecmp(buildType, "user")) { - return false; - } - - char value[PROPERTY_VALUE_MAX]; - if (property_get("camera.flash_off", value, NULL) && - (!strcasecmp(value, android::CameraParameters::TRUE) || !strcasecmp(value, "1"))) { - CAMHAL_LOGW("flash is disabled for testing purpose"); - return true; - } - - return false; -} -#endif - -status_t OMXCameraAdapter::setManualExposureVal(Gen3A_settings& Gen3A) { - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_EXPOSUREVALUETYPE expVal; - OMX_TI_CONFIG_EXPOSUREVALUERIGHTTYPE expValRight; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&expVal, OMX_CONFIG_EXPOSUREVALUETYPE); - OMX_INIT_STRUCT_PTR (&expValRight, OMX_TI_CONFIG_EXPOSUREVALUERIGHTTYPE); - expVal.nPortIndex = OMX_ALL; - expValRight.nPortIndex = OMX_ALL; - - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonExposureValue, - &expVal); - if ( OMX_ErrorNone == eError ) { - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexConfigRightExposureValue, - &expValRight); - } - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("OMX_GetConfig error 0x%x (manual exposure values)", eError); - return Utils::ErrorUtils::omxToAndroidError(eError); - } - - if ( Gen3A.Exposure != OMX_ExposureControlOff ) { - expVal.bAutoShutterSpeed = OMX_TRUE; - expVal.bAutoSensitivity = OMX_TRUE; - } else { - expVal.bAutoShutterSpeed = OMX_FALSE; - expVal.nShutterSpeedMsec = Gen3A.ManualExposure; - expValRight.nShutterSpeedMsec = Gen3A.ManualExposureRight; - if ( Gen3A.ManualGain <= 0 || Gen3A.ManualGainRight <= 0 ) { - expVal.bAutoSensitivity = OMX_TRUE; - } else { - expVal.bAutoSensitivity = OMX_FALSE; - expVal.nSensitivity = Gen3A.ManualGain; - expValRight.nSensitivity = Gen3A.ManualGainRight; - } - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonExposureValue, - &expVal); - if ( OMX_ErrorNone == eError ) { - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexConfigRightExposureValue, - &expValRight); - } - - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error 0x%x while configuring manual exposure values", eError); - } else { - CAMHAL_LOGDA("Camera manual exposure values configured successfully"); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setFlashMode(Gen3A_settings& Gen3A) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_PARAM_FLASHCONTROLTYPE flash; - OMX_CONFIG_FOCUSASSISTTYPE focusAssist; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&flash, OMX_IMAGE_PARAM_FLASHCONTROLTYPE); - flash.nPortIndex = OMX_ALL; - -#ifndef OMAP_TUNA - if (isFlashDisabled()) { - flash.eFlashControl = ( OMX_IMAGE_FLASHCONTROLTYPE ) OMX_IMAGE_FlashControlOff; - } else { -#endif - flash.eFlashControl = ( OMX_IMAGE_FLASHCONTROLTYPE ) Gen3A.FlashMode; -#ifndef OMAP_TUNA - } -#endif - - CAMHAL_LOGDB("Configuring flash mode 0x%x", flash.eFlashControl); - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_IndexConfigFlashControl, - &flash); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring flash mode 0x%x", eError); - } - else - { - CAMHAL_LOGDA("Camera flash mode configured successfully"); - } - - if ( OMX_ErrorNone == eError ) - { - OMX_INIT_STRUCT_PTR (&focusAssist, OMX_CONFIG_FOCUSASSISTTYPE); - focusAssist.nPortIndex = OMX_ALL; - if ( flash.eFlashControl == OMX_IMAGE_FlashControlOff ) - { - focusAssist.bFocusAssist = OMX_FALSE; - } - else - { - focusAssist.bFocusAssist = OMX_TRUE; - } - - CAMHAL_LOGDB("Configuring AF Assist mode 0x%x", focusAssist.bFocusAssist); - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_IndexConfigFocusAssist, - &focusAssist); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring AF Assist mode 0x%x", eError); - } - else - { - CAMHAL_LOGDA("Camera AF Assist mode configured successfully"); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::getFlashMode(Gen3A_settings& Gen3A) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_PARAM_FLASHCONTROLTYPE flash; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&flash, OMX_IMAGE_PARAM_FLASHCONTROLTYPE); - flash.nPortIndex = OMX_ALL; - - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_IndexConfigFlashControl, - &flash); - - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while getting flash mode 0x%x", eError); - } else { - Gen3A.FlashMode = flash.eFlashControl; - CAMHAL_LOGDB("Gen3A.FlashMode 0x%x", Gen3A.FlashMode); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setFocusMode(Gen3A_settings& Gen3A) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE focus; - size_t top, left, width, height, weight; - OMX_CONFIG_BOOLEANTYPE bOMX; - - LOG_FUNCTION_NAME; - - BaseCameraAdapter::AdapterState state; - BaseCameraAdapter::getState(state); - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - - ///Face detection takes precedence over touch AF - if ( mFaceDetectionRunning ) - { - //Disable region priority first - setAlgoPriority(REGION_PRIORITY, FOCUS_ALGO, false); - - //Enable face algorithm priority for focus - setAlgoPriority(FACE_PRIORITY, FOCUS_ALGO , true); - - //Do normal focus afterwards - ////FIXME: Check if the extended focus control is needed? this overrides caf - //focusControl.eFocusControl = ( OMX_IMAGE_FOCUSCONTROLTYPE ) OMX_IMAGE_FocusControlExtended; - } - else if ( (!mFocusAreas.isEmpty()) && (!mFocusAreas.itemAt(0)->isZeroArea()) ) - { - - //Disable face priority first - setAlgoPriority(FACE_PRIORITY, FOCUS_ALGO, false); - - //Enable region algorithm priority - setAlgoPriority(REGION_PRIORITY, FOCUS_ALGO, true); - - - //Do normal focus afterwards - //FIXME: Check if the extended focus control is needed? this overrides caf - //focus.eFocusControl = ( OMX_IMAGE_FOCUSCONTROLTYPE ) OMX_IMAGE_FocusControlExtended; - - } - else - { - - //Disable both region and face priority - setAlgoPriority(REGION_PRIORITY, FOCUS_ALGO, false); - - setAlgoPriority(FACE_PRIORITY, FOCUS_ALGO, false); - - } - - if ( NO_ERROR == ret && ((state & AF_ACTIVE) == 0) ) - { - OMX_INIT_STRUCT_PTR (&bOMX, OMX_CONFIG_BOOLEANTYPE); - - if ( Gen3A.Focus == OMX_IMAGE_FocusControlAutoInfinity) - { - // Don't lock at infinity, otherwise the AF cannot drive - // the lens at infinity position - if( set3ALock(mUserSetExpLock, mUserSetWbLock, OMX_FALSE) != NO_ERROR) - { - CAMHAL_LOGEA("Error Applying 3A locks"); - } else { - CAMHAL_LOGDA("Focus locked. Applied focus locks successfully"); - } - } - if ( Gen3A.Focus == OMX_IMAGE_FocusControlAuto || - Gen3A.Focus == OMX_IMAGE_FocusControlAutoInfinity) - { - // Run focus scanning if switching to continuous infinity focus mode - bOMX.bEnabled = OMX_TRUE; - } - else - { - bOMX.bEnabled = OMX_FALSE; - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexConfigAutofocusEnable, - &bOMX); - - OMX_INIT_STRUCT_PTR (&focus, OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE); - focus.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - focus.eFocusControl = (OMX_IMAGE_FOCUSCONTROLTYPE)Gen3A.Focus; - - CAMHAL_LOGDB("Configuring focus mode 0x%x", focus.eFocusControl); - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, OMX_IndexConfigFocusControl, &focus); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring focus mode 0x%x", eError); - } - else - { - CAMHAL_LOGDA("Camera focus mode configured successfully"); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::getFocusMode(Gen3A_settings& Gen3A) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE focus; - size_t top, left, width, height, weight; - - LOG_FUNCTION_NAME; - - if (OMX_StateInvalid == mComponentState) { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&focus, OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE); - focus.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigFocusControl, &focus); - - if (OMX_ErrorNone != eError) { - CAMHAL_LOGEB("Error while configuring focus mode 0x%x", eError); - } else { - Gen3A.Focus = focus.eFocusControl; - CAMHAL_LOGDB("Gen3A.Focus 0x%x", Gen3A.Focus); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setScene(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_SCENEMODETYPE scene; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&scene, OMX_CONFIG_SCENEMODETYPE); - scene.nPortIndex = OMX_ALL; - scene.eSceneMode = ( OMX_SCENEMODETYPE ) Gen3A.SceneMode; - - CAMHAL_LOGDB("Configuring scene mode 0x%x", scene.eSceneMode); - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_TI_IndexConfigSceneMode, - &scene); - - if (OMX_ErrorNone != eError) { - CAMHAL_LOGEB("Error while configuring scene mode 0x%x", eError); - } else { - CAMHAL_LOGDA("Camera scene configured successfully"); - if (Gen3A.SceneMode != OMX_Manual) { - // Get preset scene mode feedback - getFocusMode(Gen3A); - getFlashMode(Gen3A); - getWBMode(Gen3A); - - // TODO(XXX): Re-enable these for mainline - // getSharpness(Gen3A); - // getSaturation(Gen3A); - // getISO(Gen3A); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setEVCompensation(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_EXPOSUREVALUETYPE expValues; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&expValues, OMX_CONFIG_EXPOSUREVALUETYPE); - expValues.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - OMX_GetConfig( mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonExposureValue, - &expValues); - CAMHAL_LOGDB("old EV Compensation for OMX = 0x%x", (int)expValues.xEVCompensation); - CAMHAL_LOGDB("EV Compensation for HAL = %d", Gen3A.EVCompensation); - - expValues.xEVCompensation = ( Gen3A.EVCompensation * ( 1 << Q16_OFFSET ) ) / 10; - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonExposureValue, - &expValues); - CAMHAL_LOGDB("new EV Compensation for OMX = 0x%x", (int)expValues.xEVCompensation); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring EV Compensation 0x%x error = 0x%x", - ( unsigned int ) expValues.xEVCompensation, - eError); - } - else - { - CAMHAL_LOGDB("EV Compensation 0x%x configured successfully", - ( unsigned int ) expValues.xEVCompensation); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::getEVCompensation(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_EXPOSUREVALUETYPE expValues; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&expValues, OMX_CONFIG_EXPOSUREVALUETYPE); - expValues.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonExposureValue, - &expValues); - - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while getting EV Compensation error = 0x%x", eError); - } else { - Gen3A.EVCompensation = (10 * expValues.xEVCompensation) / (1 << Q16_OFFSET); - CAMHAL_LOGDB("Gen3A.EVCompensation 0x%x", Gen3A.EVCompensation); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setWBMode(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_WHITEBALCONTROLTYPE wb; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&wb, OMX_CONFIG_WHITEBALCONTROLTYPE); - wb.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - wb.eWhiteBalControl = ( OMX_WHITEBALCONTROLTYPE ) Gen3A.WhiteBallance; - - // disable face and region priorities - setAlgoPriority(FACE_PRIORITY, WHITE_BALANCE_ALGO, false); - setAlgoPriority(REGION_PRIORITY, WHITE_BALANCE_ALGO, false); - - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonWhiteBalance, - &wb); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring Whitebalance mode 0x%x error = 0x%x", - ( unsigned int ) wb.eWhiteBalControl, - eError); - } - else - { - CAMHAL_LOGDB("Whitebalance mode 0x%x configured successfully", - ( unsigned int ) wb.eWhiteBalControl); - } - - LOG_FUNCTION_NAME_EXIT; - - return eError; -} - -status_t OMXCameraAdapter::getWBMode(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_WHITEBALCONTROLTYPE wb; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&wb, OMX_CONFIG_WHITEBALCONTROLTYPE); - wb.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonWhiteBalance, - &wb); - - if (OMX_ErrorNone != eError) { - CAMHAL_LOGEB("Error while getting Whitebalance mode error = 0x%x", eError); - } else { - Gen3A.WhiteBallance = wb.eWhiteBalControl; - CAMHAL_LOGDB("Gen3A.WhiteBallance 0x%x", Gen3A.WhiteBallance); - } - - LOG_FUNCTION_NAME_EXIT; - - return eError; -} - -status_t OMXCameraAdapter::setFlicker(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_FLICKERCANCELTYPE flicker; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&flicker, OMX_CONFIG_FLICKERCANCELTYPE); - flicker.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - flicker.eFlickerCancel = (OMX_COMMONFLICKERCANCELTYPE)Gen3A.Flicker; - - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_IndexConfigFlickerCancel, - &flicker ); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring Flicker mode 0x%x error = 0x%x", - ( unsigned int ) flicker.eFlickerCancel, - eError); - } - else - { - CAMHAL_LOGDB("Flicker mode 0x%x configured successfully", - ( unsigned int ) flicker.eFlickerCancel); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setBrightness(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_BRIGHTNESSTYPE brightness; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&brightness, OMX_CONFIG_BRIGHTNESSTYPE); - brightness.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - brightness.nBrightness = Gen3A.Brightness; - - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonBrightness, - &brightness); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring Brightness 0x%x error = 0x%x", - ( unsigned int ) brightness.nBrightness, - eError); - } - else - { - CAMHAL_LOGDB("Brightness 0x%x configured successfully", - ( unsigned int ) brightness.nBrightness); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setContrast(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_CONTRASTTYPE contrast; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&contrast, OMX_CONFIG_CONTRASTTYPE); - contrast.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - contrast.nContrast = Gen3A.Contrast; - - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonContrast, - &contrast); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring Contrast 0x%x error = 0x%x", - ( unsigned int ) contrast.nContrast, - eError); - } - else - { - CAMHAL_LOGDB("Contrast 0x%x configured successfully", - ( unsigned int ) contrast.nContrast); - } - - LOG_FUNCTION_NAME_EXIT; - - return eError; -} - -status_t OMXCameraAdapter::setSharpness(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_CONFIG_PROCESSINGLEVELTYPE procSharpness; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&procSharpness, OMX_IMAGE_CONFIG_PROCESSINGLEVELTYPE); - procSharpness.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - procSharpness.nLevel = Gen3A.Sharpness; - - if( procSharpness.nLevel == 0 ) - { - procSharpness.bAuto = OMX_TRUE; - } - else - { - procSharpness.bAuto = OMX_FALSE; - } - - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_IndexConfigSharpeningLevel, - &procSharpness); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring Sharpness 0x%x error = 0x%x", - ( unsigned int ) procSharpness.nLevel, - eError); - } - else - { - CAMHAL_LOGDB("Sharpness 0x%x configured successfully", - ( unsigned int ) procSharpness.nLevel); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::getSharpness(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_CONFIG_PROCESSINGLEVELTYPE procSharpness; - - LOG_FUNCTION_NAME; - - if (OMX_StateInvalid == mComponentState) { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&procSharpness, OMX_IMAGE_CONFIG_PROCESSINGLEVELTYPE); - procSharpness.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_IndexConfigSharpeningLevel, - &procSharpness); - - if (OMX_ErrorNone != eError) { - CAMHAL_LOGEB("Error while configuring Sharpness error = 0x%x", eError); - } else { - Gen3A.Sharpness = procSharpness.nLevel; - CAMHAL_LOGDB("Gen3A.Sharpness 0x%x", Gen3A.Sharpness); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setSaturation(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_SATURATIONTYPE saturation; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&saturation, OMX_CONFIG_SATURATIONTYPE); - saturation.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - saturation.nSaturation = Gen3A.Saturation; - - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonSaturation, - &saturation); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring Saturation 0x%x error = 0x%x", - ( unsigned int ) saturation.nSaturation, - eError); - } - else - { - CAMHAL_LOGDB("Saturation 0x%x configured successfully", - ( unsigned int ) saturation.nSaturation); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::getSaturation(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_SATURATIONTYPE saturation; - - LOG_FUNCTION_NAME; - - if (OMX_StateInvalid == mComponentState) { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&saturation, OMX_CONFIG_SATURATIONTYPE); - saturation.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - eError = OMX_GetConfig( mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonSaturation, - &saturation); - - if (OMX_ErrorNone != eError) { - CAMHAL_LOGEB("Error while getting Saturation error = 0x%x", eError); - } else { - Gen3A.Saturation = saturation.nSaturation; - CAMHAL_LOGDB("Gen3A.Saturation 0x%x", Gen3A.Saturation); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setISO(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_EXPOSUREVALUETYPE expValues; - OMX_TI_CONFIG_EXPOSUREVALUERIGHTTYPE expValRight; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - // In case of manual exposure Gain is applied from setManualExposureVal - if ( Gen3A.Exposure == OMX_ExposureControlOff ) { - return NO_ERROR; - } - - OMX_INIT_STRUCT_PTR (&expValues, OMX_CONFIG_EXPOSUREVALUETYPE); - OMX_INIT_STRUCT_PTR (&expValRight, OMX_TI_CONFIG_EXPOSUREVALUERIGHTTYPE); - expValues.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - expValRight.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - eError = OMX_GetConfig( mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonExposureValue, - &expValues); - - if ( OMX_ErrorNone == eError ) { - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexConfigRightExposureValue, - &expValRight); - } - - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("OMX_GetConfig error 0x%x (manual exposure values)", eError); - return Utils::ErrorUtils::omxToAndroidError(eError); - } - - if( 0 == Gen3A.ISO ) { - expValues.bAutoSensitivity = OMX_TRUE; - } else { - expValues.bAutoSensitivity = OMX_FALSE; - expValues.nSensitivity = Gen3A.ISO; - expValRight.nSensitivity = expValues.nSensitivity; - } - - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonExposureValue, - &expValues); - - if ( OMX_ErrorNone == eError ) { - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexConfigRightExposureValue, - &expValRight); - } - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while configuring ISO 0x%x error = 0x%x", - ( unsigned int ) expValues.nSensitivity, - eError); - } else { - CAMHAL_LOGDB("ISO 0x%x configured successfully", - ( unsigned int ) expValues.nSensitivity); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::getISO(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_EXPOSUREVALUETYPE expValues; - - LOG_FUNCTION_NAME; - - if (OMX_StateInvalid == mComponentState) { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&expValues, OMX_CONFIG_EXPOSUREVALUETYPE); - expValues.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - OMX_GetConfig( mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonExposureValue, - &expValues); - - if (OMX_ErrorNone != eError) { - CAMHAL_LOGEB("Error while getting ISO error = 0x%x", eError); - } else { - Gen3A.ISO = expValues.nSensitivity; - CAMHAL_LOGDB("Gen3A.ISO %d", Gen3A.ISO); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setEffect(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_IMAGEFILTERTYPE effect; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&effect, OMX_CONFIG_IMAGEFILTERTYPE); - effect.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - effect.eImageFilter = (OMX_IMAGEFILTERTYPE ) Gen3A.Effect; - - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonImageFilter, - &effect); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring Effect 0x%x error = 0x%x", - ( unsigned int ) effect.eImageFilter, - eError); - } - else - { - CAMHAL_LOGDB("Effect 0x%x configured successfully", - ( unsigned int ) effect.eImageFilter); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setWhiteBalanceLock(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_CONFIG_LOCKTYPE lock; - - LOG_FUNCTION_NAME - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&lock, OMX_IMAGE_CONFIG_LOCKTYPE); - lock.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - lock.bLock = Gen3A.WhiteBalanceLock; - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_IndexConfigImageWhiteBalanceLock, - &lock); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring WhiteBalance Lock error = 0x%x", eError); - } - else - { - CAMHAL_LOGDB("WhiteBalance Lock configured successfully %d ", lock.bLock); - } - LOG_FUNCTION_NAME_EXIT - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setExposureLock(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_CONFIG_LOCKTYPE lock; - - LOG_FUNCTION_NAME - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&lock, OMX_IMAGE_CONFIG_LOCKTYPE); - lock.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - lock.bLock = Gen3A.ExposureLock; - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_IndexConfigImageExposureLock, - &lock); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring Exposure Lock error = 0x%x", eError); - } - else - { - CAMHAL_LOGDB("Exposure Lock configured successfully %d ", lock.bLock); - } - LOG_FUNCTION_NAME_EXIT - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setFocusLock(Gen3A_settings& Gen3A) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_CONFIG_LOCKTYPE lock; - - LOG_FUNCTION_NAME - - if ( OMX_StateInvalid == mComponentState ) { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&lock, OMX_IMAGE_CONFIG_LOCKTYPE); - lock.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - lock.bLock = Gen3A.FocusLock; - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_IndexConfigImageFocusLock, - &lock); - - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while configuring Focus Lock error = 0x%x", eError); - } else { - CAMHAL_LOGDB("Focus Lock configured successfully %d ", lock.bLock); - } - - LOG_FUNCTION_NAME_EXIT - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::set3ALock(OMX_BOOL toggleExp, OMX_BOOL toggleWb, OMX_BOOL toggleFocus) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_CONFIG_LOCKTYPE lock; - - LOG_FUNCTION_NAME - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&lock, OMX_IMAGE_CONFIG_LOCKTYPE); - lock.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - mParameters3A.ExposureLock = toggleExp; - mParameters3A.FocusLock = toggleFocus; - mParameters3A.WhiteBalanceLock = toggleWb; - - eError = OMX_GetConfig( mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_IndexConfigImageExposureLock, - &lock); - - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error GetConfig Exposure Lock error = 0x%x", eError); - goto EXIT; - } - else - { - CAMHAL_LOGDA("Exposure Lock GetConfig successfull"); - - /* Apply locks only when not applied already */ - if ( lock.bLock != toggleExp ) - { - setExposureLock(mParameters3A); - } - - } - - OMX_INIT_STRUCT_PTR (&lock, OMX_IMAGE_CONFIG_LOCKTYPE); - lock.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - eError = OMX_GetConfig( mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_IndexConfigImageFocusLock, - &lock); - - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error GetConfig Focus Lock error = 0x%x", eError); - goto EXIT; - } - else - { - CAMHAL_LOGDB("Focus Lock GetConfig successfull bLock(%d)", lock.bLock); - - /* Apply locks only when not applied already */ - if ( lock.bLock != toggleFocus ) - { - setFocusLock(mParameters3A); - } - } - - OMX_INIT_STRUCT_PTR (&lock, OMX_IMAGE_CONFIG_LOCKTYPE); - lock.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - eError = OMX_GetConfig( mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_IndexConfigImageWhiteBalanceLock, - &lock); - - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error GetConfig WhiteBalance Lock error = 0x%x", eError); - goto EXIT; - } - else - { - CAMHAL_LOGDA("WhiteBalance Lock GetConfig successfull"); - - /* Apply locks only when not applied already */ - if ( lock.bLock != toggleWb ) - { - setWhiteBalanceLock(mParameters3A); - } - - } - EXIT: - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setMeteringAreas(Gen3A_settings& Gen3A) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - CameraBuffer *bufferlist; - OMX_ALGOAREASTYPE *meteringAreas; - OMX_TI_CONFIG_SHAREDBUFFER sharedBuffer; - MemoryManager memMgr; - int areasSize = 0; - - LOG_FUNCTION_NAME - - ret = memMgr.initialize(); - if ( ret != OK ) { - CAMHAL_LOGE("MemoryManager initialization failed, error: %d", ret); - return ret; - } - - android::AutoMutex lock(mMeteringAreasLock); - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - areasSize = ((sizeof(OMX_ALGOAREASTYPE)+4095)/4096)*4096; - bufferlist = memMgr.allocateBufferList(0, 0, NULL, areasSize, 1); - meteringAreas = (OMX_ALGOAREASTYPE *)bufferlist[0].opaque; - - OMXCameraPortParameters * mPreviewData = NULL; - mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - - if (!meteringAreas) - { - CAMHAL_LOGEB("Error allocating buffer for metering areas %d", eError); - return -ENOMEM; - } - - OMX_INIT_STRUCT_PTR (meteringAreas, OMX_ALGOAREASTYPE); - - meteringAreas->nPortIndex = OMX_ALL; - meteringAreas->nNumAreas = mMeteringAreas.size(); - meteringAreas->nAlgoAreaPurpose = OMX_AlgoAreaExposure; - - for ( unsigned int n = 0; n < mMeteringAreas.size(); n++) - { - int widthDivisor = 1; - int heightDivisor = 1; - - if (mPreviewData->mFrameLayoutType == OMX_TI_StereoFrameLayoutTopBottom) { - heightDivisor = 2; - } - if (mPreviewData->mFrameLayoutType == OMX_TI_StereoFrameLayoutLeftRight) { - widthDivisor = 2; - } - - // transform the coordinates to 3A-type coordinates - mMeteringAreas.itemAt(n)->transfrom((size_t)mPreviewData->mWidth/widthDivisor, - (size_t)mPreviewData->mHeight/heightDivisor, - (size_t&)meteringAreas->tAlgoAreas[n].nTop, - (size_t&)meteringAreas->tAlgoAreas[n].nLeft, - (size_t&)meteringAreas->tAlgoAreas[n].nWidth, - (size_t&)meteringAreas->tAlgoAreas[n].nHeight); - - meteringAreas->tAlgoAreas[n].nLeft = - ( meteringAreas->tAlgoAreas[n].nLeft * METERING_AREAS_RANGE ) / mPreviewData->mWidth; - meteringAreas->tAlgoAreas[n].nTop = - ( meteringAreas->tAlgoAreas[n].nTop* METERING_AREAS_RANGE ) / mPreviewData->mHeight; - meteringAreas->tAlgoAreas[n].nWidth = - ( meteringAreas->tAlgoAreas[n].nWidth * METERING_AREAS_RANGE ) / mPreviewData->mWidth; - meteringAreas->tAlgoAreas[n].nHeight = - ( meteringAreas->tAlgoAreas[n].nHeight * METERING_AREAS_RANGE ) / mPreviewData->mHeight; - - meteringAreas->tAlgoAreas[n].nPriority = mMeteringAreas.itemAt(n)->getWeight(); - - CAMHAL_LOGDB("Metering area %d : top = %d left = %d width = %d height = %d prio = %d", - n, (int)meteringAreas->tAlgoAreas[n].nTop, (int)meteringAreas->tAlgoAreas[n].nLeft, - (int)meteringAreas->tAlgoAreas[n].nWidth, (int)meteringAreas->tAlgoAreas[n].nHeight, - (int)meteringAreas->tAlgoAreas[n].nPriority); - - } - - OMX_INIT_STRUCT_PTR (&sharedBuffer, OMX_TI_CONFIG_SHAREDBUFFER); - - sharedBuffer.nPortIndex = OMX_ALL; - sharedBuffer.nSharedBuffSize = areasSize; - sharedBuffer.pSharedBuff = (OMX_U8 *)camera_buffer_get_omx_ptr (&bufferlist[0]); - - if ( NULL == sharedBuffer.pSharedBuff ) - { - CAMHAL_LOGEA("No resources to allocate OMX shared buffer"); - ret = -ENOMEM; - goto EXIT; - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexConfigAlgoAreas, &sharedBuffer); - - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while setting Focus Areas configuration 0x%x", eError); - ret = -EINVAL; - } - else - { - CAMHAL_LOGDA("Metering Areas SetConfig successfull."); - } - - EXIT: - if (NULL != bufferlist) - { - memMgr.freeBufferList(bufferlist); - } - - return ret; -} - -//TI extensions for enable/disable algos -status_t OMXCameraAdapter::setParameter3ABoolInvert(const OMX_INDEXTYPE omx_idx, - const OMX_BOOL data, const char *msg) -{ - OMX_BOOL inv_data; - - if (OMX_TRUE == data) - { - inv_data = OMX_FALSE; - } - else if (OMX_FALSE == data) - { - inv_data = OMX_TRUE; - } - else - { - return BAD_VALUE; - } - return setParameter3ABool(omx_idx, inv_data, msg); -} - -status_t OMXCameraAdapter::setParameter3ABool(const OMX_INDEXTYPE omx_idx, - const OMX_BOOL data, const char *msg) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_BOOLEANTYPE cfgdata; - - LOG_FUNCTION_NAME - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&cfgdata, OMX_CONFIG_BOOLEANTYPE); - cfgdata.bEnabled = data; - eError = OMX_SetConfig( mCameraAdapterParameters.mHandleComp, - omx_idx, - &cfgdata); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring %s error = 0x%x", msg, eError); - } - else - { - CAMHAL_LOGDB("%s configured successfully %d ", msg, cfgdata.bEnabled); - } - - LOG_FUNCTION_NAME_EXIT - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -#ifndef OMAP_TUNA -status_t OMXCameraAdapter::setAlgoFixedGamma(Gen3A_settings& Gen3A) -{ - return setParameter3ABool((OMX_INDEXTYPE) OMX_TI_IndexConfigFixedGamma, Gen3A.AlgoFixedGamma, "Fixed Gamma"); -} - -status_t OMXCameraAdapter::setAlgoNSF1(Gen3A_settings& Gen3A) -{ - return setParameter3ABoolInvert((OMX_INDEXTYPE) OMX_TI_IndexConfigDisableNSF1, Gen3A.AlgoNSF1, "NSF1"); -} - -status_t OMXCameraAdapter::setAlgoNSF2(Gen3A_settings& Gen3A) -{ - return setParameter3ABoolInvert((OMX_INDEXTYPE) OMX_TI_IndexConfigDisableNSF2, Gen3A.AlgoNSF2, "NSF2"); -} - -status_t OMXCameraAdapter::setAlgoSharpening(Gen3A_settings& Gen3A) -{ - return setParameter3ABoolInvert((OMX_INDEXTYPE) OMX_TI_IndexConfigDisableSharpening, Gen3A.AlgoSharpening, "Sharpening"); -} - -status_t OMXCameraAdapter::setAlgoThreeLinColorMap(Gen3A_settings& Gen3A) -{ - return setParameter3ABoolInvert((OMX_INDEXTYPE) OMX_TI_IndexConfigDisableThreeLinColorMap, Gen3A.AlgoThreeLinColorMap, "Color Conversion"); -} - -status_t OMXCameraAdapter::setAlgoGIC(Gen3A_settings& Gen3A) -{ - return setParameter3ABoolInvert((OMX_INDEXTYPE) OMX_TI_IndexConfigDisableGIC, Gen3A.AlgoGIC, "Green Inballance Correction"); -} -#endif - -status_t OMXCameraAdapter::apply3Asettings( Gen3A_settings& Gen3A ) -{ - status_t ret = NO_ERROR; - unsigned int currSett; // 32 bit - int portIndex; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(m3ASettingsUpdateLock); - - /* - * Scenes have a priority during the process - * of applying 3A related parameters. - * They can override pretty much all other 3A - * settings and similarly get overridden when - * for instance the focus mode gets switched. - * There is only one exception to this rule, - * the manual a.k.a. auto scene. - */ - if (SetSceneMode & mPending3Asettings) { - mPending3Asettings &= ~SetSceneMode; - ret |= setScene(Gen3A); - // re-apply EV compensation after setting scene mode since it probably reset it - if(Gen3A.EVCompensation) { - setEVCompensation(Gen3A); - } - return ret; - } else if (OMX_Manual != Gen3A.SceneMode) { - // only certain settings are allowed when scene mode is set - mPending3Asettings &= (SetEVCompensation | SetFocus | SetWBLock | - SetExpLock | SetWhiteBallance | SetFlash); - if ( mPending3Asettings == 0 ) return NO_ERROR; - } - - for( currSett = 1; currSett < E3aSettingMax; currSett <<= 1) - { - if( currSett & mPending3Asettings ) - { - switch( currSett ) - { - case SetEVCompensation: - { - ret |= setEVCompensation(Gen3A); - break; - } - - case SetWhiteBallance: - { - ret |= setWBMode(Gen3A); - break; - } - - case SetFlicker: - { - ret |= setFlicker(Gen3A); - break; - } - - case SetBrightness: - { - ret |= setBrightness(Gen3A); - break; - } - - case SetContrast: - { - ret |= setContrast(Gen3A); - break; - } - - case SetSharpness: - { - ret |= setSharpness(Gen3A); - break; - } - - case SetSaturation: - { - ret |= setSaturation(Gen3A); - break; - } - - case SetISO: - { - ret |= setISO(Gen3A); - break; - } - - case SetEffect: - { - ret |= setEffect(Gen3A); - break; - } - - case SetFocus: - { - ret |= setFocusMode(Gen3A); - break; - } - - case SetExpMode: - { - ret |= setExposureMode(Gen3A); - break; - } - - case SetManualExposure: { - ret |= setManualExposureVal(Gen3A); - break; - } - - case SetFlash: - { - ret |= setFlashMode(Gen3A); - break; - } - - case SetExpLock: - { - ret |= setExposureLock(Gen3A); - break; - } - - case SetWBLock: - { - ret |= setWhiteBalanceLock(Gen3A); - break; - } - case SetMeteringAreas: - { - ret |= setMeteringAreas(Gen3A); - } - break; - -#ifndef OMAP_TUNA - //TI extensions for enable/disable algos - case SetAlgoFixedGamma: - { - ret |= setAlgoFixedGamma(Gen3A); - } - break; - - case SetAlgoNSF1: - { - ret |= setAlgoNSF1(Gen3A); - } - break; - - case SetAlgoNSF2: - { - ret |= setAlgoNSF2(Gen3A); - } - break; - - case SetAlgoSharpening: - { - ret |= setAlgoSharpening(Gen3A); - } - break; - - case SetAlgoThreeLinColorMap: - { - ret |= setAlgoThreeLinColorMap(Gen3A); - } - break; - - case SetAlgoGIC: - { - ret |= setAlgoGIC(Gen3A); - } - break; -#endif - - default: - CAMHAL_LOGEB("this setting (0x%x) is still not supported in CameraAdapter ", - currSett); - break; - } - mPending3Asettings &= ~currSett; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/OMXCameraAdapter/OMXAlgo.cpp b/camera/OMXCameraAdapter/OMXAlgo.cpp deleted file mode 100644 index 2188590..0000000 --- a/camera/OMXCameraAdapter/OMXAlgo.cpp +++ /dev/null @@ -1,1261 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMXAlgo.cpp -* -* This file contains functionality for handling algorithm configurations. -* -*/ - -#include "CameraHal.h" -#include "OMXCameraAdapter.h" -#include "ErrorUtils.h" - -#undef TRUE - -namespace Ti { -namespace Camera { - -status_t OMXCameraAdapter::setParametersAlgo(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state) -{ - status_t ret = NO_ERROR; - const char *valstr = NULL; - const char *valManualStr = NULL; - const char *oldstr = NULL; - OMXCameraPortParameters *cap; - BrightnessMode gbce = BRIGHTNESS_OFF; - BrightnessMode glbce = BRIGHTNESS_OFF; - - LOG_FUNCTION_NAME; - - CaptureMode capMode; - CAMHAL_LOGDB("Capture mode %s", params.get(TICameraParameters::KEY_CAP_MODE)); - if ( (valstr = params.get(TICameraParameters::KEY_CAP_MODE)) != NULL ) { - if (strcmp(valstr, (const char *) TICameraParameters::HIGH_PERFORMANCE_MODE) == 0) { - capMode = OMXCameraAdapter::HIGH_SPEED; - mCapabilitiesOpMode = MODE_HIGH_SPEED; - } else if (strcmp(valstr, (const char *) TICameraParameters::EXPOSURE_BRACKETING) == 0) { - capMode = OMXCameraAdapter::HIGH_SPEED; - mCapabilitiesOpMode = MODE_HIGH_SPEED; - } else if (strcmp(valstr, (const char *) TICameraParameters::ZOOM_BRACKETING) == 0) { - capMode = OMXCameraAdapter::HIGH_SPEED; - mCapabilitiesOpMode = MODE_HIGH_SPEED; - } else if (strcmp(valstr, (const char *) TICameraParameters::HIGH_QUALITY_MODE) == 0) { - capMode = OMXCameraAdapter::HIGH_QUALITY; - mCapabilitiesOpMode = MODE_HIGH_QUALITY; - } else if (strcmp(valstr, (const char *) TICameraParameters::HIGH_QUALITY_ZSL_MODE) == 0) { - capMode = OMXCameraAdapter::HIGH_QUALITY_ZSL; - mCapabilitiesOpMode = MODE_ZEROSHUTTERLAG; - } else if (strcmp(valstr, (const char *) TICameraParameters::VIDEO_MODE) == 0) { - capMode = OMXCameraAdapter::VIDEO_MODE; - mCapabilitiesOpMode = MODE_VIDEO; - } else if (strcmp(valstr, (const char *) TICameraParameters::CP_CAM_MODE) == 0) { - capMode = OMXCameraAdapter::CP_CAM; - mCapabilitiesOpMode = MODE_CPCAM; - } else if (strcmp(valstr, (const char *) TICameraParameters::TEMP_BRACKETING) == 0) { - capMode = OMXCameraAdapter::HIGH_SPEED; - mCapabilitiesOpMode = MODE_HIGH_SPEED; - } else { - capMode = OMXCameraAdapter::HIGH_QUALITY; - mCapabilitiesOpMode = MODE_HIGH_QUALITY; - } - - } else { - capMode = OMXCameraAdapter::HIGH_QUALITY; - mCapabilitiesOpMode = MODE_HIGH_QUALITY; - } - -#ifndef OMAP_TUNA - if ( mSensorIndex == 2 ) { - mCapabilitiesOpMode = MODE_STEREO; - } -#endif - - if ( mCapMode != capMode ) { - mCapMode = capMode; - mOMXStateSwitch = true; - mPendingPreviewSettings |= SetCapMode; - } - - CAMHAL_LOGDB("Capture Mode set %d", mCapMode); - - /// Configure IPP, LDCNSF, GBCE and GLBCE only in HQ mode - IPPMode ipp; - if((mCapMode == OMXCameraAdapter::HIGH_QUALITY) || (mCapMode == OMXCameraAdapter::HIGH_QUALITY_ZSL) - || (mCapMode == OMXCameraAdapter::VIDEO_MODE) - || (mCapMode == OMXCameraAdapter::CP_CAM)) - { - if ( (valstr = params.get(TICameraParameters::KEY_IPP)) != NULL ) - { - if (strcmp(valstr, (const char *) TICameraParameters::IPP_LDCNSF) == 0) - { - ipp = OMXCameraAdapter::IPP_LDCNSF; - } - else if (strcmp(valstr, (const char *) TICameraParameters::IPP_LDC) == 0) - { - ipp = OMXCameraAdapter::IPP_LDC; - } - else if (strcmp(valstr, (const char *) TICameraParameters::IPP_NSF) == 0) - { - ipp = OMXCameraAdapter::IPP_NSF; - } - else if (strcmp(valstr, (const char *) TICameraParameters::IPP_NONE) == 0) - { - ipp = OMXCameraAdapter::IPP_NONE; - } - else - { - ipp = OMXCameraAdapter::IPP_NONE; - } - } - else - { - ipp = OMXCameraAdapter::IPP_NONE; - } - - CAMHAL_LOGVB("IPP Mode set %d", ipp); - - if (((valstr = params.get(TICameraParameters::KEY_GBCE)) != NULL) ) { - if (strcmp(valstr, android::CameraParameters::TRUE ) == 0) { - gbce = BRIGHTNESS_ON; - } else { - gbce = BRIGHTNESS_OFF; - } - - if ( gbce != mGBCE ) { - mGBCE = gbce; - setGBCE(mGBCE); - } - - } else if(mFirstTimeInit) { - //Disable GBCE by default - setGBCE(OMXCameraAdapter::BRIGHTNESS_OFF); - } - - if ( ( valstr = params.get(TICameraParameters::KEY_GLBCE) ) != NULL ) { - - if (strcmp(valstr, android::CameraParameters::TRUE) == 0) { - glbce = BRIGHTNESS_ON; - } else { - glbce = BRIGHTNESS_OFF; - } - - if ( glbce != mGLBCE ) { - mGLBCE = glbce; - setGLBCE(mGLBCE); - } - - } else if(mFirstTimeInit) { - //Disable GLBCE by default - setGLBCE(OMXCameraAdapter::BRIGHTNESS_OFF); - } - - } else { - ipp = OMXCameraAdapter::IPP_NONE; - } - - if ( mIPP != ipp ) - { - mIPP = ipp; - mOMXStateSwitch = true; - mPendingPreviewSettings |= SetLDC; - mPendingPreviewSettings |= SetNSF; - } - - ///Set VNF Configuration - bool vnfEnabled = false; - valstr = params.get(TICameraParameters::KEY_VNF); - if (valstr && strcmp(valstr, android::CameraParameters::TRUE) == 0) - { - CAMHAL_LOGDA("VNF Enabled"); - vnfEnabled = true; - } - else - { - CAMHAL_LOGDA("VNF Disabled"); - vnfEnabled = false; - } - - if ( mVnfEnabled != vnfEnabled ) - { - mVnfEnabled = vnfEnabled; - mOMXStateSwitch = true; - mPendingPreviewSettings |= SetVNF; - } - - ///Set VSTAB Configuration - bool vstabEnabled = false; - valstr = params.get(android::CameraParameters::KEY_VIDEO_STABILIZATION); - if (valstr && strcmp(valstr, android::CameraParameters::TRUE) == 0) { - CAMHAL_LOGDA("VSTAB Enabled"); - vstabEnabled = true; - } - else - { - CAMHAL_LOGDA("VSTAB Disabled"); - vstabEnabled = false; - } - - if ( mVstabEnabled != vstabEnabled ) - { - mVstabEnabled = vstabEnabled; - mOMXStateSwitch = true; - mPendingPreviewSettings |= SetVSTAB; - } - - //A work-around for a failing call to OMX flush buffers - if ( ( capMode = OMXCameraAdapter::VIDEO_MODE ) && - ( mVstabEnabled ) ) - { - mOMXStateSwitch = true; - } - -#ifdef OMAP_ENHANCEMENT - - //Set Auto Convergence Mode - valstr = params.get((const char *) TICameraParameters::KEY_AUTOCONVERGENCE_MODE); - valManualStr = params.get(TICameraParameters::KEY_MANUAL_CONVERGENCE); - - cap = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - - if (cap->mFrameLayoutType != OMX_TI_StereoFrameLayout2D) { - if ((valstr != NULL) || (valManualStr != NULL)) { - setAutoConvergence(valstr, valManualStr, params); - if (valstr != NULL) { - CAMHAL_LOGDB("AutoConvergenceMode %s", valstr); - } - if (valManualStr != NULL) { - CAMHAL_LOGDB("Manual Convergence %s", valManualStr); - } - } - - //Set Mechanical Misalignment Correction - valstr = params.get(TICameraParameters::KEY_MECHANICAL_MISALIGNMENT_CORRECTION); - if ( valstr != NULL ) { - setMechanicalMisalignmentCorrection(strcmp(valstr, android::CameraParameters::TRUE) == 0); - CAMHAL_LOGDB("Mechanical Misalignment Correction %s", valstr); - } - } - -#endif - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -// Set AutoConvergence -status_t OMXCameraAdapter::setAutoConvergence(const char *pValstr, const char *pValManualstr, const android::CameraParameters ¶ms) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_TI_CONFIG_CONVERGENCETYPE ACParams; - const char *str = NULL; - android::Vector > tempAreas; - int mode; - int changed = 0; - - LOG_FUNCTION_NAME; - - if ( pValManualstr != NULL ) { - OMX_S32 manualConvergence = (OMX_S32)strtol(pValManualstr ,0 ,0); - - if (mManualConv != manualConvergence) { - mManualConv = manualConvergence; - changed = 1; - } - } - - if ( pValstr != NULL ) { - mode = getLUTvalue_HALtoOMX(pValstr, mAutoConvergenceLUT); - - if ( NAME_NOT_FOUND == mode ) { - CAMHAL_LOGEB("Wrong convergence mode: %s", pValstr); - LOG_FUNCTION_NAME_EXIT; - return mode; - } - - if ( mAutoConv != static_cast (mode) ) { - mAutoConv = static_cast (mode); - changed = 1; - } - } - - if ( OMX_TI_AutoConvergenceModeFocusFaceTouch == mAutoConv ) { - android::AutoMutex lock(mTouchAreasLock); - - str = params.get(android::CameraParameters::KEY_METERING_AREAS); - - if ( NULL != str ) { - ret = CameraArea::parseAreas(str, ( strlen(str) + 1 ), tempAreas); - } else { - CAMHAL_LOGEB("Touch areas not received in %s", - android::CameraParameters::KEY_METERING_AREAS); - LOG_FUNCTION_NAME_EXIT; - return BAD_VALUE; - } - - if ( CameraArea::areAreasDifferent(mTouchAreas, tempAreas) ) { - mTouchAreas.clear(); - mTouchAreas = tempAreas; - changed = 1; - } - } - - if (!changed) { - LOG_FUNCTION_NAME_EXIT; - return NO_ERROR; - } - - OMXCameraPortParameters * mPreviewData; - mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - - ACParams.nSize = (OMX_U32)sizeof(OMX_TI_CONFIG_CONVERGENCETYPE); - ACParams.nVersion = mLocalVersionParam; - ACParams.nPortIndex = OMX_ALL; - - OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexConfigAutoConvergence, - &ACParams); - - ACParams.eACMode = mAutoConv; - ACParams.nManualConverence = mManualConv; - - if (1 == mTouchAreas.size()) { - int widthDivisor = 1; - int heightDivisor = 1; - - if (mPreviewData->mFrameLayoutType == OMX_TI_StereoFrameLayoutTopBottom) { - heightDivisor = 2; - } - if (mPreviewData->mFrameLayoutType == OMX_TI_StereoFrameLayoutLeftRight) { - widthDivisor = 2; - } - - // transform the coordinates to 3A-type coordinates - mTouchAreas.itemAt(0)->transfrom((size_t)mPreviewData->mWidth/widthDivisor, - (size_t)mPreviewData->mHeight/heightDivisor, - (size_t&) ACParams.nACProcWinStartY, - (size_t&) ACParams.nACProcWinStartX, - (size_t&) ACParams.nACProcWinWidth, - (size_t&) ACParams.nACProcWinHeight); - } - - CAMHAL_LOGDB("nSize %d", (int)ACParams.nSize); - CAMHAL_LOGDB("nPortIndex %d", (int)ACParams.nPortIndex); - CAMHAL_LOGDB("nManualConverence %d", (int)ACParams.nManualConverence); - CAMHAL_LOGDB("eACMode %d", (int)ACParams.eACMode); - CAMHAL_LOGDB("nACProcWinStartX %d", (int)ACParams.nACProcWinStartX); - CAMHAL_LOGDB("nACProcWinStartY %d", (int)ACParams.nACProcWinStartY); - CAMHAL_LOGDB("nACProcWinWidth %d", (int)ACParams.nACProcWinWidth); - CAMHAL_LOGDB("nACProcWinHeight %d", (int)ACParams.nACProcWinHeight); - CAMHAL_LOGDB("bACStatus %d", (int)ACParams.bACStatus); - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexConfigAutoConvergence, - &ACParams); - - if ( eError != OMX_ErrorNone ) { - CAMHAL_LOGEB("Error while setting AutoConvergence 0x%x", eError); - ret = BAD_VALUE; - } else { - CAMHAL_LOGDA("AutoConvergence applied successfully"); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::enableVideoNoiseFilter(bool enable) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_PARAM_VIDEONOISEFILTERTYPE vnfCfg; - - - LOG_FUNCTION_NAME; - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR (&vnfCfg, OMX_PARAM_VIDEONOISEFILTERTYPE); - - if ( enable ) - { - CAMHAL_LOGDA("VNF is enabled"); - vnfCfg.eMode = OMX_VideoNoiseFilterModeOn; - } - else - { - CAMHAL_LOGDA("VNF is disabled"); - vnfCfg.eMode = OMX_VideoNoiseFilterModeOff; - } - - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_IndexParamVideoNoiseFilter, - &vnfCfg); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring video noise filter 0x%x", eError); - ret = -1; - } - else - { - CAMHAL_LOGDA("Video noise filter is configured successfully"); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::enableVideoStabilization(bool enable) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_FRAMESTABTYPE frameStabCfg; - - - LOG_FUNCTION_NAME; - - if ( NO_ERROR == ret ) - { - OMX_CONFIG_BOOLEANTYPE vstabp; - OMX_INIT_STRUCT_PTR (&vstabp, OMX_CONFIG_BOOLEANTYPE); - if(enable) - { - vstabp.bEnabled = OMX_TRUE; - } - else - { - vstabp.bEnabled = OMX_FALSE; - } - - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_IndexParamFrameStabilisation, - &vstabp); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring video stabilization param 0x%x", eError); - ret = -1; - } - else - { - CAMHAL_LOGDA("Video stabilization param configured successfully"); - } - - } - - if ( NO_ERROR == ret ) - { - - OMX_INIT_STRUCT_PTR (&frameStabCfg, OMX_CONFIG_FRAMESTABTYPE); - - - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_IndexConfigCommonFrameStabilisation, - &frameStabCfg); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while getting video stabilization mode 0x%x", - (unsigned int)eError); - ret = -1; - } - - CAMHAL_LOGDB("VSTAB Port Index = %d", (int)frameStabCfg.nPortIndex); - - frameStabCfg.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - if ( enable ) - { - CAMHAL_LOGDA("VSTAB is enabled"); - frameStabCfg.bStab = OMX_TRUE; - } - else - { - CAMHAL_LOGDA("VSTAB is disabled"); - frameStabCfg.bStab = OMX_FALSE; - - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_IndexConfigCommonFrameStabilisation, - &frameStabCfg); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring video stabilization mode 0x%x", eError); - ret = -1; - } - else - { - CAMHAL_LOGDA("Video stabilization mode configured successfully"); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setGBCE(OMXCameraAdapter::BrightnessMode mode) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_TI_CONFIG_LOCAL_AND_GLOBAL_BRIGHTNESSCONTRASTTYPE bControl; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR (&bControl, OMX_TI_CONFIG_LOCAL_AND_GLOBAL_BRIGHTNESSCONTRASTTYPE); - - bControl.nPortIndex = OMX_ALL; - - switch ( mode ) - { - case OMXCameraAdapter::BRIGHTNESS_ON: - { - bControl.eControl = OMX_TI_BceModeOn; - break; - } - case OMXCameraAdapter::BRIGHTNESS_AUTO: - { - bControl.eControl = OMX_TI_BceModeAuto; - break; - } - case OMXCameraAdapter::BRIGHTNESS_OFF: - default: - { - bControl.eControl = OMX_TI_BceModeOff; - break; - } - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_TI_IndexConfigGlobalBrightnessContrastEnhance, - &bControl); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while setting GBCE 0x%x", eError); - } - else - { - CAMHAL_LOGDB("GBCE configured successfully 0x%x", mode); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setGLBCE(OMXCameraAdapter::BrightnessMode mode) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_TI_CONFIG_LOCAL_AND_GLOBAL_BRIGHTNESSCONTRASTTYPE bControl; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR (&bControl, OMX_TI_CONFIG_LOCAL_AND_GLOBAL_BRIGHTNESSCONTRASTTYPE); - bControl.nPortIndex = OMX_ALL; - - switch ( mode ) - { - case OMXCameraAdapter::BRIGHTNESS_ON: - { - bControl.eControl = OMX_TI_BceModeOn; - break; - } - case OMXCameraAdapter::BRIGHTNESS_AUTO: - { - bControl.eControl = OMX_TI_BceModeAuto; - break; - } - case OMXCameraAdapter::BRIGHTNESS_OFF: - default: - { - bControl.eControl = OMX_TI_BceModeOff; - break; - } - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_TI_IndexConfigLocalBrightnessContrastEnhance, - &bControl); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configure GLBCE 0x%x", eError); - } - else - { - CAMHAL_LOGDA("GLBCE configured successfully"); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setCaptureMode(OMXCameraAdapter::CaptureMode mode) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_CAMOPERATINGMODETYPE camMode; - OMX_CONFIG_BOOLEANTYPE bCAC; -#ifndef OMAP_TUNA - OMX_TI_CONFIG_SINGLEPREVIEWMODETYPE singlePrevMode; -#endif - - LOG_FUNCTION_NAME; - - //CAC is disabled by default - OMX_INIT_STRUCT_PTR (&bCAC, OMX_CONFIG_BOOLEANTYPE); -#ifndef OMAP_TUNA - OMX_INIT_STRUCT_PTR (&singlePrevMode, OMX_TI_CONFIG_SINGLEPREVIEWMODETYPE); -#endif - bCAC.bEnabled = OMX_FALSE; - - if ( NO_ERROR == ret ) - { - - OMX_INIT_STRUCT_PTR (&camMode, OMX_CONFIG_CAMOPERATINGMODETYPE); - if ( mSensorIndex == OMX_TI_StereoSensor ) - { -#ifndef OMAP_TUNA - if ( OMXCameraAdapter::VIDEO_MODE == mode ) { - CAMHAL_LOGDA("Camera mode: STEREO VIDEO"); - camMode.eCamOperatingMode = OMX_TI_StereoVideo; - } else { -#endif - CAMHAL_LOGDA("Camera mode: STEREO"); - camMode.eCamOperatingMode = OMX_CaptureStereoImageCapture; -#ifndef OMAP_TUNA - } -#endif - } - else if ( OMXCameraAdapter::HIGH_SPEED == mode ) - { - CAMHAL_LOGDA("Camera mode: HIGH SPEED"); - camMode.eCamOperatingMode = OMX_CaptureImageHighSpeedTemporalBracketing; - } - else if ( OMXCameraAdapter::CP_CAM == mode ) - { - CAMHAL_LOGDA("Camera mode: CP CAM"); -#ifndef OMAP_TUNA - camMode.eCamOperatingMode = OMX_TI_CPCam; - // TODO(XXX): Hardcode for now until we implement re-proc pipe - singlePrevMode.eMode = OMX_TI_SinglePreviewMode_ImageCaptureHighSpeed; -#endif - } - else if( OMXCameraAdapter::HIGH_QUALITY == mode ) - { - CAMHAL_LOGDA("Camera mode: HIGH QUALITY"); - camMode.eCamOperatingMode = OMX_CaptureImageProfileBase; - } - else if( OMXCameraAdapter::HIGH_QUALITY_ZSL== mode ) - { - const char* valstr = NULL; - CAMHAL_LOGDA("Camera mode: HIGH QUALITY_ZSL"); - camMode.eCamOperatingMode = OMX_TI_CaptureImageProfileZeroShutterLag; - -#ifdef CAMERAHAL_TUNA - if ( !mIternalRecordingHint ) { - zslHistoryLen.nHistoryLen = 5; - } -#endif - - } - else if( OMXCameraAdapter::VIDEO_MODE == mode ) - { - CAMHAL_LOGDA("Camera mode: VIDEO MODE"); - camMode.eCamOperatingMode = OMX_CaptureVideo; - } - else - { - CAMHAL_LOGEA("Camera mode: INVALID mode passed!"); - return BAD_VALUE; - } - - if( NO_ERROR == ret ) - { - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_IndexCameraOperatingMode, - &camMode); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring camera mode 0x%x", eError); - ret = Utils::ErrorUtils::omxToAndroidError(eError); - } - else - { - CAMHAL_LOGDA("Camera mode configured successfully"); - } - } - -#ifndef OMAP_TUNA - if((NO_ERROR == ret) && (OMXCameraAdapter::CP_CAM == mode)) { - //Configure Single Preview Mode - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_TI_IndexConfigSinglePreviewMode, - &singlePrevMode); - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while configuring single preview mode 0x%x", eError); - ret = Utils::ErrorUtils::omxToAndroidError(eError); - } else { - CAMHAL_LOGDA("single preview mode configured successfully"); - } - } -#endif - - if( NO_ERROR == ret ) - { - //Configure CAC - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_IndexConfigChromaticAberrationCorrection, - &bCAC); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring CAC 0x%x", eError); - ret = Utils::ErrorUtils::omxToAndroidError(eError); - } - else - { - CAMHAL_LOGDA("CAC configured successfully"); - } - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setLDC(OMXCameraAdapter::IPPMode mode) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_BOOLEANTYPE bOMX; - - LOG_FUNCTION_NAME; - - if ( OMX_StateLoaded != mComponentState ) - { - CAMHAL_LOGEA("OMX component is not in loaded state"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR (&bOMX, OMX_CONFIG_BOOLEANTYPE); - - switch ( mode ) - { - case OMXCameraAdapter::IPP_LDCNSF: - case OMXCameraAdapter::IPP_LDC: - { - bOMX.bEnabled = OMX_TRUE; - break; - } - case OMXCameraAdapter::IPP_NONE: - case OMXCameraAdapter::IPP_NSF: - default: - { - bOMX.bEnabled = OMX_FALSE; - break; - } - } - - CAMHAL_LOGVB("Configuring LDC mode 0x%x", bOMX.bEnabled); - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_IndexParamLensDistortionCorrection, - &bOMX); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEA("Error while setting LDC"); - ret = -1; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setNSF(OMXCameraAdapter::IPPMode mode) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_PARAM_ISONOISEFILTERTYPE nsf; - - LOG_FUNCTION_NAME; - - if ( OMX_StateLoaded != mComponentState ) - { - CAMHAL_LOGEA("OMX component is not in loaded state"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR (&nsf, OMX_PARAM_ISONOISEFILTERTYPE); - nsf.nPortIndex = OMX_ALL; - - switch ( mode ) - { - case OMXCameraAdapter::IPP_LDCNSF: - case OMXCameraAdapter::IPP_NSF: - { - nsf.eMode = OMX_ISONoiseFilterModeOn; - break; - } - case OMXCameraAdapter::IPP_LDC: - case OMXCameraAdapter::IPP_NONE: - default: - { - nsf.eMode = OMX_ISONoiseFilterModeOff; - break; - } - } - - CAMHAL_LOGVB("Configuring NSF mode 0x%x", nsf.eMode); - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_IndexParamHighISONoiseFiler, - &nsf); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEA("Error while setting NSF"); - ret = -1; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setImageQuality(unsigned int quality) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_PARAM_QFACTORTYPE jpegQualityConf; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT(jpegQualityConf, OMX_IMAGE_PARAM_QFACTORTYPE); - jpegQualityConf.nQFactor = quality; - jpegQualityConf.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - OMX_IndexParamQFactor, - &jpegQualityConf); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring jpeg Quality 0x%x", eError); - ret = -1; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setThumbnailParams(unsigned int width, - unsigned int height, - unsigned int quality) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_PARAM_THUMBNAILTYPE thumbConf; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT(thumbConf, OMX_PARAM_THUMBNAILTYPE); - thumbConf.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - - eError = OMX_GetParameter(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_IndexParamThumbnail, - &thumbConf); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while retrieving thumbnail size 0x%x", eError); - ret = -1; - } - - //CTS Requirement: width or height equal to zero should - //result in absent EXIF thumbnail - if ( ( 0 == width ) || ( 0 == height ) ) - { - thumbConf.nWidth = mThumbRes[0].width; - thumbConf.nHeight = mThumbRes[0].height; - thumbConf.eCompressionFormat = OMX_IMAGE_CodingUnused; - } - else - { - thumbConf.nWidth = width; - thumbConf.nHeight = height; - thumbConf.nQuality = quality; - thumbConf.eCompressionFormat = OMX_IMAGE_CodingJPEG; - } - - CAMHAL_LOGDB("Thumbnail width = %d, Thumbnail Height = %d", width, height); - - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_IndexParamThumbnail, - &thumbConf); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring thumbnail size 0x%x", eError); - ret = -1; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setAlgoPriority(AlgoPriority priority, - Algorithm3A algo, - bool enable) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - if ( FACE_PRIORITY == priority ) { - - if ( algo & WHITE_BALANCE_ALGO ) { - if ( enable ) { - mFacePriority.bAwbFaceEnable = OMX_TRUE; - } else { - mFacePriority.bAwbFaceEnable = OMX_FALSE; - } - } - - if ( algo & EXPOSURE_ALGO ) { - if ( enable ) { - mFacePriority.bAeFaceEnable = OMX_TRUE; - } else { - mFacePriority.bAeFaceEnable = OMX_FALSE; - } - } - - if ( algo & FOCUS_ALGO ) { - if ( enable ) { - mFacePriority.bAfFaceEnable = OMX_TRUE; - } else { - mFacePriority.bAfFaceEnable = OMX_FALSE; - } - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_TI_IndexConfigFacePriority3a, - &mFacePriority); - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while configuring face priority 0x%x", eError); - } else { - CAMHAL_LOGDB("Face priority for algorithms set successfully 0x%x, 0x%x, 0x%x", - mFacePriority.bAfFaceEnable, - mFacePriority.bAeFaceEnable, - mFacePriority.bAwbFaceEnable); - } - - } else if ( REGION_PRIORITY == priority ) { - - if ( algo & WHITE_BALANCE_ALGO ) { - if ( enable ) { - mRegionPriority.bAwbRegionEnable= OMX_TRUE; - } else { - mRegionPriority.bAwbRegionEnable = OMX_FALSE; - } - } - - if ( algo & EXPOSURE_ALGO ) { - if ( enable ) { - mRegionPriority.bAeRegionEnable = OMX_TRUE; - } else { - mRegionPriority.bAeRegionEnable = OMX_FALSE; - } - } - - if ( algo & FOCUS_ALGO ) { - if ( enable ) { - mRegionPriority.bAfRegionEnable = OMX_TRUE; - } else { - mRegionPriority.bAfRegionEnable = OMX_FALSE; - } - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_TI_IndexConfigRegionPriority3a, - &mRegionPriority); - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while configuring region priority 0x%x", eError); - } else { - CAMHAL_LOGDB("Region priority for algorithms set successfully 0x%x, 0x%x, 0x%x", - mRegionPriority.bAfRegionEnable, - mRegionPriority.bAeRegionEnable, - mRegionPriority.bAwbRegionEnable); - } - - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::setPictureRotation(unsigned int degree) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_ROTATIONTYPE rotation; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = -1; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT(rotation, OMX_CONFIG_ROTATIONTYPE); - rotation.nRotation = degree; - rotation.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonRotate, - &rotation); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring rotation 0x%x", eError); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setSensorOrientation(unsigned int degree) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_ROTATIONTYPE sensorOrientation; - int tmpHeight, tmpWidth; - OMXCameraPortParameters *mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - - LOG_FUNCTION_NAME; - if ( OMX_StateInvalid == mComponentState ) { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = -1; - } - - /* Set Temproary Port resolution. - * For resolution with height >= 720, - * resolution cannot be set without configuring orientation. - * So we first set a temp resolution. We have used VGA - */ - if ( mPreviewData->mHeight >= 720 ) { - tmpHeight = mPreviewData->mHeight; - tmpWidth = mPreviewData->mWidth; - mPreviewData->mWidth = 640; - mPreviewData->mHeight = 480; - - ret = setFormat(OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW, *mPreviewData); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error while configuring format 0x%x", ret); - return ret; - } - - mPreviewData->mWidth = tmpWidth; - mPreviewData->mHeight = tmpHeight; - mPreviewPortInitialized = true; - } - else if (!mPreviewPortInitialized) { - ret = setFormat(OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW, *mPreviewData); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error while configuring format 0x%x", ret); - return ret; - } - mPreviewPortInitialized = true; - } - - /* Now set Required Orientation*/ - if ( NO_ERROR == ret ) { - OMX_INIT_STRUCT(sensorOrientation, OMX_CONFIG_ROTATIONTYPE); - sensorOrientation.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - sensorOrientation.nRotation = degree; - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonRotate, - &sensorOrientation); - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while configuring rotation 0x%x", eError); - } - CAMHAL_LOGVB(" Currently Sensor Orientation is set to : %d", - ( unsigned int ) sensorOrientation.nRotation); - CAMHAL_LOGVB(" Sensor Configured for Port : %d", - ( unsigned int ) sensorOrientation.nPortIndex); - } - - /* Now set the required resolution as requested */ - if ( NO_ERROR == ret ) { - bool portConfigured = false; - ret = setSensorQuirks(degree, - mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex], - portConfigured); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error while configuring setSensorQuirks 0x%x", ret); - return ret; - } - - if ( !portConfigured ) { - ret = setFormat (mCameraAdapterParameters.mPrevPortIndex, - mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error while configuring format 0x%x", ret); - return ret; - } - - // Another WA: Setting the port definition will reset the VFR - // configuration. - setVFramerate(mPreviewData->mMinFrameRate, - mPreviewData->mMaxFrameRate); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setVFramerate(OMX_U32 minFrameRate, OMX_U32 maxFrameRate) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_TI_CONFIG_VARFRMRANGETYPE vfr; - OMXCameraPortParameters * mPreviewData = - &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = -EINVAL; - } - - if ( !mSetFormatDone ) { - return NO_INIT; - } - - if ( NO_ERROR == ret ) { - OMX_INIT_STRUCT_PTR (&vfr, OMX_TI_CONFIG_VARFRMRANGETYPE); - - vfr.xMin = minFrameRate<<16; - vfr.xMax = maxFrameRate<<16; - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexConfigVarFrmRange, - &vfr); - if(OMX_ErrorNone != eError) { - CAMHAL_LOGEB("Error while setting VFR min = %d, max = %d, error = 0x%x", - ( unsigned int ) minFrameRate, - ( unsigned int ) maxFrameRate, - eError); - ret = -1; - } else { - CAMHAL_LOGDB("VFR Configured Successfully [%d:%d]", - ( unsigned int ) minFrameRate, - ( unsigned int ) maxFrameRate); - } - } - - return ret; -} - -#ifndef OMAP_TUNA -status_t OMXCameraAdapter::setMechanicalMisalignmentCorrection(const bool enable) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_TI_CONFIG_MM mm; - - LOG_FUNCTION_NAME; - - mm.nVersion = mLocalVersionParam; - mm.nSize = sizeof(OMX_TI_CONFIG_MM); - mm.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - mm.bMM = enable ? OMX_TRUE : OMX_FALSE; - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexConfigMechanicalMisalignment, - &mm); - - if(OMX_ErrorNone != eError) { - CAMHAL_LOGEB("Error while enabling mechanical misalignment correction. error = 0x%x", eError); - ret = -1; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} -#endif - -} // namespace Camera -} // namespace Ti diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp deleted file mode 100644 index 2a9254c..0000000 --- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp +++ /dev/null @@ -1,4721 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMXCameraAdapter.cpp -* -* This file maps the Camera Hardware Interface to OMX. -* -*/ - -#include "CameraHal.h" -#include "OMXCameraAdapter.h" -#include "ErrorUtils.h" -#include "TICameraParameters.h" -#include -#include - -#include -#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false )) -static int mDebugFps = 0; -static int mDebugFcs = 0; - -#define HERE(Msg) {CAMHAL_LOGEB("--===line %d, %s===--\n", __LINE__, Msg);} - -namespace Ti { -namespace Camera { - -#ifdef CAMERAHAL_OMX_PROFILING - -const char OMXCameraAdapter::DEFAULT_PROFILE_PATH[] = "/data/dbg/profile_data.bin"; - -#endif - -//frames skipped before recalculating the framerate -#define FPS_PERIOD 30 - -android::Mutex gAdapterLock; -/*--------------------Camera Adapter Class STARTS here-----------------------------*/ - -status_t OMXCameraAdapter::initialize(CameraProperties::Properties* caps) -{ - LOG_FUNCTION_NAME; - - char value[PROPERTY_VALUE_MAX]; - const char *mountOrientationString = NULL; - - property_get("debug.camera.showfps", value, "0"); - mDebugFps = atoi(value); - property_get("debug.camera.framecounts", value, "0"); - mDebugFcs = atoi(value); - -#ifdef CAMERAHAL_OMX_PROFILING - - property_get("debug.camera.profile", value, "0"); - mDebugProfile = atoi(value); - -#endif - - TIMM_OSAL_ERRORTYPE osalError = OMX_ErrorNone; - OMX_ERRORTYPE eError = OMX_ErrorNone; - status_t ret = NO_ERROR; - - mLocalVersionParam.s.nVersionMajor = 0x1; - mLocalVersionParam.s.nVersionMinor = 0x1; - mLocalVersionParam.s.nRevision = 0x0 ; - mLocalVersionParam.s.nStep = 0x0; - - mPending3Asettings = 0;//E3AsettingsAll; - mPendingCaptureSettings = 0; - mPendingPreviewSettings = 0; - - if ( 0 != mInitSem.Count() ) - { - CAMHAL_LOGEB("Error mInitSem semaphore count %d", mInitSem.Count()); - LOG_FUNCTION_NAME_EXIT; - return NO_INIT; - } - - ///Update the preview and image capture port indexes - mCameraAdapterParameters.mPrevPortIndex = OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW; - // temp changed in order to build OMX_CAMERA_PORT_VIDEO_OUT_IMAGE; - mCameraAdapterParameters.mImagePortIndex = OMX_CAMERA_PORT_IMAGE_OUT_IMAGE; - mCameraAdapterParameters.mMeasurementPortIndex = OMX_CAMERA_PORT_VIDEO_OUT_MEASUREMENT; - //currently not supported use preview port instead - mCameraAdapterParameters.mVideoPortIndex = OMX_CAMERA_PORT_VIDEO_OUT_VIDEO; - mCameraAdapterParameters.mVideoInPortIndex = OMX_CAMERA_PORT_VIDEO_IN_VIDEO; - - eError = OMX_Init(); - if (eError != OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_Init() failed, error: 0x%x", eError); - return Utils::ErrorUtils::omxToAndroidError(eError); - } - mOmxInitialized = true; - - // Initialize the callback handles - OMX_CALLBACKTYPE callbacks; - callbacks.EventHandler = Camera::OMXCameraAdapterEventHandler; - callbacks.EmptyBufferDone = Camera::OMXCameraAdapterEmptyBufferDone; - callbacks.FillBufferDone = Camera::OMXCameraAdapterFillBufferDone; - - ///Get the handle to the OMX Component - eError = OMXCameraAdapter::OMXCameraGetHandle(&mCameraAdapterParameters.mHandleComp, this, callbacks); - if(eError != OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_GetHandle -0x%x", eError); - } - GOTO_EXIT_IF((eError != OMX_ErrorNone), eError); - - mComponentState = OMX_StateLoaded; - - CAMHAL_LOGVB("OMX_GetHandle -0x%x sensor_index = %lu", eError, mSensorIndex); -#ifndef OMAP_TUNA - initDccFileDataSave(&mCameraAdapterParameters.mHandleComp, mCameraAdapterParameters.mPrevPortIndex); -#endif - - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortDisable, - OMX_ALL, - NULL); - - if(eError != OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_SendCommand(OMX_CommandPortDisable) -0x%x", eError); - } - GOTO_EXIT_IF((eError != OMX_ErrorNone), eError); - - // Register for port enable event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mPrevPortIndex, - mInitSem); - if(ret != NO_ERROR) { - CAMHAL_LOGEB("Error in registering for event %d", ret); - goto EXIT; - } - - // Enable PREVIEW Port - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortEnable, - mCameraAdapterParameters.mPrevPortIndex, - NULL); - if(eError != OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_SendCommand(OMX_CommandPortEnable) -0x%x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - // Wait for the port enable event to occur - ret = mInitSem.WaitTimeout(OMX_CMD_TIMEOUT); - if ( NO_ERROR == ret ) { - CAMHAL_LOGDA("-Port enable event arrived"); - } else { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mPrevPortIndex, - NULL); - CAMHAL_LOGEA("Timeout for enabling preview port expired!"); - goto EXIT; - } - - // Select the sensor - OMX_CONFIG_SENSORSELECTTYPE sensorSelect; - OMX_INIT_STRUCT_PTR (&sensorSelect, OMX_CONFIG_SENSORSELECTTYPE); - sensorSelect.eSensor = (OMX_SENSORSELECT) mSensorIndex; - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, ( OMX_INDEXTYPE ) OMX_TI_IndexConfigSensorSelect, &sensorSelect); - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while selecting the sensor index as %d - 0x%x", mSensorIndex, eError); - return BAD_VALUE; - } else { - CAMHAL_LOGDB("Sensor %d selected successfully", mSensorIndex); - } - -#ifdef CAMERAHAL_DEBUG - - printComponentVersion(mCameraAdapterParameters.mHandleComp); - -#endif - - mBracketingEnabled = false; - mZoomBracketingEnabled = false; - mBracketingBuffersQueuedCount = 0; - mBracketingRange = 1; - mLastBracetingBufferIdx = 0; - mBracketingBuffersQueued = NULL; - mOMXStateSwitch = false; - mBracketingSet = false; -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING - mRawCapture = false; - mYuvCapture = false; -#endif - - mCaptureSignalled = false; - mCaptureConfigured = false; - mReprocConfigured = false; - mRecording = false; - mWaitingForSnapshot = false; - mPictureFormatFromClient = NULL; - - mCapabilitiesOpMode = MODE_MAX; - mCapMode = INITIAL_MODE; - mIPP = IPP_NULL; - mVstabEnabled = false; - mVnfEnabled = false; - mBurstFrames = 1; - mBurstFramesAccum = 0; - mCapturedFrames = 0; - mFlushShotConfigQueue = false; - mPictureQuality = 100; - mCurrentZoomIdx = 0; - mTargetZoomIdx = 0; - mPreviousZoomIndx = 0; - mReturnZoomStatus = false; - mZoomInc = 1; - mZoomParameterIdx = 0; - mExposureBracketingValidEntries = 0; - mZoomBracketingValidEntries = 0; - mSensorOverclock = false; - mAutoConv = OMX_TI_AutoConvergenceModeMax; - mManualConv = 0; - -#ifdef CAMERAHAL_TUNA - mIternalRecordingHint = false; -#endif - - mDeviceOrientation = 0; - mFaceOrientation = 0; - mCapabilities = caps; - mZoomUpdating = false; - mZoomUpdate = false; - mGBCE = BRIGHTNESS_OFF; - mGLBCE = BRIGHTNESS_OFF; - mParameters3A.ExposureLock = OMX_FALSE; - mParameters3A.WhiteBalanceLock = OMX_FALSE; - - mEXIFData.mGPSData.mAltitudeValid = false; - mEXIFData.mGPSData.mDatestampValid = false; - mEXIFData.mGPSData.mLatValid = false; - mEXIFData.mGPSData.mLongValid = false; - mEXIFData.mGPSData.mMapDatumValid = false; - mEXIFData.mGPSData.mProcMethodValid = false; - mEXIFData.mGPSData.mVersionIdValid = false; - mEXIFData.mGPSData.mTimeStampValid = false; - mEXIFData.mModelValid = false; - mEXIFData.mMakeValid = false; - - //update the mDeviceOrientation with the sensor mount orientation. - //So that the face detect will work before onOrientationEvent() - //get triggered. - CAMHAL_ASSERT(mCapabilities); - mountOrientationString = mCapabilities->get(CameraProperties::ORIENTATION_INDEX); - CAMHAL_ASSERT(mountOrientationString); - mDeviceOrientation = atoi(mountOrientationString); - mFaceOrientation = atoi(mountOrientationString); - - if (mSensorIndex != 2) { - mCapabilities->setMode(MODE_HIGH_SPEED); - } - - if (mCapabilities->get(CameraProperties::SUPPORTED_ZOOM_STAGES) != NULL) { - mMaxZoomSupported = mCapabilities->getInt(CameraProperties::SUPPORTED_ZOOM_STAGES) + 1; - } else { - mMaxZoomSupported = 1; - } - - // initialize command handling thread - if(mCommandHandler.get() == NULL) - mCommandHandler = new CommandHandler(this); - - if ( NULL == mCommandHandler.get() ) - { - CAMHAL_LOGEA("Couldn't create command handler"); - return NO_MEMORY; - } - - ret = mCommandHandler->run("CallbackThread", android::PRIORITY_URGENT_DISPLAY); - if ( ret != NO_ERROR ) - { - if( ret == INVALID_OPERATION){ - CAMHAL_LOGDA("command handler thread already runnning!!"); - ret = NO_ERROR; - } else { - CAMHAL_LOGEA("Couldn't run command handlerthread"); - return ret; - } - } - - // initialize omx callback handling thread - if(mOMXCallbackHandler.get() == NULL) - mOMXCallbackHandler = new OMXCallbackHandler(this); - - if ( NULL == mOMXCallbackHandler.get() ) - { - CAMHAL_LOGEA("Couldn't create omx callback handler"); - return NO_MEMORY; - } - - ret = mOMXCallbackHandler->run("OMXCallbackThread", android::PRIORITY_URGENT_DISPLAY); - if ( ret != NO_ERROR ) - { - if( ret == INVALID_OPERATION){ - CAMHAL_LOGDA("omx callback handler thread already runnning!!"); - ret = NO_ERROR; - } else { - CAMHAL_LOGEA("Couldn't run omx callback handler thread"); - return ret; - } - } - - OMX_INIT_STRUCT_PTR (&mRegionPriority, OMX_TI_CONFIG_3A_REGION_PRIORITY); - OMX_INIT_STRUCT_PTR (&mFacePriority, OMX_TI_CONFIG_3A_FACE_PRIORITY); - mRegionPriority.nPortIndex = OMX_ALL; - mFacePriority.nPortIndex = OMX_ALL; - - //Setting this flag will that the first setParameter call will apply all 3A settings - //and will not conditionally apply based on current values. - mFirstTimeInit = true; - - //Flag to avoid calling setVFramerate() before OMX_SetParameter(OMX_IndexParamPortDefinition) - //Ducati will return an error otherwise. - mSetFormatDone = false; - - memset(mExposureBracketingValues, 0, EXP_BRACKET_RANGE*sizeof(int)); - memset(mZoomBracketingValues, 0, ZOOM_BRACKET_RANGE*sizeof(int)); - mMeasurementEnabled = false; - mFaceDetectionRunning = false; - mFaceDetectionPaused = false; - mFDSwitchAlgoPriority = false; - - metadataLastAnalogGain = -1; - metadataLastExposureTime = -1; - - memset(&mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex], 0, sizeof(OMXCameraPortParameters)); - memset(&mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex], 0, sizeof(OMXCameraPortParameters)); - memset(&mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoPortIndex], 0, sizeof(OMXCameraPortParameters)); - memset(&mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoInPortIndex], 0, sizeof(OMXCameraPortParameters)); - - // initialize 3A defaults - mParameters3A.Effect = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_EFFECT, EffLUT); - mParameters3A.FlashMode = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_FLASH_MODE, FlashLUT); - mParameters3A.SceneMode = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_SCENE_MODE, SceneLUT); - mParameters3A.EVCompensation = atoi(OMXCameraAdapter::DEFAULT_EV_COMPENSATION); - mParameters3A.Focus = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_FOCUS_MODE, FocusLUT); - mParameters3A.ISO = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_ISO_MODE, IsoLUT); - mParameters3A.Flicker = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_ANTIBANDING, FlickerLUT); - mParameters3A.Brightness = atoi(OMXCameraAdapter::DEFAULT_BRIGHTNESS); - mParameters3A.Saturation = atoi(OMXCameraAdapter::DEFAULT_SATURATION) - SATURATION_OFFSET; - mParameters3A.Sharpness = atoi(OMXCameraAdapter::DEFAULT_SHARPNESS) - SHARPNESS_OFFSET; - mParameters3A.Contrast = atoi(OMXCameraAdapter::DEFAULT_CONTRAST) - CONTRAST_OFFSET; - mParameters3A.WhiteBallance = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_WB, WBalLUT); - mParameters3A.Exposure = getLUTvalue_HALtoOMX(OMXCameraAdapter::DEFAULT_EXPOSURE_MODE, ExpLUT); - mParameters3A.ExposureLock = OMX_FALSE; - mParameters3A.FocusLock = OMX_FALSE; - mParameters3A.WhiteBalanceLock = OMX_FALSE; - - mParameters3A.ManualExposure = 0; - mParameters3A.ManualExposureRight = 0; - mParameters3A.ManualGain = 0; - mParameters3A.ManualGainRight = 0; - - mParameters3A.AlgoFixedGamma = OMX_TRUE; - mParameters3A.AlgoNSF1 = OMX_TRUE; - mParameters3A.AlgoNSF2 = OMX_TRUE; - mParameters3A.AlgoSharpening = OMX_TRUE; - mParameters3A.AlgoThreeLinColorMap = OMX_TRUE; - mParameters3A.AlgoGIC = OMX_TRUE; - - LOG_FUNCTION_NAME_EXIT; - return Utils::ErrorUtils::omxToAndroidError(eError); - - EXIT: - - CAMHAL_LOGDB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - performCleanupAfterError(); - LOG_FUNCTION_NAME_EXIT; - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -void OMXCameraAdapter::performCleanupAfterError() -{ - if(mCameraAdapterParameters.mHandleComp) - { - ///Free the OMX component handle in case of error - OMX_FreeHandle(mCameraAdapterParameters.mHandleComp); - mCameraAdapterParameters.mHandleComp = NULL; - } - - ///De-init the OMX - OMX_Deinit(); - mComponentState = OMX_StateInvalid; -} - -OMXCameraAdapter::OMXCameraPortParameters *OMXCameraAdapter::getPortParams(CameraFrame::FrameType frameType) -{ - OMXCameraAdapter::OMXCameraPortParameters *ret = NULL; - - switch ( frameType ) - { - case CameraFrame::IMAGE_FRAME: - ret = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - break; - case CameraFrame::RAW_FRAME: -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING - if (mRawCapture) { - ret = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoPortIndex]; - } else { -#endif - ret = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING - } -#endif - break; - case CameraFrame::PREVIEW_FRAME_SYNC: - case CameraFrame::SNAPSHOT_FRAME: - case CameraFrame::VIDEO_FRAME_SYNC: - ret = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - break; - case CameraFrame::FRAME_DATA_SYNC: - ret = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mMeasurementPortIndex]; - break; - default: - break; - }; - - return ret; -} - -status_t OMXCameraAdapter::fillThisBuffer(CameraBuffer * frameBuf, CameraFrame::FrameType frameType) -{ - LOG_FUNCTION_NAME; - - status_t ret = NO_ERROR; - OMXCameraPortParameters *port = NULL; - OMX_ERRORTYPE eError = OMX_ErrorNone; - BaseCameraAdapter::AdapterState state; - BaseCameraAdapter::getState(state); - bool isCaptureFrame = false; - - if ( ( PREVIEW_ACTIVE & state ) != PREVIEW_ACTIVE ) - { - return NO_INIT; - } - - if ( NULL == frameBuf ) - { - return -EINVAL; - } - - isCaptureFrame = (CameraFrame::IMAGE_FRAME == frameType) || - (CameraFrame::RAW_FRAME == frameType); - - if ( isCaptureFrame && (NO_ERROR == ret) ) { - // In CP_CAM mode, end image capture will be signalled when application starts preview - if ((1 > mCapturedFrames) && !mBracketingEnabled && (mCapMode != CP_CAM)) { - // Signal end of image capture - if ( NULL != mEndImageCaptureCallback) { - mEndImageCaptureCallback(mEndCaptureData); - } - return NO_ERROR; - } - } - - if ( NO_ERROR == ret ) - { - port = getPortParams(frameType); - if ( NULL == port ) - { - CAMHAL_LOGEB("Invalid frameType 0x%x", frameType); - ret = -EINVAL; - } - } - - if ( NO_ERROR == ret ) { - for ( int i = 0 ; i < port->mNumBufs ; i++) { - if ((CameraBuffer *) port->mBufferHeader[i]->pAppPrivate == frameBuf) { - if ( isCaptureFrame && !mBracketingEnabled ) { - android::AutoMutex lock(mBurstLock); - if (mBurstFramesQueued >= mBurstFramesAccum) { - port->mStatus[i] = OMXCameraPortParameters::IDLE; - return NO_ERROR; - } - mBurstFramesQueued++; - } - port->mStatus[i] = OMXCameraPortParameters::FILL; - eError = OMX_FillThisBuffer(mCameraAdapterParameters.mHandleComp, port->mBufferHeader[i]); - if ( eError != OMX_ErrorNone ) - { - CAMHAL_LOGEB("OMX_FillThisBuffer 0x%x", eError); - goto EXIT; - } - mFramesWithDucati++; - break; - } - } - } - - LOG_FUNCTION_NAME_EXIT; - return ret; - -EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - performCleanupAfterError(); - //Since fillthisbuffer is called asynchronously, make sure to signal error to the app - mErrorNotifier->errorNotify(CAMERA_ERROR_HARD); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -#ifndef OMAP_TUNA -void OMXCameraAdapter::setParamS3D(OMX_U32 port, const char *valstr) -{ - OMXCameraPortParameters *cap; - - LOG_FUNCTION_NAME; - - cap = &mCameraAdapterParameters.mCameraPortParams[port]; - if (valstr != NULL) - { - if (strcmp(valstr, TICameraParameters::S3D_TB_FULL) == 0) - { - cap->mFrameLayoutType = OMX_TI_StereoFrameLayoutTopBottom; - } - else if (strcmp(valstr, TICameraParameters::S3D_SS_FULL) == 0) - { - cap->mFrameLayoutType = OMX_TI_StereoFrameLayoutLeftRight; - } - else if (strcmp(valstr, TICameraParameters::S3D_TB_SUBSAMPLED) == 0) - { - cap->mFrameLayoutType = OMX_TI_StereoFrameLayoutTopBottomSubsample; - } - else if (strcmp(valstr, TICameraParameters::S3D_SS_SUBSAMPLED) == 0) - { - cap->mFrameLayoutType = OMX_TI_StereoFrameLayoutLeftRightSubsample; - } - else - { - cap->mFrameLayoutType = OMX_TI_StereoFrameLayout2D; - } - } - else - { - cap->mFrameLayoutType = OMX_TI_StereoFrameLayout2D; - } - - LOG_FUNCTION_NAME_EXIT; -} -#endif - -status_t OMXCameraAdapter::setParameters(const android::CameraParameters ¶ms) -{ - LOG_FUNCTION_NAME; - - int mode = 0; - status_t ret = NO_ERROR; - bool updateImagePortParams = false; - int minFramerate, maxFramerate, frameRate; - const char *valstr = NULL; - int w, h; - OMX_COLOR_FORMATTYPE pixFormat; - BaseCameraAdapter::AdapterState state; - BaseCameraAdapter::getState(state); - - ///@todo Include more camera parameters - if ( (valstr = params.getPreviewFormat()) != NULL ) { - if(strcmp(valstr, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0 || - strcmp(valstr, android::CameraParameters::PIXEL_FORMAT_YUV420P) == 0 || - strcmp(valstr, android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { - CAMHAL_LOGDA("YUV420SP format selected"); - pixFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - } else if(strcmp(valstr, android::CameraParameters::PIXEL_FORMAT_RGB565) == 0) { - CAMHAL_LOGDA("RGB565 format selected"); - pixFormat = OMX_COLOR_Format16bitRGB565; - } else { - CAMHAL_LOGDA("Invalid format, CbYCrY format selected as default"); - pixFormat = OMX_COLOR_FormatCbYCrY; - } - } else { - CAMHAL_LOGEA("Preview format is NULL, defaulting to CbYCrY"); - pixFormat = OMX_COLOR_FormatCbYCrY; - } - - OMXCameraPortParameters *cap; - cap = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - - params.getPreviewSize(&w, &h); - frameRate = params.getPreviewFrameRate(); - params.getPreviewFpsRange(&minFramerate, &maxFramerate); - minFramerate /= CameraHal::VFR_SCALE; - maxFramerate /= CameraHal::VFR_SCALE; - if ( ( 0 < minFramerate ) && ( 0 < maxFramerate ) ) { - if ( minFramerate > maxFramerate ) { - CAMHAL_LOGEA(" Min FPS set higher than MAX. So setting MIN and MAX to the higher value"); - maxFramerate = minFramerate; - } - - if ( 0 >= frameRate ) { - frameRate = maxFramerate; - } - - if ( ( cap->mMinFrameRate != (OMX_U32) minFramerate ) || - ( cap->mMaxFrameRate != (OMX_U32) maxFramerate ) ) { - cap->mMinFrameRate = minFramerate; - cap->mMaxFrameRate = maxFramerate; - setVFramerate(cap->mMinFrameRate, cap->mMaxFrameRate); - } - } - - if ( 0 < frameRate ) - { - cap->mColorFormat = pixFormat; - cap->mWidth = w; - cap->mHeight = h; - cap->mFrameRate = frameRate; - - CAMHAL_LOGVB("Prev: cap.mColorFormat = %d", (int)cap->mColorFormat); - CAMHAL_LOGVB("Prev: cap.mWidth = %d", (int)cap->mWidth); - CAMHAL_LOGVB("Prev: cap.mHeight = %d", (int)cap->mHeight); - CAMHAL_LOGVB("Prev: cap.mFrameRate = %d", (int)cap->mFrameRate); - - //TODO: Add an additional parameter for video resolution - //use preview resolution for now - cap = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - cap->mColorFormat = pixFormat; - cap->mWidth = w; - cap->mHeight = h; - cap->mFrameRate = frameRate; - - CAMHAL_LOGVB("Video: cap.mColorFormat = %d", (int)cap->mColorFormat); - CAMHAL_LOGVB("Video: cap.mWidth = %d", (int)cap->mWidth); - CAMHAL_LOGVB("Video: cap.mHeight = %d", (int)cap->mHeight); - CAMHAL_LOGVB("Video: cap.mFrameRate = %d", (int)cap->mFrameRate); - - ///mStride is set from setBufs() while passing the APIs - cap->mStride = 4096; - cap->mBufSize = cap->mStride * cap->mHeight; - } - - if ( ( cap->mWidth >= 1920 ) && - ( cap->mHeight >= 1080 ) && - ( cap->mFrameRate >= FRAME_RATE_FULL_HD ) && - ( !mSensorOverclock ) ) - { - mOMXStateSwitch = true; - } - else if ( ( ( cap->mWidth < 1920 ) || - ( cap->mHeight < 1080 ) || - ( cap->mFrameRate < FRAME_RATE_FULL_HD ) ) && - ( mSensorOverclock ) ) - { - mOMXStateSwitch = true; - } - -#ifdef CAMERAHAL_TUNA - valstr = params.get(TICameraParameters::KEY_RECORDING_HINT); - if (!valstr || (valstr && (strcmp(valstr, android::CameraParameters::FALSE)))) { - mIternalRecordingHint = false; - } else { - mIternalRecordingHint = true; - } -#endif - -#ifdef OMAP_ENHANCEMENT - if ( (valstr = params.get(TICameraParameters::KEY_MEASUREMENT_ENABLE)) != NULL ) - { - if (strcmp(valstr, android::CameraParameters::TRUE) == 0) - { - mMeasurementEnabled = true; - } - else if (strcmp(valstr, android::CameraParameters::FALSE) == 0) - { - mMeasurementEnabled = false; - } - else - { - mMeasurementEnabled = false; - } - } - else - { - //Disable measurement data by default - mMeasurementEnabled = false; - } -#endif - -#ifdef OMAP_ENHANCEMENT_S3D - setParamS3D(mCameraAdapterParameters.mPrevPortIndex, - params.get(TICameraParameters::KEY_S3D_PRV_FRAME_LAYOUT)); -#endif - - ret |= setParametersCapture(params, state); - - ret |= setParameters3A(params, state); - - ret |= setParametersAlgo(params, state); - - ret |= setParametersFocus(params, state); - - ret |= setParametersFD(params, state); - - ret |= setParametersZoom(params, state); - - ret |= setParametersEXIF(params, state); - - mParams = params; - mFirstTimeInit = false; - - if ( MODE_MAX != mCapabilitiesOpMode ) { - mCapabilities->setMode(mCapabilitiesOpMode); - } - - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -void saveFile(unsigned char *buff, int width, int height, int format) { - static int counter = 1; - int fd = -1; - char fn[256]; - - LOG_FUNCTION_NAME; - - fn[0] = 0; - sprintf(fn, "/preview%03d.yuv", counter); - fd = open(fn, O_CREAT | O_WRONLY | O_SYNC | O_TRUNC, 0777); - if(fd < 0) { - CAMHAL_LOGE("Unable to open file %s: %s", fn, strerror(fd)); - return; - } - - CAMHAL_LOGVB("Copying from 0x%x, size=%d x %d", buff, width, height); - - //method currently supports only nv12 dumping - int stride = width; - uint8_t *bf = (uint8_t*) buff; - for(int i=0;iget(CameraProperties::CAMERA_NAME), - (OMX_SCENEMODETYPE) mParameters3A.SceneMode); - if(entry) { - mParameters3A.Focus = entry->focus; - mParameters3A.FlashMode = entry->flash; - mParameters3A.WhiteBallance = entry->wb; - } - } - - valstr = getLUTvalue_OMXtoHAL(mParameters3A.WhiteBallance, WBalLUT); - valstr_supported = mParams.get(android::CameraParameters::KEY_SUPPORTED_WHITE_BALANCE); - if (valstr && valstr_supported && strstr(valstr_supported, valstr)) - params.set(android::CameraParameters::KEY_WHITE_BALANCE , valstr); - - valstr = getLUTvalue_OMXtoHAL(mParameters3A.FlashMode, FlashLUT); - valstr_supported = mParams.get(android::CameraParameters::KEY_SUPPORTED_FLASH_MODES); - if (valstr && valstr_supported && strstr(valstr_supported, valstr)) - params.set(android::CameraParameters::KEY_FLASH_MODE, valstr); - - if ((mParameters3A.Focus == OMX_IMAGE_FocusControlAuto) && - (mCapMode != OMXCameraAdapter::VIDEO_MODE)) { - valstr = android::CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE; - } else { - valstr = getLUTvalue_OMXtoHAL(mParameters3A.Focus, FocusLUT); - } - valstr_supported = mParams.get(android::CameraParameters::KEY_SUPPORTED_FOCUS_MODES); - if (valstr && valstr_supported && strstr(valstr_supported, valstr)) - params.set(android::CameraParameters::KEY_FOCUS_MODE, valstr); - } - - //Query focus distances only when focus is running - if ( ( AF_ACTIVE & state ) || - ( NULL == mParameters.get(android::CameraParameters::KEY_FOCUS_DISTANCES) ) ) - { - updateFocusDistances(params); - } - else - { - params.set(android::CameraParameters::KEY_FOCUS_DISTANCES, - mParameters.get(android::CameraParameters::KEY_FOCUS_DISTANCES)); - } - -#ifdef OMAP_ENHANCEMENT - OMX_INIT_STRUCT_PTR (&exp, OMX_CONFIG_EXPOSUREVALUETYPE); - exp.nPortIndex = OMX_ALL; - - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonExposureValue, - &exp); - if ( OMX_ErrorNone == eError ) - { - params.set(TICameraParameters::KEY_CURRENT_ISO, exp.nSensitivity); - } - else - { - CAMHAL_LOGEB("OMX error 0x%x, while retrieving current ISO value", eError); - } -#endif - - { - android::AutoMutex lock(mZoomLock); - //Immediate zoom should not be avaialable while smooth zoom is running - if ( ZOOM_ACTIVE & state ) - { - if ( mZoomParameterIdx != mCurrentZoomIdx ) - { - mZoomParameterIdx += mZoomInc; - } - params.set(android::CameraParameters::KEY_ZOOM, mZoomParameterIdx); - if ( ( mCurrentZoomIdx == mTargetZoomIdx ) && - ( mZoomParameterIdx == mCurrentZoomIdx ) ) - { - - if ( NO_ERROR == ret ) - { - - ret = BaseCameraAdapter::setState(CAMERA_STOP_SMOOTH_ZOOM); - - if ( NO_ERROR == ret ) - { - ret = BaseCameraAdapter::commitState(); - } - else - { - ret |= BaseCameraAdapter::rollbackState(); - } - - } - - } - - CAMHAL_LOGDB("CameraParameters Zoom = %d", mCurrentZoomIdx); - } - else - { - params.set(android::CameraParameters::KEY_ZOOM, mCurrentZoomIdx); - } - } - - //Populate current lock status - if ( mUserSetExpLock || mParameters3A.ExposureLock ) { - params.set(android::CameraParameters::KEY_AUTO_EXPOSURE_LOCK, - android::CameraParameters::TRUE); - } else { - params.set(android::CameraParameters::KEY_AUTO_EXPOSURE_LOCK, - android::CameraParameters::FALSE); - } - - if ( mUserSetWbLock || mParameters3A.WhiteBalanceLock ) { - params.set(android::CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK, - android::CameraParameters::TRUE); - } else { - params.set(android::CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK, - android::CameraParameters::FALSE); - } - - // Update Picture size capabilities dynamically - params.set(android::CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, - mCapabilities->get(CameraProperties::SUPPORTED_PICTURE_SIZES)); - - // Update framerate capabilities dynamically - params.set(android::CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES, - mCapabilities->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES)); - - params.set(TICameraParameters::KEY_FRAMERATES_EXT_SUPPORTED, - mCapabilities->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES_EXT)); - - params.set(android::CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, - mCapabilities->get(CameraProperties::FRAMERATE_RANGE_SUPPORTED)); - - params.set(TICameraParameters::KEY_FRAMERATE_RANGES_EXT_SUPPORTED, - mCapabilities->get(CameraProperties::FRAMERATE_RANGE_EXT_SUPPORTED)); - - LOG_FUNCTION_NAME_EXIT; -} - -status_t OMXCameraAdapter::setupTunnel(uint32_t SliceHeight, uint32_t EncoderHandle, uint32_t width, uint32_t height) { - LOG_FUNCTION_NAME; - - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_HANDLETYPE *encoderHandle = (OMX_HANDLETYPE *)EncoderHandle; - - CAMHAL_LOGDB("\n %s: SliceHeight:%d, EncoderHandle:%d width:%d height:%d \n", __FUNCTION__, SliceHeight, EncoderHandle, width, height); - - if (SliceHeight == 0){ - CAMHAL_LOGEA("\n\n #### Encoder Slice Height Not received, Dont Setup Tunnel $$$$\n\n"); - return BAD_VALUE; - } - - if (encoderHandle == NULL) { - CAMHAL_LOGEA("Encoder Handle not set \n\n"); - return BAD_VALUE; - } - - if ( 0 != mInitSem.Count() ) { - CAMHAL_LOGEB("Error mInitSem semaphore count %d", mInitSem.Count()); - LOG_FUNCTION_NAME_EXIT; - return NO_INIT; - } - - // Register for port enable event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mVideoPortIndex, - mInitSem); - if(ret != NO_ERROR) { - CAMHAL_LOGEB("Error in registering for event %d", ret); - return UNKNOWN_ERROR; - } - - // Enable VIDEO Port - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortEnable, - mCameraAdapterParameters.mVideoPortIndex, - NULL); - if(eError != OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_SendCommand(OMX_CommandPortEnable) -0x%x", eError); - return BAD_VALUE; - } - - // Wait for the port enable event to occur - ret = mInitSem.WaitTimeout(OMX_CMD_TIMEOUT); - if ( NO_ERROR == ret ) { - CAMHAL_LOGDA("-Port enable event arrived"); - } else { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mVideoPortIndex, - NULL); - CAMHAL_LOGEA("Timeout for enabling preview port expired!"); - return UNKNOWN_ERROR; - } - - //Set the Video Port Params - OMX_PARAM_PORTDEFINITIONTYPE portCheck; - OMX_INIT_STRUCT_PTR (&portCheck, OMX_PARAM_PORTDEFINITIONTYPE); - portCheck.nPortIndex = OMX_CAMERA_PORT_VIDEO_OUT_VIDEO; - eError = OMX_GetParameter(mCameraAdapterParameters.mHandleComp, - OMX_IndexParamPortDefinition, &portCheck); - if (eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_GetParameter OMX_IndexParamPortDefinition Error - %x", eError); - } - - portCheck.format.video.nFrameWidth = width; - portCheck.format.video.nFrameHeight = height; - portCheck.format.video.eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - OMX_IndexParamPortDefinition, &portCheck); - if (eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_SetParameter OMX_IndexParamPortDefinition Error- %x", eError); - } - -#ifndef OMAP_TUNA - //Slice Configuration - OMX_TI_PARAM_VTCSLICE VTCSlice; - OMX_INIT_STRUCT_PTR(&VTCSlice, OMX_TI_PARAM_VTCSLICE); - eError = OMX_GetParameter(mCameraAdapterParameters.mHandleComp, (OMX_INDEXTYPE)OMX_TI_IndexParamVtcSlice, &VTCSlice); - if (eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_GetParameter OMX_TI_IndexParamVtcSlice Error - %x", eError); - } - - VTCSlice.nSliceHeight = SliceHeight; - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, (OMX_INDEXTYPE)OMX_TI_IndexParamVtcSlice, &VTCSlice); - if (OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("OMX_SetParameter on OMX_TI_IndexParamVtcSlice returned error: 0x%x", eError); - return BAD_VALUE; - } -#endif - - eError = OMX_SetupTunnel(mCameraAdapterParameters.mHandleComp, - mCameraAdapterParameters.mVideoPortIndex, encoderHandle, 0); - if (OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("OMX_SetupTunnel returned error: 0x%x", eError); - return BAD_VALUE; - } - - return NO_ERROR; -} - -status_t OMXCameraAdapter::setSensorQuirks(int orientation, - OMXCameraPortParameters &portParams, - bool &portConfigured) -{ - status_t overclockStatus = NO_ERROR; - int sensorID = -1; - size_t overclockWidth; - size_t overclockHeight; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_PARAM_PORTDEFINITIONTYPE portCheck; - - LOG_FUNCTION_NAME; - - portConfigured = false; - OMX_INIT_STRUCT_PTR (&portCheck, OMX_PARAM_PORTDEFINITIONTYPE); - - portCheck.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - eError = OMX_GetParameter (mCameraAdapterParameters.mHandleComp, - OMX_IndexParamPortDefinition, - &portCheck); - - if ( eError != OMX_ErrorNone ) { - CAMHAL_LOGEB("OMX_GetParameter - %x", eError); - return Utils::ErrorUtils::omxToAndroidError(eError); - } - - if ( ( orientation == 90 ) || ( orientation == 270 ) ) { - overclockWidth = 1080; - overclockHeight = 1920; - } else { - overclockWidth = 1920; - overclockHeight = 1080; - } - - sensorID = mCapabilities->getInt(CameraProperties::CAMERA_SENSOR_ID); - if( ( ( sensorID == SENSORID_IMX060 ) && - ( portParams.mWidth >= overclockWidth ) && - ( portParams.mHeight >= overclockHeight ) && - ( portParams.mFrameRate >= FRAME_RATE_FULL_HD ) ) || - (( sensorID == SENSORID_OV14825) && - ( portParams.mFrameRate >= FRAME_RATE_HIGH_HD ))|| - ( ( sensorID == SENSORID_OV5640 ) && - ( portParams.mWidth >= overclockWidth ) && - ( portParams.mHeight >= overclockHeight ) ) ) { - overclockStatus = setSensorOverclock(true); - } else { - - //WA: If the next port resolution doesn't require - // sensor overclocking, but the previous resolution - // needed it, then we have to first set new port - // resolution and then disable sensor overclocking. - if( ( ( sensorID == SENSORID_IMX060 ) && - ( portCheck.format.video.nFrameWidth >= overclockWidth ) && - ( portCheck.format.video.nFrameHeight >= overclockHeight ) && - ( ( portCheck.format.video.xFramerate >> 16 ) >= FRAME_RATE_FULL_HD ) ) || - (( sensorID == SENSORID_OV14825) && - (( portCheck.format.video.xFramerate >> 16) >= FRAME_RATE_HIGH_HD ))|| - ( ( sensorID == SENSORID_OV5640 ) && - ( portCheck.format.video.nFrameWidth >= overclockWidth ) && - ( portCheck.format.video.nFrameHeight >= overclockHeight ) ) ) { - status_t ret = setFormat(mCameraAdapterParameters.mPrevPortIndex, - portParams); - if ( NO_ERROR != ret ) { - return ret; - } - - // Another WA: Setting the port definition will reset the VFR - // configuration. - setVFramerate(portParams.mMinFrameRate, portParams.mMaxFrameRate); - - portConfigured = true; - } - - overclockStatus = setSensorOverclock(false); - } - - LOG_FUNCTION_NAME_EXIT; - - return overclockStatus; -} -status_t OMXCameraAdapter::setFormat(OMX_U32 port, OMXCameraPortParameters &portParams) -{ - LOG_FUNCTION_NAME; - - status_t ret = NO_ERROR; - size_t bufferCount; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_PARAM_PORTDEFINITIONTYPE portCheck; - - OMX_INIT_STRUCT_PTR (&portCheck, OMX_PARAM_PORTDEFINITIONTYPE); - - portCheck.nPortIndex = port; - - eError = OMX_GetParameter (mCameraAdapterParameters.mHandleComp, - OMX_IndexParamPortDefinition, &portCheck); - if (eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_GetParameter - %x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - if (OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW == port) { - portCheck.format.video.nFrameWidth = portParams.mWidth; - portCheck.format.video.nFrameHeight = portParams.mHeight; - portCheck.format.video.eColorFormat = portParams.mColorFormat; - portCheck.format.video.nStride = portParams.mStride; - - portCheck.format.video.xFramerate = portParams.mFrameRate<<16; - portCheck.nBufferSize = portParams.mStride * portParams.mHeight; - portCheck.nBufferCountActual = portParams.mNumBufs; - mFocusThreshold = FOCUS_THRESHOLD * portParams.mFrameRate; - // Used for RAW capture - } else if (OMX_CAMERA_PORT_VIDEO_OUT_VIDEO == port) { - portCheck.format.video.nFrameWidth = portParams.mWidth; - portCheck.format.video.nFrameHeight = portParams.mHeight; - portCheck.format.video.eColorFormat = OMX_COLOR_FormatRawBayer10bit; // portParams.mColorFormat; - portCheck.nBufferCountActual = 1; // portParams.mNumBufs; - } else if (OMX_CAMERA_PORT_IMAGE_OUT_IMAGE == port) { - portCheck.format.image.nFrameWidth = portParams.mWidth; - portCheck.format.image.nFrameHeight = portParams.mHeight; - if (OMX_COLOR_FormatUnused == portParams.mColorFormat) { - portCheck.format.image.eColorFormat = OMX_COLOR_FormatCbYCrY; - if (mCodingMode == CodingJPEG) { - portCheck.format.image.eCompressionFormat = OMX_IMAGE_CodingJPEG; - } else if (mCodingMode == CodingJPS) { - portCheck.format.image.eCompressionFormat = (OMX_IMAGE_CODINGTYPE) OMX_TI_IMAGE_CodingJPS; - } else if (mCodingMode == CodingMPO) { - portCheck.format.image.eCompressionFormat = (OMX_IMAGE_CODINGTYPE) OMX_TI_IMAGE_CodingMPO; - } else { - portCheck.format.image.eCompressionFormat = OMX_IMAGE_CodingUnused; - } - } else { - portCheck.format.image.eColorFormat = portParams.mColorFormat; - portCheck.format.image.eCompressionFormat = OMX_IMAGE_CodingUnused; - } - -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING - // RAW + YUV Capture - if (mYuvCapture) { - portCheck.format.image.eColorFormat = OMX_COLOR_FormatCbYCrY; - portCheck.format.image.eCompressionFormat = OMX_IMAGE_CodingUnused; - } -#endif - //Stride for 1D tiler buffer is zero - portCheck.format.image.nStride = 0; - portCheck.nBufferCountActual = portParams.mNumBufs; - } else if (OMX_CAMERA_PORT_VIDEO_IN_VIDEO == port) { - portCheck.format.video.nFrameWidth = portParams.mWidth; - portCheck.format.video.nStride = portParams.mStride; - portCheck.format.video.nFrameHeight = portParams.mHeight; - portCheck.format.video.eColorFormat = portParams.mColorFormat; - portCheck.format.video.xFramerate = 30 << 16; - portCheck.nBufferCountActual = portParams.mNumBufs; - } else { - CAMHAL_LOGEB("Unsupported port index (%lu)", port); - } - -#ifndef OMAP_TUNA - if (( mSensorIndex == OMX_TI_StereoSensor ) && (OMX_CAMERA_PORT_VIDEO_OUT_VIDEO != port)) { - ret = setS3DFrameLayout(port); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEA("Error configuring stereo 3D frame layout"); - return ret; - } - } -#endif - - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - OMX_IndexParamPortDefinition, &portCheck); - if (eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_SetParameter - %x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - /* check if parameters are set correctly by calling GetParameter() */ - eError = OMX_GetParameter(mCameraAdapterParameters.mHandleComp, - OMX_IndexParamPortDefinition, &portCheck); - if (eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_GetParameter - %x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - portParams.mBufSize = portCheck.nBufferSize; - portParams.mStride = portCheck.format.image.nStride; - - if (OMX_CAMERA_PORT_IMAGE_OUT_IMAGE == port) { - CAMHAL_LOGDB("\n *** IMG Width = %ld", portCheck.format.image.nFrameWidth); - CAMHAL_LOGDB("\n *** IMG Height = %ld", portCheck.format.image.nFrameHeight); - - CAMHAL_LOGDB("\n *** IMG IMG FMT = %x", portCheck.format.image.eColorFormat); - CAMHAL_LOGDB("\n *** IMG portCheck.nBufferSize = %ld\n",portCheck.nBufferSize); - CAMHAL_LOGDB("\n *** IMG portCheck.nBufferCountMin = %ld\n", - portCheck.nBufferCountMin); - CAMHAL_LOGDB("\n *** IMG portCheck.nBufferCountActual = %ld\n", - portCheck.nBufferCountActual); - CAMHAL_LOGDB("\n *** IMG portCheck.format.image.nStride = %ld\n", - portCheck.format.image.nStride); - } else if (OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW == port) { - CAMHAL_LOGDB("\n *** PRV Width = %ld", portCheck.format.video.nFrameWidth); - CAMHAL_LOGDB("\n *** PRV Height = %ld", portCheck.format.video.nFrameHeight); - - CAMHAL_LOGDB("\n *** PRV IMG FMT = %x", portCheck.format.video.eColorFormat); - CAMHAL_LOGDB("\n *** PRV portCheck.nBufferSize = %ld\n",portCheck.nBufferSize); - CAMHAL_LOGDB("\n *** PRV portCheck.nBufferCountMin = %ld\n", - portCheck.nBufferCountMin); - CAMHAL_LOGDB("\n *** PRV portCheck.nBufferCountActual = %ld\n", - portCheck.nBufferCountActual); - CAMHAL_LOGDB("\n ***PRV portCheck.format.video.nStride = %ld\n", - portCheck.format.video.nStride); - } else { - CAMHAL_LOGDB("\n *** VID Width = %ld", portCheck.format.video.nFrameWidth); - CAMHAL_LOGDB("\n *** VID Height = %ld", portCheck.format.video.nFrameHeight); - - CAMHAL_LOGDB("\n *** VID IMG FMT = %x", portCheck.format.video.eColorFormat); - CAMHAL_LOGDB("\n *** VID portCheck.nBufferSize = %ld\n",portCheck.nBufferSize); - CAMHAL_LOGDB("\n *** VID portCheck.nBufferCountMin = %ld\n", - portCheck.nBufferCountMin); - CAMHAL_LOGDB("\n *** VID portCheck.nBufferCountActual = %ld\n", - portCheck.nBufferCountActual); - CAMHAL_LOGDB("\n *** VID portCheck.format.video.nStride = %ld\n", - portCheck.format.video.nStride); - } - - mSetFormatDone = true; - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); - - EXIT: - - CAMHAL_LOGEB("Exiting function %s because of eError = 0x%x", __FUNCTION__, eError); - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::flushBuffers(OMX_U32 nPort) -{ - LOG_FUNCTION_NAME; - - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - if ( 0 != mFlushSem.Count() ) - { - CAMHAL_LOGEB("Error mFlushSem semaphore count %d", mFlushSem.Count()); - LOG_FUNCTION_NAME_EXIT; - return NO_INIT; - } - - OMXCameraPortParameters * mPreviewData = NULL; - mPreviewData = &mCameraAdapterParameters.mCameraPortParams[nPort]; - - ///Register for the FLUSH event - ///This method just inserts a message in Event Q, which is checked in the callback - ///The sempahore passed is signalled by the callback - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandFlush, - nPort, - mFlushSem); - if(ret!=NO_ERROR) - { - CAMHAL_LOGEB("Error in registering for event %d", ret); - goto EXIT; - } - - ///Send FLUSH command to preview port - eError = OMX_SendCommand (mCameraAdapterParameters.mHandleComp, - OMX_CommandFlush, - nPort, - NULL); - - if(eError!=OMX_ErrorNone) - { - CAMHAL_LOGEB("OMX_SendCommand(OMX_CommandFlush)-0x%x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - CAMHAL_LOGDA("Waiting for flush event"); - - ///Wait for the FLUSH event to occur - ret = mFlushSem.WaitTimeout(OMX_CMD_TIMEOUT); - - //If somethiing bad happened while we wait - if (mComponentState == OMX_StateInvalid) - { - CAMHAL_LOGEA("Invalid State after Flush Exitting!!!"); - goto EXIT; - } - - if ( NO_ERROR == ret ) - { - CAMHAL_LOGDA("Flush event received"); - } - else - { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandFlush, - nPort, - NULL); - CAMHAL_LOGDA("Flush event timeout expired"); - goto EXIT; - } - - mOMXCallbackHandler->flush(); - - LOG_FUNCTION_NAME_EXIT; - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - - EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - performCleanupAfterError(); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -///API to give the buffers to Adapter -status_t OMXCameraAdapter::useBuffers(CameraMode mode, CameraBuffer * bufArr, int num, size_t length, unsigned int queueable) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - switch(mode) - { - case CAMERA_PREVIEW: - mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex].mNumBufs = num; - mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex].mMaxQueueable = queueable; - ret = UseBuffersPreview(bufArr, num); - break; - - case CAMERA_IMAGE_CAPTURE: - mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex].mNumBufs = num; - mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex].mMaxQueueable = queueable; - ret = UseBuffersCapture(bufArr, num); - break; - - case CAMERA_VIDEO: - mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoPortIndex].mNumBufs = num; - mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoPortIndex].mMaxQueueable = queueable; - ret = UseBuffersRawCapture(bufArr, num); - break; - - case CAMERA_MEASUREMENT: - mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mMeasurementPortIndex].mNumBufs = num; - mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mMeasurementPortIndex].mMaxQueueable = queueable; - ret = UseBuffersPreviewData(bufArr, num); - break; - - case CAMERA_REPROCESS: - mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoInPortIndex].mNumBufs = num; - mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoInPortIndex].mMaxQueueable = queueable; - ret = UseBuffersReprocess(bufArr, num); - break; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::UseBuffersPreviewData(CameraBuffer * bufArr, int num) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXCameraPortParameters * measurementData = NULL; - android::AutoMutex lock(mPreviewDataBufferLock); - - LOG_FUNCTION_NAME; - - if ( mComponentState != OMX_StateLoaded ) - { - CAMHAL_LOGEA("Calling UseBuffersPreviewData() when not in LOADED state"); - return BAD_VALUE; - } - - if ( NULL == bufArr ) - { - CAMHAL_LOGEA("NULL pointer passed for buffArr"); - return BAD_VALUE; - } - - if ( 0 != mUsePreviewDataSem.Count() ) - { - CAMHAL_LOGEB("Error mUsePreviewDataSem semaphore count %d", mUsePreviewDataSem.Count()); - LOG_FUNCTION_NAME_EXIT; - return NO_INIT; - } - - if ( NO_ERROR == ret ) - { - measurementData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mMeasurementPortIndex]; - measurementData->mNumBufs = num ; - } - - if ( NO_ERROR == ret ) - { - ///Register for port enable event on measurement port - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mMeasurementPortIndex, - mUsePreviewDataSem); - - if ( ret == NO_ERROR ) - { - CAMHAL_LOGDB("Registering for event %d", ret); - } - else - { - CAMHAL_LOGEB("Error in registering for event %d", ret); - goto EXIT; - } - } - - if ( NO_ERROR == ret ) - { - ///Enable MEASUREMENT Port - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortEnable, - mCameraAdapterParameters.mMeasurementPortIndex, - NULL); - - if ( eError == OMX_ErrorNone ) - { - CAMHAL_LOGDB("OMX_SendCommand(OMX_CommandPortEnable) -0x%x", eError); - } - else - { - CAMHAL_LOGEB("OMX_SendCommand(OMX_CommandPortEnable) -0x%x", eError); - goto EXIT; - } - } - - if ( NO_ERROR == ret ) - { - ret = mUsePreviewDataSem.WaitTimeout(OMX_CMD_TIMEOUT); - - //If somethiing bad happened while we wait - if (mComponentState == OMX_StateInvalid) - { - CAMHAL_LOGEA("Invalid State after measurement port enable Exitting!!!"); - goto EXIT; - } - - if ( NO_ERROR == ret ) - { - CAMHAL_LOGDA("Port enable event arrived on measurement port"); - } - else - { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mMeasurementPortIndex, - NULL); - CAMHAL_LOGEA("Timeout expoired during port enable on measurement port"); - goto EXIT; - } - - CAMHAL_LOGDA("Port enable event arrived on measurement port"); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - performCleanupAfterError(); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::switchToExecuting() -{ - status_t ret = NO_ERROR; - Utils::Message msg; - - LOG_FUNCTION_NAME; - - mStateSwitchLock.lock(); - msg.command = CommandHandler::CAMERA_SWITCH_TO_EXECUTING; - msg.arg1 = mErrorNotifier; - ret = mCommandHandler->put(&msg); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::doSwitchToExecuting() -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - LOG_FUNCTION_NAME; - - if ( (mComponentState == OMX_StateExecuting) || (mComponentState == OMX_StateInvalid) ){ - CAMHAL_LOGDA("Already in OMX_Executing state or OMX_StateInvalid state"); - mStateSwitchLock.unlock(); - return NO_ERROR; - } - - if ( 0 != mSwitchToExecSem.Count() ){ - CAMHAL_LOGEB("Error mSwitchToExecSem semaphore count %d", mSwitchToExecSem.Count()); - goto EXIT; - } - - ///Register for Preview port DISABLE event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortDisable, - mCameraAdapterParameters.mPrevPortIndex, - mSwitchToExecSem); - if ( NO_ERROR != ret ){ - CAMHAL_LOGEB("Error in registering Port Disable for event %d", ret); - goto EXIT; - } - ///Disable Preview Port - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortDisable, - mCameraAdapterParameters.mPrevPortIndex, - NULL); - ret = mSwitchToExecSem.WaitTimeout(OMX_CMD_TIMEOUT); - if (ret != NO_ERROR){ - CAMHAL_LOGEB("Timeout PREVIEW PORT DISABLE %d", ret); - } - - CAMHAL_LOGVB("PREV PORT DISABLED %d", ret); - - ///Register for IDLE state switch event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandStateSet, - OMX_StateIdle, - mSwitchToExecSem); - if(ret!=NO_ERROR) - { - CAMHAL_LOGEB("Error in IDLE STATE SWITCH %d", ret); - goto EXIT; - } - eError = OMX_SendCommand (mCameraAdapterParameters.mHandleComp , - OMX_CommandStateSet, - OMX_StateIdle, - NULL); - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - ret = mSwitchToExecSem.WaitTimeout(OMX_CMD_TIMEOUT); - if (ret != NO_ERROR){ - CAMHAL_LOGEB("Timeout IDLE STATE SWITCH %d", ret); - goto EXIT; - } - mComponentState = OMX_StateIdle; - CAMHAL_LOGVB("OMX_SendCommand(OMX_StateIdle) 0x%x", eError); - - ///Register for EXECUTING state switch event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandStateSet, - OMX_StateExecuting, - mSwitchToExecSem); - if(ret!=NO_ERROR) - { - CAMHAL_LOGEB("Error in EXECUTING STATE SWITCH %d", ret); - goto EXIT; - } - eError = OMX_SendCommand (mCameraAdapterParameters.mHandleComp , - OMX_CommandStateSet, - OMX_StateExecuting, - NULL); - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - ret = mSwitchToExecSem.WaitTimeout(OMX_CMD_TIMEOUT); - if (ret != NO_ERROR){ - CAMHAL_LOGEB("Timeout EXEC STATE SWITCH %d", ret); - goto EXIT; - } - mComponentState = OMX_StateExecuting; - CAMHAL_LOGVB("OMX_SendCommand(OMX_StateExecuting) 0x%x", eError); - - mStateSwitchLock.unlock(); - - LOG_FUNCTION_NAME_EXIT; - return ret; - - EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - performCleanupAfterError(); - mStateSwitchLock.unlock(); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::switchToIdle() { - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mIdleStateSwitchLock); - - if ( mComponentState == OMX_StateIdle || mComponentState == OMX_StateLoaded || mComponentState == OMX_StateInvalid) { - CAMHAL_LOGDA("Already in OMX_StateIdle, OMX_Loaded state or OMX_StateInvalid state"); - return NO_ERROR; - } - - if ( 0 != mSwitchToLoadedSem.Count() ) - { - CAMHAL_LOGEB("Error mSwitchToLoadedSem semaphore count %d", mSwitchToLoadedSem.Count()); - goto EXIT; - } - - ///Register for EXECUTING state transition. - ///This method just inserts a message in Event Q, which is checked in the callback - ///The sempahore passed is signalled by the callback - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandStateSet, - OMX_StateIdle, - mSwitchToLoadedSem); - - if(ret!=NO_ERROR) - { - CAMHAL_LOGEB("Error in registering for event %d", ret); - goto EXIT; - } - - eError = OMX_SendCommand (mCameraAdapterParameters.mHandleComp, - OMX_CommandStateSet, - OMX_StateIdle, - NULL); - - if(eError!=OMX_ErrorNone) - { - CAMHAL_LOGEB("OMX_SendCommand(OMX_StateIdle) - %x", eError); - } - - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - ///Wait for the EXECUTING ->IDLE transition to arrive - - CAMHAL_LOGDA("EXECUTING->IDLE state changed"); - ret = mSwitchToLoadedSem.WaitTimeout(OMX_CMD_TIMEOUT); - - //If somethiing bad happened while we wait - if (mComponentState == OMX_StateInvalid) - { - CAMHAL_LOGEA("Invalid State after EXECUTING->IDLE Exitting!!!"); - goto EXIT; - } - - if ( NO_ERROR == ret ) - { - CAMHAL_LOGDA("EXECUTING->IDLE state changed"); - } - else - { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandStateSet, - OMX_StateIdle, - NULL); - CAMHAL_LOGEA("Timeout expired on EXECUTING->IDLE state change"); - goto EXIT; - } - - mComponentState = OMX_StateIdle; - - return NO_ERROR; - -EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - performCleanupAfterError(); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - - - -status_t OMXCameraAdapter::prevPortEnable() { - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - LOG_FUNCTION_NAME; - - ///Register for Preview port ENABLE event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mPrevPortIndex, - mSwitchToLoadedSem); - - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Error in registering for event %d", ret); - goto EXIT; - } - - ///Enable Preview Port - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortEnable, - mCameraAdapterParameters.mPrevPortIndex, - NULL); - - - CAMHAL_LOGDB("OMX_SendCommand(OMX_CommandStateSet) 0x%x", eError); - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - CAMHAL_LOGDA("Enabling Preview port"); - ///Wait for state to switch to idle - ret = mSwitchToLoadedSem.WaitTimeout(OMX_CMD_TIMEOUT); - - //If somethiing bad happened while we wait - if (mComponentState == OMX_StateInvalid) - { - CAMHAL_LOGEA("Invalid State after Enabling Preview port Exitting!!!"); - goto EXIT; - } - - if ( NO_ERROR == ret ) - { - CAMHAL_LOGDA("Preview port enabled!"); - } - else - { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mPrevPortIndex, - NULL); - CAMHAL_LOGEA("Preview enable timedout"); - - goto EXIT; - } - - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - -EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - performCleanupAfterError(); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::switchToLoaded(bool bPortEnableRequired) { - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mStateSwitchLock); - if ( mComponentState == OMX_StateLoaded || mComponentState == OMX_StateInvalid) { - CAMHAL_LOGDA("Already in OMX_Loaded state or OMX_StateInvalid state"); - return NO_ERROR; - } - - if ( mComponentState != OMX_StateIdle) { - ret = switchToIdle(); - if (ret != NO_ERROR) return ret; - } - - if ( 0 != mSwitchToLoadedSem.Count() ) { - CAMHAL_LOGEB("Error mSwitchToLoadedSem semaphore count %d", mSwitchToLoadedSem.Count()); - goto EXIT; - } - - ///Register for LOADED state transition. - ///This method just inserts a message in Event Q, which is checked in the callback - ///The sempahore passed is signalled by the callback - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandStateSet, - OMX_StateLoaded, - mSwitchToLoadedSem); - - if(ret!=NO_ERROR) - { - CAMHAL_LOGEB("Error in registering for event %d", ret); - goto EXIT; - } - - eError = OMX_SendCommand (mCameraAdapterParameters.mHandleComp, - OMX_CommandStateSet, - OMX_StateLoaded, - NULL); - - if(eError!=OMX_ErrorNone) - { - CAMHAL_LOGEB("OMX_SendCommand(OMX_StateLoaded) - %x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - if ( !bPortEnableRequired ) { - OMXCameraPortParameters *mCaptureData , *mPreviewData, *measurementData; - mCaptureData = mPreviewData = measurementData = NULL; - - mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - mCaptureData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - measurementData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mMeasurementPortIndex]; - - ///Free the OMX Buffers - for ( int i = 0 ; i < mPreviewData->mNumBufs ; i++ ) { - eError = OMX_FreeBuffer(mCameraAdapterParameters.mHandleComp, - mCameraAdapterParameters.mPrevPortIndex, - mPreviewData->mBufferHeader[i]); - - if(eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_FreeBuffer - %x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - } - - if ( mMeasurementEnabled ) { - - for ( int i = 0 ; i < measurementData->mNumBufs ; i++ ) { - eError = OMX_FreeBuffer(mCameraAdapterParameters.mHandleComp, - mCameraAdapterParameters.mMeasurementPortIndex, - measurementData->mBufferHeader[i]); - if(eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_FreeBuffer - %x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - } - - { - android::AutoMutex lock(mPreviewDataBufferLock); - mPreviewDataBuffersAvailable.clear(); - } - - } - } - - CAMHAL_LOGDA("Switching IDLE->LOADED state"); - ret = mSwitchToLoadedSem.WaitTimeout(OMX_CMD_TIMEOUT); - - //If somethiing bad happened while we wait - if (mComponentState == OMX_StateInvalid) - { - CAMHAL_LOGEA("Invalid State after IDLE->LOADED Exitting!!!"); - goto EXIT; - } - - if ( NO_ERROR == ret ) - { - CAMHAL_LOGDA("IDLE->LOADED state changed"); - } - else - { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandStateSet, - OMX_StateLoaded, - NULL); - CAMHAL_LOGEA("Timeout expired on IDLE->LOADED state change"); - goto EXIT; - } - - mComponentState = OMX_StateLoaded; - if (bPortEnableRequired == true) { - prevPortEnable(); - } - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - -EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - { - android::AutoMutex lock(mPreviewBufferLock); - ///Clear all the available preview buffers - mPreviewBuffersAvailable.clear(); - } - performCleanupAfterError(); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::UseBuffersPreview(CameraBuffer * bufArr, int num) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - int tmpHeight, tmpWidth; - - LOG_FUNCTION_NAME; - - if(!bufArr) - { - CAMHAL_LOGEA("NULL pointer passed for buffArr"); - LOG_FUNCTION_NAME_EXIT; - return BAD_VALUE; - } - - OMXCameraPortParameters * mPreviewData = NULL; - OMXCameraPortParameters *measurementData = NULL; - mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - measurementData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mMeasurementPortIndex]; - mPreviewData->mNumBufs = num ; - - if ( 0 != mUsePreviewSem.Count() ) - { - CAMHAL_LOGEB("Error mUsePreviewSem semaphore count %d", mUsePreviewSem.Count()); - LOG_FUNCTION_NAME_EXIT; - return NO_INIT; - } - - if(mPreviewData->mNumBufs != num) - { - CAMHAL_LOGEA("Current number of buffers doesnt equal new num of buffers passed!"); - LOG_FUNCTION_NAME_EXIT; - return BAD_VALUE; - } - - mStateSwitchLock.lock(); - - if ( mComponentState == OMX_StateLoaded ) { - - if (mPendingPreviewSettings & SetLDC) { - mPendingPreviewSettings &= ~SetLDC; - ret = setLDC(mIPP); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("setLDC() failed %d", ret); - } - } - - if (mPendingPreviewSettings & SetNSF) { - mPendingPreviewSettings &= ~SetNSF; - ret = setNSF(mIPP); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("setNSF() failed %d", ret); - } - } - - if (mPendingPreviewSettings & SetCapMode) { - mPendingPreviewSettings &= ~SetCapMode; - ret = setCaptureMode(mCapMode); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("setCaptureMode() failed %d", ret); - } - } - - if(mCapMode == OMXCameraAdapter::VIDEO_MODE) { - - if (mPendingPreviewSettings & SetVNF) { - mPendingPreviewSettings &= ~SetVNF; - ret = enableVideoNoiseFilter(mVnfEnabled); - if ( NO_ERROR != ret){ - CAMHAL_LOGEB("Error configuring VNF %x", ret); - } - } - - if (mPendingPreviewSettings & SetVSTAB) { - mPendingPreviewSettings &= ~SetVSTAB; - ret = enableVideoStabilization(mVstabEnabled); - if ( NO_ERROR != ret) { - CAMHAL_LOGEB("Error configuring VSTAB %x", ret); - } - } - - } - } - - ret = setSensorOrientation(mSensorOrientation); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Error configuring Sensor Orientation %x", ret); - mSensorOrientation = 0; - } - - if ( mComponentState == OMX_StateLoaded ) - { - ///Register for IDLE state switch event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandStateSet, - OMX_StateIdle, - mUsePreviewSem); - - if(ret!=NO_ERROR) - { - CAMHAL_LOGEB("Error in registering for event %d", ret); - goto EXIT; - } - - ///Once we get the buffers, move component state to idle state and pass the buffers to OMX comp using UseBuffer - eError = OMX_SendCommand (mCameraAdapterParameters.mHandleComp , - OMX_CommandStateSet, - OMX_StateIdle, - NULL); - - CAMHAL_LOGDB("OMX_SendCommand(OMX_CommandStateSet) 0x%x", eError); - - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - mComponentState = OMX_StateIdle; - } - else - { - ///Register for Preview port ENABLE event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mPrevPortIndex, - mUsePreviewSem); - - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Error in registering for event %d", ret); - goto EXIT; - } - - ///Enable Preview Port - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortEnable, - mCameraAdapterParameters.mPrevPortIndex, - NULL); - } - - - ///Configure DOMX to use either gralloc handles or vptrs - OMX_TI_PARAMUSENATIVEBUFFER domxUseGrallocHandles; - OMX_INIT_STRUCT_PTR (&domxUseGrallocHandles, OMX_TI_PARAMUSENATIVEBUFFER); - - domxUseGrallocHandles.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - domxUseGrallocHandles.bEnable = OMX_TRUE; - - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexUseNativeBuffers, &domxUseGrallocHandles); - if(eError!=OMX_ErrorNone) - { - CAMHAL_LOGEB("OMX_SetParameter - %x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - OMX_BUFFERHEADERTYPE *pBufferHdr; - for(int index=0;indexmBufSize, - ptr); - if(eError!=OMX_ErrorNone) - { - CAMHAL_LOGEB("OMX_UseBuffer-0x%x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - pBufferHdr->pAppPrivate = (OMX_PTR)&bufArr[index]; - pBufferHdr->nSize = sizeof(OMX_BUFFERHEADERTYPE); - pBufferHdr->nVersion.s.nVersionMajor = 1 ; - pBufferHdr->nVersion.s.nVersionMinor = 1 ; - pBufferHdr->nVersion.s.nRevision = 0 ; - pBufferHdr->nVersion.s.nStep = 0; - mPreviewData->mBufferHeader[index] = pBufferHdr; - } - - if ( mMeasurementEnabled ) - { - - for( int i = 0; i < num; i++ ) - { - OMX_BUFFERHEADERTYPE *pBufHdr; - OMX_U8 *ptr; - - ptr = (OMX_U8 *)camera_buffer_get_omx_ptr (&mPreviewDataBuffers[i]); - eError = OMX_UseBuffer( mCameraAdapterParameters.mHandleComp, - &pBufHdr, - mCameraAdapterParameters.mMeasurementPortIndex, - 0, - measurementData->mBufSize, - ptr); - - if ( eError == OMX_ErrorNone ) - { - pBufHdr->pAppPrivate = (OMX_PTR *)&mPreviewDataBuffers[i]; - pBufHdr->nSize = sizeof(OMX_BUFFERHEADERTYPE); - pBufHdr->nVersion.s.nVersionMajor = 1 ; - pBufHdr->nVersion.s.nVersionMinor = 1 ; - pBufHdr->nVersion.s.nRevision = 0 ; - pBufHdr->nVersion.s.nStep = 0; - measurementData->mBufferHeader[i] = pBufHdr; - } - else - { - CAMHAL_LOGEB("OMX_UseBuffer -0x%x", eError); - ret = BAD_VALUE; - break; - } - } - - } - - CAMHAL_LOGDA("Registering preview buffers"); - - ret = mUsePreviewSem.WaitTimeout(OMX_CMD_TIMEOUT); - - //If somethiing bad happened while we wait - if (mComponentState == OMX_StateInvalid) - { - CAMHAL_LOGEA("Invalid State after Registering preview buffers Exitting!!!"); - goto EXIT; - } - - if ( NO_ERROR == ret ) - { - CAMHAL_LOGDA("Preview buffer registration successfull"); - } - else - { - if ( mComponentState == OMX_StateLoaded ) - { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandStateSet, - OMX_StateIdle, - NULL); - } - else - { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mPrevPortIndex, - NULL); - } - CAMHAL_LOGEA("Timeout expired on preview buffer registration"); - goto EXIT; - } - - LOG_FUNCTION_NAME_EXIT; - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - - ///If there is any failure, we reach here. - ///Here, we do any resource freeing and convert from OMX error code to Camera Hal error code -EXIT: - mStateSwitchLock.unlock(); - - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - performCleanupAfterError(); - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - - LOG_FUNCTION_NAME_EXIT; - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::startPreview() -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXCameraPortParameters *mPreviewData = NULL; - OMXCameraPortParameters *measurementData = NULL; - - LOG_FUNCTION_NAME; - - if( 0 != mStartPreviewSem.Count() ) - { - CAMHAL_LOGEB("Error mStartPreviewSem semaphore count %d", mStartPreviewSem.Count()); - ret = NO_INIT; - goto EXIT; - } - - // Enable all preview mode extra data. - if ( OMX_ErrorNone == eError) { - ret |= setExtraData(true, mCameraAdapterParameters.mPrevPortIndex, OMX_AncillaryData); -#ifndef OMAP_TUNA - ret |= setExtraData(true, OMX_ALL, OMX_TI_VectShotInfo); -#endif - } - - mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - measurementData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mMeasurementPortIndex]; - - if( OMX_StateIdle == mComponentState ) - { - ///Register for EXECUTING state transition. - ///This method just inserts a message in Event Q, which is checked in the callback - ///The sempahore passed is signalled by the callback - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandStateSet, - OMX_StateExecuting, - mStartPreviewSem); - - if(ret!=NO_ERROR) - { - CAMHAL_LOGEB("Error in registering for event %d", ret); - goto EXIT; - } - - ///Switch to EXECUTING state - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandStateSet, - OMX_StateExecuting, - NULL); - - if(eError!=OMX_ErrorNone) - { - CAMHAL_LOGEB("OMX_SendCommand(OMX_StateExecuting)-0x%x", eError); - } - - CAMHAL_LOGDA("+Waiting for component to go into EXECUTING state"); - ret = mStartPreviewSem.WaitTimeout(OMX_CMD_TIMEOUT); - - //If somethiing bad happened while we wait - if (mComponentState == OMX_StateInvalid) - { - CAMHAL_LOGEA("Invalid State after IDLE_EXECUTING Exitting!!!"); - goto EXIT; - } - - if ( NO_ERROR == ret ) - { - CAMHAL_LOGDA("+Great. Component went into executing state!!"); - } - else - { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandStateSet, - OMX_StateExecuting, - NULL); - CAMHAL_LOGDA("Timeout expired on executing state switch!"); - goto EXIT; - } - - mComponentState = OMX_StateExecuting; - - } - - mStateSwitchLock.unlock(); - - //Queue all the buffers on preview port - for(int index=0;index< mPreviewData->mMaxQueueable;index++) - { - CAMHAL_LOGDB("Queuing buffer on Preview port - 0x%x", (uint32_t)mPreviewData->mBufferHeader[index]->pBuffer); - mPreviewData->mStatus[index] = OMXCameraPortParameters::FILL; - eError = OMX_FillThisBuffer(mCameraAdapterParameters.mHandleComp, - (OMX_BUFFERHEADERTYPE*)mPreviewData->mBufferHeader[index]); - if(eError!=OMX_ErrorNone) - { - CAMHAL_LOGEB("OMX_FillThisBuffer-0x%x", eError); - } - mFramesWithDucati++; -#ifdef CAMERAHAL_DEBUG - mBuffersWithDucati.add((int)mPreviewData->mBufferHeader[index]->pAppPrivate,1); -#endif - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - } - - if ( mMeasurementEnabled ) - { - - for(int index=0;index< mPreviewData->mNumBufs;index++) - { - CAMHAL_LOGDB("Queuing buffer on Measurement port - 0x%x", (uint32_t) measurementData->mBufferHeader[index]->pBuffer); - measurementData->mStatus[index] = OMXCameraPortParameters::FILL; - eError = OMX_FillThisBuffer(mCameraAdapterParameters.mHandleComp, - (OMX_BUFFERHEADERTYPE*) measurementData->mBufferHeader[index]); - if(eError!=OMX_ErrorNone) - { - CAMHAL_LOGEB("OMX_FillThisBuffer-0x%x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - } - - } - - setFocusCallback(true); - - //reset frame rate estimates - mFPS = 0.0f; - mLastFPS = 0.0f; - // start frame count from 0. i.e first frame after - // startPreview will be the 0th reference frame - // this way we will wait for second frame until - // takePicture/autoFocus is allowed to run. we - // are seeing SetConfig/GetConfig fail after - // calling after the first frame and not failing - // after the second frame - mFrameCount = -1; - mLastFrameCount = 0; - mIter = 1; - mLastFPSTime = systemTime(); - mTunnelDestroyed = false; - - LOG_FUNCTION_NAME_EXIT; - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - - EXIT: - - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - performCleanupAfterError(); - mStateSwitchLock.unlock(); - LOG_FUNCTION_NAME_EXIT; - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - -} - -status_t OMXCameraAdapter::destroyTunnel() -{ - LOG_FUNCTION_NAME; - - OMX_ERRORTYPE eError = OMX_ErrorNone; - status_t ret = NO_ERROR; - - OMXCameraPortParameters *mCaptureData , *mPreviewData, *measurementData; - mCaptureData = mPreviewData = measurementData = NULL; - - mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - mCaptureData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - measurementData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mMeasurementPortIndex]; - - if (mAdapterState == LOADED_PREVIEW_STATE) { - // Something happened in CameraHal between UseBuffers and startPreview - // this means that state switch is still locked..so we need to unlock else - // deadlock will occur on the next start preview - mStateSwitchLock.unlock(); - return ALREADY_EXISTS; - } - - if ( mComponentState != OMX_StateExecuting ) - { - CAMHAL_LOGEA("Calling StopPreview() when not in EXECUTING state"); - LOG_FUNCTION_NAME_EXIT; - return NO_INIT; - } - - { - android::AutoMutex lock(mFrameCountMutex); - // we should wait for the first frame to come before trying to stopPreview...if not - // we might put OMXCamera in a bad state (IDLE->LOADED timeout). Seeing this a lot - // after a capture - if (mFrameCount < 1) { - // I want to wait for at least two frames.... - mFrameCount = -1; - - // first frame may time some time to come...so wait for an adequate amount of time - // which 2 * OMX_CAPTURE_TIMEOUT * 1000 will cover. - ret = mFirstFrameCondition.waitRelative(mFrameCountMutex, - (nsecs_t) 2 * OMX_CAPTURE_TIMEOUT * 1000); - } - // even if we timeout waiting for the first frame...go ahead with trying to stop preview - // signal anybody that might be waiting - mFrameCount = 0; - mFirstFrameCondition.broadcast(); - } - - { - android::AutoMutex lock(mDoAFMutex); - mDoAFCond.broadcast(); - } - - OMX_CONFIG_FOCUSASSISTTYPE focusAssist; - OMX_INIT_STRUCT_PTR (&focusAssist, OMX_CONFIG_FOCUSASSISTTYPE); - focusAssist.nPortIndex = OMX_ALL; - focusAssist.bFocusAssist = OMX_FALSE; - CAMHAL_LOGDB("Configuring AF Assist mode 0x%x", focusAssist.bFocusAssist); - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_IndexConfigFocusAssist, - &focusAssist); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring AF Assist mode 0x%x", eError); - } - else - { - CAMHAL_LOGDA("Camera AF Assist mode configured successfully"); - } - - if ( 0 != mStopPreviewSem.Count() ) - { - CAMHAL_LOGEB("Error mStopPreviewSem semaphore count %d", mStopPreviewSem.Count()); - LOG_FUNCTION_NAME_EXIT; - return NO_INIT; - } - - ret = disableImagePort(); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("disable image port failed 0x%x", ret); - goto EXIT; - } - - CAMHAL_LOGDB("Average framerate: %f", mFPS); - - //Avoid state switching of the OMX Component - ret = flushBuffers(); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Flush Buffers failed 0x%x", ret); - goto EXIT; - } - - switchToIdle(); - - mTunnelDestroyed = true; - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - -EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - { - android::AutoMutex lock(mPreviewBufferLock); - ///Clear all the available preview buffers - mPreviewBuffersAvailable.clear(); - } - performCleanupAfterError(); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - -} - -status_t OMXCameraAdapter::stopPreview() { - LOG_FUNCTION_NAME; - - OMX_ERRORTYPE eError = OMX_ErrorNone; - status_t ret = NO_ERROR; - - if (mTunnelDestroyed == false){ - ret = destroyTunnel(); - if (ret == ALREADY_EXISTS) { - // Special case to handle invalid stopping preview in LOADED_PREVIEW_STATE - return NO_ERROR; - } - if (ret != NO_ERROR) { - CAMHAL_LOGEB(" destroyTunnel returned error "); - return ret; - } - } - - mTunnelDestroyed = false; - - { - android::AutoMutex lock(mPreviewBufferLock); - ///Clear all the available preview buffers - mPreviewBuffersAvailable.clear(); - } - - switchToLoaded(); - - mFirstTimeInit = true; - mPendingCaptureSettings = 0; - mFramesWithDucati = 0; - mFramesWithDisplay = 0; - mFramesWithEncoder = 0; - - LOG_FUNCTION_NAME_EXIT; - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::setSensorOverclock(bool enable) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_BOOLEANTYPE bOMX; - - LOG_FUNCTION_NAME; - - if ( OMX_StateLoaded != mComponentState ) - { - CAMHAL_LOGDA("OMX component is not in loaded state"); - return ret; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR (&bOMX, OMX_CONFIG_BOOLEANTYPE); - - if ( enable ) - { - bOMX.bEnabled = OMX_TRUE; - } - else - { - bOMX.bEnabled = OMX_FALSE; - } - - CAMHAL_LOGDB("Configuring Sensor overclock mode 0x%x", bOMX.bEnabled); - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, ( OMX_INDEXTYPE ) OMX_TI_IndexParamSensorOverClockMode, &bOMX); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while setting Sensor overclock 0x%x", eError); - } - else - { - mSensorOverclock = enable; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::printComponentVersion(OMX_HANDLETYPE handle) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_VERSIONTYPE compVersion; - char compName[OMX_MAX_STRINGNAME_SIZE]; - char *currentUUID = NULL; - size_t offset = 0; - - LOG_FUNCTION_NAME; - - if ( NULL == handle ) - { - CAMHAL_LOGEB("Invalid OMX Handle =0x%x", ( unsigned int ) handle); - ret = -EINVAL; - } - - mCompUUID[0] = 0; - - if ( NO_ERROR == ret ) - { - eError = OMX_GetComponentVersion(handle, - compName, - &compVersion, - &mCompRevision, - &mCompUUID - ); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("OMX_GetComponentVersion returned 0x%x", eError); - ret = BAD_VALUE; - } - } - - if ( NO_ERROR == ret ) - { - CAMHAL_LOGVB("OMX Component name: [%s]", compName); - CAMHAL_LOGVB("OMX Component version: [%u]", ( unsigned int ) compVersion.nVersion); - CAMHAL_LOGVB("Spec version: [%u]", ( unsigned int ) mCompRevision.nVersion); - CAMHAL_LOGVB("Git Commit ID: [%s]", mCompUUID); - currentUUID = ( char * ) mCompUUID; - } - - if ( NULL != currentUUID ) - { - offset = strlen( ( const char * ) mCompUUID) + 1; - if ( (int)currentUUID + (int)offset - (int)mCompUUID < OMX_MAX_STRINGNAME_SIZE ) - { - currentUUID += offset; - CAMHAL_LOGVB("Git Branch: [%s]", currentUUID); - } - else - { - ret = BAD_VALUE; - } - } - - if ( NO_ERROR == ret ) - { - offset = strlen( ( const char * ) currentUUID) + 1; - - if ( (int)currentUUID + (int)offset - (int)mCompUUID < OMX_MAX_STRINGNAME_SIZE ) - { - currentUUID += offset; - CAMHAL_LOGVB("Build date and time: [%s]", currentUUID); - } - else - { - ret = BAD_VALUE; - } - } - - if ( NO_ERROR == ret ) - { - offset = strlen( ( const char * ) currentUUID) + 1; - - if ( (int)currentUUID + (int)offset - (int)mCompUUID < OMX_MAX_STRINGNAME_SIZE ) - { - currentUUID += offset; - CAMHAL_LOGVB("Build description: [%s]", currentUUID); - } - else - { - ret = BAD_VALUE; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -#ifndef OMAP_TUNA -status_t OMXCameraAdapter::setS3DFrameLayout(OMX_U32 port) const -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_TI_FRAMELAYOUTTYPE frameLayout; - const OMXCameraPortParameters *cap = - &mCameraAdapterParameters.mCameraPortParams[port]; - - LOG_FUNCTION_NAME; - - OMX_INIT_STRUCT_PTR (&frameLayout, OMX_TI_FRAMELAYOUTTYPE); - frameLayout.nPortIndex = port; - eError = OMX_GetParameter(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexParamStereoFrmLayout, &frameLayout); - if (eError != OMX_ErrorNone) - { - CAMHAL_LOGEB("Error while getting S3D frame layout: 0x%x", eError); - return -EINVAL; - } - - if (cap->mFrameLayoutType == OMX_TI_StereoFrameLayoutTopBottomSubsample) - { - frameLayout.eFrameLayout = OMX_TI_StereoFrameLayoutTopBottom; - frameLayout.nSubsampleRatio = 2; - } - else if (cap->mFrameLayoutType == - OMX_TI_StereoFrameLayoutLeftRightSubsample) - { - frameLayout.eFrameLayout = OMX_TI_StereoFrameLayoutLeftRight; - frameLayout.nSubsampleRatio = 2; - } - else - { - frameLayout.eFrameLayout = cap->mFrameLayoutType; - frameLayout.nSubsampleRatio = 1; - } - frameLayout.nSubsampleRatio = frameLayout.nSubsampleRatio << 7; - - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexParamStereoFrmLayout, &frameLayout); - if (eError != OMX_ErrorNone) - { - CAMHAL_LOGEB("Error while setting S3D frame layout: 0x%x", eError); - return -EINVAL; - } - else - { - CAMHAL_LOGDB("S3D frame layout %d applied successfully on port %lu", - frameLayout.eFrameLayout, port); - } - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} -#endif - -status_t OMXCameraAdapter::autoFocus() -{ - status_t ret = NO_ERROR; - Utils::Message msg; - - LOG_FUNCTION_NAME; - - { - android::AutoMutex lock(mFrameCountMutex); - if (mFrameCount < 1) { - // first frame may time some time to come...so wait for an adequate amount of time - // which 2 * OMX_CAPTURE_TIMEOUT * 1000 will cover. - ret = mFirstFrameCondition.waitRelative(mFrameCountMutex, - (nsecs_t) 2 * OMX_CAPTURE_TIMEOUT * 1000); - if ((NO_ERROR != ret) || (mFrameCount == 0)) { - goto EXIT; - } - } - } - - msg.command = CommandHandler::CAMERA_PERFORM_AUTOFOCUS; - msg.arg1 = mErrorNotifier; - ret = mCommandHandler->put(&msg); - - EXIT: - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::takePicture() -{ - status_t ret = NO_ERROR; - Utils::Message msg; - - LOG_FUNCTION_NAME; - - { - android::AutoMutex lock(mFrameCountMutex); - if (mFrameCount < 1) { - // first frame may time some time to come...so wait for an adequate amount of time - // which 2 * OMX_CAPTURE_TIMEOUT * 1000 will cover. - ret = mFirstFrameCondition.waitRelative(mFrameCountMutex, - (nsecs_t) 2 * OMX_CAPTURE_TIMEOUT * 1000); - if ((NO_ERROR != ret) || (mFrameCount == 0)) { - goto EXIT; - } - } - } - - // TODO(XXX): re-using take picture to kick off reprocessing pipe - // Need to rethink this approach during reimplementation - if (mNextState == REPROCESS_STATE) { - msg.command = CommandHandler::CAMERA_START_REPROCESS; - } else { - msg.command = CommandHandler::CAMERA_START_IMAGE_CAPTURE; - } - - msg.arg1 = mErrorNotifier; - msg.arg2 = cacheCaptureParameters(); - ret = mCommandHandler->put(&msg); - - EXIT: - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::startVideoCapture() -{ - return BaseCameraAdapter::startVideoCapture(); -} - -status_t OMXCameraAdapter::stopVideoCapture() -{ - return BaseCameraAdapter::stopVideoCapture(); -} - -//API to get the frame size required to be allocated. This size is used to override the size passed -//by camera service when VSTAB/VNF is turned ON for example -status_t OMXCameraAdapter::getFrameSize(size_t &width, size_t &height) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_RECTTYPE tFrameDim; - - LOG_FUNCTION_NAME; - - OMX_INIT_STRUCT_PTR (&tFrameDim, OMX_CONFIG_RECTTYPE); - tFrameDim.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - if ( mOMXStateSwitch ) - { - ret = switchToLoaded(true); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("switchToLoaded() failed 0x%x", ret); - goto exit; - } - - mOMXStateSwitch = false; - } - - if ( OMX_StateLoaded == mComponentState ) - { - - if (mPendingPreviewSettings & SetLDC) { - mPendingPreviewSettings &= ~SetLDC; - ret = setLDC(mIPP); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("setLDC() failed %d", ret); - LOG_FUNCTION_NAME_EXIT; - goto exit; - } - } - - if (mPendingPreviewSettings & SetNSF) { - mPendingPreviewSettings &= ~SetNSF; - ret = setNSF(mIPP); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("setNSF() failed %d", ret); - LOG_FUNCTION_NAME_EXIT; - goto exit; - } - } - - if (mPendingPreviewSettings & SetCapMode) { - mPendingPreviewSettings &= ~SetCapMode; - ret = setCaptureMode(mCapMode); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("setCaptureMode() failed %d", ret); - } - } - - if(mCapMode == OMXCameraAdapter::VIDEO_MODE) { - - if (mPendingPreviewSettings & SetVNF) { - mPendingPreviewSettings &= ~SetVNF; - ret = enableVideoNoiseFilter(mVnfEnabled); - if ( NO_ERROR != ret){ - CAMHAL_LOGEB("Error configuring VNF %x", ret); - } - } - - if (mPendingPreviewSettings & SetVSTAB) { - mPendingPreviewSettings &= ~SetVSTAB; - ret = enableVideoStabilization(mVstabEnabled); - if ( NO_ERROR != ret) { - CAMHAL_LOGEB("Error configuring VSTAB %x", ret); - } - } - - } - } - - ret = setSensorOrientation(mSensorOrientation); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Error configuring Sensor Orientation %x", ret); - mSensorOrientation = 0; - } - - if ( NO_ERROR == ret ) - { - eError = OMX_GetParameter(mCameraAdapterParameters.mHandleComp, ( OMX_INDEXTYPE ) OMX_TI_IndexParam2DBufferAllocDimension, &tFrameDim); - if ( OMX_ErrorNone == eError) - { - width = tFrameDim.nWidth; - height = tFrameDim.nHeight; - } - } - -exit: - - CAMHAL_LOGDB("Required frame size %dx%d", width, height); - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::getFrameDataSize(size_t &dataFrameSize, size_t bufferCount) -{ - status_t ret = NO_ERROR; - OMX_PARAM_PORTDEFINITIONTYPE portCheck; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - LOG_FUNCTION_NAME; - - if ( OMX_StateLoaded != mComponentState ) - { - CAMHAL_LOGEA("Calling getFrameDataSize() when not in LOADED state"); - dataFrameSize = 0; - ret = BAD_VALUE; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR(&portCheck, OMX_PARAM_PORTDEFINITIONTYPE); - portCheck.nPortIndex = mCameraAdapterParameters.mMeasurementPortIndex; - - eError = OMX_GetParameter(mCameraAdapterParameters.mHandleComp, OMX_IndexParamPortDefinition, &portCheck); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("OMX_GetParameter on OMX_IndexParamPortDefinition returned: 0x%x", eError); - dataFrameSize = 0; - ret = BAD_VALUE; - } - } - - if ( NO_ERROR == ret ) - { - portCheck.nBufferCountActual = bufferCount; - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, OMX_IndexParamPortDefinition, &portCheck); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("OMX_SetParameter on OMX_IndexParamPortDefinition returned: 0x%x", eError); - dataFrameSize = 0; - ret = BAD_VALUE; - } - } - - if ( NO_ERROR == ret ) - { - eError = OMX_GetParameter(mCameraAdapterParameters.mHandleComp, OMX_IndexParamPortDefinition, &portCheck); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("OMX_GetParameter on OMX_IndexParamPortDefinition returned: 0x%x", eError); - ret = BAD_VALUE; - } - else - { - mCameraAdapterParameters.mCameraPortParams[portCheck.nPortIndex].mBufSize = portCheck.nBufferSize; - dataFrameSize = portCheck.nBufferSize; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -void OMXCameraAdapter::onOrientationEvent(uint32_t orientation, uint32_t tilt) -{ - LOG_FUNCTION_NAME; - - static const unsigned int DEGREES_TILT_IGNORE = 45; - - // if tilt angle is greater than DEGREES_TILT_IGNORE - // we are going to ignore the orientation returned from - // sensor. the orientation returned from sensor is not - // reliable. Value of DEGREES_TILT_IGNORE may need adjusting - if (tilt > DEGREES_TILT_IGNORE) { - return; - } - - int mountOrientation = 0; - bool isFront = false; - if (mCapabilities) { - const char * const mountOrientationString = - mCapabilities->get(CameraProperties::ORIENTATION_INDEX); - if (mountOrientationString) { - mountOrientation = atoi(mountOrientationString); - } - - const char * const facingString = mCapabilities->get(CameraProperties::FACING_INDEX); - if (facingString) { - isFront = strcmp(facingString, TICameraParameters::FACING_FRONT) == 0; - } - } - - // direction is a constant sign for facing, meaning the rotation direction relative to device - // +1 (clockwise) for back sensor and -1 (counter-clockwise) for front sensor - const int direction = isFront ? -1 : 1; - - int rotation = mountOrientation + direction*orientation; - - // crop the calculated value to [0..360) range - while ( rotation < 0 ) rotation += 360; - rotation %= 360; - - if (rotation != mDeviceOrientation) { - mDeviceOrientation = rotation; - - // restart face detection with new rotation - setFaceDetectionOrientation(mDeviceOrientation); - } - CAMHAL_LOGSVB("orientation = %d tilt = %d device_orientation = %d", orientation, tilt, mDeviceOrientation); - - LOG_FUNCTION_NAME_EXIT; -} - -/* Application callback Functions */ -/*========================================================*/ -/* @ fn SampleTest_EventHandler :: Application callback */ -/*========================================================*/ -OMX_ERRORTYPE OMXCameraAdapterEventHandler(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData) -{ - LOG_FUNCTION_NAME; - - CAMHAL_LOGDB("Event %d", eEvent); - - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMXCameraAdapter *oca = (OMXCameraAdapter*)pAppData; - ret = oca->OMXCameraAdapterEventHandler(hComponent, eEvent, nData1, nData2, pEventData); - - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -/* Application callback Functions */ -/*========================================================*/ -/* @ fn SampleTest_EventHandler :: Application callback */ -/*========================================================*/ -OMX_ERRORTYPE OMXCameraAdapter::OMXCameraAdapterEventHandler(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData) -{ - - LOG_FUNCTION_NAME; - - OMX_ERRORTYPE eError = OMX_ErrorNone; - CAMHAL_LOGDB("+OMX_Event %x, %d %d", eEvent, (int)nData1, (int)nData2); - - switch (eEvent) { - case OMX_EventCmdComplete: - CAMHAL_LOGDB("+OMX_EventCmdComplete %d %d", (int)nData1, (int)nData2); - - if (OMX_CommandStateSet == nData1) { - mCameraAdapterParameters.mState = (OMX_STATETYPE) nData2; - - } else if (OMX_CommandFlush == nData1) { - CAMHAL_LOGDB("OMX_CommandFlush received for port %d", (int)nData2); - - } else if (OMX_CommandPortDisable == nData1) { - CAMHAL_LOGDB("OMX_CommandPortDisable received for port %d", (int)nData2); - - } else if (OMX_CommandPortEnable == nData1) { - CAMHAL_LOGDB("OMX_CommandPortEnable received for port %d", (int)nData2); - - } else if (OMX_CommandMarkBuffer == nData1) { - ///This is not used currently - } - - CAMHAL_LOGDA("-OMX_EventCmdComplete"); - break; - - case OMX_EventIndexSettingChanged: - CAMHAL_LOGDB("OMX_EventIndexSettingChanged event received data1 0x%x, data2 0x%x", - ( unsigned int ) nData1, ( unsigned int ) nData2); - break; - - case OMX_EventError: - CAMHAL_LOGDB("OMX interface failed to execute OMX command %d", (int)nData1); - CAMHAL_LOGDA("See OMX_INDEXTYPE for reference"); - if ( NULL != mErrorNotifier && ( ( OMX_U32 ) OMX_ErrorHardware == nData1 ) && mComponentState != OMX_StateInvalid) - { - CAMHAL_LOGEA("***Got Fatal Error Notification***\n"); - mComponentState = OMX_StateInvalid; - /* - Remove any unhandled events and - unblock any waiting semaphores - */ - if ( !mEventSignalQ.isEmpty() ) - { - for (unsigned int i = 0 ; i < mEventSignalQ.size(); i++ ) - { - CAMHAL_LOGEB("***Removing %d EVENTS***** \n", mEventSignalQ.size()); - //remove from queue and free msg - Utils::Message *msg = mEventSignalQ.itemAt(i); - if ( NULL != msg ) - { - Utils::Semaphore *sem = (Utils::Semaphore*) msg->arg3; - if ( sem ) - { - sem->Signal(); - } - free(msg); - } - } - mEventSignalQ.clear(); - } - ///Report Error to App - mErrorNotifier->errorNotify(CAMERA_ERROR_FATAL); - } - break; - - case OMX_EventMark: - break; - - case OMX_EventPortSettingsChanged: - break; - - case OMX_EventBufferFlag: - break; - - case OMX_EventResourcesAcquired: - break; - - case OMX_EventComponentResumed: - break; - - case OMX_EventDynamicResourcesAvailable: - break; - - case OMX_EventPortFormatDetected: - break; - - default: - break; - } - - ///Signal to the thread(s) waiting that the event has occured - SignalEvent(hComponent, eEvent, nData1, nData2, pEventData); - - LOG_FUNCTION_NAME_EXIT; - return eError; - - EXIT: - - CAMHAL_LOGEB("Exiting function %s because of eError=%x", __FUNCTION__, eError); - LOG_FUNCTION_NAME_EXIT; - return eError; -} - -OMX_ERRORTYPE OMXCameraAdapter::SignalEvent(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData) -{ - android::AutoMutex lock(mEventLock); - Utils::Message *msg; - bool eventSignalled = false; - - LOG_FUNCTION_NAME; - - if ( !mEventSignalQ.isEmpty() ) - { - CAMHAL_LOGDA("Event queue not empty"); - - for ( unsigned int i = 0 ; i < mEventSignalQ.size() ; i++ ) - { - msg = mEventSignalQ.itemAt(i); - if ( NULL != msg ) - { - if( ( msg->command != 0 || msg->command == ( unsigned int ) ( eEvent ) ) - && ( !msg->arg1 || ( OMX_U32 ) msg->arg1 == nData1 ) - && ( !msg->arg2 || ( OMX_U32 ) msg->arg2 == nData2 ) - && msg->arg3) - { - Utils::Semaphore *sem = (Utils::Semaphore*) msg->arg3; - CAMHAL_LOGDA("Event matched, signalling sem"); - mEventSignalQ.removeAt(i); - //Signal the semaphore provided - sem->Signal(); - free(msg); - eventSignalled = true; - break; - } - } - } - } - else - { - CAMHAL_LOGDA("Event queue empty!!!"); - } - - // Special handling for any unregistered events - if (!eventSignalled) { - // Handling for focus callback - if ((nData2 == OMX_IndexConfigCommonFocusStatus) && - (eEvent == (OMX_EVENTTYPE) OMX_EventIndexSettingChanged)) { - Utils::Message msg; - msg.command = OMXCallbackHandler::CAMERA_FOCUS_STATUS; - msg.arg1 = NULL; - msg.arg2 = NULL; - mOMXCallbackHandler->put(&msg); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE OMXCameraAdapter::RemoveEvent(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData) -{ - android::AutoMutex lock(mEventLock); - Utils::Message *msg; - LOG_FUNCTION_NAME; - - if ( !mEventSignalQ.isEmpty() ) - { - CAMHAL_LOGDA("Event queue not empty"); - - for ( unsigned int i = 0 ; i < mEventSignalQ.size() ; i++ ) - { - msg = mEventSignalQ.itemAt(i); - if ( NULL != msg ) - { - if( ( msg->command != 0 || msg->command == ( unsigned int ) ( eEvent ) ) - && ( !msg->arg1 || ( OMX_U32 ) msg->arg1 == nData1 ) - && ( !msg->arg2 || ( OMX_U32 ) msg->arg2 == nData2 ) - && msg->arg3) - { - Utils::Semaphore *sem = (Utils::Semaphore*) msg->arg3; - CAMHAL_LOGDA("Event matched, signalling sem"); - mEventSignalQ.removeAt(i); - free(msg); - break; - } - } - } - } - else - { - CAMHAL_LOGEA("Event queue empty!!!"); - } - LOG_FUNCTION_NAME_EXIT; - - return OMX_ErrorNone; -} - - -status_t OMXCameraAdapter::RegisterForEvent(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN Utils::Semaphore &semaphore) -{ - status_t ret = NO_ERROR; - ssize_t res; - android::AutoMutex lock(mEventLock); - - LOG_FUNCTION_NAME; - Utils::Message * msg = ( struct Utils::Message * ) malloc(sizeof(struct Utils::Message)); - if ( NULL != msg ) - { - msg->command = ( unsigned int ) eEvent; - msg->arg1 = ( void * ) nData1; - msg->arg2 = ( void * ) nData2; - msg->arg3 = ( void * ) &semaphore; - msg->arg4 = ( void * ) hComponent; - res = mEventSignalQ.add(msg); - if ( NO_MEMORY == res ) - { - CAMHAL_LOGEA("No ressources for inserting OMX events"); - free(msg); - ret = -ENOMEM; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -/*========================================================*/ -/* @ fn SampleTest_EmptyBufferDone :: Application callback*/ -/*========================================================*/ -OMX_ERRORTYPE OMXCameraAdapterEmptyBufferDone(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffHeader) -{ - LOG_FUNCTION_NAME; - - OMX_ERRORTYPE eError = OMX_ErrorNone; - - OMXCameraAdapter *oca = (OMXCameraAdapter*)pAppData; - eError = oca->OMXCameraAdapterEmptyBufferDone(hComponent, pBuffHeader); - - LOG_FUNCTION_NAME_EXIT; - return eError; -} - - -/*========================================================*/ -/* @ fn SampleTest_EmptyBufferDone :: Application callback*/ -/*========================================================*/ -OMX_ERRORTYPE OMXCameraAdapter::OMXCameraAdapterEmptyBufferDone(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffHeader) -{ - - LOG_FUNCTION_NAME; - status_t stat = NO_ERROR; - status_t res1, res2; - OMXCameraPortParameters *pPortParam; - CameraFrame::FrameType typeOfFrame = CameraFrame::ALL_FRAMES; - unsigned int refCount = 0; - unsigned int mask = 0xFFFF; - CameraFrame cameraFrame; - OMX_TI_PLATFORMPRIVATE *platformPrivate; - - res1 = res2 = NO_ERROR; - - if (!pBuffHeader || !pBuffHeader->pBuffer) { - CAMHAL_LOGE("NULL Buffer from OMX"); - return OMX_ErrorNone; - } - - pPortParam = &(mCameraAdapterParameters.mCameraPortParams[pBuffHeader->nInputPortIndex]); - platformPrivate = (OMX_TI_PLATFORMPRIVATE*) pBuffHeader->pPlatformPrivate; - - if (pBuffHeader->nInputPortIndex == OMX_CAMERA_PORT_VIDEO_IN_VIDEO) { - typeOfFrame = CameraFrame::REPROCESS_INPUT_FRAME; - mask = (unsigned int)CameraFrame::REPROCESS_INPUT_FRAME; - - stat = sendCallBacks(cameraFrame, pBuffHeader, mask, pPortParam); - } - - LOG_FUNCTION_NAME_EXIT; - - return OMX_ErrorNone; -} - -static void debugShowFPS() -{ - static int mFrameCount = 0; - static int mLastFrameCount = 0; - static nsecs_t mLastFpsTime = 0; - static float mFps = 0; - mFrameCount++; - if (!(mFrameCount & 0x1F)) { - nsecs_t now = systemTime(); - nsecs_t diff = now - mLastFpsTime; - mFps = ((mFrameCount - mLastFrameCount) * float(s2ns(1))) / diff; - mLastFpsTime = now; - mLastFrameCount = mFrameCount; - CAMHAL_LOGI("Camera %d Frames, %f FPS", mFrameCount, mFps); - } - // XXX: mFPS has the value we want -} - -/*========================================================*/ -/* @ fn SampleTest_FillBufferDone :: Application callback*/ -/*========================================================*/ -OMX_ERRORTYPE OMXCameraAdapterFillBufferDone(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffHeader) -{ - Utils::Message msg; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - if (UNLIKELY(mDebugFps)) { - debugShowFPS(); - } - - OMXCameraAdapter *adapter = ( OMXCameraAdapter * ) pAppData; - if ( NULL != adapter ) - { - msg.command = OMXCameraAdapter::OMXCallbackHandler::CAMERA_FILL_BUFFER_DONE; - msg.arg1 = ( void * ) hComponent; - msg.arg2 = ( void * ) pBuffHeader; - adapter->mOMXCallbackHandler->put(&msg); - } - - return eError; -} - -#ifdef CAMERAHAL_OMX_PROFILING - -status_t OMXCameraAdapter::storeProfilingData(OMX_BUFFERHEADERTYPE* pBuffHeader) { - OMX_TI_PLATFORMPRIVATE *platformPrivate = NULL; - OMX_OTHER_EXTRADATATYPE *extraData = NULL; - FILE *fd = NULL; - - LOG_FUNCTION_NAME - - if ( UNLIKELY( mDebugProfile ) ) { - - platformPrivate = static_cast (pBuffHeader->pPlatformPrivate); - extraData = getExtradata(static_cast (platformPrivate->pMetaDataBuffer), - platformPrivate->nMetaDataSize, - static_cast (OMX_TI_ProfilerData)); - - if ( NULL != extraData ) { - if( extraData->eType == static_cast (OMX_TI_ProfilerData) ) { - - fd = fopen(DEFAULT_PROFILE_PATH, "ab"); - if ( NULL != fd ) { - fwrite(extraData->data, 1, extraData->nDataSize, fd); - fclose(fd); - } else { - return -errno; - } - - } else { - return NOT_ENOUGH_DATA; - } - } else { - return NOT_ENOUGH_DATA; - } - } - - LOG_FUNCTION_NAME_EXIT - - return NO_ERROR; -} - -#endif - -/*========================================================*/ -/* @ fn SampleTest_FillBufferDone :: Application callback*/ -/*========================================================*/ -OMX_ERRORTYPE OMXCameraAdapter::OMXCameraAdapterFillBufferDone(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffHeader) -{ - - status_t stat = NO_ERROR; - status_t res1, res2; - OMXCameraPortParameters *pPortParam; - OMX_ERRORTYPE eError = OMX_ErrorNone; - CameraFrame::FrameType typeOfFrame = CameraFrame::ALL_FRAMES; - unsigned int refCount = 0; - BaseCameraAdapter::AdapterState state, nextState; - BaseCameraAdapter::getState(state); - BaseCameraAdapter::getNextState(nextState); - android::sp metadataResult = NULL; - unsigned int mask = 0xFFFF; - CameraFrame cameraFrame; - OMX_OTHER_EXTRADATATYPE *extraData; - OMX_TI_ANCILLARYDATATYPE *ancillaryData = NULL; - bool snapshotFrame = false; - - if ( NULL == pBuffHeader ) { - return OMX_ErrorBadParameter; - } - -#ifdef CAMERAHAL_OMX_PROFILING - - storeProfilingData(pBuffHeader); - -#endif - - res1 = res2 = NO_ERROR; - - if ( !pBuffHeader || !pBuffHeader->pBuffer ) { - CAMHAL_LOGEA("NULL Buffer from OMX"); - return OMX_ErrorNone; - } - - pPortParam = &(mCameraAdapterParameters.mCameraPortParams[pBuffHeader->nOutputPortIndex]); - - // Find buffer and mark it as filled - for (int i = 0; i < pPortParam->mNumBufs; i++) { - if (pPortParam->mBufferHeader[i] == pBuffHeader) { - pPortParam->mStatus[i] = OMXCameraPortParameters::DONE; - } - } - - if (pBuffHeader->nOutputPortIndex == OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW) - { - - if ( ( PREVIEW_ACTIVE & state ) != PREVIEW_ACTIVE ) - { - return OMX_ErrorNone; - } - - if ( mWaitingForSnapshot ) { - extraData = getExtradata(pBuffHeader->pPlatformPrivate, - (OMX_EXTRADATATYPE) OMX_AncillaryData); - - if ( NULL != extraData ) { - ancillaryData = (OMX_TI_ANCILLARYDATATYPE*) extraData->data; -#ifdef OMAP_TUNA - snapshotFrame = ancillaryData->nDCCStatus; -#else - if ((OMX_2D_Snap == ancillaryData->eCameraView) - || (OMX_3D_Left_Snap == ancillaryData->eCameraView) - || (OMX_3D_Right_Snap == ancillaryData->eCameraView)) { - snapshotFrame = OMX_TRUE; - } else { - snapshotFrame = OMX_FALSE; - } -#endif - mPending3Asettings |= SetFocus; - } - } - - ///Prepare the frames to be sent - initialize CameraFrame object and reference count - // TODO(XXX): ancillary data for snapshot frame is not being sent for video snapshot - // if we are waiting for a snapshot and in video mode...go ahead and send - // this frame as a snapshot - if( mWaitingForSnapshot && (mCapturedFrames > 0) && - (snapshotFrame || (mCapMode == VIDEO_MODE))) - { - typeOfFrame = CameraFrame::SNAPSHOT_FRAME; - mask = (unsigned int)CameraFrame::SNAPSHOT_FRAME; - - // video snapshot gets ancillary data and wb info from last snapshot frame - mCaptureAncillaryData = ancillaryData; - mWhiteBalanceData = NULL; - extraData = getExtradata(pBuffHeader->pPlatformPrivate, - (OMX_EXTRADATATYPE) OMX_WhiteBalance); - if ( NULL != extraData ) - { - mWhiteBalanceData = (OMX_TI_WHITEBALANCERESULTTYPE*) extraData->data; - } - } - else - { - typeOfFrame = CameraFrame::PREVIEW_FRAME_SYNC; - mask = (unsigned int)CameraFrame::PREVIEW_FRAME_SYNC; - } - - if (mRecording) - { - mask |= (unsigned int)CameraFrame::VIDEO_FRAME_SYNC; - mFramesWithEncoder++; - } - - //CAMHAL_LOGV("FBD pBuffer = 0x%x", pBuffHeader->pBuffer); - - if( mWaitingForSnapshot ) - { - if (!mBracketingEnabled && - ((HIGH_SPEED == mCapMode) || (VIDEO_MODE == mCapMode)) ) - { - notifyShutterSubscribers(); - } - } - - stat = sendCallBacks(cameraFrame, pBuffHeader, mask, pPortParam); - mFramesWithDisplay++; - - mFramesWithDucati--; - -#ifdef CAMERAHAL_DEBUG - if(mBuffersWithDucati.indexOfKey((uint32_t)pBuffHeader->pBuffer)<0) - { - CAMHAL_LOGE("Buffer was never with Ducati!! %p", pBuffHeader->pBuffer); - for(unsigned int i=0;ipBuffer); -#endif - - if(mDebugFcs) - CAMHAL_LOGEB("C[%d] D[%d] E[%d]", mFramesWithDucati, mFramesWithDisplay, mFramesWithEncoder); - - recalculateFPS(); - - createPreviewMetadata(pBuffHeader, metadataResult, pPortParam->mWidth, pPortParam->mHeight); - if ( NULL != metadataResult.get() ) { - notifyMetadataSubscribers(metadataResult); - metadataResult.clear(); - } - - { - android::AutoMutex lock(mFaceDetectionLock); - if ( mFDSwitchAlgoPriority ) { - - //Disable region priority and enable face priority for AF - setAlgoPriority(REGION_PRIORITY, FOCUS_ALGO, false); - setAlgoPriority(FACE_PRIORITY, FOCUS_ALGO , true); - - //Disable Region priority and enable Face priority - setAlgoPriority(REGION_PRIORITY, EXPOSURE_ALGO, false); - setAlgoPriority(FACE_PRIORITY, EXPOSURE_ALGO, true); - mFDSwitchAlgoPriority = false; - } - } - -#ifndef OMAP_TUNA - sniffDccFileDataSave(pBuffHeader); -#endif - - stat |= advanceZoom(); - - // On the fly update to 3A settings not working - // Do not update 3A here if we are in the middle of a capture - // or in the middle of transitioning to it - if( mPending3Asettings && - ( (nextState & CAPTURE_ACTIVE) == 0 ) && - ( (state & CAPTURE_ACTIVE) == 0 ) ) { - apply3Asettings(mParameters3A); - } - - } - else if( pBuffHeader->nOutputPortIndex == OMX_CAMERA_PORT_VIDEO_OUT_MEASUREMENT ) - { - typeOfFrame = CameraFrame::FRAME_DATA_SYNC; - mask = (unsigned int)CameraFrame::FRAME_DATA_SYNC; - - stat = sendCallBacks(cameraFrame, pBuffHeader, mask, pPortParam); - } - else if( pBuffHeader->nOutputPortIndex == OMX_CAMERA_PORT_IMAGE_OUT_IMAGE ) - { - OMX_COLOR_FORMATTYPE pixFormat; - const char *valstr = NULL; - - pixFormat = pPortParam->mColorFormat; - - if ( OMX_COLOR_FormatUnused == pixFormat ) - { - typeOfFrame = CameraFrame::IMAGE_FRAME; - mask = (unsigned int) CameraFrame::IMAGE_FRAME; - } else if ( pixFormat == OMX_COLOR_FormatCbYCrY && - ((mPictureFormatFromClient && - !strcmp(mPictureFormatFromClient, - android::CameraParameters::PIXEL_FORMAT_JPEG)) || - !mPictureFormatFromClient) ) { - // signals to callbacks that this needs to be coverted to jpeg - // before returning to framework - typeOfFrame = CameraFrame::IMAGE_FRAME; - mask = (unsigned int) CameraFrame::IMAGE_FRAME; - cameraFrame.mQuirks |= CameraFrame::ENCODE_RAW_YUV422I_TO_JPEG; - cameraFrame.mQuirks |= CameraFrame::FORMAT_YUV422I_UYVY; - - // populate exif data and pass to subscribers via quirk - // subscriber is in charge of freeing exif data - ExifElementsTable* exif = new ExifElementsTable(); - setupEXIF_libjpeg(exif, mCaptureAncillaryData, mWhiteBalanceData); - cameraFrame.mQuirks |= CameraFrame::HAS_EXIF_DATA; - cameraFrame.mCookie2 = (void*) exif; - } else { - typeOfFrame = CameraFrame::RAW_FRAME; - mask = (unsigned int) CameraFrame::RAW_FRAME; - } - - pPortParam->mImageType = typeOfFrame; - - if((mCapturedFrames>0) && !mCaptureSignalled) - { - mCaptureSignalled = true; - mCaptureSem.Signal(); - } - - if( ( CAPTURE_ACTIVE & state ) != CAPTURE_ACTIVE ) - { - goto EXIT; - } - - { - android::AutoMutex lock(mBracketingLock); - if ( mBracketingEnabled ) - { - doBracketing(pBuffHeader, typeOfFrame); - return eError; - } - } - - if (mZoomBracketingEnabled) { - doZoom(mZoomBracketingValues[mCurrentZoomBracketing]); - CAMHAL_LOGDB("Current Zoom Bracketing: %d", mZoomBracketingValues[mCurrentZoomBracketing]); - mCurrentZoomBracketing++; - if (mCurrentZoomBracketing == ARRAY_SIZE(mZoomBracketingValues)) { - mZoomBracketingEnabled = false; - } - } - - if ( 1 > mCapturedFrames ) - { - goto EXIT; - } - -#ifdef OMAP_ENHANCEMENT_CPCAM - if ( NULL != mSharedAllocator ) { - cameraFrame.mMetaData = new CameraMetadataResult(getMetaData(pBuffHeader->pPlatformPrivate, mSharedAllocator)); - } -#endif - - CAMHAL_LOGDB("Captured Frames: %d", mCapturedFrames); - - mCapturedFrames--; - -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING - if (mYuvCapture) { - struct timeval timeStampUsec; - gettimeofday(&timeStampUsec, NULL); - - time_t saveTime; - time(&saveTime); - const struct tm * const timeStamp = gmtime(&saveTime); - - char filename[256]; - snprintf(filename,256, "%s/yuv_%d_%d_%d_%lu.yuv", - kYuvImagesOutputDirPath, - timeStamp->tm_hour, - timeStamp->tm_min, - timeStamp->tm_sec, - timeStampUsec.tv_usec); - - const status_t saveBufferStatus = saveBufferToFile(((CameraBuffer*)pBuffHeader->pAppPrivate)->mapped, - pBuffHeader->nFilledLen, filename); - - if (saveBufferStatus != OK) { - CAMHAL_LOGE("ERROR: %d, while saving yuv!", saveBufferStatus); - } else { - CAMHAL_LOGD("yuv_%d_%d_%d_%lu.yuv successfully saved in %s", - timeStamp->tm_hour, - timeStamp->tm_min, - timeStamp->tm_sec, - timeStampUsec.tv_usec, - kYuvImagesOutputDirPath); - } - } -#endif - - stat = sendCallBacks(cameraFrame, pBuffHeader, mask, pPortParam); -#ifdef OMAP_ENHANCEMENT_CPCAM - if ( NULL != cameraFrame.mMetaData.get() ) { - cameraFrame.mMetaData.clear(); - } -#endif - - } - else if (pBuffHeader->nOutputPortIndex == OMX_CAMERA_PORT_VIDEO_OUT_VIDEO) { - typeOfFrame = CameraFrame::RAW_FRAME; - pPortParam->mImageType = typeOfFrame; - { - android::AutoMutex lock(mLock); - if( ( CAPTURE_ACTIVE & state ) != CAPTURE_ACTIVE ) { - goto EXIT; - } - } - - CAMHAL_LOGD("RAW buffer done on video port, length = %d", pBuffHeader->nFilledLen); - - mask = (unsigned int) CameraFrame::RAW_FRAME; - -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING - if ( mRawCapture ) { - struct timeval timeStampUsec; - gettimeofday(&timeStampUsec, NULL); - - time_t saveTime; - time(&saveTime); - const struct tm * const timeStamp = gmtime(&saveTime); - - char filename[256]; - snprintf(filename,256, "%s/raw_%d_%d_%d_%lu.raw", - kRawImagesOutputDirPath, - timeStamp->tm_hour, - timeStamp->tm_min, - timeStamp->tm_sec, - timeStampUsec.tv_usec); - - const status_t saveBufferStatus = saveBufferToFile( ((CameraBuffer*)pBuffHeader->pAppPrivate)->mapped, - pBuffHeader->nFilledLen, filename); - - if (saveBufferStatus != OK) { - CAMHAL_LOGE("ERROR: %d , while saving raw!", saveBufferStatus); - } else { - CAMHAL_LOGD("raw_%d_%d_%d_%lu.raw successfully saved in %s", - timeStamp->tm_hour, - timeStamp->tm_min, - timeStamp->tm_sec, - timeStampUsec.tv_usec, - kRawImagesOutputDirPath); - stat = sendCallBacks(cameraFrame, pBuffHeader, mask, pPortParam); - } - } -#endif - } else { - CAMHAL_LOGEA("Frame received for non-(preview/capture/measure) port. This is yet to be supported"); - goto EXIT; - } - - if ( NO_ERROR != stat ) - { - CameraBuffer *camera_buffer; - - camera_buffer = (CameraBuffer *)pBuffHeader->pAppPrivate; - - CAMHAL_LOGDB("sendFrameToSubscribers error: %d", stat); - returnFrame(camera_buffer, typeOfFrame); - } - - return eError; - - EXIT: - - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, stat, eError); - - if ( NO_ERROR != stat ) - { - if ( NULL != mErrorNotifier ) - { - mErrorNotifier->errorNotify(CAMERA_ERROR_UNKNOWN); - } - } - - return eError; -} - -status_t OMXCameraAdapter::recalculateFPS() -{ - float currentFPS; - - { - android::AutoMutex lock(mFrameCountMutex); - mFrameCount++; - if (mFrameCount == 1) { - mFirstFrameCondition.broadcast(); - } - } - - if ( ( mFrameCount % FPS_PERIOD ) == 0 ) - { - nsecs_t now = systemTime(); - nsecs_t diff = now - mLastFPSTime; - currentFPS = ((mFrameCount - mLastFrameCount) * float(s2ns(1))) / diff; - mLastFPSTime = now; - mLastFrameCount = mFrameCount; - - if ( 1 == mIter ) - { - mFPS = currentFPS; - } - else - { - //cumulative moving average - mFPS = mLastFPS + (currentFPS - mLastFPS)/mIter; - } - - mLastFPS = mFPS; - mIter++; - } - - return NO_ERROR; -} - -status_t OMXCameraAdapter::sendCallBacks(CameraFrame frame, OMX_IN OMX_BUFFERHEADERTYPE *pBuffHeader, unsigned int mask, OMXCameraPortParameters *port) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( NULL == port) - { - CAMHAL_LOGEA("Invalid portParam"); - return -EINVAL; - } - - if ( NULL == pBuffHeader ) - { - CAMHAL_LOGEA("Invalid Buffer header"); - return -EINVAL; - } - - android::AutoMutex lock(mSubscriberLock); - - //frame.mFrameType = typeOfFrame; - frame.mFrameMask = mask; - frame.mBuffer = (CameraBuffer *)pBuffHeader->pAppPrivate; - frame.mLength = pBuffHeader->nFilledLen; - frame.mAlignment = port->mStride; - frame.mOffset = pBuffHeader->nOffset; - frame.mWidth = port->mWidth; - frame.mHeight = port->mHeight; - frame.mYuv[0] = 0; //NULL; - frame.mYuv[1] = 0; //NULL; - - if ( onlyOnce && mRecording ) - { - mTimeSourceDelta = (pBuffHeader->nTimeStamp * 1000) - systemTime(SYSTEM_TIME_MONOTONIC); - onlyOnce = false; - } - - frame.mTimestamp = (pBuffHeader->nTimeStamp * 1000) - mTimeSourceDelta; - - ret = setInitFrameRefCount(frame.mBuffer, mask); - - if (ret != NO_ERROR) { - CAMHAL_LOGDB("Error in setInitFrameRefCount %d", ret); - } else { - ret = sendFrameToSubscribers(&frame); - } - - CAMHAL_LOGSVB("B 0x%x T %llu", frame.mBuffer, pBuffHeader->nTimeStamp); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -bool OMXCameraAdapter::CommandHandler::Handler() -{ - Utils::Message msg; - volatile int forever = 1; - status_t stat; - ErrorNotifier *errorNotify = NULL; - - LOG_FUNCTION_NAME; - - while ( forever ) - { - stat = NO_ERROR; - CAMHAL_LOGDA("Handler: waiting for messsage..."); - Utils::MessageQueue::waitForMsg(&mCommandMsgQ, NULL, NULL, -1); - { - android::AutoMutex lock(mLock); - mCommandMsgQ.get(&msg); - } - CAMHAL_LOGDB("msg.command = %d", msg.command); - switch ( msg.command ) { - case CommandHandler::CAMERA_START_IMAGE_CAPTURE: - { - OMXCameraAdapter::CachedCaptureParameters* cap_params = - static_cast(msg.arg2); - stat = mCameraAdapter->startImageCapture(false, cap_params); - delete cap_params; - break; - } - case CommandHandler::CAMERA_PERFORM_AUTOFOCUS: - { - stat = mCameraAdapter->doAutoFocus(); - break; - } - case CommandHandler::COMMAND_EXIT: - { - CAMHAL_LOGDA("Exiting command handler"); - forever = 0; - break; - } - case CommandHandler::CAMERA_SWITCH_TO_EXECUTING: - { - stat = mCameraAdapter->doSwitchToExecuting(); - break; - } - case CommandHandler::CAMERA_START_REPROCESS: - { - OMXCameraAdapter::CachedCaptureParameters* cap_params = - static_cast(msg.arg2); - stat = mCameraAdapter->startReprocess(); - stat = mCameraAdapter->startImageCapture(false, cap_params); - delete cap_params; - break; - } - } - - } - - LOG_FUNCTION_NAME_EXIT; - - return false; -} - -bool OMXCameraAdapter::OMXCallbackHandler::Handler() -{ - Utils::Message msg; - volatile int forever = 1; - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - while(forever){ - Utils::MessageQueue::waitForMsg(&mCommandMsgQ, NULL, NULL, -1); - { - android::AutoMutex lock(mLock); - mCommandMsgQ.get(&msg); - mIsProcessed = false; - } - - switch ( msg.command ) { - case OMXCallbackHandler::CAMERA_FILL_BUFFER_DONE: - { - ret = mCameraAdapter->OMXCameraAdapterFillBufferDone(( OMX_HANDLETYPE ) msg.arg1, - ( OMX_BUFFERHEADERTYPE *) msg.arg2); - break; - } - case OMXCallbackHandler::CAMERA_FOCUS_STATUS: - { - mCameraAdapter->handleFocusCallback(); - break; - } - case CommandHandler::COMMAND_EXIT: - { - CAMHAL_LOGDA("Exiting OMX callback handler"); - forever = 0; - break; - } - } - - { - android::AutoMutex locker(mLock); - CAMHAL_UNUSED(locker); - - mIsProcessed = mCommandMsgQ.isEmpty(); - if ( mIsProcessed ) - mCondition.signal(); - } - } - - // force the condition to wake - { - android::AutoMutex locker(mLock); - CAMHAL_UNUSED(locker); - - mIsProcessed = true; - mCondition.signal(); - } - - LOG_FUNCTION_NAME_EXIT; - return false; -} - -void OMXCameraAdapter::OMXCallbackHandler::flush() -{ - LOG_FUNCTION_NAME; - - android::AutoMutex locker(mLock); - CAMHAL_UNUSED(locker); - - if ( mIsProcessed ) - return; - - mCondition.wait(mLock); -} - -status_t OMXCameraAdapter::setExtraData(bool enable, OMX_U32 nPortIndex, OMX_EXT_EXTRADATATYPE eType) { - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_EXTRADATATYPE extraDataControl; - - LOG_FUNCTION_NAME; - - if ( ( OMX_StateInvalid == mComponentState ) || - ( NULL == mCameraAdapterParameters.mHandleComp ) ) { - CAMHAL_LOGEA("OMX component is in invalid state"); - return -EINVAL; - } - - OMX_INIT_STRUCT_PTR (&extraDataControl, OMX_CONFIG_EXTRADATATYPE); - - extraDataControl.nPortIndex = nPortIndex; - extraDataControl.eExtraDataType = eType; -#ifdef OMAP_TUNA - extraDataControl.eCameraView = OMX_2D; -#endif - - if (enable) { - extraDataControl.bEnable = OMX_TRUE; - } else { - extraDataControl.bEnable = OMX_FALSE; - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_IndexConfigOtherExtraDataControl, - &extraDataControl); - - LOG_FUNCTION_NAME_EXIT; - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -OMX_OTHER_EXTRADATATYPE *OMXCameraAdapter::getExtradata(const OMX_PTR ptrPrivate, OMX_EXTRADATATYPE type) const -{ - if ( NULL != ptrPrivate ) { - const OMX_TI_PLATFORMPRIVATE *platformPrivate = (const OMX_TI_PLATFORMPRIVATE *) ptrPrivate; - - CAMHAL_LOGSVB("Size = %d, sizeof = %d, pAuxBuf = 0x%x, pAuxBufSize= %d, pMetaDataBufer = 0x%x, nMetaDataSize = %d", - platformPrivate->nSize, - sizeof(OMX_TI_PLATFORMPRIVATE), - platformPrivate->pAuxBuf1, - platformPrivate->pAuxBufSize1, - platformPrivate->pMetaDataBuffer, - platformPrivate->nMetaDataSize); - if ( sizeof(OMX_TI_PLATFORMPRIVATE) == platformPrivate->nSize ) { - if ( 0 < platformPrivate->nMetaDataSize ) { - OMX_U32 remainingSize = platformPrivate->nMetaDataSize; - OMX_OTHER_EXTRADATATYPE *extraData = (OMX_OTHER_EXTRADATATYPE *) platformPrivate->pMetaDataBuffer; - if ( NULL != extraData ) { - while ( extraData->eType && extraData->nDataSize && extraData->data && - (remainingSize >= extraData->nSize)) { - if ( type == extraData->eType ) { - return extraData; - } - remainingSize -= extraData->nSize; - extraData = (OMX_OTHER_EXTRADATATYPE*) ((char*)extraData + extraData->nSize); - } - } else { - CAMHAL_LOGEB("OMX_TI_PLATFORMPRIVATE pMetaDataBuffer is NULL"); - } - } else { - CAMHAL_LOGEB("OMX_TI_PLATFORMPRIVATE nMetaDataSize is size is %d", - ( unsigned int ) platformPrivate->nMetaDataSize); - } - } else { - CAMHAL_LOGEB("OMX_TI_PLATFORMPRIVATE size mismatch: expected = %d, received = %d", - ( unsigned int ) sizeof(OMX_TI_PLATFORMPRIVATE), - ( unsigned int ) platformPrivate->nSize); - } - } else { - CAMHAL_LOGEA("Invalid OMX_TI_PLATFORMPRIVATE"); - } - - // Required extradata type wasn't found - return NULL; -} - -OMXCameraAdapter::CachedCaptureParameters* OMXCameraAdapter::cacheCaptureParameters() { - CachedCaptureParameters* params = new CachedCaptureParameters(); - - params->mPendingCaptureSettings = mPendingCaptureSettings; - params->mPictureRotation = mPictureRotation; - memcpy(params->mExposureBracketingValues, - mExposureBracketingValues, - sizeof(mExposureBracketingValues)); - memcpy(params->mExposureGainBracketingValues, - mExposureGainBracketingValues, - sizeof(mExposureGainBracketingValues)); - memcpy(params->mExposureGainBracketingModes, - mExposureGainBracketingModes, - sizeof(mExposureGainBracketingModes)); - params->mExposureBracketingValidEntries = mExposureBracketingValidEntries; - params->mExposureBracketMode = mExposureBracketMode; - params->mBurstFrames = mBurstFrames; - params->mFlushShotConfigQueue = mFlushShotConfigQueue; - - return params; -} - -OMXCameraAdapter::OMXCameraAdapter(size_t sensor_index) -{ - LOG_FUNCTION_NAME; - - mOmxInitialized = false; - mComponentState = OMX_StateInvalid; - mSensorIndex = sensor_index; - mPictureRotation = 0; - // Initial values - mTimeSourceDelta = 0; - onlyOnce = true; -#ifndef OMAP_TUNA - mDccData.pData = NULL; -#endif - - mInitSem.Create(0); - mFlushSem.Create(0); - mUsePreviewDataSem.Create(0); - mUsePreviewSem.Create(0); - mUseCaptureSem.Create(0); - mUseReprocessSem.Create(0); - mStartPreviewSem.Create(0); - mStopPreviewSem.Create(0); - mStartCaptureSem.Create(0); - mStopCaptureSem.Create(0); - mStopReprocSem.Create(0); - mSwitchToLoadedSem.Create(0); - mCaptureSem.Create(0); - - mSwitchToExecSem.Create(0); - - mCameraAdapterParameters.mHandleComp = 0; - - mUserSetExpLock = OMX_FALSE; - mUserSetWbLock = OMX_FALSE; - - mFramesWithDucati = 0; - mFramesWithDisplay = 0; - mFramesWithEncoder = 0; - -#ifdef CAMERAHAL_OMX_PROFILING - - mDebugProfile = 0; - -#endif - - mPreviewPortInitialized = false; - - LOG_FUNCTION_NAME_EXIT; -} - -OMXCameraAdapter::~OMXCameraAdapter() -{ - LOG_FUNCTION_NAME; - - android::AutoMutex lock(gAdapterLock); - - if ( mOmxInitialized ) { - // return to OMX Loaded state - switchToLoaded(); - -#ifndef OMAP_TUNA - saveDccFileDataSave(); - - closeDccFileDataSave(); -#endif - // deinit the OMX - if ( mComponentState == OMX_StateLoaded || mComponentState == OMX_StateInvalid ) { - // free the handle for the Camera component - if ( mCameraAdapterParameters.mHandleComp ) { - OMX_FreeHandle(mCameraAdapterParameters.mHandleComp); - mCameraAdapterParameters.mHandleComp = NULL; - } - } - - OMX_Deinit(); - mOmxInitialized = false; - } - - //Remove any unhandled events - if ( !mEventSignalQ.isEmpty() ) - { - for (unsigned int i = 0 ; i < mEventSignalQ.size() ; i++ ) - { - Utils::Message *msg = mEventSignalQ.itemAt(i); - //remove from queue and free msg - if ( NULL != msg ) - { - Utils::Semaphore *sem = (Utils::Semaphore*) msg->arg3; - sem->Signal(); - free(msg); - - } - } - mEventSignalQ.clear(); - } - - //Exit and free ref to command handling thread - if ( NULL != mCommandHandler.get() ) - { - Utils::Message msg; - msg.command = CommandHandler::COMMAND_EXIT; - msg.arg1 = mErrorNotifier; - mCommandHandler->clearCommandQ(); - mCommandHandler->put(&msg); - mCommandHandler->requestExitAndWait(); - mCommandHandler.clear(); - } - - //Exit and free ref to callback handling thread - if ( NULL != mOMXCallbackHandler.get() ) - { - Utils::Message msg; - msg.command = OMXCallbackHandler::COMMAND_EXIT; - //Clear all messages pending first - mOMXCallbackHandler->clearCommandQ(); - mOMXCallbackHandler->put(&msg); - mOMXCallbackHandler->requestExitAndWait(); - mOMXCallbackHandler.clear(); - } - - LOG_FUNCTION_NAME_EXIT; -} - -extern "C" CameraAdapter* OMXCameraAdapter_Factory(size_t sensor_index) -{ - CameraAdapter *adapter = NULL; - android::AutoMutex lock(gAdapterLock); - - LOG_FUNCTION_NAME; - - adapter = new OMXCameraAdapter(sensor_index); - if ( adapter ) { - CAMHAL_LOGDB("New OMX Camera adapter instance created for sensor %d",sensor_index); - } else { - CAMHAL_LOGEA("OMX Camera adapter create failed for sensor index = %d!",sensor_index); - } - - LOG_FUNCTION_NAME_EXIT; - - return adapter; -} - -OMX_ERRORTYPE OMXCameraAdapter::OMXCameraGetHandle(OMX_HANDLETYPE *handle, OMX_PTR pAppData, - const OMX_CALLBACKTYPE & callbacks) -{ - OMX_ERRORTYPE eError = OMX_ErrorUndefined; - - for ( int i = 0; i < 5; ++i ) { - if ( i > 0 ) { - // sleep for 100 ms before next attempt - usleep(100000); - } - - // setup key parameters to send to Ducati during init - OMX_CALLBACKTYPE oCallbacks = callbacks; - - // get handle - eError = OMX_GetHandle(handle, (OMX_STRING)"OMX.TI.DUCATI1.VIDEO.CAMERA", pAppData, &oCallbacks); - if ( eError == OMX_ErrorNone ) { - return OMX_ErrorNone; - } - - CAMHAL_LOGEB("OMX_GetHandle() failed, error: 0x%x", eError); - } - - *handle = 0; - return eError; -} - - -class CapabilitiesHandler -{ -public: - CapabilitiesHandler() - { - mComponent = 0; - mIsAborted = true; - } - - const OMX_HANDLETYPE & component() const - { - return mComponent; - } - - OMX_HANDLETYPE & componentRef() - { - return mComponent; - } - - status_t disableAllPorts() - { - android::AutoMutex locker(mLock); - CAMHAL_UNUSED(locker); - - mPortsLeftToDisable = OMX_CAMERA_NUM_PORTS; - mIsOk = false; - mIsAborted = false; - - CAMHAL_LOGD("Disabling ports..."); - const OMX_ERRORTYPE sendCommandError = OMX_SendCommand(component(), - OMX_CommandPortDisable, OMX_ALL, 0); - CAMHAL_LOGD("Disabling ports... DONE"); - - if ( sendCommandError != OMX_ErrorNone ) - { - CAMHAL_LOGE("Failed disabling all ports, error: 0x%x", sendCommandError); - return Utils::ErrorUtils::omxToAndroidError(sendCommandError); - } - - CAMHAL_LOGD("Waiting for disabling all ports will be finished..."); - const status_t waitStatus = mCondition.waitRelative(mLock, seconds_to_nanoseconds(3)); - CAMHAL_LOGD("Waiting for disabling all ports will be finished... DONE"); - - if ( waitStatus != NO_ERROR ) - { - CAMHAL_LOGE("Timeout triggered while waiting for all ports to be disabled"); - return TIMED_OUT; - } - - if ( !mIsOk ) - { - CAMHAL_LOGE("Failed to disable all ports"); - return UNKNOWN_ERROR; - } - - // all ports have been disabled - mIsAborted = true; - - return NO_ERROR; - } - - status_t switchToState(OMX_STATETYPE state) - { - CAMHAL_LOGSV("."); - android::AutoMutex locker(mLock); - CAMHAL_UNUSED(locker); - CAMHAL_LOGSV("."); - - mState = state; - mIsOk = false; - mIsAborted = false; - - CAMHAL_LOGD("Switching to state 0x%x...", mState); - const OMX_ERRORTYPE switchError = OMX_SendCommand(mComponent, - OMX_CommandStateSet, mState, 0); - CAMHAL_LOGD("Switching to state 0x%x... DONE", mState); - - if ( switchError != OMX_ErrorNone ) - { - CAMHAL_LOGE("Failed switching to state 0x%x, error: 0x%x", mState, switchError); - return Utils::ErrorUtils::omxToAndroidError(switchError); - } - - // wait for the event for 3 seconds - CAMHAL_LOGD("Waiting..."); - const status_t waitStatus = mCondition.waitRelative(mLock, seconds_to_nanoseconds(3)); - CAMHAL_LOGD("Waiting... DONE"); - - // disable following events - mIsAborted = true; - - if ( waitStatus != NO_ERROR ) - { - CAMHAL_LOGE("Timeout triggered while switching to state 0x%x", mState); - return TIMED_OUT; - } - - // state has been switched, check whether is was Idle - if ( !mIsOk ) - { - CAMHAL_LOGE("Switching to state 0x%x has failed", mState); - return UNKNOWN_ERROR; - } - - return NO_ERROR; - } - - status_t fetchCapabiltiesForMode(OMX_CAMOPERATINGMODETYPE mode, - int sensorId, - CameraProperties::Properties * properties) - { - OMX_CONFIG_CAMOPERATINGMODETYPE camMode; - - OMX_INIT_STRUCT_PTR (&camMode, OMX_CONFIG_CAMOPERATINGMODETYPE); - camMode.eCamOperatingMode = mode; - - OMX_ERRORTYPE eError = OMX_SetParameter(component(), - ( OMX_INDEXTYPE ) OMX_IndexCameraOperatingMode, - &camMode); - - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGE("Error while configuring camera mode in CameraAdapter_Capabilities 0x%x", eError); - return BAD_VALUE; - } - - const status_t idleSwitchError = switchToState(OMX_StateIdle); - if ( idleSwitchError != NO_ERROR ) { - CAMHAL_LOGE("Failed to switch to Idle state, error: %d", idleSwitchError); - return UNKNOWN_ERROR; - } - - // get and fill capabilities - OMXCameraAdapter::getCaps(sensorId, properties, component()); - - const status_t loadedSwitchError = switchToState(OMX_StateLoaded); - if ( loadedSwitchError != NO_ERROR ) { - CAMHAL_LOGE("Failed to switch to Loaded state, error: %d", loadedSwitchError); - return UNKNOWN_ERROR; - } - - return NO_ERROR; - } - - status_t fetchCapabilitiesForSensor(int sensorId, - CameraProperties::Properties * properties) - { - CAMHAL_LOGD("Disabling all ports..."); - const status_t disableAllPortsError = disableAllPorts(); - CAMHAL_LOGD("Disabling all ports... DONE"); - - if ( disableAllPortsError != NO_ERROR ) { - CAMHAL_LOGE("Failed to disable all ports, error: %d", - disableAllPortsError); - return UNKNOWN_ERROR; - } - - // sensor select - OMX_CONFIG_SENSORSELECTTYPE sensorSelect; - OMX_INIT_STRUCT_PTR (&sensorSelect, OMX_CONFIG_SENSORSELECTTYPE); - sensorSelect.eSensor = (OMX_SENSORSELECT)sensorId; - - CAMHAL_LOGD("Selecting sensor %d...", sensorId); - const OMX_ERRORTYPE sensorSelectError = OMX_SetConfig(component(), - (OMX_INDEXTYPE)OMX_TI_IndexConfigSensorSelect, &sensorSelect); - CAMHAL_LOGD("Selecting sensor %d... DONE", sensorId); - - if ( sensorSelectError != OMX_ErrorNone ) { - CAMHAL_LOGD("Max supported sensor number reached: %d", sensorId); - return BAD_VALUE; - } - - status_t err = NO_ERROR; -#ifndef OMAP_TUNA - if ( sensorId == 2 ) { - CAMHAL_LOGD("Camera mode: STEREO"); - properties->setMode(MODE_STEREO); - err = fetchCapabiltiesForMode(OMX_CaptureStereoImageCapture, - sensorId, - properties); - } else { -#endif - CAMHAL_LOGD("Camera MONO"); - - CAMHAL_LOGD("Camera mode: HQ "); - properties->setMode(MODE_HIGH_QUALITY); - err = fetchCapabiltiesForMode(OMX_CaptureImageProfileBase, - sensorId, - properties); - if ( NO_ERROR != err ) { - return err; - } - - CAMHAL_LOGD("Camera mode: VIDEO "); - properties->setMode(MODE_VIDEO); - err = fetchCapabiltiesForMode(OMX_CaptureVideo, - sensorId, - properties); - if ( NO_ERROR != err ) { - return err; - } - - CAMHAL_LOGD("Camera mode: ZSL "); - properties->setMode(MODE_ZEROSHUTTERLAG); - err = fetchCapabiltiesForMode(OMX_TI_CaptureImageProfileZeroShutterLag, - sensorId, - properties); - if ( NO_ERROR != err ) { - return err; - } - - CAMHAL_LOGD("Camera mode: HS "); - properties->setMode(MODE_HIGH_SPEED); - err = fetchCapabiltiesForMode(OMX_CaptureImageHighSpeedTemporalBracketing, - sensorId, - properties); - if ( NO_ERROR != err ) { - return err; - } - -#ifndef OMAP_TUNA - CAMHAL_LOGD("Camera mode: CPCAM "); - properties->setMode(MODE_CPCAM); - err = fetchCapabiltiesForMode(OMX_TI_CPCam, - sensorId, - properties); - if ( NO_ERROR != err ) { - return err; - } - - } -#endif - - return err; - } - -public: - static OMX_ERRORTYPE eventCallback(const OMX_HANDLETYPE component, - const OMX_PTR cookie, const OMX_EVENTTYPE event, const OMX_U32 data1, const OMX_U32 data2, - const OMX_PTR pEventData) - { - LOG_FUNCTION_NAME; - - CAMHAL_UNUSED(pEventData); - - CAMHAL_LOGD("event = 0x%x", event); - CAMHAL_LOGD("data1 = 0x%x", data1); - CAMHAL_LOGD("data2 = 0x%x", data2); - - CapabilitiesHandler * handler = reinterpret_cast(cookie); - - // ensure this is out component - if ( handler->component() != component ) - { - CAMHAL_LOGE("Wrong component handle received: %p, expecting: %p", - component, handler->component()); - return OMX_ErrorBadParameter; - } - - return handler->processEvent(event, data1, data2); - } - - OMX_ERRORTYPE processEvent(const OMX_EVENTTYPE event, const OMX_U32 data1, const OMX_U32 data2) - { - android::AutoMutex locker(mLock); - CAMHAL_UNUSED(locker); - - if ( mIsAborted ) - { - CAMHAL_LOGE("Waiting for state switch has been aborted"); - return OMX_ErrorNone; - } - - switch ( event ) - { - case OMX_EventCmdComplete: - switch ( data1 ) - { - case OMX_CommandStateSet: - // this is our state switch command we are waiting for - mIsOk = static_cast(data2) == mState; - - // wake up the caller - CAMHAL_LOGD("Waking the condition..."); - mCondition.signal(); - CAMHAL_LOGD("Waking the condition... DONE"); - break; - - case OMX_CommandPortDisable: - CAMHAL_LOGD("Decreasing disabled port count: %d", mPortsLeftToDisable); - mPortsLeftToDisable--; - if ( mPortsLeftToDisable == 0 ) - { - CAMHAL_LOGD("All ports have been disabled, waking the caller..."); - mIsOk = true; - mCondition.signal(); - CAMHAL_LOGD("All ports have been disabled, waking the caller... DONE"); - } - break; - - default: - // ignore rest of the commands - break; - } - break; - - case OMX_EventError: - CAMHAL_LOGE("Error event received, data1 = 0x%8x, data2 = 0x%8x", data1, data2); - - // keep mIsOk in false state, indicating that request has failed - - CAMHAL_LOGD("Waking the condition..."); - mCondition.signal(); - CAMHAL_LOGD("Waking the condition... DONE"); - break; - - default: - // ignore rest of the event types - break; - } - - return OMX_ErrorNone; - } - -private: - android::Mutex mLock; - android::Condition mCondition; - OMX_HANDLETYPE mComponent; - OMX_STATETYPE mState; - bool mIsAborted; - bool mIsOk; - int mPortsLeftToDisable; -}; - -extern "C" status_t OMXCameraAdapter_Capabilities( - CameraProperties::Properties * const properties_array, - const int starting_camera, const int max_camera, int & supportedCameras) -{ - LOG_FUNCTION_NAME; - - supportedCameras = 0; - - int num_cameras_supported = 0; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - android::AutoMutex lock(gAdapterLock); - - if (!properties_array) { - CAMHAL_LOGEB("invalid param: properties = 0x%p", properties_array); - LOG_FUNCTION_NAME_EXIT; - return BAD_VALUE; - } - - eError = OMX_Init(); - if (eError != OMX_ErrorNone) { - CAMHAL_LOGEB("Error OMX_Init -0x%x", eError); - return Utils::ErrorUtils::omxToAndroidError(eError); - } - - // Continue selecting sensor and then querying OMX Camera for it's capabilities - // When sensor select returns an error, we know to break and stop - while (eError == OMX_ErrorNone && - (starting_camera + num_cameras_supported) < max_camera) { - - CapabilitiesHandler handler; - - OMX_CALLBACKTYPE callbacks; - callbacks.EventHandler = CapabilitiesHandler::eventCallback; - callbacks.EmptyBufferDone = 0; - callbacks.FillBufferDone = 0; - - eError = OMXCameraAdapter::OMXCameraGetHandle(&handler.componentRef(), &handler, callbacks); - if (eError != OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_GetHandle -0x%x", eError); - goto EXIT; - } - - const int sensorId = num_cameras_supported; - CameraProperties::Properties * properties = properties_array + starting_camera + sensorId; - const status_t err = handler.fetchCapabilitiesForSensor(sensorId, properties); - - // clean up - if(handler.component()) { - CAMHAL_LOGD("Freeing the component..."); - OMX_FreeHandle(handler.component()); - CAMHAL_LOGD("Freeing the component... DONE"); - handler.componentRef() = NULL; - } - - if ( err != NO_ERROR ) - break; - - num_cameras_supported++; - CAMHAL_LOGDB("Number of OMX Cameras detected = %d \n",num_cameras_supported); - } - - EXIT: - CAMHAL_LOGD("Deinit..."); - OMX_Deinit(); - CAMHAL_LOGD("Deinit... DONE"); - - if ( eError != OMX_ErrorNone ) - { - CAMHAL_LOGE("Error: 0x%x", eError); - LOG_FUNCTION_NAME_EXIT; - return Utils::ErrorUtils::omxToAndroidError(eError); - } - - supportedCameras = num_cameras_supported; - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -} // namespace Camera -} // namespace Ti - - -/*--------------------Camera Adapter Class ENDS here-----------------------------*/ - diff --git a/camera/OMXCameraAdapter/OMXCapabilities.cpp b/camera/OMXCameraAdapter/OMXCapabilities.cpp deleted file mode 100644 index 20e366a..0000000 --- a/camera/OMXCameraAdapter/OMXCapabilities.cpp +++ /dev/null @@ -1,2647 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMXCap.cpp -* -* This file implements the OMX Capabilities feature. -* -*/ - -#include "CameraHal.h" -#include "OMXCameraAdapter.h" -#include "ErrorUtils.h" -#include "TICameraParameters.h" - -namespace Ti { -namespace Camera { - -/************************************ - * global constants and variables - *************************************/ - -#define ARRAY_SIZE(array) (sizeof((array)) / sizeof((array)[0])) - -static const char PARAM_SEP[] = ","; -static const uint32_t VFR_OFFSET = 8; -static const char FPS_STR_MAX_LEN = 10; - -static const unsigned int MANUAL_EXPOSURE_STEP = 1; -static const unsigned int MANUAL_GAIN_ISO_MIN = 100; -static const unsigned int MANUAL_GAIN_ISO_STEP = 100; - -const int OMXCameraAdapter::SENSORID_IMX060 = 300; -const int OMXCameraAdapter::SENSORID_OV5650 = 301; -const int OMXCameraAdapter::SENSORID_OV5640 = 302; -const int OMXCameraAdapter::SENSORID_OV14825 = 304; -const int OMXCameraAdapter::SENSORID_S5K4E1GA = 305; -const int OMXCameraAdapter::SENSORID_S5K6A1GX03 = 306; - -const int OMXCameraAdapter::FPS_MIN = 5; -const int OMXCameraAdapter::FPS_MAX = 30; -const int OMXCameraAdapter::FPS_MAX_EXTENDED = 60; - -inline static int androidFromDucatiFrameRate(OMX_U32 frameRate) { - return (frameRate >> VFR_OFFSET) * CameraHal::VFR_SCALE; -} - -/**** look up tables to translate OMX Caps to Parameter ****/ - -const CapResolution OMXCameraAdapter::mImageCapRes [] = { - { 4416, 3312, "4416x3312" }, - { 4032, 3024, "4032x3024" }, - { 4000, 3000, "4000x3000" }, - { 3648, 2736, "3648x2736" }, - { 3264, 2448, "3264x2448" }, - { 2608, 1960, "2608x1960" }, - { 2592, 1944, "2592x1944" }, - { 2592, 1728, "2592x1728" }, - { 2592, 1458, "2592x1458" }, - { 2304, 1296, "2304x1296" }, - { 2240, 1344, "2240x1344" }, - { 2160, 1440, "2160x1440" }, - { 2112, 1728, "2112x1728" }, - { 2048, 1536, "2048x1536" }, - { 2016, 1512, "2016x1512" }, - { 2000, 1600, "2000x1600" }, - { 1600, 1200, "1600x1200" }, - { 1280, 1024, "1280x1024" }, - { 1152, 864, "1152x864" }, - { 1280, 960, "1280x960" }, - { 1024, 768, "1024x768" }, - { 640, 480, "640x480" }, - { 320, 240, "320x240" }, -}; - -#ifndef OMAP_TUNA -const CapResolution OMXCameraAdapter::mImageCapResSS [] = { - { 4032*2, 3024, "8064x3024" }, - { 3648*2, 2736, "7296x2736" }, - { 3264*2, 2448, "6528x2448" }, - { 2592*2, 1944, "5184x1944" }, - { 2048*2, 1536, "4096x1536" }, - { 1600*2, 1200, "3200x1200" }, - { 1280*2, 960, "2560x960" }, - { 1024*2, 768, "2048x768" }, - { 640*2, 480, "1280x480" }, - { 320*2, 240, "640x240" }, -}; - -const CapResolution OMXCameraAdapter::mImageCapResTB [] = { - { 4032, 3024*2, "4032x6048" }, - { 3648, 2736*2, "3648x5472" }, - { 3264, 2448*2, "3264x4896" }, - { 2592, 1944*2, "2592x3888" }, - { 2048, 1536*2, "2048x3072" }, - { 1600, 1200*2, "1600x2400" }, - { 1280, 960*2, "1280x1920" }, - { 1024, 768*2, "1024x1536" }, - { 640, 480*2, "640x960" }, - { 320, 240*2, "320x480" }, -}; -#endif - -const CapResolution OMXCameraAdapter::mPreviewRes [] = { - { 1920, 1080, "1920x1080" }, - { 1280, 720, "1280x720" }, - { 960, 720, "960x720" }, - { 800, 480, "800x480" }, - { 720, 576, "720x576" }, - { 720, 480, "720x480" }, - { 768, 576, "768x576" }, - { 640, 480, "640x480" }, - { 320, 240, "320x240" }, - { 352, 288, "352x288" }, - { 240, 160, "240x160" }, - { 176, 144, "176x144" }, - { 160, 120, "160x120" }, - { 128, 96, "128x96" }, -}; - -const CapResolution OMXCameraAdapter::mPreviewPortraitRes [] = { - //Portrait resolutions - { 1088, 1920, "1088x1920" }, - { 720, 1280, "720x1280" }, - { 480, 800, "480x800" }, - { 576, 720, "576x720" }, - { 576, 768, "576x768" }, - { 480, 720, "480x720" }, - { 480, 640, "480x640" }, - { 288, 352, "288x352" }, - { 240, 320, "240x320" }, - { 160, 240, "160x240" }, - { 144, 176, "144x176" }, - { 120, 160, "120x160"}, - { 96, 128, "96x128" } -}; - -#ifndef OMAP_TUNA -const CapResolution OMXCameraAdapter::mPreviewResSS [] = { - { 1920*2, 1080, "3840x1080" }, - { 1280*2, 720, "2560x720" }, - { 800*2, 480, "1600x480" }, - { 720*2, 576, "1440x576" }, - { 720*2, 480, "1440x480" }, - { 768*2, 576, "1536x576" }, - { 640*2, 480, "1280x480" }, - { 320*2, 240, "640x240" }, - { 352*2, 288, "704x288" }, - { 240*2, 160, "480x160" }, - { 176*2, 144, "352x144" }, - { 128*2, 96, "256x96" } -}; - -const CapResolution OMXCameraAdapter::mPreviewResTB [] = { - { 1920, 1080*2, "1920x2160" }, - { 1280, 720*2, "1280x1440" }, - { 800, 480*2, "800x960" }, - { 720, 576*2, "720x1152" }, - { 720, 480*2, "720x960" }, - { 768, 576*2, "768x1152" }, - { 640, 480*2, "640x960" }, - { 320, 240*2, "320x480" }, - { 352, 288*2, "352x576" }, - { 240, 160*2, "240x320" }, - { 176, 144*2, "176x288" }, - { 128, 96*2, "128x192" }, -}; -#endif - -const CapResolution OMXCameraAdapter::mThumbRes [] = { - { 640, 480, "640x480" }, - { 160, 120, "160x120" }, - { 200, 120, "200x120" }, - { 320, 240, "320x240" }, - { 512, 384, "512x384" }, - { 352, 144, "352x144" }, - { 176, 144, "176x144" }, - { 96, 96, "96x96" }, -}; - -const CapPixelformat OMXCameraAdapter::mPixelformats [] = { - { OMX_COLOR_FormatCbYCrY, android::CameraParameters::PIXEL_FORMAT_YUV422I }, - { OMX_COLOR_FormatYUV420SemiPlanar, android::CameraParameters::PIXEL_FORMAT_YUV420SP }, - { OMX_COLOR_Format16bitRGB565, android::CameraParameters::PIXEL_FORMAT_RGB565 }, -#if 0 /*def OMAP_TUNA*/ - { OMX_COLOR_FormatRawBayer10bit, android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB }, - { OMX_COLOR_FormatYUV420SemiPlanar, android::CameraParameters::PIXEL_FORMAT_YUV420P }, -#else - { OMX_COLOR_FormatYUV420SemiPlanar, android::CameraParameters::PIXEL_FORMAT_YUV420P }, - { OMX_COLOR_FormatUnused, TICameraParameters::PIXEL_FORMAT_UNUSED }, - { OMX_COLOR_FormatRawBayer10bit, android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB }, -#endif -}; - -#ifndef OMAP_TUNA -const userToOMX_LUT OMXCameraAdapter::mFrameLayout [] = { - { TICameraParameters::S3D_NONE, OMX_TI_StereoFrameLayout2D }, - { TICameraParameters::S3D_TB_FULL, OMX_TI_StereoFrameLayoutTopBottom }, - { TICameraParameters::S3D_SS_FULL, OMX_TI_StereoFrameLayoutLeftRight }, -#ifndef OMAP_TUNA - { TICameraParameters::S3D_TB_SUBSAMPLED, OMX_TI_StereoFrameLayoutTopBottomSubsample }, - { TICameraParameters::S3D_SS_SUBSAMPLED, OMX_TI_StereoFrameLayoutLeftRightSubsample }, -#endif -}; - -const LUTtype OMXCameraAdapter::mLayoutLUT = { - ARRAY_SIZE(mFrameLayout), - mFrameLayout -}; -#endif - -const CapCodingFormat OMXCameraAdapter::mImageCodingFormat [] = { - { OMX_IMAGE_CodingJPEG, android::CameraParameters::PIXEL_FORMAT_JPEG }, - { (OMX_IMAGE_CODINGTYPE)OMX_TI_IMAGE_CodingJPS, TICameraParameters::PIXEL_FORMAT_JPS }, - { (OMX_IMAGE_CODINGTYPE)OMX_TI_IMAGE_CodingMPO, TICameraParameters::PIXEL_FORMAT_MPO }, -}; - -const CapFramerate OMXCameraAdapter::mFramerates [] = { - { 60, "60" }, - { 30, "30" }, - { 24, "24" }, - { 20, "20" }, - { 15, "15" }, - { 10, "10" }, -}; - -const CapZoom OMXCameraAdapter::mZoomStages [] = { - { 65536, "100" }, - { 68157, "104" }, - { 70124, "107" }, - { 72745, "111" }, - { 75366, "115" }, - { 77988, "119" }, - { 80609, "123" }, - { 83231, "127" }, - { 86508, "132" }, - { 89784, "137" }, - { 92406, "141" }, - { 95683, "146" }, - { 99615, "152" }, - { 102892, "157" }, - { 106168, "162" }, - { 110100, "168" }, - { 114033, "174" }, - { 117965, "180" }, - { 122552, "187" }, - { 126484, "193" }, - { 131072, "200" }, - { 135660, "207" }, - { 140247, "214" }, - { 145490, "222" }, - { 150733, "230" }, - { 155976, "238" }, - { 161219, "246" }, - { 167117, "255" }, - { 173015, "264" }, - { 178913, "273" }, - { 185467, "283" }, - { 192020, "293" }, - { 198574, "303" }, - { 205783, "314" }, - { 212992, "325" }, - { 220201, "336" }, - { 228065, "348" }, - { 236585, "361" }, - { 244449, "373" }, - { 252969, "386" }, - { 262144, "400" }, - { 271319, "414" }, - { 281149, "429" }, - { 290980, "444" }, - { 300810, "459" }, - { 311951, "476" }, - { 322437, "492" }, - { 334234, "510" }, - { 346030, "528" }, - { 357827, "546" }, - { 370934, "566" }, - { 384041, "586" }, - { 397148, "606" }, - { 411566, "628" }, - { 425984, "650" }, - { 441057, "673" }, - { 456131, "696" }, - { 472515, "721" }, - { 488899, "746" }, - { 506593, "773" }, - { 524288, "800" }, -}; - -const CapISO OMXCameraAdapter::mISOStages [] = { - { 0, "auto" }, - { 100, "100" }, - { 200, "200"}, - { 400, "400" }, - { 800, "800" }, - { 1000, "1000" }, - { 1200, "1200" }, - { 1600, "1600" }, -}; - -// mapped values have to match with new_sensor_MSP.h -const CapU32 OMXCameraAdapter::mSensorNames [] = { - { SENSORID_IMX060, "IMX060" }, - { SENSORID_OV5650, "OV5650" }, - { SENSORID_OV5640, "OV5640" }, - { SENSORID_OV14825, "OV14825"}, - { SENSORID_S5K4E1GA, "S5K4E1GA"}, - { SENSORID_S5K6A1GX03, "S5K6A1GX03" } - // TODO(XXX): need to account for S3D camera later -}; - -const userToOMX_LUT OMXCameraAdapter::mAutoConvergence [] = { - { TICameraParameters::AUTOCONVERGENCE_MODE_DISABLE, OMX_TI_AutoConvergenceModeDisable }, - { TICameraParameters::AUTOCONVERGENCE_MODE_FRAME, OMX_TI_AutoConvergenceModeFrame }, - { TICameraParameters::AUTOCONVERGENCE_MODE_CENTER, OMX_TI_AutoConvergenceModeCenter }, - { TICameraParameters::AUTOCONVERGENCE_MODE_TOUCH, OMX_TI_AutoConvergenceModeFocusFaceTouch }, - { TICameraParameters::AUTOCONVERGENCE_MODE_MANUAL, OMX_TI_AutoConvergenceModeManual } -}; - -const LUTtype OMXCameraAdapter::mAutoConvergenceLUT = { - ARRAY_SIZE(mAutoConvergence), - mAutoConvergence -}; - -const userToOMX_LUT OMXCameraAdapter::mBracketingModes [] = { - { TICameraParameters::TEMP_BRACKETING , OMX_BracketTemporal }, - { TICameraParameters::EXPOSURE_BRACKETING , OMX_BracketExposureRelativeInEV } -}; - -const LUTtype OMXCameraAdapter::mBracketingModesLUT = { - ARRAY_SIZE(mBracketingModes), - mBracketingModes -}; - -// values for supported camera facing direction -const CapU32 OMXCameraAdapter::mFacing [] = { -#ifdef OMAP_TUNA - { 1, TICameraParameters::FACING_BACK }, - { 0, TICameraParameters::FACING_FRONT}, -#else - { OMX_TI_SENFACING_BACK , TICameraParameters::FACING_BACK }, - { OMX_TI_SENFACING_FRONT, TICameraParameters::FACING_FRONT}, -#endif -}; - -/***************************************** - * internal static function declarations - *****************************************/ - -/**** Utility functions to help translate OMX Caps to Parameter ****/ - -status_t OMXCameraAdapter::encodeImageCodingFormatCap(OMX_IMAGE_CODINGTYPE format, - const CapCodingFormat *cap, - size_t capCount, - char * buffer) { - - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( ( NULL == buffer ) || ( NULL == cap ) ) { - CAMHAL_LOGEA("Invalid input arguments"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) { - for ( unsigned int i = 0 ; i < capCount ; i++ ) { - if ( format == cap[i].imageCodingFormat ) { - if (buffer[0] != '\0') { - strncat(buffer, PARAM_SEP, ((((int)MAX_PROP_VALUE_LENGTH - 1 - (int)strlen(buffer)) < 0) ? 0 : (MAX_PROP_VALUE_LENGTH - 1 - strlen(buffer)))); - } - strncat(buffer, cap[i].param, ((((int)MAX_PROP_VALUE_LENGTH - 1 - (int)strlen(buffer)) < 0) ? 0 : (MAX_PROP_VALUE_LENGTH - 1 - strlen(buffer)))); - } - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::encodePixelformatCap(OMX_COLOR_FORMATTYPE format, - const CapPixelformat *cap, - size_t capCount, - char * buffer, - size_t bufferSize) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( ( NULL == buffer ) || ( NULL == cap ) ) { - CAMHAL_LOGEA("Invalid input arguments"); - return -EINVAL; - } - - - for ( unsigned int i = 0 ; i < capCount ; i++ ) - { - if ( format == cap[i].pixelformat ) - { - if (buffer[0] != '\0') { - strncat(buffer, PARAM_SEP, bufferSize - 1); - } - strncat(buffer, cap[i].param, bufferSize - 1); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -void OMXCameraAdapter::encodeFrameRates(const int minFrameRate, const int maxFrameRate, - const OMX_TI_CAPTYPE & caps, const CapFramerate * const fixedFrameRates, - const int frameRateCount, android::Vector & fpsRanges) { - LOG_FUNCTION_NAME; - - if ( minFrameRate == maxFrameRate ) { - // single fixed frame rate supported - fpsRanges.add(FpsRange(minFrameRate, maxFrameRate)); - return; - } - - // insert min and max frame rates - fpsRanges.add(FpsRange(minFrameRate, minFrameRate)); - fpsRanges.add(FpsRange(maxFrameRate, maxFrameRate)); - - // insert variable frame rates - for ( int i = 0; i < static_cast(caps.ulPrvVarFPSModesCount); ++i ) { - const FpsRange fpsRange = FpsRange( - max(androidFromDucatiFrameRate(caps.tPrvVarFPSModes[i].nVarFPSMin), minFrameRate), - min(androidFromDucatiFrameRate(caps.tPrvVarFPSModes[i].nVarFPSMax), maxFrameRate)); - - if ( fpsRange.isFixed() ) { - // this range is either min or max fixed frame rate, already added above - continue; - } - - fpsRanges.add(fpsRange); - } - - // insert fixed frame rates - for ( int i = 0; i < frameRateCount; ++i ) { - const int fixedFrameRate = fixedFrameRates[i].num * CameraHal::VFR_SCALE; - - if ( fixedFrameRate < minFrameRate || fixedFrameRate > maxFrameRate ) { - // not supported by hardware - continue; - } - - const FpsRange fpsRange = FpsRange(fixedFrameRate, fixedFrameRate); - fpsRanges.add(fpsRange); - } - - // sort first by max, then by min, according to Android API requirements - fpsRanges.sort(FpsRange::compare); - - // remove duplicated frame rates - for ( int i = 0; i < static_cast(fpsRanges.size()) - 1; ) { - const FpsRange & current = fpsRanges.itemAt(i); - const FpsRange & next = fpsRanges.itemAt(i + 1); - if ( current == next ) { - fpsRanges.removeAt(i + 1); - } else { - i++; - } - } -} - -size_t OMXCameraAdapter::encodeZoomCap(OMX_S32 maxZoom, - const CapZoom *cap, - size_t capCount, - char * buffer, - size_t bufferSize) -{ - status_t res = NO_ERROR; - size_t ret = 0; - - LOG_FUNCTION_NAME; - - if ( (NULL == buffer) || (NULL == cap) ) { - CAMHAL_LOGEA("Invalid input arguments"); - return -EINVAL; - } - - - for ( unsigned int i = 0; i < capCount; i++ ) { - if ( cap[i].num <= maxZoom ) { - if (buffer[0] != '\0') { - strncat(buffer, PARAM_SEP, bufferSize - 1); - } - strncat(buffer, cap[i].param, bufferSize - 1); - ret++; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::encodeISOCap(OMX_U32 maxISO, - const CapISO *cap, - size_t capCount, - char * buffer, - size_t bufferSize) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( (NULL == buffer) || (NULL == cap) ) { - CAMHAL_LOGEA("Invalid input arguments"); - return -EINVAL; - } - - for ( unsigned int i = 0; i < capCount; i++ ) { - if ( cap[i].num <= maxISO) { - if (buffer[0] != '\0') { - strncat(buffer, PARAM_SEP, bufferSize - 1); - } - strncat(buffer, cap[i].param, bufferSize - 1); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::encodeSizeCap(OMX_TI_CAPRESTYPE &res, - const CapResolution *cap, - size_t capCount, - char * buffer, - size_t bufferSize) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( (NULL == buffer) || (NULL == cap) ) { - CAMHAL_LOGEA("Invalid input arguments"); - return -EINVAL; - } - - for ( unsigned int i = 0 ; i < capCount ; i++ ) { - if ( (cap[i].width <= res.nWidthMax) && - (cap[i].height <= res.nHeightMax) && - (cap[i].width >= res.nWidthMin) && - (cap[i].height >= res.nHeightMin) ) { - if (buffer[0] != '\0') { - strncat(buffer, PARAM_SEP, bufferSize - 1); - } - strncat(buffer, cap[i].param, bufferSize -1); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -#ifndef OMAP_TUNA -status_t OMXCameraAdapter::encodeSizeCap3D(OMX_TI_CAPRESTYPE &res, - const CapResolution *cap, - size_t capCount, - char * buffer, - size_t bufferSize) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( (NULL == buffer) || (NULL == cap) ) { - CAMHAL_LOGEA("Invalid input arguments"); - return -EINVAL; - } - - for ( unsigned int i = 0 ; i < capCount ; i++ ) { - if ( (cap[i].width <= res.nWidthMax) && - (cap[i].height <= res.nHeightMax) && - (cap[i].width >= res.nWidthMin) && - (cap[i].height >= res.nHeightMin) -#ifndef OMAP_TUNA - && (cap[i].width * cap[i].height <= res.nMaxResInPixels) -#endif - ) { - if (buffer[0] != '\0') { - strncat(buffer, PARAM_SEP, bufferSize - 1); - } - strncat(buffer, cap[i].param, bufferSize -1); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} -#endif - -status_t OMXCameraAdapter::insertImageSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; -#ifndef OMAP_TUNA - int s3d_detected = 0; - int s3d_ss_detected = 0; - int s3d_tb_detected = 0; -#endif - - LOG_FUNCTION_NAME; - -#ifndef OMAP_TUNA - for ( unsigned int i = 0 ; i < caps.ulCapFrameLayoutCount; i++ ) { - if (caps.eCapFrameLayout[i] == OMX_TI_StereoFrameLayoutTopBottom) - { - s3d_tb_detected = 1; - } - else if (caps.eCapFrameLayout[i] == OMX_TI_StereoFrameLayoutLeftRight) - { - s3d_ss_detected = 1; - } - else if ( (caps.eCapFrameLayout[i] == OMX_TI_StereoFrameLayoutTopBottomSubsample) - || (caps.eCapFrameLayout[i] == OMX_TI_StereoFrameLayoutLeftRightSubsample) ) - { - s3d_detected = 1; - } - } -#endif - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - -#ifndef OMAP_TUNA - // Check if we are in 2d mode - if (!s3d_ss_detected && !s3d_tb_detected && !s3d_detected) - { -#endif - ret = encodeSizeCap(caps.tImageResRange, - mImageCapRes, - ARRAY_SIZE(mImageCapRes), - supported, - MAX_PROP_VALUE_LENGTH); - - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported picture sizes 0x%x", ret); - } else { - params->set(CameraProperties::SUPPORTED_PICTURE_SIZES, supported); - } - params->set(CameraProperties::MAX_PICTURE_WIDTH, caps.tImageResRange.nWidthMax); - params->set(CameraProperties::MAX_PICTURE_HEIGHT, caps.tImageResRange.nHeightMax); -#ifndef OMAP_TUNA - } - else // 3d mode - { - if (s3d_tb_detected) - { - ret = encodeSizeCap3D(caps.tImageResRange, - mImageCapResTB, - ARRAY_SIZE(mImageCapResTB), - supported, - MAX_PROP_VALUE_LENGTH); - - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported picture sizes 0x%x", ret); - } else { - params->set(CameraProperties::SUPPORTED_PICTURE_TOPBOTTOM_SIZES, supported); - } - } - else - { - params->set(CameraProperties::SUPPORTED_PICTURE_TOPBOTTOM_SIZES, supported); - } - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - if (s3d_ss_detected) - { - ret = encodeSizeCap3D(caps.tImageResRange, - mImageCapResSS, - ARRAY_SIZE(mImageCapResSS), - supported, - MAX_PROP_VALUE_LENGTH); - - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported picture sizes 0x%x", ret); - } else { - params->set(CameraProperties::SUPPORTED_PICTURE_SIDEBYSIDE_SIZES, supported); - } - } - else - { - params->set(CameraProperties::SUPPORTED_PICTURE_SIDEBYSIDE_SIZES, supported); - } - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - if (s3d_detected) - { - ret = encodeSizeCap3D(caps.tImageResRange, - mImageCapRes, - ARRAY_SIZE(mImageCapRes), - supported, - MAX_PROP_VALUE_LENGTH); - - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported picture sizes 0x%x", ret); - } else { - params->set(CameraProperties::SUPPORTED_PICTURE_SUBSAMPLED_SIZES, supported); - } - } else { - params->set(CameraProperties::SUPPORTED_PICTURE_SUBSAMPLED_SIZES, supported); - } - } -#endif - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertPreviewSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; -#ifndef OMAP_TUNA - int s3d_detected = 0; - int s3d_ss_detected = 0; - int s3d_tb_detected = 0; -#endif - - LOG_FUNCTION_NAME; - -#ifndef OMAP_TUNA - for ( unsigned int i = 0 ; i < caps.ulPrvFrameLayoutCount; i++ ) { - if (caps.ePrvFrameLayout[i] == OMX_TI_StereoFrameLayoutTopBottom) - { - s3d_tb_detected = 1; - } - else if (caps.ePrvFrameLayout[i] == OMX_TI_StereoFrameLayoutLeftRight) - { - s3d_ss_detected = 1; - } - else if ( (caps.ePrvFrameLayout[i] == OMX_TI_StereoFrameLayoutTopBottomSubsample) - || (caps.ePrvFrameLayout[i] == OMX_TI_StereoFrameLayoutLeftRightSubsample) ) - { - s3d_detected = 1; - } - } -#endif - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - -#ifndef OMAP_TUNA - // Check if we are in 2d mode - if (!s3d_ss_detected && !s3d_tb_detected && !s3d_detected) - { -#endif - ret = encodeSizeCap(caps.tPreviewResRange, - mPreviewRes, - ARRAY_SIZE(mPreviewRes), - supported, - MAX_PROP_VALUE_LENGTH); - - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported Landscape preview sizes 0x%x", ret); - return ret; - } - -#ifndef OMAP_TUNA - /* Insert Portait Resolutions by verifying Potrait Capability Support */ - ret = encodeSizeCap(caps.tRotatedPreviewResRange, - mPreviewPortraitRes, - ARRAY_SIZE(mPreviewPortraitRes), - supported, - MAX_PROP_VALUE_LENGTH); -#endif - - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported Potrait preview sizes 0x%x", ret); - } else { - params->set(CameraProperties::SUPPORTED_PREVIEW_SIZES, supported); - } -#ifndef OMAP_TUNA - } - else // 3d mode - { - if (s3d_tb_detected) - { - ret = encodeSizeCap3D(caps.tPreviewResRange, - mPreviewResTB, - ARRAY_SIZE(mPreviewResTB), - supported, - MAX_PROP_VALUE_LENGTH); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported 3D TB preview sizes 0x%x", ret); - return ret; - } else { - params->set(CameraProperties::SUPPORTED_PREVIEW_TOPBOTTOM_SIZES, supported); - } - } - else - { - params->set(CameraProperties::SUPPORTED_PREVIEW_TOPBOTTOM_SIZES, supported); - } - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - if (s3d_ss_detected) - { - ret = encodeSizeCap3D(caps.tPreviewResRange, - mPreviewResSS, - ARRAY_SIZE(mPreviewResSS), - supported, - MAX_PROP_VALUE_LENGTH); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported 3D SS preview sizes 0x%x", ret); - return ret; - } else { - params->set(CameraProperties::SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES, supported); - } - } - else - { - params->set(CameraProperties::SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES, supported); - } - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - if (s3d_detected) - { - ret = encodeSizeCap3D(caps.tPreviewResRange, - mPreviewRes, - ARRAY_SIZE(mPreviewRes), - supported, - MAX_PROP_VALUE_LENGTH); - - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported preview sizes 0x%x", ret); - return ret; - } else { - params->set(CameraProperties::SUPPORTED_PREVIEW_SUBSAMPLED_SIZES, supported); - } - } - else - { - params->set(CameraProperties::SUPPORTED_PREVIEW_SUBSAMPLED_SIZES, supported); - } - } -#endif - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertVideoSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - ret = encodeSizeCap(caps.tPreviewResRange, - mPreviewRes, - ARRAY_SIZE(mPreviewRes), - supported, - MAX_PROP_VALUE_LENGTH); - - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported video sizes 0x%x", ret); - } else { - params->set(CameraProperties::SUPPORTED_VIDEO_SIZES, supported); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertThumbSizes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - ret = encodeSizeCap(caps.tThumbResRange, - mThumbRes, - ARRAY_SIZE(mThumbRes), - supported, - MAX_PROP_VALUE_LENGTH); - - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported thumbnail sizes 0x%x", ret); - } else { - //CTS Requirement: 0x0 should always be supported - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat(supported, "0x0", MAX_PROP_NAME_LENGTH); - params->set(CameraProperties::SUPPORTED_THUMBNAIL_SIZES, supported); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertZoomStages(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - size_t zoomStageCount = 0; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - zoomStageCount = encodeZoomCap(caps.xMaxWidthZoom, - mZoomStages, - ARRAY_SIZE(mZoomStages), - supported, - MAX_PROP_VALUE_LENGTH); - - params->set(CameraProperties::SUPPORTED_ZOOM_RATIOS, supported); - params->set(CameraProperties::SUPPORTED_ZOOM_STAGES, zoomStageCount - 1); //As per CTS requirement - - if ( 0 == zoomStageCount ) { - params->set(CameraProperties::ZOOM_SUPPORTED, android::CameraParameters::FALSE); - params->set(CameraProperties::SMOOTH_ZOOM_SUPPORTED, android::CameraParameters::FALSE); - } else { - params->set(CameraProperties::ZOOM_SUPPORTED, android::CameraParameters::TRUE); - params->set(CameraProperties::SMOOTH_ZOOM_SUPPORTED, android::CameraParameters::TRUE); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertImageFormats(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', sizeof(supported)); - - for ( int i = 0 ; i < caps.ulImageFormatCount ; i++ ) { - ret = encodePixelformatCap(caps.eImageFormats[i], - mPixelformats, - ARRAY_SIZE(mPixelformats), - supported, - MAX_PROP_VALUE_LENGTH); - - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported picture formats 0x%x", ret); - break; - } - } - -#ifndef OMAP_TUNA - for (int i = 0; i < caps.ulImageCodingFormatCount ; i++) { - ret = encodeImageCodingFormatCap(caps.eImageCodingFormat[i], - mImageCodingFormat, - ARRAY_SIZE(mImageCodingFormat), - supported); - - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported picture formats 0x%x", ret); - break; - } - } -#endif - - if ( NO_ERROR == ret ) { -#ifdef OMAP_TUNA - //jpeg is not supported in (our) OMX capabilies - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat(supported, android::CameraParameters::PIXEL_FORMAT_JPEG, MAX_PROP_VALUE_LENGTH - 1); -#endif - params->set(CameraProperties::SUPPORTED_PICTURE_FORMATS, supported); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertPreviewFormats(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - for ( int i = 0 ; i < caps.ulPreviewFormatCount; i++ ) { - ret = encodePixelformatCap(caps.ePreviewFormats[i], - mPixelformats, - ARRAY_SIZE(mPixelformats), - supported, - MAX_PROP_VALUE_LENGTH); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported preview formats 0x%x", ret); - break; - } - } - - if ( NO_ERROR == ret ) { - // need to advertise we support YV12 format - // tuna advertises this already though -#ifndef OMAP_TUNA - // We will program preview port with NV21 when we see application set YV12 - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat(supported, android::CameraParameters::PIXEL_FORMAT_YUV420P, MAX_PROP_VALUE_LENGTH - 1); -#endif - params->set(CameraProperties::SUPPORTED_PREVIEW_FORMATS, supported); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertFramerates(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - // collect supported normal frame rates - { - android::Vector fpsRanges; - - const int minFrameRate = max(FPS_MIN * CameraHal::VFR_SCALE, - androidFromDucatiFrameRate(caps.xFramerateMin)); - const int maxFrameRate = min(FPS_MAX * CameraHal::VFR_SCALE, - androidFromDucatiFrameRate(caps.xFramerateMax)); - - if ( minFrameRate > maxFrameRate ) { - CAMHAL_LOGE("Invalid frame rate range: [%d .. %d]", caps.xFramerateMin, caps.xFramerateMax); - return BAD_VALUE; - } - - encodeFrameRates(minFrameRate, maxFrameRate, caps, mFramerates, ARRAY_SIZE(mFramerates), fpsRanges); - - // populate variable frame rates - char supported[MAX_PROP_VALUE_LENGTH]; - char defaultRange[MAX_PROP_VALUE_LENGTH]; - - memset(supported, 0, sizeof(supported)); - memset(defaultRange, 0, sizeof(defaultRange)); - - for ( int i = 0; i < static_cast(fpsRanges.size()); ++i ) { - const FpsRange & fpsRange = fpsRanges.itemAt(i); - if ( supported[0] ) strncat(supported, PARAM_SEP, 1); - char tmp[MAX_PROP_VALUE_LENGTH]; - snprintf(tmp, sizeof(tmp) - 1, "(%d,%d)", fpsRange.min(), fpsRange.max()); - strcat(supported, tmp); - } - - const FpsRange & defaultFpsRange = fpsRanges.itemAt(fpsRanges.size() - 1); - snprintf(defaultRange, sizeof(defaultRange) - 1, "%d,%d", defaultFpsRange.min(), defaultFpsRange.max()); - - CAMHAL_LOGD("Supported framerate ranges: %s", supported); - CAMHAL_LOGD("Default framerate range: [%s]", defaultRange); - - params->set(CameraProperties::FRAMERATE_RANGE_SUPPORTED, supported); - params->set(CameraProperties::FRAMERATE_RANGE, defaultRange); - - // populate fixed frame rates - memset(supported, 0, sizeof(supported)); - memset(defaultRange, 0, sizeof(defaultRange)); - - for ( int i = 0; i < static_cast(fpsRanges.size()); ++i ) { - const FpsRange & fpsRange = fpsRanges.itemAt(i); - if ( fpsRange.isFixed() && (fpsRange.min()%CameraHal::VFR_SCALE) == 0 ) { - if ( supported[0] ) strncat(supported, PARAM_SEP, 1); - char tmp[MAX_PROP_VALUE_LENGTH]; - snprintf(tmp, sizeof(tmp) - 1, "%d", fpsRange.min()/CameraHal::VFR_SCALE); - strcat(supported, tmp); - } - } - - CAMHAL_LOGD("Supported preview framerates: %s", supported); - params->set(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES, supported); - - // insert default frame rate only if it is fixed - if ( defaultFpsRange.isFixed() && (defaultFpsRange.min()%CameraHal::VFR_SCALE) == 0 ) { - snprintf(defaultRange, sizeof(defaultRange) - 1, "%d", defaultFpsRange.min()/CameraHal::VFR_SCALE); - params->set(CameraProperties::PREVIEW_FRAME_RATE, defaultRange); - } - } - - // collect supported extended frame rates - { - android::Vector fpsRanges; - - const int minFrameRate = max(FPS_MIN * CameraHal::VFR_SCALE, - androidFromDucatiFrameRate(caps.xFramerateMin)); - const int maxFrameRate = min(FPS_MAX_EXTENDED * CameraHal::VFR_SCALE, - androidFromDucatiFrameRate(caps.xFramerateMax)); - - encodeFrameRates(minFrameRate, maxFrameRate, caps, mFramerates, ARRAY_SIZE(mFramerates), fpsRanges); - - // populate variable frame rates - char supported[MAX_PROP_VALUE_LENGTH]; - memset(supported, 0, sizeof(supported) - 1); - - for ( int i = 0; i < static_cast(fpsRanges.size()); ++i ) { - const FpsRange & fpsRange = fpsRanges.itemAt(i); - if ( supported[0] ) strncat(supported, PARAM_SEP, 1); - char tmp[MAX_PROP_VALUE_LENGTH]; - snprintf(tmp, sizeof(tmp) - 1, "(%d,%d)", fpsRange.min(), fpsRange.max()); - strcat(supported, tmp); - } - - CAMHAL_LOGD("Supported framerate ranges extended: %s", supported); - params->set(CameraProperties::FRAMERATE_RANGE_EXT_SUPPORTED, supported); - - // populate fixed frame rates - memset(supported, 0, sizeof(supported) - 1); - - for ( int i = 0; i < static_cast(fpsRanges.size()); ++i ) { - const FpsRange & fpsRange = fpsRanges.itemAt(i); - if ( fpsRange.isFixed() && (fpsRange.min()%CameraHal::VFR_SCALE) == 0 ) { - if ( supported[0] ) strncat(supported, PARAM_SEP, 1); - char tmp[MAX_PROP_VALUE_LENGTH]; - snprintf(tmp, sizeof(tmp) - 1, "%d", fpsRange.min()/CameraHal::VFR_SCALE); - strcat(supported, tmp); - } - } - - CAMHAL_LOGD("Supported extended preview framerates: %s", supported); - params->set(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES_EXT, supported); - } - - return OK; -} - -status_t OMXCameraAdapter::insertEVs(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", ( int ) ( caps.xEVCompensationMin * 10 )); - params->set(CameraProperties::SUPPORTED_EV_MIN, supported); - - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", ( int ) ( caps.xEVCompensationMax * 10 )); - params->set(CameraProperties::SUPPORTED_EV_MAX, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertISOModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - ret = encodeISOCap(caps.nSensitivityMax, - mISOStages, - ARRAY_SIZE(mISOStages), - supported, - MAX_PROP_VALUE_LENGTH); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error inserting supported ISO modes 0x%x", ret); - } else { - params->set(CameraProperties::SUPPORTED_ISO_VALUES, supported); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertIPPModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - //Off is always supported - strncat(supported, TICameraParameters::IPP_NONE, MAX_PROP_NAME_LENGTH); - - if ( caps.bLensDistortionCorrectionSupported ) { - strncat(supported, PARAM_SEP, 1); - strncat(supported, TICameraParameters::IPP_LDC, MAX_PROP_NAME_LENGTH); - } - - if ( caps.bISONoiseFilterSupported ) { - strncat(supported, PARAM_SEP, 1); - strncat(supported, TICameraParameters::IPP_NSF, MAX_PROP_NAME_LENGTH); - } - - if ( caps.bISONoiseFilterSupported && caps.bLensDistortionCorrectionSupported ) { - strncat(supported, PARAM_SEP, 1); - strncat(supported, TICameraParameters::IPP_LDCNSF, MAX_PROP_NAME_LENGTH); - } - - params->set(CameraProperties::SUPPORTED_IPP_MODES, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertWBModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - for ( unsigned int i = 0 ; i < caps.ulWhiteBalanceCount ; i++ ) { - p = getLUTvalue_OMXtoHAL(caps.eWhiteBalanceModes[i], WBalLUT); - if ( NULL != p ) { - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat(supported, p, MAX_PROP_NAME_LENGTH); - } - } - - params->set(CameraProperties::SUPPORTED_WHITE_BALANCE, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertEffects(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - for ( unsigned int i = 0 ; i < caps.ulColorEffectCount; i++ ) { - p = getLUTvalue_OMXtoHAL(caps.eColorEffects[i], EffLUT); - if ( NULL != p ) { - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat(supported, p, MAX_PROP_NAME_LENGTH); - } - } - - params->set(CameraProperties::SUPPORTED_EFFECTS, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertExpModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - for ( unsigned int i = 0 ; i < caps.ulExposureModeCount; i++ ) { - p = getLUTvalue_OMXtoHAL(caps.eExposureModes[i], ExpLUT); - if ( NULL != p ) { - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat(supported, p, MAX_PROP_NAME_LENGTH); - } - } - - params->set(CameraProperties::SUPPORTED_EXPOSURE_MODES, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertManualExpRanges(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - -#ifndef OMAP_TUNA - if (caps.nManualExpMin > caps.nManualExpMax) { -#endif - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) 0); - params->set(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MIN, supported); - - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) 0); - params->set(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MAX, supported); - - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) 0); - params->set(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_STEP, supported); -#ifndef OMAP_TUNA - } else { - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) caps.nManualExpMin); - params->set(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MIN, supported); - - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) caps.nManualExpMax); - params->set(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_MAX, supported); - - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) MANUAL_EXPOSURE_STEP); - params->set(CameraProperties::SUPPORTED_MANUAL_EXPOSURE_STEP, supported); - } -#endif - - if (MANUAL_GAIN_ISO_MIN > caps.nSensitivityMax) { - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) 0); - params->set(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MIN, supported); - - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) 0); - params->set(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MAX, supported); - - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) 0); - params->set(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_STEP, supported); } - else { - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) MANUAL_GAIN_ISO_MIN); - params->set(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MIN, supported); - - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) caps.nSensitivityMax); - params->set(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_MAX, supported); - - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", (int) MANUAL_GAIN_ISO_STEP); - params->set(CameraProperties::SUPPORTED_MANUAL_GAIN_ISO_STEP, supported); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertFlashModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - for ( unsigned int i = 0 ; i < caps.ulFlashCount; i++ ) { - p = getLUTvalue_OMXtoHAL(caps.eFlashModes[i], FlashLUT); - if ( NULL != p ) { - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat(supported, p, MAX_PROP_NAME_LENGTH); - } - } - - if ( strlen(supported) == 0 ) { - strncpy(supported, DEFAULT_FLASH_MODE, MAX_PROP_NAME_LENGTH); - } - - params->set(CameraProperties::SUPPORTED_FLASH_MODES, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertSceneModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - for ( unsigned int i = 0 ; i < caps.ulSceneCount; i++ ) { - p = getLUTvalue_OMXtoHAL(caps.eSceneModes[i], SceneLUT); - if ( NULL != p ) { - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat(supported, p, MAX_PROP_NAME_LENGTH); - } - } - - params->set(CameraProperties::SUPPORTED_SCENE_MODES, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertFocusModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - for ( unsigned int i = 0 ; i < caps.ulFocusModeCount; i++ ) { - getMultipleLUTvalue_OMXtoHAL(caps.eFocusModes[i], FocusLUT, supported); - } - - // Check if focus is supported by camera - if (caps.ulFocusModeCount == 1 && - caps.eFocusModes[0] == OMX_IMAGE_FocusControlOff) { - // Focus is not supported by camera - // Advertise this to app as infinitiy focus mode - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat(supported, android::CameraParameters::FOCUS_MODE_INFINITY, MAX_PROP_NAME_LENGTH); - } - - params->set(CameraProperties::SUPPORTED_FOCUS_MODES, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertFlickerModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - for ( unsigned int i = 0 ; i < caps.ulFlickerCount; i++ ) { - p = getLUTvalue_OMXtoHAL(caps.eFlicker[i], FlickerLUT); - if ( NULL != p ) { - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat(supported, p, MAX_PROP_NAME_LENGTH); - } - } - - params->set(CameraProperties::SUPPORTED_ANTIBANDING, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertAreas(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - - sprintf(supported, "%d", caps.ulAlgoAreasFocusCount); - params->set(CameraProperties::MAX_FOCUS_AREAS, supported); - CAMHAL_LOGDB("Maximum supported focus areas %s", supported); - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - sprintf(supported, "%d", caps.ulAlgoAreasExposureCount); - params->set(CameraProperties::MAX_NUM_METERING_AREAS, supported); - CAMHAL_LOGDB("Maximum supported exposure areas %s", supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertVNFSupported(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - -#ifndef OMAP_TUNA - if ( OMX_TRUE == caps.bVideoNoiseFilterSupported ) { - params->set(CameraProperties::VNF_SUPPORTED, android::CameraParameters::TRUE); - } else { -#endif - params->set(CameraProperties::VNF_SUPPORTED, android::CameraParameters::FALSE); -#ifndef OMAP_TUNA - } -#endif - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertVSTABSupported(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - -#ifndef OMAP_TUNA - if ( OMX_TRUE == caps.bVideoStabilizationSupported ) { - params->set(CameraProperties::VSTAB_SUPPORTED, android::CameraParameters::TRUE); - } else { -#endif - params->set(CameraProperties::VSTAB_SUPPORTED, android::CameraParameters::FALSE); -#ifndef OMAP_TUNA - } -#endif - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertLocks(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME - -#ifndef OMAP_TUNA - if ( caps.bAELockSupported ) { - params->set(CameraProperties::AUTO_EXPOSURE_LOCK_SUPPORTED, android::CameraParameters::TRUE); - } else { -#endif - params->set(CameraProperties::AUTO_EXPOSURE_LOCK_SUPPORTED, android::CameraParameters::FALSE); -#ifndef OMAP_TUNA - } -#endif - -#ifndef OMAP_TUNA - if ( caps.bAWBLockSupported ) { - params->set(CameraProperties::AUTO_WHITEBALANCE_LOCK_SUPPORTED, android::CameraParameters::TRUE); - } else { -#endif - params->set(CameraProperties::AUTO_WHITEBALANCE_LOCK_SUPPORTED, android::CameraParameters::FALSE); -#ifndef OMAP_TUNA - } -#endif - - LOG_FUNCTION_NAME_EXIT - - return ret; -} - -status_t OMXCameraAdapter::insertSenMount(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - unsigned int i = 0; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', sizeof(supported)); - - // 1) Look up and assign sensor name - for (i = 0; i < ARRAY_SIZE(mSensorNames); i++) { - if(mSensorNames[i].num == caps.tSenMounting.nSenId) { - // sensor found - break; - } - } - if ( i == ARRAY_SIZE(mSensorNames) ) { - p = "UNKNOWN_SENSOR"; - } else { - p = mSensorNames[i].param; - } - strncat(supported, p, REMAINING_BYTES(supported)); - params->set(CameraProperties::CAMERA_NAME, supported); - params->set(CameraProperties::CAMERA_SENSOR_ID, caps.tSenMounting.nSenId); - - // 2) Assign mounting rotation - params->set(CameraProperties::ORIENTATION_INDEX, caps.tSenMounting.nRotation); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertRaw(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) { - - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - unsigned int i = 0; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', sizeof(supported)); -#ifdef OMAP_TUNA - sprintf(supported,"%d",int(caps.tImageResRange.nWidthMax)); -#else - sprintf(supported,"%d",int(caps.uSenNativeResWidth)); -#endif - params->set(CameraProperties::RAW_WIDTH, supported); - - memset(supported, '\0', sizeof(supported)); -#ifdef OMAP_TUNA - sprintf(supported,"%d",int(caps.tImageResRange.nHeightMax)); -#else - if (caps.bMechanicalMisalignmentSupported) { - sprintf(supported,"%d",int(caps.uSenNativeResHeight) * 2); - } else { - sprintf(supported,"%d",int(caps.uSenNativeResHeight)); - } -#endif - params->set(CameraProperties::RAW_HEIGHT, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertFacing(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - unsigned int i = 0; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', sizeof(supported)); - -#ifdef OMAP_TUNA - if(caps.tSenMounting.nSenId == 305) { - i = 0; - } else { - i = 1; - } -#else - for (i = 0; i < ARRAY_SIZE(mFacing); i++) { - if((OMX_TI_SENFACING_TYPE)mFacing[i].num == caps.tSenMounting.eFacing) { - break; - } - } -#endif - if ( i == ARRAY_SIZE(mFacing) ) { - p = "UNKNOWN_FACING"; - } else { - p = mFacing[i].param; - } - strncat(supported, p, REMAINING_BYTES(supported)); - params->set(CameraProperties::FACING_INDEX, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -#ifndef OMAP_TUNA -status_t OMXCameraAdapter::insertFocalLength(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', sizeof(supported)); - -#ifndef OMAP_TUNA - sprintf(supported, "%d", caps.nFocalLength / 100); -#endif - strncat(supported, ".", REMAINING_BYTES(supported)); -#ifndef OMAP_TUNA - sprintf(supported+(strlen(supported)*sizeof(char)), "%d", caps.nFocalLength % 100); -#endif - - params->set(CameraProperties::FOCAL_LENGTH, supported); - - LOG_FUNCTION_NAME_EXIT - - return ret; -} -#endif - -status_t OMXCameraAdapter::insertAutoConvergenceModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - unsigned int i = 0; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', sizeof(supported)); -#ifndef OMAP_TUNA - for ( unsigned int i = 0 ; i < caps.ulAutoConvModesCount; i++ ) { - p = getLUTvalue_OMXtoHAL(caps.eAutoConvModes[i], mAutoConvergenceLUT); - if ( NULL != p ) { - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); - } - strncat(supported, p, REMAINING_BYTES(supported)); - } - } -#endif - params->set(CameraProperties::AUTOCONVERGENCE_MODE_VALUES, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertManualConvergenceRange(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - -#ifndef OMAP_TUNA - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", ( int ) ( caps.nManualConvMin )); -#endif - params->set(CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_MIN, supported); - -#ifndef OMAP_TUNA - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", ( int ) ( caps.nManualConvMax )); -#endif - params->set(CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_MAX, supported); - -#ifndef OMAP_TUNA - snprintf(supported, MAX_PROP_VALUE_LENGTH, "%d", ( int ) ( caps.nManualConvMax != caps.nManualConvMin )); -#endif - params->set(CameraProperties::SUPPORTED_MANUAL_CONVERGENCE_STEP, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -#ifndef OMAP_TUNA -status_t OMXCameraAdapter::insertMechanicalMisalignmentCorrection(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - LOG_FUNCTION_NAME; - - params->set(CameraProperties::MECHANICAL_MISALIGNMENT_CORRECTION_SUPPORTED, - caps.bMechanicalMisalignmentSupported == OMX_TRUE ? - android::CameraParameters::TRUE : android::CameraParameters::FALSE); - - return OK; -} -#endif - -status_t OMXCameraAdapter::insertCaptureModes(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', sizeof(supported)); - -#ifndef OMAP_TUNA - // 3D mode detect: Misalignment is present only in 3d mode - if (caps.bMechanicalMisalignmentSupported) - { - strncat(supported, TICameraParameters::HIGH_QUALITY_MODE, REMAINING_BYTES(supported)); - strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); - strncat(supported, TICameraParameters::VIDEO_MODE, REMAINING_BYTES(supported)); - } - else // 2D mode detect: Misalignment is present only in 3d mode - { -#endif - strncat(supported, TICameraParameters::HIGH_QUALITY_MODE, REMAINING_BYTES(supported)); - strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); - strncat(supported, TICameraParameters::VIDEO_MODE, REMAINING_BYTES(supported)); - strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); - strncat(supported, TICameraParameters::HIGH_PERFORMANCE_MODE, REMAINING_BYTES(supported)); - strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); - strncat(supported, TICameraParameters::HIGH_QUALITY_ZSL_MODE, REMAINING_BYTES(supported)); -#ifdef OMAP_ENHANCEMENT_CPCAM - strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); - strncat(supported, TICameraParameters::CP_CAM_MODE, REMAINING_BYTES(supported)); -#endif - strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); - strncat(supported, TICameraParameters::ZOOM_BRACKETING, REMAINING_BYTES(supported)); -#ifndef OMAP_TUNA - } -#endif - -#ifndef OMAP_TUNA - for ( unsigned int i = 0 ; i < caps.ulBracketingModesCount; i++ ) { - p = getLUTvalue_OMXtoHAL(caps.eBracketingModes[i], mBracketingModesLUT); - if ( NULL != p ) { - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, REMAINING_BYTES(supported)); - } - strncat(supported, p, REMAINING_BYTES(supported)); - } - } -#endif - - params->set(CameraProperties::CAP_MODE_VALUES, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -#ifndef OMAP_TUNA -status_t OMXCameraAdapter::insertLayout(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char supported[MAX_PROP_VALUE_LENGTH]; - const char *p; - unsigned int i = 0; - - LOG_FUNCTION_NAME; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); -#ifndef OMAP_TUNA - for ( unsigned int i = 0 ; i < caps.ulPrvFrameLayoutCount; i++ ) { - p = getLUTvalue_OMXtoHAL(caps.ePrvFrameLayout[i], mLayoutLUT); - if ( NULL != p ) { - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat(supported, p, MAX_PROP_NAME_LENGTH); - } - } -#endif - params->set(CameraProperties::S3D_PRV_FRAME_LAYOUT_VALUES, supported); - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); -#ifndef OMAP_TUNA - for ( unsigned int i = 0 ; i < caps.ulCapFrameLayoutCount; i++ ) { - p = getLUTvalue_OMXtoHAL(caps.eCapFrameLayout[i], mLayoutLUT); - if ( NULL != p ) { - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat(supported, p, MAX_PROP_NAME_LENGTH); - } - } -#endif - params->set(CameraProperties::S3D_CAP_FRAME_LAYOUT_VALUES, supported); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} -#endif - -status_t OMXCameraAdapter::insertVideoSnapshotSupported(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - -#ifndef OMAP_TUNA - if (caps.bStillCapDuringVideoSupported) - { - params->set(CameraProperties::VIDEO_SNAPSHOT_SUPPORTED, android::CameraParameters::TRUE); - } - else - { -#endif - params->set(CameraProperties::VIDEO_SNAPSHOT_SUPPORTED, android::CameraParameters::FALSE); -#ifndef OMAP_TUNA - } -#endif - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertGBCESupported(CameraProperties::Properties* params, - const OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - -#ifndef OMAP_TUNA - if (caps.bGbceSupported) { - params->set(CameraProperties::SUPPORTED_GBCE, - android::CameraParameters::TRUE); - } else { -#endif - params->set(CameraProperties::SUPPORTED_GBCE, - android::CameraParameters::FALSE); -#ifndef OMAP_TUNA - } -#endif - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertGLBCESupported(CameraProperties::Properties* params, - const OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - -#ifndef OMAP_TUNA - if (caps.bGlbceSupported) { - params->set(CameraProperties::SUPPORTED_GLBCE, - android::CameraParameters::TRUE); - } else { -#endif - params->set(CameraProperties::SUPPORTED_GLBCE, - android::CameraParameters::FALSE); -#ifndef OMAP_TUNA - } -#endif - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertDefaults(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - char *pos, *str, *def; - char temp[MAX_PROP_VALUE_LENGTH]; - - LOG_FUNCTION_NAME; - -#ifndef OMAP_TUNA - /* If default is supported - set it, else - set first supported */ - if (strstr(params->get(CameraProperties::S3D_PRV_FRAME_LAYOUT_VALUES), DEFAULT_S3D_PREVIEW_LAYOUT)) { - strncpy(temp, DEFAULT_S3D_PREVIEW_LAYOUT, MAX_PROP_VALUE_LENGTH - 1); - } else { - strncpy(temp, params->get(CameraProperties::S3D_PRV_FRAME_LAYOUT_VALUES), - MAX_PROP_VALUE_LENGTH - 1); - if ((pos = strstr(temp, PARAM_SEP))) { - *pos = '\0'; - } - } - params->set(CameraProperties::S3D_PRV_FRAME_LAYOUT, temp); -#endif - -#ifndef OMAP_TUNA - if (!strcmp(TICameraParameters::S3D_TB_FULL, temp)) { - params->set(CameraProperties::SUPPORTED_PREVIEW_SIZES, params->get(CameraProperties::SUPPORTED_PREVIEW_TOPBOTTOM_SIZES)); - } else if (!strcmp(TICameraParameters::S3D_SS_FULL, temp)) { - params->set(CameraProperties::SUPPORTED_PREVIEW_SIZES, params->get(CameraProperties::SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES)); - } else if ((!strcmp(TICameraParameters::S3D_TB_SUBSAMPLED, temp)) - || (!strcmp(TICameraParameters::S3D_SS_SUBSAMPLED, temp))) { - params->set(CameraProperties::SUPPORTED_PREVIEW_SIZES, params->get(CameraProperties::SUPPORTED_PREVIEW_SUBSAMPLED_SIZES)); - } -#endif - -#ifndef OMAP_TUNA - /* If default is supported - set it, else - set first supported */ - if (strstr(params->get(CameraProperties::S3D_CAP_FRAME_LAYOUT_VALUES), DEFAULT_S3D_PICTURE_LAYOUT)) { - strncpy(temp, DEFAULT_S3D_PICTURE_LAYOUT, MAX_PROP_VALUE_LENGTH - 1); - } else { - strncpy(temp, params->get(CameraProperties::S3D_CAP_FRAME_LAYOUT_VALUES), - MAX_PROP_VALUE_LENGTH - 1); - if ((pos = strstr(temp, PARAM_SEP))) { - *pos = '\0'; - } - } - params->set(CameraProperties::S3D_CAP_FRAME_LAYOUT, temp); -#endif - -#ifndef OMAP_TUNA - if (!strcmp(TICameraParameters::S3D_TB_FULL, temp)) { - params->set(CameraProperties::SUPPORTED_PICTURE_SIZES, params->get(CameraProperties::SUPPORTED_PICTURE_TOPBOTTOM_SIZES)); - } else if (!strcmp(TICameraParameters::S3D_SS_FULL, temp)) { - params->set(CameraProperties::SUPPORTED_PICTURE_SIZES, params->get(CameraProperties::SUPPORTED_PICTURE_SIDEBYSIDE_SIZES)); - } else if ((!strcmp(TICameraParameters::S3D_TB_SUBSAMPLED, temp)) - || (!strcmp(TICameraParameters::S3D_SS_SUBSAMPLED, temp))) { - params->set(CameraProperties::SUPPORTED_PICTURE_SIZES, params->get(CameraProperties::SUPPORTED_PICTURE_SUBSAMPLED_SIZES)); - } -#endif - - params->set(CameraProperties::ANTIBANDING, DEFAULT_ANTIBANDING); - params->set(CameraProperties::BRIGHTNESS, DEFAULT_BRIGHTNESS); - params->set(CameraProperties::CONTRAST, DEFAULT_CONTRAST); - params->set(CameraProperties::EFFECT, DEFAULT_EFFECT); - params->set(CameraProperties::EV_COMPENSATION, DEFAULT_EV_COMPENSATION); - params->set(CameraProperties::SUPPORTED_EV_STEP, DEFAULT_EV_STEP); - params->set(CameraProperties::EXPOSURE_MODE, DEFAULT_EXPOSURE_MODE); - params->set(CameraProperties::FLASH_MODE, DEFAULT_FLASH_MODE); - pos = strstr(params->get(CameraProperties::SUPPORTED_FOCUS_MODES), DEFAULT_FOCUS_MODE_PREFERRED); - if ( NULL != pos ) - { - params->set(CameraProperties::FOCUS_MODE, DEFAULT_FOCUS_MODE_PREFERRED); - } - else - { - params->set(CameraProperties::FOCUS_MODE, DEFAULT_FOCUS_MODE); - } - params->set(CameraProperties::IPP, DEFAULT_IPP); - params->set(CameraProperties::GBCE, android::CameraParameters::FALSE); - params->set(CameraProperties::GLBCE, android::CameraParameters::FALSE); - params->set(CameraProperties::ISO_MODE, DEFAULT_ISO_MODE); - params->set(CameraProperties::JPEG_QUALITY, DEFAULT_JPEG_QUALITY); - params->set(CameraProperties::JPEG_THUMBNAIL_QUALITY, DEFAULT_THUMBNAIL_QUALITY); - params->set(CameraProperties::JPEG_THUMBNAIL_SIZE, DEFAULT_THUMBNAIL_SIZE); - params->set(CameraProperties::PICTURE_FORMAT, DEFAULT_PICTURE_FORMAT); - -#ifndef OMAP_TUNA - if (!strcmp(params->get(CameraProperties::S3D_CAP_FRAME_LAYOUT), - TICameraParameters::S3D_TB_FULL)) { - params->set(CameraProperties::PICTURE_SIZE, DEFAULT_PICTURE_TB_SIZE); - } else if (!strcmp(params->get(CameraProperties::S3D_CAP_FRAME_LAYOUT), - TICameraParameters::S3D_SS_FULL)) { - params->set(CameraProperties::PICTURE_SIZE, DEFAULT_PICTURE_SS_SIZE); - } else { -#endif - params->set(CameraProperties::PICTURE_SIZE, DEFAULT_PICTURE_SIZE); -#ifndef OMAP_TUNA - } -#endif - -#ifndef OMAP_TUNA - if (!strcmp(params->get(CameraProperties::S3D_PRV_FRAME_LAYOUT), - TICameraParameters::S3D_TB_FULL)) { - params->set(CameraProperties::PREVIEW_SIZE, DEFAULT_PREVIEW_TB_SIZE); - } else if (!strcmp(params->get(CameraProperties::S3D_PRV_FRAME_LAYOUT), - TICameraParameters::S3D_SS_FULL)) { - params->set(CameraProperties::PREVIEW_SIZE, DEFAULT_PREVIEW_SS_SIZE); - } else { -#endif - params->set(CameraProperties::PREVIEW_SIZE, DEFAULT_PREVIEW_SIZE); -#ifndef OMAP_TUNA - } -#endif - - params->set(CameraProperties::PREVIEW_FORMAT, DEFAULT_PREVIEW_FORMAT); - - /* Set default value if supported, otherwise set max supported value */ - strncpy(temp, params->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES), - MAX_PROP_VALUE_LENGTH - 1); - def = str = temp; - while (1) { - if ((pos = strstr(str, PARAM_SEP))) { - *pos = '\0'; - } - if (!strcmp(str, DEFAULT_FRAMERATE)) { - def = str; - break; - } - if (atoi(str) > atoi(def)) { - def = str; - } - if (pos == NULL) { - break; - } - str = pos + strlen(PARAM_SEP); - } - params->set(CameraProperties::PREVIEW_FRAME_RATE, def); - - params->set(CameraProperties::REQUIRED_PREVIEW_BUFS, DEFAULT_NUM_PREV_BUFS); - params->set(CameraProperties::REQUIRED_IMAGE_BUFS, DEFAULT_NUM_PIC_BUFS); - params->set(CameraProperties::SATURATION, DEFAULT_SATURATION); - params->set(CameraProperties::SCENE_MODE, DEFAULT_SCENE_MODE); - params->set(CameraProperties::SHARPNESS, DEFAULT_SHARPNESS); - params->set(CameraProperties::VSTAB, DEFAULT_VSTAB); - params->set(CameraProperties::VNF, DEFAULT_VNF); - params->set(CameraProperties::WHITEBALANCE, DEFAULT_WB); - params->set(CameraProperties::ZOOM, DEFAULT_ZOOM); - params->set(CameraProperties::MAX_FD_HW_FACES, DEFAULT_MAX_FD_HW_FACES); - params->set(CameraProperties::MAX_FD_SW_FACES, DEFAULT_MAX_FD_SW_FACES); - params->set(CameraProperties::AUTO_EXPOSURE_LOCK, DEFAULT_AE_LOCK); - params->set(CameraProperties::AUTO_WHITEBALANCE_LOCK, DEFAULT_AWB_LOCK); -#ifdef OMAP_TUNA - if(caps.tSenMounting.nSenId == 305) { - params->set(CameraProperties::FOCAL_LENGTH, DEFAULT_FOCAL_LENGTH_PRIMARY); - } else { - params->set(CameraProperties::FOCAL_LENGTH, DEFAULT_FOCAL_LENGTH_SECONDARY); - } -#endif - params->set(CameraProperties::HOR_ANGLE, DEFAULT_HOR_ANGLE); - params->set(CameraProperties::VER_ANGLE, DEFAULT_VER_ANGLE); - params->set(CameraProperties::VIDEO_SIZE, DEFAULT_VIDEO_SIZE); - params->set(CameraProperties::SENSOR_ORIENTATION, DEFAULT_SENSOR_ORIENTATION); - params->set(CameraProperties::AUTOCONVERGENCE_MODE, DEFAULT_AUTOCONVERGENCE_MODE); - params->set(CameraProperties::MANUAL_CONVERGENCE, DEFAULT_MANUAL_CONVERGENCE); -#ifndef OMAP_TUNA - params->set(CameraProperties::MECHANICAL_MISALIGNMENT_CORRECTION, DEFAULT_MECHANICAL_MISALIGNMENT_CORRECTION_MODE); -#endif - - char property[PROPERTY_VALUE_MAX]; - property_get("ro.product.manufacturer", - property, - DEFAULT_EXIF_MAKE); - property[0] = toupper(property[0]); - params->set(CameraProperties::EXIF_MAKE, property); - property_get("ro.product.model", - property, - DEFAULT_EXIF_MODEL); - property[0] = toupper(property[0]); - params->set(CameraProperties::EXIF_MODEL, property); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::insertCapabilities(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( NO_ERROR == ret ) { - ret = insertImageSizes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertPreviewSizes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertThumbSizes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertZoomStages(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertImageFormats(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertPreviewFormats(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertFramerates(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertEVs(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertISOModes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertIPPModes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertWBModes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertEffects(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertExpModes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertManualExpRanges(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertFlashModes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertSceneModes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertFocusModes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertFlickerModes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertSenMount(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertLocks(params, caps); - } - - if ( NO_ERROR == ret) { - ret = insertAreas(params, caps); - } - - if ( NO_ERROR == ret) { - ret = insertFacing(params, caps); - } - -#ifndef OMAP_TUNA - if ( NO_ERROR == ret) { - ret = insertFocalLength(params, caps); - } -#endif - - if ( NO_ERROR == ret) { - ret = insertAutoConvergenceModes(params, caps); - } - - if ( NO_ERROR == ret) { - ret = insertManualConvergenceRange(params, caps); - } - -#ifndef OMAP_TUNA - if ( NO_ERROR == ret) { - ret = insertMechanicalMisalignmentCorrection(params, caps); - } -#endif - - if ( NO_ERROR == ret) { - ret = insertRaw(params, caps); - } - - if ( NO_ERROR == ret) { - ret = insertCaptureModes(params, caps); - } - -#ifndef OMAP_TUNA - if ( NO_ERROR == ret) { - ret = insertLayout(params, caps); - } -#endif - - if ( NO_ERROR == ret) { - ret = insertVideoSnapshotSupported(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertVSTABSupported(params, caps); - } - - if ( NO_ERROR == ret) { - ret = insertVNFSupported(params, caps); - } - - //NOTE: Ensure that we always call insertDefaults after inserting the supported capabilities - //as there are checks inside insertDefaults to make sure a certain default is supported - // or not - if ( NO_ERROR == ret ) { - ret = insertVideoSizes(params, caps); - } - - if ( NO_ERROR == ret) { - ret = insertGBCESupported(params, caps); - } - - if ( NO_ERROR == ret) { - ret = insertGLBCESupported(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertDefaults(params, caps); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - - -bool OMXCameraAdapter::_checkOmxTiCap(const OMX_TI_CAPTYPE & caps) -{ -#define CAMHAL_CHECK_OMX_TI_CAP(countVar, arrayVar) \ - do { \ - const int count = static_cast(caps.countVar); \ - const int maxSize = CAMHAL_SIZE_OF_ARRAY(caps.arrayVar); \ - if ( count < 0 || count > maxSize ) \ - { \ - CAMHAL_LOGE("OMX_TI_CAPTYPE verification failed"); \ - CAMHAL_LOGE(" variable: OMX_TI_CAPTYPE::" #countVar \ - ", value: %d, max allowed: %d", \ - count, maxSize); \ - return false; \ - } \ - } while (0) - - CAMHAL_CHECK_OMX_TI_CAP(ulPreviewFormatCount, ePreviewFormats); - CAMHAL_CHECK_OMX_TI_CAP(ulImageFormatCount, eImageFormats); - CAMHAL_CHECK_OMX_TI_CAP(ulWhiteBalanceCount, eWhiteBalanceModes); - CAMHAL_CHECK_OMX_TI_CAP(ulColorEffectCount, eColorEffects); - CAMHAL_CHECK_OMX_TI_CAP(ulFlickerCount, eFlicker); - CAMHAL_CHECK_OMX_TI_CAP(ulExposureModeCount, eExposureModes); - CAMHAL_CHECK_OMX_TI_CAP(ulFocusModeCount, eFocusModes); - CAMHAL_CHECK_OMX_TI_CAP(ulSceneCount, eSceneModes); - CAMHAL_CHECK_OMX_TI_CAP(ulFlashCount, eFlashModes); - CAMHAL_CHECK_OMX_TI_CAP(ulPrvVarFPSModesCount, tPrvVarFPSModes); - CAMHAL_CHECK_OMX_TI_CAP(ulCapVarFPSModesCount, tCapVarFPSModes); -#ifndef OMAP_TUNA - CAMHAL_CHECK_OMX_TI_CAP(ulAutoConvModesCount, eAutoConvModes); - CAMHAL_CHECK_OMX_TI_CAP(ulBracketingModesCount, eBracketingModes); - CAMHAL_CHECK_OMX_TI_CAP(ulImageCodingFormatCount, eImageCodingFormat); - CAMHAL_CHECK_OMX_TI_CAP(ulPrvFrameLayoutCount, ePrvFrameLayout); - CAMHAL_CHECK_OMX_TI_CAP(ulCapFrameLayoutCount, eCapFrameLayout); -#endif - -#undef CAMHAL_CHECK_OMX_TI_CAP - - return true; -} - - -bool OMXCameraAdapter::_dumpOmxTiCap(const int sensorId, const OMX_TI_CAPTYPE & caps) -{ - if ( !_checkOmxTiCap(caps) ) - { - CAMHAL_LOGE("OMX_TI_CAPTYPE structure is invalid"); - return false; - } - - CAMHAL_LOGD("==================================================="); - CAMHAL_LOGD("---- Dumping OMX capabilities for sensor id: %d ----", sensorId); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulPreviewFormatCount = %d", int(caps.ulPreviewFormatCount)); - for ( int i = 0; i < int(caps.ulPreviewFormatCount); ++i ) - CAMHAL_LOGD(" ePreviewFormats[%2d] = %d", i, int(caps.ePreviewFormats[i])); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulImageFormatCount = %d", int(caps.ulImageFormatCount)); - for ( int i = 0; i < int(caps.ulImageFormatCount); ++i ) - CAMHAL_LOGD(" eImageFormats[%2d] = %d", i, int(caps.eImageFormats[i])); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("tPreviewResRange.nWidthMin = %d", int(caps.tPreviewResRange.nWidthMin)); - CAMHAL_LOGD("tPreviewResRange.nHeightMin = %d", int(caps.tPreviewResRange.nHeightMin)); - CAMHAL_LOGD("tPreviewResRange.nWidthMax = %d", int(caps.tPreviewResRange.nWidthMax)); - CAMHAL_LOGD("tPreviewResRange.nHeightMax = %d", int(caps.tPreviewResRange.nHeightMax)); -#ifndef OMAP_TUNA - CAMHAL_LOGD("tPreviewResRange.nMaxResInPixels = %d", int(caps.tPreviewResRange.nMaxResInPixels)); -#endif - -#ifndef OMAP_TUNA - CAMHAL_LOGD(""); - CAMHAL_LOGD("tRotatedPreviewResRange.nWidthMin = %d", int(caps.tRotatedPreviewResRange.nWidthMin)); - CAMHAL_LOGD("tRotatedPreviewResRange.nHeightMin = %d", int(caps.tRotatedPreviewResRange.nHeightMin)); - CAMHAL_LOGD("tRotatedPreviewResRange.nWidthMax = %d", int(caps.tRotatedPreviewResRange.nWidthMax)); - CAMHAL_LOGD("tRotatedPreviewResRange.nHeightMax = %d", int(caps.tRotatedPreviewResRange.nHeightMax)); - CAMHAL_LOGD("tRotatedPreviewResRange.nMaxResInPixels = %d", int(caps.tRotatedPreviewResRange.nMaxResInPixels)); -#endif - - CAMHAL_LOGD(""); - CAMHAL_LOGD("tImageResRange.nWidthMin = %d", int(caps.tImageResRange.nWidthMin)); - CAMHAL_LOGD("tImageResRange.nHeightMin = %d", int(caps.tImageResRange.nHeightMin)); - CAMHAL_LOGD("tImageResRange.nWidthMax = %d", int(caps.tImageResRange.nWidthMax)); - CAMHAL_LOGD("tImageResRange.nHeightMax = %d", int(caps.tImageResRange.nHeightMax)); -#ifndef OMAP_TUNA - CAMHAL_LOGD("tImageResRange.nMaxResInPixels = %d", int(caps.tImageResRange.nMaxResInPixels)); -#endif - - CAMHAL_LOGD(""); - CAMHAL_LOGD("tThumbResRange.nWidthMin = %d", int(caps.tThumbResRange.nWidthMin)); - CAMHAL_LOGD("tThumbResRange.nHeightMin = %d", int(caps.tThumbResRange.nHeightMin)); - CAMHAL_LOGD("tThumbResRange.nWidthMax = %d", int(caps.tThumbResRange.nWidthMax)); - CAMHAL_LOGD("tThumbResRange.nHeightMax = %d", int(caps.tThumbResRange.nHeightMax)); -#ifndef OMAP_TUNA - CAMHAL_LOGD("tThumbResRange.nMaxResInPixels = %d", int(caps.tThumbResRange.nMaxResInPixels)); -#endif - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulWhiteBalanceCount = %d", int(caps.ulWhiteBalanceCount)); - for ( int i = 0; i < int(caps.ulWhiteBalanceCount); ++i ) - CAMHAL_LOGD(" eWhiteBalanceModes[%2d] = 0x%08x", i, int(caps.eWhiteBalanceModes[i])); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulColorEffectCount = %d", int(caps.ulColorEffectCount)); - for ( int i = 0; i < int(caps.ulColorEffectCount); ++i ) - CAMHAL_LOGD(" eColorEffects[%2d] = 0x%08x", i, int(caps.eColorEffects[i])); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("xMaxWidthZoom = %d", int(caps.xMaxWidthZoom)); - CAMHAL_LOGD("xMaxHeightZoom = %d", int(caps.xMaxHeightZoom)); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulFlickerCount = %d", int(caps.ulFlickerCount)); - for ( int i = 0; i < int(caps.ulFlickerCount); ++i ) - CAMHAL_LOGD(" eFlicker[%2d] = %d", i, int(caps.eFlicker[i])); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulExposureModeCount = %d", int(caps.ulExposureModeCount)); - for ( int i = 0; i < int(caps.ulExposureModeCount); ++i ) - CAMHAL_LOGD(" eExposureModes[%2d] = 0x%08x", i, int(caps.eExposureModes[i])); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("bLensDistortionCorrectionSupported = %d", int(caps.bLensDistortionCorrectionSupported)); - CAMHAL_LOGD("bISONoiseFilterSupported = %d", int(caps.bISONoiseFilterSupported)); - CAMHAL_LOGD("xEVCompensationMin = %d", int(caps.xEVCompensationMin)); - CAMHAL_LOGD("xEVCompensationMax = %d", int(caps.xEVCompensationMax)); - CAMHAL_LOGD("nSensitivityMax = %d", int(caps.nSensitivityMax)); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulFocusModeCount = %d", int(caps.ulFocusModeCount)); - for ( int i = 0; i < int(caps.ulFocusModeCount); ++i ) - CAMHAL_LOGD(" eFocusModes[%2d] = 0x%08x", i, int(caps.eFocusModes[i])); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulSceneCount = %d", int(caps.ulSceneCount)); - for ( int i = 0; i < int(caps.ulSceneCount); ++i ) - CAMHAL_LOGD(" eSceneModes[%2d] = %d", i, int(caps.eSceneModes[i])); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulFlashCount = %d", int(caps.ulFlashCount)); - for ( int i = 0; i < int(caps.ulFlashCount); ++i ) - CAMHAL_LOGD(" eFlashModes[%2d] = %d", i, int(caps.eFlashModes[i])); - - CAMHAL_LOGD("xFramerateMin = %d", int(caps.xFramerateMin)); - CAMHAL_LOGD("xFramerateMax = %d", int(caps.xFramerateMax)); - CAMHAL_LOGD("bContrastSupported = %d", int(caps.bContrastSupported)); - CAMHAL_LOGD("bSaturationSupported = %d", int(caps.bSaturationSupported)); - CAMHAL_LOGD("bBrightnessSupported = %d", int(caps.bBrightnessSupported)); - CAMHAL_LOGD("bProcessingLevelSupported = %d", int(caps.bProcessingLevelSupported)); - CAMHAL_LOGD("bQFactorSupported = %d", int(caps.bQFactorSupported)); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulPrvVarFPSModesCount = %d", int(caps.ulPrvVarFPSModesCount)); - for ( int i = 0; i < int(caps.ulPrvVarFPSModesCount); ++i ) - { - CAMHAL_LOGD(" tPrvVarFPSModes[%d].nVarFPSMin = %d", i, int(caps.tPrvVarFPSModes[i].nVarFPSMin)); - CAMHAL_LOGD(" tPrvVarFPSModes[%d].nVarFPSMax = %d", i, int(caps.tPrvVarFPSModes[i].nVarFPSMax)); - } - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulCapVarFPSModesCount = %d", int(caps.ulCapVarFPSModesCount)); - for ( int i = 0; i < int(caps.ulCapVarFPSModesCount); ++i ) - { - CAMHAL_LOGD(" tCapVarFPSModes[%d].nVarFPSMin = %d", i, int(caps.tCapVarFPSModes[i].nVarFPSMin)); - CAMHAL_LOGD(" tCapVarFPSModes[%d].nVarFPSMax = %d", i, int(caps.tCapVarFPSModes[i].nVarFPSMax)); - } - - CAMHAL_LOGD(""); - CAMHAL_LOGD("tSenMounting.nSenId = %d", int(caps.tSenMounting.nSenId)); - CAMHAL_LOGD("tSenMounting.nRotation = %d", int(caps.tSenMounting.nRotation)); -#ifndef OMAP_TUNA - CAMHAL_LOGD("tSenMounting.bMirror = %d", int(caps.tSenMounting.bMirror)); - CAMHAL_LOGD("tSenMounting.bFlip = %d", int(caps.tSenMounting.bFlip)); - CAMHAL_LOGD("tSenMounting.eFacing = %d", int(caps.tSenMounting.eFacing)); -#endif - -#ifndef OMAP_TUNA - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulAutoConvModesCount = %d", int(caps.ulAutoConvModesCount)); - for ( int i = 0; i < int(caps.ulAutoConvModesCount); ++i ) - CAMHAL_LOGD(" eAutoConvModes[%2d] = %d", i, int(caps.eAutoConvModes[i])); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulBracketingModesCount = %d", int(caps.ulBracketingModesCount)); - for ( int i = 0; i < int(caps.ulBracketingModesCount); ++i ) - CAMHAL_LOGD(" eBracketingModes[%2d] = %d", i, int(caps.eBracketingModes[i])); -#endif - - CAMHAL_LOGD(""); -#ifndef OMAP_TUNA - CAMHAL_LOGD("bGbceSupported = %d", int(caps.bGbceSupported)); - CAMHAL_LOGD("bRawJpegSupported = %d", int(caps.bRawJpegSupported)); -#endif - -#ifndef OMAP_TUNA - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulImageCodingFormatCount = %d", int(caps.ulImageCodingFormatCount)); - for ( int i = 0; i < int(caps.ulImageCodingFormatCount); ++i ) - CAMHAL_LOGD(" eImageCodingFormat[%2d] = %d", i, int(caps.eImageCodingFormat[i])); -#endif - - CAMHAL_LOGD(""); -#ifndef OMAP_TUNA - CAMHAL_LOGD("uSenNativeResWidth = %d", int(caps.uSenNativeResWidth)); - CAMHAL_LOGD("uSenNativeResHeight = %d", int(caps.uSenNativeResHeight)); -#endif - CAMHAL_LOGD("ulAlgoAreasFocusCount = %d", int(caps.ulAlgoAreasFocusCount)); - CAMHAL_LOGD("ulAlgoAreasExposureCount = %d", int(caps.ulAlgoAreasExposureCount)); -#ifndef OMAP_TUNA - CAMHAL_LOGD("bAELockSupported = %d", int(caps.bAELockSupported)); - CAMHAL_LOGD("bAWBLockSupported = %d", int(caps.bAWBLockSupported)); - CAMHAL_LOGD("bAFLockSupported = %d", int(caps.bAFLockSupported)); - CAMHAL_LOGD("nFocalLength = %d", int(caps.nFocalLength)); -#endif - -#ifndef OMAP_TUNA - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulPrvFrameLayoutCount = %d", int(caps.ulPrvFrameLayoutCount)); - for ( int i = 0; i < int(caps.ulPrvFrameLayoutCount); ++i ) - CAMHAL_LOGD(" ePrvFrameLayout[%2d] = %d", i, int(caps.ePrvFrameLayout[i])); - - CAMHAL_LOGD(""); - CAMHAL_LOGD("ulCapFrameLayoutCount = %d", int(caps.ulCapFrameLayoutCount)); - for ( int i = 0; i < int(caps.ulCapFrameLayoutCount); ++i ) - CAMHAL_LOGD(" eCapFrameLayout[%2d] = %d", i, int(caps.eCapFrameLayout[i])); -#endif - -#ifndef OMAP_TUNA - CAMHAL_LOGD(""); - CAMHAL_LOGD("bVideoNoiseFilterSupported = %d", int(caps.bVideoNoiseFilterSupported )); - CAMHAL_LOGD("bVideoStabilizationSupported = %d", int(caps.bVideoStabilizationSupported )); - CAMHAL_LOGD("bStillCapDuringVideoSupported = %d", int(caps.bStillCapDuringVideoSupported )); - CAMHAL_LOGD("bMechanicalMisalignmentSupported = %d", int(caps.bMechanicalMisalignmentSupported)); - CAMHAL_LOGD("bFacePrioritySupported = %d", int(caps.bFacePrioritySupported )); - CAMHAL_LOGD("bRegionPrioritySupported = %d", int(caps.bRegionPrioritySupported )); - CAMHAL_LOGD("bGlbceSupported = %d", int(caps.bGlbceSupported)); -#endif - -#ifndef OMAP_TUNA - CAMHAL_LOGD(""); - CAMHAL_LOGD("nManualConvMin = %d", int(caps.nManualConvMin )); - CAMHAL_LOGD("nManualConvMax = %d", int(caps.nManualConvMax )); - CAMHAL_LOGD("nManualExpMin = %d", int(caps.nManualExpMin )); - CAMHAL_LOGD("nManualExpMax = %d", int(caps.nManualExpMax )); - CAMHAL_LOGD("nBrightnessMin = %d", int(caps.nBrightnessMin )); - CAMHAL_LOGD("nBrightnessMax = %d", int(caps.nBrightnessMax )); - CAMHAL_LOGD("nContrastMin = %d", int(caps.nContrastMin )); - CAMHAL_LOGD("nContrastMax = %d", int(caps.nContrastMax )); - CAMHAL_LOGD("nSharpnessMin = %d", int(caps.nSharpnessMin )); - CAMHAL_LOGD("nSharpnessMax = %d", int(caps.nSharpnessMax )); - CAMHAL_LOGD("nSaturationMin = %d", int(caps.nSaturationMin )); - CAMHAL_LOGD("nSaturationMax = %d", int(caps.nSaturationMax )); -#endif - - CAMHAL_LOGD(""); - CAMHAL_LOGD("------------------- end of dump -------------------"); - CAMHAL_LOGD("==================================================="); - - return true; -} - -/***************************************** - * public exposed function declarations - *****************************************/ - -status_t OMXCameraAdapter::getCaps(const int sensorId, CameraProperties::Properties* params, OMX_HANDLETYPE handle) -{ - status_t ret = NO_ERROR; - int caps_size = 0; - OMX_ERRORTYPE eError = OMX_ErrorNone; - CameraBuffer *bufferlist; - OMX_TI_CAPTYPE* caps; - OMX_TI_CONFIG_SHAREDBUFFER sharedBuffer; - MemoryManager memMgr; - - LOG_FUNCTION_NAME; - - ret = memMgr.initialize(); - if ( ret != OK ) { - CAMHAL_LOGE("MemoryManager initialization failed, error: %d", ret); - return ret; - } - - // allocate tiler (or ion) buffer for caps (size is always a multiple of 4K) - caps_size = ((sizeof(OMX_TI_CAPTYPE)+4095)/4096)*4096; - bufferlist = memMgr.allocateBufferList(0, 0, NULL, caps_size, 1); - caps = (OMX_TI_CAPTYPE*) bufferlist[0].opaque; - - if (!caps) { - CAMHAL_LOGEB("Error allocating buffer for caps %d", eError); - ret = -ENOMEM; - goto EXIT; - } - - // initialize structures to be passed to OMX Camera - OMX_INIT_STRUCT_PTR (caps, OMX_TI_CAPTYPE); - caps->nPortIndex = OMX_ALL; - - OMX_INIT_STRUCT_PTR (&sharedBuffer, OMX_TI_CONFIG_SHAREDBUFFER); - sharedBuffer.nPortIndex = OMX_ALL; - sharedBuffer.nSharedBuffSize = caps_size; - sharedBuffer.pSharedBuff = (OMX_U8 *) camera_buffer_get_omx_ptr (&bufferlist[0]); - - // Get capabilities from OMX Camera - eError = OMX_GetConfig(handle, (OMX_INDEXTYPE) OMX_TI_IndexConfigCamCapabilities, &sharedBuffer); - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error during capabilities query 0x%x", eError); - ret = UNKNOWN_ERROR; - goto EXIT; - } else { - CAMHAL_LOGDA("OMX capability query success"); - } - -#ifdef CAMERAHAL_DEBUG - _dumpOmxTiCap(sensorId, *caps); -#endif - - // Translate and insert Ducati capabilities to CameraProperties - if ( NO_ERROR == ret ) { - ret = insertCapabilities(params, *caps); - } - - CAMHAL_LOGDB("sen mount id=%u", (unsigned int)caps->tSenMounting.nSenId); -#ifndef OMAP_TUNA - CAMHAL_LOGDB("facing id=%u", (unsigned int)caps->tSenMounting.eFacing); -#endif - - EXIT: - if (bufferlist) { - memMgr.freeBufferList(bufferlist); - } - - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/OMXCameraAdapter/OMXCapture.cpp b/camera/OMXCameraAdapter/OMXCapture.cpp deleted file mode 100644 index b13572f..0000000 --- a/camera/OMXCameraAdapter/OMXCapture.cpp +++ /dev/null @@ -1,2096 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMXCapture.cpp -* -* This file contains functionality for handling image capture. -* -*/ - -#include "CameraHal.h" -#include "OMXCameraAdapter.h" -#include "ErrorUtils.h" - - -namespace Ti { -namespace Camera { - -status_t OMXCameraAdapter::setParametersCapture(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state) -{ - status_t ret = NO_ERROR; - const char *str = NULL; - int w, h; - OMX_COLOR_FORMATTYPE pixFormat; - CodingMode codingMode = mCodingMode; - const char *valstr = NULL; - int varint = 0; - OMX_TI_STEREOFRAMELAYOUTTYPE capFrmLayout; - bool inCaptureState = false; - - LOG_FUNCTION_NAME; - - OMXCameraPortParameters *cap; - cap = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - - capFrmLayout = cap->mFrameLayoutType; -#ifndef OMAP_TUNA - setParamS3D(mCameraAdapterParameters.mImagePortIndex, - params.get(TICameraParameters::KEY_S3D_CAP_FRAME_LAYOUT)); -#endif - if (capFrmLayout != cap->mFrameLayoutType) { - mPendingCaptureSettings |= SetFormat; - } - - params.getPictureSize(&w, &h); - - if ( ( w != ( int ) cap->mWidth ) || - ( h != ( int ) cap->mHeight ) ) - { - mPendingCaptureSettings |= SetFormat; - } - - cap->mWidth = w; - cap->mHeight = h; - //TODO: Support more pixelformats - //cap->mStride = 2; - - CAMHAL_LOGVB("Image: cap.mWidth = %d", (int)cap->mWidth); - CAMHAL_LOGVB("Image: cap.mHeight = %d", (int)cap->mHeight); - - if ((valstr = params.getPictureFormat()) != NULL) { - if (strcmp(valstr, android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { - CAMHAL_LOGDA("CbYCrY format selected"); - pixFormat = OMX_COLOR_FormatCbYCrY; - mPictureFormatFromClient = android::CameraParameters::PIXEL_FORMAT_YUV422I; - } else if(strcmp(valstr, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { - CAMHAL_LOGDA("YUV420SP format selected"); - pixFormat = OMX_COLOR_FormatYUV420SemiPlanar; - mPictureFormatFromClient = android::CameraParameters::PIXEL_FORMAT_YUV420SP; - } else if(strcmp(valstr, android::CameraParameters::PIXEL_FORMAT_RGB565) == 0) { - CAMHAL_LOGDA("RGB565 format selected"); - pixFormat = OMX_COLOR_Format16bitRGB565; - mPictureFormatFromClient = android::CameraParameters::PIXEL_FORMAT_RGB565; - } else if (strcmp(valstr, android::CameraParameters::PIXEL_FORMAT_JPEG) == 0) { - CAMHAL_LOGDA("JPEG format selected"); - pixFormat = OMX_COLOR_FormatUnused; - codingMode = CodingJPEG; - mPictureFormatFromClient = android::CameraParameters::PIXEL_FORMAT_JPEG; - } else if (strcmp(valstr, TICameraParameters::PIXEL_FORMAT_JPS) == 0) { - CAMHAL_LOGDA("JPS format selected"); - pixFormat = OMX_COLOR_FormatUnused; - codingMode = CodingJPS; - mPictureFormatFromClient = TICameraParameters::PIXEL_FORMAT_JPS; - } else if (strcmp(valstr, TICameraParameters::PIXEL_FORMAT_MPO) == 0) { - CAMHAL_LOGDA("MPO format selected"); - pixFormat = OMX_COLOR_FormatUnused; - codingMode = CodingMPO; - mPictureFormatFromClient = TICameraParameters::PIXEL_FORMAT_MPO; - } else if (strcmp(valstr, android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB) == 0) { - CAMHAL_LOGDA("RAW Picture format selected"); - pixFormat = OMX_COLOR_FormatRawBayer10bit; - mPictureFormatFromClient = android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB; - } else { - CAMHAL_LOGEA("Invalid format, JPEG format selected as default"); - pixFormat = OMX_COLOR_FormatUnused; - codingMode = CodingJPEG; - mPictureFormatFromClient = NULL; - } - } else { - CAMHAL_LOGEA("Picture format is NULL, defaulting to JPEG"); - pixFormat = OMX_COLOR_FormatUnused; - codingMode = CodingJPEG; - mPictureFormatFromClient = NULL; - } - -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING - mRawCapture = false; - mYuvCapture = false; - - valstr = params.get(TICameraParameters::KEY_CAP_MODE); - if ( (!valstr || strcmp(valstr, TICameraParameters::HIGH_QUALITY_MODE) == 0) && - access(kRawImagesOutputDirPath, F_OK) != -1 ) { - mRawCapture = true; - } - - if (mRawCapture && (access(kYuvImagesOutputDirPath, F_OK) != -1)) { - pixFormat = OMX_COLOR_FormatCbYCrY; - mYuvCapture = true; - } -#endif - // JPEG capture is not supported in video mode by OMX Camera - // Set capture format to yuv422i...jpeg encode will - // be done on A9 - valstr = params.get(TICameraParameters::KEY_CAP_MODE); - if ( (valstr && !strcmp(valstr, (const char *) TICameraParameters::VIDEO_MODE)) && - (pixFormat == OMX_COLOR_FormatUnused) ) { - CAMHAL_LOGDA("Capturing in video mode...selecting yuv422i"); - pixFormat = OMX_COLOR_FormatCbYCrY; - } - - if (pixFormat != cap->mColorFormat || codingMode != mCodingMode) { - mPendingCaptureSettings |= SetFormat; - cap->mColorFormat = pixFormat; - mCodingMode = codingMode; - } - -#ifdef OMAP_ENHANCEMENT - str = params.get(TICameraParameters::KEY_TEMP_BRACKETING); - if ( ( str != NULL ) && - ( strcmp(str, android::CameraParameters::TRUE) == 0 ) ) { - - if ( !mBracketingSet ) { - mPendingCaptureSettings |= SetExpBracket; - } - - mBracketingSet = true; - } else { - - if ( mBracketingSet ) { - mPendingCaptureSettings |= SetExpBracket; - } - - mBracketingSet = false; - } - - if ( (str = params.get(TICameraParameters::KEY_EXP_BRACKETING_RANGE)) != NULL ) { - parseExpRange(str, mExposureBracketingValues, NULL, - mExposureGainBracketingModes, - EXP_BRACKET_RANGE, mExposureBracketingValidEntries); -#ifndef OMAP_TUNA - if (mCapMode == OMXCameraAdapter::CP_CAM) { - mExposureBracketMode = OMX_BracketVectorShot; - } else { -#endif - mExposureBracketMode = OMX_BracketExposureRelativeInEV; -#ifndef OMAP_TUNA - } -#endif - mPendingCaptureSettings |= SetExpBracket; - } else if ( (str = params.get(TICameraParameters::KEY_EXP_GAIN_BRACKETING_RANGE)) != NULL) { - parseExpRange(str, mExposureBracketingValues, mExposureGainBracketingValues, - mExposureGainBracketingModes, - EXP_BRACKET_RANGE, mExposureBracketingValidEntries); -#ifndef OMAP_TUNA - if (mCapMode == OMXCameraAdapter::CP_CAM) { - mExposureBracketMode = OMX_BracketVectorShot; - } else { -#endif - mExposureBracketMode = OMX_BracketExposureGainAbsolute; -#ifndef OMAP_TUNA - } -#endif - mPendingCaptureSettings |= SetExpBracket; - } else { - // if bracketing was previously set...we set again before capturing to clear - if (mExposureBracketingValidEntries) { - mPendingCaptureSettings |= SetExpBracket; - mExposureBracketingValidEntries = 0; - } - } - - str = params.get(TICameraParameters::KEY_ZOOM_BRACKETING_RANGE); - if ( NULL != str ) { - parseExpRange(str, mZoomBracketingValues, NULL, NULL, - ZOOM_BRACKET_RANGE, mZoomBracketingValidEntries); - mCurrentZoomBracketing = 0; - mZoomBracketingEnabled = true; - } else { - if (mZoomBracketingValidEntries) { - mZoomBracketingValidEntries = 0; - } - mZoomBracketingEnabled = false; - } -#endif - - // Flush config queue - // If TRUE: Flush queue and abort processing before enqueing - valstr = params.get(TICameraParameters::KEY_FLUSH_SHOT_CONFIG_QUEUE); - if ( NULL != valstr ) { - if ( 0 == strcmp(valstr, android::CameraParameters::TRUE) ) { - mFlushShotConfigQueue = true; - } else if ( 0 == strcmp(valstr, android::CameraParameters::FALSE) ) { - mFlushShotConfigQueue = false; - } else { - CAMHAL_LOGE("Missing flush shot config parameter. Will use current (%s)", - mFlushShotConfigQueue ? "true" : "false"); - } - } - - if ( params.getInt(android::CameraParameters::KEY_ROTATION) != -1 ) - { - if (params.getInt(android::CameraParameters::KEY_ROTATION) != (int) mPictureRotation) { - mPendingCaptureSettings |= SetRotation; - } - mPictureRotation = params.getInt(android::CameraParameters::KEY_ROTATION); - } - else - { - if (mPictureRotation) mPendingCaptureSettings |= SetRotation; - mPictureRotation = 0; - } - - CAMHAL_LOGVB("Picture Rotation set %d", mPictureRotation); - -#ifdef OMAP_ENHANCEMENT - // Read Sensor Orientation and set it based on perating mode - varint = params.getInt(TICameraParameters::KEY_SENSOR_ORIENTATION); - if ( varint != -1 ) - { - mSensorOrientation = varint; - if (mSensorOrientation == 270 ||mSensorOrientation==90) - { - CAMHAL_LOGEA(" Orientation is 270/90. So setting counter rotation to Ducati"); - mSensorOrientation +=180; - mSensorOrientation%=360; - } - } - else - { - mSensorOrientation = 0; - } - - CAMHAL_LOGVB("Sensor Orientation set : %d", mSensorOrientation); -#endif - -#ifdef OMAP_ENHANCEMENT_BURST_CAPTURE - varint = params.getInt(TICameraParameters::KEY_BURST); - if ( varint >= 1 ) - { - if (varint != (int) mBurstFrames) { - mPendingCaptureSettings |= SetBurst; - } - mBurstFrames = varint; - } - else - { - if (mBurstFrames != 1) mPendingCaptureSettings |= SetBurst; - mBurstFrames = 1; - } - - CAMHAL_LOGVB("Burst Frames set %d", mBurstFrames); -#endif - - varint = params.getInt(android::CameraParameters::KEY_JPEG_QUALITY); - if ( varint >= MIN_JPEG_QUALITY && varint <= MAX_JPEG_QUALITY ) { - if ((unsigned int)varint != mPictureQuality) { - mPendingCaptureSettings |= SetQuality; - mPictureQuality = varint; - } - } else { - if (mPictureQuality != MAX_JPEG_QUALITY) { - mPendingCaptureSettings |= SetQuality; - mPictureQuality = MAX_JPEG_QUALITY; - } - } - - CAMHAL_LOGVB("Picture Quality set %d", mPictureQuality); - - varint = params.getInt(android::CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH); - if ( varint >= 0 ) { - if ((unsigned int)varint != mThumbWidth) { - mPendingCaptureSettings |= SetThumb; - mThumbWidth = varint; - } - } else { - if (mThumbWidth != DEFAULT_THUMB_WIDTH) { - mPendingCaptureSettings |= SetThumb; - mThumbWidth = DEFAULT_THUMB_WIDTH; - } - } - - CAMHAL_LOGVB("Picture Thumb width set %d", mThumbWidth); - - varint = params.getInt(android::CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT); - if ( varint >= 0 ) { - if ((unsigned int)varint != mThumbHeight) { - mPendingCaptureSettings |= SetThumb; - mThumbHeight = varint; - } - } else { - if (mThumbHeight != DEFAULT_THUMB_HEIGHT) { - mPendingCaptureSettings |= SetThumb; - mThumbHeight = DEFAULT_THUMB_HEIGHT; - } - } - - CAMHAL_LOGVB("Picture Thumb height set %d", mThumbHeight); - - varint = params.getInt(android::CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY); - if ( varint >= MIN_JPEG_QUALITY && varint <= MAX_JPEG_QUALITY ) { - if ((unsigned int)varint != mThumbQuality) { - mPendingCaptureSettings |= SetThumb; - mThumbQuality = varint; - } - } else { - if (mThumbQuality != MAX_JPEG_QUALITY) { - mPendingCaptureSettings |= SetThumb; - mThumbQuality = MAX_JPEG_QUALITY; - } - } - - CAMHAL_LOGDB("Thumbnail Quality set %d", mThumbQuality); - - if (mFirstTimeInit) { - mPendingCaptureSettings = ECapturesettingsAll; - } - - // we are already capturing and in cpcam mode...just need to enqueue - // shots - inCaptureState = (CAPTURE_ACTIVE & mAdapterState) && (CAPTURE_ACTIVE & mNextState); - if ((mPendingCaptureSettings & ~SetExpBracket) && !inCaptureState) { - disableReprocess(); - disableImagePort(); - if ( NULL != mReleaseImageBuffersCallback ) { - mReleaseImageBuffersCallback(mReleaseData); - } - if (mPendingCaptureSettings & SetFormat) { - mPendingCaptureSettings &= ~SetFormat; - ret = setFormat(OMX_CAMERA_PORT_IMAGE_OUT_IMAGE, *cap); - if ( ret != NO_ERROR ) { - CAMHAL_LOGEB("setFormat() failed %d", ret); - LOG_FUNCTION_NAME_EXIT; - return ret; - } - } - } - - cap = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoPortIndex]; - cap->mWidth = params.getInt(TICameraParameters::RAW_WIDTH); - cap->mHeight = params.getInt(TICameraParameters::RAW_HEIGHT); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::getPictureBufferSize(CameraFrame &frame, size_t bufferCount) -{ - status_t ret = NO_ERROR; - OMXCameraPortParameters *imgCaptureData = NULL; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - LOG_FUNCTION_NAME; - - if ( NO_ERROR == ret ) - { - imgCaptureData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - - imgCaptureData->mNumBufs = bufferCount; - - // check if image port is already configured... - // if it already configured then we don't have to query again - if (!mCaptureConfigured) { - ret = setFormat(OMX_CAMERA_PORT_IMAGE_OUT_IMAGE, *imgCaptureData); - } - - if ( ret == NO_ERROR ) - { - frame.mLength = imgCaptureData->mBufSize; - frame.mWidth = imgCaptureData->mWidth; - frame.mHeight = imgCaptureData->mHeight; - frame.mAlignment = imgCaptureData->mStride; - CAMHAL_LOGDB("getPictureBufferSize: width:%u height:%u alignment:%u length:%u", - frame.mWidth, frame.mHeight, frame.mAlignment, frame.mLength); - } - else - { - CAMHAL_LOGEB("setFormat() failed 0x%x", ret); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -int OMXCameraAdapter::getBracketingValueMode(const char *a, const char *b) const -{ - BracketingValueMode bvm = BracketingValueAbsolute; - - if ( (NULL != b) && - (NULL != a) && - (a < b) && - ( (NULL != memchr(a, '+', b - a)) || - (NULL != memchr(a, '-', b - a)) ) ) { - bvm = BracketingValueRelative; - } - return bvm; -} - -status_t OMXCameraAdapter::parseExpRange(const char *rangeStr, - int *expRange, - int *gainRange, - int *expGainModes, - size_t count, - size_t &validEntries) -{ - status_t ret = NO_ERROR; - char *end = NULL; - const char *startPtr = NULL; - size_t i = 0; - - LOG_FUNCTION_NAME; - - if ( NULL == rangeStr ){ - return -EINVAL; - } - - if ( NULL == expRange ){ - return -EINVAL; - } - - if ( NO_ERROR == ret ) { - startPtr = rangeStr; - do { - // Relative Exposure example: "-30,-10, 0, 10, 30" - // Absolute Gain ex. (exposure,gain) pairs: "(100,300),(200,300),(400,300),(800,300),(1600,300)" - // Relative Gain ex. (exposure,gain) pairs: "(-30,+0),(-10, +0),(+0,+0),(+10,+0),(+30,+0)" - // Forced relative Exposure example: "-30F,-10F, 0F, 10F, 30F" - // Forced absolute Gain ex. (exposure,gain) pairs: "(100,300)F,(200,300)F,(400,300)F,(800,300)F,(1600,300)F" - // Forced relative Gain ex. (exposure,gain) pairs: "(-30,+0)F,(-10, +0)F,(+0,+0)F,(+10,+0)F,(+30,+0)F" - - // skip '(' and ',' - while ((*startPtr == '(') || (*startPtr == ',')) startPtr++; - - expRange[i] = (int)strtol(startPtr, &end, 10); - - if (expGainModes) { - // if gainRange is given rangeStr should be (exposure, gain) pair - if (gainRange) { - int bvm_exp = getBracketingValueMode(startPtr, end); - startPtr = end + 1; // for the ',' - gainRange[i] = (int)strtol(startPtr, &end, 10); - - if (BracketingValueAbsolute == bvm_exp) { - expGainModes[i] = getBracketingValueMode(startPtr, end); - } else { - expGainModes[i] = bvm_exp; - } - } else { - expGainModes[i] = BracketingValueCompensation; - } - } - startPtr = end; - - // skip ')' - while (*startPtr == ')') startPtr++; - - // Check for "forced" key - if (expGainModes) { - while ((*startPtr == 'F') || (*startPtr == 'f')) { - if ( BracketingValueAbsolute == expGainModes[i] ) { - expGainModes[i] = BracketingValueAbsoluteForced; - } else if ( BracketingValueRelative == expGainModes[i] ) { - expGainModes[i] = BracketingValueRelativeForced; - } else if ( BracketingValueCompensation == expGainModes[i] ) { - expGainModes[i] = BracketingValueCompensationForced; - } else { - CAMHAL_LOGE("Unexpected old mode 0x%x", expGainModes[i]); - } - startPtr++; - } - } - - i++; - - } while ((startPtr[0] != '\0') && (i < count)); - validEntries = i; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::doExposureBracketing(int *evValues, - int *evValues2, - int *evModes2, - size_t evCount, - size_t frameCount, - bool flush, - OMX_BRACKETMODETYPE bracketMode) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = -EINVAL; - } - - if ( NULL == evValues ) { - CAMHAL_LOGEA("Exposure compensation values pointer is invalid"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) { -#ifndef OMAP_TUNA - if (bracketMode == OMX_BracketVectorShot) { - ret = setVectorShot(evValues, evValues2, evModes2, evCount, frameCount, flush, bracketMode); - } else { -#endif - ret = setExposureBracketing(evValues, evValues2, evCount, frameCount, bracketMode); -#ifndef OMAP_TUNA - } -#endif - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -#ifndef OMAP_TUNA -status_t OMXCameraAdapter::setVectorStop(bool toPreview) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_TI_CONFIG_VECTSHOTSTOPMETHODTYPE vecShotStop; - - - LOG_FUNCTION_NAME; - - OMX_INIT_STRUCT_PTR(&vecShotStop, OMX_TI_CONFIG_VECTSHOTSTOPMETHODTYPE); - - vecShotStop.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - if (toPreview) { - vecShotStop.eStopMethod = OMX_TI_VECTSHOTSTOPMETHOD_GOTO_PREVIEW; - } else { - vecShotStop.eStopMethod = OMX_TI_VECTSHOTSTOPMETHOD_WAIT_IN_CAPTURE; - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexConfigVectShotStopMethod, - &vecShotStop); - if (OMX_ErrorNone != eError) { - CAMHAL_LOGEB("Error while configuring bracket shot 0x%x", eError); - } else { - CAMHAL_LOGDA("Bracket shot configured successfully"); - } - - LOG_FUNCTION_NAME_EXIT; - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::initVectorShot() -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_CAPTUREMODETYPE expCapMode; - OMX_CONFIG_EXTCAPTUREMODETYPE extExpCapMode; - - LOG_FUNCTION_NAME; - - if (NO_ERROR == ret) { - OMX_INIT_STRUCT_PTR (&expCapMode, OMX_CONFIG_CAPTUREMODETYPE); - expCapMode.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - - expCapMode.bFrameLimited = OMX_FALSE; - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCaptureMode, - &expCapMode); - if (OMX_ErrorNone != eError) { - CAMHAL_LOGEB("Error while configuring capture mode 0x%x", eError); - goto exit; - } else { - CAMHAL_LOGDA("Camera capture mode configured successfully"); - } - } - - if (NO_ERROR == ret) { - OMX_INIT_STRUCT_PTR (&extExpCapMode, OMX_CONFIG_EXTCAPTUREMODETYPE); - extExpCapMode.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - - extExpCapMode.bEnableBracketing = OMX_TRUE; - extExpCapMode.tBracketConfigType.eBracketMode = OMX_BracketVectorShot; - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_IndexConfigExtCaptureMode, - &extExpCapMode); - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while configuring extended capture mode 0x%x", eError); - goto exit; - } else { - CAMHAL_LOGDA("Extended camera capture mode configured successfully"); - } - } - -#ifndef OMAP_TUNA - if (NO_ERROR == ret) { - // set vector stop method to stop in capture - ret = setVectorStop(false); - } -#endif - - exit: - LOG_FUNCTION_NAME_EXIT; - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::setVectorShot(int *evValues, - int *evValues2, - int *evModes2, - size_t evCount, - size_t frameCount, - bool flush, - OMX_BRACKETMODETYPE bracketMode) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_TI_CONFIG_ENQUEUESHOTCONFIGS enqueueShotConfigs; - OMX_TI_CONFIG_QUERYAVAILABLESHOTS queryAvailableShots; - bool doFlush = flush; - - LOG_FUNCTION_NAME; - - OMX_INIT_STRUCT_PTR(&enqueueShotConfigs, OMX_TI_CONFIG_ENQUEUESHOTCONFIGS); - OMX_INIT_STRUCT_PTR(&queryAvailableShots, OMX_TI_CONFIG_QUERYAVAILABLESHOTS); - - queryAvailableShots.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexConfigQueryAvailableShots, - &queryAvailableShots); - if (OMX_ErrorNone != eError) { - CAMHAL_LOGE("Error getting available shots 0x%x", eError); - goto exit; - } else { - CAMHAL_LOGD("AVAILABLE SHOTS: %d", queryAvailableShots.nAvailableShots); - if (queryAvailableShots.nAvailableShots < evCount) { - // TODO(XXX): Need to implement some logic to handle this error - CAMHAL_LOGE("Not enough available shots to fulfill this queue request"); - ret = -ENOSPC; - goto exit; - } - } - - for ( unsigned int confID = 0; confID < evCount; ) { - unsigned int i; - for ( i = 0 ; (i < ARRAY_SIZE(enqueueShotConfigs.nShotConfig)) && (confID < evCount); i++, confID++ ) { - CAMHAL_LOGD("%2u: (%7d,%4d) mode: %d", confID, evValues[confID], evValues2[confID], evModes2[confID]); - enqueueShotConfigs.nShotConfig[i].nConfigId = confID; - enqueueShotConfigs.nShotConfig[i].nFrames = 1; - if ( (BracketingValueCompensation == evModes2[confID]) || - (BracketingValueCompensationForced == evModes2[confID]) ) { - // EV compensation - enqueueShotConfigs.nShotConfig[i].nEC = evValues[confID]; - enqueueShotConfigs.nShotConfig[i].nExp = 0; - enqueueShotConfigs.nShotConfig[i].nGain = 0; - } else { - // exposure,gain pair - enqueueShotConfigs.nShotConfig[i].nEC = 0; - enqueueShotConfigs.nShotConfig[i].nExp = evValues[confID]; - enqueueShotConfigs.nShotConfig[i].nGain = evValues2[confID]; - } - enqueueShotConfigs.nShotConfig[i].eExpGainApplyMethod = OMX_TI_EXPGAINAPPLYMETHOD_ABSOLUTE; - switch (evModes2[confID]) { - case BracketingValueAbsolute: // (exp,gain) pairs directly program sensor values - default : - enqueueShotConfigs.nShotConfig[i].eExpGainApplyMethod = OMX_TI_EXPGAINAPPLYMETHOD_ABSOLUTE; - break; - case BracketingValueRelative: // (exp,gain) pairs relative to AE settings and constraints - case BracketingValueCompensation: // EV compensation relative to AE settings and constraints - enqueueShotConfigs.nShotConfig[i].eExpGainApplyMethod = OMX_TI_EXPGAINAPPLYMETHOD_RELATIVE; - break; - case BracketingValueAbsoluteForced: // (exp,gain) pairs directly program sensor values - // are forced over constraints due to flicker, etc. - enqueueShotConfigs.nShotConfig[i].eExpGainApplyMethod = OMX_TI_EXPGAINAPPLYMETHOD_FORCE_ABSOLUTE; - break; - case BracketingValueRelativeForced: // (exp, gain) pairs relative to AE settings AND settings - case BracketingValueCompensationForced: // EV compensation relative to AE settings and constraints - // are forced over constraints due to flicker, etc. - enqueueShotConfigs.nShotConfig[i].eExpGainApplyMethod = OMX_TI_EXPGAINAPPLYMETHOD_FORCE_RELATIVE; - break; - } - enqueueShotConfigs.nShotConfig[i].bNoSnapshot = OMX_FALSE; // TODO: Make this configurable - } - - // Repeat last exposure and again - if ((confID == evCount) && (evCount > 0) && (frameCount > evCount) && (0 != i)) { - enqueueShotConfigs.nShotConfig[i-1].nFrames = frameCount - evCount; - } - - enqueueShotConfigs.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - enqueueShotConfigs.bFlushQueue = doFlush ? OMX_TRUE : OMX_FALSE; - enqueueShotConfigs.nNumConfigs = i; - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_TI_IndexConfigEnqueueShotConfigs, - &enqueueShotConfigs); - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while configuring bracket shot 0x%x", eError); - goto exit; - } else { - CAMHAL_LOGDA("Bracket shot configured successfully"); - } - // Flush only first time - doFlush = false; - } - - exit: - LOG_FUNCTION_NAME_EXIT; - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} -#endif - -status_t OMXCameraAdapter::setExposureBracketing(int *evValues, - int *evValues2, - size_t evCount, - size_t frameCount, - OMX_BRACKETMODETYPE bracketMode) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_CAPTUREMODETYPE expCapMode; - OMX_CONFIG_EXTCAPTUREMODETYPE extExpCapMode; - - LOG_FUNCTION_NAME; - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR (&expCapMode, OMX_CONFIG_CAPTUREMODETYPE); - expCapMode.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - - /// If frameCount>0 but evCount<=0, then this is the case of HQ burst. - //Otherwise, it is normal HQ capture - ///If frameCount>0 and evCount>0 then this is the cause of HQ Exposure bracketing. - if ( 0 == evCount && 0 == frameCount ) - { - expCapMode.bFrameLimited = OMX_FALSE; - } - else - { - expCapMode.bFrameLimited = OMX_TRUE; - expCapMode.nFrameLimit = frameCount; - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCaptureMode, - &expCapMode); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring capture mode 0x%x", eError); - } - else - { - CAMHAL_LOGDA("Camera capture mode configured successfully"); - } - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR (&extExpCapMode, OMX_CONFIG_EXTCAPTUREMODETYPE); - extExpCapMode.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - - if ( 0 == evCount ) - { - extExpCapMode.bEnableBracketing = OMX_FALSE; - } - else - { - extExpCapMode.bEnableBracketing = OMX_TRUE; - extExpCapMode.tBracketConfigType.eBracketMode = bracketMode; - extExpCapMode.tBracketConfigType.nNbrBracketingValues = evCount - 1; - } - - for ( unsigned int i = 0 ; i < evCount ; i++ ) - { -#ifndef OMAP_TUNA - if (bracketMode == OMX_BracketExposureGainAbsolute) { - extExpCapMode.tBracketConfigType.nBracketValues[i] = evValues[i]; - extExpCapMode.tBracketConfigType.nBracketValues2[i] = evValues2[i]; - } else { -#endif - // assuming OMX_BracketExposureRelativeInEV - extExpCapMode.tBracketConfigType.nBracketValues[i] = ( evValues[i] * ( 1 << Q16_OFFSET ) ) / 10; -#ifndef OMAP_TUNA - } -#endif - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_IndexConfigExtCaptureMode, - &extExpCapMode); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring extended capture mode 0x%x", eError); - } - else - { - CAMHAL_LOGDA("Extended camera capture mode configured successfully"); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setShutterCallback(bool enabled) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_CALLBACKREQUESTTYPE shutterRequstCallback; - - LOG_FUNCTION_NAME; - - if ( OMX_StateExecuting != mComponentState ) - { - CAMHAL_LOGEA("OMX component not in executing state"); - ret = -1; - } - - if ( NO_ERROR == ret ) - { - - OMX_INIT_STRUCT_PTR (&shutterRequstCallback, OMX_CONFIG_CALLBACKREQUESTTYPE); - shutterRequstCallback.nPortIndex = OMX_ALL; - - if ( enabled ) - { - shutterRequstCallback.bEnable = OMX_TRUE; - shutterRequstCallback.nIndex = ( OMX_INDEXTYPE ) OMX_TI_IndexConfigShutterCallback; - CAMHAL_LOGDA("Enabling shutter callback"); - } - else - { - shutterRequstCallback.bEnable = OMX_FALSE; - shutterRequstCallback.nIndex = ( OMX_INDEXTYPE ) OMX_TI_IndexConfigShutterCallback; - CAMHAL_LOGDA("Disabling shutter callback"); - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_IndexConfigCallbackRequest, - &shutterRequstCallback); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error registering shutter callback 0x%x", eError); - ret = -1; - } - else - { - CAMHAL_LOGDB("Shutter callback for index 0x%x registered successfully", - OMX_TI_IndexConfigShutterCallback); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::doBracketing(OMX_BUFFERHEADERTYPE *pBuffHeader, - CameraFrame::FrameType typeOfFrame) -{ - status_t ret = NO_ERROR; - int currentBufferIdx, nextBufferIdx; - OMXCameraPortParameters * imgCaptureData = NULL; - - LOG_FUNCTION_NAME; - - imgCaptureData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - - if ( OMX_StateExecuting != mComponentState ) - { - CAMHAL_LOGEA("OMX component is not in executing state"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) - { - CameraBuffer *buffer = (CameraBuffer *)pBuffHeader->pAppPrivate; - currentBufferIdx = buffer->index; - - if ( currentBufferIdx >= imgCaptureData->mNumBufs) - { - CAMHAL_LOGEB("Invalid bracketing buffer index 0x%x", currentBufferIdx); - ret = -EINVAL; - } - } - - if ( NO_ERROR == ret ) - { - mBracketingBuffersQueued[currentBufferIdx] = false; - mBracketingBuffersQueuedCount--; - - if ( 0 >= mBracketingBuffersQueuedCount ) - { - nextBufferIdx = ( currentBufferIdx + 1 ) % imgCaptureData->mNumBufs; - mBracketingBuffersQueued[nextBufferIdx] = true; - mBracketingBuffersQueuedCount++; - mLastBracetingBufferIdx = nextBufferIdx; - setFrameRefCount((CameraBuffer *)imgCaptureData->mBufferHeader[nextBufferIdx]->pAppPrivate, typeOfFrame, 1); - returnFrame((CameraBuffer *)imgCaptureData->mBufferHeader[nextBufferIdx]->pAppPrivate, typeOfFrame); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::sendBracketFrames(size_t &framesSent) -{ - status_t ret = NO_ERROR; - int currentBufferIdx; - OMXCameraPortParameters * imgCaptureData = NULL; - - LOG_FUNCTION_NAME; - - imgCaptureData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - framesSent = 0; - - if ( OMX_StateExecuting != mComponentState ) - { - CAMHAL_LOGEA("OMX component is not in executing state"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) - { - - currentBufferIdx = mLastBracetingBufferIdx; - do - { - currentBufferIdx++; - currentBufferIdx %= imgCaptureData->mNumBufs; - if (!mBracketingBuffersQueued[currentBufferIdx] ) - { - CameraFrame cameraFrame; - sendCallBacks(cameraFrame, - imgCaptureData->mBufferHeader[currentBufferIdx], - imgCaptureData->mImageType, - imgCaptureData); - framesSent++; - } - } while ( currentBufferIdx != mLastBracetingBufferIdx ); - - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::startBracketing(int range) -{ - status_t ret = NO_ERROR; - OMXCameraPortParameters * imgCaptureData = NULL; - - LOG_FUNCTION_NAME; - - imgCaptureData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - - if ( OMX_StateExecuting != mComponentState ) - { - CAMHAL_LOGEA("OMX component is not in executing state"); - ret = -EINVAL; - } - - { - android::AutoMutex lock(mBracketingLock); - - if ( mBracketingEnabled ) - { - return ret; - } - } - - if ( 0 == imgCaptureData->mNumBufs ) - { - CAMHAL_LOGEB("Image capture buffers set to %d", imgCaptureData->mNumBufs); - ret = -EINVAL; - } - - if ( mPending3Asettings ) - apply3Asettings(mParameters3A); - - if ( NO_ERROR == ret ) - { - android::AutoMutex lock(mBracketingLock); - - mBracketingRange = range; - mBracketingBuffersQueued = new bool[imgCaptureData->mNumBufs]; - if ( NULL == mBracketingBuffersQueued ) - { - CAMHAL_LOGEA("Unable to allocate bracketing management structures"); - ret = -1; - } - - if ( NO_ERROR == ret ) - { - mBracketingBuffersQueuedCount = imgCaptureData->mNumBufs; - mBurstFramesAccum = imgCaptureData->mNumBufs; - mLastBracetingBufferIdx = mBracketingBuffersQueuedCount - 1; - - for ( int i = 0 ; i < imgCaptureData->mNumBufs ; i++ ) - { - mBracketingBuffersQueued[i] = true; - } - - } - } - - if ( NO_ERROR == ret ) - { - CachedCaptureParameters* cap_params = cacheCaptureParameters(); - ret = startImageCapture(true, cap_params); - delete cap_params; - { - android::AutoMutex lock(mBracketingLock); - - if ( NO_ERROR == ret ) - { - mBracketingEnabled = true; - } - else - { - mBracketingEnabled = false; - } - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::stopBracketing() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - ret = stopImageCapture(); - - android::AutoMutex lock(mBracketingLock); - - if ( NULL != mBracketingBuffersQueued ) - { - delete [] mBracketingBuffersQueued; - } - - mBracketingBuffersQueued = NULL; - mBracketingEnabled = false; - mBracketingBuffersQueuedCount = 0; - mLastBracetingBufferIdx = 0; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::startImageCapture(bool bracketing, CachedCaptureParameters* capParams) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXCameraPortParameters * capData = NULL; - OMX_CONFIG_BOOLEANTYPE bOMX; - size_t bracketingSent = 0; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mImageCaptureLock); - - if(!mCaptureConfigured) - { - ///Image capture was cancelled before we could start - return NO_ERROR; - } - - if ( 0 != mStartCaptureSem.Count() ) - { - CAMHAL_LOGEB("Error mStartCaptureSem semaphore count %d", mStartCaptureSem.Count()); - return NO_INIT; - } - - if ( !bracketing ) { - if ((getNextState() & (CAPTURE_ACTIVE|BRACKETING_ACTIVE)) == 0) { - CAMHAL_LOGDA("trying starting capture when already canceled"); - return NO_ERROR; - } - } - - if (!capParams) { - CAMHAL_LOGE("Invalid cached parameters sent!"); - return BAD_VALUE; - } - - // Camera framework doesn't expect face callbacks once capture is triggered - pauseFaceDetection(true); - - //During bracketing image capture is already active - { - android::AutoMutex lock(mBracketingLock); - if ( mBracketingEnabled ) - { - //Stop bracketing, activate normal burst for the remaining images - mBracketingEnabled = false; - ret = sendBracketFrames(bracketingSent); - - // Check if we accumulated enough buffers - if ( bracketingSent < ( mBracketingRange - 1 ) ) - { - mCapturedFrames = mBracketingRange + ( ( mBracketingRange - 1 ) - bracketingSent ); - } - else - { - mCapturedFrames = mBracketingRange; - } - mBurstFramesQueued = 0; - mBurstFramesAccum = mCapturedFrames; - - if(ret != NO_ERROR) - goto EXIT; - else - return ret; - } - } - - if ( NO_ERROR == ret ) { - if (capParams->mPendingCaptureSettings & SetRotation) { - mPendingCaptureSettings &= ~SetRotation; - ret = setPictureRotation(mPictureRotation); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error configuring image rotation %x", ret); - } - } - - if (capParams->mPendingCaptureSettings & (SetBurst|SetExpBracket)) { - mPendingCaptureSettings &= ~(SetExpBracket|SetBurst); - if ( mBracketingSet ) { - ret = doExposureBracketing(capParams->mExposureBracketingValues, - capParams->mExposureGainBracketingValues, - capParams->mExposureGainBracketingModes, - 0, - 0, - capParams->mFlushShotConfigQueue, - capParams->mExposureBracketMode); - } else { - ret = doExposureBracketing(capParams->mExposureBracketingValues, - capParams->mExposureGainBracketingValues, - capParams->mExposureGainBracketingModes, - capParams->mExposureBracketingValidEntries, - capParams->mBurstFrames, - capParams->mFlushShotConfigQueue, - capParams->mExposureBracketMode); - } - - if ( ret != NO_ERROR ) { - CAMHAL_LOGEB("setExposureBracketing() failed %d", ret); - goto EXIT; - } - } - } - - capData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - - //OMX shutter callback events are only available in hq mode - if ( (HIGH_QUALITY == mCapMode) || (HIGH_QUALITY_ZSL== mCapMode)) { - if ( NO_ERROR == ret ) - { - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - (OMX_EVENTTYPE) OMX_EventIndexSettingChanged, - OMX_ALL, - OMX_TI_IndexConfigShutterCallback, - mStartCaptureSem); - } - - if ( NO_ERROR == ret ) - { - ret = setShutterCallback(true); - } - - } - - if (mPending3Asettings) { - apply3Asettings(mParameters3A); - } - - // check is we are already in capture state...which means we are - // accumulating shots - if ((ret == NO_ERROR) && (mBurstFramesQueued > 0)) { - int index = 0; - int queued = 0; - android::AutoMutex lock(mBurstLock); - - if (capParams->mFlushShotConfigQueue) { - // reset shot queue - mCapturedFrames = mBurstFrames; - mBurstFramesAccum = mBurstFrames; - mBurstFramesQueued = 0; - for ( int index = 0 ; index < capData->mNumBufs ; index++ ) { - if (OMXCameraPortParameters::FILL == capData->mStatus[index]) { - mBurstFramesQueued++; - } - } - } else { - mCapturedFrames += mBurstFrames; - mBurstFramesAccum += mBurstFrames; - } - - while ((mBurstFramesQueued < mBurstFramesAccum) && - (index < capData->mNumBufs) && - (queued < capData->mMaxQueueable)) { - if (capData->mStatus[index] == OMXCameraPortParameters::IDLE) { - CAMHAL_LOGDB("Queuing buffer on Capture port - %p", - capData->mBufferHeader[index]->pBuffer); - capData->mStatus[index] = OMXCameraPortParameters::FILL; - eError = OMX_FillThisBuffer(mCameraAdapterParameters.mHandleComp, - (OMX_BUFFERHEADERTYPE*)capData->mBufferHeader[index]); - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - mBurstFramesQueued++; - queued++; - } else if (OMXCameraPortParameters::FILL == capData->mStatus[index]) { - queued++; - } - index++; - } - } else if ( NO_ERROR == ret ) { - ///Queue all the buffers on capture port - for ( int index = 0 ; index < capData->mMaxQueueable ; index++ ) { - if (mBurstFramesQueued < mBurstFramesAccum) { - CAMHAL_LOGDB("Queuing buffer on Capture port - %p", - capData->mBufferHeader[index]->pBuffer); - capData->mStatus[index] = OMXCameraPortParameters::FILL; - eError = OMX_FillThisBuffer(mCameraAdapterParameters.mHandleComp, - (OMX_BUFFERHEADERTYPE*)capData->mBufferHeader[index]); - mBurstFramesQueued++; - } else { - capData->mStatus[index] = OMXCameraPortParameters::IDLE; - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - } - -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING - if (mRawCapture) { - capData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoPortIndex]; - - ///Queue all the buffers on capture port - for ( int index = 0 ; index < capData->mNumBufs ; index++ ) { - CAMHAL_LOGDB("Queuing buffer on Video port (for RAW capture) - 0x%x", ( unsigned int ) capData->mBufferHeader[index]->pBuffer); - capData->mStatus[index] = OMXCameraPortParameters::FILL; - eError = OMX_FillThisBuffer(mCameraAdapterParameters.mHandleComp, - (OMX_BUFFERHEADERTYPE*)capData->mBufferHeader[index]); - - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - } - } -#endif - - mWaitingForSnapshot = true; - mCaptureSignalled = false; - mPendingCaptureSettings &= ~SetBurst; - - // Capturing command is not needed when capturing in video mode - // Only need to queue buffers on image ports - if (mCapMode != VIDEO_MODE) { - OMX_INIT_STRUCT_PTR (&bOMX, OMX_CONFIG_BOOLEANTYPE); - bOMX.bEnabled = OMX_TRUE; - - /// sending Capturing Command to the component - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCapturing, - &bOMX); - - CAMHAL_LOGDB("Capture set - 0x%x", eError); - - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - } - } - - //OMX shutter callback events are only available in hq mode - - if ( (HIGH_QUALITY == mCapMode) || (HIGH_QUALITY_ZSL== mCapMode)) - { - if ( NO_ERROR == ret ) - { - ret = mStartCaptureSem.WaitTimeout(OMX_CAPTURE_TIMEOUT); - } - - //If something bad happened while we wait - if (mComponentState != OMX_StateExecuting) - { - CAMHAL_LOGEA("Invalid State after Image Capture Exitting!!!"); - goto EXIT; - } - - if ( NO_ERROR == ret ) - { - CAMHAL_LOGDA("Shutter callback received"); - notifyShutterSubscribers(); - } - else - { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - (OMX_EVENTTYPE) OMX_EventIndexSettingChanged, - OMX_ALL, - OMX_TI_IndexConfigShutterCallback, - NULL); - CAMHAL_LOGEA("Timeout expired on shutter callback"); - goto EXIT; - } - - } - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - -EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - mWaitingForSnapshot = false; - mCaptureSignalled = false; - performCleanupAfterError(); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::stopImageCapture() -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_BOOLEANTYPE bOMX; - OMXCameraPortParameters *imgCaptureData = NULL; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mImageCaptureLock); - - if (!mCaptureConfigured) { - //Capture is not ongoing, return from here - return NO_ERROR; - } - - if ( 0 != mStopCaptureSem.Count() ) { - CAMHAL_LOGEB("Error mStopCaptureSem semaphore count %d", mStopCaptureSem.Count()); - goto EXIT; - } - - // TODO(XXX): Reprocessing is currently piggy-backing capture commands - if (mAdapterState == REPROCESS_STATE) { - ret = stopReprocess(); - } - - //Disable the callback first - mWaitingForSnapshot = false; - - // OMX shutter callback events are only available in hq mode - if ((HIGH_QUALITY == mCapMode) || (HIGH_QUALITY_ZSL== mCapMode)) { - //Disable the callback first - ret = setShutterCallback(false); - - // if anybody is waiting on the shutter callback - // signal them and then recreate the semaphore - if ( 0 != mStartCaptureSem.Count() ) { - - for (int i = mStartCaptureSem.Count(); i < 0; i++) { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, - (OMX_EVENTTYPE) OMX_EventIndexSettingChanged, - OMX_ALL, - OMX_TI_IndexConfigShutterCallback, - NULL ); - } - mStartCaptureSem.Create(0); - } - } -#ifndef OMAP_TUNA - else if (CP_CAM == mCapMode) { - // Reset shot config queue - OMX_TI_CONFIG_ENQUEUESHOTCONFIGS resetShotConfigs; - OMX_INIT_STRUCT_PTR(&resetShotConfigs, OMX_TI_CONFIG_ENQUEUESHOTCONFIGS); - - resetShotConfigs.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - resetShotConfigs.bFlushQueue = OMX_TRUE; - resetShotConfigs.nNumConfigs = 0; - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_TI_IndexConfigEnqueueShotConfigs, - &resetShotConfigs); - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while reset shot config 0x%x", eError); - goto EXIT; - } else { - CAMHAL_LOGDA("Shot config reset successfully"); - } - } -#endif - - //Wait here for the capture to be done, in worst case timeout and proceed with cleanup - mCaptureSem.WaitTimeout(OMX_CAPTURE_TIMEOUT); - - //If somethiing bad happened while we wait - if (mComponentState == OMX_StateInvalid) - { - CAMHAL_LOGEA("Invalid State Image Capture Stop Exitting!!!"); - goto EXIT; - } - - // Disable image capture - // Capturing command is not needed when capturing in video mode - if (mCapMode != VIDEO_MODE) { - OMX_INIT_STRUCT_PTR (&bOMX, OMX_CONFIG_BOOLEANTYPE); - bOMX.bEnabled = OMX_FALSE; - imgCaptureData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCapturing, - &bOMX); - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGDB("Error during SetConfig- 0x%x", eError); - ret = -1; - goto EXIT; - } - } - - // Disable WB and vector shot extra data for metadata - setExtraData(false, mCameraAdapterParameters.mImagePortIndex, OMX_WhiteBalance); - // TODO: WA: if domx client disables VectShotInfo metadata on the image port, this causes - // VectShotInfo to be disabled internally on preview port also. Remove setting in OMXCapture - // setExtraData(false, mCameraAdapterParameters.mImagePortIndex, OMX_TI_VectShotInfo); -#ifndef OMAP_TUNA - setExtraData(false, mCameraAdapterParameters.mImagePortIndex, OMX_TI_LSCTable); -#endif - - CAMHAL_LOGDB("Capture set - 0x%x", eError); - - mCaptureSignalled = true; //set this to true if we exited because of timeout - - { - android::AutoMutex lock(mFrameCountMutex); - mFrameCount = 0; - mFirstFrameCondition.broadcast(); - } - - // Stop is always signalled externally in CPCAM mode - // We need to make sure we really stop - if ((mCapMode == CP_CAM)) { - disableReprocess(); - disableImagePort(); - if ( NULL != mReleaseImageBuffersCallback ) { - mReleaseImageBuffersCallback(mReleaseData); - } - } - - // Moving code for below commit here as an optimization for continuous capture, - // so focus settings don't have to reapplied after each capture - // c78fa2a CameraHAL: Always reset focus mode after capture - // Workaround when doing many consecutive shots, CAF wasn't getting restarted. - mPending3Asettings |= SetFocus; - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - -EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - //Release image buffers - if ( NULL != mReleaseImageBuffersCallback ) { - mReleaseImageBuffersCallback(mReleaseData); - } - - { - android::AutoMutex lock(mFrameCountMutex); - mFrameCount = 0; - mFirstFrameCondition.broadcast(); - } - - performCleanupAfterError(); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::disableImagePort(){ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXCameraPortParameters *imgCaptureData = NULL; - OMXCameraPortParameters *imgRawCaptureData = NULL; - - if (!mCaptureConfigured) { - return NO_ERROR; - } - - mCaptureConfigured = false; - imgCaptureData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - imgRawCaptureData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoPortIndex]; // for RAW capture - - ///Register for Image port Disable event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortDisable, - mCameraAdapterParameters.mImagePortIndex, - mStopCaptureSem); - ///Disable Capture Port - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortDisable, - mCameraAdapterParameters.mImagePortIndex, - NULL); - - ///Free all the buffers on capture port - if (imgCaptureData) { - CAMHAL_LOGDB("Freeing buffer on Capture port - %d", imgCaptureData->mNumBufs); - for ( int index = 0 ; index < imgCaptureData->mNumBufs ; index++) { - CAMHAL_LOGDB("Freeing buffer on Capture port - 0x%x", - ( unsigned int ) imgCaptureData->mBufferHeader[index]->pBuffer); - eError = OMX_FreeBuffer(mCameraAdapterParameters.mHandleComp, - mCameraAdapterParameters.mImagePortIndex, - (OMX_BUFFERHEADERTYPE*)imgCaptureData->mBufferHeader[index]); - - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - } - } - CAMHAL_LOGDA("Waiting for port disable"); - //Wait for the image port enable event - ret = mStopCaptureSem.WaitTimeout(OMX_CMD_TIMEOUT); - - //If somethiing bad happened while we wait - if (mComponentState == OMX_StateInvalid) - { - CAMHAL_LOGEA("Invalid State after Disable Image Port Exitting!!!"); - goto EXIT; - } - - if ( NO_ERROR == ret ) { - CAMHAL_LOGDA("Port disabled"); - } else { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortDisable, - mCameraAdapterParameters.mImagePortIndex, - NULL); - CAMHAL_LOGDA("Timeout expired on port disable"); - goto EXIT; - } - - deinitInternalBuffers(mCameraAdapterParameters.mImagePortIndex); - -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING - if (mRawCapture) { - ///Register for Video port Disable event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortDisable, - mCameraAdapterParameters.mVideoPortIndex, - mStopCaptureSem); - ///Disable RawCapture Port - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortDisable, - mCameraAdapterParameters.mVideoPortIndex, - NULL); - - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - ///Free all the buffers on RawCapture port - if (imgRawCaptureData) { - CAMHAL_LOGDB("Freeing buffer on Capture port - %d", imgRawCaptureData->mNumBufs); - for ( int index = 0 ; index < imgRawCaptureData->mNumBufs ; index++) { - CAMHAL_LOGDB("Freeing buffer on Capture port - 0x%x", ( unsigned int ) imgRawCaptureData->mBufferHeader[index]->pBuffer); - eError = OMX_FreeBuffer(mCameraAdapterParameters.mHandleComp, - mCameraAdapterParameters.mVideoPortIndex, - (OMX_BUFFERHEADERTYPE*)imgRawCaptureData->mBufferHeader[index]); - - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - } - } - CAMHAL_LOGDA("Waiting for Video port disable"); - //Wait for the image port enable event - mStopCaptureSem.WaitTimeout(OMX_CMD_TIMEOUT); - CAMHAL_LOGDA("Video Port disabled"); - } -#endif - -EXIT: - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::initInternalBuffers(OMX_U32 portIndex) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - int index = 0; -#ifndef OMAP_TUNA - OMX_TI_PARAM_USEBUFFERDESCRIPTOR bufferdesc; - - /* Indicate to Ducati that we're planning to use dynamically-mapped buffers */ - OMX_INIT_STRUCT_PTR (&bufferdesc, OMX_TI_PARAM_USEBUFFERDESCRIPTOR); - bufferdesc.nPortIndex = portIndex; - bufferdesc.bEnabled = OMX_FALSE; - bufferdesc.eBufferType = OMX_TI_BufferTypePhysicalPageList; - - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexUseBufferDescriptor, - &bufferdesc); - if (eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_SetParameter - %x", eError); - return -EINVAL; - } - - CAMHAL_LOGDA("Initializing internal buffers"); - do { - OMX_TI_PARAM_COMPONENTBUFALLOCTYPE bufferalloc; - OMX_TI_PARAM_COMPONENTBUFALLOCTYPE bufferallocset; - OMX_INIT_STRUCT_PTR (&bufferalloc, OMX_TI_PARAM_COMPONENTBUFALLOCTYPE); - bufferalloc.nPortIndex = portIndex; - bufferalloc.nIndex = index; - - eError = OMX_GetParameter (mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexParamComponentBufferAllocation, - &bufferalloc); - if (eError == OMX_ErrorNoMore) { - return NO_ERROR; - } - if (eError != OMX_ErrorNone) { - CAMHAL_LOGE("GetParameter failed error = 0x%x", eError); - break; - } - - CAMHAL_LOGDB("Requesting buftype %d of size %dx%d", - (int)bufferalloc.eBufType, (int)bufferalloc.nAllocWidth, - (int)bufferalloc.nAllocLines); - - bufferalloc.eBufType = OMX_TI_BufferTypeHardwareReserved1D; - - OMX_INIT_STRUCT_PTR (&bufferallocset, OMX_TI_PARAM_COMPONENTBUFALLOCTYPE); - bufferallocset.nPortIndex = portIndex; - bufferallocset.nIndex = index; - bufferallocset.eBufType = OMX_TI_BufferTypeHardwareReserved1D; - bufferallocset.nAllocWidth = bufferalloc.nAllocWidth; - bufferallocset.nAllocLines = bufferalloc.nAllocLines; - - eError = OMX_SetParameter (mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexParamComponentBufferAllocation, - &bufferallocset); - if (eError != OMX_ErrorNone) { - CAMHAL_LOGE("SetParameter failed, error=%08x", eError); - if (eError == OMX_ErrorNoMore) return NO_ERROR; - break; - } - - index++; - - /* 1 is an arbitrary limit */ - } while (index < 1); - - CAMHAL_LOGV("Ducati requested too many (>1) internal buffers"); - - return -EINVAL; -#endif - return NO_ERROR; -} - -status_t OMXCameraAdapter::deinitInternalBuffers(OMX_U32 portIndex) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; -#ifndef OMAP_TUNA - OMX_TI_PARAM_USEBUFFERDESCRIPTOR bufferdesc; - - OMX_INIT_STRUCT_PTR (&bufferdesc, OMX_TI_PARAM_USEBUFFERDESCRIPTOR); - bufferdesc.nPortIndex = portIndex; - bufferdesc.bEnabled = OMX_FALSE; - bufferdesc.eBufferType = OMX_TI_BufferTypeDefault; - - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexUseBufferDescriptor, - &bufferdesc); - if (eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_SetParameter - %x", eError); - return -EINVAL; - } - - OMX_TI_PARAM_COMPONENTBUFALLOCTYPE bufferalloc; - OMX_INIT_STRUCT_PTR (&bufferalloc, OMX_TI_PARAM_COMPONENTBUFALLOCTYPE); - bufferalloc.nPortIndex = portIndex; - bufferalloc.eBufType = OMX_TI_BufferTypeDefault; - bufferalloc.nAllocWidth = 1; - bufferalloc.nAllocLines = 1; - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexParamComponentBufferAllocation, - &bufferalloc); -#endif - if (eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_SetParameter - %x", eError); - return -EINVAL; - } - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::UseBuffersCapture(CameraBuffer * bufArr, int num) -{ - LOG_FUNCTION_NAME; - - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXCameraPortParameters * imgCaptureData = NULL; - OMXCameraPortParameters cap; - - imgCaptureData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - - if ( 0 != mUseCaptureSem.Count() ) - { - CAMHAL_LOGEB("Error mUseCaptureSem semaphore count %d", mUseCaptureSem.Count()); - return BAD_VALUE; - } - - // capture is already configured...we can skip this step - if (mCaptureConfigured) { - if ( NO_ERROR == ret ) - { - ret = setupEXIF(); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Error configuring EXIF Buffer %x", ret); - } - } - - mCapturedFrames = mBurstFrames; - mBurstFramesQueued = 0; - return NO_ERROR; - } - - imgCaptureData->mNumBufs = num; - - //TODO: Support more pixelformats - - CAMHAL_LOGDB("Params Width = %d", (int)imgCaptureData->mWidth); - CAMHAL_LOGDB("Params Height = %d", (int)imgCaptureData->mHeight); - - if (mPendingCaptureSettings & SetFormat) { - mPendingCaptureSettings &= ~SetFormat; - ret = setFormat(OMX_CAMERA_PORT_IMAGE_OUT_IMAGE, *imgCaptureData); - if ( ret != NO_ERROR ) { - CAMHAL_LOGEB("setFormat() failed %d", ret); - LOG_FUNCTION_NAME_EXIT; - return ret; - } - } - - if (mPendingCaptureSettings & SetThumb) { - mPendingCaptureSettings &= ~SetThumb; - ret = setThumbnailParams(mThumbWidth, mThumbHeight, mThumbQuality); - if ( NO_ERROR != ret) { - CAMHAL_LOGEB("Error configuring thumbnail size %x", ret); - return ret; - } - } - - if (mPendingCaptureSettings & SetQuality) { - mPendingCaptureSettings &= ~SetQuality; - ret = setImageQuality(mPictureQuality); - if ( NO_ERROR != ret) { - CAMHAL_LOGEB("Error configuring image quality %x", ret); - goto EXIT; - } - } - - // assuming if buffers are from ANW that they will be pagelist buffers - // and need a tiler reservation - if (bufArr[0].type == CAMERA_BUFFER_ANW) { - initInternalBuffers(mCameraAdapterParameters.mImagePortIndex); - } - - ///Register for Image port ENABLE event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mImagePortIndex, - mUseCaptureSem); - - ///Enable Capture Port - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortEnable, - mCameraAdapterParameters.mImagePortIndex, - NULL); - - CAMHAL_LOGDB("OMX_UseBuffer = 0x%x", eError); - GOTO_EXIT_IF(( eError != OMX_ErrorNone ), eError); - - // Configure DOMX to use either gralloc handles or vptrs - if ((imgCaptureData->mNumBufs > 0)) { - OMX_TI_PARAMUSENATIVEBUFFER domxUseGrallocHandles; - OMX_INIT_STRUCT_PTR (&domxUseGrallocHandles, OMX_TI_PARAMUSENATIVEBUFFER); - - domxUseGrallocHandles.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - if (bufArr[0].type == CAMERA_BUFFER_ANW) { - CAMHAL_LOGD ("Using ANW Buffers"); - domxUseGrallocHandles.bEnable = OMX_TRUE; - } else { - CAMHAL_LOGD ("Using ION Buffers"); - domxUseGrallocHandles.bEnable = OMX_FALSE; - } - - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexUseNativeBuffers, &domxUseGrallocHandles); - if (eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_SetParameter - %x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - } - - for ( int index = 0 ; index < imgCaptureData->mNumBufs ; index++ ) - { - OMX_BUFFERHEADERTYPE *pBufferHdr; - CAMHAL_LOGDB("OMX_UseBuffer Capture address: 0x%x, size = %d", - (unsigned int)bufArr[index].opaque, - (int)imgCaptureData->mBufSize); - - eError = OMX_UseBuffer(mCameraAdapterParameters.mHandleComp, - &pBufferHdr, - mCameraAdapterParameters.mImagePortIndex, - 0, - imgCaptureData->mBufSize, - (OMX_U8*)camera_buffer_get_omx_ptr(&bufArr[index])); - - CAMHAL_LOGDB("OMX_UseBuffer = 0x%x", eError); - GOTO_EXIT_IF(( eError != OMX_ErrorNone ), eError); - - pBufferHdr->pAppPrivate = (OMX_PTR) &bufArr[index]; - bufArr[index].index = index; - pBufferHdr->nSize = sizeof(OMX_BUFFERHEADERTYPE); - pBufferHdr->nVersion.s.nVersionMajor = 1 ; - pBufferHdr->nVersion.s.nVersionMinor = 1 ; - pBufferHdr->nVersion.s.nRevision = 0; - pBufferHdr->nVersion.s.nStep = 0; - imgCaptureData->mBufferHeader[index] = pBufferHdr; - } - - //Wait for the image port enable event - CAMHAL_LOGDA("Waiting for port enable"); - ret = mUseCaptureSem.WaitTimeout(OMX_CMD_TIMEOUT); - - //If somethiing bad happened while we wait - if (mComponentState == OMX_StateInvalid) - { - CAMHAL_LOGEA("Invalid State after Enable Image Port Exitting!!!"); - goto EXIT; - } - - if ( ret == NO_ERROR ) - { - CAMHAL_LOGDA("Port enabled"); - } - else - { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mImagePortIndex, - NULL); - CAMHAL_LOGDA("Timeout expired on port enable"); - goto EXIT; - } - - if ( NO_ERROR == ret ) - { - ret = setupEXIF(); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Error configuring EXIF Buffer %x", ret); - } - } - - // Enable WB and vector shot extra data for metadata - setExtraData(true, mCameraAdapterParameters.mImagePortIndex, OMX_WhiteBalance); - // TODO: WA: if domx client disables VectShotInfo metadata on the image port, this causes - // VectShotInfo to be disabled internally on preview port also. Remove setting in OMXCapture - // setExtraData(true, mCameraAdapterParameters.mImagePortIndex, OMX_TI_VectShotInfo); -#ifndef OMAP_TUNA - setExtraData(true, mCameraAdapterParameters.mImagePortIndex, OMX_TI_LSCTable); - - // CPCam mode only supports vector shot - // Regular capture is not supported - if (mCapMode == CP_CAM) initVectorShot(); - - // Choose proper single preview mode for cpcapture capture (reproc or hs) - if (( NO_ERROR == ret) && (OMXCameraAdapter::CP_CAM == mCapMode)) { - OMX_TI_CONFIG_SINGLEPREVIEWMODETYPE singlePrevMode; - OMX_INIT_STRUCT_PTR (&singlePrevMode, OMX_TI_CONFIG_SINGLEPREVIEWMODETYPE); - if (mNextState == LOADED_CAPTURE_STATE) { - singlePrevMode.eMode = OMX_TI_SinglePreviewMode_ImageCaptureHighSpeed; - } else if (mNextState == LOADED_REPROCESS_CAPTURE_STATE) { - singlePrevMode.eMode = OMX_TI_SinglePreviewMode_Reprocess; - } else { - CAMHAL_LOGE("Wrong state trying to start a capture in CPCAM mode?"); - singlePrevMode.eMode = OMX_TI_SinglePreviewMode_ImageCaptureHighSpeed; - } - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexConfigSinglePreviewMode, - &singlePrevMode); - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while configuring single preview mode 0x%x", eError); - ret = Utils::ErrorUtils::omxToAndroidError(eError); - } else { - CAMHAL_LOGDA("single preview mode configured successfully"); - } - } -#endif - - mCapturedFrames = mBurstFrames; - mBurstFramesAccum = mBurstFrames; - mBurstFramesQueued = 0; - - mCaptureConfigured = true; - -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING - if (mRawCapture) { - mCaptureConfigured = false; - } -#endif - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - -EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - setExtraData(false, mCameraAdapterParameters.mImagePortIndex, OMX_WhiteBalance); - // TODO: WA: if domx client disables VectShotInfo metadata on the image port, this causes - // VectShotInfo to be disabled internally on preview port also. Remove setting in OMXCapture - // setExtraData(false, mCameraAdapterParameters.mImagePortIndex, OMX_TI_VectShotInfo); -#ifndef OMAP_TUNA - setExtraData(false, mCameraAdapterParameters.mImagePortIndex, OMX_TI_LSCTable); -#endif - //Release image buffers - if ( NULL != mReleaseImageBuffersCallback ) { - mReleaseImageBuffersCallback(mReleaseData); - } - performCleanupAfterError(); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - -} -status_t OMXCameraAdapter::UseBuffersRawCapture(CameraBuffer *bufArr, int num) -{ - LOG_FUNCTION_NAME - status_t ret; - OMX_ERRORTYPE eError; - OMXCameraPortParameters * imgRawCaptureData = NULL; - Utils::Semaphore camSem; - OMXCameraPortParameters cap; - - imgRawCaptureData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoPortIndex]; - - if (mCaptureConfigured) { - return NO_ERROR; - } - - camSem.Create(); - - // mWaitingForSnapshot is true only when we're in the process of capturing - if (mWaitingForSnapshot) { - ///Register for Video port Disable event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - (OMX_EVENTTYPE) OMX_EventCmdComplete, - OMX_CommandPortDisable, - mCameraAdapterParameters.mVideoPortIndex, - camSem); - - ///Disable Capture Port - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortDisable, - mCameraAdapterParameters.mVideoPortIndex, - NULL); - - CAMHAL_LOGDA("Waiting for port disable"); - //Wait for the image port enable event - camSem.Wait(); - CAMHAL_LOGDA("Port disabled"); - } - - imgRawCaptureData->mNumBufs = num; - - CAMHAL_LOGDB("RAW Max sensor width = %d", (int)imgRawCaptureData->mWidth); - CAMHAL_LOGDB("RAW Max sensor height = %d", (int)imgRawCaptureData->mHeight); - - ret = setFormat(OMX_CAMERA_PORT_VIDEO_OUT_VIDEO, *imgRawCaptureData); - - if (ret != NO_ERROR) { - CAMHAL_LOGEB("setFormat() failed %d", ret); - LOG_FUNCTION_NAME_EXIT - return ret; - } - - ///Register for Video port ENABLE event - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - (OMX_EVENTTYPE) OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mVideoPortIndex, - camSem); - - ///Enable Video Capture Port - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortEnable, - mCameraAdapterParameters.mVideoPortIndex, - NULL); - - mCaptureBuffersLength = (int)imgRawCaptureData->mBufSize; - for ( int index = 0 ; index < imgRawCaptureData->mNumBufs ; index++ ) { - OMX_BUFFERHEADERTYPE *pBufferHdr; - CAMHAL_LOGDB("OMX_UseBuffer rawCapture address: 0x%x, size = %d ", - (unsigned int)bufArr[index].opaque, - (int)imgRawCaptureData->mBufSize ); - - eError = OMX_UseBuffer( mCameraAdapterParameters.mHandleComp, - &pBufferHdr, - mCameraAdapterParameters.mVideoPortIndex, - 0, - mCaptureBuffersLength, - (OMX_U8*)camera_buffer_get_omx_ptr(&bufArr[index])); - if (eError != OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_UseBuffer = 0x%x", eError); - } - - GOTO_EXIT_IF(( eError != OMX_ErrorNone ), eError); - - pBufferHdr->pAppPrivate = (OMX_PTR) &bufArr[index]; - bufArr[index].index = index; - pBufferHdr->nSize = sizeof(OMX_BUFFERHEADERTYPE); - pBufferHdr->nVersion.s.nVersionMajor = 1 ; - pBufferHdr->nVersion.s.nVersionMinor = 1 ; - pBufferHdr->nVersion.s.nRevision = 0; - pBufferHdr->nVersion.s.nStep = 0; - imgRawCaptureData->mBufferHeader[index] = pBufferHdr; - - } - - //Wait for the image port enable event - CAMHAL_LOGDA("Waiting for port enable"); - camSem.Wait(); - CAMHAL_LOGDA("Port enabled"); - - if (NO_ERROR == ret) { - ret = setupEXIF(); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Error configuring EXIF Buffer %x", ret); - } - } - - mCapturedFrames = mBurstFrames; - mBurstFramesQueued = 0; - mCaptureConfigured = true; - - EXIT: - - if (eError != OMX_ErrorNone) { - if ( NULL != mErrorNotifier ) - { - mErrorNotifier->errorNotify(eError); - } - } - - LOG_FUNCTION_NAME_EXIT - - return ret; -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/OMXCameraAdapter/OMXDccDataSave.cpp b/camera/OMXCameraAdapter/OMXDccDataSave.cpp deleted file mode 100644 index 7547743..0000000 --- a/camera/OMXCameraAdapter/OMXDccDataSave.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMXDccDataSave.cpp -* -* This file contains functionality for handling DCC data save -* -*/ - -#include "CameraHal.h" -#include "OMXCameraAdapter.h" - - -namespace Ti { -namespace Camera { - -status_t OMXCameraAdapter::initDccFileDataSave(OMX_HANDLETYPE* omxHandle, int portIndex) -{ - OMX_CONFIG_EXTRADATATYPE extraDataControl; - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - LOG_FUNCTION_NAME; - - OMX_INIT_STRUCT_PTR (&extraDataControl, OMX_CONFIG_EXTRADATATYPE); - extraDataControl.nPortIndex = portIndex; - extraDataControl.eExtraDataType = OMX_TI_DccData; - extraDataControl.bEnable = OMX_TRUE; - - eError = OMX_SetConfig(*omxHandle, - ( OMX_INDEXTYPE ) OMX_IndexConfigOtherExtraDataControl, - &extraDataControl); - - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring dcc data overwrite extra data 0x%x", - eError); - - ret = NO_INIT; - } - - if (mDccData.pData) { - free(mDccData.pData); - mDccData.pData = NULL; - } - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::sniffDccFileDataSave(OMX_BUFFERHEADERTYPE* pBuffHeader) -{ - OMX_OTHER_EXTRADATATYPE *extraData; - OMX_TI_DCCDATATYPE* dccData; - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mDccDataLock); - - if ( NULL == pBuffHeader ) { - CAMHAL_LOGEA("Invalid Buffer header"); - LOG_FUNCTION_NAME_EXIT; - return -EINVAL; - } - - extraData = getExtradata(pBuffHeader->pPlatformPrivate, - (OMX_EXTRADATATYPE)OMX_TI_DccData); - - if ( NULL != extraData ) { - CAMHAL_LOGVB("Size = %d, sizeof = %d, eType = 0x%x, nDataSize= %d, nPortIndex = 0x%x, nVersion = 0x%x", - extraData->nSize, - sizeof(OMX_OTHER_EXTRADATATYPE), - extraData->eType, - extraData->nDataSize, - extraData->nPortIndex, - extraData->nVersion); - } else { - CAMHAL_LOGVA("Invalid OMX_TI_DCCDATATYPE"); - LOG_FUNCTION_NAME_EXIT; - return NO_ERROR; - } - - dccData = ( OMX_TI_DCCDATATYPE * ) extraData->data; - - if (NULL == dccData) { - CAMHAL_LOGVA("OMX_TI_DCCDATATYPE is not found in extra data"); - LOG_FUNCTION_NAME_EXIT; - return NO_ERROR; - } - - if (mDccData.pData) { - free(mDccData.pData); - } - - memcpy(&mDccData, dccData, sizeof(mDccData)); - - int dccDataSize = (int)dccData->nSize - (int)(&(((OMX_TI_DCCDATATYPE*)0)->pData)); - - mDccData.pData = (OMX_PTR)malloc(dccDataSize); - - if (NULL == mDccData.pData) { - CAMHAL_LOGVA("not enough memory for DCC data"); - LOG_FUNCTION_NAME_EXIT; - return NO_ERROR; - } - - memcpy(mDccData.pData, &(dccData->pData), dccDataSize); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -// Recursively searches given directory contents for the correct DCC file. -// The directory must be opened and its stream pointer + path passed -// as arguments. As this function is called recursively, to avoid excessive -// stack usage the path param is reused -> this MUST be char array with -// enough length!!! (260 should suffice). Path must end with "/". -// The directory must also be closed in the caller function. -// If the correct camera DCC file is found (based on the OMX measurement data) -// its file stream pointer is returned. NULL is returned otherwise -FILE * OMXCameraAdapter::parseDCCsubDir(DIR *pDir, char *path) -{ - FILE *pFile; - DIR *pSubDir; - struct dirent *dirEntry; - int initialPathLength = strlen(path); - - LOG_FUNCTION_NAME; - - /* check each directory entry */ - while ((dirEntry = readdir(pDir)) != NULL) - { - if (dirEntry->d_name[0] == '.') - continue; - - strcat(path, dirEntry->d_name); - // dirEntry might be sub directory -> check it - pSubDir = opendir(path); - if (pSubDir) { - // dirEntry is sub directory -> parse it - strcat(path, "/"); - pFile = parseDCCsubDir(pSubDir, path); - closedir(pSubDir); - if (pFile) { - // the correct DCC file found! - LOG_FUNCTION_NAME_EXIT; - return pFile; - } - } else { - // dirEntry is file -> open it - pFile = fopen(path, "rb"); - if (pFile) { - // now check if this is the correct DCC file for that camera - OMX_U32 dccFileIDword; - OMX_U32 *dccFileDesc = (OMX_U32 *) &mDccData.nCameraModuleId; - int i; - - // DCC file ID is 3 4-byte words - for (i = 0; i < 3; i++) { - if (fread(&dccFileIDword, sizeof(OMX_U32), 1, pFile) != 1) { - // file too short - break; - } - if (dccFileIDword != dccFileDesc[i]) { - // DCC file ID word i does not match - break; - } - } - - fclose(pFile); - if (i == 3) { - // the correct DCC file found! - CAMHAL_LOGDB("DCC file to be updated: %s", path); - // reopen it for modification - pFile = fopen(path, "rb+"); - if (!pFile) - CAMHAL_LOGEB("ERROR: DCC file %s failed to open for modification", path); - LOG_FUNCTION_NAME_EXIT; - return pFile; - } - } else { - CAMHAL_LOGEB("ERROR: Failed to open file %s for reading", path); - } - } - // restore original path - path[initialPathLength] = '\0'; - } - - LOG_FUNCTION_NAME_EXIT; - - // DCC file not found in this directory tree - return NULL; -} - -// Finds the DCC file corresponding to the current camera based on the -// OMX measurement data, opens it and returns the file stream pointer -// (NULL on error or if file not found). -// The folder string dccFolderPath must end with "/" -FILE * OMXCameraAdapter::fopenCameraDCC(const char *dccFolderPath) -{ - FILE *pFile; - DIR *pDir; - char dccPath[260]; - - LOG_FUNCTION_NAME; - - strcpy(dccPath, dccFolderPath); - - pDir = opendir(dccPath); - if (!pDir) { - CAMHAL_LOGEB("ERROR: Opening DCC directory %s failed", dccPath); - LOG_FUNCTION_NAME_EXIT; - return NULL; - } - - pFile = parseDCCsubDir(pDir, dccPath); - closedir(pDir); - if (pFile) { - CAMHAL_LOGDB("DCC file %s opened for modification", dccPath); - } - - LOG_FUNCTION_NAME_EXIT; - - return pFile; -} - -// Positions the DCC file stream pointer to the correct offset within the -// correct usecase based on the OMX mesurement data. Returns 0 on success -status_t OMXCameraAdapter::fseekDCCuseCasePos(FILE *pFile) -{ - OMX_U32 dccNumUseCases = 0; - OMX_U32 dccUseCaseData[3]; - OMX_U32 i; - - LOG_FUNCTION_NAME; - - // position the file pointer to the DCC use cases section - if (fseek(pFile, 80, SEEK_SET)) { - CAMHAL_LOGEA("ERROR: Unexpected end of DCC file"); - LOG_FUNCTION_NAME_EXIT; - return -EINVAL; - } - - if (fread(&dccNumUseCases, sizeof(OMX_U32), 1, pFile) != 1 || - dccNumUseCases == 0) { - CAMHAL_LOGEA("ERROR: DCC file contains 0 use cases"); - LOG_FUNCTION_NAME_EXIT; - return -EINVAL; - } - - for (i = 0; i < dccNumUseCases; i++) { - if (fread(dccUseCaseData, sizeof(OMX_U32), 3, pFile) != 3) { - CAMHAL_LOGEA("ERROR: Unexpected end of DCC file"); - LOG_FUNCTION_NAME_EXIT; - return -EINVAL; - } - - if (dccUseCaseData[0] == mDccData.nUseCaseId) { - // DCC use case match! - break; - } - } - - if (i == dccNumUseCases) { - CAMHAL_LOGEB("ERROR: Use case ID %lu not found in DCC file", mDccData.nUseCaseId); - LOG_FUNCTION_NAME_EXIT; - return -EINVAL; - } - - // dccUseCaseData[1] is the offset to the beginning of the actual use case - // from the beginning of the file - // mDccData.nOffset is the offset within the actual use case (from the - // beginning of the use case to the data to be modified) - - if (fseek(pFile,dccUseCaseData[1] + mDccData.nOffset, SEEK_SET )) - { - CAMHAL_LOGEA("ERROR: Error setting the correct offset"); - LOG_FUNCTION_NAME_EXIT; - return -EINVAL; - } - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -status_t OMXCameraAdapter::saveDccFileDataSave() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mDccDataLock); - - if (mDccData.pData) - { - FILE *fd = fopenCameraDCC(DCC_PATH); - - if (fd) - { - if (!fseekDCCuseCasePos(fd)) - { - int dccDataSize = (int)mDccData.nSize - (int)(&(((OMX_TI_DCCDATATYPE*)0)->pData)); - - if (fwrite(mDccData.pData, dccDataSize, 1, fd) != 1) - { - CAMHAL_LOGEA("ERROR: Writing to DCC file failed"); - } - else - { - CAMHAL_LOGDA("DCC file successfully updated"); - } - } - fclose(fd); - } - else - { - CAMHAL_LOGEA("ERROR: Correct DCC file not found or failed to open for modification"); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::closeDccFileDataSave() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mDccDataLock); - - if (mDccData.pData) { - free(mDccData.pData); - mDccData.pData = NULL; - } - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/OMXCameraAdapter/OMXDefaults.cpp b/camera/OMXCameraAdapter/OMXDefaults.cpp deleted file mode 100644 index fd3b5aa..0000000 --- a/camera/OMXCameraAdapter/OMXDefaults.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMXDefaults.cpp -* -* This file contains definitions are OMX Camera defaults -* -*/ - -#include "CameraHal.h" -#include "OMXCameraAdapter.h" - -namespace Ti { -namespace Camera { - -#define __STRINGIFY(s) __STRING(s) - -// OMX Camera defaults -const char OMXCameraAdapter::DEFAULT_ANTIBANDING[] = "auto"; -const char OMXCameraAdapter::DEFAULT_BRIGHTNESS[] = "50"; -const char OMXCameraAdapter::DEFAULT_CONTRAST[] = "100"; -const char OMXCameraAdapter::DEFAULT_EFFECT[] = "none"; -const char OMXCameraAdapter::DEFAULT_EV_COMPENSATION[] = "0"; -const char OMXCameraAdapter::DEFAULT_EV_STEP[] = "0.1"; -const char OMXCameraAdapter::DEFAULT_EXPOSURE_MODE[] = "auto"; -const char OMXCameraAdapter::DEFAULT_FLASH_MODE[] = "off"; -const char OMXCameraAdapter::DEFAULT_FOCUS_MODE_PREFERRED[] = "auto"; -const char OMXCameraAdapter::DEFAULT_FOCUS_MODE[] = "infinity"; -const char OMXCameraAdapter::DEFAULT_IPP[] = "ldc-nsf"; -const char OMXCameraAdapter::DEFAULT_ISO_MODE[] = "auto"; -const char OMXCameraAdapter::DEFAULT_JPEG_QUALITY[] = "95"; -const char OMXCameraAdapter::DEFAULT_THUMBNAIL_QUALITY[] = "60"; -const char OMXCameraAdapter::DEFAULT_THUMBNAIL_SIZE[] = "160x120"; -const char OMXCameraAdapter::DEFAULT_PICTURE_FORMAT[] = "jpeg"; -#ifndef OMAP_TUNA -const char OMXCameraAdapter::DEFAULT_S3D_PICTURE_LAYOUT[] = "tb-full"; -#endif -const char OMXCameraAdapter::DEFAULT_PICTURE_SIZE[] = "320x240"; -#ifndef OMAP_TUNA -const char OMXCameraAdapter::DEFAULT_PICTURE_SS_SIZE[] = "640x240"; -const char OMXCameraAdapter::DEFAULT_PICTURE_TB_SIZE[] = "320x480"; -#endif -const char OMXCameraAdapter::DEFAULT_PREVIEW_FORMAT[] = "yuv420sp"; -const char OMXCameraAdapter::DEFAULT_FRAMERATE[] = "30"; -#ifndef OMAP_TUNA -const char OMXCameraAdapter::DEFAULT_S3D_PREVIEW_LAYOUT[] = "tb-subsampled"; -#endif -const char OMXCameraAdapter::DEFAULT_PREVIEW_SIZE[] = "640x480"; -#ifndef OMAP_TUNA -const char OMXCameraAdapter::DEFAULT_PREVIEW_SS_SIZE[] = "1280x480"; -const char OMXCameraAdapter::DEFAULT_PREVIEW_TB_SIZE[] = "640x960"; -#endif -const char OMXCameraAdapter::DEFAULT_NUM_PREV_BUFS[] = "6"; -const char OMXCameraAdapter::DEFAULT_NUM_PIC_BUFS[] = "1"; -const char OMXCameraAdapter::DEFAULT_SATURATION[] = "100"; -const char OMXCameraAdapter::DEFAULT_SCENE_MODE[] = "auto"; -const char OMXCameraAdapter::DEFAULT_SHARPNESS[] = "100"; -const char * OMXCameraAdapter::DEFAULT_VSTAB = android::CameraParameters::FALSE; -const char * OMXCameraAdapter::DEFAULT_VNF = android::CameraParameters::FALSE; -const char OMXCameraAdapter::DEFAULT_WB[] = "auto"; -const char OMXCameraAdapter::DEFAULT_ZOOM[] = "0"; -const char OMXCameraAdapter::DEFAULT_MAX_FD_HW_FACES[] = __STRINGIFY(MAX_NUM_FACES_SUPPORTED); -const char OMXCameraAdapter::DEFAULT_MAX_FD_SW_FACES[] = "0"; -#ifdef OMAP_TUNA -const char OMXCameraAdapter::DEFAULT_FOCAL_LENGTH_PRIMARY[] = "3.43"; -const char OMXCameraAdapter::DEFAULT_FOCAL_LENGTH_SECONDARY[] = "1.95"; -#endif -const char OMXCameraAdapter::DEFAULT_HOR_ANGLE[] = "54.8"; -const char OMXCameraAdapter::DEFAULT_VER_ANGLE[] = "42.5"; -const char * OMXCameraAdapter::DEFAULT_AE_LOCK = android::CameraParameters::FALSE; -const char * OMXCameraAdapter::DEFAULT_AWB_LOCK = android::CameraParameters::FALSE; -const char OMXCameraAdapter::DEFAULT_VIDEO_SIZE[] = "1920x1080"; -const char OMXCameraAdapter::DEFAULT_SENSOR_ORIENTATION[] = "0"; -const char OMXCameraAdapter::DEFAULT_AUTOCONVERGENCE_MODE[] = "frame"; -const char OMXCameraAdapter::DEFAULT_MANUAL_CONVERGENCE[] = "0"; -#ifndef OMAP_TUNA -const char * OMXCameraAdapter::DEFAULT_MECHANICAL_MISALIGNMENT_CORRECTION_MODE = android::CameraParameters::TRUE; -#endif -const char OMXCameraAdapter::DEFAULT_EXIF_MAKE[] = "default_make"; -const char OMXCameraAdapter::DEFAULT_EXIF_MODEL[] = "default_model"; - -} // namespace Camera -} // namespace Ti diff --git a/camera/OMXCameraAdapter/OMXExif.cpp b/camera/OMXCameraAdapter/OMXExif.cpp deleted file mode 100644 index bf475e8..0000000 --- a/camera/OMXCameraAdapter/OMXExif.cpp +++ /dev/null @@ -1,845 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMXExif.cpp -* -* This file contains functionality for handling EXIF insertion. -* -*/ - -#include "CameraHal.h" -#include "OMXCameraAdapter.h" -#include - -namespace Ti { -namespace Camera { - -status_t OMXCameraAdapter::setParametersEXIF(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state) -{ - status_t ret = NO_ERROR; - const char *valstr = NULL; - double gpsPos; - - LOG_FUNCTION_NAME; - - if( ( valstr = params.get(android::CameraParameters::KEY_GPS_LATITUDE) ) != NULL ) - { - gpsPos = strtod(valstr, NULL); - - if ( convertGPSCoord(gpsPos, - mEXIFData.mGPSData.mLatDeg, - mEXIFData.mGPSData.mLatMin, - mEXIFData.mGPSData.mLatSec, - mEXIFData.mGPSData.mLatSecDiv ) == NO_ERROR ) - { - - if ( 0 < gpsPos ) - { - strncpy(mEXIFData.mGPSData.mLatRef, GPS_NORTH_REF, GPS_REF_SIZE); - } - else - { - strncpy(mEXIFData.mGPSData.mLatRef, GPS_SOUTH_REF, GPS_REF_SIZE); - } - - mEXIFData.mGPSData.mLatValid = true; - } - else - { - mEXIFData.mGPSData.mLatValid = false; - } - } - else - { - mEXIFData.mGPSData.mLatValid = false; - } - - if( ( valstr = params.get(android::CameraParameters::KEY_GPS_LONGITUDE) ) != NULL ) - { - gpsPos = strtod(valstr, NULL); - - if ( convertGPSCoord(gpsPos, - mEXIFData.mGPSData.mLongDeg, - mEXIFData.mGPSData.mLongMin, - mEXIFData.mGPSData.mLongSec, - mEXIFData.mGPSData.mLongSecDiv) == NO_ERROR ) - { - - if ( 0 < gpsPos ) - { - strncpy(mEXIFData.mGPSData.mLongRef, GPS_EAST_REF, GPS_REF_SIZE); - } - else - { - strncpy(mEXIFData.mGPSData.mLongRef, GPS_WEST_REF, GPS_REF_SIZE); - } - - mEXIFData.mGPSData.mLongValid= true; - } - else - { - mEXIFData.mGPSData.mLongValid = false; - } - } - else - { - mEXIFData.mGPSData.mLongValid = false; - } - - if( ( valstr = params.get(android::CameraParameters::KEY_GPS_ALTITUDE) ) != NULL ) - { - gpsPos = strtod(valstr, NULL); - mEXIFData.mGPSData.mAltitude = floor(fabs(gpsPos)); - if (gpsPos < 0) { - mEXIFData.mGPSData.mAltitudeRef = 1; - } else { - mEXIFData.mGPSData.mAltitudeRef = 0; - } - mEXIFData.mGPSData.mAltitudeValid = true; - } - else - { - mEXIFData.mGPSData.mAltitudeValid= false; - } - - if( (valstr = params.get(android::CameraParameters::KEY_GPS_TIMESTAMP)) != NULL ) - { - long gpsTimestamp = strtol(valstr, NULL, 10); - struct tm *timeinfo = gmtime( ( time_t * ) & (gpsTimestamp) ); - if ( NULL != timeinfo ) - { - mEXIFData.mGPSData.mTimeStampHour = timeinfo->tm_hour; - mEXIFData.mGPSData.mTimeStampMin = timeinfo->tm_min; - mEXIFData.mGPSData.mTimeStampSec = timeinfo->tm_sec; - mEXIFData.mGPSData.mTimeStampValid = true; - } - else - { - mEXIFData.mGPSData.mTimeStampValid = false; - } - } - else - { - mEXIFData.mGPSData.mTimeStampValid = false; - } - - if( ( valstr = params.get(android::CameraParameters::KEY_GPS_TIMESTAMP) ) != NULL ) - { - long gpsDatestamp = strtol(valstr, NULL, 10); - struct tm *timeinfo = gmtime( ( time_t * ) & (gpsDatestamp) ); - if ( NULL != timeinfo ) - { - strftime(mEXIFData.mGPSData.mDatestamp, GPS_DATESTAMP_SIZE, "%Y:%m:%d", timeinfo); - mEXIFData.mGPSData.mDatestampValid = true; - } - else - { - mEXIFData.mGPSData.mDatestampValid = false; - } - } - else - { - mEXIFData.mGPSData.mDatestampValid = false; - } - - if( ( valstr = params.get(android::CameraParameters::KEY_GPS_PROCESSING_METHOD) ) != NULL ) - { - strncpy(mEXIFData.mGPSData.mProcMethod, valstr, GPS_PROCESSING_SIZE-1); - mEXIFData.mGPSData.mProcMethodValid = true; - } - else - { - mEXIFData.mGPSData.mProcMethodValid = false; - } - - if( ( valstr = params.get(TICameraParameters::KEY_GPS_MAPDATUM) ) != NULL ) - { - strncpy(mEXIFData.mGPSData.mMapDatum, valstr, GPS_MAPDATUM_SIZE-1); - mEXIFData.mGPSData.mMapDatumValid = true; - } - else - { - mEXIFData.mGPSData.mMapDatumValid = false; - } - - if( ( valstr = params.get(TICameraParameters::KEY_GPS_VERSION) ) != NULL ) - { - strncpy(mEXIFData.mGPSData.mVersionId, valstr, GPS_VERSION_SIZE-1); - mEXIFData.mGPSData.mVersionIdValid = true; - } - else - { - mEXIFData.mGPSData.mVersionIdValid = false; - } - - if( ( valstr = params.get(TICameraParameters::KEY_EXIF_MODEL ) ) != NULL ) - { - CAMHAL_LOGVB("EXIF Model: %s", valstr); - strncpy(mEXIFData.mModel, valstr, EXIF_MODEL_SIZE - 1); - mEXIFData.mModelValid= true; - } - else - { - mEXIFData.mModelValid= false; - } - - if( ( valstr = params.get(TICameraParameters::KEY_EXIF_MAKE ) ) != NULL ) - { - CAMHAL_LOGVB("EXIF Make: %s", valstr); - strncpy(mEXIFData.mMake, valstr, EXIF_MAKE_SIZE - 1); - mEXIFData.mMakeValid = true; - } - else - { - mEXIFData.mMakeValid= false; - } - - - if( ( valstr = params.get(android::CameraParameters::KEY_FOCAL_LENGTH) ) != NULL ) { - CAMHAL_LOGVB("EXIF Focal length: %s", valstr); - ExifElementsTable::stringToRational(valstr, - &mEXIFData.mFocalNum, - &mEXIFData.mFocalDen); - } else { - mEXIFData.mFocalNum = 0; - mEXIFData.mFocalDen = 0; - } - - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setupEXIF() -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_TI_CONFIG_SHAREDBUFFER sharedBuffer; - OMX_TI_CONFIG_EXIF_TAGS *exifTags; - unsigned char *startPtr = NULL; - unsigned char *sharedPtr = NULL; - struct timeval sTv; - struct tm *pTime; - OMXCameraPortParameters * capData = NULL; - MemoryManager memMgr; - CameraBuffer *memmgr_buf_array = NULL; - int buf_size = 0; - - LOG_FUNCTION_NAME; - - ret = memMgr.initialize(); - if ( ret != OK ) { - CAMHAL_LOGE("MemoryManager initialization failed, error: %d", ret); - return ret; - } - - sharedBuffer.pSharedBuff = NULL; - capData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR (&sharedBuffer, OMX_TI_CONFIG_SHAREDBUFFER); - sharedBuffer.nPortIndex = mCameraAdapterParameters.mImagePortIndex; - - //We allocate the shared buffer dynamically based on the - //requirements of the EXIF tags. The additional buffers will - //get stored after the EXIF configuration structure and the pointers - //will contain offsets within the shared buffer itself. - buf_size = sizeof(OMX_TI_CONFIG_EXIF_TAGS) + - ( EXIF_MODEL_SIZE ) + - ( EXIF_MAKE_SIZE ) + - ( EXIF_DATE_TIME_SIZE ) + - ( GPS_MAPDATUM_SIZE ) + - ( GPS_PROCESSING_SIZE ); - buf_size = ((buf_size+4095)/4096)*4096; - sharedBuffer.nSharedBuffSize = buf_size; - - memmgr_buf_array = memMgr.allocateBufferList(0, 0, NULL, buf_size, 1); - sharedBuffer.pSharedBuff = (OMX_U8*)camera_buffer_get_omx_ptr(&memmgr_buf_array[0]); - startPtr = ( OMX_U8 * ) memmgr_buf_array[0].opaque; - - if ( NULL == startPtr) - { - CAMHAL_LOGEA("No resources to allocate OMX shared buffer"); - ret = -1; - } - - //Extra data begins right after the EXIF configuration structure. - sharedPtr = startPtr + sizeof(OMX_TI_CONFIG_EXIF_TAGS); - } - - if ( NO_ERROR == ret ) - { - exifTags = ( OMX_TI_CONFIG_EXIF_TAGS * ) startPtr; - OMX_INIT_STRUCT_PTR (exifTags, OMX_TI_CONFIG_EXIF_TAGS); - exifTags->nPortIndex = mCameraAdapterParameters.mImagePortIndex; - - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_TI_IndexConfigExifTags, - &sharedBuffer ); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while retrieving EXIF configuration structure 0x%x", eError); - ret = -1; - } - } - - if ( NO_ERROR == ret ) - { - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusModel ) && - ( mEXIFData.mModelValid ) ) - { - strncpy(( char * ) sharedPtr, - mEXIFData.mModel, - EXIF_MODEL_SIZE - 1); - - exifTags->pModelBuff = ( OMX_S8 * ) ( sharedPtr - startPtr ); - exifTags->ulModelBuffSizeBytes = strlen((char*)sharedPtr) + 1; - sharedPtr += EXIF_MODEL_SIZE; - exifTags->eStatusModel = OMX_TI_TagUpdated; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusMake) && - ( mEXIFData.mMakeValid ) ) - { - strncpy( ( char * ) sharedPtr, - mEXIFData.mMake, - EXIF_MAKE_SIZE - 1); - - exifTags->pMakeBuff = ( OMX_S8 * ) ( sharedPtr - startPtr ); - exifTags->ulMakeBuffSizeBytes = strlen((char*)sharedPtr) + 1; - sharedPtr += EXIF_MAKE_SIZE; - exifTags->eStatusMake = OMX_TI_TagUpdated; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusFocalLength )) - { - if (mEXIFData.mFocalNum || mEXIFData.mFocalDen ) { - exifTags->ulFocalLength[0] = (OMX_U32) mEXIFData.mFocalNum; - exifTags->ulFocalLength[1] = (OMX_U32) mEXIFData.mFocalDen; - CAMHAL_LOGVB("exifTags->ulFocalLength = [%u] [%u]", - (unsigned int)(exifTags->ulFocalLength[0]), - (unsigned int)(exifTags->ulFocalLength[1])); - exifTags->eStatusFocalLength = OMX_TI_TagUpdated; - } - } - - if ( OMX_TI_TagReadWrite == exifTags->eStatusDateTime ) - { - int status = gettimeofday (&sTv, NULL); - pTime = localtime (&sTv.tv_sec); - if ( ( 0 == status ) && ( NULL != pTime ) ) - { - snprintf(( char * ) sharedPtr, EXIF_DATE_TIME_SIZE, - "%04d:%02d:%02d %02d:%02d:%02d", - pTime->tm_year + 1900, - pTime->tm_mon + 1, - pTime->tm_mday, - pTime->tm_hour, - pTime->tm_min, - pTime->tm_sec ); - } - - exifTags->pDateTimeBuff = ( OMX_S8 * ) ( sharedPtr - startPtr ); - sharedPtr += EXIF_DATE_TIME_SIZE; - exifTags->ulDateTimeBuffSizeBytes = EXIF_DATE_TIME_SIZE; - exifTags->eStatusDateTime = OMX_TI_TagUpdated; - } - - if ( OMX_TI_TagReadWrite == exifTags->eStatusImageWidth ) - { - exifTags->ulImageWidth = capData->mWidth; - exifTags->eStatusImageWidth = OMX_TI_TagUpdated; - } - - if ( OMX_TI_TagReadWrite == exifTags->eStatusImageHeight ) - { - exifTags->ulImageHeight = capData->mHeight; - exifTags->eStatusImageHeight = OMX_TI_TagUpdated; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusGpsLatitude ) && - ( mEXIFData.mGPSData.mLatValid ) ) - { - exifTags->ulGpsLatitude[0] = abs(mEXIFData.mGPSData.mLatDeg); - exifTags->ulGpsLatitude[2] = abs(mEXIFData.mGPSData.mLatMin); - exifTags->ulGpsLatitude[4] = abs(mEXIFData.mGPSData.mLatSec); - exifTags->ulGpsLatitude[1] = 1; - exifTags->ulGpsLatitude[3] = 1; - exifTags->ulGpsLatitude[5] = abs(mEXIFData.mGPSData.mLatSecDiv); - exifTags->eStatusGpsLatitude = OMX_TI_TagUpdated; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusGpslatitudeRef ) && - ( mEXIFData.mGPSData.mLatValid ) ) - { - exifTags->cGpslatitudeRef[0] = ( OMX_S8 ) mEXIFData.mGPSData.mLatRef[0]; - exifTags->cGpslatitudeRef[1] = '\0'; - exifTags->eStatusGpslatitudeRef = OMX_TI_TagUpdated; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusGpsLongitude ) && - ( mEXIFData.mGPSData.mLongValid ) ) - { - exifTags->ulGpsLongitude[0] = abs(mEXIFData.mGPSData.mLongDeg); - exifTags->ulGpsLongitude[2] = abs(mEXIFData.mGPSData.mLongMin); - exifTags->ulGpsLongitude[4] = abs(mEXIFData.mGPSData.mLongSec); - exifTags->ulGpsLongitude[1] = 1; - exifTags->ulGpsLongitude[3] = 1; - exifTags->ulGpsLongitude[5] = abs(mEXIFData.mGPSData.mLongSecDiv); - exifTags->eStatusGpsLongitude = OMX_TI_TagUpdated; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusGpsLongitudeRef ) && - ( mEXIFData.mGPSData.mLongValid ) ) - { - exifTags->cGpsLongitudeRef[0] = ( OMX_S8 ) mEXIFData.mGPSData.mLongRef[0]; - exifTags->cGpsLongitudeRef[1] = '\0'; - exifTags->eStatusGpsLongitudeRef = OMX_TI_TagUpdated; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusGpsAltitude ) && - ( mEXIFData.mGPSData.mAltitudeValid) ) - { - exifTags->ulGpsAltitude[0] = ( OMX_U32 ) mEXIFData.mGPSData.mAltitude; - exifTags->ulGpsAltitude[1] = 1; - exifTags->eStatusGpsAltitude = OMX_TI_TagUpdated; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusGpsAltitudeRef ) && - ( mEXIFData.mGPSData.mAltitudeValid) ) - { - exifTags->ucGpsAltitudeRef = (OMX_U8) mEXIFData.mGPSData.mAltitudeRef; - exifTags->eStatusGpsAltitudeRef = OMX_TI_TagUpdated; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusGpsMapDatum ) && - ( mEXIFData.mGPSData.mMapDatumValid ) ) - { - memcpy(sharedPtr, mEXIFData.mGPSData.mMapDatum, GPS_MAPDATUM_SIZE); - - exifTags->pGpsMapDatumBuff = ( OMX_S8 * ) ( sharedPtr - startPtr ); - exifTags->ulGpsMapDatumBuffSizeBytes = GPS_MAPDATUM_SIZE; - exifTags->eStatusGpsMapDatum = OMX_TI_TagUpdated; - sharedPtr += GPS_MAPDATUM_SIZE; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusGpsProcessingMethod ) && - ( mEXIFData.mGPSData.mProcMethodValid ) ) - { - exifTags->pGpsProcessingMethodBuff = ( OMX_S8 * ) ( sharedPtr - startPtr ); - memcpy(sharedPtr, ExifAsciiPrefix, sizeof(ExifAsciiPrefix)); - sharedPtr += sizeof(ExifAsciiPrefix); - - memcpy(sharedPtr, - mEXIFData.mGPSData.mProcMethod, - ( GPS_PROCESSING_SIZE - sizeof(ExifAsciiPrefix) ) ); - exifTags->ulGpsProcessingMethodBuffSizeBytes = GPS_PROCESSING_SIZE; - exifTags->eStatusGpsProcessingMethod = OMX_TI_TagUpdated; - sharedPtr += GPS_PROCESSING_SIZE; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusGpsVersionId ) && - ( mEXIFData.mGPSData.mVersionIdValid ) ) - { - exifTags->ucGpsVersionId[0] = ( OMX_U8 ) mEXIFData.mGPSData.mVersionId[0]; - exifTags->ucGpsVersionId[1] = ( OMX_U8 ) mEXIFData.mGPSData.mVersionId[1]; - exifTags->ucGpsVersionId[2] = ( OMX_U8 ) mEXIFData.mGPSData.mVersionId[2]; - exifTags->ucGpsVersionId[3] = ( OMX_U8 ) mEXIFData.mGPSData.mVersionId[3]; - exifTags->eStatusGpsVersionId = OMX_TI_TagUpdated; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusGpsTimeStamp ) && - ( mEXIFData.mGPSData.mTimeStampValid ) ) - { - exifTags->ulGpsTimeStamp[0] = mEXIFData.mGPSData.mTimeStampHour; - exifTags->ulGpsTimeStamp[2] = mEXIFData.mGPSData.mTimeStampMin; - exifTags->ulGpsTimeStamp[4] = mEXIFData.mGPSData.mTimeStampSec; - exifTags->ulGpsTimeStamp[1] = 1; - exifTags->ulGpsTimeStamp[3] = 1; - exifTags->ulGpsTimeStamp[5] = 1; - exifTags->eStatusGpsTimeStamp = OMX_TI_TagUpdated; - } - - if ( ( OMX_TI_TagReadWrite == exifTags->eStatusGpsDateStamp ) && - ( mEXIFData.mGPSData.mDatestampValid ) ) - { - strncpy( ( char * ) exifTags->cGpsDateStamp, - ( char * ) mEXIFData.mGPSData.mDatestamp, - GPS_DATESTAMP_SIZE ); - exifTags->eStatusGpsDateStamp = OMX_TI_TagUpdated; - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_TI_IndexConfigExifTags, - &sharedBuffer ); - - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while setting EXIF configuration 0x%x", eError); - ret = -1; - } - } - - if ( NULL != memmgr_buf_array ) - { - memMgr.freeBufferList(memmgr_buf_array); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setupEXIF_libjpeg(ExifElementsTable* exifTable, - OMX_TI_ANCILLARYDATATYPE* pAncillaryData, - OMX_TI_WHITEBALANCERESULTTYPE* pWhiteBalanceData) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - struct timeval sTv; - struct tm *pTime; - OMXCameraPortParameters * capData = NULL; - - LOG_FUNCTION_NAME; - - capData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mImagePortIndex]; - - if ((NO_ERROR == ret) && (mEXIFData.mModelValid)) { - ret = exifTable->insertElement(TAG_MODEL, mEXIFData.mModel); - } - - if ((NO_ERROR == ret) && (mEXIFData.mMakeValid)) { - ret = exifTable->insertElement(TAG_MAKE, mEXIFData.mMake); - } - - if ((NO_ERROR == ret)) { - if (mEXIFData.mFocalNum || mEXIFData.mFocalDen) { - char temp_value[256]; // arbitrarily long string - snprintf(temp_value, - sizeof(temp_value)/sizeof(char), - "%u/%u", - mEXIFData.mFocalNum, - mEXIFData.mFocalDen); - ret = exifTable->insertElement(TAG_FOCALLENGTH, temp_value); - - } - } - - if ((NO_ERROR == ret)) { - int status = gettimeofday (&sTv, NULL); - pTime = localtime (&sTv.tv_sec); - char temp_value[EXIF_DATE_TIME_SIZE + 1]; - if ((0 == status) && (NULL != pTime)) { - snprintf(temp_value, EXIF_DATE_TIME_SIZE, - "%04d:%02d:%02d %02d:%02d:%02d", - pTime->tm_year + 1900, - pTime->tm_mon + 1, - pTime->tm_mday, - pTime->tm_hour, - pTime->tm_min, - pTime->tm_sec ); - ret = exifTable->insertElement(TAG_DATETIME, temp_value); - } - } - - if ((NO_ERROR == ret)) { - char temp_value[5]; - snprintf(temp_value, sizeof(temp_value)/sizeof(char), "%u", capData->mWidth); - ret = exifTable->insertElement(TAG_IMAGE_WIDTH, temp_value); - } - - if ((NO_ERROR == ret)) { - char temp_value[5]; - snprintf(temp_value, sizeof(temp_value)/sizeof(char), "%u", capData->mHeight); - ret = exifTable->insertElement(TAG_IMAGE_LENGTH, temp_value); - } - - if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mLatValid)) { - char temp_value[256]; // arbitrarily long string - snprintf(temp_value, - sizeof(temp_value)/sizeof(char) - 1, - "%d/%d,%d/%d,%d/%d", - abs(mEXIFData.mGPSData.mLatDeg), 1, - abs(mEXIFData.mGPSData.mLatMin), 1, - abs(mEXIFData.mGPSData.mLatSec), abs(mEXIFData.mGPSData.mLatSecDiv)); - ret = exifTable->insertElement(TAG_GPS_LAT, temp_value); - } - - if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mLatValid)) { - ret = exifTable->insertElement(TAG_GPS_LAT_REF, mEXIFData.mGPSData.mLatRef); - } - - if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mLongValid)) { - char temp_value[256]; // arbitrarily long string - snprintf(temp_value, - sizeof(temp_value)/sizeof(char) - 1, - "%d/%d,%d/%d,%d/%d", - abs(mEXIFData.mGPSData.mLongDeg), 1, - abs(mEXIFData.mGPSData.mLongMin), 1, - abs(mEXIFData.mGPSData.mLongSec), abs(mEXIFData.mGPSData.mLongSecDiv)); - ret = exifTable->insertElement(TAG_GPS_LONG, temp_value); - } - - if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mLongValid)) { - ret = exifTable->insertElement(TAG_GPS_LONG_REF, mEXIFData.mGPSData.mLongRef); - } - - if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mAltitudeValid)) { - char temp_value[256]; // arbitrarily long string - snprintf(temp_value, - sizeof(temp_value)/sizeof(char) - 1, - "%d/%d", - abs( mEXIFData.mGPSData.mAltitude), 1); - ret = exifTable->insertElement(TAG_GPS_ALT, temp_value); - } - - if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mAltitudeValid)) { - char temp_value[5]; - snprintf(temp_value, - sizeof(temp_value)/sizeof(char) - 1, - "%d", mEXIFData.mGPSData.mAltitudeRef); - ret = exifTable->insertElement(TAG_GPS_ALT_REF, temp_value); - } - - if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mMapDatumValid)) { - ret = exifTable->insertElement(TAG_GPS_MAP_DATUM, mEXIFData.mGPSData.mMapDatum); - } - - if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mProcMethodValid)) { - char temp_value[GPS_PROCESSING_SIZE]; - - memcpy(temp_value, ExifAsciiPrefix, sizeof(ExifAsciiPrefix)); - memcpy(temp_value + sizeof(ExifAsciiPrefix), - mEXIFData.mGPSData.mProcMethod, - (GPS_PROCESSING_SIZE - sizeof(ExifAsciiPrefix))); - ret = exifTable->insertElement(TAG_GPS_PROCESSING_METHOD, temp_value); - } - - if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mVersionIdValid)) { - char temp_value[256]; // arbitrarily long string - snprintf(temp_value, - sizeof(temp_value)/sizeof(char) - 1, - "%d,%d,%d,%d", - mEXIFData.mGPSData.mVersionId[0], - mEXIFData.mGPSData.mVersionId[1], - mEXIFData.mGPSData.mVersionId[2], - mEXIFData.mGPSData.mVersionId[3]); - ret = exifTable->insertElement(TAG_GPS_VERSION_ID, temp_value); - } - - if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mTimeStampValid)) { - char temp_value[256]; // arbitrarily long string - snprintf(temp_value, - sizeof(temp_value)/sizeof(char) - 1, - "%d/%d,%d/%d,%d/%d", - mEXIFData.mGPSData.mTimeStampHour, 1, - mEXIFData.mGPSData.mTimeStampMin, 1, - mEXIFData.mGPSData.mTimeStampSec, 1); - ret = exifTable->insertElement(TAG_GPS_TIMESTAMP, temp_value); - } - - if ((NO_ERROR == ret) && (mEXIFData.mGPSData.mDatestampValid) ) { - ret = exifTable->insertElement(TAG_GPS_DATESTAMP, mEXIFData.mGPSData.mDatestamp); - } - - if (NO_ERROR == ret) { - const char* exif_orient = - ExifElementsTable::degreesToExifOrientation(mPictureRotation); - - if (exif_orient) { - ret = exifTable->insertElement(TAG_ORIENTATION, exif_orient); - } - } - - // fill in short and ushort tags - if (NO_ERROR == ret) { - char temp_value[2]; - temp_value[1] = '\0'; - - // AWB - if (mParameters3A.WhiteBallance == OMX_WhiteBalControlAuto) { - temp_value[0] = '0'; - } else { - temp_value[0] = '1'; - } - exifTable->insertElement(TAG_WHITEBALANCE, temp_value); - - // MeteringMode - // TODO(XXX): only supporting this metering mode at the moment, may change in future - temp_value[0] = '2'; - exifTable->insertElement(TAG_METERING_MODE, temp_value); - - // ExposureProgram - // TODO(XXX): only supporting this exposure program at the moment, may change in future - temp_value[0] = '3'; - exifTable->insertElement(TAG_EXPOSURE_PROGRAM, temp_value); - - // ColorSpace - temp_value[0] = '1'; - exifTable->insertElement(TAG_COLOR_SPACE, temp_value); - - temp_value[0] = '2'; - exifTable->insertElement(TAG_SENSING_METHOD, temp_value); - - temp_value[0] = '1'; - exifTable->insertElement(TAG_CUSTOM_RENDERED, temp_value); - } - - if (pAncillaryData && (NO_ERROR == ret)) { - unsigned int numerator = 0, denominator = 0; - char temp_value[256]; - unsigned int temp_num = 0; - - // DigitalZoomRatio - snprintf(temp_value, - sizeof(temp_value)/sizeof(char), - "%u/%u", - pAncillaryData->nDigitalZoomFactor, 1024); - exifTable->insertElement(TAG_DIGITALZOOMRATIO, temp_value); - - // ExposureTime - snprintf(temp_value, - sizeof(temp_value)/sizeof(char), - "%u/%u", - pAncillaryData->nExposureTime, 1000000); - exifTable->insertElement(TAG_EXPOSURETIME, temp_value); - - // ApertureValue and FNumber - snprintf(temp_value, - sizeof(temp_value)/sizeof(char), - "%u/%u", - pAncillaryData->nApertureValue, 100); - exifTable->insertElement(TAG_FNUMBER, temp_value); - exifTable->insertElement(TAG_APERTURE, temp_value); - - // ISO - snprintf(temp_value, - sizeof(temp_value)/sizeof(char), - "%u,0,0", - pAncillaryData->nCurrentISO); - exifTable->insertElement(TAG_ISO_EQUIVALENT, temp_value); - - // ShutterSpeed - snprintf(temp_value, - sizeof(temp_value)/sizeof(char), - "%f", - log(pAncillaryData->nExposureTime) / log(2)); - ExifElementsTable::stringToRational(temp_value, &numerator, &denominator); - snprintf(temp_value, sizeof(temp_value)/sizeof(char), "%u/%u", numerator, denominator); - exifTable->insertElement(TAG_SHUTTERSPEED, temp_value); - - // Flash - if (mParameters3A.FlashMode == OMX_IMAGE_FlashControlAuto) { - if(pAncillaryData->nFlashStatus) temp_num = 0x19; // Flash fired, auto mode - else temp_num = 0x18; // Flash did not fire, auto mode - } else if (mParameters3A.FlashMode == OMX_IMAGE_FlashControlOn) { - if(pAncillaryData->nFlashStatus) temp_num = 0x9; // Flash fired, compulsory flash mode - else temp_num = 0x10; // Flash did not fire, compulsory flash mode - } else if(pAncillaryData->nFlashStatus) { - temp_num = 0x1; // Flash fired - } else { - temp_num = 0x0; // Flash did not fire - } - snprintf(temp_value, - sizeof(temp_value)/sizeof(char), - "%u", temp_num); - exifTable->insertElement(TAG_FLASH, temp_value); - - if (pWhiteBalanceData) { - unsigned int lightsource = 0; - unsigned int colourtemp = pWhiteBalanceData->nColorTemperature; - bool flash_fired = (temp_num & 0x1); // value from flash above - - // stole this from framework/tools_library/src/tools_sys_exif_tags.c - if( colourtemp <= 3200 ) { - lightsource = 3; // Tungsten - } else if( colourtemp > 3200 && colourtemp <= 4800 ) { - lightsource = 2; // Fluorescent - } else if( colourtemp > 4800 && colourtemp <= 5500 ) { - lightsource = 1; // Daylight - } else if( colourtemp > 5500 && colourtemp <= 6500 ) { - lightsource = 9; // Fine weather - } else if( colourtemp > 6500 ) { - lightsource = 10; // Cloudy weather - } - - if(flash_fired) { - lightsource = 4; // Flash - } - - snprintf(temp_value, - sizeof(temp_value)/sizeof(char), - "%u", lightsource); - exifTable->insertElement(TAG_LIGHT_SOURCE, temp_value); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::convertGPSCoord(double coord, - int °, - int &min, - int &sec, - int &secDivisor) -{ - double tmp; - - LOG_FUNCTION_NAME; - - if ( coord == 0 ) { - - CAMHAL_LOGE("Invalid GPS coordinate"); - - return -EINVAL; - } - - deg = (int) floor(fabs(coord)); - tmp = ( fabs(coord) - floor(fabs(coord)) ) * GPS_MIN_DIV; - min = (int) floor(tmp); - tmp = ( tmp - floor(tmp) ) * ( GPS_SEC_DIV * GPS_SEC_ACCURACY ); - sec = (int) floor(tmp); - secDivisor = GPS_SEC_ACCURACY; - - if( sec >= ( GPS_SEC_DIV * GPS_SEC_ACCURACY ) ) { - sec = 0; - min += 1; - } - - if( min >= 60 ) { - min = 0; - deg += 1; - } - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/OMXCameraAdapter/OMXFD.cpp b/camera/OMXCameraAdapter/OMXFD.cpp deleted file mode 100644 index 9220008..0000000 --- a/camera/OMXCameraAdapter/OMXFD.cpp +++ /dev/null @@ -1,504 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMXFD.cpp -* -* This file contains functionality for handling face detection. -* -*/ - -#include "CameraHal.h" -#include "OMXCameraAdapter.h" - -namespace Ti { -namespace Camera { - -const uint32_t OMXCameraAdapter::FACE_DETECTION_THRESHOLD = 80; - -status_t OMXCameraAdapter::setParametersFD(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::startFaceDetection() -{ - status_t ret = NO_ERROR; - - android::AutoMutex lock(mFaceDetectionLock); - - ret = setFaceDetection(true, mFaceOrientation); - if (ret != NO_ERROR) { - goto out; - } - - if ( mFaceDetectionRunning ) { - mFDSwitchAlgoPriority = true; - } - - // Note: White balance will not be face prioritized, since - // the algorithm needs full frame statistics, and not face - // regions alone. - - faceDetectionNumFacesLastOutput = 0; - out: - return ret; -} - -status_t OMXCameraAdapter::stopFaceDetection() -{ - status_t ret = NO_ERROR; - const char *str = NULL; - BaseCameraAdapter::AdapterState state; - BaseCameraAdapter::getState(state); - - android::AutoMutex lock(mFaceDetectionLock); - - ret = setFaceDetection(false, mFaceOrientation); - if (ret != NO_ERROR) { - goto out; - } - - if ( mFaceDetectionRunning ) { - //Enable region priority and disable face priority for AF - setAlgoPriority(REGION_PRIORITY, FOCUS_ALGO, true); - setAlgoPriority(FACE_PRIORITY, FOCUS_ALGO , false); - - //Enable Region priority and disable Face priority - setAlgoPriority(REGION_PRIORITY, EXPOSURE_ALGO, true); - setAlgoPriority(FACE_PRIORITY, EXPOSURE_ALGO, false); - } - - if (mPending3Asettings) { - apply3Asettings(mParameters3A); - } - - faceDetectionNumFacesLastOutput = 0; - out: - return ret; -} - -void OMXCameraAdapter::pauseFaceDetection(bool pause) -{ - android::AutoMutex lock(mFaceDetectionLock); - // pausing will only take affect if fd is already running - if (mFaceDetectionRunning) { - mFaceDetectionPaused = pause; - faceDetectionNumFacesLastOutput = 0; - } -} - -status_t OMXCameraAdapter::setFaceDetectionOrientation(OMX_U32 orientation) -{ - status_t ret = NO_ERROR; - - android::AutoMutex lock(mFaceDetectionLock); - - mFaceOrientation = orientation; - - if (mFaceDetectionRunning) { - // restart face detection with new rotation - setFaceDetection(true, orientation); - } - - return ret; -} - -status_t OMXCameraAdapter::setFaceDetection(bool enable, OMX_U32 orientation) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_OBJDETECTIONTYPE objDetection; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = -EINVAL; - } - - if ( NO_ERROR == ret ) - { - if ( orientation > 270 ) { - orientation = 0; - } - - OMX_INIT_STRUCT_PTR (&objDetection, OMX_CONFIG_OBJDETECTIONTYPE); - objDetection.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - objDetection.nDeviceOrientation = orientation; - if ( enable ) - { - objDetection.bEnable = OMX_TRUE; - } - else - { - objDetection.bEnable = OMX_FALSE; - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_IndexConfigImageFaceDetection, - &objDetection); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while configuring face detection 0x%x", eError); - ret = -1; - } - else - { - CAMHAL_LOGDA("Face detection configured successfully"); - } - } - - if ( NO_ERROR == ret ) - { - // TODO(XXX): Should enable/disable FD extra data separately - // on each port. - ret = setExtraData(enable, OMX_ALL, OMX_FaceDetection); - - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEA("Error while configuring face detection extra data"); - } - else - { - CAMHAL_LOGDA("Face detection extra data configured successfully"); - } - } - - if ( NO_ERROR == ret ) - { - mFaceDetectionRunning = enable; - mFaceDetectionPaused = !enable; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::createPreviewMetadata(OMX_BUFFERHEADERTYPE* pBuffHeader, - android::sp &result, - size_t previewWidth, - size_t previewHeight) -{ - status_t ret = NO_ERROR; - status_t faceRet = NO_ERROR; - status_t metaRet = NO_ERROR; - OMX_FACEDETECTIONTYPE *faceData = NULL; - - LOG_FUNCTION_NAME; - - if ( OMX_StateExecuting != mComponentState ) { - CAMHAL_LOGEA("OMX component is not in executing state"); - return NO_INIT; - } - - if ( NULL == pBuffHeader ) { - CAMHAL_LOGEA("Invalid Buffer header"); - return-EINVAL; - } - - if ( mFaceDetectionRunning && !mFaceDetectionPaused ) { - OMX_OTHER_EXTRADATATYPE *extraData; - - extraData = getExtradata(pBuffHeader->pPlatformPrivate, - (OMX_EXTRADATATYPE)OMX_FaceDetection); - - if ( NULL != extraData ) { - CAMHAL_LOGSVB("Size = %d, sizeof = %d, eType = 0x%x, nDataSize= %d, nPortIndex = 0x%x, nVersion = 0x%x", - extraData->nSize, - sizeof(OMX_OTHER_EXTRADATATYPE), - extraData->eType, - extraData->nDataSize, - extraData->nPortIndex, - extraData->nVersion); - } else { - CAMHAL_LOGD("FD extra data not found!"); - return -EINVAL; - } - - faceData = ( OMX_FACEDETECTIONTYPE * ) extraData->data; - if ( NULL != faceData ) { - if ( sizeof(OMX_FACEDETECTIONTYPE) == faceData->nSize ) { - CAMHAL_LOGSVB("Faces detected %d", - faceData->ulFaceCount, - faceData->nSize, - sizeof(OMX_FACEDETECTIONTYPE), - faceData->eCameraView, - faceData->nPortIndex, - faceData->nVersion); - } else { - CAMHAL_LOGEB("OMX_FACEDETECTIONTYPE size mismatch: expected = %d, received = %d", - ( unsigned int ) sizeof(OMX_FACEDETECTIONTYPE), - ( unsigned int ) faceData->nSize); - return -EINVAL; - } - } else { - CAMHAL_LOGEA("Invalid OMX_FACEDETECTIONTYPE"); - return -EINVAL; - } - } - - result = new (std::nothrow) CameraMetadataResult; - if(NULL == result.get()) { - ret = NO_MEMORY; - return ret; - } - - //Encode face coordinates - faceRet = encodeFaceCoordinates(faceData, result->getMetadataResult() - , previewWidth, previewHeight); - if ((NO_ERROR == faceRet) || (NOT_ENOUGH_DATA == faceRet)) { - // Ignore harmless errors (no error and no update) and go ahead and encode - // the preview meta data - metaRet = encodePreviewMetadata(result->getMetadataResult() - , pBuffHeader->pPlatformPrivate); - if ( (NO_ERROR != metaRet) && (NOT_ENOUGH_DATA != metaRet) ) { - // Some 'real' error occurred during preview meta data encod, clear metadata - // result and return correct error code - result.clear(); - ret = metaRet; - } - } else { - //Some real error occurred during face encoding, clear metadata result - // and return correct error code - result.clear(); - ret = faceRet; - } - - if((NOT_ENOUGH_DATA == faceRet) && (NOT_ENOUGH_DATA == metaRet)) { - //No point sending the callback if nothing is changed - result.clear(); - ret = faceRet; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::encodeFaceCoordinates(const OMX_FACEDETECTIONTYPE *faceData, - camera_frame_metadata_t *metadataResult, - size_t previewWidth, - size_t previewHeight) -{ - status_t ret = NO_ERROR; - camera_face_t *faces; - size_t hRange, vRange; - double tmp; - bool faceArrayChanged = false; - - LOG_FUNCTION_NAME; - - hRange = CameraMetadataResult::RIGHT - CameraMetadataResult::LEFT; - vRange = CameraMetadataResult::BOTTOM - CameraMetadataResult::TOP; - - android::AutoMutex lock(mFaceDetectionLock); - - // Avoid memory leak if called twice on same CameraMetadataResult - if ( (0 < metadataResult->number_of_faces) && (NULL != metadataResult->faces) ) { - free(metadataResult->faces); - metadataResult->number_of_faces = 0; - metadataResult->faces = NULL; - } - - if ( (NULL != faceData) && (0 < faceData->ulFaceCount) ) { - int orient_mult; - int trans_left, trans_top, trans_right, trans_bot; - - faces = ( camera_face_t * ) malloc(sizeof(camera_face_t)*faceData->ulFaceCount); - if ( NULL == faces ) { - ret = NO_MEMORY; - goto out; - } - - /** - / * When device is 180 degrees oriented to the sensor, need to translate - / * the output from Ducati to what Android expects - / * Ducati always gives face coordinates in this form, irrespective of - / * rotation, i.e (l,t) always represents the point towards the left eye - / * and top of hair. - / * (l, t) - / * --------------- - / * - ,,,,,,, - - / * - | | - - / * - | a>| - - / * - | | - - / * - ,,,,,,, - - / * --------------- - / * (r, b) - */ - - if (mFaceOrientation == 180) { - orient_mult = -1; - trans_left = 2; // right is now left - trans_top = 3; // bottom is now top - trans_right = 0; // left is now right - trans_bot = 1; // top is not bottom - } else { - orient_mult = 1; - trans_left = 0; // left - trans_top = 1; // top - trans_right = 2; // right - trans_bot = 3; // bottom - } - - int j = 0, i = 0; - for ( ; j < faceData->ulFaceCount ; j++) - { - OMX_S32 nLeft = 0; - OMX_S32 nTop = 0; - //Face filtering - //For real faces, it is seen that the h/w passes a score >=80 - //For false faces, we seem to get even a score of 70 sometimes. - //In order to avoid any issue at application level, we filter - //<=70 score here. - if(faceData->tFacePosition[j].nScore <= FACE_DETECTION_THRESHOLD) - continue; - - if (mFaceOrientation == 180) { - // from sensor pov, the left pos is the right corner of the face in pov of frame - nLeft = faceData->tFacePosition[j].nLeft + faceData->tFacePosition[j].nWidth; - nTop = faceData->tFacePosition[j].nTop + faceData->tFacePosition[j].nHeight; - } else { - nLeft = faceData->tFacePosition[j].nLeft; - nTop = faceData->tFacePosition[j].nTop; - } - - tmp = ( double ) nLeft / ( double ) previewWidth; - tmp *= hRange; - tmp -= hRange/2; - faces[i].rect[trans_left] = tmp; - - tmp = ( double ) nTop / ( double )previewHeight; - tmp *= vRange; - tmp -= vRange/2; - faces[i].rect[trans_top] = tmp; - - tmp = ( double ) faceData->tFacePosition[j].nWidth / ( double ) previewWidth; - tmp *= hRange; - tmp *= orient_mult; - faces[i].rect[trans_right] = faces[i].rect[trans_left] + tmp; - - tmp = ( double ) faceData->tFacePosition[j].nHeight / ( double ) previewHeight; - tmp *= vRange; - tmp *= orient_mult; - faces[i].rect[trans_bot] = faces[i].rect[trans_top] + tmp; - - faces[i].score = faceData->tFacePosition[j].nScore; - faces[i].id = 0; - faces[i].left_eye[0] = CameraMetadataResult::INVALID_DATA; - faces[i].left_eye[1] = CameraMetadataResult::INVALID_DATA; - faces[i].right_eye[0] = CameraMetadataResult::INVALID_DATA; - faces[i].right_eye[1] = CameraMetadataResult::INVALID_DATA; - faces[i].mouth[0] = CameraMetadataResult::INVALID_DATA; - faces[i].mouth[1] = CameraMetadataResult::INVALID_DATA; - i++; - } - - metadataResult->number_of_faces = i; - metadataResult->faces = faces; - - for (int i = 0; i < metadataResult->number_of_faces; i++) - { - bool faceChanged = true; - int centerX = (faces[i].rect[trans_left] + faces[i].rect[trans_right] ) / 2; - int centerY = (faces[i].rect[trans_top] + faces[i].rect[trans_bot] ) / 2; - - int sizeX = (faces[i].rect[trans_right] - faces[i].rect[trans_left] ) ; - int sizeY = (faces[i].rect[trans_bot] - faces[i].rect[trans_top] ) ; - - for (int j = 0; j < faceDetectionNumFacesLastOutput; j++) - { - int tempCenterX = (faceDetectionLastOutput[j].rect[trans_left] + - faceDetectionLastOutput[j].rect[trans_right] ) / 2; - int tempCenterY = (faceDetectionLastOutput[j].rect[trans_top] + - faceDetectionLastOutput[j].rect[trans_bot] ) / 2; - int tempSizeX = (faceDetectionLastOutput[j].rect[trans_right] - - faceDetectionLastOutput[j].rect[trans_left] ) ; - int tempSizeY = (faceDetectionLastOutput[j].rect[trans_bot] - - faceDetectionLastOutput[j].rect[trans_top] ) ; - - if ( ( tempCenterX == centerX) && - ( tempCenterY == centerY) ) { - // Found Face. - // Now check size of rectangle - // compare to last output. - if ( ( tempSizeX == sizeX ) && - ( tempSizeY == sizeY ) ) { - faceChanged = false; - } - } - } - // Send face detection data after some face coordinate changes - if (faceChanged) { - faceArrayChanged = true; - } - } - - // Save this output for next iteration - for (int i = 0; i < metadataResult->number_of_faces; i++) - { - faceDetectionLastOutput[i] = faces[i]; - } - } else { - metadataResult->number_of_faces = 0; - metadataResult->faces = NULL; - } - - // Send face detection data after face count changes - if (faceDetectionNumFacesLastOutput != metadataResult->number_of_faces) { - faceArrayChanged = true; - } - faceDetectionNumFacesLastOutput = metadataResult->number_of_faces; - - if ( !faceArrayChanged ) { - ret = NOT_ENOUGH_DATA; - } - - LOG_FUNCTION_NAME_EXIT; - -out: - - return ret; -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/OMXCameraAdapter/OMXFocus.cpp b/camera/OMXCameraAdapter/OMXFocus.cpp deleted file mode 100644 index db03f7d..0000000 --- a/camera/OMXCameraAdapter/OMXFocus.cpp +++ /dev/null @@ -1,890 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** -* @file OMXFocus.cpp -* -* This file contains functionality for handling focus configurations. -* -*/ - -#include "CameraHal.h" -#include "OMXCameraAdapter.h" -#include "ErrorUtils.h" - -#define TOUCH_FOCUS_RANGE 0xFF -#define AF_IMAGE_CALLBACK_TIMEOUT 5000000 //5 seconds timeout -#define AF_VIDEO_CALLBACK_TIMEOUT 2800000 //2.8 seconds timeout - -namespace Ti { -namespace Camera { - -const nsecs_t OMXCameraAdapter::CANCEL_AF_TIMEOUT = seconds_to_nanoseconds(1); - -status_t OMXCameraAdapter::setParametersFocus(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state) -{ - status_t ret = NO_ERROR; - const char *str = NULL; - android::Vector > tempAreas; - size_t MAX_FOCUS_AREAS; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mFocusAreasLock); - - str = params.get(android::CameraParameters::KEY_FOCUS_AREAS); - - MAX_FOCUS_AREAS = atoi(params.get(android::CameraParameters::KEY_MAX_NUM_FOCUS_AREAS)); - - if ( NULL != str ) { - ret = CameraArea::parseAreas(str, ( strlen(str) + 1 ), tempAreas); - } - - if ( (NO_ERROR == ret) && CameraArea::areAreasDifferent(mFocusAreas, tempAreas) ) { - mFocusAreas.clear(); - mFocusAreas = tempAreas; - if ( MAX_FOCUS_AREAS < mFocusAreas.size() ) { - CAMHAL_LOGEB("Focus areas supported %d, focus areas set %d", - MAX_FOCUS_AREAS, - mFocusAreas.size()); - ret = -EINVAL; - } - else { - if ( !mFocusAreas.isEmpty() ) { - setTouchFocus(); - } - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::doAutoFocus() -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE focusControl; - OMX_PARAM_FOCUSSTATUSTYPE focusStatus; - OMX_CONFIG_BOOLEANTYPE bOMX; - CameraAdapter::AdapterState state; - nsecs_t timeout = 0; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component in Invalid state"); - returnFocusStatus(false); - return -EINVAL; - } - - if ( OMX_StateExecuting != mComponentState ) - { - CAMHAL_LOGEA("OMX component not in executing state"); - returnFocusStatus(false); - return NO_ERROR; - } - - if( ((AF_ACTIVE & getState()) != AF_ACTIVE) && ((AF_ACTIVE & getNextState()) != AF_ACTIVE) ) { - CAMHAL_LOGDA("Auto focus got canceled before doAutoFocus could be called"); - return NO_ERROR; - } - - // AF when fixed focus modes are set should be a no-op. - if ( ( mParameters3A.Focus == OMX_IMAGE_FocusControlOff ) || - ( mParameters3A.Focus == OMX_IMAGE_FocusControlAutoInfinity ) || - ( mParameters3A.Focus == OMX_IMAGE_FocusControlHyperfocal ) ) { - returnFocusStatus(true); - return NO_ERROR; - } - - OMX_INIT_STRUCT_PTR (&focusStatus, OMX_PARAM_FOCUSSTATUSTYPE); - - // If the app calls autoFocus, the camera will stop sending face callbacks. - pauseFaceDetection(true); - - // This is needed for applying FOCUS_REGION correctly - if ( (!mFocusAreas.isEmpty()) && (!mFocusAreas.itemAt(0)->isZeroArea())) - { - //Disable face priority - setAlgoPriority(FACE_PRIORITY, FOCUS_ALGO, false); - - //Enable region algorithm priority - setAlgoPriority(REGION_PRIORITY, FOCUS_ALGO, true); - } - - OMX_INIT_STRUCT_PTR (&focusControl, OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE); - focusControl.eFocusControl = ( OMX_IMAGE_FOCUSCONTROLTYPE ) mParameters3A.Focus; - - if (mParameters3A.FocusLock) { - // this basically means user never called cancelAutoFocus after a scan... - // if this is the case we need to unlock AF to ensure we will do a scan - if (set3ALock(mUserSetExpLock, mUserSetWbLock, OMX_FALSE) != NO_ERROR) { - CAMHAL_LOGEA("Error Unlocking 3A locks"); - } else { - CAMHAL_LOGDA("AE/AWB unlocked successfully"); - } - - } else if ( mParameters3A.Focus == OMX_IMAGE_FocusControlAuto ) { - // In case we have CAF running we should first check the AF status. - // If it has managed to lock, then do as usual and return status - // immediately. - ret = checkFocus(&focusStatus); - if ( NO_ERROR != ret ) { - CAMHAL_LOGEB("Focus status check failed 0x%x!", ret); - return ret; - } else { - CAMHAL_LOGDB("Focus status check 0x%x!", focusStatus.eFocusStatus); - } - } - - if ( (focusControl.eFocusControl == OMX_IMAGE_FocusControlAuto && - ( focusStatus.eFocusStatus == OMX_FocusStatusRequest || - focusStatus.eFocusStatus == OMX_FocusStatusUnableToReach || - focusStatus.eFocusStatus == OMX_FocusStatusLost ) ) || - (mParameters3A.Focus != (OMX_IMAGE_FOCUSCONTROLTYPE)OMX_IMAGE_FocusControlAuto) ) { - OMX_INIT_STRUCT_PTR (&bOMX, OMX_CONFIG_BOOLEANTYPE); - bOMX.bEnabled = OMX_TRUE; - - //Enable focus scanning - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexConfigAutofocusEnable, - &bOMX); - if ( OMX_ErrorNone != eError ) { - return Utils::ErrorUtils::omxToAndroidError(eError); - } - - { - android::AutoMutex lock(mDoAFMutex); - - // force AF, Ducati will take care of whether CAF - // or AF will be performed, depending on light conditions - if ( focusControl.eFocusControl == OMX_IMAGE_FocusControlAuto && - ( focusStatus.eFocusStatus == OMX_FocusStatusUnableToReach || - focusStatus.eFocusStatus == OMX_FocusStatusLost ) ) { - focusControl.eFocusControl = OMX_IMAGE_FocusControlAutoLock; - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigFocusControl, - &focusControl); - - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while starting focus 0x%x", eError); - return INVALID_OPERATION; - } else { - CAMHAL_LOGDA("Autofocus started successfully"); - } - - // No need to wait if preview is about to stop - getNextState(state); - if ( ( PREVIEW_ACTIVE & state ) != PREVIEW_ACTIVE ) { - return NO_ERROR; - } - - // configure focus timeout based on capture mode - timeout = (mCapMode == VIDEO_MODE) ? - ( ( nsecs_t ) AF_VIDEO_CALLBACK_TIMEOUT * 1000 ) : - ( ( nsecs_t ) AF_IMAGE_CALLBACK_TIMEOUT * 1000 ); - - - ret = mDoAFCond.waitRelative(mDoAFMutex, timeout); - } - - //If somethiing bad happened while we wait - if (mComponentState == OMX_StateInvalid) { - CAMHAL_LOGEA("Invalid State after Auto Focus Exitting!!!"); - return -EINVAL; - } - - if(ret != NO_ERROR) { - CAMHAL_LOGEA("Autofocus callback timeout expired"); - ret = returnFocusStatus(true); - } else { - CAMHAL_LOGDA("Autofocus callback received"); - ret = returnFocusStatus(false); - } - } else { // Focus mode in continuous - if ( NO_ERROR == ret ) { - ret = returnFocusStatus(true); - mPending3Asettings |= SetFocus; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::stopAutoFocus() -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE focusControl; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) { - CAMHAL_LOGEA("OMX component in Invalid state"); - returnFocusStatus(false); - return -EINVAL; - } - - if ( OMX_StateExecuting != mComponentState ) { - CAMHAL_LOGEA("OMX component not in executing state"); - return NO_ERROR; - } - - if ( mParameters3A.Focus == OMX_IMAGE_FocusControlAutoInfinity ) { - // No need to stop focus if we are in infinity mode. Nothing to stop. - return NO_ERROR; - } - - OMX_INIT_STRUCT_PTR (&focusControl, OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE); - focusControl.eFocusControl = OMX_IMAGE_FocusControlOff; - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigFocusControl, - &focusControl); - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while stopping focus 0x%x", eError); - return Utils::ErrorUtils::omxToAndroidError(eError); - } -#ifdef OMAP_TUNA - else { - // This is a WA. Usually the OMX Camera component should - // generate AF status change OMX event fairly quickly - // ( after one preview frame ) and this notification should - // actually come from 'handleFocusCallback()'. - android::AutoMutex lock(mDoAFMutex); - mDoAFCond.broadcast(); - } -#endif - - LOG_FUNCTION_NAME_EXIT; - - return NO_ERROR; -} - -status_t OMXCameraAdapter::getFocusMode(OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE &focusMode) -{; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) { - CAMHAL_LOGEA("OMX component is in invalid state"); - return NO_INIT; - } - - OMX_INIT_STRUCT_PTR (&focusMode, OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE); - focusMode.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigFocusControl, - &focusMode); - - if ( OMX_ErrorNone != eError ) { - CAMHAL_LOGEB("Error while retrieving focus mode 0x%x", eError); - } - - LOG_FUNCTION_NAME_EXIT; - - return Utils::ErrorUtils::omxToAndroidError(eError); -} - -status_t OMXCameraAdapter::cancelAutoFocus() -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE focusMode; - - LOG_FUNCTION_NAME; - - ret = getFocusMode(focusMode); - if ( NO_ERROR != ret ) { - return ret; - } - - //Stop the AF only for modes other than CAF, Inifinity or Off - if ( ( focusMode.eFocusControl != OMX_IMAGE_FocusControlAuto ) && - ( focusMode.eFocusControl != ( OMX_IMAGE_FOCUSCONTROLTYPE ) - OMX_IMAGE_FocusControlAutoInfinity ) && - ( focusMode.eFocusControl != OMX_IMAGE_FocusControlOff ) ) { - android::AutoMutex lock(mCancelAFMutex); - stopAutoFocus(); - ret = mCancelAFCond.waitRelative(mCancelAFMutex, CANCEL_AF_TIMEOUT); - if ( NO_ERROR != ret ) { - CAMHAL_LOGE("Cancel AF timeout!"); - } - } else if (focusMode.eFocusControl == OMX_IMAGE_FocusControlAuto) { - // This re-enabling of CAF doesn't seem to - // be needed any more. - // re-apply CAF after unlocking and canceling - // mPending3Asettings |= SetFocus; - } - - { - // Signal to 'doAutoFocus()' - android::AutoMutex lock(mDoAFMutex); - mDoAFCond.broadcast(); - } - - // If the apps call #cancelAutoFocus()}, the face callbacks will also resume. - pauseFaceDetection(false); - - LOG_FUNCTION_NAME_EXIT; - - return ret; - -} - -status_t OMXCameraAdapter::setFocusCallback(bool enabled) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_CALLBACKREQUESTTYPE focusRequstCallback; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component in Invalid state"); - ret = -EINVAL; - } - - if ( OMX_StateExecuting != mComponentState ) - { - CAMHAL_LOGEA("OMX component not in executing state"); - return NO_ERROR; - } - - if ( NO_ERROR == ret ) - { - - OMX_INIT_STRUCT_PTR (&focusRequstCallback, OMX_CONFIG_CALLBACKREQUESTTYPE); - focusRequstCallback.nPortIndex = OMX_ALL; - focusRequstCallback.nIndex = OMX_IndexConfigCommonFocusStatus; - - if ( enabled ) - { - focusRequstCallback.bEnable = OMX_TRUE; - } - else - { - focusRequstCallback.bEnable = OMX_FALSE; - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_IndexConfigCallbackRequest, - &focusRequstCallback); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error registering focus callback 0x%x", eError); - ret = -1; - } - else - { - CAMHAL_LOGDB("Autofocus callback for index 0x%x registered successfully", - OMX_IndexConfigCommonFocusStatus); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::returnFocusStatus(bool timeoutReached) -{ - status_t ret = NO_ERROR; - OMX_PARAM_FOCUSSTATUSTYPE eFocusStatus; - CameraHalEvent::FocusStatus focusStatus = CameraHalEvent::FOCUS_STATUS_FAIL; - BaseCameraAdapter::AdapterState state, nextState; - BaseCameraAdapter::getState(state); - BaseCameraAdapter::getNextState(nextState); - - LOG_FUNCTION_NAME; - - OMX_INIT_STRUCT(eFocusStatus, OMX_PARAM_FOCUSSTATUSTYPE); - - if( ((AF_ACTIVE & state ) != AF_ACTIVE) && ((AF_ACTIVE & nextState ) != AF_ACTIVE) ) - { - /// We don't send focus callback if focus was not started - CAMHAL_LOGDA("Not sending focus callback because focus was not started"); - return NO_ERROR; - } - - if ( NO_ERROR == ret ) - { - - if ( !timeoutReached ) - { - ret = checkFocus(&eFocusStatus); - - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEA("Focus status check failed!"); - } - } - } - - if ( NO_ERROR == ret ) - { - - if ( timeoutReached ) - { - focusStatus = CameraHalEvent::FOCUS_STATUS_FAIL; - } - else - { - switch (eFocusStatus.eFocusStatus) - { - case OMX_FocusStatusReached: - { - focusStatus = CameraHalEvent::FOCUS_STATUS_SUCCESS; - break; - } - case OMX_FocusStatusOff: // AF got canceled - return NO_ERROR; - case OMX_FocusStatusUnableToReach: - case OMX_FocusStatusRequest: - default: - { - focusStatus = CameraHalEvent::FOCUS_STATUS_FAIL; - break; - } - } - // Lock CAF after AF call - if( set3ALock(mUserSetExpLock, mUserSetWbLock, OMX_TRUE) != NO_ERROR) { - CAMHAL_LOGEA("Error Applying 3A locks"); - } else { - CAMHAL_LOGDA("Focus locked. Applied focus locks successfully"); - } - - stopAutoFocus(); - } - //Query current focus distance after AF is complete - updateFocusDistances(mParameters); - } - - ret = BaseCameraAdapter::setState(CAMERA_CANCEL_AUTOFOCUS); - if ( NO_ERROR == ret ) - { - ret = BaseCameraAdapter::commitState(); - } - else - { - ret |= BaseCameraAdapter::rollbackState(); - } - - if ( NO_ERROR == ret ) - { - notifyFocusSubscribers(focusStatus); - } - - // After focus, face detection will resume sending face callbacks - pauseFaceDetection(false); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::checkFocus(OMX_PARAM_FOCUSSTATUSTYPE *eFocusStatus) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - LOG_FUNCTION_NAME; - - if ( NULL == eFocusStatus ) - { - CAMHAL_LOGEA("Invalid focus status"); - ret = -EINVAL; - } - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component in Invalid state"); - ret = -EINVAL; - } - - if ( OMX_StateExecuting != mComponentState ) - { - CAMHAL_LOGEA("OMX component not in executing state"); - ret = NO_ERROR; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR (eFocusStatus, OMX_PARAM_FOCUSSTATUSTYPE); - - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonFocusStatus, - eFocusStatus); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while retrieving focus status: 0x%x", eError); - ret = -1; - } - } - - if ( NO_ERROR == ret ) - { - CAMHAL_LOGDB("Focus Status: %d", eFocusStatus->eFocusStatus); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::updateFocusDistances(android::CameraParameters ¶ms) -{ - OMX_U32 focusNear, focusOptimal, focusFar; - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - ret = getFocusDistances(focusNear, focusOptimal, focusFar); - if ( NO_ERROR == ret) - { - ret = addFocusDistances(focusNear, focusOptimal, focusFar, params); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Error in call to addFocusDistances() 0x%x", ret); - } - } - else - { - CAMHAL_LOGEB("Error in call to getFocusDistances() 0x%x", ret); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::getFocusDistances(OMX_U32 &near,OMX_U32 &optimal, OMX_U32 &far) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError; - - OMX_TI_CONFIG_FOCUSDISTANCETYPE focusDist; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = UNKNOWN_ERROR; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR(&focusDist, OMX_TI_CONFIG_FOCUSDISTANCETYPE); - focusDist.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; - - eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp, - ( OMX_INDEXTYPE ) OMX_TI_IndexConfigFocusDistance, - &focusDist); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while querying focus distances 0x%x", eError); - ret = UNKNOWN_ERROR; - } - - } - - if ( NO_ERROR == ret ) - { - near = focusDist.nFocusDistanceNear; - optimal = focusDist.nFocusDistanceOptimal; - far = focusDist.nFocusDistanceFar; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::encodeFocusDistance(OMX_U32 dist, char *buffer, size_t length) -{ - status_t ret = NO_ERROR; - uint32_t focusScale = 1000; - float distFinal; - - LOG_FUNCTION_NAME; - - if(mParameters3A.Focus == OMX_IMAGE_FocusControlAutoInfinity) - { - dist=0; - } - - if ( NO_ERROR == ret ) - { - if ( 0 == dist ) - { - strncpy(buffer, android::CameraParameters::FOCUS_DISTANCE_INFINITY, ( length - 1 )); - } - else - { - distFinal = dist; - distFinal /= focusScale; - snprintf(buffer, ( length - 1 ) , "%5.3f", distFinal); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::addFocusDistances(OMX_U32 &near, - OMX_U32 &optimal, - OMX_U32 &far, - android::CameraParameters& params) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( NO_ERROR == ret ) - { - ret = encodeFocusDistance(near, mFocusDistNear, FOCUS_DIST_SIZE); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Error encoding near focus distance 0x%x", ret); - } - } - - if ( NO_ERROR == ret ) - { - ret = encodeFocusDistance(optimal, mFocusDistOptimal, FOCUS_DIST_SIZE); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Error encoding near focus distance 0x%x", ret); - } - } - - if ( NO_ERROR == ret ) - { - ret = encodeFocusDistance(far, mFocusDistFar, FOCUS_DIST_SIZE); - if ( NO_ERROR != ret ) - { - CAMHAL_LOGEB("Error encoding near focus distance 0x%x", ret); - } - } - - if ( NO_ERROR == ret ) - { - snprintf(mFocusDistBuffer, ( FOCUS_DIST_BUFFER_SIZE - 1) ,"%s,%s,%s", mFocusDistNear, - mFocusDistOptimal, - mFocusDistFar); - - params.set(android::CameraParameters::KEY_FOCUS_DISTANCES, mFocusDistBuffer); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::setTouchFocus() -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - OMX_ALGOAREASTYPE *focusAreas; - OMX_TI_CONFIG_SHAREDBUFFER sharedBuffer; - MemoryManager memMgr; - CameraBuffer *bufferlist; - int areasSize = 0; - - LOG_FUNCTION_NAME; - - ret = memMgr.initialize(); - if ( ret != OK ) { - CAMHAL_LOGE("MemoryManager initialization failed, error: %d", ret); - return ret; - } - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = -1; - } - - if ( NO_ERROR == ret ) - { - - areasSize = ((sizeof(OMX_ALGOAREASTYPE)+4095)/4096)*4096; - bufferlist = memMgr.allocateBufferList(0, 0, NULL, areasSize, 1); - focusAreas = (OMX_ALGOAREASTYPE*) bufferlist[0].opaque; - - OMXCameraPortParameters * mPreviewData = NULL; - mPreviewData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mPrevPortIndex]; - - if (!focusAreas) - { - CAMHAL_LOGEB("Error allocating buffer for focus areas %d", eError); - return -ENOMEM; - } - - OMX_INIT_STRUCT_PTR (focusAreas, OMX_ALGOAREASTYPE); - - focusAreas->nPortIndex = OMX_ALL; - focusAreas->nNumAreas = mFocusAreas.size(); - focusAreas->nAlgoAreaPurpose = OMX_AlgoAreaFocus; - - // If the area is the special case of (0, 0, 0, 0, 0), then - // the algorithm needs nNumAreas to be set to 0, - // in order to automatically choose the best fitting areas. - if ( mFocusAreas.itemAt(0)->isZeroArea() ) - { - focusAreas->nNumAreas = 0; - } - - for ( unsigned int n = 0; n < mFocusAreas.size(); n++) { - int widthDivisor = 1; - int heightDivisor = 1; - - if (mPreviewData->mFrameLayoutType == OMX_TI_StereoFrameLayoutTopBottom) { - heightDivisor = 2; - } - if (mPreviewData->mFrameLayoutType == OMX_TI_StereoFrameLayoutLeftRight) { - widthDivisor = 2; - } - - // transform the coordinates to 3A-type coordinates - mFocusAreas.itemAt(n)->transfrom((size_t)mPreviewData->mWidth/widthDivisor, - (size_t)mPreviewData->mHeight/heightDivisor, - (size_t&)focusAreas->tAlgoAreas[n].nTop, - (size_t&)focusAreas->tAlgoAreas[n].nLeft, - (size_t&)focusAreas->tAlgoAreas[n].nWidth, - (size_t&)focusAreas->tAlgoAreas[n].nHeight); - - focusAreas->tAlgoAreas[n].nLeft = - ( focusAreas->tAlgoAreas[n].nLeft * TOUCH_FOCUS_RANGE ) / mPreviewData->mWidth; - focusAreas->tAlgoAreas[n].nTop = - ( focusAreas->tAlgoAreas[n].nTop* TOUCH_FOCUS_RANGE ) / mPreviewData->mHeight; - focusAreas->tAlgoAreas[n].nWidth = - ( focusAreas->tAlgoAreas[n].nWidth * TOUCH_FOCUS_RANGE ) / mPreviewData->mWidth; - focusAreas->tAlgoAreas[n].nHeight = - ( focusAreas->tAlgoAreas[n].nHeight * TOUCH_FOCUS_RANGE ) / mPreviewData->mHeight; - focusAreas->tAlgoAreas[n].nPriority = mFocusAreas.itemAt(n)->getWeight(); - - CAMHAL_LOGDB("Focus area %d : top = %d left = %d width = %d height = %d prio = %d", - n, (int)focusAreas->tAlgoAreas[n].nTop, (int)focusAreas->tAlgoAreas[n].nLeft, - (int)focusAreas->tAlgoAreas[n].nWidth, (int)focusAreas->tAlgoAreas[n].nHeight, - (int)focusAreas->tAlgoAreas[n].nPriority); - } - - OMX_INIT_STRUCT_PTR (&sharedBuffer, OMX_TI_CONFIG_SHAREDBUFFER); - - sharedBuffer.nPortIndex = OMX_ALL; - sharedBuffer.nSharedBuffSize = areasSize; - sharedBuffer.pSharedBuff = (OMX_U8 *) camera_buffer_get_omx_ptr (&bufferlist[0]); - - if ( NULL == sharedBuffer.pSharedBuff ) - { - CAMHAL_LOGEA("No resources to allocate OMX shared buffer"); - ret = -ENOMEM; - goto EXIT; - } - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE) OMX_TI_IndexConfigAlgoAreas, &sharedBuffer); - - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while setting Focus Areas configuration 0x%x", eError); - ret = -EINVAL; - } - - EXIT: - if (NULL != bufferlist) - { - memMgr.freeBufferList (bufferlist); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -void OMXCameraAdapter::handleFocusCallback() { - OMX_PARAM_FOCUSSTATUSTYPE eFocusStatus; - CameraHalEvent::FocusStatus focusStatus = CameraHalEvent::FOCUS_STATUS_FAIL; - status_t ret = NO_ERROR; - BaseCameraAdapter::AdapterState nextState; - BaseCameraAdapter::getNextState(nextState); - - OMX_INIT_STRUCT(eFocusStatus, OMX_PARAM_FOCUSSTATUSTYPE); - - ret = checkFocus(&eFocusStatus); - - if (NO_ERROR != ret) { - CAMHAL_LOGEA("Focus status check failed!"); - // signal and unblock doAutoFocus - if (AF_ACTIVE & nextState) { - android::AutoMutex lock(mDoAFMutex); - mDoAFCond.broadcast(); - } - return; - } - - if ( eFocusStatus.eFocusStatus == OMX_FocusStatusOff ) { - android::AutoMutex lock(mCancelAFMutex); - mCancelAFCond.signal(); - return; - } - - if (eFocusStatus.eFocusStatus != OMX_FocusStatusRequest) { - // signal doAutoFocus when a end of scan message comes - // ignore start of scan - android::AutoMutex lock(mDoAFMutex); - mDoAFCond.broadcast(); - } - - if (mParameters3A.Focus != (OMX_IMAGE_FOCUSCONTROLTYPE) OMX_IMAGE_FocusControlAuto) { - CAMHAL_LOGDA("unregistered focus callback when not in CAF or doAutoFocus... not handling"); - return; - } - - // Handling for CAF Callbacks - switch (eFocusStatus.eFocusStatus) { - case OMX_FocusStatusRequest: - focusStatus = CameraHalEvent::FOCUS_STATUS_PENDING; - break; - case OMX_FocusStatusReached: - case OMX_FocusStatusOff: - case OMX_FocusStatusUnableToReach: - default: - focusStatus = CameraHalEvent::FOCUS_STATUS_DONE; - break; - } - - notifyFocusSubscribers(focusStatus); -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/OMXCameraAdapter/OMXMetadata.cpp b/camera/OMXCameraAdapter/OMXMetadata.cpp deleted file mode 100644 index af8c49c..0000000 --- a/camera/OMXCameraAdapter/OMXMetadata.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMX3A.cpp -* -* This file contains functionality for handling 3A configurations. -* -*/ - -#undef LOG_TAG - -#define LOG_TAG "OMXMetaData" - -#include "OMXCameraAdapter.h" -#include - -namespace Ti { -namespace Camera { - -#ifdef OMAP_ENHANCEMENT_CPCAM -camera_memory_t * OMXCameraAdapter::getMetaData(const OMX_PTR plat_pvt, - camera_request_memory allocator) const -{ - camera_memory_t * ret = NULL; - - OMX_OTHER_EXTRADATATYPE *extraData; - OMX_FACEDETECTIONTYPE *faceData = NULL; - OMX_TI_WHITEBALANCERESULTTYPE * WBdata = NULL; - OMX_TI_VECTSHOTINFOTYPE *shotInfo = NULL; - OMX_TI_LSCTABLETYPE *lscTbl = NULL; - camera_metadata_t *metaData; - size_t offset = 0; - - size_t metaDataSize = sizeof(camera_metadata_t); - - extraData = getExtradata(plat_pvt, (OMX_EXTRADATATYPE) OMX_FaceDetection); - if ( NULL != extraData ) { - faceData = ( OMX_FACEDETECTIONTYPE * ) extraData->data; - metaDataSize += faceData->ulFaceCount * sizeof(camera_metadata_face_t); - } - - extraData = getExtradata(plat_pvt, (OMX_EXTRADATATYPE) OMX_WhiteBalance); - if ( NULL != extraData ) { - WBdata = ( OMX_TI_WHITEBALANCERESULTTYPE * ) extraData->data; - } - - extraData = getExtradata(plat_pvt, (OMX_EXTRADATATYPE) OMX_TI_VectShotInfo); - if ( NULL != extraData ) { - shotInfo = ( OMX_TI_VECTSHOTINFOTYPE * ) extraData->data; - } - - extraData = getExtradata(plat_pvt, (OMX_EXTRADATATYPE) OMX_TI_LSCTable); - if ( NULL != extraData ) { - lscTbl = ( OMX_TI_LSCTABLETYPE * ) extraData->data; - metaDataSize += OMX_TI_LSC_GAIN_TABLE_SIZE; - } - - ret = allocator(-1, metaDataSize, 1, NULL); - if ( NULL == ret ) { - return NULL; - } else { - metaData = static_cast (ret->data); - offset += sizeof(camera_metadata_t); - } - - if ( NULL != faceData ) { - metaData->number_of_faces = 0; - int idx = 0; - metaData->faces_offset = offset; - struct camera_metadata_face *faces = reinterpret_cast (static_cast(ret->data) + offset); - for ( int j = 0; j < faceData->ulFaceCount ; j++ ) { - if(faceData->tFacePosition[j].nScore <= FACE_DETECTION_THRESHOLD) { - continue; - } - idx = metaData->number_of_faces; - metaData->number_of_faces++; - // TODO: Rework and re-use encodeFaceCoordinates() - faces[idx].left = faceData->tFacePosition[j].nLeft; - faces[idx].top = faceData->tFacePosition[j].nTop; - faces[idx].bottom = faceData->tFacePosition[j].nWidth; - faces[idx].right = faceData->tFacePosition[j].nHeight; - } - offset += sizeof(camera_metadata_face_t) * metaData->number_of_faces; - } - - if ( NULL != WBdata ) { - metaData->awb_temp = WBdata->nColorTemperature; - metaData->gain_b = WBdata->nGainB; - metaData->gain_gb = WBdata->nGainGB; - metaData->gain_gr = WBdata->nGainGR; - metaData->gain_r = WBdata->nGainR; - metaData->offset_b = WBdata->nOffsetB; - metaData->offset_gb = WBdata->nOffsetGB; - metaData->offset_gr = WBdata->nOffsetGR; - metaData->offset_r = WBdata->nOffsetR; - } - - if ( NULL != lscTbl ) { - metaData->lsc_table_applied = lscTbl->bApplied; - metaData->lsc_table_size = OMX_TI_LSC_GAIN_TABLE_SIZE; - metaData->lsc_table_offset = offset; - uint8_t *lsc_table = reinterpret_cast (static_cast(ret->data) + offset); - memcpy(lsc_table, lscTbl->pGainTable, OMX_TI_LSC_GAIN_TABLE_SIZE); - offset += metaData->lsc_table_size; - } - - if ( NULL != shotInfo ) { - metaData->frame_number = shotInfo->nFrameNum; - metaData->shot_number = shotInfo->nConfigId; - metaData->analog_gain = shotInfo->nAGain; - metaData->analog_gain_req = shotInfo->nReqGain; - metaData->analog_gain_min = shotInfo->nGainMin; - metaData->analog_gain_max = shotInfo->nGainMax; - metaData->analog_gain_error = shotInfo->nSenAGainErr; - metaData->analog_gain_dev = shotInfo->nDevAGain; - metaData->exposure_time = shotInfo->nExpTime; - metaData->exposure_time_req = shotInfo->nReqExpTime; - metaData->exposure_time_min = shotInfo->nExpMin; - metaData->exposure_time_max = shotInfo->nExpMax; - metaData->exposure_time_dev = shotInfo->nDevExpTime; - metaData->exposure_time_error = shotInfo->nSenExpTimeErr; - metaData->exposure_compensation_req = shotInfo->nReqEC; - metaData->exposure_dev = shotInfo->nDevEV; - } - - return ret; -} -#endif - -status_t OMXCameraAdapter::encodePreviewMetadata(camera_frame_metadata_t *meta, const OMX_PTR plat_pvt) -{ - status_t ret = NO_ERROR; -#ifdef OMAP_ENHANCEMENT_CPCAM - OMX_OTHER_EXTRADATATYPE *extraData = NULL; - - extraData = getExtradata(plat_pvt, (OMX_EXTRADATATYPE) OMX_TI_VectShotInfo); - - if ( (NULL != extraData) && (NULL != extraData->data) ) { - OMX_TI_VECTSHOTINFOTYPE *shotInfo; - shotInfo = (OMX_TI_VECTSHOTINFOTYPE*) extraData->data; - - meta->analog_gain = shotInfo->nAGain; - meta->exposure_time = shotInfo->nExpTime; - } else { - meta->analog_gain = -1; - meta->exposure_time = -1; - } - - // Send metadata event only after any value has been changed - if ((metadataLastAnalogGain == meta->analog_gain) && - (metadataLastExposureTime == meta->exposure_time)) { - ret = NOT_ENOUGH_DATA; - } else { - metadataLastAnalogGain = meta->analog_gain; - metadataLastExposureTime = meta->exposure_time; - } -#else - // no-op in non enhancement mode - CAMHAL_UNUSED(meta); - CAMHAL_UNUSED(plat_pvt); -#endif - - return ret; -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/OMXCameraAdapter/OMXReprocess.cpp b/camera/OMXCameraAdapter/OMXReprocess.cpp deleted file mode 100644 index 28f1744..0000000 --- a/camera/OMXCameraAdapter/OMXReprocess.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMXReprocess.cpp -* -* This file contains functionality for handling reprocessing operations. -* -*/ - -#include "CameraHal.h" -#include "OMXCameraAdapter.h" -#include "ErrorUtils.h" - - -namespace Ti { -namespace Camera { - -status_t OMXCameraAdapter::setParametersReprocess(const android::CameraParameters ¶ms, - CameraBuffer* buffers, - BaseCameraAdapter::AdapterState state) -{ - status_t ret = NO_ERROR; - int w, h, s; - OMX_COLOR_FORMATTYPE pixFormat; - OMXCameraPortParameters *portData; - const char* valstr; - - LOG_FUNCTION_NAME; - - if (!buffers) { - CAMHAL_LOGE("invalid buffer array"); - return BAD_VALUE; - } - - portData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoInPortIndex]; - - w = buffers[0].width; - h = buffers[0].height; - s = buffers[0].stride; - - valstr = buffers[0].format; - if (valstr != NULL) { - if(strcmp(valstr, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { - CAMHAL_LOGDA("YUV420SP format selected"); - pixFormat = OMX_COLOR_FormatYUV420SemiPlanar; - } else if (strcmp(valstr, android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB) == 0) { - CAMHAL_LOGDA("RAW Picture format selected"); - pixFormat = OMX_COLOR_FormatRawBayer10bit; - } else { - CAMHAL_LOGDA("Format not supported, selecting YUV420SP by default"); - pixFormat = OMX_COLOR_FormatYUV420SemiPlanar; - } - } else { - CAMHAL_LOGDA("Format not supported, selecting YUV420SP by default"); - pixFormat = OMX_COLOR_FormatYUV420SemiPlanar; - } - - if ( (w != (int)portData->mWidth) || (h != (int)portData->mHeight) || - (s != (int) portData->mStride) || (pixFormat != portData->mColorFormat)) { - portData->mWidth = w; - portData->mHeight = h; - - if ( OMX_COLOR_FormatRawBayer10bit == pixFormat ) { - portData->mStride = w * 2; - } else { - portData->mStride = s; - } - - portData->mColorFormat = pixFormat; - - ret = setFormat(OMX_CAMERA_PORT_VIDEO_IN_VIDEO, *portData); - if ( ret != NO_ERROR ) { - CAMHAL_LOGEB("setFormat() failed %d", ret); - LOG_FUNCTION_NAME_EXIT; - return ret; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::startReprocess() -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXCameraPortParameters * portData = NULL; - - LOG_FUNCTION_NAME; - CAMHAL_LOGD ("mReprocConfigured = %d", mReprocConfigured); - if (!mReprocConfigured) { - return NO_ERROR; - } - - portData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoInPortIndex]; - - CAMHAL_LOGD ("mReprocConfigured = %d", mBurstFramesQueued); - if (NO_ERROR == ret) { - android::AutoMutex lock(mBurstLock); - - for ( int index = 0 ; index < portData->mMaxQueueable ; index++ ) { - CAMHAL_LOGDB("Queuing buffer on video input port - %p", - portData->mBufferHeader[index]->pBuffer); - portData->mStatus[index] = OMXCameraPortParameters::FILL; - eError = OMX_EmptyThisBuffer(mCameraAdapterParameters.mHandleComp, - (OMX_BUFFERHEADERTYPE*)portData->mBufferHeader[index]); - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - } - } - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - -EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - performCleanupAfterError(); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::stopReprocess() -{ - LOG_FUNCTION_NAME; - - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXCameraPortParameters *portData = NULL; - - if (!mReprocConfigured) { - return NO_ERROR; - } - - portData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoInPortIndex]; - - // Disable port - send command and then free all buffers - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortDisable, - mCameraAdapterParameters.mVideoInPortIndex, - mStopReprocSem); - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortDisable, - mCameraAdapterParameters.mVideoInPortIndex, - NULL); - if (portData) { - CAMHAL_LOGDB("Freeing buffers on reproc port - num: %d", portData->mNumBufs); - for (int index = 0 ; index < portData->mNumBufs ; index++) { - CAMHAL_LOGDB("Freeing buffer on reproc port - 0x%x", - ( unsigned int ) portData->mBufferHeader[index]->pBuffer); - eError = OMX_FreeBuffer(mCameraAdapterParameters.mHandleComp, - mCameraAdapterParameters.mVideoInPortIndex, - (OMX_BUFFERHEADERTYPE*)portData->mBufferHeader[index]); - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - } - } - CAMHAL_LOGDA("Waiting for port disable"); - ret = mStopReprocSem.WaitTimeout(OMX_CMD_TIMEOUT); - if (mComponentState == OMX_StateInvalid) { - CAMHAL_LOGEA("Invalid State after Disable Image Port Exitting!!!"); - goto EXIT; - } - if (NO_ERROR == ret) { - CAMHAL_LOGDA("Port disabled"); - } else { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortDisable, - mCameraAdapterParameters.mVideoInPortIndex, - NULL); - CAMHAL_LOGDA("Timeout expired on port disable"); - goto EXIT; - } - - deinitInternalBuffers(mCameraAdapterParameters.mVideoInPortIndex); - - mReprocConfigured = false; - -EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::disableReprocess(){ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - // no-op..for now - -EXIT: - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); -} - -status_t OMXCameraAdapter::UseBuffersReprocess(CameraBuffer *bufArr, int num) -{ - LOG_FUNCTION_NAME; - - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXCameraPortParameters *portData = NULL; - - portData = &mCameraAdapterParameters.mCameraPortParams[mCameraAdapterParameters.mVideoInPortIndex]; - - if ( 0 != mUseReprocessSem.Count() ) { - CAMHAL_LOGEB("Error mUseReprocessSem semaphore count %d", mUseReprocessSem.Count()); - return BAD_VALUE; - } - - if (mAdapterState == REPROCESS_STATE) { - stopReprocess(); - } else if (mAdapterState == CAPTURE_STATE) { - stopImageCapture(); - disableImagePort(); - } - - if (mReprocConfigured) { - return NO_ERROR; - } - - portData->mNumBufs = num; - - // Configure - ret = setParametersReprocess(mParams, bufArr, mAdapterState); - - // Configure DOMX to use either gralloc handles or vptrs - OMX_TI_PARAMUSENATIVEBUFFER domxUseGrallocHandles; - OMX_INIT_STRUCT_PTR (&domxUseGrallocHandles, OMX_TI_PARAMUSENATIVEBUFFER); - - domxUseGrallocHandles.nPortIndex = mCameraAdapterParameters.mVideoInPortIndex; - if (bufArr[0].type == CAMERA_BUFFER_ANW) { - CAMHAL_LOGD("Using ANW"); - domxUseGrallocHandles.bEnable = OMX_TRUE; - - // Need to allocate tiler reservation and state we are going to be using - // pagelist buffers. Assuming this happens when buffers if from anw - initInternalBuffers(mCameraAdapterParameters.mVideoInPortIndex); - } else { - CAMHAL_LOGD("Using ION"); - domxUseGrallocHandles.bEnable = OMX_FALSE; - } - eError = OMX_SetParameter(mCameraAdapterParameters.mHandleComp, - (OMX_INDEXTYPE)OMX_TI_IndexUseNativeBuffers, &domxUseGrallocHandles); - if (eError!=OMX_ErrorNone) { - CAMHAL_LOGEB("OMX_SetParameter - %x", eError); - } - GOTO_EXIT_IF((eError!=OMX_ErrorNone), eError); - - // Enable Port - ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mVideoInPortIndex, - mUseReprocessSem); - eError = OMX_SendCommand(mCameraAdapterParameters.mHandleComp, - OMX_CommandPortEnable, - mCameraAdapterParameters.mVideoInPortIndex, - NULL); - GOTO_EXIT_IF(( eError != OMX_ErrorNone ), eError); - - for (int index = 0 ; index < portData->mNumBufs ; index++) - { - OMX_BUFFERHEADERTYPE *pBufferHdr; - CAMHAL_LOGDB("OMX_UseBuffer Capture address: 0x%x, size = %d", - (unsigned int)bufArr[index].opaque, - (int)portData->mBufSize); - - eError = OMX_UseBuffer(mCameraAdapterParameters.mHandleComp, - &pBufferHdr, - mCameraAdapterParameters.mVideoInPortIndex, - 0, - portData->mBufSize, - (OMX_U8*)camera_buffer_get_omx_ptr(&bufArr[index])); - - CAMHAL_LOGDB("OMX_UseBuffer = 0x%x", eError); - GOTO_EXIT_IF(( eError != OMX_ErrorNone ), eError); - - pBufferHdr->pAppPrivate = (OMX_PTR) &bufArr[index]; - bufArr[index].index = index; - pBufferHdr->nSize = sizeof(OMX_BUFFERHEADERTYPE); - pBufferHdr->nVersion.s.nVersionMajor = 1 ; - pBufferHdr->nVersion.s.nVersionMinor = 1 ; - pBufferHdr->nVersion.s.nRevision = 0; - pBufferHdr->nVersion.s.nStep = 0; - portData->mBufferHeader[index] = pBufferHdr; - } - - // Wait for port enable event - CAMHAL_LOGDA("Waiting for port enable"); - ret = mUseReprocessSem.WaitTimeout(OMX_CMD_TIMEOUT); - - // Error out if somethiing bad happened while we wait - if (mComponentState == OMX_StateInvalid) { - CAMHAL_LOGEA("Invalid State while trying to enable port for reprocessing"); - goto EXIT; - } - - if (ret == NO_ERROR) { - CAMHAL_LOGDA("Port enabled"); - } else { - ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, - OMX_EventCmdComplete, - OMX_CommandPortEnable, - mCameraAdapterParameters.mVideoInPortIndex, - NULL); - CAMHAL_LOGDA("Timeout expired on port enable"); - goto EXIT; - } - - mReprocConfigured = true; - - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - -EXIT: - CAMHAL_LOGEB("Exiting function %s because of ret %d eError=%x", __FUNCTION__, ret, eError); - // Release image buffers - if ( NULL != mReleaseImageBuffersCallback ) { - mReleaseImageBuffersCallback(mReleaseData); - } - performCleanupAfterError(); - LOG_FUNCTION_NAME_EXIT; - return (ret | Utils::ErrorUtils::omxToAndroidError(eError)); - -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/OMXCameraAdapter/OMXZoom.cpp b/camera/OMXCameraAdapter/OMXZoom.cpp deleted file mode 100644 index 11c8f75..0000000 --- a/camera/OMXCameraAdapter/OMXZoom.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMXZoom.cpp -* -* This file contains functionality for handling zoom configurations. -* -*/ - -#include "CameraHal.h" -#include "OMXCameraAdapter.h" - -namespace Ti { -namespace Camera { - -const int32_t OMXCameraAdapter::ZOOM_STEPS [ZOOM_STAGES] = { - 65536, 68157, 70124, 72745, - 75366, 77988, 80609, 83231, - 86508, 89784, 92406, 95683, - 99615, 102892, 106168, 110100, - 114033, 117965, 122552, 126484, - 131072, 135660, 140247, 145490, - 150733, 155976, 161219, 167117, - 173015, 178913, 185467, 192020, - 198574, 205783, 212992, 220201, - 228065, 236585, 244449, 252969, - 262144, 271319, 281149, 290980, - 300810, 311951, 322437, 334234, - 346030, 357827, 370934, 384041, - 397148, 411566, 425984, 441057, - 456131, 472515, 488899, 506593, - 524288 }; - - -status_t OMXCameraAdapter::setParametersZoom(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state) -{ - status_t ret = NO_ERROR; - android::AutoMutex lock(mZoomLock); - - LOG_FUNCTION_NAME; - - //Immediate zoom should not be avaialable while smooth zoom is running - if ( ( ZOOM_ACTIVE & state ) != ZOOM_ACTIVE ) - { - int zoom = params.getInt(android::CameraParameters::KEY_ZOOM); - if (( zoom >= 0 ) && ( zoom < mMaxZoomSupported )) { - mTargetZoomIdx = zoom; - - //Immediate zoom should be applied instantly ( CTS requirement ) - mCurrentZoomIdx = mTargetZoomIdx; - if(!mZoomUpdating) { - doZoom(mCurrentZoomIdx); - mZoomUpdating = true; - } else { - mZoomUpdate = true; - } - - CAMHAL_LOGDB("Zoom by App %d", zoom); - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::doZoom(int index) -{ - status_t ret = NO_ERROR; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CONFIG_SCALEFACTORTYPE zoomControl; - - LOG_FUNCTION_NAME; - - if ( OMX_StateInvalid == mComponentState ) - { - CAMHAL_LOGEA("OMX component is in invalid state"); - ret = -1; - } - - if (( 0 > index) || ((mMaxZoomSupported - 1 ) < index )) { - CAMHAL_LOGEB("Zoom index %d out of range", index); - ret = -EINVAL; - } - - if (mPreviousZoomIndx == (unsigned int)index ) - { - return NO_ERROR; - } - - if ( NO_ERROR == ret ) - { - OMX_INIT_STRUCT_PTR (&zoomControl, OMX_CONFIG_SCALEFACTORTYPE); - zoomControl.nPortIndex = OMX_ALL; - zoomControl.xHeight = ZOOM_STEPS[index]; - zoomControl.xWidth = ZOOM_STEPS[index]; - - eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, - OMX_IndexConfigCommonDigitalZoom, - &zoomControl); - if ( OMX_ErrorNone != eError ) - { - CAMHAL_LOGEB("Error while applying digital zoom 0x%x", eError); - ret = -1; - } - else - { - CAMHAL_LOGDA("Digital zoom applied successfully"); - mPreviousZoomIndx = index; - } - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::advanceZoom() -{ - status_t ret = NO_ERROR; - AdapterState state; - android::AutoMutex lock(mZoomLock); - - BaseCameraAdapter::getState(state); - - if ( mReturnZoomStatus ) - { - mCurrentZoomIdx +=mZoomInc; - mTargetZoomIdx = mCurrentZoomIdx; - mReturnZoomStatus = false; - ret = doZoom(mCurrentZoomIdx); - notifyZoomSubscribers(mCurrentZoomIdx, true); - } - else if ( mCurrentZoomIdx != mTargetZoomIdx ) - { - if ( ZOOM_ACTIVE & state ) - { - if ( mCurrentZoomIdx < mTargetZoomIdx ) - { - mZoomInc = 1; - } - else - { - mZoomInc = -1; - } - - mCurrentZoomIdx += mZoomInc; - } - else - { - mCurrentZoomIdx = mTargetZoomIdx; - } - - ret = doZoom(mCurrentZoomIdx); - - if ( ZOOM_ACTIVE & state ) - { - if ( mCurrentZoomIdx == mTargetZoomIdx ) - { - CAMHAL_LOGDB("[Goal Reached] Smooth Zoom notify currentIdx = %d, targetIdx = %d", - mCurrentZoomIdx, - mTargetZoomIdx); - - if ( NO_ERROR == ret ) - { - - ret = BaseCameraAdapter::setState(CAMERA_STOP_SMOOTH_ZOOM); - - if ( NO_ERROR == ret ) - { - ret = BaseCameraAdapter::commitState(); - } - else - { - ret |= BaseCameraAdapter::rollbackState(); - } - - } - mReturnZoomStatus = false; - notifyZoomSubscribers(mCurrentZoomIdx, true); - } - else - { - CAMHAL_LOGDB("[Advancing] Smooth Zoom notify currentIdx = %d, targetIdx = %d", - mCurrentZoomIdx, - mTargetZoomIdx); - notifyZoomSubscribers(mCurrentZoomIdx, false); - } - } - } - else if ( (mCurrentZoomIdx == mTargetZoomIdx ) && - ( ZOOM_ACTIVE & state ) ) - { - ret = BaseCameraAdapter::setState(CameraAdapter::CAMERA_STOP_SMOOTH_ZOOM); - - if ( NO_ERROR == ret ) - { - ret = BaseCameraAdapter::commitState(); - } - else - { - ret |= BaseCameraAdapter::rollbackState(); - } - - } - - if(mZoomUpdate) { - doZoom(mTargetZoomIdx); - mZoomUpdate = false; - mZoomUpdating = true; - } else { - mZoomUpdating = false; - } - - return ret; -} - -status_t OMXCameraAdapter::startSmoothZoom(int targetIdx) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mZoomLock); - - CAMHAL_LOGDB("Start smooth zoom target = %d, mCurrentIdx = %d", - targetIdx, - mCurrentZoomIdx); - - if (( targetIdx >= 0 ) && ( targetIdx < mMaxZoomSupported )) { - mTargetZoomIdx = targetIdx; - mZoomParameterIdx = mCurrentZoomIdx; - mReturnZoomStatus = false; - } else { - CAMHAL_LOGEB("Smooth value out of range %d!", targetIdx); - ret = -EINVAL; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t OMXCameraAdapter::stopSmoothZoom() -{ - status_t ret = NO_ERROR; - android::AutoMutex lock(mZoomLock); - - LOG_FUNCTION_NAME; - - if ( mTargetZoomIdx != mCurrentZoomIdx ) - { - if ( mCurrentZoomIdx < mTargetZoomIdx ) - { - mZoomInc = 1; - } - else - { - mZoomInc = -1; - } - mReturnZoomStatus = true; - mReturnZoomStatus = true; - CAMHAL_LOGDB("Stop smooth zoom mCurrentZoomIdx = %d, mTargetZoomIdx = %d", - mCurrentZoomIdx, - mTargetZoomIdx); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/SensorListener.cpp b/camera/SensorListener.cpp deleted file mode 100644 index c86e867..0000000 --- a/camera/SensorListener.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file SensorListener.cpp -* -* This file listens and propogates sensor events to CameraHal. -* -*/ - -#include "SensorListener.h" - -#include -#include -#include - -namespace Ti { -namespace Camera { - -/*** static declarations ***/ -static const float RADIANS_2_DEG = (float) (180 / M_PI); -// measured values on device...might need tuning -static const int DEGREES_90_THRESH = 50; -static const int DEGREES_180_THRESH = 170; -static const int DEGREES_270_THRESH = 250; - -static int sensor_events_listener(int fd, int events, void* data) -{ - SensorListener* listener = (SensorListener*) data; - ssize_t num_sensors; - ASensorEvent sen_events[8]; - while ((num_sensors = listener->mSensorEventQueue->read(sen_events, 8)) > 0) { - for (int i = 0; i < num_sensors; i++) { - if (sen_events[i].type == android::Sensor::TYPE_ACCELEROMETER) { - float x = sen_events[i].vector.azimuth; - float y = sen_events[i].vector.pitch; - float z = sen_events[i].vector.roll; - float radius = 0; - int tilt = 0, orient = 0; - - CAMHAL_LOGSVA("ACCELEROMETER EVENT"); - CAMHAL_LOGSVB(" azimuth = %f pitch = %f roll = %f", - sen_events[i].vector.azimuth, - sen_events[i].vector.pitch, - sen_events[i].vector.roll); - // see http://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates - // about conversion from cartesian to spherical for orientation calculations - radius = (float) sqrt(x * x + y * y + z * z); - tilt = (int) asinf(z / radius) * RADIANS_2_DEG; - orient = (int) atan2f(-x, y) * RADIANS_2_DEG; - - if (orient < 0) { - orient += 360; - } - - if (orient >= DEGREES_270_THRESH) { - orient = 270; - } else if (orient >= DEGREES_180_THRESH) { - orient = 180; - } else if (orient >= DEGREES_90_THRESH) { - orient = 90; - } else { - orient = 0; - } - listener->handleOrientation(orient, tilt); - CAMHAL_LOGSVB(" tilt = %d orientation = %d", tilt, orient); - } else if (sen_events[i].type == android::Sensor::TYPE_GYROSCOPE) { - CAMHAL_LOGSVA("GYROSCOPE EVENT"); - } - } - } - - if (num_sensors < 0 && num_sensors != -EAGAIN) { - CAMHAL_LOGEB("reading events failed: %s", strerror(-num_sensors)); - } - - return 1; -} - -/****** public - member functions ******/ -SensorListener::SensorListener() { - LOG_FUNCTION_NAME; - - sensorsEnabled = 0; - mOrientationCb = NULL; - mSensorEventQueue = NULL; - mSensorLooperThread = NULL; - - LOG_FUNCTION_NAME_EXIT; -} - -SensorListener::~SensorListener() { - LOG_FUNCTION_NAME; - - CAMHAL_LOGDA("Kill looper thread"); - if (mSensorLooperThread.get()) { - // 1. Request exit - // 2. Wake up looper which should be polling for an event - // 3. Wait for exit - mSensorLooperThread->requestExit(); - mSensorLooperThread->wake(); - mSensorLooperThread->join(); - mSensorLooperThread.clear(); - mSensorLooperThread = NULL; - } - - CAMHAL_LOGDA("Kill looper"); - if (mLooper.get()) { - mLooper->removeFd(mSensorEventQueue->getFd()); - mLooper.clear(); - mLooper = NULL; - } - CAMHAL_LOGDA("SensorListener destroyed"); - - LOG_FUNCTION_NAME_EXIT; -} - -status_t SensorListener::initialize() { - status_t ret = NO_ERROR; - android::SensorManager& mgr(android::SensorManager::getInstance()); - - LOG_FUNCTION_NAME; - - android::sp mLooper; - - mSensorEventQueue = mgr.createEventQueue(); - if (mSensorEventQueue == NULL) { - CAMHAL_LOGEA("createEventQueue returned NULL"); - ret = NO_INIT; - goto out; - } - - mLooper = new android::Looper(false); - mLooper->addFd(mSensorEventQueue->getFd(), 0, ALOOPER_EVENT_INPUT, sensor_events_listener, this); - - if (mSensorLooperThread.get() == NULL) - mSensorLooperThread = new SensorLooperThread(mLooper.get()); - - if (mSensorLooperThread.get() == NULL) { - CAMHAL_LOGEA("Couldn't create sensor looper thread"); - ret = NO_MEMORY; - goto out; - } - - ret = mSensorLooperThread->run("sensor looper thread", android::PRIORITY_URGENT_DISPLAY); - if (ret == INVALID_OPERATION){ - CAMHAL_LOGDA("thread already running ?!?"); - } else if (ret != NO_ERROR) { - CAMHAL_LOGEA("couldn't run thread"); - goto out; - } - - out: - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -void SensorListener::setCallbacks(orientation_callback_t orientation_cb, void *cookie) { - LOG_FUNCTION_NAME; - - if (orientation_cb) { - mOrientationCb = orientation_cb; - } - mCbCookie = cookie; - - LOG_FUNCTION_NAME_EXIT; -} - -void SensorListener::handleOrientation(uint32_t orientation, uint32_t tilt) { - LOG_FUNCTION_NAME; - - android::AutoMutex lock(&mLock); - - if (mOrientationCb && (sensorsEnabled & SENSOR_ORIENTATION)) { - mOrientationCb(orientation, tilt, mCbCookie); - } - - LOG_FUNCTION_NAME_EXIT; -} - -void SensorListener::enableSensor(sensor_type_t type) { - android::Sensor const* sensor; - android::SensorManager& mgr(android::SensorManager::getInstance()); - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(&mLock); - - if ((type & SENSOR_ORIENTATION) && !(sensorsEnabled & SENSOR_ORIENTATION)) { - sensor = mgr.getDefaultSensor(android::Sensor::TYPE_ACCELEROMETER); - CAMHAL_LOGDB("orientation = %p (%s)", sensor, sensor->getName().string()); - mSensorEventQueue->enableSensor(sensor); - mSensorEventQueue->setEventRate(sensor, ms2ns(100)); - sensorsEnabled |= SENSOR_ORIENTATION; - } - - LOG_FUNCTION_NAME_EXIT; -} - -void SensorListener::disableSensor(sensor_type_t type) { - android::Sensor const* sensor; - android::SensorManager& mgr(android::SensorManager::getInstance()); - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(&mLock); - - if ((type & SENSOR_ORIENTATION) && (sensorsEnabled & SENSOR_ORIENTATION)) { - sensor = mgr.getDefaultSensor(android::Sensor::TYPE_ACCELEROMETER); - CAMHAL_LOGDB("orientation = %p (%s)", sensor, sensor->getName().string()); - mSensorEventQueue->disableSensor(sensor); - sensorsEnabled &= ~SENSOR_ORIENTATION; - } - - LOG_FUNCTION_NAME_EXIT; -} - -} // namespace Camera -} // namespace Ti diff --git a/camera/TICameraParameters.cpp b/camera/TICameraParameters.cpp deleted file mode 100644 index 1e2ec20..0000000 --- a/camera/TICameraParameters.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include -#include -#include - -#define TI_KEY_ALGO_PREFIX "ti-algo-" - -namespace Ti { -namespace Camera { - -//TI extensions to camera mode -const char TICameraParameters::HIGH_PERFORMANCE_MODE[] = "high-performance"; -const char TICameraParameters::HIGH_QUALITY_MODE[] = "high-quality"; -const char TICameraParameters::HIGH_QUALITY_ZSL_MODE[] = "high-quality-zsl"; -const char TICameraParameters::CP_CAM_MODE[] = "cp-cam"; -const char TICameraParameters::VIDEO_MODE[] = "video-mode"; -const char TICameraParameters::EXPOSURE_BRACKETING[] = "exposure-bracketing"; -const char TICameraParameters::ZOOM_BRACKETING[] = "zoom-bracketing"; -const char TICameraParameters::TEMP_BRACKETING[] = "temporal-bracketing"; - -// TI extensions to standard android Parameters -const char TICameraParameters::KEY_SUPPORTED_CAMERAS[] = "camera-indexes"; -const char TICameraParameters::KEY_CAMERA[] = "camera-index"; -const char TICameraParameters::KEY_SHUTTER_ENABLE[] = "shutter-enable"; -const char TICameraParameters::KEY_CAMERA_NAME[] = "camera-name"; -const char TICameraParameters::KEY_BURST[] = "burst-capture"; -const char TICameraParameters::KEY_CAP_MODE[] = "mode"; -const char TICameraParameters::KEY_CAP_MODE_VALUES[] = "mode-values"; -const char TICameraParameters::KEY_VNF[] = "vnf"; -const char TICameraParameters::KEY_VNF_SUPPORTED[] = "vnf-supported"; -const char TICameraParameters::KEY_SATURATION[] = "saturation"; -const char TICameraParameters::KEY_BRIGHTNESS[] = "brightness"; -const char TICameraParameters::KEY_SUPPORTED_EXPOSURE[] = "exposure-mode-values"; -const char TICameraParameters::KEY_EXPOSURE_MODE[] = "exposure"; -const char TICameraParameters::KEY_SUPPORTED_MANUAL_EXPOSURE_MIN[] = "supported-manual-exposure-min"; -const char TICameraParameters::KEY_SUPPORTED_MANUAL_EXPOSURE_MAX[] = "supported-manual-exposure-max"; -const char TICameraParameters::KEY_SUPPORTED_MANUAL_EXPOSURE_STEP[] = "supported-manual-exposure-step"; -const char TICameraParameters::KEY_SUPPORTED_MANUAL_GAIN_ISO_MIN[] = "supported-manual-gain-iso-min"; -const char TICameraParameters::KEY_SUPPORTED_MANUAL_GAIN_ISO_MAX[] = "supported-manual-gain-iso-max"; -const char TICameraParameters::KEY_SUPPORTED_MANUAL_GAIN_ISO_STEP[] = "supported-manual-gain-iso-step"; -const char TICameraParameters::KEY_MANUAL_EXPOSURE[] = "manual-exposure"; -const char TICameraParameters::KEY_MANUAL_EXPOSURE_RIGHT[] = "manual-exposure-right"; -const char TICameraParameters::KEY_MANUAL_GAIN_ISO[] = "manual-gain-iso"; -const char TICameraParameters::KEY_MANUAL_GAIN_ISO_RIGHT[] = "manual-gain-iso-right"; -const char TICameraParameters::KEY_CONTRAST[] = "contrast"; -const char TICameraParameters::KEY_SHARPNESS[] = "sharpness"; -const char TICameraParameters::KEY_ISO[] = "iso"; -const char TICameraParameters::KEY_SUPPORTED_ISO_VALUES[] = "iso-mode-values"; -const char TICameraParameters::KEY_SUPPORTED_IPP[] = "ipp-values"; -const char TICameraParameters::KEY_IPP[] = "ipp"; -const char TICameraParameters::KEY_METERING_MODE[] = "meter-mode"; -const char TICameraParameters::KEY_EXP_BRACKETING_RANGE[] = "exp-bracketing-range"; -const char TICameraParameters::KEY_EXP_GAIN_BRACKETING_RANGE[] = "exp-gain-bracketing-range"; -const char TICameraParameters::KEY_ZOOM_BRACKETING_RANGE[] = "zoom-bracketing-range"; -const char TICameraParameters::KEY_TEMP_BRACKETING[] = "temporal-bracketing"; -const char TICameraParameters::KEY_TEMP_BRACKETING_RANGE_POS[] = "temporal-bracketing-range-positive"; -const char TICameraParameters::KEY_TEMP_BRACKETING_RANGE_NEG[] = "temporal-bracketing-range-negative"; -const char TICameraParameters::KEY_FLUSH_SHOT_CONFIG_QUEUE[] = "flush-shot-config-queue"; -const char TICameraParameters::KEY_MEASUREMENT_ENABLE[] = "measurement"; -const char TICameraParameters::KEY_GBCE[] = "gbce"; -const char TICameraParameters::KEY_GBCE_SUPPORTED[] = "gbce-supported"; -const char TICameraParameters::KEY_GLBCE[] = "glbce"; -const char TICameraParameters::KEY_GLBCE_SUPPORTED[] = "glbce-supported"; -const char TICameraParameters::KEY_CURRENT_ISO[] = "current-iso"; -const char TICameraParameters::KEY_SENSOR_ORIENTATION[] = "sensor-orientation"; -const char TICameraParameters::KEY_RECORDING_HINT[] = "internal-recording-hint"; -const char TICameraParameters::KEY_AUTO_FOCUS_LOCK[] = "auto-focus-lock"; -const char TICameraParameters::KEY_FRAMERATE_RANGES_EXT_SUPPORTED[] = "preview-fps-range-ext-values"; -const char TICameraParameters::KEY_FRAMERATES_EXT_SUPPORTED[] = "preview-fps-ext-values"; - -const char TICameraParameters::RAW_WIDTH[] = "raw-width"; -const char TICameraParameters::RAW_HEIGHT[] = "raw-height"; - -#ifndef OMAP_TUNA -// TI extensions for Stereo Mode -const char TICameraParameters::KEY_S3D_PRV_FRAME_LAYOUT[] = "s3d-prv-frame-layout"; -const char TICameraParameters::KEY_S3D_PRV_FRAME_LAYOUT_VALUES[] = "s3d-prv-frame-layout-values"; -const char TICameraParameters::KEY_S3D_CAP_FRAME_LAYOUT[] = "s3d-cap-frame-layout"; -const char TICameraParameters::KEY_S3D_CAP_FRAME_LAYOUT_VALUES[] = "s3d-cap-frame-layout-values"; -#endif - -#ifndef OMAP_TUNA -//TI extentions fo 3D resolutions -const char TICameraParameters::KEY_SUPPORTED_PICTURE_SUBSAMPLED_SIZES[] = "supported-picture-subsampled-size-values"; -const char TICameraParameters::KEY_SUPPORTED_PICTURE_TOPBOTTOM_SIZES[] = "supported-picture-topbottom-size-values"; -const char TICameraParameters::KEY_SUPPORTED_PICTURE_SIDEBYSIDE_SIZES[] = "supported-picture-sidebyside-size-values"; -const char TICameraParameters::KEY_SUPPORTED_PREVIEW_SUBSAMPLED_SIZES[] = "supported-preview-subsampled-size-values"; -const char TICameraParameters::KEY_SUPPORTED_PREVIEW_TOPBOTTOM_SIZES[] = "supported-preview-topbottom-size-values"; -const char TICameraParameters::KEY_SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES[] = "supported-preview-sidebyside-size-values"; -#endif - -//TI extensions for SAC/SMC -const char TICameraParameters::KEY_AUTOCONVERGENCE_MODE[] = "auto-convergence-mode"; -const char TICameraParameters::KEY_AUTOCONVERGENCE_MODE_VALUES[] = "auto-convergence-mode-values"; -const char TICameraParameters::KEY_MANUAL_CONVERGENCE[] = "manual-convergence"; -const char TICameraParameters::KEY_SUPPORTED_MANUAL_CONVERGENCE_MIN[] = "supported-manual-convergence-min"; -const char TICameraParameters::KEY_SUPPORTED_MANUAL_CONVERGENCE_MAX[] = "supported-manual-convergence-max"; -const char TICameraParameters::KEY_SUPPORTED_MANUAL_CONVERGENCE_STEP[] = "supported-manual-convergence-step"; - -//TI extensions for setting EXIF tags -const char TICameraParameters::KEY_EXIF_MODEL[] = "exif-model"; -const char TICameraParameters::KEY_EXIF_MAKE[] = "exif-make"; - -//TI extensions for additiona GPS data -const char TICameraParameters::KEY_GPS_MAPDATUM[] = "gps-mapdatum"; -const char TICameraParameters::KEY_GPS_VERSION[] = "gps-version"; -const char TICameraParameters::KEY_GPS_DATESTAMP[] = "gps-datestamp"; - -// TI extensions for slice mode implementation for VTC -const char TICameraParameters::KEY_VTC_HINT[] = "internal-vtc-hint"; -const char TICameraParameters::KEY_VIDEO_ENCODER_HANDLE[] = "encoder_handle"; -const char TICameraParameters::KEY_VIDEO_ENCODER_SLICE_HEIGHT[] = "encoder_slice_height"; - -//TI extensions to Image post-processing -const char TICameraParameters::IPP_LDCNSF[] = "ldc-nsf"; -const char TICameraParameters::IPP_LDC[] = "ldc"; -const char TICameraParameters::IPP_NSF[] = "nsf"; -const char TICameraParameters::IPP_NONE[] = "off"; - -// TI extensions to standard android pixel formats -const char TICameraParameters::PIXEL_FORMAT_UNUSED[] = "unused"; -const char TICameraParameters::PIXEL_FORMAT_JPS[] = "jps"; -const char TICameraParameters::PIXEL_FORMAT_MPO[] = "mpo"; -const char TICameraParameters::PIXEL_FORMAT_YUV422I_UYVY[] = "yuv422i-uyvy"; - -// TI extensions to standard android scene mode settings -const char TICameraParameters::SCENE_MODE_CLOSEUP[] = "closeup"; -const char TICameraParameters::SCENE_MODE_AQUA[] = "aqua"; -const char TICameraParameters::SCENE_MODE_SNOWBEACH[] = "snow-beach"; -const char TICameraParameters::SCENE_MODE_MOOD[] = "mood"; -const char TICameraParameters::SCENE_MODE_NIGHT_INDOOR[] = "night-indoor"; -const char TICameraParameters::SCENE_MODE_DOCUMENT[] = "document"; -const char TICameraParameters::SCENE_MODE_BARCODE[] = "barcode"; -const char TICameraParameters::SCENE_MODE_VIDEO_SUPER_NIGHT[] = "super-night"; -const char TICameraParameters::SCENE_MODE_VIDEO_CINE[] = "cine"; -const char TICameraParameters::SCENE_MODE_VIDEO_OLD_FILM[] = "old-film"; - -// TI extensions to standard android white balance values. -const char TICameraParameters::WHITE_BALANCE_TUNGSTEN[] = "tungsten"; -const char TICameraParameters::WHITE_BALANCE_HORIZON[] = "horizon"; -const char TICameraParameters::WHITE_BALANCE_SUNSET[] = "sunset"; -const char TICameraParameters::WHITE_BALANCE_FACE[] = "face-priority"; - -// TI extensions to standard android focus modes. -const char TICameraParameters::FOCUS_MODE_PORTRAIT[] = "portrait"; -const char TICameraParameters::FOCUS_MODE_EXTENDED[] = "extended"; -const char TICameraParameters::FOCUS_MODE_FACE[] = "face-priority"; -const char TICameraParameters::FOCUS_MODE_OFF[] = "off"; - -// TI extensions to add values for effect settings. -const char TICameraParameters::EFFECT_NATURAL[] = "natural"; -const char TICameraParameters::EFFECT_VIVID[] = "vivid"; -const char TICameraParameters::EFFECT_COLOR_SWAP[] = "color-swap"; -const char TICameraParameters::EFFECT_BLACKWHITE[] = "blackwhite"; - -// TI extensions to add exposure preset modes -const char TICameraParameters::EXPOSURE_MODE_MANUAL[] = "manual"; -const char TICameraParameters::EXPOSURE_MODE_AUTO[] = "auto"; -const char TICameraParameters::EXPOSURE_MODE_NIGHT[] = "night"; -const char TICameraParameters::EXPOSURE_MODE_BACKLIGHT[] = "backlighting"; -const char TICameraParameters::EXPOSURE_MODE_SPOTLIGHT[] = "spotlight"; -const char TICameraParameters::EXPOSURE_MODE_SPORTS[] = "sports"; -const char TICameraParameters::EXPOSURE_MODE_SNOW[] = "snow"; -const char TICameraParameters::EXPOSURE_MODE_BEACH[] = "beach"; -const char TICameraParameters::EXPOSURE_MODE_APERTURE[] = "aperture"; -const char TICameraParameters::EXPOSURE_MODE_SMALL_APERTURE[] = "small-aperture"; -const char TICameraParameters::EXPOSURE_MODE_FACE[] = "face-priority"; - -// TI extensions to add iso values -const char TICameraParameters::ISO_MODE_AUTO[] = "auto"; -const char TICameraParameters::ISO_MODE_100[] = "100"; -const char TICameraParameters::ISO_MODE_200[] = "200"; -const char TICameraParameters::ISO_MODE_400[] = "400"; -const char TICameraParameters::ISO_MODE_800[] = "800"; -const char TICameraParameters::ISO_MODE_1000[] = "1000"; -const char TICameraParameters::ISO_MODE_1200[] = "1200"; -const char TICameraParameters::ISO_MODE_1600[] = "1600"; - -#ifndef OMAP_TUNA -//TI extensions for stereo frame layouts -const char TICameraParameters::S3D_NONE[] = "none"; -const char TICameraParameters::S3D_TB_FULL[] = "tb-full"; -const char TICameraParameters::S3D_SS_FULL[] = "ss-full"; -const char TICameraParameters::S3D_TB_SUBSAMPLED[] = "tb-subsampled"; -const char TICameraParameters::S3D_SS_SUBSAMPLED[] = "ss-subsampled"; -#endif - -// TI extensions to add auto convergence values -const char TICameraParameters::AUTOCONVERGENCE_MODE_DISABLE[] = "disable"; -const char TICameraParameters::AUTOCONVERGENCE_MODE_FRAME[] = "frame"; -const char TICameraParameters::AUTOCONVERGENCE_MODE_CENTER[] = "center"; -const char TICameraParameters::AUTOCONVERGENCE_MODE_TOUCH[] = "touch"; -const char TICameraParameters::AUTOCONVERGENCE_MODE_MANUAL[] = "manual"; - -//TI values for camera direction -const char TICameraParameters::FACING_FRONT[]="front"; -const char TICameraParameters::FACING_BACK[]="back"; - -//TI extensions to flash settings -const char TICameraParameters::FLASH_MODE_FILL_IN[] = "fill-in"; - -//TI extensions to add sensor orientation parameters -const char TICameraParameters::ORIENTATION_SENSOR_NONE[] = "0"; -const char TICameraParameters::ORIENTATION_SENSOR_90[] = "90"; -const char TICameraParameters::ORIENTATION_SENSOR_180[] = "180"; -const char TICameraParameters::ORIENTATION_SENSOR_270[] = "270"; - -#ifndef OMAP_TUNA -const char TICameraParameters::KEY_MECHANICAL_MISALIGNMENT_CORRECTION_SUPPORTED[] = "mechanical-misalignment-correction-supported"; -const char TICameraParameters::KEY_MECHANICAL_MISALIGNMENT_CORRECTION[] = "mechanical-misalignment-correction"; -#endif - -#ifndef OMAP_TUNA -//TI extensions for enable/disable algos -const char TICameraParameters::KEY_ALGO_FIXED_GAMMA[] = TI_KEY_ALGO_PREFIX "fixed-gamma"; -const char TICameraParameters::KEY_ALGO_NSF1[] = TI_KEY_ALGO_PREFIX "nsf1"; -const char TICameraParameters::KEY_ALGO_NSF2[] = TI_KEY_ALGO_PREFIX "nsf2"; -const char TICameraParameters::KEY_ALGO_SHARPENING[] = TI_KEY_ALGO_PREFIX "sharpening"; -const char TICameraParameters::KEY_ALGO_THREELINCOLORMAP[] = TI_KEY_ALGO_PREFIX "threelinecolormap"; -const char TICameraParameters::KEY_ALGO_GIC[] = TI_KEY_ALGO_PREFIX "gic"; -#endif - -} // namespace Camera -} // namespace Ti diff --git a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp deleted file mode 100644 index 29c71c7..0000000 --- a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp +++ /dev/null @@ -1,1318 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file V4LCameraAdapter.cpp -* -* This file maps the Camera Hardware Interface to V4L2. -* -*/ - - -#include "V4LCameraAdapter.h" -#include "CameraHal.h" -#include "TICameraParameters.h" -#include "DebugUtils.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false )) -static int mDebugFps = 0; - -#define Q16_OFFSET 16 - -#define HERE(Msg) {CAMHAL_LOGEB("--=== %s===--\n", Msg);} - -namespace Ti { -namespace Camera { - -//frames skipped before recalculating the framerate -#define FPS_PERIOD 30 - -//define this macro to save first few raw frames when starting the preview. -//#define SAVE_RAW_FRAMES 1 -//#define DUMP_CAPTURE_FRAME 1 -//#define PPM_PER_FRAME_CONVERSION 1 - -//Proto Types -static void convertYUV422i_yuyvTouyvy(uint8_t *src, uint8_t *dest, size_t size ); -static void convertYUV422ToNV12Tiler(unsigned char *src, unsigned char *dest, int width, int height ); -static void convertYUV422ToNV12(unsigned char *src, unsigned char *dest, int width, int height ); - -android::Mutex gV4LAdapterLock; -char device[15]; - - -/*--------------------Camera Adapter Class STARTS here-----------------------------*/ - -/*--------------------V4L wrapper functions -------------------------------*/ -status_t V4LCameraAdapter::v4lIoctl (int fd, int req, void* argp) { - status_t ret = NO_ERROR; - errno = 0; - - do { - ret = ioctl (fd, req, argp); - }while (-1 == ret && EINTR == errno); - - return ret; -} - -status_t V4LCameraAdapter::v4lInitMmap(int& count) { - status_t ret = NO_ERROR; - - //First allocate adapter internal buffers at V4L level for USB Cam - //These are the buffers from which we will copy the data into overlay buffers - /* Check if camera can handle NB_BUFFER buffers */ - mVideoInfo->rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - mVideoInfo->rb.memory = V4L2_MEMORY_MMAP; - mVideoInfo->rb.count = count; - - ret = v4lIoctl(mCameraHandle, VIDIOC_REQBUFS, &mVideoInfo->rb); - if (ret < 0) { - CAMHAL_LOGEB("VIDIOC_REQBUFS failed: %s", strerror(errno)); - return ret; - } - - count = mVideoInfo->rb.count; - for (int i = 0; i < count; i++) { - - memset (&mVideoInfo->buf, 0, sizeof (struct v4l2_buffer)); - - mVideoInfo->buf.index = i; - mVideoInfo->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - mVideoInfo->buf.memory = V4L2_MEMORY_MMAP; - - ret = v4lIoctl (mCameraHandle, VIDIOC_QUERYBUF, &mVideoInfo->buf); - if (ret < 0) { - CAMHAL_LOGEB("Unable to query buffer (%s)", strerror(errno)); - return ret; - } - - mVideoInfo->mem[i] = mmap (NULL, - mVideoInfo->buf.length, - PROT_READ | PROT_WRITE, - MAP_SHARED, - mCameraHandle, - mVideoInfo->buf.m.offset); - - CAMHAL_LOGVB(" mVideoInfo->mem[%d]=%p ; mVideoInfo->buf.length = %d", i, mVideoInfo->mem[i], mVideoInfo->buf.length); - if (mVideoInfo->mem[i] == MAP_FAILED) { - CAMHAL_LOGEB("Unable to map buffer [%d]. (%s)", i, strerror(errno)); - return -1; - } - } - return ret; -} - -status_t V4LCameraAdapter::v4lInitUsrPtr(int& count) { - status_t ret = NO_ERROR; - - mVideoInfo->rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - mVideoInfo->rb.memory = V4L2_MEMORY_USERPTR; - mVideoInfo->rb.count = count; - - ret = v4lIoctl(mCameraHandle, VIDIOC_REQBUFS, &mVideoInfo->rb); - if (ret < 0) { - CAMHAL_LOGEB("VIDIOC_REQBUFS failed for USERPTR: %s", strerror(errno)); - return ret; - } - - count = mVideoInfo->rb.count; - return ret; -} - -status_t V4LCameraAdapter::v4lStartStreaming () { - status_t ret = NO_ERROR; - enum v4l2_buf_type bufType; - - if (!mVideoInfo->isStreaming) { - bufType = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - ret = v4lIoctl (mCameraHandle, VIDIOC_STREAMON, &bufType); - if (ret < 0) { - CAMHAL_LOGEB("StartStreaming: Unable to start capture: %s", strerror(errno)); - return ret; - } - mVideoInfo->isStreaming = true; - } - return ret; -} - -status_t V4LCameraAdapter::v4lStopStreaming (int nBufferCount) { - status_t ret = NO_ERROR; - enum v4l2_buf_type bufType; - - if (mVideoInfo->isStreaming) { - bufType = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - ret = v4lIoctl (mCameraHandle, VIDIOC_STREAMOFF, &bufType); - if (ret < 0) { - CAMHAL_LOGEB("StopStreaming: Unable to stop capture: %s", strerror(errno)); - goto EXIT; - } - mVideoInfo->isStreaming = false; - - /* Unmap buffers */ - mVideoInfo->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - mVideoInfo->buf.memory = V4L2_MEMORY_MMAP; - for (int i = 0; i < nBufferCount; i++) { - if (munmap(mVideoInfo->mem[i], mVideoInfo->buf.length) < 0) { - CAMHAL_LOGEA("munmap() failed"); - } - } - - //free the memory allocated during REQBUFS, by setting the count=0 - mVideoInfo->rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - mVideoInfo->rb.memory = V4L2_MEMORY_MMAP; - mVideoInfo->rb.count = 0; - - ret = v4lIoctl(mCameraHandle, VIDIOC_REQBUFS, &mVideoInfo->rb); - if (ret < 0) { - CAMHAL_LOGEB("VIDIOC_REQBUFS failed: %s", strerror(errno)); - goto EXIT; - } - } -EXIT: - return ret; -} - -status_t V4LCameraAdapter::v4lSetFormat (int width, int height, uint32_t pix_format) { - status_t ret = NO_ERROR; - - mVideoInfo->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - ret = v4lIoctl(mCameraHandle, VIDIOC_G_FMT, &mVideoInfo->format); - if (ret < 0) { - CAMHAL_LOGEB("VIDIOC_G_FMT Failed: %s", strerror(errno)); - } - - mVideoInfo->width = width; - mVideoInfo->height = height; - mVideoInfo->framesizeIn = (width * height << 1); - mVideoInfo->formatIn = DEFAULT_PIXEL_FORMAT; - - mVideoInfo->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - mVideoInfo->format.fmt.pix.width = width; - mVideoInfo->format.fmt.pix.height = height; - mVideoInfo->format.fmt.pix.pixelformat = pix_format; - - ret = v4lIoctl(mCameraHandle, VIDIOC_S_FMT, &mVideoInfo->format); - if (ret < 0) { - CAMHAL_LOGEB("VIDIOC_S_FMT Failed: %s", strerror(errno)); - return ret; - } - v4lIoctl(mCameraHandle, VIDIOC_G_FMT, &mVideoInfo->format); - CAMHAL_LOGDB("VIDIOC_G_FMT : WxH = %dx%d", mVideoInfo->format.fmt.pix.width, mVideoInfo->format.fmt.pix.height); - return ret; -} - -status_t V4LCameraAdapter::restartPreview () -{ - status_t ret = NO_ERROR; - int width = 0; - int height = 0; - struct v4l2_streamparm streamParams; - - //configure for preview size and pixel format. - mParams.getPreviewSize(&width, &height); - - ret = v4lSetFormat (width, height, DEFAULT_PIXEL_FORMAT); - if (ret < 0) { - CAMHAL_LOGEB("v4lSetFormat Failed: %s", strerror(errno)); - goto EXIT; - } - - ret = v4lInitMmap(mPreviewBufferCount); - if (ret < 0) { - CAMHAL_LOGEB("v4lInitMmap Failed: %s", strerror(errno)); - goto EXIT; - } - - //set frame rate - streamParams.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - streamParams.parm.capture.capability = V4L2_CAP_TIMEPERFRAME; - streamParams.parm.capture.capturemode = V4L2_MODE_HIGHQUALITY; - streamParams.parm.capture.timeperframe.denominator = FPS_PERIOD; - streamParams.parm.capture.timeperframe.numerator= 1; - ret = v4lIoctl(mCameraHandle, VIDIOC_S_PARM, &streamParams); - if (ret < 0) { - CAMHAL_LOGEB("VIDIOC_S_PARM Failed: %s", strerror(errno)); - goto EXIT; - } - - for (int i = 0; i < mPreviewBufferCountQueueable; i++) { - - mVideoInfo->buf.index = i; - mVideoInfo->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - mVideoInfo->buf.memory = V4L2_MEMORY_MMAP; - - ret = v4lIoctl(mCameraHandle, VIDIOC_QBUF, &mVideoInfo->buf); - if (ret < 0) { - CAMHAL_LOGEA("VIDIOC_QBUF Failed"); - goto EXIT; - } - nQueued++; - } - - ret = v4lStartStreaming(); - CAMHAL_LOGDA("Ready for preview...."); -EXIT: - return ret; -} - -/*--------------------Camera Adapter Functions-----------------------------*/ -status_t V4LCameraAdapter::initialize(CameraProperties::Properties* caps) -{ - char value[PROPERTY_VALUE_MAX]; - - LOG_FUNCTION_NAME; - property_get("debug.camera.showfps", value, "0"); - mDebugFps = atoi(value); - - int ret = NO_ERROR; - - // Allocate memory for video info structure - mVideoInfo = (struct VideoInfo *) calloc (1, sizeof (struct VideoInfo)); - if(!mVideoInfo) { - ret = NO_MEMORY; - goto EXIT; - } - - if ((mCameraHandle = open(device, O_RDWR) ) == -1) { - CAMHAL_LOGEB("Error while opening handle to V4L2 Camera: %s", strerror(errno)); - ret = BAD_VALUE; - goto EXIT; - } - - ret = v4lIoctl (mCameraHandle, VIDIOC_QUERYCAP, &mVideoInfo->cap); - if (ret < 0) { - CAMHAL_LOGEA("Error when querying the capabilities of the V4L Camera"); - ret = BAD_VALUE; - goto EXIT; - } - - if ((mVideoInfo->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) { - CAMHAL_LOGEA("Error while adapter initialization: video capture not supported."); - ret = BAD_VALUE; - goto EXIT; - } - - if (!(mVideoInfo->cap.capabilities & V4L2_CAP_STREAMING)) { - CAMHAL_LOGEA("Error while adapter initialization: Capture device does not support streaming i/o"); - ret = BAD_VALUE; - goto EXIT; - } - - // Initialize flags - mPreviewing = false; - mVideoInfo->isStreaming = false; - mRecording = false; - mCapturing = false; -EXIT: - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -status_t V4LCameraAdapter::fillThisBuffer(CameraBuffer *frameBuf, CameraFrame::FrameType frameType) -{ - status_t ret = NO_ERROR; - int idx = 0; - LOG_FUNCTION_NAME; - - if ( frameType == CameraFrame::IMAGE_FRAME) { //(1 > mCapturedFrames) - // Signal end of image capture - if ( NULL != mEndImageCaptureCallback) { - CAMHAL_LOGDB("===========Signal End Image Capture=========="); - mEndImageCaptureCallback(mEndCaptureData); - } - goto EXIT; - } - if ( !mVideoInfo->isStreaming ) { - goto EXIT; - } - - idx = mPreviewBufs.valueFor(frameBuf); - if(idx < 0) { - CAMHAL_LOGEB("Wrong index = %d",idx); - goto EXIT; - } - - mVideoInfo->buf.index = idx; - mVideoInfo->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - mVideoInfo->buf.memory = V4L2_MEMORY_MMAP; - - ret = v4lIoctl(mCameraHandle, VIDIOC_QBUF, &mVideoInfo->buf); - if (ret < 0) { - CAMHAL_LOGEA("VIDIOC_QBUF Failed"); - goto EXIT; - } - nQueued++; -EXIT: - LOG_FUNCTION_NAME_EXIT; - return ret; - -} - -status_t V4LCameraAdapter::setParameters(const android::CameraParameters ¶ms) -{ - status_t ret = NO_ERROR; - int width, height; - struct v4l2_streamparm streamParams; - - LOG_FUNCTION_NAME; - - if(!mPreviewing && !mCapturing) { - params.getPreviewSize(&width, &height); - CAMHAL_LOGDB("Width * Height %d x %d format 0x%x", width, height, DEFAULT_PIXEL_FORMAT); - - ret = v4lSetFormat( width, height, DEFAULT_PIXEL_FORMAT); - if (ret < 0) { - CAMHAL_LOGEB(" VIDIOC_S_FMT Failed: %s", strerror(errno)); - goto EXIT; - } - //set frame rate - // Now its fixed to 30 FPS - streamParams.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - streamParams.parm.capture.capability = V4L2_CAP_TIMEPERFRAME; - streamParams.parm.capture.capturemode = V4L2_MODE_HIGHQUALITY; - streamParams.parm.capture.timeperframe.denominator = FPS_PERIOD; - streamParams.parm.capture.timeperframe.numerator= 1; - ret = v4lIoctl(mCameraHandle, VIDIOC_S_PARM, &streamParams); - if (ret < 0) { - CAMHAL_LOGEB(" VIDIOC_S_PARM Failed: %s", strerror(errno)); - goto EXIT; - } - int actualFps = streamParams.parm.capture.timeperframe.denominator / streamParams.parm.capture.timeperframe.numerator; - CAMHAL_LOGDB("Actual FPS set is : %d.", actualFps); - } - - // Udpate the current parameter set - mParams = params; - -EXIT: - LOG_FUNCTION_NAME_EXIT; - return ret; -} - - -void V4LCameraAdapter::getParameters(android::CameraParameters& params) -{ - LOG_FUNCTION_NAME; - - // Return the current parameter set - params = mParams; - - LOG_FUNCTION_NAME_EXIT; -} - - -///API to give the buffers to Adapter -status_t V4LCameraAdapter::useBuffers(CameraMode mode, CameraBuffer *bufArr, int num, size_t length, unsigned int queueable) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mLock); - - switch(mode) - { - case CAMERA_PREVIEW: - mPreviewBufferCountQueueable = queueable; - ret = UseBuffersPreview(bufArr, num); - break; - - case CAMERA_IMAGE_CAPTURE: - mCaptureBufferCountQueueable = queueable; - ret = UseBuffersCapture(bufArr, num); - break; - - case CAMERA_VIDEO: - //@warn Video capture is not fully supported yet - mPreviewBufferCountQueueable = queueable; - ret = UseBuffersPreview(bufArr, num); - break; - - case CAMERA_MEASUREMENT: - break; - - default: - break; - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t V4LCameraAdapter::UseBuffersCapture(CameraBuffer *bufArr, int num) { - int ret = NO_ERROR; - - LOG_FUNCTION_NAME; - if(NULL == bufArr) { - ret = BAD_VALUE; - goto EXIT; - } - - for (int i = 0; i < num; i++) { - //Associate each Camera internal buffer with the one from Overlay - mCaptureBufs.add(&bufArr[i], i); - CAMHAL_LOGDB("capture- buff [%d] = 0x%x ",i, mCaptureBufs.keyAt(i)); - } - - // Update the preview buffer count - mCaptureBufferCount = num; -EXIT: - LOG_FUNCTION_NAME_EXIT; - return ret; - -} - -status_t V4LCameraAdapter::UseBuffersPreview(CameraBuffer *bufArr, int num) -{ - int ret = NO_ERROR; - LOG_FUNCTION_NAME; - - if(NULL == bufArr) { - ret = BAD_VALUE; - goto EXIT; - } - - ret = v4lInitMmap(num); - if (ret == NO_ERROR) { - for (int i = 0; i < num; i++) { - //Associate each Camera internal buffer with the one from Overlay - mPreviewBufs.add(&bufArr[i], i); - CAMHAL_LOGDB("Preview- buff [%d] = 0x%x ",i, mPreviewBufs.keyAt(i)); - } - - // Update the preview buffer count - mPreviewBufferCount = num; - } -EXIT: - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -status_t V4LCameraAdapter::takePicture() { - status_t ret = NO_ERROR; - int width = 0; - int height = 0; - size_t yuv422i_buff_size = 0; - int index = 0; - char *fp = NULL; - CameraBuffer *buffer = NULL; - CameraFrame frame; - - LOG_FUNCTION_NAME; - - android::AutoMutex lock(mCaptureBufsLock); - - if(mCapturing) { - CAMHAL_LOGEA("Already Capture in Progress..."); - ret = BAD_VALUE; - goto EXIT; - } - - mCapturing = true; - mPreviewing = false; - - // Stop preview streaming - ret = v4lStopStreaming(mPreviewBufferCount); - if (ret < 0 ) { - CAMHAL_LOGEB("v4lStopStreaming Failed: %s", strerror(errno)); - goto EXIT; - } - - //configure for capture image size and pixel format. - mParams.getPictureSize(&width, &height); - CAMHAL_LOGDB("Image Capture Size WxH = %dx%d",width,height); - yuv422i_buff_size = width * height * 2; - - ret = v4lSetFormat (width, height, DEFAULT_PIXEL_FORMAT); - if (ret < 0) { - CAMHAL_LOGEB("v4lSetFormat Failed: %s", strerror(errno)); - goto EXIT; - } - - ret = v4lInitMmap(mCaptureBufferCount); - if (ret < 0) { - CAMHAL_LOGEB("v4lInitMmap Failed: %s", strerror(errno)); - goto EXIT; - } - - for (int i = 0; i < mCaptureBufferCountQueueable; i++) { - - mVideoInfo->buf.index = i; - mVideoInfo->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - mVideoInfo->buf.memory = V4L2_MEMORY_MMAP; - - ret = v4lIoctl(mCameraHandle, VIDIOC_QBUF, &mVideoInfo->buf); - if (ret < 0) { - CAMHAL_LOGEA("VIDIOC_QBUF Failed"); - ret = BAD_VALUE; - goto EXIT; - } - nQueued++; - } - - ret = v4lStartStreaming(); - if (ret < 0) { - CAMHAL_LOGEB("v4lStartStreaming Failed: %s", strerror(errno)); - goto EXIT; - } - - CAMHAL_LOGDA("Streaming started for Image Capture"); - - //get the frame and send to encode as JPG - fp = this->GetFrame(index); - if(!fp) { - CAMHAL_LOGEA("!!! Captured frame is NULL !!!!"); - ret = BAD_VALUE; - goto EXIT; - } - - CAMHAL_LOGDA("::Capture Frame received from V4L::"); - buffer = mCaptureBufs.keyAt(index); - CAMHAL_LOGVB("## captureBuf[%d] = 0x%x, yuv422i_buff_size=%d", index, buffer->opaque, yuv422i_buff_size); - - //copy the yuv422i data to the image buffer. - memcpy(buffer->opaque, fp, yuv422i_buff_size); - -#ifdef DUMP_CAPTURE_FRAME - //dump the YUV422 buffer in to a file - //a folder should have been created at /data/misc/camera/raw/ - { - int fd =-1; - fd = open("/data/misc/camera/raw/captured_yuv422i_dump.yuv", O_CREAT | O_WRONLY | O_SYNC | O_TRUNC, 0777); - if(fd < 0) { - CAMHAL_LOGEB("Unable to open file: %s", strerror(fd)); - } - else { - write(fd, fp, yuv422i_buff_size ); - close(fd); - CAMHAL_LOGDB("::Captured Frame dumped at /data/misc/camera/raw/captured_yuv422i_dump.yuv::"); - } - } -#endif - - CAMHAL_LOGDA("::sending capture frame to encoder::"); - frame.mFrameType = CameraFrame::IMAGE_FRAME; - frame.mBuffer = buffer; - frame.mLength = yuv422i_buff_size; - frame.mWidth = width; - frame.mHeight = height; - frame.mAlignment = width*2; - frame.mOffset = 0; - frame.mTimestamp = systemTime(SYSTEM_TIME_MONOTONIC); - frame.mFrameMask = (unsigned int)CameraFrame::IMAGE_FRAME; - frame.mQuirks |= CameraFrame::ENCODE_RAW_YUV422I_TO_JPEG; - frame.mQuirks |= CameraFrame::FORMAT_YUV422I_YUYV; - - ret = setInitFrameRefCount(frame.mBuffer, frame.mFrameMask); - if (ret != NO_ERROR) { - CAMHAL_LOGDB("Error in setInitFrameRefCount %d", ret); - } else { - ret = sendFrameToSubscribers(&frame); - } - - // Stop streaming after image capture - ret = v4lStopStreaming(mCaptureBufferCount); - if (ret < 0 ) { - CAMHAL_LOGEB("v4lStopStreaming Failed: %s", strerror(errno)); - goto EXIT; - } - - ret = restartPreview(); -EXIT: - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -status_t V4LCameraAdapter::stopImageCapture() -{ - status_t ret = NO_ERROR; - LOG_FUNCTION_NAME; - - //Release image buffers - if ( NULL != mReleaseImageBuffersCallback ) { - mReleaseImageBuffersCallback(mReleaseData); - } - mCaptureBufs.clear(); - - mCapturing = false; - mPreviewing = true; - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -status_t V4LCameraAdapter::autoFocus() -{ - status_t ret = NO_ERROR; - LOG_FUNCTION_NAME; - - //autoFocus is not implemented. Just return. - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -status_t V4LCameraAdapter::startPreview() -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - android::AutoMutex lock(mPreviewBufsLock); - - if(mPreviewing) { - ret = BAD_VALUE; - goto EXIT; - } - - for (int i = 0; i < mPreviewBufferCountQueueable; i++) { - - mVideoInfo->buf.index = i; - mVideoInfo->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - mVideoInfo->buf.memory = V4L2_MEMORY_MMAP; - - ret = v4lIoctl(mCameraHandle, VIDIOC_QBUF, &mVideoInfo->buf); - if (ret < 0) { - CAMHAL_LOGEA("VIDIOC_QBUF Failed"); - goto EXIT; - } - nQueued++; - } - - ret = v4lStartStreaming(); - - // Create and start preview thread for receiving buffers from V4L Camera - if(!mCapturing) { - mPreviewThread = new PreviewThread(this); - CAMHAL_LOGDA("Created preview thread"); - } - - //Update the flag to indicate we are previewing - mPreviewing = true; - mCapturing = false; - -EXIT: - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -status_t V4LCameraAdapter::stopPreview() -{ - enum v4l2_buf_type bufType; - int ret = NO_ERROR; - - LOG_FUNCTION_NAME; - android::AutoMutex lock(mStopPreviewLock); - - if(!mPreviewing) { - return NO_INIT; - } - mPreviewing = false; - - ret = v4lStopStreaming(mPreviewBufferCount); - if (ret < 0) { - CAMHAL_LOGEB("StopStreaming: FAILED: %s", strerror(errno)); - } - - nQueued = 0; - nDequeued = 0; - mFramesWithEncoder = 0; - - mPreviewBufs.clear(); - - mPreviewThread->requestExitAndWait(); - mPreviewThread.clear(); - - LOG_FUNCTION_NAME_EXIT; - return ret; -} - -char * V4LCameraAdapter::GetFrame(int &index) -{ - int ret = NO_ERROR; - LOG_FUNCTION_NAME; - - mVideoInfo->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - mVideoInfo->buf.memory = V4L2_MEMORY_MMAP; - - /* DQ */ - ret = v4lIoctl(mCameraHandle, VIDIOC_DQBUF, &mVideoInfo->buf); - if (ret < 0) { - CAMHAL_LOGEA("GetFrame: VIDIOC_DQBUF Failed"); - return NULL; - } - nDequeued++; - - index = mVideoInfo->buf.index; - - LOG_FUNCTION_NAME_EXIT; - return (char *)mVideoInfo->mem[mVideoInfo->buf.index]; -} - -//API to get the frame size required to be allocated. This size is used to override the size passed -//by camera service when VSTAB/VNF is turned ON for example -status_t V4LCameraAdapter::getFrameSize(size_t &width, size_t &height) -{ - status_t ret = NO_ERROR; - LOG_FUNCTION_NAME; - - // Just return the current preview size, nothing more to do here. - mParams.getPreviewSize(( int * ) &width, - ( int * ) &height); - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t V4LCameraAdapter::getFrameDataSize(size_t &dataFrameSize, size_t bufferCount) -{ - // We don't support meta data, so simply return - return NO_ERROR; -} - -status_t V4LCameraAdapter::getPictureBufferSize(CameraFrame *frame, size_t bufferCount) -{ - int width = 0; - int height = 0; - int bytesPerPixel = 2; // for YUV422i; default pixel format - - LOG_FUNCTION_NAME; - - if (frame == NULL) { - return BAD_VALUE; - } - - mParams.getPictureSize( &width, &height ); - frame->mLength = width * height * bytesPerPixel; - frame->mWidth = width; - frame->mHeight = height; - frame->mAlignment = width * bytesPerPixel; - - CAMHAL_LOGDB("Picture size: W x H = %u x %u (size=%u bytes, alignment=%u bytes)", - frame->mWidth, frame->mHeight, frame->mLength, frame->mAlignment); - LOG_FUNCTION_NAME_EXIT; - return NO_ERROR; -} - -static void debugShowFPS() -{ - static int mFrameCount = 0; - static int mLastFrameCount = 0; - static nsecs_t mLastFpsTime = 0; - static float mFps = 0; - if(mDebugFps) { - mFrameCount++; - if (!(mFrameCount & 0x1F)) { - nsecs_t now = systemTime(); - nsecs_t diff = now - mLastFpsTime; - mFps = ((mFrameCount - mLastFrameCount) * float(s2ns(1))) / diff; - mLastFpsTime = now; - mLastFrameCount = mFrameCount; - CAMHAL_LOGD("Camera %d Frames, %f FPS", mFrameCount, mFps); - } - } -} - -status_t V4LCameraAdapter::recalculateFPS() -{ - float currentFPS; - - mFrameCount++; - - if ( ( mFrameCount % FPS_PERIOD ) == 0 ) - { - nsecs_t now = systemTime(); - nsecs_t diff = now - mLastFPSTime; - currentFPS = ((mFrameCount - mLastFrameCount) * float(s2ns(1))) / diff; - mLastFPSTime = now; - mLastFrameCount = mFrameCount; - - if ( 1 == mIter ) - { - mFPS = currentFPS; - } - else - { - //cumulative moving average - mFPS = mLastFPS + (currentFPS - mLastFPS)/mIter; - } - - mLastFPS = mFPS; - mIter++; - } - - return NO_ERROR; -} - -void V4LCameraAdapter::onOrientationEvent(uint32_t orientation, uint32_t tilt) -{ - LOG_FUNCTION_NAME; - - LOG_FUNCTION_NAME_EXIT; -} - - -V4LCameraAdapter::V4LCameraAdapter(size_t sensor_index) -{ - LOG_FUNCTION_NAME; - - // Nothing useful to do in the constructor - mFramesWithEncoder = 0; - - LOG_FUNCTION_NAME_EXIT; -} - -V4LCameraAdapter::~V4LCameraAdapter() -{ - LOG_FUNCTION_NAME; - - // Close the camera handle and free the video info structure - close(mCameraHandle); - - if (mVideoInfo) - { - free(mVideoInfo); - mVideoInfo = NULL; - } - - LOG_FUNCTION_NAME_EXIT; -} - -static void convertYUV422i_yuyvTouyvy(uint8_t *src, uint8_t *dest, size_t size ) { - //convert YUV422I yuyv to uyvy format. - uint32_t *bf = (uint32_t*)src; - uint32_t *dst = (uint32_t*)dest; - - LOG_FUNCTION_NAME; - - if (!src || !dest) { - return; - } - - for(size_t i = 0; i < size; i = i+4) - { - dst[0] = ((bf[0] & 0x00FF00FF) << 8) | ((bf[0] & 0xFF00FF00) >> 8); - bf++; - dst++; - } - - LOG_FUNCTION_NAME_EXIT; -} - -static void convertYUV422ToNV12Tiler(unsigned char *src, unsigned char *dest, int width, int height ) { - //convert YUV422I to YUV420 NV12 format and copies directly to preview buffers (Tiler memory). - int stride = 4096; - unsigned char *bf = src; - unsigned char *dst_y = dest; - unsigned char *dst_uv = dest + ( height * stride); -#ifdef PPM_PER_FRAME_CONVERSION - static int frameCount = 0; - static nsecs_t ppm_diff = 0; - nsecs_t ppm_start = systemTime(); -#endif - - LOG_FUNCTION_NAME; - - if (width % 16 ) { - for(int i = 0; i < height; i++) { - for(int j = 0; j < width; j++) { - *dst_y = *bf; - dst_y++; - bf = bf + 2; - } - dst_y += (stride - width); - } - - bf = src; - bf++; //UV sample - for(int i = 0; i < height/2; i++) { - for(int j=0; j= 30) { - ppm_diff = ppm_diff / frameCount; - LOGD("PPM: YUV422i to NV12 Conversion(%d x %d): %llu us ( %llu ms )", width, height, - ns2us(ppm_diff), ns2ms(ppm_diff) ); - ppm_diff = 0; - frameCount = 0; - } -#endif - - LOG_FUNCTION_NAME_EXIT; -} - -static void convertYUV422ToNV12(unsigned char *src, unsigned char *dest, int width, int height ) { - //convert YUV422I to YUV420 NV12 format. - unsigned char *bf = src; - unsigned char *dst_y = dest; - unsigned char *dst_uv = dest + (width * height); - - LOG_FUNCTION_NAME; - - if (width % 16 ) { - for(int i = 0; i < height; i++) { - for(int j = 0; j < width; j++) { - *dst_y = *bf; - dst_y++; - bf = bf + 2; - } - } - - bf = src; - bf++; //UV sample - for(int i = 0; i < height/2; i++) { - for(int j=0; j 3) { - return; - } - //dump nv12 buffer - counter++; - sprintf(fn, "/data/misc/camera/raw/nv12_dump_%03d.yuv", counter); - CAMHAL_LOGEB("Dumping nv12 frame to a file : %s.", fn); - - fd = open(fn, O_CREAT | O_WRONLY | O_SYNC | O_TRUNC, 0777); - if(fd < 0) { - CAMHAL_LOGE("Unable to open file %s: %s", fn, strerror(fd)); - return; - } - - write(fd, buff, buff_size ); - close(fd); - - LOG_FUNCTION_NAME_EXIT; -} -#endif - -/* Preview Thread */ -// --------------------------------------------------------------------------- - -int V4LCameraAdapter::previewThread() -{ - status_t ret = NO_ERROR; - int width, height; - CameraFrame frame; - void *y_uv[2]; - int index = 0; - int stride = 4096; - char *fp = NULL; - - mParams.getPreviewSize(&width, &height); - - if (mPreviewing) { - - fp = this->GetFrame(index); - if(!fp) { - ret = BAD_VALUE; - goto EXIT; - } - CameraBuffer *buffer = mPreviewBufs.keyAt(index); - CameraFrame *lframe = (CameraFrame *)mFrameQueue.valueFor(buffer); - if (!lframe) { - ret = BAD_VALUE; - goto EXIT; - } - - debugShowFPS(); - - if ( mFrameSubscribers.size() == 0 ) { - ret = BAD_VALUE; - goto EXIT; - } - y_uv[0] = (void*) lframe->mYuv[0]; - //y_uv[1] = (void*) lframe->mYuv[1]; - //y_uv[1] = (void*) (lframe->mYuv[0] + height*stride); - convertYUV422ToNV12Tiler ( (unsigned char*)fp, (unsigned char*)y_uv[0], width, height); - CAMHAL_LOGVB("##...index= %d.;camera buffer= 0x%x; y= 0x%x; UV= 0x%x.",index, buffer, y_uv[0], y_uv[1] ); - -#ifdef SAVE_RAW_FRAMES - unsigned char* nv12_buff = (unsigned char*) malloc(width*height*3/2); - //Convert yuv422i to yuv420sp(NV12) & dump the frame to a file - convertYUV422ToNV12 ( (unsigned char*)fp, nv12_buff, width, height); - saveFile( nv12_buff, ((width*height)*3/2) ); - free (nv12_buff); -#endif - - frame.mFrameType = CameraFrame::PREVIEW_FRAME_SYNC; - frame.mBuffer = buffer; - frame.mLength = width*height*3/2; - frame.mAlignment = stride; - frame.mOffset = 0; - frame.mTimestamp = systemTime(SYSTEM_TIME_MONOTONIC); - frame.mFrameMask = (unsigned int)CameraFrame::PREVIEW_FRAME_SYNC; - - if (mRecording) - { - frame.mFrameMask |= (unsigned int)CameraFrame::VIDEO_FRAME_SYNC; - mFramesWithEncoder++; - } - - ret = setInitFrameRefCount(frame.mBuffer, frame.mFrameMask); - if (ret != NO_ERROR) { - CAMHAL_LOGDB("Error in setInitFrameRefCount %d", ret); - } else { - ret = sendFrameToSubscribers(&frame); - } - } -EXIT: - - return ret; -} - -//scan for video devices -void detectVideoDevice(char** video_device_list, int& num_device) { - char dir_path[20]; - char* filename; - char** dev_list = video_device_list; - DIR *d; - struct dirent *dir; - int index = 0; - - strcpy(dir_path, DEVICE_PATH); - d = opendir(dir_path); - if(d) { - //read each entry in the /dev/ and find if there is videox entry. - while ((dir = readdir(d)) != NULL) { - filename = dir->d_name; - if (strncmp(filename, DEVICE_NAME, 5) == 0) { - strcpy(dev_list[index],DEVICE_PATH); - strncat(dev_list[index],filename,sizeof(DEVICE_NAME)); - index++; - } - } //end of while() - closedir(d); - num_device = index; - - for(int i=0; iset(CameraProperties::PREVIEW_FORMAT, DEFAULT_PREVIEW_FORMAT); - - params->set(CameraProperties::PICTURE_FORMAT, DEFAULT_PICTURE_FORMAT); - params->set(CameraProperties::PICTURE_SIZE, DEFAULT_PICTURE_SIZE); - params->set(CameraProperties::PREVIEW_SIZE, DEFAULT_PREVIEW_SIZE); - params->set(CameraProperties::PREVIEW_FRAME_RATE, DEFAULT_FRAMERATE); - params->set(CameraProperties::REQUIRED_PREVIEW_BUFS, DEFAULT_NUM_PREV_BUFS); - params->set(CameraProperties::FOCUS_MODE, DEFAULT_FOCUS_MODE); - - params->set(CameraProperties::CAMERA_NAME, "USBCAMERA"); - params->set(CameraProperties::JPEG_THUMBNAIL_SIZE, "320x240"); - params->set(CameraProperties::JPEG_QUALITY, "90"); - params->set(CameraProperties::JPEG_THUMBNAIL_QUALITY, "50"); - params->set(CameraProperties::FRAMERATE_RANGE_SUPPORTED, "(30000,30000)"); - params->set(CameraProperties::FRAMERATE_RANGE, "30000,30000"); - params->set(CameraProperties::S3D_PRV_FRAME_LAYOUT, "none"); - params->set(CameraProperties::SUPPORTED_EXPOSURE_MODES, "auto"); - params->set(CameraProperties::SUPPORTED_ISO_VALUES, "auto"); - params->set(CameraProperties::SUPPORTED_ANTIBANDING, "auto"); - params->set(CameraProperties::SUPPORTED_EFFECTS, "none"); - params->set(CameraProperties::SUPPORTED_IPP_MODES, "ldc-nsf"); - params->set(CameraProperties::FACING_INDEX, TICameraParameters::FACING_FRONT); - params->set(CameraProperties::ORIENTATION_INDEX, 0); - params->set(CameraProperties::SENSOR_ORIENTATION, "0"); - params->set(CameraProperties::VSTAB, DEFAULT_VSTAB); - params->set(CameraProperties::VNF, DEFAULT_VNF); - - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t V4LCameraAdapter::insertPreviewFormats(CameraProperties::Properties* params, V4L_TI_CAPTYPE &caps) { - - char supported[MAX_PROP_VALUE_LENGTH]; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - for (int i = 0; i < caps.ulPreviewFormatCount; i++) { - for (unsigned int j = 0; j < ARRAY_SIZE(mPixelformats); j++) { - if(caps.ePreviewFormats[i] == mPixelformats[j].pixelformat ) { - strncat (supported, mPixelformats[j].param, MAX_PROP_VALUE_LENGTH-1 ); - strncat (supported, PARAM_SEP, 1 ); - } - } - } - strncat(supported, android::CameraParameters::PIXEL_FORMAT_YUV420P, MAX_PROP_VALUE_LENGTH - 1); - params->set(CameraProperties::SUPPORTED_PREVIEW_FORMATS, supported); - return NO_ERROR; -} - -status_t V4LCameraAdapter::insertPreviewSizes(CameraProperties::Properties* params, V4L_TI_CAPTYPE &caps) { - - char supported[MAX_PROP_VALUE_LENGTH]; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - for (int i = 0; i < caps.ulPreviewResCount; i++) { - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat (supported, caps.tPreviewRes[i].param, MAX_PROP_VALUE_LENGTH-1 ); - } - - params->set(CameraProperties::SUPPORTED_PREVIEW_SIZES, supported); - params->set(CameraProperties::SUPPORTED_PREVIEW_SUBSAMPLED_SIZES, supported); - return NO_ERROR; -} - -status_t V4LCameraAdapter::insertImageSizes(CameraProperties::Properties* params, V4L_TI_CAPTYPE &caps) { - - char supported[MAX_PROP_VALUE_LENGTH]; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - for (int i = 0; i < caps.ulCaptureResCount; i++) { - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat (supported, caps.tCaptureRes[i].param, MAX_PROP_VALUE_LENGTH-1 ); - } - params->set(CameraProperties::SUPPORTED_PICTURE_SIZES, supported); - return NO_ERROR; -} - -status_t V4LCameraAdapter::insertFrameRates(CameraProperties::Properties* params, V4L_TI_CAPTYPE &caps) { - - char supported[MAX_PROP_VALUE_LENGTH]; - char temp[10]; - - memset(supported, '\0', MAX_PROP_VALUE_LENGTH); - for (int i = 0; i < caps.ulFrameRateCount; i++) { - snprintf (temp, 10, "%d", caps.ulFrameRates[i] ); - if (supported[0] != '\0') { - strncat(supported, PARAM_SEP, 1); - } - strncat (supported, temp, MAX_PROP_VALUE_LENGTH-1 ); - } - - params->set(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES, supported); - return NO_ERROR; -} - -status_t V4LCameraAdapter::insertCapabilities(CameraProperties::Properties* params, V4L_TI_CAPTYPE &caps) -{ - status_t ret = NO_ERROR; - - LOG_FUNCTION_NAME; - - if ( NO_ERROR == ret ) { - ret = insertPreviewFormats(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertImageSizes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertPreviewSizes(params, caps); - } - - if ( NO_ERROR == ret ) { - ret = insertFrameRates(params, caps); - } - - //Insert Supported Focus modes. - params->set(CameraProperties::SUPPORTED_FOCUS_MODES, "infinity"); - - params->set(CameraProperties::SUPPORTED_PICTURE_FORMATS, "jpeg"); - - if ( NO_ERROR == ret ) { - ret = insertDefaults(params, caps); - } - - LOG_FUNCTION_NAME_EXIT; - - return ret; -} - -status_t V4LCameraAdapter::sortAscend(V4L_TI_CAPTYPE &caps, uint16_t count) { - size_t tempRes; - size_t w, h, tmpW,tmpH; - for (int i=0; i (tmpW * tmpH) ) { - caps.tPreviewRes[j].width = w; - caps.tPreviewRes[j].height = h; - w = tmpW; - h = tmpH; - } - } - caps.tPreviewRes[i].width = w; - caps.tPreviewRes[i].height = h; - - } - return NO_ERROR; -} - -/***************************************** - * public exposed function declarations - *****************************************/ - -status_t V4LCameraAdapter::getCaps(const int sensorId, CameraProperties::Properties* params, - V4L_HANDLETYPE handle) { - status_t status = NO_ERROR; - V4L_TI_CAPTYPE caps; - int i = 0; - int j = 0; - struct v4l2_fmtdesc fmtDesc; - struct v4l2_frmsizeenum frmSizeEnum; - struct v4l2_frmivalenum frmIvalEnum; - - //get supported pixel formats - for ( i = 0; status == NO_ERROR; i++) { - fmtDesc.index = i; - fmtDesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - status = ioctl (handle, VIDIOC_ENUM_FMT, &fmtDesc); - if (status == NO_ERROR) { - CAMHAL_LOGDB("fmtDesc[%d].description::pixelformat::flags== (%s::%d::%d)",i, fmtDesc.description,fmtDesc.pixelformat,fmtDesc.flags); - caps.ePreviewFormats[i] = fmtDesc.pixelformat; - } - } - caps.ulPreviewFormatCount = i; - - //get preview sizes & capture image sizes - status = NO_ERROR; - for ( i = 0; status == NO_ERROR; i++) { - frmSizeEnum.index = i; - //Check for frame sizes for default pixel format - //TODO: Check for frame sizes for all supported pixel formats - frmSizeEnum.pixel_format = V4L2_PIX_FMT_YUYV; - status = ioctl (handle, VIDIOC_ENUM_FRAMESIZES, &frmSizeEnum); - if(frmSizeEnum.type != V4L2_FRMSIZE_TYPE_DISCRETE) { - break; - } - if (status == NO_ERROR) { - CAMHAL_LOGDB("frmSizeEnum.index[%d].width x height == (%d x %d)", i, frmSizeEnum.discrete.width, frmSizeEnum.discrete.height); - caps.tPreviewRes[i].width = frmSizeEnum.discrete.width; - caps.tPreviewRes[i].height = frmSizeEnum.discrete.height; - snprintf(caps.tPreviewRes[i].param, MAX_RES_STRING_LENGTH,"%dx%d",frmSizeEnum.discrete.width,frmSizeEnum.discrete.height); - - caps.tCaptureRes[i].width = frmSizeEnum.discrete.width; - caps.tCaptureRes[i].height = frmSizeEnum.discrete.height; - snprintf(caps.tCaptureRes[i].param, MAX_RES_STRING_LENGTH,"%dx%d",frmSizeEnum.discrete.width,frmSizeEnum.discrete.height); - } - else { - caps.ulCaptureResCount = i; - caps.ulPreviewResCount = i; - } - } - if(frmSizeEnum.type != V4L2_FRMSIZE_TYPE_DISCRETE) { - CAMHAL_LOGDB("\nmin_width x height = %d x %d ",frmSizeEnum.stepwise.min_width, frmSizeEnum.stepwise.min_height); - CAMHAL_LOGDB("\nmax_width x height = %d x %d ",frmSizeEnum.stepwise.max_width, frmSizeEnum.stepwise.max_height); - CAMHAL_LOGDB("\nstep width x height = %d x %d ",frmSizeEnum.stepwise.step_width,frmSizeEnum.stepwise.step_height); - //TODO: populate the sizes when type = V4L2_FRMSIZE_TYPE_STEPWISE - } - - //sort the preview sizes in ascending order - sortAscend(caps, caps.ulPreviewResCount); - - //get supported frame rates - bool fps30 = false; - for ( j=caps.ulPreviewResCount-1; j >= 0; j--) { - CAMHAL_LOGDB(" W x H = %d x %d", caps.tPreviewRes[j].width, caps.tPreviewRes[j].height); - status = NO_ERROR; - for ( i = 0; status == NO_ERROR; i++) { - frmIvalEnum.index = i; - //Check for supported frame rates for the default pixel format. - frmIvalEnum.pixel_format = V4L2_PIX_FMT_YUYV; - frmIvalEnum.width = caps.tPreviewRes[j].width; - frmIvalEnum.height = caps.tPreviewRes[j].height; - - status = ioctl (handle, VIDIOC_ENUM_FRAMEINTERVALS, &frmIvalEnum); - if(frmIvalEnum.type != V4L2_FRMIVAL_TYPE_DISCRETE) { - break; - } - if (status == NO_ERROR) { - CAMHAL_LOGDB("frmIvalEnum[%d].frame rate= %d)",i, (frmIvalEnum.discrete.denominator/frmIvalEnum.discrete.numerator)); - caps.ulFrameRates[i] = (frmIvalEnum.discrete.denominator/frmIvalEnum.discrete.numerator); - if (caps.ulFrameRates[i] == 30) { - fps30 = true; - } - } - else { - caps.ulFrameRateCount = i; - } - } - if(fps30) { - break; - } - } - - if(frmIvalEnum.type != V4L2_FRMIVAL_TYPE_DISCRETE) { - //TODO: populate the frame rates when type = V4L2_FRMIVAL_TYPE_STEPWISE; - } - - //update the preview resolution with the highest resolution which supports 30fps. -/* // for video preview the application choose the resolution from the mediaprofiles.xml. - // so populating all supported preview resolution is required for video mode. - caps.tPreviewRes[0].width = caps.tPreviewRes[j].width; - caps.tPreviewRes[0].height = caps.tPreviewRes[j].height; - snprintf(caps.tPreviewRes[0].param, MAX_RES_STRING_LENGTH,"%dx%d",caps.tPreviewRes[j].width,caps.tPreviewRes[j].height); - caps.ulPreviewResCount = 1; -*/ - insertCapabilities (params, caps); - return NO_ERROR; -} - - - -} // namespace Camera -} // namespace Ti diff --git a/camera/inc/ANativeWindowDisplayAdapter.h b/camera/inc/ANativeWindowDisplayAdapter.h deleted file mode 100644 index 560e98d..0000000 --- a/camera/inc/ANativeWindowDisplayAdapter.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - -#include "CameraHal.h" -#include -#include - -namespace Ti { -namespace Camera { - -/** - * Display handler class - This class basically handles the buffer posting to display - */ - -class ANativeWindowDisplayAdapter : public DisplayAdapter -{ -public: - - typedef struct - { - CameraBuffer *mBuffer; - void *mUser; - int mOffset; - int mWidth; - int mHeight; - int mWidthStride; - int mHeightStride; - int mLength; - CameraFrame::FrameType mType; - } DisplayFrame; - - enum DisplayStates - { - DISPLAY_INIT = 0, - DISPLAY_STARTED, - DISPLAY_STOPPED, - DISPLAY_EXITED - }; - -public: - - ANativeWindowDisplayAdapter(); - virtual ~ANativeWindowDisplayAdapter(); - - ///Initializes the display adapter creates any resources required - virtual status_t initialize(); - - virtual int setPreviewWindow(struct preview_stream_ops *window); - virtual int setFrameProvider(FrameNotifier *frameProvider); - virtual int setErrorHandler(ErrorNotifier *errorNotifier); - virtual int enableDisplay(int width, int height, struct timeval *refTime = NULL); - virtual int disableDisplay(bool cancel_buffer = true); - virtual status_t pauseDisplay(bool pause); - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - //Used for shot to snapshot measurement - virtual status_t setSnapshotTimeRef(struct timeval *refTime = NULL); - -#endif - - virtual bool supportsExternalBuffering(); - - //Implementation of inherited interfaces - virtual CameraBuffer * allocateBufferList(int width, int height, const char* format, int &bytes, int numBufs); - virtual CameraBuffer *getBufferList(int *numBufs); - virtual uint32_t * getOffsets() ; - virtual int getFd() ; - virtual int freeBufferList(CameraBuffer * buflist); - - virtual status_t maxQueueableBuffers(unsigned int& queueable); - virtual status_t minUndequeueableBuffers(int& unqueueable); - - ///Class specific functions - static void frameCallbackRelay(CameraFrame* caFrame); - void frameCallback(CameraFrame* caFrame); - - void displayThread(); - - private: - void destroy(); - bool processHalMsg(); - status_t PostFrame(ANativeWindowDisplayAdapter::DisplayFrame &dispFrame); - bool handleFrameReturn(); - status_t returnBuffersToWindow(); - -public: - - static const int DISPLAY_TIMEOUT; - static const int FAILED_DQS_TO_SUSPEND; - - class DisplayThread : public android::Thread - { - ANativeWindowDisplayAdapter* mDisplayAdapter; - Utils::MessageQueue mDisplayThreadQ; - - public: - DisplayThread(ANativeWindowDisplayAdapter* da) - : Thread(false), mDisplayAdapter(da) { } - - ///Returns a reference to the display message Q for display adapter to post messages - Utils::MessageQueue& msgQ() - { - return mDisplayThreadQ; - } - - virtual bool threadLoop() - { - mDisplayAdapter->displayThread(); - return false; - } - - enum DisplayThreadCommands - { - DISPLAY_START, - DISPLAY_STOP, - DISPLAY_FRAME, - DISPLAY_EXIT - }; - }; - - //friend declarations -friend class DisplayThread; - -private: - int postBuffer(void* displayBuf); - -private: - bool mFirstInit; - bool mSuspend; - int mFailedDQs; - bool mPaused; //Pause state - preview_stream_ops_t* mANativeWindow; - android::sp mDisplayThread; - FrameProvider *mFrameProvider; ///Pointer to the frame provider interface - Utils::MessageQueue mDisplayQ; - unsigned int mDisplayState; - ///@todo Have a common class for these members - mutable android::Mutex mLock; - bool mDisplayEnabled; - int mBufferCount; - CameraBuffer *mBuffers; - //buffer_handle_t** mBufferHandleMap; // -> frames[i].BufferHandle - //IMG_native_handle_t** mGrallocHandleMap; // -> frames[i].GrallocHandle - uint32_t* mOffsetsMap; // -> frames[i].Offset - int mFD; - android::KeyedVector mFramesWithCameraAdapterMap; - android::KeyedVector mFramesType; - android::sp mErrorNotifier; - - uint32_t mFrameWidth; - uint32_t mFrameHeight; - uint32_t mPreviewWidth; - uint32_t mPreviewHeight; - - uint32_t mXOff; - uint32_t mYOff; - - const char *mPixelFormat; - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - //Used for calculating standby to first shot - struct timeval mStandbyToShot; - bool mMeasureStandby; - //Used for shot to snapshot/shot calculation - struct timeval mStartCapture; - bool mShotToShot; - -#endif - -}; - -} // namespace Camera -} // namespace Ti diff --git a/camera/inc/BaseCameraAdapter.h b/camera/inc/BaseCameraAdapter.h deleted file mode 100644 index b7966b0..0000000 --- a/camera/inc/BaseCameraAdapter.h +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - -#ifndef BASE_CAMERA_ADAPTER_H -#define BASE_CAMERA_ADAPTER_H - -#include "CameraHal.h" - -namespace Ti { -namespace Camera { - -struct LUT { - const char * userDefinition; - int halDefinition; -}; - -struct LUTtypeHAL{ - int size; - const LUT *Table; -}; - -class BaseCameraAdapter : public CameraAdapter -{ - -public: - - BaseCameraAdapter(); - virtual ~BaseCameraAdapter(); - - ///Initialzes the camera adapter creates any resources required - virtual status_t initialize(CameraProperties::Properties*) = 0; - - virtual int setErrorHandler(ErrorNotifier *errorNotifier); - - //Message/Frame notification APIs - virtual void enableMsgType(int32_t msgs, frame_callback callback=NULL, event_callback eventCb=NULL, void* cookie=NULL); - virtual void disableMsgType(int32_t msgs, void* cookie); - virtual void returnFrame(CameraBuffer * frameBuf, CameraFrame::FrameType frameType); - virtual void addFramePointers(CameraBuffer *frameBuf, void *y_uv); - virtual void removeFramePointers(); - - //APIs to configure Camera adapter and get the current parameter set - virtual status_t setParameters(const android::CameraParameters& params) = 0; - virtual void getParameters(android::CameraParameters& params) = 0; - - //API to send a command to the camera - virtual status_t sendCommand(CameraCommands operation, int value1 = 0, int value2 = 0, int value3 = 0, int value4 = 0 ); - - virtual status_t registerImageReleaseCallback(release_image_buffers_callback callback, void *user_data); - - virtual status_t registerEndCaptureCallback(end_image_capture_callback callback, void *user_data); - - //Retrieves the current Adapter state - virtual AdapterState getState(); - //Retrieves the next Adapter state - virtual AdapterState getNextState(); - - virtual status_t setSharedAllocator(camera_request_memory shmem_alloc) { mSharedAllocator = shmem_alloc; return NO_ERROR; }; - - // Rolls the state machine back to INTIALIZED_STATE from the current state - virtual status_t rollbackToInitializedState(); - -protected: - //The first two methods will try to switch the adapter state. - //Every call to setState() should be followed by a corresponding - //call to commitState(). If the state switch fails, then it will - //get reset to the previous state via rollbackState(). - virtual status_t setState(CameraCommands operation); - virtual status_t commitState(); - virtual status_t rollbackState(); - - // Retrieves the current Adapter state - for internal use (not locked) - virtual status_t getState(AdapterState &state); - // Retrieves the next Adapter state - for internal use (not locked) - virtual status_t getNextState(AdapterState &state); - - //-----------Interface that needs to be implemented by deriving classes -------------------- - - //Should be implmented by deriving classes in order to start image capture - virtual status_t takePicture(); - - //Should be implmented by deriving classes in order to start image capture - virtual status_t stopImageCapture(); - - //Should be implmented by deriving classes in order to start temporal bracketing - virtual status_t startBracketing(int range); - - //Should be implemented by deriving classes in order to stop temporal bracketing - virtual status_t stopBracketing(); - - //Should be implemented by deriving classes in oder to initiate autoFocus - virtual status_t autoFocus(); - - //Should be implemented by deriving classes in oder to initiate autoFocus - virtual status_t cancelAutoFocus(); - - //Should be called by deriving classes in order to do some bookkeeping - virtual status_t startVideoCapture(); - - //Should be called by deriving classes in order to do some bookkeeping - virtual status_t stopVideoCapture(); - - //Should be implemented by deriving classes in order to start camera preview - virtual status_t startPreview(); - - //Should be implemented by deriving classes in order to stop camera preview - virtual status_t stopPreview(); - - //Should be implemented by deriving classes in order to start smooth zoom - virtual status_t startSmoothZoom(int targetIdx); - - //Should be implemented by deriving classes in order to stop smooth zoom - virtual status_t stopSmoothZoom(); - - //Should be implemented by deriving classes in order to stop smooth zoom - virtual status_t useBuffers(CameraMode mode, CameraBuffer* bufArr, int num, size_t length, unsigned int queueable); - - //Should be implemented by deriving classes in order queue a released buffer in CameraAdapter - virtual status_t fillThisBuffer(CameraBuffer* frameBuf, CameraFrame::FrameType frameType); - - //API to get the frame size required to be allocated. This size is used to override the size passed - //by camera service when VSTAB/VNF is turned ON for example - virtual status_t getFrameSize(size_t &width, size_t &height); - - //API to get required data frame size - virtual status_t getFrameDataSize(size_t &dataFrameSize, size_t bufferCount); - - //API to get required picture buffers size with the current configuration in CameraParameters - virtual status_t getPictureBufferSize(CameraFrame &frame, size_t bufferCount); - - // Should be implemented by deriving classes in order to start face detection - // ( if supported ) - virtual status_t startFaceDetection(); - - // Should be implemented by deriving classes in order to stop face detection - // ( if supported ) - virtual status_t stopFaceDetection(); - - virtual status_t switchToExecuting(); - - virtual status_t setupTunnel(uint32_t SliceHeight, uint32_t EncoderHandle, uint32_t width, uint32_t height); - - virtual status_t destroyTunnel(); - - virtual status_t cameraPreviewInitialization(); - - // Receive orientation events from CameraHal - virtual void onOrientationEvent(uint32_t orientation, uint32_t tilt); - - // ---------------------Interface ends----------------------------------- - - status_t notifyFocusSubscribers(CameraHalEvent::FocusStatus status); - status_t notifyShutterSubscribers(); - status_t notifyZoomSubscribers(int zoomIdx, bool targetReached); - status_t notifyMetadataSubscribers(android::sp &meta); - - //Send the frame to subscribers - status_t sendFrameToSubscribers(CameraFrame *frame); - - //Resets the refCount for this particular frame - status_t resetFrameRefCount(CameraFrame &frame); - - //A couple of helper functions - void setFrameRefCount(CameraBuffer* frameBuf, CameraFrame::FrameType frameType, int refCount); - int getFrameRefCount(CameraBuffer* frameBuf, CameraFrame::FrameType frameType); - int setInitFrameRefCount(CameraBuffer* buf, unsigned int mask); - static const char* getLUTvalue_translateHAL(int Value, LUTtypeHAL LUT); - -// private member functions -private: - status_t __sendFrameToSubscribers(CameraFrame* frame, - android::KeyedVector *subscribers, - CameraFrame::FrameType frameType); - status_t rollbackToPreviousState(); - -// protected data types and variables -protected: - enum FrameState { - STOPPED = 0, - RUNNING - }; - - enum FrameCommands { - START_PREVIEW = 0, - START_RECORDING, - RETURN_FRAME, - STOP_PREVIEW, - STOP_RECORDING, - DO_AUTOFOCUS, - TAKE_PICTURE, - FRAME_EXIT - }; - - enum AdapterCommands { - ACK = 0, - ERROR - }; - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - struct timeval mStartFocus; - struct timeval mStartCapture; - -#endif - - mutable android::Mutex mReturnFrameLock; - - //Lock protecting the Adapter state - mutable android::Mutex mLock; - AdapterState mAdapterState; - AdapterState mNextState; - - //Different frame subscribers get stored using these - android::KeyedVector mFrameSubscribers; - android::KeyedVector mSnapshotSubscribers; - android::KeyedVector mFrameDataSubscribers; - android::KeyedVector mVideoSubscribers; - android::KeyedVector mVideoInSubscribers; - android::KeyedVector mImageSubscribers; - android::KeyedVector mRawSubscribers; - android::KeyedVector mFocusSubscribers; - android::KeyedVector mZoomSubscribers; - android::KeyedVector mShutterSubscribers; - android::KeyedVector mMetadataSubscribers; - - //Preview buffer management data - CameraBuffer *mPreviewBuffers; - int mPreviewBufferCount; - size_t mPreviewBuffersLength; - android::KeyedVector mPreviewBuffersAvailable; - mutable android::Mutex mPreviewBufferLock; - - //Snapshot buffer management data - android::KeyedVector mSnapshotBuffersAvailable; - mutable android::Mutex mSnapshotBufferLock; - - //Video buffer management data - CameraBuffer *mVideoBuffers; - android::KeyedVector mVideoBuffersAvailable; - int mVideoBuffersCount; - size_t mVideoBuffersLength; - mutable android::Mutex mVideoBufferLock; - - //Image buffer management data - CameraBuffer *mCaptureBuffers; - android::KeyedVector mCaptureBuffersAvailable; - int mCaptureBuffersCount; - size_t mCaptureBuffersLength; - mutable android::Mutex mCaptureBufferLock; - - //Metadata buffermanagement - CameraBuffer *mPreviewDataBuffers; - android::KeyedVector mPreviewDataBuffersAvailable; - int mPreviewDataBuffersCount; - size_t mPreviewDataBuffersLength; - mutable android::Mutex mPreviewDataBufferLock; - - //Video input buffer management data (used for reproc pipe) - CameraBuffer *mVideoInBuffers; - android::KeyedVector mVideoInBuffersAvailable; - mutable android::Mutex mVideoInBufferLock; - - Utils::MessageQueue mFrameQ; - Utils::MessageQueue mAdapterQ; - mutable android::Mutex mSubscriberLock; - ErrorNotifier *mErrorNotifier; - release_image_buffers_callback mReleaseImageBuffersCallback; - end_image_capture_callback mEndImageCaptureCallback; - void *mReleaseData; - void *mEndCaptureData; - bool mRecording; - - camera_request_memory mSharedAllocator; - - uint32_t mFramesWithDucati; - uint32_t mFramesWithDisplay; - uint32_t mFramesWithEncoder; - -#ifdef CAMERAHAL_DEBUG - android::KeyedVector mBuffersWithDucati; -#endif - - android::KeyedVector mFrameQueue; -}; - -} // namespace Camera -} // namespace Ti - -#endif //BASE_CAMERA_ADAPTER_H - - diff --git a/camera/inc/BufferSourceAdapter.h b/camera/inc/BufferSourceAdapter.h deleted file mode 100644 index 436d2e5..0000000 --- a/camera/inc/BufferSourceAdapter.h +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef BUFFER_SOURCE_ADAPTER_H -#define BUFFER_SOURCE_ADAPTER_H - -#ifdef OMAP_ENHANCEMENT_CPCAM - -#include "CameraHal.h" -#include -#include - -namespace Ti { -namespace Camera { - -/** - * Handles enqueueing/dequeing buffers to tap-in/tap-out points - * TODO(XXX): this class implements DisplayAdapter for now - * but this will most likely change once tap-in/tap-out points - * are better defined - */ - -class BufferSourceAdapter : public DisplayAdapter -{ -// private types -private: - // helper class to return frame in different thread context - class ReturnFrame : public android::Thread { - public: - ReturnFrame(BufferSourceAdapter* __this) : mBufferSourceAdapter(__this) { - mWaitForSignal.Create(0); - mDestroying = false; - } - - ~ReturnFrame() { - mDestroying = true; - mWaitForSignal.Release(); - } - - void signal() { - mWaitForSignal.Signal(); - } - - virtual bool threadLoop() { - mWaitForSignal.Wait(); - if (!mDestroying) mBufferSourceAdapter->handleFrameReturn(); - return true; - } - - private: - BufferSourceAdapter* mBufferSourceAdapter; - Utils::Semaphore mWaitForSignal; - bool mDestroying; - }; - - // helper class to queue frame in different thread context - class QueueFrame : public android::Thread { - public: - QueueFrame(BufferSourceAdapter* __this) : mBufferSourceAdapter(__this) { - mDestroying = false; - } - - ~QueueFrame() { - mDestroying = true; - - android::AutoMutex lock(mFramesMutex); - while (!mFrames.empty()) { - CameraFrame *frame = mFrames.itemAt(0); - mFrames.removeAt(0); - frame->mMetaData.clear(); - delete frame; - } - mFramesCondition.signal(); - } - - void addFrame(CameraFrame *frame) { - android::AutoMutex lock(mFramesMutex); - mFrames.add(new CameraFrame(*frame)); - mFramesCondition.signal(); - } - - virtual bool threadLoop() { - CameraFrame *frame = NULL; - { - android::AutoMutex lock(mFramesMutex); - while (mFrames.empty() && !mDestroying) mFramesCondition.wait(mFramesMutex); - if (!mDestroying) { - frame = mFrames.itemAt(0); - mFrames.removeAt(0); - } - } - - if (frame) { - mBufferSourceAdapter->handleFrameCallback(frame); - frame->mMetaData.clear(); - delete frame; - } - - return true; - } - - private: - BufferSourceAdapter* mBufferSourceAdapter; - android::Vector mFrames; - android::Condition mFramesCondition; - android::Mutex mFramesMutex; - bool mDestroying; - }; - - enum { - BUFFER_SOURCE_TAP_IN, - BUFFER_SOURCE_TAP_OUT - }; - -// public member functions -public: - BufferSourceAdapter(); - virtual ~BufferSourceAdapter(); - - virtual status_t initialize(); - virtual int setPreviewWindow(struct preview_stream_ops *source); - virtual int setFrameProvider(FrameNotifier *frameProvider); - virtual int setErrorHandler(ErrorNotifier *errorNotifier); - virtual int enableDisplay(int width, int height, struct timeval *refTime = NULL); - virtual int disableDisplay(bool cancel_buffer = true); - virtual status_t pauseDisplay(bool pause); -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - // Not implemented in this class - virtual status_t setSnapshotTimeRef(struct timeval *refTime = NULL) { return NO_ERROR; } -#endif - virtual bool supportsExternalBuffering(); - virtual CameraBuffer * allocateBufferList(int width, int dummyHeight, const char* format, int &bytes, int numBufs); - virtual CameraBuffer *getBufferList(int *numBufs); - virtual uint32_t * getOffsets() ; - virtual int getFd() ; - virtual int freeBufferList(CameraBuffer * buflist); - virtual int maxQueueableBuffers(unsigned int& queueable); - virtual int minUndequeueableBuffers(int& unqueueable); - - static void frameCallback(CameraFrame* caFrame); - void addFrame(CameraFrame* caFrame); - void handleFrameCallback(CameraFrame* caFrame); - bool handleFrameReturn(); - -private: - void destroy(); - status_t returnBuffersToWindow(); - -private: - preview_stream_ops_t* mBufferSource; - FrameProvider *mFrameProvider; // Pointer to the frame provider interface - - mutable android::Mutex mLock; - int mBufferCount; - CameraBuffer *mBuffers; - - android::KeyedVector mFramesWithCameraAdapterMap; - android::sp mErrorNotifier; - android::sp mReturnFrame; - android::sp mQueueFrame; - - uint32_t mFrameWidth; - uint32_t mFrameHeight; - uint32_t mPreviewWidth; - uint32_t mPreviewHeight; - - int mBufferSourceDirection; - - const char *mPixelFormat; -}; - -} // namespace Camera -} // namespace Ti - -#endif - -#endif diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h deleted file mode 100644 index 4fded38..0000000 --- a/camera/inc/CameraHal.h +++ /dev/null @@ -1,1484 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - -#ifndef ANDROID_HARDWARE_CAMERA_HARDWARE_H -#define ANDROID_HARDWARE_CAMERA_HARDWARE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#ifdef OMAP_ENHANCEMENT_CPCAM -#include -#include -#endif -#include -#include - -/* For IMG_native_handle_t */ -#include -#include - -#include - -#include "Common.h" -#include "MessageQueue.h" -#include "Semaphore.h" -#include "CameraProperties.h" -#include "SensorListener.h" - -//temporarily define format here -#define HAL_PIXEL_FORMAT_TI_NV12 0x100 -#define HAL_PIXEL_FORMAT_TI_Y8 0x103 -#define HAL_PIXEL_FORMAT_TI_Y16 0x104 - -#define MIN_WIDTH 640 -#define MIN_HEIGHT 480 -#ifdef OMAP_TUNA -#define PICTURE_WIDTH 2592 /* 5mp - 2560. 8mp - 3280 */ /* Make sure it is a multiple of 16. */ -#define PICTURE_HEIGHT 1944 /* 5mp - 2048. 8mp - 2464 */ /* Make sure it is a multiple of 16. */ -#else -#define PICTURE_WIDTH 3264 /* 5mp - 2560. 8mp - 3280 */ /* Make sure it is a multiple of 16. */ -#define PICTURE_HEIGHT 2448 /* 5mp - 2048. 8mp - 2464 */ /* Make sure it is a multiple of 16. */ -#endif -#define PREVIEW_WIDTH 176 -#define PREVIEW_HEIGHT 144 -#define PIXEL_FORMAT V4L2_PIX_FMT_UYVY - -#define VIDEO_FRAME_COUNT_MAX 8 //NUM_OVERLAY_BUFFERS_REQUESTED -#define MAX_CAMERA_BUFFERS 8 //NUM_OVERLAY_BUFFERS_REQUESTED -#define MAX_ZOOM 3 -#define THUMB_WIDTH 80 -#define THUMB_HEIGHT 60 -#define PIX_YUV422I 0 -#define PIX_YUV420P 1 - -#define SATURATION_OFFSET 100 -#define SHARPNESS_OFFSET 100 -#define CONTRAST_OFFSET 100 - -#define FRAME_RATE_HIGH_HD 60 - -#define CAMHAL_GRALLOC_USAGE GRALLOC_USAGE_HW_TEXTURE | \ - GRALLOC_USAGE_HW_RENDER | \ - GRALLOC_USAGE_SW_READ_RARELY | \ - GRALLOC_USAGE_SW_WRITE_NEVER - -//Enables Absolute PPM measurements in logcat -#ifdef CAMERAHAL_SUPERVERBOSE -#define PPM_INSTRUMENTATION_ABS 1 -#endif - -#define LOCK_BUFFER_TRIES 5 -#define HAL_PIXEL_FORMAT_NV12 0x100 - -#define NONNEG_ASSIGN(x,y) \ - if(x > -1) \ - y = x - -#define CAMHAL_SIZE_OF_ARRAY(x) static_cast(sizeof(x)/sizeof(x[0])) - -namespace Ti { -namespace Camera { - -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING -extern const char * const kRawImagesOutputDirPath; -extern const char * const kYuvImagesOutputDirPath; -#endif -#define V4L_CAMERA_NAME_USB "USBCAMERA" -#define OMX_CAMERA_NAME_OV "OV5640" -#define OMX_CAMERA_NAME_SONY "IMX060" - - -///Forward declarations -class CameraHal; -class CameraFrame; -class CameraHalEvent; -class DisplayFrame; - -class FpsRange { -public: - static int compare(const FpsRange * left, const FpsRange * right); - - FpsRange(int min, int max); - FpsRange(); - - bool operator==(const FpsRange & fpsRange) const; - - bool isNull() const; - bool isFixed() const; - - int min() const; - int max() const; - -private: - int mMin; - int mMax; -}; - - -inline int FpsRange::compare(const FpsRange * const left, const FpsRange * const right) { - if ( left->max() < right->max() ) { - return -1; - } - - if ( left->max() > right->max() ) { - return 1; - } - - if ( left->min() < right->min() ) { - return -1; - } - - if ( left->min() > right->min() ) { - return 1; - } - - return 0; -} - -inline FpsRange::FpsRange(const int min, const int max) : mMin(min), mMax(max) {} - -inline FpsRange::FpsRange() : mMin(-1), mMax(-1) {} - -inline bool FpsRange::operator==(const FpsRange & fpsRange) const { - return mMin == fpsRange.mMin && mMax == fpsRange.mMax; -} - -inline bool FpsRange::isNull() const { - return mMin == -1 || mMax == -1; -} - -inline bool FpsRange::isFixed() const { - return mMin == mMax; -} - -inline int FpsRange::min() const { return mMin; } - -inline int FpsRange::max() const { return mMax; } - -class CameraArea : public android::RefBase -{ -public: - - CameraArea(ssize_t top, - ssize_t left, - ssize_t bottom, - ssize_t right, - size_t weight) : mTop(top), - mLeft(left), - mBottom(bottom), - mRight(right), - mWeight(weight) {} - - status_t transfrom(size_t width, - size_t height, - size_t &top, - size_t &left, - size_t &areaWidth, - size_t &areaHeight); - - bool isValid() - { - return ( ( 0 != mTop ) || ( 0 != mLeft ) || ( 0 != mBottom ) || ( 0 != mRight) ); - } - - bool isZeroArea() - { - return ( (0 == mTop ) && ( 0 == mLeft ) && ( 0 == mBottom ) - && ( 0 == mRight ) && ( 0 == mWeight )); - } - - size_t getWeight() - { - return mWeight; - } - - bool compare(const android::sp &area); - - static status_t parseAreas(const char *area, - size_t areaLength, - android::Vector< android::sp > &areas); - - static status_t checkArea(ssize_t top, - ssize_t left, - ssize_t bottom, - ssize_t right, - ssize_t weight); - - static bool areAreasDifferent(android::Vector< android::sp > &, android::Vector< android::sp > &); - -protected: - static const ssize_t TOP = -1000; - static const ssize_t LEFT = -1000; - static const ssize_t BOTTOM = 1000; - static const ssize_t RIGHT = 1000; - static const ssize_t WEIGHT_MIN = 1; - static const ssize_t WEIGHT_MAX = 1000; - - ssize_t mTop; - ssize_t mLeft; - ssize_t mBottom; - ssize_t mRight; - size_t mWeight; -}; - -class CameraMetadataResult : public android::RefBase -{ -public: - -#ifdef OMAP_ENHANCEMENT_CPCAM - CameraMetadataResult(camera_memory_t * extMeta) : mExtendedMetadata(extMeta) { - mMetadata.faces = NULL; - mMetadata.number_of_faces = 0; -#ifdef OMAP_ENHANCEMENT - mMetadata.analog_gain = 0; - mMetadata.exposure_time = 0; -#endif - }; -#endif - - CameraMetadataResult() { - mMetadata.faces = NULL; - mMetadata.number_of_faces = 0; -#ifdef OMAP_ENHANCEMENT_CPCAM - mMetadata.analog_gain = 0; - mMetadata.exposure_time = 0; -#endif - -#ifdef OMAP_ENHANCEMENT_CPCAM - mExtendedMetadata = NULL; -#endif - } - - virtual ~CameraMetadataResult() { - if ( NULL != mMetadata.faces ) { - free(mMetadata.faces); - } -#ifdef OMAP_ENHANCEMENT_CPCAM - if ( NULL != mExtendedMetadata ) { - mExtendedMetadata->release(mExtendedMetadata); - } -#endif - } - - camera_frame_metadata_t *getMetadataResult() { return &mMetadata; }; - -#ifdef OMAP_ENHANCEMENT_CPCAM - camera_memory_t *getExtendedMetadata() { return mExtendedMetadata; }; -#endif - - static const ssize_t TOP = -1000; - static const ssize_t LEFT = -1000; - static const ssize_t BOTTOM = 1000; - static const ssize_t RIGHT = 1000; - static const ssize_t INVALID_DATA = -2000; - -private: - - camera_frame_metadata_t mMetadata; -#ifdef OMAP_ENHANCEMENT_CPCAM - camera_memory_t *mExtendedMetadata; -#endif -}; - -typedef enum { - CAMERA_BUFFER_NONE = 0, - CAMERA_BUFFER_GRALLOC, - CAMERA_BUFFER_ANW, - CAMERA_BUFFER_MEMORY, - CAMERA_BUFFER_ION -} CameraBufferType; - -typedef struct _CameraBuffer { - CameraBufferType type; - /* opaque is the generic drop-in replacement for the pointers - * that were used previously */ - void *opaque; - - /* opaque has different meanings depending on the buffer type: - * GRALLOC - gralloc_handle_t - * ANW - a pointer to the buffer_handle_t (which corresponds to - * the ANativeWindowBuffer *) - * MEMORY - address of allocated memory - * ION - address of mapped ion allocation - * - * FIXME opaque should be split into several fields: - * - handle/pointer we got from the allocator - * - handle/value we pass to OMX - * - pointer to mapped memory (if the buffer is mapped) - */ - - /* mapped holds ptr to mapped memory in userspace */ - void *mapped; - - /* These are specific to ION buffers */ - struct ion_handle * ion_handle; - int ion_fd; - int fd; - size_t size; - int index; - - /* These describe the camera buffer */ - int width; - int stride; - int height; - const char *format; -} CameraBuffer; - -void * camera_buffer_get_omx_ptr (CameraBuffer *buffer); - -class CameraFrame -{ - public: - - enum FrameType - { - PREVIEW_FRAME_SYNC = 0x1, ///SYNC implies that the frame needs to be explicitly returned after consuming in order to be filled by camera again - PREVIEW_FRAME = 0x2 , ///Preview frame includes viewfinder and snapshot frames - IMAGE_FRAME_SYNC = 0x4, ///Image Frame is the image capture output frame - IMAGE_FRAME = 0x8, - VIDEO_FRAME_SYNC = 0x10, ///Timestamp will be updated for these frames - VIDEO_FRAME = 0x20, - FRAME_DATA_SYNC = 0x40, ///Any extra data assosicated with the frame. Always synced with the frame - FRAME_DATA= 0x80, - RAW_FRAME = 0x100, - SNAPSHOT_FRAME = 0x200, - REPROCESS_INPUT_FRAME = 0x400, - ALL_FRAMES = 0xFFFF ///Maximum of 16 frame types supported - }; - - enum FrameQuirks - { - ENCODE_RAW_YUV422I_TO_JPEG = 0x1 << 0, - HAS_EXIF_DATA = 0x1 << 1, - FORMAT_YUV422I_YUYV = 0x1 << 2, - FORMAT_YUV422I_UYVY = 0x1 << 3, - }; - - //default contrustor - CameraFrame(): - mCookie(NULL), - mCookie2(NULL), - mBuffer(NULL), - mFrameType(0), - mTimestamp(0), - mWidth(0), - mHeight(0), - mOffset(0), - mAlignment(0), - mFd(0), - mLength(0), - mFrameMask(0), - mQuirks(0) - { - mYuv[0] = 0; //NULL; - mYuv[1] = 0; //NULL; - -#ifdef OMAP_ENHANCEMENT_CPCAM - mMetaData = 0; -#endif - } - - void *mCookie; - void *mCookie2; - CameraBuffer *mBuffer; - int mFrameType; - nsecs_t mTimestamp; - unsigned int mWidth, mHeight; - uint32_t mOffset; - unsigned int mAlignment; - int mFd; - size_t mLength; - unsigned mFrameMask; - unsigned int mQuirks; - unsigned int mYuv[2]; -#ifdef OMAP_ENHANCEMENT_CPCAM - android::sp mMetaData; -#endif - ///@todo add other member vars like stride etc -}; - -enum CameraHalError -{ - CAMERA_ERROR_FATAL = 0x1, //Fatal errors can only be recovered by restarting media server - CAMERA_ERROR_HARD = 0x2, // Hard errors are hardware hangs that may be recoverable by resetting the hardware internally within the adapter - CAMERA_ERROR_SOFT = 0x4, // Soft errors are non fatal errors that can be recovered from without needing to stop use-case -}; - -///Common Camera Hal Event class which is visible to CameraAdapter,DisplayAdapter and AppCallbackNotifier -///@todo Rename this class to CameraEvent -class CameraHalEvent -{ -public: - //Enums - enum CameraHalEventType { - NO_EVENTS = 0x0, - EVENT_FOCUS_LOCKED = 0x1, - EVENT_FOCUS_ERROR = 0x2, - EVENT_ZOOM_INDEX_REACHED = 0x4, - EVENT_SHUTTER = 0x8, - EVENT_METADATA = 0x10, - ///@remarks Future enum related to display, like frame displayed event, could be added here - ALL_EVENTS = 0xFFFF ///Maximum of 16 event types supported - }; - - enum FocusStatus { - FOCUS_STATUS_SUCCESS = 0x1, - FOCUS_STATUS_FAIL = 0x2, - FOCUS_STATUS_PENDING = 0x4, - FOCUS_STATUS_DONE = 0x8, - }; - - ///Class declarations - ///@remarks Add a new class for a new event type added above - - //Shutter event specific data - typedef struct ShutterEventData_t { - bool shutterClosed; - }ShutterEventData; - - ///Focus event specific data - typedef struct FocusEventData_t { - FocusStatus focusStatus; - int currentFocusValue; - } FocusEventData; - - ///Zoom specific event data - typedef struct ZoomEventData_t { - int currentZoomIndex; - bool targetZoomIndexReached; - } ZoomEventData; - - typedef struct FaceData_t { - ssize_t top; - ssize_t left; - ssize_t bottom; - ssize_t right; - size_t score; - } FaceData; - - typedef android::sp MetaEventData; - - class CameraHalEventData : public android::RefBase{ - - public: - - CameraHalEvent::FocusEventData focusEvent; - CameraHalEvent::ZoomEventData zoomEvent; - CameraHalEvent::ShutterEventData shutterEvent; - CameraHalEvent::MetaEventData metadataEvent; - }; - - //default contrustor - CameraHalEvent(): - mCookie(NULL), - mEventType(NO_EVENTS) {} - - //copy constructor - CameraHalEvent(const CameraHalEvent &event) : - mCookie(event.mCookie), - mEventType(event.mEventType), - mEventData(event.mEventData) {}; - - void* mCookie; - CameraHalEventType mEventType; - android::sp mEventData; - -}; - -/// Have a generic callback class based on template - to adapt CameraFrame and Event -typedef void (*frame_callback) (CameraFrame *cameraFrame); -typedef void (*event_callback) (CameraHalEvent *event); - -//signals CameraHAL to relase image buffers -typedef void (*release_image_buffers_callback) (void *userData); -typedef void (*end_image_capture_callback) (void *userData); - -/** - * Interface class implemented by classes that have some events to communicate to dependendent classes - * Dependent classes use this interface for registering for events - */ -class MessageNotifier -{ -public: - static const uint32_t EVENT_BIT_FIELD_POSITION; - static const uint32_t FRAME_BIT_FIELD_POSITION; - - ///@remarks Msg type comes from CameraFrame and CameraHalEvent classes - /// MSB 16 bits is for events and LSB 16 bits is for frame notifications - /// FrameProvider and EventProvider classes act as helpers to event/frame - /// consumers to call this api - virtual void enableMsgType(int32_t msgs, frame_callback frameCb=NULL, event_callback eventCb=NULL, void* cookie=NULL) = 0; - virtual void disableMsgType(int32_t msgs, void* cookie) = 0; - - virtual ~MessageNotifier() {}; -}; - -class ErrorNotifier : public virtual android::RefBase -{ -public: - virtual void errorNotify(int error) = 0; - - virtual ~ErrorNotifier() {}; -}; - - -/** - * Interace class abstraction for Camera Adapter to act as a frame provider - * This interface is fully implemented by Camera Adapter - */ -class FrameNotifier : public MessageNotifier -{ -public: - virtual void returnFrame(CameraBuffer* frameBuf, CameraFrame::FrameType frameType) = 0; - virtual void addFramePointers(CameraBuffer *frameBuf, void *buf) = 0; - virtual void removeFramePointers() = 0; - - virtual ~FrameNotifier() {}; -}; - -/** * Wrapper class around Frame Notifier, which is used by display and notification classes for interacting with Camera Adapter - */ -class FrameProvider -{ - FrameNotifier* mFrameNotifier; - void* mCookie; - frame_callback mFrameCallback; - -public: - FrameProvider(FrameNotifier *fn, void* cookie, frame_callback frameCallback) - :mFrameNotifier(fn), mCookie(cookie),mFrameCallback(frameCallback) { } - - int enableFrameNotification(int32_t frameTypes); - int disableFrameNotification(int32_t frameTypes); - int returnFrame(CameraBuffer *frameBuf, CameraFrame::FrameType frameType); - void addFramePointers(CameraBuffer *frameBuf, void *buf); - void removeFramePointers(); -}; - -/** Wrapper class around MessageNotifier, which is used by display and notification classes for interacting with - * Camera Adapter - */ -class EventProvider -{ -public: - MessageNotifier* mEventNotifier; - void* mCookie; - event_callback mEventCallback; - -public: - EventProvider(MessageNotifier *mn, void* cookie, event_callback eventCallback) - :mEventNotifier(mn), mCookie(cookie), mEventCallback(eventCallback) {} - - int enableEventNotification(int32_t eventTypes); - int disableEventNotification(int32_t eventTypes); -}; - -/* - * Interface for providing buffers - */ -class BufferProvider -{ -public: - virtual CameraBuffer * allocateBufferList(int width, int height, const char* format, int &bytes, int numBufs) = 0; - - // gets a buffer list from BufferProvider when buffers are sent from external source and already pre-allocated - // only call this function for an input source into CameraHal. If buffers are not from a pre-allocated source - // this function will return NULL and numBufs of -1 - virtual CameraBuffer *getBufferList(int *numBufs) = 0; - - //additional methods used for memory mapping - virtual uint32_t * getOffsets() = 0; - virtual int getFd() = 0; - - virtual int freeBufferList(CameraBuffer * buf) = 0; - - virtual ~BufferProvider() {} -}; - -/** - * Class for handling data and notify callbacks to application - */ -class AppCallbackNotifier: public ErrorNotifier , public virtual android::RefBase -{ - -public: - - ///Constants - static const int NOTIFIER_TIMEOUT; - static const int32_t MAX_BUFFERS = 8; - - enum NotifierCommands - { - NOTIFIER_CMD_PROCESS_EVENT, - NOTIFIER_CMD_PROCESS_FRAME, - NOTIFIER_CMD_PROCESS_ERROR - }; - - enum NotifierState - { - NOTIFIER_STOPPED, - NOTIFIER_STARTED, - NOTIFIER_EXITED - }; - -public: - - ~AppCallbackNotifier(); - - ///Initialzes the callback notifier, creates any resources required - status_t initialize(); - - ///Starts the callbacks to application - status_t start(); - - ///Stops the callbacks from going to application - status_t stop(); - - void setEventProvider(int32_t eventMask, MessageNotifier * eventProvider); - void setFrameProvider(FrameNotifier *frameProvider); - - //All sub-components of Camera HAL call this whenever any error happens - virtual void errorNotify(int error); - - status_t startPreviewCallbacks(android::CameraParameters ¶ms, CameraBuffer *buffers, uint32_t *offsets, int fd, size_t length, size_t count); - status_t stopPreviewCallbacks(); - - status_t enableMsgType(int32_t msgType); - status_t disableMsgType(int32_t msgType); - - //API for enabling/disabling measurement data - void setMeasurements(bool enable); - - //thread loops - bool notificationThread(); - - ///Notification callback functions - static void frameCallbackRelay(CameraFrame* caFrame); - static void eventCallbackRelay(CameraHalEvent* chEvt); - void frameCallback(CameraFrame* caFrame); - void eventCallback(CameraHalEvent* chEvt); - void flushAndReturnFrames(); - - void setCallbacks(CameraHal *cameraHal, - camera_notify_callback notify_cb, - camera_data_callback data_cb, - camera_data_timestamp_callback data_cb_timestamp, - camera_request_memory get_memory, - void *user); - - //Set Burst mode - void setBurst(bool burst); - - //Notifications from CameraHal for video recording case - status_t startRecording(); - status_t stopRecording(); - status_t initSharedVideoBuffers(CameraBuffer *buffers, uint32_t *offsets, int fd, size_t length, size_t count, CameraBuffer *vidBufs); - status_t releaseRecordingFrame(const void *opaque); - - status_t useMetaDataBufferMode(bool enable); - - void EncoderDoneCb(void*, void*, CameraFrame::FrameType type, void* cookie1, void* cookie2, void *cookie3); - - void useVideoBuffers(bool useVideoBuffers); - - bool getUesVideoBuffers(); - void setVideoRes(int width, int height); - - void flushEventQueue(); - - //Internal class definitions - class NotificationThread : public android::Thread { - AppCallbackNotifier* mAppCallbackNotifier; - Utils::MessageQueue mNotificationThreadQ; - public: - enum NotificationThreadCommands - { - NOTIFIER_START, - NOTIFIER_STOP, - NOTIFIER_EXIT, - }; - public: - NotificationThread(AppCallbackNotifier* nh) - : Thread(false), mAppCallbackNotifier(nh) { } - virtual bool threadLoop() { - return mAppCallbackNotifier->notificationThread(); - } - - Utils::MessageQueue &msgQ() { return mNotificationThreadQ;} - }; - - //Friend declarations - friend class NotificationThread; - -private: - void notifyEvent(); - void notifyFrame(); - bool processMessage(); - void releaseSharedVideoBuffers(); - status_t dummyRaw(); - void copyAndSendPictureFrame(CameraFrame* frame, int32_t msgType); - void copyAndSendPreviewFrame(CameraFrame* frame, int32_t msgType); - size_t calculateBufferSize(size_t width, size_t height, const char *pixelFormat); - const char* getContstantForPixelFormat(const char *pixelFormat); - -private: - mutable android::Mutex mLock; - mutable android::Mutex mBurstLock; - CameraHal* mCameraHal; - camera_notify_callback mNotifyCb; - camera_data_callback mDataCb; - camera_data_timestamp_callback mDataCbTimestamp; - camera_request_memory mRequestMemory; - void *mCallbackCookie; - - //Keeps Video MemoryHeaps and Buffers within - //these objects - android::KeyedVector mVideoHeaps; - android::KeyedVector mVideoBuffers; - android::KeyedVector mVideoMap; - - //Keeps list of Gralloc handles and associated Video Metadata Buffers - android::KeyedVector mVideoMetadataBufferMemoryMap; - android::KeyedVector mVideoMetadataBufferReverseMap; - - bool mBufferReleased; - - android::sp< NotificationThread> mNotificationThread; - EventProvider *mEventProvider; - FrameProvider *mFrameProvider; - Utils::MessageQueue mEventQ; - Utils::MessageQueue mFrameQ; - NotifierState mNotifierState; - - bool mPreviewing; - camera_memory_t* mPreviewMemory; - CameraBuffer mPreviewBuffers[MAX_BUFFERS]; - int mPreviewBufCount; - int mPreviewWidth; - int mPreviewHeight; - int mPreviewStride; - const char *mPreviewPixelFormat; - android::KeyedVector > mSharedPreviewHeaps; - android::KeyedVector > mSharedPreviewBuffers; - - //Burst mode active - bool mBurst; - mutable android::Mutex mRecordingLock; - bool mRecording; - bool mMeasurementEnabled; - - bool mUseMetaDataBufferMode; - bool mRawAvailable; - - bool mUseVideoBuffers; - - int mVideoWidth; - int mVideoHeight; - -}; - - -/** - * Class used for allocating memory for JPEG bit stream buffers, output buffers of camera in no overlay case - */ -class MemoryManager : public BufferProvider, public virtual android::RefBase -{ -public: - MemoryManager(); - ~MemoryManager(); - - status_t initialize(); - - int setErrorHandler(ErrorNotifier *errorNotifier); - virtual CameraBuffer * allocateBufferList(int width, int height, const char* format, int &bytes, int numBufs); - virtual CameraBuffer *getBufferList(int *numBufs); - virtual uint32_t * getOffsets(); - virtual int getFd() ; - virtual int freeBufferList(CameraBuffer * buflist); - -private: - android::sp mErrorNotifier; - int mIonFd; -}; - - - - -/** - * CameraAdapter interface class - * Concrete classes derive from this class and provide implementations based on the specific camera h/w interface - */ - -class CameraAdapter: public FrameNotifier, public virtual android::RefBase -{ -protected: - enum AdapterActiveStates { - INTIALIZED_ACTIVE = 1 << 0, - LOADED_PREVIEW_ACTIVE = 1 << 1, - PREVIEW_ACTIVE = 1 << 2, - LOADED_CAPTURE_ACTIVE = 1 << 3, - CAPTURE_ACTIVE = 1 << 4, - BRACKETING_ACTIVE = 1 << 5, - AF_ACTIVE = 1 << 6, - ZOOM_ACTIVE = 1 << 7, - VIDEO_ACTIVE = 1 << 8, - LOADED_REPROCESS_ACTIVE = 1 << 9, - REPROCESS_ACTIVE = 1 << 10, - }; -public: - typedef struct - { - CameraBuffer *mBuffers; - uint32_t *mOffsets; - int mFd; - size_t mLength; - size_t mCount; - size_t mMaxQueueable; - } BuffersDescriptor; - - enum CameraCommands - { - CAMERA_START_PREVIEW = 0, - CAMERA_STOP_PREVIEW = 1, - CAMERA_START_VIDEO = 2, - CAMERA_STOP_VIDEO = 3, - CAMERA_START_IMAGE_CAPTURE = 4, - CAMERA_STOP_IMAGE_CAPTURE = 5, - CAMERA_PERFORM_AUTOFOCUS = 6, - CAMERA_CANCEL_AUTOFOCUS = 7, - CAMERA_PREVIEW_FLUSH_BUFFERS = 8, - CAMERA_START_SMOOTH_ZOOM = 9, - CAMERA_STOP_SMOOTH_ZOOM = 10, - CAMERA_USE_BUFFERS_PREVIEW = 11, - CAMERA_SET_TIMEOUT = 12, - CAMERA_CANCEL_TIMEOUT = 13, - CAMERA_START_BRACKET_CAPTURE = 14, - CAMERA_STOP_BRACKET_CAPTURE = 15, - CAMERA_QUERY_RESOLUTION_PREVIEW = 16, - CAMERA_QUERY_BUFFER_SIZE_IMAGE_CAPTURE = 17, - CAMERA_QUERY_BUFFER_SIZE_PREVIEW_DATA = 18, - CAMERA_USE_BUFFERS_IMAGE_CAPTURE = 19, - CAMERA_USE_BUFFERS_PREVIEW_DATA = 20, - CAMERA_TIMEOUT_EXPIRED = 21, - CAMERA_START_FD = 22, - CAMERA_STOP_FD = 23, - CAMERA_SWITCH_TO_EXECUTING = 24, - CAMERA_USE_BUFFERS_VIDEO_CAPTURE = 25, -#ifdef OMAP_ENHANCEMENT_CPCAM - CAMERA_USE_BUFFERS_REPROCESS = 26, - CAMERA_START_REPROCESS = 27, -#endif -#ifdef OMAP_ENHANCEMENT_VTC - CAMERA_SETUP_TUNNEL = 28, - CAMERA_DESTROY_TUNNEL = 29, -#endif - CAMERA_PREVIEW_INITIALIZATION = 30, - }; - - enum CameraMode - { - CAMERA_PREVIEW, - CAMERA_IMAGE_CAPTURE, - CAMERA_VIDEO, - CAMERA_MEASUREMENT, - CAMERA_REPROCESS, - }; - - enum AdapterState { - INTIALIZED_STATE = INTIALIZED_ACTIVE, - LOADED_PREVIEW_STATE = LOADED_PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - PREVIEW_STATE = PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - LOADED_CAPTURE_STATE = LOADED_CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - CAPTURE_STATE = CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - BRACKETING_STATE = BRACKETING_ACTIVE | CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE , - AF_STATE = AF_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - ZOOM_STATE = ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - VIDEO_STATE = VIDEO_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - VIDEO_AF_STATE = VIDEO_ACTIVE | AF_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - VIDEO_ZOOM_STATE = VIDEO_ACTIVE | ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - VIDEO_LOADED_CAPTURE_STATE = VIDEO_ACTIVE | LOADED_CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - VIDEO_CAPTURE_STATE = VIDEO_ACTIVE | CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - AF_ZOOM_STATE = AF_ACTIVE | ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - BRACKETING_ZOOM_STATE = BRACKETING_ACTIVE | ZOOM_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - LOADED_REPROCESS_STATE = LOADED_REPROCESS_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - LOADED_REPROCESS_CAPTURE_STATE = LOADED_REPROCESS_ACTIVE | LOADED_CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - REPROCESS_STATE = REPROCESS_ACTIVE | CAPTURE_ACTIVE | PREVIEW_ACTIVE | INTIALIZED_ACTIVE, - }; - - -public: - - ///Initialzes the camera adapter creates any resources required - virtual int initialize(CameraProperties::Properties*) = 0; - - virtual int setErrorHandler(ErrorNotifier *errorNotifier) = 0; - - //Message/Frame notification APIs - virtual void enableMsgType(int32_t msgs, - frame_callback callback = NULL, - event_callback eventCb = NULL, - void *cookie = NULL) = 0; - virtual void disableMsgType(int32_t msgs, void* cookie) = 0; - virtual void returnFrame(CameraBuffer* frameBuf, CameraFrame::FrameType frameType) = 0; - virtual void addFramePointers(CameraBuffer *frameBuf, void *buf) = 0; - virtual void removeFramePointers() = 0; - - //APIs to configure Camera adapter and get the current parameter set - virtual int setParameters(const android::CameraParameters& params) = 0; - virtual void getParameters(android::CameraParameters& params) = 0; - - //Registers callback for returning image buffers back to CameraHAL - virtual int registerImageReleaseCallback(release_image_buffers_callback callback, void *user_data) = 0; - - //Registers callback, which signals a completed image capture - virtual int registerEndCaptureCallback(end_image_capture_callback callback, void *user_data) = 0; - - //API to send a command to the camera - virtual status_t sendCommand(CameraCommands operation, int value1=0, int value2=0, int value3=0, int value4=0) = 0; - - virtual ~CameraAdapter() {}; - - //Retrieves the current Adapter state - virtual AdapterState getState() = 0; - - //Retrieves the next Adapter state - virtual AdapterState getNextState() = 0; - - // Receive orientation events from CameraHal - virtual void onOrientationEvent(uint32_t orientation, uint32_t tilt) = 0; - - // Rolls the state machine back to INTIALIZED_STATE from the current state - virtual status_t rollbackToInitializedState() = 0; - - // Retrieves the current Adapter state - for internal use (not locked) - virtual status_t getState(AdapterState &state) = 0; - // Retrieves the next Adapter state - for internal use (not locked) - virtual status_t getNextState(AdapterState &state) = 0; - - virtual status_t setSharedAllocator(camera_request_memory shmem_alloc) = 0; - -protected: - //The first two methods will try to switch the adapter state. - //Every call to setState() should be followed by a corresponding - //call to commitState(). If the state switch fails, then it will - //get reset to the previous state via rollbackState(). - virtual status_t setState(CameraCommands operation) = 0; - virtual status_t commitState() = 0; - virtual status_t rollbackState() = 0; -}; - -class DisplayAdapter : public BufferProvider, public virtual android::RefBase -{ -public: - DisplayAdapter(); - -#ifdef OMAP_ENHANCEMENT - preview_stream_extended_ops_t * extendedOps() const { - return mExtendedOps; - } - - void setExtendedOps(preview_stream_extended_ops_t * extendedOps); -#endif - - ///Initializes the display adapter creates any resources required - virtual int initialize() = 0; - - virtual int setPreviewWindow(struct preview_stream_ops *window) = 0; - virtual int setFrameProvider(FrameNotifier *frameProvider) = 0; - virtual int setErrorHandler(ErrorNotifier *errorNotifier) = 0; - virtual int enableDisplay(int width, int height, struct timeval *refTime = NULL) = 0; - virtual int disableDisplay(bool cancel_buffer = true) = 0; - //Used for Snapshot review temp. pause - virtual int pauseDisplay(bool pause) = 0; - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - //Used for shot to snapshot measurement - virtual int setSnapshotTimeRef(struct timeval *refTime = NULL) = 0; -#endif - - virtual bool supportsExternalBuffering() = 0; - - // Get max queueable buffers display supports - // This function should only be called after - // allocateBufferList - virtual status_t maxQueueableBuffers(unsigned int& queueable) = 0; - - // Get min buffers display needs at any given time - virtual status_t minUndequeueableBuffers(int& unqueueable) = 0; -protected: - virtual const char* getPixFormatConstant(const char* parameters_format) const; - virtual size_t getBufSize(const char* parameters_format, int width, int height) const; - -private: -#ifdef OMAP_ENHANCEMENT - preview_stream_extended_ops_t * mExtendedOps; -#endif -}; - -static void releaseImageBuffers(void *userData); - -static void endImageCapture(void *userData); - - /** - Implementation of the Android Camera hardware abstraction layer - - This class implements the interface methods defined in CameraHardwareInterface - for the OMAP4 platform - -*/ -class CameraHal - -{ - -public: - ///Constants - static const int NO_BUFFERS_PREVIEW; - static const int NO_BUFFERS_IMAGE_CAPTURE; - static const int NO_BUFFERS_IMAGE_CAPTURE_SYSTEM_HEAP; - static const uint32_t VFR_SCALE = 1000; - - - /*--------------------Interface Methods---------------------------------*/ - - //@{ -public: - - /** Set the notification and data callbacks */ - void setCallbacks(camera_notify_callback notify_cb, - camera_data_callback data_cb, - camera_data_timestamp_callback data_cb_timestamp, - camera_request_memory get_memory, - void *user); - - /** Receives orientation events from SensorListener **/ - void onOrientationEvent(uint32_t orientation, uint32_t tilt); - - /** - * The following three functions all take a msgtype, - * which is a bitmask of the messages defined in - * include/ui/Camera.h - */ - - /** - * Enable a message, or set of messages. - */ - void enableMsgType(int32_t msgType); - - /** - * Disable a message, or a set of messages. - */ - void disableMsgType(int32_t msgType); - - /** - * Query whether a message, or a set of messages, is enabled. - * Note that this is operates as an AND, if any of the messages - * queried are off, this will return false. - */ - int msgTypeEnabled(int32_t msgType); - - /** - * Start preview mode. - */ - int startPreview(); - - /** - * Set preview mode related initialization. - * Only used when slice based processing is enabled. - */ - int cameraPreviewInitialization(); - - /** - * Only used if overlays are used for camera preview. - */ - int setPreviewWindow(struct preview_stream_ops *window); - -#ifdef OMAP_ENHANCEMENT_CPCAM - void setExtendedPreviewStreamOps(preview_stream_extended_ops_t *ops); - - /** - * Set a tap-in or tap-out point. - */ - int setBufferSource(struct preview_stream_ops *tapin, struct preview_stream_ops *tapout); -#endif - - /** - * Stop a previously started preview. - */ - void stopPreview(); - - /** - * Returns true if preview is enabled. - */ - bool previewEnabled(); - - /** - * Start record mode. When a record image is available a CAMERA_MSG_VIDEO_FRAME - * message is sent with the corresponding frame. Every record frame must be released - * by calling releaseRecordingFrame(). - */ - int startRecording(); - - /** - * Stop a previously started recording. - */ - void stopRecording(); - - /** - * Returns true if recording is enabled. - */ - int recordingEnabled(); - - /** - * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME. - */ - void releaseRecordingFrame(const void *opaque); - - /** - * Start auto focus, the notification callback routine is called - * with CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() - * will be called again if another auto focus is needed. - */ - int autoFocus(); - - /** - * Cancels auto-focus function. If the auto-focus is still in progress, - * this function will cancel it. Whether the auto-focus is in progress - * or not, this function will return the focus position to the default. - * If the camera does not support auto-focus, this is a no-op. - */ - int cancelAutoFocus(); - - /** - * Take a picture. - */ - int takePicture(const char* params); - - /** - * Cancel a picture that was started with takePicture. Calling this - * method when no picture is being taken is a no-op. - */ - int cancelPicture(); - - /** Set the camera parameters. */ - int setParameters(const char* params); - int setParameters(const android::CameraParameters& params); - - /** Return the camera parameters. */ - char* getParameters(); - void putParameters(char *); - - /** - * Send command to camera driver. - */ - int sendCommand(int32_t cmd, int32_t arg1, int32_t arg2); - - /** - * Release the hardware resources owned by this object. Note that this is - * *not* done in the destructor. - */ - void release(); - - /** - * Dump state of the camera hardware - */ - int dump(int fd) const; - -#ifdef OMAP_ENHANCEMENT_CPCAM - /** - * start a reprocessing operation. - */ - int reprocess(const char* params); - - /** - * cancels current reprocessing operation - */ - int cancel_reprocess(); -#endif - - status_t storeMetaDataInBuffers(bool enable); - - //@} - -/*--------------------Internal Member functions - Public---------------------------------*/ - -public: - /** @name internalFunctionsPublic */ - //@{ - - /** Constructor of CameraHal */ - CameraHal(int cameraId); - - // Destructor of CameraHal - ~CameraHal(); - - /** Initialize CameraHal */ - status_t initialize(CameraProperties::Properties*); - - /** Deinitialize CameraHal */ - void deinitialize(); - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - //Uses the constructor timestamp as a reference to calcluate the - // elapsed time - static void PPM(const char *); - //Uses a user provided timestamp as a reference to calcluate the - // elapsed time - static void PPM(const char *, struct timeval*, ...); - -#endif - - /** Free image bufs */ - status_t freeImageBufs(); - - //Signals the end of image capture - status_t signalEndImageCapture(); - - //Events - static void eventCallbackRelay(CameraHalEvent* event); - void eventCallback(CameraHalEvent* event); - void setEventProvider(int32_t eventMask, MessageNotifier * eventProvider); - -/*--------------------Internal Member functions - Private---------------------------------*/ -private: - - /** @name internalFunctionsPrivate */ - //@{ - - /** Set the camera parameters specific to Video Recording. */ - bool setVideoModeParameters(const android::CameraParameters&); - - /** Reset the camera parameters specific to Video Recording. */ - bool resetVideoModeParameters(); - - /** Restart the preview with setParameter. */ - status_t restartPreview(); - - status_t parseResolution(const char *resStr, int &width, int &height); - - void insertSupportedParams(); - - /** Allocate preview data buffers */ - status_t allocPreviewDataBufs(size_t size, size_t bufferCount); - - /** Free preview data buffers */ - status_t freePreviewDataBufs(); - - /** Allocate preview buffers */ - status_t allocPreviewBufs(int width, int height, const char* previewFormat, unsigned int bufferCount, unsigned int &max_queueable); - - /** Allocate video buffers */ - status_t allocVideoBufs(uint32_t width, uint32_t height, uint32_t bufferCount); - - /** Allocate image capture buffers */ - status_t allocImageBufs(unsigned int width, unsigned int height, size_t length, - const char* previewFormat, unsigned int bufferCount, - unsigned int *max_queueable); - - /** Allocate Raw buffers */ - status_t allocRawBufs(int width, int height, const char* previewFormat, int bufferCount); - - /** Free preview buffers */ - status_t freePreviewBufs(); - - /** Free video bufs */ - status_t freeVideoBufs(CameraBuffer *bufs); - - /** Free RAW bufs */ - status_t freeRawBufs(); - - //Check if a given resolution is supported by the current camera - //instance - bool isResolutionValid(unsigned int width, unsigned int height, const char *supportedResolutions); - - //Check if a given variable frame rate range is supported by the current camera - //instance - bool isFpsRangeValid(int fpsMin, int fpsMax, const char *supportedFpsRanges); - - //Check if a given parameter is supported by the current camera - // instance - bool isParameterValid(const char *param, const char *supportedParams); - bool isParameterValid(int param, const char *supportedParams); - status_t doesSetParameterNeedUpdate(const char *new_param, const char *old_params, bool &update); - - /** Initialize default parameters */ - void initDefaultParameters(); - - void dumpProperties(CameraProperties::Properties& cameraProps); - - status_t startImageBracketing(); - - status_t stopImageBracketing(); - - void setShutter(bool enable); - - void forceStopPreview(); - - void getPreferredPreviewRes(int *width, int *height); - void resetPreviewRes(android::CameraParameters *params); - - // Internal __takePicture function - used in public takePicture() and reprocess() - int __takePicture(const char* params); - //@} - - -/*----------Member variables - Public ---------------------*/ -public: - int32_t mMsgEnabled; - bool mRecordEnabled; - nsecs_t mCurrentTime; - bool mFalsePreview; - bool mPreviewEnabled; - uint32_t mTakePictureQueue; - bool mBracketingEnabled; - bool mBracketingRunning; - //User shutter override - bool mShutterEnabled; - bool mMeasurementEnabled; - //Google's parameter delimiter - static const char PARAMS_DELIMITER[]; - - CameraAdapter *mCameraAdapter; - android::sp mAppCallbackNotifier; - android::sp mDisplayAdapter; - android::sp mMemoryManager; - // TODO(XXX): May need to keep this as a vector in the future - // when we can have multiple tap-in/tap-out points - android::sp mBufferSourceAdapter_In; - android::sp mBufferSourceAdapter_Out; - -#ifdef OMAP_ENHANCEMENT - preview_stream_extended_ops_t * mExtendedPreviewStreamOps; -#endif - - android::sp mPictureHeap; - - int* mGrallocHandles; - bool mFpsRangeChangedByApp; - - - int mRawWidth; - int mRawHeight; - bool mRawCapture; - - -///static member vars - - static const int SW_SCALING_FPS_LIMIT; - -#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS - - //Timestamp from the CameraHal constructor - static struct timeval ppm_start; - //Timestamp of the autoFocus command - static struct timeval mStartFocus; - //Timestamp of the startPreview command - static struct timeval mStartPreview; - //Timestamp of the takePicture command - static struct timeval mStartCapture; - -#endif - -/*----------Member variables - Private ---------------------*/ -private: - bool mDynamicPreviewSwitch; - //keeps paused state of display - bool mDisplayPaused; - -#ifdef OMAP_ENHANCEMENT_VTC - bool mTunnelSetup; - bool mVTCUseCase; -#endif - - //Index of current camera adapter - int mCameraIndex; - - mutable android::Mutex mLock; - - android::sp mSensorListener; - - void* mCameraAdapterHandle; - - android::CameraParameters mParameters; - bool mPreviewRunning; - bool mPreviewStateOld; - bool mRecordingEnabled; - EventProvider *mEventProvider; - - CameraBuffer *mPreviewDataBuffers; - uint32_t *mPreviewDataOffsets; - int mPreviewDataFd; - int mPreviewDataLength; - CameraBuffer *mImageBuffers; - uint32_t *mImageOffsets; - int mImageFd; - int mImageLength; - CameraBuffer *mPreviewBuffers; - uint32_t *mPreviewOffsets; - int mPreviewLength; - int mPreviewFd; - CameraBuffer *mVideoBuffers; - uint32_t *mVideoOffsets; - int mVideoFd; - int mVideoLength; - - int mBracketRangePositive; - int mBracketRangeNegative; - - ///@todo Rename this as preview buffer provider - BufferProvider *mBufProvider; - BufferProvider *mVideoBufProvider; - - - CameraProperties::Properties* mCameraProperties; - - bool mPreviewStartInProgress; - bool mPreviewInitializationDone; - - bool mSetPreviewWindowCalled; - - uint32_t mPreviewWidth; - uint32_t mPreviewHeight; - int32_t mMaxZoomSupported; - - int mVideoWidth; - int mVideoHeight; - - android::String8 mCapModeBackup; -}; - -} // namespace Camera -} // namespace Ti - -#endif diff --git a/camera/inc/CameraProperties.h b/camera/inc/CameraProperties.h deleted file mode 100644 index e20d18d..0000000 --- a/camera/inc/CameraProperties.h +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - - -#ifndef CAMERA_PROPERTIES_H -#define CAMERA_PROPERTIES_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include "cutils/properties.h" - -#include "Common.h" - -namespace Ti { -namespace Camera { - -#ifdef OMAP_TUNA -#define MAX_CAMERAS_SUPPORTED 2 -#else -#define MAX_CAMERAS_SUPPORTED 3 -#endif -#define MAX_SIMUL_CAMERAS_SUPPORTED 1 -#define MAX_PROP_NAME_LENGTH 50 -#define MAX_PROP_VALUE_LENGTH 2048 - -#define REMAINING_BYTES(buff) ((((int)sizeof(buff) - 1 - (int)strlen(buff)) < 0) ? 0 : (sizeof(buff) - 1 - strlen(buff))) - -enum OperatingMode { - MODE_HIGH_SPEED = 0, - MODE_HIGH_QUALITY, - MODE_ZEROSHUTTERLAG, - MODE_VIDEO, -#ifndef OMAP_TUNA - MODE_STEREO, -#endif - MODE_CPCAM, - MODE_MAX -}; - -// Class that handles the Camera Properties -class CameraProperties -{ -public: - static const char INVALID[]; - static const char CAMERA_NAME[]; - static const char CAMERA_SENSOR_INDEX[]; - static const char CAMERA_SENSOR_ID[]; - static const char ORIENTATION_INDEX[]; - static const char FACING_INDEX[]; - static const char SUPPORTED_PREVIEW_SIZES[]; -#ifndef OMAP_TUNA - static const char SUPPORTED_PREVIEW_SUBSAMPLED_SIZES[]; - static const char SUPPORTED_PREVIEW_TOPBOTTOM_SIZES[]; - static const char SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES[]; -#endif - static const char SUPPORTED_PREVIEW_FORMATS[]; - static const char SUPPORTED_PREVIEW_FRAME_RATES[]; - static const char SUPPORTED_PREVIEW_FRAME_RATES_EXT[]; - static const char SUPPORTED_PICTURE_SIZES[]; -#ifndef OMAP_TUNA - static const char SUPPORTED_PICTURE_SUBSAMPLED_SIZES[]; - static const char SUPPORTED_PICTURE_TOPBOTTOM_SIZES[]; - static const char SUPPORTED_PICTURE_SIDEBYSIDE_SIZES[]; -#endif - static const char SUPPORTED_PICTURE_FORMATS[]; - static const char SUPPORTED_THUMBNAIL_SIZES[]; - static const char SUPPORTED_WHITE_BALANCE[]; - static const char SUPPORTED_EFFECTS[]; - static const char SUPPORTED_ANTIBANDING[]; - static const char SUPPORTED_EXPOSURE_MODES[]; - static const char SUPPORTED_MANUAL_EXPOSURE_MIN[]; - static const char SUPPORTED_MANUAL_EXPOSURE_MAX[]; - static const char SUPPORTED_MANUAL_EXPOSURE_STEP[]; - static const char SUPPORTED_MANUAL_GAIN_ISO_MIN[]; - static const char SUPPORTED_MANUAL_GAIN_ISO_MAX[]; - static const char SUPPORTED_MANUAL_GAIN_ISO_STEP[]; - static const char SUPPORTED_EV_MIN[]; - static const char SUPPORTED_EV_MAX[]; - static const char SUPPORTED_EV_STEP[]; - static const char SUPPORTED_ISO_VALUES[]; - static const char SUPPORTED_SCENE_MODES[]; - static const char SUPPORTED_FLASH_MODES[]; - static const char SUPPORTED_FOCUS_MODES[]; - static const char REQUIRED_PREVIEW_BUFS[]; - static const char REQUIRED_IMAGE_BUFS[]; - static const char SUPPORTED_ZOOM_RATIOS[]; - static const char SUPPORTED_ZOOM_STAGES[]; - static const char SUPPORTED_IPP_MODES[]; - static const char SMOOTH_ZOOM_SUPPORTED[]; - static const char ZOOM_SUPPORTED[]; - static const char PREVIEW_SIZE[]; - static const char PREVIEW_FORMAT[]; - static const char PREVIEW_FRAME_RATE[]; - static const char ZOOM[]; - static const char PICTURE_SIZE[]; - static const char PICTURE_FORMAT[]; - static const char JPEG_THUMBNAIL_SIZE[]; - static const char WHITEBALANCE[]; - static const char EFFECT[]; - static const char ANTIBANDING[]; - static const char EXPOSURE_MODE[]; - static const char EV_COMPENSATION[]; - static const char ISO_MODE[]; - static const char FOCUS_MODE[]; - static const char SCENE_MODE[]; - static const char FLASH_MODE[]; - static const char JPEG_QUALITY[]; - static const char BRIGHTNESS[]; - static const char SATURATION[]; - static const char SHARPNESS[]; - static const char CONTRAST[]; - static const char IPP[]; - static const char GBCE[]; - static const char SUPPORTED_GBCE[]; - static const char GLBCE[]; - static const char SUPPORTED_GLBCE[]; - static const char AUTOCONVERGENCE_MODE[]; - static const char AUTOCONVERGENCE_MODE_VALUES[]; - static const char MANUAL_CONVERGENCE[]; - static const char SUPPORTED_MANUAL_CONVERGENCE_MIN[]; - static const char SUPPORTED_MANUAL_CONVERGENCE_MAX[]; - static const char SUPPORTED_MANUAL_CONVERGENCE_STEP[]; - static const char SENSOR_ORIENTATION[]; - static const char SENSOR_ORIENTATION_VALUES[]; - static const char REVISION[]; - static const char FOCAL_LENGTH[]; - static const char HOR_ANGLE[]; - static const char VER_ANGLE[]; - static const char EXIF_MAKE[]; - static const char EXIF_MODEL[]; - static const char JPEG_THUMBNAIL_QUALITY[]; - static const char MAX_FOCUS_AREAS[]; - static const char MAX_FD_HW_FACES[]; - static const char MAX_FD_SW_FACES[]; - - static const char MAX_PICTURE_WIDTH[]; - static const char MAX_PICTURE_HEIGHT[]; - - static const char PARAMS_DELIMITER []; - -#ifndef OMAP_TUNA - static const char S3D_PRV_FRAME_LAYOUT[]; - static const char S3D_PRV_FRAME_LAYOUT_VALUES[]; - static const char S3D_CAP_FRAME_LAYOUT[]; - static const char S3D_CAP_FRAME_LAYOUT_VALUES[]; -#endif - static const char VSTAB[]; - static const char VSTAB_SUPPORTED[]; - static const char VNF[]; - static const char VNF_SUPPORTED[]; - static const char FRAMERATE_RANGE[]; - static const char FRAMERATE_RANGE_SUPPORTED[]; - static const char FRAMERATE_RANGE_EXT_SUPPORTED[]; - - static const char DEFAULT_VALUE[]; - - static const char AUTO_EXPOSURE_LOCK[]; - static const char AUTO_EXPOSURE_LOCK_SUPPORTED[]; - static const char AUTO_WHITEBALANCE_LOCK[]; - static const char AUTO_WHITEBALANCE_LOCK_SUPPORTED[]; - static const char MAX_NUM_METERING_AREAS[]; - static const char METERING_AREAS[]; - static const char MAX_NUM_FOCUS_AREAS[]; - - static const char VIDEO_SNAPSHOT_SUPPORTED[]; - - static const char VIDEO_SIZE[]; - static const char SUPPORTED_VIDEO_SIZES[]; - -#ifndef OMAP_TUNA - static const char MECHANICAL_MISALIGNMENT_CORRECTION_SUPPORTED[]; - static const char MECHANICAL_MISALIGNMENT_CORRECTION[]; -#endif - - static const char RAW_WIDTH[]; - static const char RAW_HEIGHT[]; - - static const char CAP_MODE_VALUES[]; - - CameraProperties(); - ~CameraProperties(); - - // container class passed around for accessing properties - class Properties - { - public: - - Properties() - { - } - - ~Properties() - { - } - - void set(const char *prop, const char *value); - void set(const char *prop, int value); - const char* get(const char * prop) const; - int getInt(const char * prop) const; - void setSensorIndex(int idx); - void setMode(OperatingMode mode); - OperatingMode getMode() const; - void dump(); - - protected: - const char* keyAt(const unsigned int) const; - const char* valueAt(const unsigned int) const; - - private: - OperatingMode mCurrentMode; - android::DefaultKeyedVector mProperties[MODE_MAX]; - - }; - - ///Initializes the CameraProperties class - status_t initialize(); - status_t loadProperties(); - int camerasSupported(); - int getProperties(int cameraIndex, Properties** properties); - -private: - - int mCamerasSupported; - int mInitialized; - mutable android::Mutex mLock; - - Properties mCameraProps[MAX_CAMERAS_SUPPORTED]; - -}; - -} // namespace Camera -} // namespace Ti - -#endif //CAMERA_PROPERTIES_H diff --git a/camera/inc/Common.h b/camera/inc/Common.h deleted file mode 100644 index 690fce7..0000000 --- a/camera/inc/Common.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef CAMERAHAL_COMMON_H -#define CAMERAHAL_COMMON_H - -#include "UtilsCommon.h" -#include "DebugUtils.h" -#include "Status.h" - - - - -// logging functions -#ifdef CAMERAHAL_DEBUG -# define CAMHAL_LOGD DBGUTILS_LOGD -# define CAMHAL_LOGDA DBGUTILS_LOGDA -# define CAMHAL_LOGDB DBGUTILS_LOGDB -# ifdef CAMERAHAL_SUPERVERBOSE -# define CAMHAL_LOGSV DBGUTILS_LOGV -# define CAMHAL_LOGSVA DBGUTILS_LOGVA -# define CAMHAL_LOGSVB DBGUTILS_LOGVB -# else -# define CAMHAL_LOGSV(...) -# define CAMHAL_LOGSVA(str) -# define CAMHAL_LOGSVB(str, ...) -# endif -# ifdef CAMERAHAL_DEBUG_VERBOSE -# define CAMHAL_LOGV DBGUTILS_LOGV -# define CAMHAL_LOGVA DBGUTILS_LOGVA -# define CAMHAL_LOGVB DBGUTILS_LOGVB -# else -# define CAMHAL_LOGV(...) -# define CAMHAL_LOGVA(str) -# define CAMHAL_LOGVB(str, ...) -# endif -#else -# define CAMHAL_LOGD(...) -# define CAMHAL_LOGDA(str) -# define CAMHAL_LOGDB(str, ...) -# define CAMHAL_LOGSV(...) -# define CAMHAL_LOGSVA(str) -# define CAMHAL_LOGSVB(str, ...) -# define CAMHAL_LOGV(...) -# define CAMHAL_LOGVA(str) -# define CAMHAL_LOGVB(str, ...) -#endif - -#define CAMHAL_LOGI DBGUTILS_LOGI -#define CAMHAL_LOGW DBGUTILS_LOGW -#define CAMHAL_LOGE DBGUTILS_LOGE -#define CAMHAL_LOGEA DBGUTILS_LOGEA -#define CAMHAL_LOGEB DBGUTILS_LOGEB -#define CAMHAL_LOGF DBGUTILS_LOGF - -#define CAMHAL_ASSERT DBGUTILS_ASSERT -#define CAMHAL_ASSERT_X DBGUTILS_ASSERT_X - -#define CAMHAL_UNUSED(x) (void)x - - - - -#endif // CAMERAHAL_COMMON_H diff --git a/camera/inc/Encoder_libjpeg.h b/camera/inc/Encoder_libjpeg.h deleted file mode 100644 index 72feb08..0000000 --- a/camera/inc/Encoder_libjpeg.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file Encoder_libjpeg.h -* -* This defines API for camerahal to encode YUV using libjpeg -* -*/ - -#ifndef ANDROID_CAMERA_HARDWARE_ENCODER_LIBJPEG_H -#define ANDROID_CAMERA_HARDWARE_ENCODER_LIBJPEG_H - -#include -#include - -extern "C" { -#include "jhead.h" - -#undef TRUE -#undef FALSE - -} - -#include "CameraHal.h" - -#define CANCEL_TIMEOUT 5000000 // 5 seconds - -namespace Ti { -namespace Camera { - -/** - * libjpeg encoder class - uses libjpeg to encode yuv - */ - -#define MAX_EXIF_TAGS_SUPPORTED 30 -typedef void (*encoder_libjpeg_callback_t) (void* main_jpeg, - void* thumb_jpeg, - CameraFrame::FrameType type, - void* cookie1, - void* cookie2, - void* cookie3, - void* cookie4, - bool canceled); - -// these have to match strings defined in external/jhead/exif.c -static const char TAG_MODEL[] = "Model"; -static const char TAG_MAKE[] = "Make"; -static const char TAG_FOCALLENGTH[] = "FocalLength"; -static const char TAG_DATETIME[] = "DateTime"; -static const char TAG_IMAGE_WIDTH[] = "ImageWidth"; -static const char TAG_IMAGE_LENGTH[] = "ImageLength"; -static const char TAG_GPS_LAT[] = "GPSLatitude"; -static const char TAG_GPS_LAT_REF[] = "GPSLatitudeRef"; -static const char TAG_GPS_LONG[] = "GPSLongitude"; -static const char TAG_GPS_LONG_REF[] = "GPSLongitudeRef"; -static const char TAG_GPS_ALT[] = "GPSAltitude"; -static const char TAG_GPS_ALT_REF[] = "GPSAltitudeRef"; -static const char TAG_GPS_MAP_DATUM[] = "GPSMapDatum"; -static const char TAG_GPS_PROCESSING_METHOD[] = "GPSProcessingMethod"; -static const char TAG_GPS_VERSION_ID[] = "GPSVersionID"; -static const char TAG_GPS_TIMESTAMP[] = "GPSTimeStamp"; -static const char TAG_GPS_DATESTAMP[] = "GPSDateStamp"; -static const char TAG_ORIENTATION[] = "Orientation"; -static const char TAG_FLASH[] = "Flash"; -static const char TAG_DIGITALZOOMRATIO[] = "DigitalZoomRatio"; -static const char TAG_EXPOSURETIME[] = "ExposureTime"; -static const char TAG_APERTURE[] = "ApertureValue"; -static const char TAG_ISO_EQUIVALENT[] = "ISOSpeedRatings"; -static const char TAG_WHITEBALANCE[] = "WhiteBalance"; -static const char TAG_LIGHT_SOURCE[] = "LightSource"; -static const char TAG_METERING_MODE[] = "MeteringMode"; -static const char TAG_EXPOSURE_PROGRAM[] = "ExposureProgram"; -static const char TAG_COLOR_SPACE[] = "ColorSpace"; -static const char TAG_CPRS_BITS_PER_PIXEL[] = "CompressedBitsPerPixel"; -static const char TAG_FNUMBER[] = "FNumber"; -static const char TAG_SHUTTERSPEED[] = "ShutterSpeedValue"; -static const char TAG_SENSING_METHOD[] = "SensingMethod"; -static const char TAG_CUSTOM_RENDERED[] = "CustomRendered"; - -class ExifElementsTable { - public: - ExifElementsTable() : - gps_tag_count(0), exif_tag_count(0), position(0), - jpeg_opened(false) - { -#ifdef ANDROID_API_JB_OR_LATER - has_datetime_tag = false; -#endif - } - ~ExifElementsTable(); - - status_t insertElement(const char* tag, const char* value); - void insertExifToJpeg(unsigned char* jpeg, size_t jpeg_size); - status_t insertExifThumbnailImage(const char*, int); - void saveJpeg(unsigned char* picture, size_t jpeg_size); - static const char* degreesToExifOrientation(unsigned int); - static void stringToRational(const char*, unsigned int*, unsigned int*); - static bool isAsciiTag(const char* tag); - private: - ExifElement_t table[MAX_EXIF_TAGS_SUPPORTED]; - unsigned int gps_tag_count; - unsigned int exif_tag_count; - unsigned int position; - bool jpeg_opened; -#ifdef ANDROID_API_JB_OR_LATER - bool has_datetime_tag; -#endif -}; - -class Encoder_libjpeg : public android::Thread { - /* public member types and variables */ - public: - struct params { - uint8_t* src; - int src_size; - uint8_t* dst; - int dst_size; - int quality; - int in_width; - int in_height; - int out_width; - int out_height; - int right_crop; - int start_offset; - const char* format; - size_t jpeg_size; - }; - /* public member functions */ - public: - Encoder_libjpeg(params* main_jpeg, - params* tn_jpeg, - encoder_libjpeg_callback_t cb, - CameraFrame::FrameType type, - void* cookie1, - void* cookie2, - void* cookie3, void *cookie4) - : android::Thread(false), mMainInput(main_jpeg), mThumbnailInput(tn_jpeg), mCb(cb), - mCancelEncoding(false), mCookie1(cookie1), mCookie2(cookie2), mCookie3(cookie3), mCookie4(cookie4), - mType(type), mThumb(NULL) { - this->incStrong(this); - mCancelSem.Create(0); - } - - ~Encoder_libjpeg() { - CAMHAL_LOGVB("~Encoder_libjpeg(%p)", this); - } - - virtual bool threadLoop() { - size_t size = 0; - if (mThumbnailInput) { - // start thread to encode thumbnail - mThumb = new Encoder_libjpeg(mThumbnailInput, NULL, NULL, mType, NULL, NULL, NULL, NULL); - mThumb->run(); - } - - // encode our main image - size = encode(mMainInput); - - // signal cancel semaphore incase somebody is waiting - mCancelSem.Signal(); - - // check if it is main jpeg thread - if(mThumb.get()) { - // wait until tn jpeg thread exits. - mThumb->join(); - mThumb.clear(); - mThumb = NULL; - } - - if(mCb) { - mCb(mMainInput, mThumbnailInput, mType, mCookie1, mCookie2, mCookie3, mCookie4, mCancelEncoding); - } - - // encoder thread runs, self-destructs, and then exits - this->decStrong(this); - return false; - } - - void cancel() { - mCancelEncoding = true; - if (mThumb.get()) { - mThumb->cancel(); - mCancelSem.WaitTimeout(CANCEL_TIMEOUT); - } - } - - void getCookies(void **cookie1, void **cookie2, void **cookie3) { - if (cookie1) *cookie1 = mCookie1; - if (cookie2) *cookie2 = mCookie2; - if (cookie3) *cookie3 = mCookie3; - } - - private: - params* mMainInput; - params* mThumbnailInput; - encoder_libjpeg_callback_t mCb; - bool mCancelEncoding; - void* mCookie1; - void* mCookie2; - void* mCookie3; - void* mCookie4; - CameraFrame::FrameType mType; - android::sp mThumb; - Utils::Semaphore mCancelSem; - - size_t encode(params*); -}; - -} // namespace Camera -} // namespace Ti - -#endif diff --git a/camera/inc/General3A_Settings.h b/camera/inc/General3A_Settings.h deleted file mode 100644 index 777b255..0000000 --- a/camera/inc/General3A_Settings.h +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file General3A_Settings.h -* -* This file maps the Camera Hardware Interface to OMX. -* -*/ - -#include "OMX_TI_IVCommon.h" -#include "OMX_TI_Common.h" -#include "OMX_TI_Index.h" -#include "TICameraParameters.h" - -#ifndef GENERAL_3A_SETTINGS_H -#define GENERAL_3A_SETTINGS_H - -namespace Ti { -namespace Camera { - -struct userToOMX_LUT{ - const char * userDefinition; - int omxDefinition; -}; - -struct LUTtype{ - int size; - const userToOMX_LUT *Table; -}; - -const userToOMX_LUT isoUserToOMX[] = { - { TICameraParameters::ISO_MODE_AUTO, 0 }, - { TICameraParameters::ISO_MODE_100, 100 }, - { TICameraParameters::ISO_MODE_200, 200 }, - { TICameraParameters::ISO_MODE_400, 400 }, - { TICameraParameters::ISO_MODE_800, 800 }, - { TICameraParameters::ISO_MODE_1000, 1000 }, - { TICameraParameters::ISO_MODE_1200, 1200 }, - { TICameraParameters::ISO_MODE_1600, 1600 }, -}; - -const userToOMX_LUT effects_UserToOMX [] = { - { android::CameraParameters::EFFECT_NONE, OMX_ImageFilterNone }, - { android::CameraParameters::EFFECT_NEGATIVE, OMX_ImageFilterNegative }, - { android::CameraParameters::EFFECT_SOLARIZE, OMX_ImageFilterSolarize }, - { android::CameraParameters::EFFECT_SEPIA, OMX_ImageFilterSepia }, - { android::CameraParameters::EFFECT_MONO, OMX_ImageFilterGrayScale }, - { android::CameraParameters::EFFECT_BLACKBOARD, OMX_TI_ImageFilterBlackBoard }, - { android::CameraParameters::EFFECT_WHITEBOARD, OMX_TI_ImageFilterWhiteBoard }, - { android::CameraParameters::EFFECT_AQUA, OMX_TI_ImageFilterAqua }, - { android::CameraParameters::EFFECT_POSTERIZE, OMX_TI_ImageFilterPosterize }, -#ifdef OMAP_ENHANCEMENT - { TICameraParameters::EFFECT_NATURAL, OMX_ImageFilterNatural }, - { TICameraParameters::EFFECT_VIVID, OMX_ImageFilterVivid }, - { TICameraParameters::EFFECT_COLOR_SWAP, OMX_ImageFilterColourSwap }, - { TICameraParameters::EFFECT_BLACKWHITE, OMX_TI_ImageFilterBlackWhite } -#endif -}; - -const userToOMX_LUT scene_UserToOMX [] = { - { android::CameraParameters::SCENE_MODE_AUTO, OMX_Manual }, - { android::CameraParameters::SCENE_MODE_LANDSCAPE, OMX_Landscape }, - { android::CameraParameters::SCENE_MODE_NIGHT_PORTRAIT, OMX_NightPortrait }, - { android::CameraParameters::SCENE_MODE_FIREWORKS, OMX_Fireworks }, - { android::CameraParameters::SCENE_MODE_ACTION, OMX_TI_Action }, - { android::CameraParameters::SCENE_MODE_BEACH, OMX_TI_Beach }, - { android::CameraParameters::SCENE_MODE_CANDLELIGHT, OMX_TI_Candlelight }, - { android::CameraParameters::SCENE_MODE_NIGHT, OMX_TI_Night }, - { android::CameraParameters::SCENE_MODE_PARTY, OMX_TI_Party }, - { android::CameraParameters::SCENE_MODE_PORTRAIT, OMX_TI_Portrait }, - { android::CameraParameters::SCENE_MODE_SNOW, OMX_TI_Snow }, - { android::CameraParameters::SCENE_MODE_STEADYPHOTO, OMX_TI_Steadyphoto }, - { android::CameraParameters::SCENE_MODE_SUNSET, OMX_TI_Sunset }, - { android::CameraParameters::SCENE_MODE_THEATRE, OMX_TI_Theatre }, - { android::CameraParameters::SCENE_MODE_SPORTS, OMX_Sport }, -#ifdef OMAP_ENHANCEMENT - { TICameraParameters::SCENE_MODE_CLOSEUP, OMX_Closeup }, - { TICameraParameters::SCENE_MODE_AQUA, OMX_Underwater }, - { TICameraParameters::SCENE_MODE_MOOD, OMX_Mood }, - { TICameraParameters::SCENE_MODE_NIGHT_INDOOR, OMX_NightIndoor }, - { TICameraParameters::SCENE_MODE_DOCUMENT, OMX_Document }, - { TICameraParameters::SCENE_MODE_BARCODE, OMX_Barcode }, - { TICameraParameters::SCENE_MODE_VIDEO_SUPER_NIGHT, OMX_SuperNight }, - { TICameraParameters::SCENE_MODE_VIDEO_CINE, OMX_Cine }, - { TICameraParameters::SCENE_MODE_VIDEO_OLD_FILM, OMX_OldFilm }, -#endif -}; - -const userToOMX_LUT whiteBal_UserToOMX [] = { - { android::CameraParameters::WHITE_BALANCE_AUTO, OMX_WhiteBalControlAuto }, - { android::CameraParameters::WHITE_BALANCE_DAYLIGHT, OMX_WhiteBalControlSunLight }, - { android::CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT, OMX_WhiteBalControlCloudy }, - { android::CameraParameters::WHITE_BALANCE_FLUORESCENT, OMX_WhiteBalControlFluorescent }, - { android::CameraParameters::WHITE_BALANCE_INCANDESCENT, OMX_WhiteBalControlIncandescent }, - { android::CameraParameters::WHITE_BALANCE_SHADE, OMX_TI_WhiteBalControlShade }, - { android::CameraParameters::WHITE_BALANCE_TWILIGHT, OMX_TI_WhiteBalControlTwilight }, - { android::CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT, OMX_TI_WhiteBalControlWarmFluorescent }, -#ifdef OMAP_ENHANCEMENT - { TICameraParameters::WHITE_BALANCE_TUNGSTEN, OMX_WhiteBalControlTungsten }, - { TICameraParameters::WHITE_BALANCE_HORIZON, OMX_WhiteBalControlHorizon }, - { TICameraParameters::WHITE_BALANCE_SUNSET, OMX_TI_WhiteBalControlSunset } -#endif -}; - -const userToOMX_LUT antibanding_UserToOMX [] = { - { android::CameraParameters::ANTIBANDING_OFF, OMX_FlickerCancelOff }, - { android::CameraParameters::ANTIBANDING_AUTO, OMX_FlickerCancelAuto }, - { android::CameraParameters::ANTIBANDING_50HZ, OMX_FlickerCancel50 }, - { android::CameraParameters::ANTIBANDING_60HZ, OMX_FlickerCancel60 } -}; - -const userToOMX_LUT focus_UserToOMX [] = { - { android::CameraParameters::FOCUS_MODE_AUTO, OMX_IMAGE_FocusControlAutoLock }, - { android::CameraParameters::FOCUS_MODE_INFINITY, OMX_IMAGE_FocusControlAutoInfinity }, - { android::CameraParameters::FOCUS_MODE_INFINITY, OMX_IMAGE_FocusControlHyperfocal }, - { android::CameraParameters::FOCUS_MODE_MACRO, OMX_IMAGE_FocusControlAutoMacro }, - { android::CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO, OMX_IMAGE_FocusControlAuto }, - { android::CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE, OMX_IMAGE_FocusControlAuto }, -#ifdef OMAP_ENHANCEMENT - { TICameraParameters::FOCUS_MODE_FACE , OMX_IMAGE_FocusControlContinousFacePriority }, - { TICameraParameters::FOCUS_MODE_PORTRAIT, OMX_IMAGE_FocusControlPortrait }, - { TICameraParameters::FOCUS_MODE_EXTENDED, OMX_IMAGE_FocusControlExtended }, -#endif - { TICameraParameters::FOCUS_MODE_OFF , OMX_IMAGE_FocusControlOff } -}; - -const userToOMX_LUT exposure_UserToOMX [] = { - { TICameraParameters::EXPOSURE_MODE_MANUAL, OMX_ExposureControlOff }, - { TICameraParameters::EXPOSURE_MODE_AUTO, OMX_ExposureControlAuto }, - { TICameraParameters::EXPOSURE_MODE_NIGHT, OMX_ExposureControlNight }, - { TICameraParameters::EXPOSURE_MODE_BACKLIGHT, OMX_ExposureControlBackLight }, - { TICameraParameters::EXPOSURE_MODE_SPOTLIGHT, OMX_ExposureControlSpotLight}, - { TICameraParameters::EXPOSURE_MODE_SPORTS, OMX_ExposureControlSports }, - { TICameraParameters::EXPOSURE_MODE_SNOW, OMX_ExposureControlSnow }, - { TICameraParameters::EXPOSURE_MODE_BEACH, OMX_ExposureControlBeach }, - { TICameraParameters::EXPOSURE_MODE_APERTURE, OMX_ExposureControlLargeAperture }, - { TICameraParameters::EXPOSURE_MODE_SMALL_APERTURE, OMX_ExposureControlSmallApperture }, -}; - -const userToOMX_LUT flash_UserToOMX [] = { - { android::CameraParameters::FLASH_MODE_OFF ,OMX_IMAGE_FlashControlOff }, - { android::CameraParameters::FLASH_MODE_ON ,OMX_IMAGE_FlashControlOn }, - { android::CameraParameters::FLASH_MODE_AUTO ,OMX_IMAGE_FlashControlAuto }, - { android::CameraParameters::FLASH_MODE_TORCH ,OMX_IMAGE_FlashControlTorch }, - { android::CameraParameters::FLASH_MODE_RED_EYE ,OMX_IMAGE_FlashControlRedEyeReduction }, -#ifdef OMAP_ENHANCEMENT - { TICameraParameters::FLASH_MODE_FILL_IN ,OMX_IMAGE_FlashControlFillin } -#endif -}; - -const LUTtype ExpLUT = - { - sizeof(exposure_UserToOMX)/sizeof(exposure_UserToOMX[0]), - exposure_UserToOMX - }; - -const LUTtype WBalLUT = - { - sizeof(whiteBal_UserToOMX)/sizeof(whiteBal_UserToOMX[0]), - whiteBal_UserToOMX - }; - -const LUTtype FlickerLUT = - { - sizeof(antibanding_UserToOMX)/sizeof(antibanding_UserToOMX[0]), - antibanding_UserToOMX - }; - -const LUTtype SceneLUT = - { - sizeof(scene_UserToOMX)/sizeof(scene_UserToOMX[0]), - scene_UserToOMX - }; - -const LUTtype FlashLUT = - { - sizeof(flash_UserToOMX)/sizeof(flash_UserToOMX[0]), - flash_UserToOMX - }; - -const LUTtype EffLUT = - { - sizeof(effects_UserToOMX)/sizeof(effects_UserToOMX[0]), - effects_UserToOMX - }; - -const LUTtype FocusLUT = - { - sizeof(focus_UserToOMX)/sizeof(focus_UserToOMX[0]), - focus_UserToOMX - }; - -const LUTtype IsoLUT = - { - sizeof(isoUserToOMX)/sizeof(isoUserToOMX[0]), - isoUserToOMX - }; - -/* -* class Gen3A_settings -* stores the 3A settings -* also defines the look up tables -* for mapping settings from Hal to OMX -*/ -class Gen3A_settings{ - public: - - int Exposure; - int WhiteBallance; - int Flicker; - int SceneMode; - int Effect; - int Focus; - int EVCompensation; - int Contrast; - int Saturation; - int Sharpness; - int ISO; - int FlashMode; - int ManualExposure; - int ManualExposureRight; - int ManualGain; - int ManualGainRight; - - unsigned int Brightness; - OMX_BOOL ExposureLock; - OMX_BOOL FocusLock; - OMX_BOOL WhiteBalanceLock; - - OMX_BOOL AlgoFixedGamma; - OMX_BOOL AlgoNSF1; - OMX_BOOL AlgoNSF2; - OMX_BOOL AlgoSharpening; - OMX_BOOL AlgoThreeLinColorMap; - OMX_BOOL AlgoGIC; - -}; - -/* -* Flags raised when a setting is changed -*/ -enum E3ASettingsFlags -{ - SetSceneMode = 1 << 0, - SetEVCompensation = 1 << 1, - SetWhiteBallance = 1 << 2, - SetFlicker = 1 << 3, - SetExposure = 1 << 4, - SetSharpness = 1 << 5, - SetBrightness = 1 << 6, - SetContrast = 1 << 7, - SetISO = 1 << 8, - SetSaturation = 1 << 9, - SetEffect = 1 << 10, - SetFocus = 1 << 11, - SetExpMode = 1 << 14, - SetFlash = 1 << 15, - SetExpLock = 1 << 16, - SetWBLock = 1 << 17, - SetMeteringAreas = 1 << 18, - SetManualExposure = 1 << 19, - - SetAlgoFixedGamma = 1 << 20, - SetAlgoNSF1 = 1 << 21, - SetAlgoNSF2 = 1 << 22, - SetAlgoSharpening = 1 << 23, - SetAlgoThreeLinColorMap = 1 << 24, - SetAlgoGIC = 1 << 25, - - - E3aSettingMax, - E3AsettingsAll = ( ((E3aSettingMax -1 ) << 1) -1 ) /// all possible flags raised -}; - -} // namespace Camera -} // namespace Ti - -#endif //GENERAL_3A_SETTINGS_H diff --git a/camera/inc/NV12_resize.h b/camera/inc/NV12_resize.h deleted file mode 100644 index 4b05a4f..0000000 --- a/camera/inc/NV12_resize.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NV12_RESIZE_H_ -#define NV12_RESIZE_H_ - -#include "Common.h" - -typedef unsigned char mmBool; -typedef unsigned char mmUchar; -typedef unsigned char mmUint8; -typedef unsigned char mmByte; -typedef unsigned short mmUint16; -typedef unsigned int mmUint32; -typedef unsigned long mmUint64; -typedef signed char mmInt8; -typedef char mmChar; -typedef signed short mmInt16; -typedef signed int mmInt32; -typedef signed long mmLong; -typedef signed int mmHandle; -typedef float mmFloat; -typedef double mmDouble; -typedef int HObj; -typedef HObj HFile; -typedef int HDir; -typedef void* mmMutexHandle; -typedef struct _fstat { - mmInt32 fileSize; -} VE_FileAttribute; - -typedef struct { - mmInt32 second; - mmInt32 millisecond; -} tsVE_Time; - -typedef struct { - mmInt32 year; - mmInt32 month; - mmInt32 day; - mmInt32 hour; - mmInt32 minute; - mmInt32 second; -} TmDateTime; - -const mmUint8 bWeights[8][8][4] = { - {{64, 0, 0, 0}, {56, 0, 0, 8}, {48, 0, 0,16}, {40, 0, 0,24}, - {32, 0, 0,32}, {24, 0, 0,40}, {16, 0, 0,48}, { 8, 0, 0,56}}, - - {{56, 8, 0, 0}, {49, 7, 1, 7}, {42, 6, 2,14}, {35, 5, 3,21}, - {28, 4, 4,28}, {21, 3, 5,35}, {14, 2, 6,42}, { 7, 1, 7,49}}, - - {{48,16, 0, 0}, {42,14, 2, 6}, {36,12,4 ,12}, {30,10,6 ,18}, - {24, 8, 8,24}, {18, 6,10,30}, {12,4 ,12,36}, { 6, 2,14,42}}, - - {{40,24,0 ,0 }, {35,21, 3, 5}, {30,18, 6,10}, {25,15, 9,15}, - {20,12,12,20}, {15, 9,15,25}, {10, 6,18,30}, { 5, 3,21,35}}, - - {{32,32, 0,0 }, {28,28, 4, 4}, {24,24, 8, 8}, {20,20,12,12}, - {16,16,16,16}, {12,12,20,20}, { 8, 8,24,24}, { 4, 4,28,28}}, - - {{24,40,0 ,0 }, {21,35, 5, 3}, {18,30,10, 6}, {15,25,15, 9}, - {12,20,20,12}, { 9,15,25,15}, { 6,10,30,18}, { 3, 5,35,21}}, - - {{16,48, 0,0 }, {14,42, 6, 2}, {12,36,12, 4}, {10,30,18, 6}, - {8 ,24,24,8 }, { 6,18,30,10}, { 4,12,36,12}, { 2, 6,42,14}}, - - {{ 8,56, 0,0 }, { 7,49, 7, 1}, { 6,42,14, 2}, { 5,35,21, 3}, - { 4,28,28,4 }, { 3,21,35, 5}, { 2,14,42, 6}, { 1,7 ,49, 7}} -}; - -typedef enum { - IC_FORMAT_NONE, - IC_FORMAT_RGB565, - IC_FORMAT_RGB888, - IC_FORMAT_YCbCr420_lp, - IC_FORMAT_YCbCr, - IC_FORMAT_YCbCr420_FRAME_PK, - IC_FORMAT_MAX -} enumImageFormat; - -/* This structure defines the format of an image */ -typedef struct { - mmInt32 uWidth; - mmInt32 uHeight; - mmInt32 uStride; - enumImageFormat eFormat; - mmByte *imgPtr; - mmByte *clrPtr; - mmInt32 uOffset; -} structConvImage; - -typedef struct IC_crop_struct { - mmUint32 x; /* x pos of rectangle */ - mmUint32 y; /* y pos of rectangle */ - mmUint32 uWidth; /* dx of rectangle */ - mmUint32 uHeight; /* dy of rectangle */ -} IC_rect_type; - -/*========================================================================== -* Function Name : VT_resizeFrame_Video_opt2_lp -* -* Description : Resize a yuv frame. -* -* Input(s) : input_img_ptr -> Input Image Structure -* : output_img_ptr -> Output Image Structure -* : cropout -> crop structure -* -* Value Returned : mmBool -> FALSE on error TRUE on success -* NOTE: -* Not tested for crop funtionallity. -* faster version. -============================================================================*/ -mmBool -VT_resizeFrame_Video_opt2_lp( - structConvImage* i_img_ptr, /* Points to the input image */ - structConvImage* o_img_ptr, /* Points to the output image */ - IC_rect_type* cropout, /* how much to resize to in final image */ - mmUint16 dummy /* Transparent pixel value */ - ); - -#endif //#define NV12_RESIZE_H_ diff --git a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h deleted file mode 100644 index 8182c9c..0000000 --- a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h +++ /dev/null @@ -1,1245 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - -#ifndef OMX_CAMERA_ADAPTER_H -#define OMX_CAMERA_ADAPTER_H - -#include "CameraHal.h" -#include "OMX_Types.h" -#include "OMX_Core.h" -#include "OMX_CoreExt.h" -#include "OMX_IVCommon.h" -#include "OMX_Component.h" -#include "OMX_Index.h" -#include "OMX_IndexExt.h" -#include "OMX_TI_Index.h" -#include "OMX_TI_IVCommon.h" -#include "OMX_TI_Common.h" -#include "OMX_TI_Image.h" -#include "General3A_Settings.h" -#include "OMXSceneModeTables.h" - -#include "BaseCameraAdapter.h" -#include "Encoder_libjpeg.h" -#include "DebugUtils.h" - - -extern "C" -{ -#include "timm_osal_error.h" -#include "timm_osal_events.h" -#include "timm_osal_trace.h" -#include "timm_osal_semaphores.h" -} - - -namespace Ti { -namespace Camera { - -#define Q16_OFFSET 16 - -#define OMX_CMD_TIMEOUT 3000000 //3 sec. -#define OMX_CAPTURE_TIMEOUT 5000000 //5 sec. - -#define FOCUS_THRESHOLD 5 //[s.] - -#define MIN_JPEG_QUALITY 1 -#define MAX_JPEG_QUALITY 100 -#define EXP_BRACKET_RANGE 10 -#define ZOOM_BRACKET_RANGE 10 - -#define FOCUS_DIST_SIZE 100 -#define FOCUS_DIST_BUFFER_SIZE 500 - -#define TOUCH_DATA_SIZE 200 -#define DEFAULT_THUMB_WIDTH 160 -#define DEFAULT_THUMB_HEIGHT 120 -#define FRAME_RATE_FULL_HD 27 -#define FRAME_RATE_HIGH_HD 60 - -#define ZOOM_STAGES 61 - -#define FACE_DETECTION_BUFFER_SIZE 0x1000 -#define MAX_NUM_FACES_SUPPORTED 35 - -#define EXIF_MODEL_SIZE 100 -#define EXIF_MAKE_SIZE 100 -#define EXIF_DATE_TIME_SIZE 20 - -#define GPS_MIN_DIV 60 -#define GPS_SEC_DIV 60 -#define GPS_SEC_ACCURACY 1000 -#define GPS_TIMESTAMP_SIZE 6 -#define GPS_DATESTAMP_SIZE 11 -#define GPS_REF_SIZE 2 -#define GPS_MAPDATUM_SIZE 100 -#define GPS_PROCESSING_SIZE 100 -#define GPS_VERSION_SIZE 4 -#define GPS_NORTH_REF "N" -#define GPS_SOUTH_REF "S" -#define GPS_EAST_REF "E" -#define GPS_WEST_REF "W" - -/* Default portstartnumber of Camera component */ -#define OMX_CAMERA_DEFAULT_START_PORT_NUM 0 - -/* Define number of ports for differt domains */ -#define OMX_CAMERA_PORT_OTHER_NUM 1 -#define OMX_CAMERA_PORT_VIDEO_NUM 4 -#define OMX_CAMERA_PORT_IMAGE_NUM 1 -#define OMX_CAMERA_PORT_AUDIO_NUM 0 -#define OMX_CAMERA_NUM_PORTS (OMX_CAMERA_PORT_OTHER_NUM + OMX_CAMERA_PORT_VIDEO_NUM + OMX_CAMERA_PORT_IMAGE_NUM + OMX_CAMERA_PORT_AUDIO_NUM) - -/* Define start port number for differt domains */ -#define OMX_CAMERA_PORT_OTHER_START OMX_CAMERA_DEFAULT_START_PORT_NUM -#define OMX_CAMERA_PORT_VIDEO_START (OMX_CAMERA_PORT_OTHER_START + OMX_CAMERA_PORT_OTHER_NUM) -#define OMX_CAMERA_PORT_IMAGE_START (OMX_CAMERA_PORT_VIDEO_START + OMX_CAMERA_PORT_VIDEO_NUM) -#define OMX_CAMERA_PORT_AUDIO_START (OMX_CAMERA_PORT_IMAGE_START + OMX_CAMERA_PORT_IMAGE_NUM) - -/* Port index for camera component */ -#define OMX_CAMERA_PORT_OTHER_IN (OMX_CAMERA_PORT_OTHER_START + 0) -#define OMX_CAMERA_PORT_VIDEO_IN_VIDEO (OMX_CAMERA_PORT_VIDEO_START + 0) -#define OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW (OMX_CAMERA_PORT_VIDEO_START + 1) -#define OMX_CAMERA_PORT_VIDEO_OUT_VIDEO (OMX_CAMERA_PORT_VIDEO_START + 2) -#define OMX_CAMERA_PORT_VIDEO_OUT_MEASUREMENT (OMX_CAMERA_PORT_VIDEO_START + 3) -#define OMX_CAMERA_PORT_IMAGE_OUT_IMAGE (OMX_CAMERA_PORT_IMAGE_START + 0) - - -#define OMX_INIT_STRUCT(_s_, _name_) \ - memset(&(_s_), 0x0, sizeof(_name_)); \ - (_s_).nSize = sizeof(_name_); \ - (_s_).nVersion.s.nVersionMajor = 0x1; \ - (_s_).nVersion.s.nVersionMinor = 0x1; \ - (_s_).nVersion.s.nRevision = 0x0; \ - (_s_).nVersion.s.nStep = 0x0 - -#define OMX_INIT_STRUCT_PTR(_s_, _name_) \ - memset((_s_), 0x0, sizeof(_name_)); \ - (_s_)->nSize = sizeof(_name_); \ - (_s_)->nVersion.s.nVersionMajor = 0x1; \ - (_s_)->nVersion.s.nVersionMinor = 0x1; \ - (_s_)->nVersion.s.nRevision = 0x0; \ - (_s_)->nVersion.s.nStep = 0x0 - -#define GOTO_EXIT_IF(_CONDITION,_ERROR) { \ - if ((_CONDITION)) { \ - eError = (_ERROR); \ - goto EXIT; \ - } \ -} - -const int64_t kCameraBufferLatencyNs = 250000000LL; // 250 ms - -///OMX Specific Functions -static OMX_ERRORTYPE OMXCameraAdapterEventHandler(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData); - -static OMX_ERRORTYPE OMXCameraAdapterEmptyBufferDone(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); - -static OMX_ERRORTYPE OMXCameraAdapterFillBufferDone(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffHeader); - -struct CapResolution { - size_t width, height; - const char *param; -}; - -struct CapPixelformat { - OMX_COLOR_FORMATTYPE pixelformat; - const char *param; -}; - -struct CapCodingFormat { - OMX_IMAGE_CODINGTYPE imageCodingFormat; - const char *param; -}; - -struct CapU32 { - OMX_U32 num; - const char *param; -}; - -struct CapS32 { - OMX_S32 num; - const char *param; -}; - -typedef CapU32 CapFramerate; -typedef CapU32 CapISO; -typedef CapU32 CapSensorName; -typedef CapS32 CapZoom; - -/** - * Class which completely abstracts the camera hardware interaction from camera hal - * TODO: Need to list down here, all the message types that will be supported by this class - Need to implement BufferProvider interface to use AllocateBuffer of OMX if needed - */ -class OMXCameraAdapter : public BaseCameraAdapter -{ -public: - - /*--------------------Constant declarations----------------------------------------*/ - static const int32_t MAX_NO_BUFFERS = 20; - - ///@remarks OMX Camera has six ports - buffer input, time input, preview, image, video, and meta data - static const int MAX_NO_PORTS = 6; - - ///Five second timeout - static const int CAMERA_ADAPTER_TIMEOUT = 5000*1000; - - enum CaptureMode - { - INITIAL_MODE = -1, - HIGH_SPEED = 1, - HIGH_QUALITY = 2, - VIDEO_MODE = 3, - HIGH_QUALITY_ZSL = 4, - CP_CAM = 5, - }; - - enum IPPMode - { - IPP_NULL = -1, - IPP_NONE = 0, - IPP_NSF, - IPP_LDC, - IPP_LDCNSF, - }; - - enum CodingMode - { - CodingJPEG = 0, - CodingJPS, - CodingMPO, - }; - - enum Algorithm3A - { - WHITE_BALANCE_ALGO = 0x1, - EXPOSURE_ALGO = 0x2, - FOCUS_ALGO = 0x4, - }; - - enum AlgoPriority - { - FACE_PRIORITY = 0, - REGION_PRIORITY, - }; - - enum BrightnessMode - { - BRIGHTNESS_OFF = 0, - BRIGHTNESS_ON, - BRIGHTNESS_AUTO, - }; - - enum CaptureSettingsFlags { - SetFormat = 1 << 0, - SetThumb = 1 << 1, - SetExpBracket = 1 << 2, - SetQuality = 1 << 3, - SetRotation = 1 << 4, - SetBurst = 1 << 5, - ECaptureSettingMax, - ECapturesettingsAll = ( ((ECaptureSettingMax -1 ) << 1) -1 ) /// all possible flags raised - }; - - enum PreviewSettingsFlags { - SetLDC = 1 << 0, - SetNSF = 1 << 1, - SetCapMode = 1 << 2, - SetVNF = 1 << 3, - SetVSTAB = 1 << 4, - EPreviewSettingMax, - EPreviewSettingsAll = ( ((EPreviewSettingMax -1 ) << 1) -1 ) /// all possible flags raised - }; - - enum BracketingValueMode { - BracketingValueAbsolute, - BracketingValueRelative, - BracketingValueAbsoluteForced, - BracketingValueRelativeForced, - BracketingValueCompensation, - BracketingValueCompensationForced - }; - - class GPSData - { - public: - int mLongDeg, mLongMin, mLongSec, mLongSecDiv; - char mLongRef[GPS_REF_SIZE]; - bool mLongValid; - int mLatDeg, mLatMin, mLatSec, mLatSecDiv; - char mLatRef[GPS_REF_SIZE]; - bool mLatValid; - int mAltitude; - unsigned char mAltitudeRef; - bool mAltitudeValid; - char mMapDatum[GPS_MAPDATUM_SIZE]; - bool mMapDatumValid; - char mVersionId[GPS_VERSION_SIZE]; - bool mVersionIdValid; - char mProcMethod[GPS_PROCESSING_SIZE]; - bool mProcMethodValid; - char mDatestamp[GPS_DATESTAMP_SIZE]; - bool mDatestampValid; - uint32_t mTimeStampHour; - uint32_t mTimeStampMin; - uint32_t mTimeStampSec; - bool mTimeStampValid; - }; - - class EXIFData - { - public: - GPSData mGPSData; - char mMake[EXIF_MODEL_SIZE]; - char mModel[EXIF_MAKE_SIZE]; - unsigned int mFocalNum, mFocalDen; - bool mMakeValid; - bool mModelValid; - }; - - ///Parameters specific to any port of the OMX Camera component - class OMXCameraPortParameters - { - public: - //CameraBuffer * mHostBufaddr[MAX_NO_BUFFERS]; - OMX_BUFFERHEADERTYPE *mBufferHeader[MAX_NO_BUFFERS]; - OMX_U8 mStatus[MAX_NO_BUFFERS]; - OMX_U32 mWidth; - OMX_U32 mHeight; - OMX_U32 mStride; - OMX_U8 mNumBufs; - - // defines maximum number of buffers our of mNumBufs - // queueable at given moment - OMX_U8 mMaxQueueable; - - OMX_U32 mBufSize; - OMX_COLOR_FORMATTYPE mColorFormat; - OMX_PARAM_VIDEONOISEFILTERTYPE mVNFMode; - OMX_PARAM_VIDEOYUVRANGETYPE mYUVRange; - OMX_CONFIG_BOOLEANTYPE mVidStabParam; - OMX_CONFIG_FRAMESTABTYPE mVidStabConfig; - OMX_U32 mCapFrame; - OMX_U32 mFrameRate; - OMX_U32 mMinFrameRate; - OMX_U32 mMaxFrameRate; - CameraFrame::FrameType mImageType; - OMX_TI_STEREOFRAMELAYOUTTYPE mFrameLayoutType; - - CameraBuffer * lookup_omx_buffer (OMX_BUFFERHEADERTYPE *pBufHeader); - enum { - IDLE = 0, // buffer is neither with HAL or Ducati - FILL, // buffer is with Ducati - DONE, // buffer is filled and sent to HAL - }; - }; - - ///Context of the OMX Camera component - class OMXCameraAdapterComponentContext - { - public: - OMX_HANDLETYPE mHandleComp; - OMX_U32 mNumPorts; - OMX_STATETYPE mState ; - OMX_U32 mVideoPortIndex; - OMX_U32 mPrevPortIndex; - OMX_U32 mImagePortIndex; - OMX_U32 mMeasurementPortIndex; - OMX_U32 mVideoInPortIndex; - OMXCameraPortParameters mCameraPortParams[MAX_NO_PORTS]; - }; - - class CachedCaptureParameters - { - public: - unsigned int mPendingCaptureSettings; - unsigned int mPictureRotation; - int mExposureBracketingValues[EXP_BRACKET_RANGE]; - int mExposureGainBracketingValues[EXP_BRACKET_RANGE]; - int mExposureGainBracketingModes[EXP_BRACKET_RANGE]; - size_t mExposureBracketingValidEntries; - OMX_BRACKETMODETYPE mExposureBracketMode; - unsigned int mBurstFrames; - bool mFlushShotConfigQueue; - }; - -public: - - OMXCameraAdapter(size_t sensor_index); - ~OMXCameraAdapter(); - - ///Initialzes the camera adapter creates any resources required - virtual status_t initialize(CameraProperties::Properties*); - - //APIs to configure Camera adapter and get the current parameter set - virtual status_t setParameters(const android::CameraParameters& params); - virtual void getParameters(android::CameraParameters& params); - - // API - status_t UseBuffersPreview(CameraBuffer *bufArr, int num); - - //API to flush the buffers - status_t flushBuffers(OMX_U32 port = OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW); - - // API - virtual status_t setFormat(OMX_U32 port, OMXCameraPortParameters &cap); - - // Function to get and populate caps from handle - static status_t getCaps(int sensorId, CameraProperties::Properties* props, OMX_HANDLETYPE handle); - static const char* getLUTvalue_OMXtoHAL(int OMXValue, LUTtype LUT); - static int getMultipleLUTvalue_OMXtoHAL(int OMXValue, LUTtype LUT, char * supported); - static int getLUTvalue_HALtoOMX(const char * HalValue, LUTtype LUT); - - OMX_ERRORTYPE OMXCameraAdapterEventHandler(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData); - - OMX_ERRORTYPE OMXCameraAdapterEmptyBufferDone(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); - - OMX_ERRORTYPE OMXCameraAdapterFillBufferDone(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffHeader); - - static OMX_ERRORTYPE OMXCameraGetHandle(OMX_HANDLETYPE *handle, OMX_PTR pAppData, - const OMX_CALLBACKTYPE & callbacks); - -protected: - - //Parent class method implementation - virtual status_t takePicture(); - virtual status_t stopImageCapture(); - virtual status_t startBracketing(int range); - virtual status_t stopBracketing(); - virtual status_t autoFocus(); - virtual status_t cancelAutoFocus(); - virtual status_t startSmoothZoom(int targetIdx); - virtual status_t stopSmoothZoom(); - virtual status_t startVideoCapture(); - virtual status_t stopVideoCapture(); - virtual status_t startPreview(); - virtual status_t stopPreview(); - virtual status_t useBuffers(CameraMode mode, CameraBuffer * bufArr, int num, size_t length, unsigned int queueable); - virtual status_t fillThisBuffer(CameraBuffer * frameBuf, CameraFrame::FrameType frameType); - virtual status_t getFrameSize(size_t &width, size_t &height); - virtual status_t getPictureBufferSize(CameraFrame &frame, size_t bufferCount); - virtual status_t getFrameDataSize(size_t &dataFrameSize, size_t bufferCount); - virtual status_t startFaceDetection(); - virtual status_t stopFaceDetection(); - virtual status_t switchToExecuting(); - virtual void onOrientationEvent(uint32_t orientation, uint32_t tilt); - -private: - - // Caches and returns current set of parameters - CachedCaptureParameters* cacheCaptureParameters(); - - status_t doSwitchToExecuting(); - - void performCleanupAfterError(); - - status_t switchToIdle(); - - status_t switchToLoaded(bool bPortEnableRequired = false); - status_t prevPortEnable(); - - OMXCameraPortParameters *getPortParams(CameraFrame::FrameType frameType); - - OMX_ERRORTYPE SignalEvent(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData); - OMX_ERRORTYPE RemoveEvent(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData); - - status_t RegisterForEvent(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN Utils::Semaphore &semaphore); - - status_t setPictureRotation(unsigned int degree); - status_t setSensorOrientation(unsigned int degree); - status_t setImageQuality(unsigned int quality); - status_t setThumbnailParams(unsigned int width, unsigned int height, unsigned int quality); - status_t setSensorQuirks(int orientation, - OMXCameraPortParameters &portParams, - bool &portConfigured); - - status_t setupTunnel(uint32_t SliceHeight, uint32_t EncoderHandle, uint32_t width, uint32_t height); - status_t destroyTunnel(); - - //EXIF - status_t setParametersEXIF(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state); - status_t convertGPSCoord(double coord, int °, int &min, int &sec, int &secDivisor); - status_t setupEXIF(); - status_t setupEXIF_libjpeg(ExifElementsTable*, OMX_TI_ANCILLARYDATATYPE*, - OMX_TI_WHITEBALANCERESULTTYPE*); - - //Focus functionality - status_t doAutoFocus(); - status_t stopAutoFocus(); - status_t checkFocus(OMX_PARAM_FOCUSSTATUSTYPE *eFocusStatus); - status_t returnFocusStatus(bool timeoutReached); - status_t getFocusMode(OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE &focusMode); - void handleFocusCallback(); - - - //Focus distances - status_t setParametersFocus(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state); - status_t addFocusDistances(OMX_U32 &near, - OMX_U32 &optimal, - OMX_U32 &far, - android::CameraParameters& params); - status_t encodeFocusDistance(OMX_U32 dist, char *buffer, size_t length); - status_t getFocusDistances(OMX_U32 &near,OMX_U32 &optimal, OMX_U32 &far); - - //VSTAB and VNF Functionality - status_t enableVideoNoiseFilter(bool enable); - status_t enableVideoStabilization(bool enable); - - //Digital zoom - status_t setParametersZoom(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state); - status_t doZoom(int index); - status_t advanceZoom(); - - //3A related parameters - status_t setParameters3A(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state); - void declareParameter3ABool(const android::CameraParameters ¶ms, const char *key, - OMX_BOOL ¤t_setting, E3ASettingsFlags pending, - const char *msg); - - // scene modes - status_t setScene(Gen3A_settings& Gen3A); - // returns pointer to SceneModesEntry from the LUT for camera given 'name' and 'scene' - static const SceneModesEntry* getSceneModeEntry(const char* name, OMX_SCENEMODETYPE scene); - - - //Flash modes - status_t setFlashMode(Gen3A_settings& Gen3A); - status_t getFlashMode(Gen3A_settings& Gen3A); - - // Focus modes - status_t setFocusMode(Gen3A_settings& Gen3A); - status_t getFocusMode(Gen3A_settings& Gen3A); - - //Exposure Modes - status_t setExposureMode(Gen3A_settings& Gen3A); - status_t setManualExposureVal(Gen3A_settings& Gen3A); - status_t setEVCompensation(Gen3A_settings& Gen3A); - status_t setWBMode(Gen3A_settings& Gen3A); - status_t setFlicker(Gen3A_settings& Gen3A); - status_t setBrightness(Gen3A_settings& Gen3A); - status_t setContrast(Gen3A_settings& Gen3A); - status_t setSharpness(Gen3A_settings& Gen3A); - status_t setSaturation(Gen3A_settings& Gen3A); - status_t setISO(Gen3A_settings& Gen3A); - status_t setEffect(Gen3A_settings& Gen3A); - status_t setMeteringAreas(Gen3A_settings& Gen3A); - - //TI extensions for enable/disable algos - status_t setParameter3ABool(const OMX_INDEXTYPE omx_idx, - const OMX_BOOL data, const char *msg); - status_t setParameter3ABoolInvert(const OMX_INDEXTYPE omx_idx, - const OMX_BOOL data, const char *msg); -#ifndef OMAP_TUNA - status_t setAlgoFixedGamma(Gen3A_settings& Gen3A); - status_t setAlgoNSF1(Gen3A_settings& Gen3A); - status_t setAlgoNSF2(Gen3A_settings& Gen3A); - status_t setAlgoSharpening(Gen3A_settings& Gen3A); - status_t setAlgoThreeLinColorMap(Gen3A_settings& Gen3A); - status_t setAlgoGIC(Gen3A_settings& Gen3A); -#endif - - status_t getEVCompensation(Gen3A_settings& Gen3A); - status_t getWBMode(Gen3A_settings& Gen3A); - status_t getSharpness(Gen3A_settings& Gen3A); - status_t getSaturation(Gen3A_settings& Gen3A); - status_t getISO(Gen3A_settings& Gen3A); - - // 3A locks - status_t setExposureLock(Gen3A_settings& Gen3A); - status_t setFocusLock(Gen3A_settings& Gen3A); - status_t setWhiteBalanceLock(Gen3A_settings& Gen3A); - status_t set3ALock(OMX_BOOL toggleExp, OMX_BOOL toggleWb, OMX_BOOL toggleFocus); - - //Stereo 3D -#ifndef OMAP_TUNA - void setParamS3D(OMX_U32 port, const char *valstr); - status_t setS3DFrameLayout(OMX_U32 port) const; -#endif - - //API to set FrameRate using VFR interface - status_t setVFramerate(OMX_U32 minFrameRate,OMX_U32 maxFrameRate); - - status_t setParametersAlgo(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state); - - //Noise filtering - status_t setNSF(OMXCameraAdapter::IPPMode mode); - - //LDC - status_t setLDC(OMXCameraAdapter::IPPMode mode); - - //GLBCE - status_t setGLBCE(OMXCameraAdapter::BrightnessMode mode); - - //GBCE - status_t setGBCE(OMXCameraAdapter::BrightnessMode mode); - - status_t printComponentVersion(OMX_HANDLETYPE handle); - - //Touch AF - status_t setTouchFocus(); - - //Face detection - status_t setParametersFD(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state); - status_t updateFocusDistances(android::CameraParameters ¶ms); - status_t setFaceDetectionOrientation(OMX_U32 orientation); - status_t setFaceDetection(bool enable, OMX_U32 orientation); - status_t createPreviewMetadata(OMX_BUFFERHEADERTYPE* pBuffHeader, - android::sp &result, - size_t previewWidth, - size_t previewHeight); - status_t encodeFaceCoordinates(const OMX_FACEDETECTIONTYPE *faceData, - camera_frame_metadata_t *metadataResult, - size_t previewWidth, - size_t previewHeight); - status_t encodePreviewMetadata(camera_frame_metadata_t *meta, const OMX_PTR plat_pvt); - - void pauseFaceDetection(bool pause); - - //3A Algorithms priority configuration - status_t setAlgoPriority(AlgoPriority priority, Algorithm3A algo, bool enable); - - //Sensor overclocking - status_t setSensorOverclock(bool enable); - - // Utility methods for OMX Capabilities - static bool _checkOmxTiCap(const OMX_TI_CAPTYPE & caps); - static bool _dumpOmxTiCap(int sensorId, const OMX_TI_CAPTYPE & caps); - - static status_t insertCapabilities(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t encodeSizeCap(OMX_TI_CAPRESTYPE&, const CapResolution *, size_t, char *, size_t); - static status_t encodeISOCap(OMX_U32, const CapISO*, size_t, char*, size_t); - static size_t encodeZoomCap(OMX_S32, const CapZoom*, size_t, char*, size_t); - static void encodeFrameRates(int minFrameRate, int maxFrameRate, const OMX_TI_CAPTYPE & caps, - const CapFramerate * fixedFrameRates, int frameRateCount, android::Vector & fpsRanges); - static status_t encodeImageCodingFormatCap(OMX_IMAGE_CODINGTYPE, - const CapCodingFormat *, - size_t, - char *); - static status_t encodePixelformatCap(OMX_COLOR_FORMATTYPE, - const CapPixelformat*, - size_t, - char*, - size_t); -#ifndef OMAP_TUNA - static status_t encodeSizeCap3D(OMX_TI_CAPRESTYPE&, - const CapResolution*, - size_t , - char * , - size_t); -#endif - static status_t insertImageSizes(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertPreviewSizes(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertThumbSizes(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertZoomStages(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertImageFormats(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertPreviewFormats(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertFramerates(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertEVs(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertISOModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertIPPModes(CameraProperties::Properties*, OMX_TI_CAPTYPE &); - static status_t insertWBModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertEffects(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertExpModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertManualExpRanges(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertSceneModes(CameraProperties::Properties*, OMX_TI_CAPTYPE &); - static status_t insertFocusModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertFlickerModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertFlashModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertSenMount(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertDefaults(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertLocks(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertAreas(CameraProperties::Properties*, OMX_TI_CAPTYPE&); -#ifndef OMAP_TUNA - static status_t insertMechanicalMisalignmentCorrection(CameraProperties::Properties*, OMX_TI_CAPTYPE&); -#endif - static status_t insertCaptureModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertVideoSizes(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertFacing(CameraProperties::Properties*, OMX_TI_CAPTYPE&); -#ifndef OMAP_TUNA - static status_t insertFocalLength(CameraProperties::Properties*, OMX_TI_CAPTYPE&); -#endif - static status_t insertAutoConvergenceModes(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertManualConvergenceRange(CameraProperties::Properties*, OMX_TI_CAPTYPE&); -#ifndef OMAP_TUNA - static status_t insertLayout(CameraProperties::Properties*, OMX_TI_CAPTYPE&); -#endif - static status_t insertVideoSnapshotSupported(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - static status_t insertVNFSupported(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps); - static status_t insertVSTABSupported(CameraProperties::Properties* params, OMX_TI_CAPTYPE &caps); - static status_t insertGBCESupported(CameraProperties::Properties* params, - const OMX_TI_CAPTYPE &caps); - static status_t insertGLBCESupported(CameraProperties::Properties* params, - const OMX_TI_CAPTYPE &caps); - static status_t insertRaw(CameraProperties::Properties*, OMX_TI_CAPTYPE&); - - status_t setParametersCapture(const android::CameraParameters ¶ms, - BaseCameraAdapter::AdapterState state); - - //Exposure Bracketing -#ifndef OMAP_TUNA - status_t initVectorShot(); - status_t setVectorShot(int *evValues, int *evValues2, int *evModes2, - size_t evCount, size_t frameCount, - bool flush, OMX_BRACKETMODETYPE bracketMode); -#endif - status_t setVectorStop(bool toPreview = false); - status_t setExposureBracketing(int *evValues, int *evValues2, - size_t evCount, size_t frameCount, - OMX_BRACKETMODETYPE bracketMode); - status_t doExposureBracketing(int *evValues, int *evValues2, - int *evModes2, - size_t evCount, size_t frameCount, - bool flush, - OMX_BRACKETMODETYPE bracketMode); - int getBracketingValueMode(const char *a, const char *b) const; - status_t parseExpRange(const char *rangeStr, int *expRange, int *gainRange, - int *expGainModes, - size_t count, size_t &validEntries); - - //Temporal Bracketing - status_t doBracketing(OMX_BUFFERHEADERTYPE *pBuffHeader, CameraFrame::FrameType typeOfFrame); - status_t sendBracketFrames(size_t &framesSent); - - // Image Capture Service - status_t startImageCapture(bool bracketing, CachedCaptureParameters*); - status_t disableImagePort(); - - //Shutter callback notifications - status_t setShutterCallback(bool enabled); - - //Sets eithter HQ or HS mode and the frame count - status_t setCaptureMode(OMXCameraAdapter::CaptureMode mode); - status_t UseBuffersCapture(CameraBuffer *bufArr, int num); - status_t UseBuffersPreviewData(CameraBuffer *bufArr, int num); - status_t UseBuffersRawCapture(CameraBuffer *bufArr, int num); - - //Used for calculation of the average frame rate during preview - status_t recalculateFPS(); - - //Sends the incoming OMX buffer header to subscribers - status_t sendCallBacks(CameraFrame frame, OMX_IN OMX_BUFFERHEADERTYPE *pBuffHeader, unsigned int mask, OMXCameraPortParameters *port); - - status_t apply3Asettings( Gen3A_settings& Gen3A ); - - // AutoConvergence - status_t setAutoConvergence(const char *valstr, const char *pValManualstr, const android::CameraParameters ¶ms); - - status_t setExtraData(bool enable, OMX_U32, OMX_EXT_EXTRADATATYPE); - OMX_OTHER_EXTRADATATYPE *getExtradata(const OMX_PTR ptrPrivate, OMX_EXTRADATATYPE type) const; - - // Meta data -#ifdef OMAP_ENHANCEMENT_CPCAM - camera_memory_t * getMetaData(const OMX_PTR plat_pvt, - camera_request_memory allocator) const; -#endif - -#ifndef OMAP_TUNA - // Mechanical Misalignment Correction - status_t setMechanicalMisalignmentCorrection(bool enable); - - // DCC file data save - status_t initDccFileDataSave(OMX_HANDLETYPE* omxHandle, int portIndex); - status_t sniffDccFileDataSave(OMX_BUFFERHEADERTYPE* pBuffHeader); - status_t saveDccFileDataSave(); - status_t closeDccFileDataSave(); - status_t fseekDCCuseCasePos(FILE *pFile); - FILE * fopenCameraDCC(const char *dccFolderPath); - FILE * parseDCCsubDir(DIR *pDir, char *path); -#endif - -#ifdef CAMERAHAL_OMX_PROFILING - status_t storeProfilingData(OMX_BUFFERHEADERTYPE* pBuffHeader); -#endif - - // Internal buffers - status_t initInternalBuffers (OMX_U32); - status_t deinitInternalBuffers (OMX_U32); - - // Reprocess Methods -- implementation in OMXReprocess.cpp - status_t setParametersReprocess(const android::CameraParameters ¶ms, CameraBuffer* bufs, - BaseCameraAdapter::AdapterState state); - status_t startReprocess(); - status_t disableReprocess(); - status_t stopReprocess(); - status_t UseBuffersReprocess(CameraBuffer *bufArr, int num); - - class CommandHandler : public android::Thread { - public: - CommandHandler(OMXCameraAdapter* ca) - : android::Thread(false), mCameraAdapter(ca) { } - - virtual bool threadLoop() { - bool ret; - ret = Handler(); - return ret; - } - - status_t put(Utils::Message* msg){ - android::AutoMutex lock(mLock); - return mCommandMsgQ.put(msg); - } - - void clearCommandQ() - { - android::AutoMutex lock(mLock); - mCommandMsgQ.clear(); - } - - enum { - COMMAND_EXIT = -1, - CAMERA_START_IMAGE_CAPTURE = 0, - CAMERA_PERFORM_AUTOFOCUS, - CAMERA_SWITCH_TO_EXECUTING, - CAMERA_START_REPROCESS - }; - - private: - bool Handler(); - Utils::MessageQueue mCommandMsgQ; - OMXCameraAdapter* mCameraAdapter; - android::Mutex mLock; - }; - android::sp mCommandHandler; - -public: - - class OMXCallbackHandler : public android::Thread { - public: - OMXCallbackHandler(OMXCameraAdapter* ca) - : Thread(false), mCameraAdapter(ca) - { - mIsProcessed = true; - } - - virtual bool threadLoop() { - bool ret; - ret = Handler(); - return ret; - } - - status_t put(Utils::Message* msg){ - android::AutoMutex lock(mLock); - mIsProcessed = false; - return mCommandMsgQ.put(msg); - } - - void clearCommandQ() - { - android::AutoMutex lock(mLock); - mCommandMsgQ.clear(); - } - - void flush(); - - enum { - COMMAND_EXIT = -1, - CAMERA_FILL_BUFFER_DONE, - CAMERA_FOCUS_STATUS - }; - - private: - bool Handler(); - Utils::MessageQueue mCommandMsgQ; - OMXCameraAdapter* mCameraAdapter; - android::Mutex mLock; - android::Condition mCondition; - bool mIsProcessed; - }; - - android::sp mOMXCallbackHandler; - -private: - - //AF callback - status_t setFocusCallback(bool enabled); - - //OMX Capabilities data - static const CapResolution mImageCapRes []; -#ifndef OMAP_TUNA - static const CapResolution mImageCapResSS []; - static const CapResolution mImageCapResTB []; -#endif - static const CapResolution mPreviewRes []; -#ifndef OMAP_TUNA - static const CapResolution mPreviewResSS []; - static const CapResolution mPreviewResTB []; -#endif - static const CapResolution mPreviewPortraitRes []; - static const CapResolution mThumbRes []; - static const CapPixelformat mPixelformats []; -#ifndef OMAP_TUNA - static const userToOMX_LUT mFrameLayout []; - static const LUTtype mLayoutLUT; -#endif - static const CapCodingFormat mImageCodingFormat[]; - static const CapFramerate mFramerates []; - static const CapU32 mSensorNames[] ; - static const CapZoom mZoomStages []; - static const CapISO mISOStages []; - static const int SENSORID_IMX060; - static const int SENSORID_OV5650; - static const int SENSORID_OV5640; - static const int SENSORID_OV14825; - static const int SENSORID_S5K4E1GA; - static const int SENSORID_S5K6A1GX03; - static const CapU32 mFacing []; - static const userToOMX_LUT mAutoConvergence []; - static const LUTtype mAutoConvergenceLUT; - static const userToOMX_LUT mBracketingModes[]; - static const LUTtype mBracketingModesLUT; - - static const int FPS_MIN; - static const int FPS_MAX; - static const int FPS_MAX_EXTENDED; - - // OMX Camera defaults - static const char DEFAULT_ANTIBANDING[]; - static const char DEFAULT_BRIGHTNESS[]; - static const char DEFAULT_CONTRAST[]; - static const char DEFAULT_EFFECT[]; - static const char DEFAULT_EV_COMPENSATION[]; - static const char DEFAULT_EV_STEP[]; - static const char DEFAULT_EXPOSURE_MODE[]; - static const char DEFAULT_FLASH_MODE[]; - static const char DEFAULT_FOCUS_MODE_PREFERRED[]; - static const char DEFAULT_FOCUS_MODE[]; - static const char DEFAULT_IPP[]; - static const char DEFAULT_ISO_MODE[]; - static const char DEFAULT_JPEG_QUALITY[]; - static const char DEFAULT_THUMBNAIL_QUALITY[]; - static const char DEFAULT_THUMBNAIL_SIZE[]; - static const char DEFAULT_PICTURE_FORMAT[]; -#ifndef OMAP_TUNA - static const char DEFAULT_S3D_PICTURE_LAYOUT[]; -#endif - static const char DEFAULT_PICTURE_SIZE[]; -#ifndef OMAP_TUNA - static const char DEFAULT_PICTURE_SS_SIZE[]; - static const char DEFAULT_PICTURE_TB_SIZE[]; -#endif - static const char DEFAULT_PREVIEW_FORMAT[]; - static const char DEFAULT_FRAMERATE[]; -#ifndef OMAP_TUNA - static const char DEFAULT_S3D_PREVIEW_LAYOUT[]; -#endif - static const char DEFAULT_PREVIEW_SIZE[]; -#ifndef OMAP_TUNA - static const char DEFAULT_PREVIEW_SS_SIZE[]; - static const char DEFAULT_PREVIEW_TB_SIZE[]; -#endif - static const char DEFAULT_NUM_PREV_BUFS[]; - static const char DEFAULT_NUM_PIC_BUFS[]; - static const char DEFAULT_SATURATION[]; - static const char DEFAULT_SCENE_MODE[]; - static const char DEFAULT_SHARPNESS[]; - static const char * DEFAULT_VSTAB; - static const char * DEFAULT_VNF; - static const char DEFAULT_WB[]; - static const char DEFAULT_ZOOM[]; - static const char DEFAULT_MAX_FD_HW_FACES[]; - static const char DEFAULT_MAX_FD_SW_FACES[]; - static const char * DEFAULT_AE_LOCK; - static const char * DEFAULT_AWB_LOCK; -#ifdef OMAP_TUNA - static const char DEFAULT_FOCAL_LENGTH_PRIMARY[]; - static const char DEFAULT_FOCAL_LENGTH_SECONDARY[]; -#endif - static const char DEFAULT_HOR_ANGLE[]; - static const char DEFAULT_VER_ANGLE[]; - static const char DEFAULT_VIDEO_SIZE[]; - static const char DEFAULT_SENSOR_ORIENTATION[]; - static const char DEFAULT_AUTOCONVERGENCE_MODE[]; - static const char DEFAULT_MANUAL_CONVERGENCE[]; -#ifndef OMAP_TUNA - static const char * DEFAULT_MECHANICAL_MISALIGNMENT_CORRECTION_MODE; -#endif - static const char DEFAULT_EXIF_MODEL[]; - static const char DEFAULT_EXIF_MAKE[]; - - static const size_t MAX_FOCUS_AREAS; - -#ifdef CAMERAHAL_OMX_PROFILING - - static const char DEFAULT_PROFILE_PATH[]; - int mDebugProfile; - -#endif - - OMX_VERSIONTYPE mCompRevision; - - //OMX Component UUID - OMX_UUIDTYPE mCompUUID; - - //Current Focus distances - char mFocusDistNear[FOCUS_DIST_SIZE]; - char mFocusDistOptimal[FOCUS_DIST_SIZE]; - char mFocusDistFar[FOCUS_DIST_SIZE]; - char mFocusDistBuffer[FOCUS_DIST_BUFFER_SIZE]; - - // Current Focus areas - android::Vector > mFocusAreas; - mutable android::Mutex mFocusAreasLock; - - // Current Touch convergence areas - android::Vector > mTouchAreas; - mutable android::Mutex mTouchAreasLock; - - // Current Metering areas - android::Vector > mMeteringAreas; - mutable android::Mutex mMeteringAreasLock; - - OperatingMode mCapabilitiesOpMode; - CaptureMode mCapMode; - // TODO(XXX): Do we really need this lock? Let's - // try to merge temporal bracketing and burst - // capture later - mutable android::Mutex mBurstLock; - size_t mBurstFrames; - size_t mBurstFramesAccum; - size_t mBurstFramesQueued; - size_t mCapturedFrames; - bool mFlushShotConfigQueue; - - bool mMeasurementEnabled; - - //Exposure Bracketing - int mExposureBracketingValues[EXP_BRACKET_RANGE]; - int mExposureGainBracketingValues[EXP_BRACKET_RANGE]; - int mExposureGainBracketingModes[EXP_BRACKET_RANGE]; - size_t mExposureBracketingValidEntries; - OMX_BRACKETMODETYPE mExposureBracketMode; - - //Zoom Bracketing - int mZoomBracketingValues[ZOOM_BRACKET_RANGE]; - size_t mZoomBracketingValidEntries; - - static const uint32_t FACE_DETECTION_THRESHOLD; - mutable android::Mutex mFaceDetectionLock; - //Face detection status - bool mFaceDetectionRunning; - bool mFaceDetectionPaused; - bool mFDSwitchAlgoPriority; - - camera_face_t faceDetectionLastOutput[MAX_NUM_FACES_SUPPORTED]; - int faceDetectionNumFacesLastOutput; - int metadataLastAnalogGain; - int metadataLastExposureTime; - - //Geo-tagging - EXIFData mEXIFData; - - //Image post-processing - IPPMode mIPP; - - //jpeg Picture Quality - unsigned int mPictureQuality; - - //thumbnail resolution - unsigned int mThumbWidth, mThumbHeight; - - //thumbnail quality - unsigned int mThumbQuality; - - //variables holding the estimated framerate - float mFPS, mLastFPS; - - //automatically disable AF after a given amount of frames - unsigned int mFocusThreshold; - - //This is needed for the CTS tests. They falsely assume, that during - //smooth zoom the current zoom stage will not change within the - //zoom callback scope, which in a real world situation is not always the - //case. This variable will "simulate" the expected behavior - unsigned int mZoomParameterIdx; - - //current zoom - android::Mutex mZoomLock; - unsigned int mCurrentZoomIdx, mTargetZoomIdx, mPreviousZoomIndx; - bool mZoomUpdating, mZoomUpdate; - int mZoomInc; - bool mReturnZoomStatus; - static const int32_t ZOOM_STEPS []; - - //local copy - OMX_VERSIONTYPE mLocalVersionParam; - - unsigned int mPending3Asettings; - android::Mutex m3ASettingsUpdateLock; - Gen3A_settings mParameters3A; - const char *mPictureFormatFromClient; - - BrightnessMode mGBCE; - BrightnessMode mGLBCE; - - OMX_TI_CONFIG_3A_FACE_PRIORITY mFacePriority; - OMX_TI_CONFIG_3A_REGION_PRIORITY mRegionPriority; - - android::CameraParameters mParams; - CameraProperties::Properties* mCapabilities; - unsigned int mPictureRotation; - bool mWaitingForSnapshot; - bool mCaptureConfigured; - unsigned int mPendingCaptureSettings; - unsigned int mPendingPreviewSettings; - OMX_TI_ANCILLARYDATATYPE* mCaptureAncillaryData; - OMX_TI_WHITEBALANCERESULTTYPE* mWhiteBalanceData; - bool mReprocConfigured; - - //Temporal bracketing management data - bool mBracketingSet; - mutable android::Mutex mBracketingLock; - bool *mBracketingBuffersQueued; - int mBracketingBuffersQueuedCount; - int mLastBracetingBufferIdx; - bool mBracketingEnabled; - bool mZoomBracketingEnabled; - size_t mBracketingRange; - int mCurrentZoomBracketing; - android::CameraParameters mParameters; - -#ifdef CAMERAHAL_TUNA - bool mIternalRecordingHint; -#endif - - bool mOmxInitialized; - OMXCameraAdapterComponentContext mCameraAdapterParameters; - bool mFirstTimeInit; - - ///Semaphores used internally - Utils::Semaphore mInitSem; - Utils::Semaphore mFlushSem; - Utils::Semaphore mUsePreviewDataSem; - Utils::Semaphore mUsePreviewSem; - Utils::Semaphore mUseCaptureSem; - Utils::Semaphore mStartPreviewSem; - Utils::Semaphore mStopPreviewSem; - Utils::Semaphore mStartCaptureSem; - Utils::Semaphore mStopCaptureSem; - Utils::Semaphore mSwitchToLoadedSem; - Utils::Semaphore mSwitchToExecSem; - Utils::Semaphore mStopReprocSem; - Utils::Semaphore mUseReprocessSem; - - mutable android::Mutex mStateSwitchLock; - mutable android::Mutex mIdleStateSwitchLock; - - android::Vector mEventSignalQ; - android::Mutex mEventLock; - - OMX_STATETYPE mComponentState; - - OMX_TI_AUTOCONVERGENCEMODETYPE mAutoConv; - OMX_S32 mManualConv; - bool mVnfEnabled; - bool mVstabEnabled; - - int mSensorOrientation; - int mDeviceOrientation; - int mFaceOrientation; - bool mSensorOverclock; - - //Indicates if we should leave - //OMX_Executing state during - //stop-/startPreview - bool mOMXStateSwitch; - - int mFrameCount; - int mLastFrameCount; - unsigned int mIter; - nsecs_t mLastFPSTime; - android::Mutex mFrameCountMutex; - android::Condition mFirstFrameCondition; - - static const nsecs_t CANCEL_AF_TIMEOUT; - android::Mutex mCancelAFMutex; - android::Condition mCancelAFCond; - - android::Mutex mDoAFMutex; - android::Condition mDoAFCond; - - size_t mSensorIndex; - CodingMode mCodingMode; - - // Time source delta of ducati & system time - OMX_TICKS mTimeSourceDelta; - bool onlyOnce; - - Utils::Semaphore mCaptureSem; - bool mCaptureSignalled; - - OMX_BOOL mUserSetExpLock; - OMX_BOOL mUserSetWbLock; - -#ifdef CAMERAHAL_USE_RAW_IMAGE_SAVING - bool mRawCapture; - bool mYuvCapture; -#endif - - bool mSetFormatDone; - -#ifndef OMAP_TUNA - OMX_TI_DCCDATATYPE mDccData; - android::Mutex mDccDataLock; -#endif - - int mMaxZoomSupported; - android::Mutex mImageCaptureLock; - - bool mTunnelDestroyed; - bool mPreviewPortInitialized; - -}; - -} // namespace Camera -} // namespace Ti - -#endif //OMX_CAMERA_ADAPTER_H diff --git a/camera/inc/OMXCameraAdapter/OMXSceneModeTables.h b/camera/inc/OMXCameraAdapter/OMXSceneModeTables.h deleted file mode 100644 index d57843e..0000000 --- a/camera/inc/OMXCameraAdapter/OMXSceneModeTables.h +++ /dev/null @@ -1,553 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file OMXSceneModeTables.h -* -* This holds scene mode settings for different omx cameras. -* -*/ - -#include "OMX_TI_IVCommon.h" -#include "OMX_TI_Common.h" -#include "OMX_TI_Index.h" - -#ifndef OMXCAMERAADAPTER_SCENEMODES_H -#define OMXCAMERAADAPTER_SCENEMODES_H - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(array) (sizeof((array)) / sizeof((array)[0])) -#endif - -namespace Ti { -namespace Camera { - -struct SceneModesEntry { - OMX_SCENEMODETYPE scene; - OMX_IMAGE_FLASHCONTROLTYPE flash; - int focus; - OMX_WHITEBALCONTROLTYPE wb; -}; - -struct CameraToSensorModesLUTEntry { - const char* name; - const SceneModesEntry* Table; - const unsigned int size; -}; - -static const SceneModesEntry S5K4E1GA_SceneModesLUT [] = { - { OMX_Closeup, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlAutoMacro, - OMX_WhiteBalControlAuto }, - { OMX_Landscape, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Underwater, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlAutoLock, - OMX_WhiteBalControlSunLight }, - { OMX_Sport, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Mood, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlAutoLock, - OMX_WhiteBalControlAuto }, - { OMX_NightPortrait, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlPortrait, - OMX_WhiteBalControlAuto }, - { OMX_NightIndoor, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Fireworks, - OMX_IMAGE_FlashControlOn, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Document, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlAutoMacro, - OMX_WhiteBalControlAuto }, - { OMX_Barcode, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlAutoMacro, - OMX_WhiteBalControlAuto }, - { OMX_SuperNight, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Cine, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_OldFilm, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Action, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlAuto, - OMX_WhiteBalControlAuto }, - { OMX_TI_Beach, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlAutoLock, - OMX_WhiteBalControlAuto }, - { OMX_TI_Candlelight, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlIncandescent }, - { OMX_TI_Night, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlAuto, - OMX_WhiteBalControlAuto }, - { OMX_TI_Party, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlAuto, - OMX_WhiteBalControlAuto }, - { OMX_TI_Portrait, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlPortrait, - OMX_WhiteBalControlAuto }, - { OMX_TI_Snow, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlAutoLock, - OMX_WhiteBalControlAuto }, - { OMX_TI_Steadyphoto, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Sunset, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlAuto, - OMX_WhiteBalControlSunLight }, - { OMX_TI_Theatre, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, -}; - -static const SceneModesEntry S5K6A1GX03_SceneModesLUT [] = { - { OMX_Closeup, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Landscape, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Underwater, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlSunLight }, - { OMX_Sport, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_SnowBeach, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Mood, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_NightPortrait, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_NightIndoor, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Fireworks, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Document, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Barcode, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_SuperNight, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Cine, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_OldFilm, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Action, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Beach, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Candlelight, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlIncandescent }, - { OMX_TI_Night, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Party, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Portrait, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Snow, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Steadyphoto, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Sunset, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlSunLight }, - { OMX_TI_Theatre, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, -}; - -static const SceneModesEntry IMX060_SceneModesLUT [] = { - { OMX_Closeup, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlAutoMacro, - OMX_WhiteBalControlAuto }, - { OMX_Landscape, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlSunLight }, - { OMX_Underwater, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Sport, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_SnowBeach, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Mood, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_NightPortrait, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlPortrait, - OMX_WhiteBalControlAuto }, - { OMX_NightIndoor, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Fireworks, - OMX_IMAGE_FlashControlOn, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Document, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlAutoMacro, - OMX_WhiteBalControlAuto }, - { OMX_Barcode, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlAutoMacro, - OMX_WhiteBalControlAuto }, - { OMX_SuperNight, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlAutoInfinity, - OMX_WhiteBalControlAuto }, - { OMX_Cine, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_OldFilm, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Action, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Beach, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Candlelight, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlIncandescent }, - { OMX_TI_Night, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Party, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlAutoLock, - OMX_WhiteBalControlAuto }, - { OMX_TI_Portrait, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Snow, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Steadyphoto, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Sunset, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - ( OMX_WHITEBALCONTROLTYPE ) OMX_TI_WhiteBalControlSunset }, - { OMX_TI_Theatre, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, -}; - -static const SceneModesEntry OV5640_SceneModesLUT [] = { - { OMX_Closeup, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Landscape, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Underwater, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlSunLight }, - { OMX_Sport, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlAutoInfinity, - OMX_WhiteBalControlAuto }, - { OMX_SnowBeach, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Mood, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_NightPortrait, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_NightIndoor, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Fireworks, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Document, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Barcode, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_SuperNight, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Cine, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_OldFilm, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Action, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Beach, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Candlelight, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlIncandescent }, - { OMX_TI_Night, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Party, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Portrait, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Snow, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Steadyphoto, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Sunset, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Theatre, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, -}; - -static const SceneModesEntry OV5650_SceneModesLUT [] = { - { OMX_Closeup, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Landscape, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlSunLight }, - { OMX_Underwater, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Sport, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_SnowBeach, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Mood, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_NightPortrait, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlPortrait, - OMX_WhiteBalControlAuto }, - { OMX_NightIndoor, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Fireworks, - OMX_IMAGE_FlashControlOn, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Document, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_Barcode, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_SuperNight, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlAutoInfinity, - OMX_WhiteBalControlAuto }, - { OMX_Cine, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_OldFilm, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Action, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Beach, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Candlelight, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlIncandescent }, - { OMX_TI_Night, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Party, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlAutoLock, - OMX_WhiteBalControlAuto }, - { OMX_TI_Portrait, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Snow, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Steadyphoto, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, - { OMX_TI_Sunset, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FocusControlHyperfocal, - ( OMX_WHITEBALCONTROLTYPE ) OMX_TI_WhiteBalControlSunset }, - { OMX_TI_Theatre, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FocusControlHyperfocal, - OMX_WhiteBalControlAuto }, -}; - -static const CameraToSensorModesLUTEntry CameraToSensorModesLUT [] = { - { "S5K4E1GA", S5K4E1GA_SceneModesLUT, ARRAY_SIZE(S5K4E1GA_SceneModesLUT)}, - { "S5K6A1GX03", S5K6A1GX03_SceneModesLUT, ARRAY_SIZE(S5K6A1GX03_SceneModesLUT)}, - { "IMX060", IMX060_SceneModesLUT, ARRAY_SIZE(IMX060_SceneModesLUT)}, - { "OV5640", OV5640_SceneModesLUT, ARRAY_SIZE(OV5640_SceneModesLUT)}, - { "OV5650", OV5650_SceneModesLUT, ARRAY_SIZE(OV5650_SceneModesLUT)}, -}; - -} // namespace Camera -} // namespace Ti - -#endif diff --git a/camera/inc/SensorListener.h b/camera/inc/SensorListener.h deleted file mode 100644 index 44037b7..0000000 --- a/camera/inc/SensorListener.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @file SensorListener.h -* -* This defines API for camerahal to get sensor events -* -*/ - -#ifndef ANDROID_CAMERA_HARDWARE_SENSOR_LISTENER_H -#define ANDROID_CAMERA_HARDWARE_SENSOR_LISTENER_H - -#include -#include -#include -#include -#include - -#include "Common.h" - -namespace Ti { -namespace Camera { - -/** - * SensorListner class - Registers with sensor manager to get sensor events - */ - -typedef void (*orientation_callback_t) (uint32_t orientation, uint32_t tilt, void* cookie); - -class SensorLooperThread : public android::Thread { - public: - SensorLooperThread(android::Looper* looper) - : Thread(false) { - mLooper = android::sp(looper); - } - ~SensorLooperThread() { - mLooper.clear(); - } - - virtual bool threadLoop() { - int32_t ret = mLooper->pollOnce(-1); - return true; - } - - // force looper wake up - void wake() { - mLooper->wake(); - } - private: - android::sp mLooper; -}; - - -class SensorListener : public android::RefBase -{ -/* public - types */ -public: - typedef enum { - SENSOR_ACCELEROMETER = 1 << 0, - SENSOR_MAGNETIC_FIELD = 1 << 1, - SENSOR_GYROSCOPE = 1 << 2, - SENSOR_LIGHT = 1 << 3, - SENSOR_PROXIMITY = 1 << 4, - SENSOR_ORIENTATION = 1 << 5, - } sensor_type_t; -/* public - functions */ -public: - SensorListener(); - ~SensorListener(); - status_t initialize(); - void setCallbacks(orientation_callback_t orientation_cb, void *cookie); - void enableSensor(sensor_type_t type); - void disableSensor(sensor_type_t type); - void handleOrientation(uint32_t orientation, uint32_t tilt); -/* public - member variables */ -public: - android::sp mSensorEventQueue; -/* private - member variables */ -private: - int sensorsEnabled; - orientation_callback_t mOrientationCb; - void *mCbCookie; - android::sp mLooper; - android::sp mSensorLooperThread; - android::Mutex mLock; -}; - -} // namespace Camera -} // namespace Ti - -#endif diff --git a/camera/inc/TICameraParameters.h b/camera/inc/TICameraParameters.h deleted file mode 100644 index 95690f8..0000000 --- a/camera/inc/TICameraParameters.h +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TI_CAMERA_PARAMETERS_H -#define TI_CAMERA_PARAMETERS_H - -#include -#include - -namespace Ti { -namespace Camera { - -///TI Specific Camera Parameters -class TICameraParameters -{ -public: - -// Supported Camera indexes -// Example value: "0,1,2,3", where 0-primary, 1-secondary1, 2-secondary2, 3-sterocamera -static const char KEY_SUPPORTED_CAMERAS[]; -// Select logical Camera index -static const char KEY_CAMERA[]; -static const char KEY_CAMERA_NAME[]; -static const char KEY_BURST[]; -static const char KEY_CAP_MODE[]; -static const char KEY_CAP_MODE_VALUES[]; -static const char KEY_VNF[]; -static const char KEY_VNF_SUPPORTED[]; -static const char KEY_SATURATION[]; -static const char KEY_BRIGHTNESS[]; -static const char KEY_SUPPORTED_EXPOSURE[]; -static const char KEY_EXPOSURE_MODE[]; -static const char KEY_SUPPORTED_MANUAL_EXPOSURE_MIN[]; -static const char KEY_SUPPORTED_MANUAL_EXPOSURE_MAX[]; -static const char KEY_SUPPORTED_MANUAL_EXPOSURE_STEP[]; -static const char KEY_SUPPORTED_MANUAL_GAIN_ISO_MIN[]; -static const char KEY_SUPPORTED_MANUAL_GAIN_ISO_MAX[]; -static const char KEY_SUPPORTED_MANUAL_GAIN_ISO_STEP[]; -static const char KEY_MANUAL_EXPOSURE[]; -static const char KEY_MANUAL_EXPOSURE_RIGHT[]; -static const char KEY_MANUAL_GAIN_ISO[]; -static const char KEY_MANUAL_GAIN_ISO_RIGHT[]; -static const char KEY_CONTRAST[]; -static const char KEY_SHARPNESS[]; -static const char KEY_ISO[]; -static const char KEY_SUPPORTED_ISO_VALUES[]; -static const char KEY_SUPPORTED_IPP[]; -static const char KEY_IPP[]; -static const char KEY_METERING_MODE[]; -static const char KEY_EXP_BRACKETING_RANGE[]; -static const char KEY_EXP_GAIN_BRACKETING_RANGE[]; -static const char KEY_ZOOM_BRACKETING_RANGE[]; -static const char KEY_TEMP_BRACKETING[]; -static const char KEY_TEMP_BRACKETING_RANGE_POS[]; -static const char KEY_TEMP_BRACKETING_RANGE_NEG[]; -static const char KEY_FLUSH_SHOT_CONFIG_QUEUE[]; -static const char KEY_SHUTTER_ENABLE[]; -static const char KEY_MEASUREMENT_ENABLE[]; -static const char KEY_INITIAL_VALUES[]; -static const char KEY_GBCE[]; -static const char KEY_GBCE_SUPPORTED[]; -static const char KEY_GLBCE[]; -static const char KEY_GLBCE_SUPPORTED[]; -static const char KEY_FRAMERATE_RANGES_EXT_SUPPORTED[]; -static const char KEY_FRAMERATES_EXT_SUPPORTED[]; - -// TI recording hint to notify camera adapters of possible recording -static const char KEY_RECORDING_HINT[]; -static const char KEY_AUTO_FOCUS_LOCK[]; -static const char KEY_CURRENT_ISO[]; - -static const char KEY_SENSOR_ORIENTATION[]; - -//TI extensions for camera capabilies -static const char INITIAL_VALUES_TRUE[]; -static const char INITIAL_VALUES_FALSE[]; - -// TI extensions to add values for ManualConvergence and AutoConvergence mode -static const char KEY_AUTOCONVERGENCE_MODE[]; -static const char KEY_AUTOCONVERGENCE_MODE_VALUES[]; -static const char KEY_MANUAL_CONVERGENCE[]; -static const char KEY_SUPPORTED_MANUAL_CONVERGENCE_MIN[]; -static const char KEY_SUPPORTED_MANUAL_CONVERGENCE_MAX[]; -static const char KEY_SUPPORTED_MANUAL_CONVERGENCE_STEP[]; - -// TI extensions to add Min frame rate Values -static const char VIDEO_MINFRAMERATE_5[]; -static const char VIDEO_MINFRAMERATE_10[]; -static const char VIDEO_MINFRAMERATE_15[]; -static const char VIDEO_MINFRAMERATE_20[]; -static const char VIDEO_MINFRAMERATE_24[]; -static const char VIDEO_MINFRAMERATE_25[]; -static const char VIDEO_MINFRAMERATE_30[]; -static const char VIDEO_MINFRAMERATE_33[]; - -//TI extensions for setting EXIF tags -static const char KEY_EXIF_MODEL[]; -static const char KEY_EXIF_MAKE[]; - -//TI extensions for additional GPS data -static const char KEY_GPS_MAPDATUM[]; -static const char KEY_GPS_VERSION[]; -static const char KEY_GPS_DATESTAMP[]; - -// TI extensions for VTC -static const char KEY_VTC_HINT[]; -static const char KEY_VIDEO_ENCODER_HANDLE[]; -static const char KEY_VIDEO_ENCODER_SLICE_HEIGHT[]; - -static const char RAW_WIDTH[]; -static const char RAW_HEIGHT[]; - -//TI extensions to Image post-processing -static const char IPP_LDCNSF[]; -static const char IPP_LDC[]; -static const char IPP_NSF[]; -static const char IPP_NONE[]; - -//TI extensions to camera mode -static const char HIGH_PERFORMANCE_MODE[]; -static const char HIGH_QUALITY_MODE[]; -static const char HIGH_QUALITY_ZSL_MODE[]; -static const char CP_CAM_MODE[]; -static const char VIDEO_MODE[]; -static const char EXPOSURE_BRACKETING[]; -static const char ZOOM_BRACKETING[]; -static const char TEMP_BRACKETING[]; - -// TI extensions to standard android pixel formats -static const char PIXEL_FORMAT_UNUSED[]; -static const char PIXEL_FORMAT_JPS[]; -static const char PIXEL_FORMAT_MPO[]; -static const char PIXEL_FORMAT_YUV422I_UYVY[]; - -// TI extensions to standard android scene mode settings -static const char SCENE_MODE_CLOSEUP[]; -static const char SCENE_MODE_AQUA[]; -static const char SCENE_MODE_SNOWBEACH[]; -static const char SCENE_MODE_MOOD[]; -static const char SCENE_MODE_NIGHT_INDOOR[]; -static const char SCENE_MODE_DOCUMENT[]; -static const char SCENE_MODE_BARCODE[]; -static const char SCENE_MODE_VIDEO_SUPER_NIGHT[]; -static const char SCENE_MODE_VIDEO_CINE[]; -static const char SCENE_MODE_VIDEO_OLD_FILM[]; - -// TI extensions to standard android white balance settings. -static const char WHITE_BALANCE_TUNGSTEN[]; -static const char WHITE_BALANCE_HORIZON[]; -static const char WHITE_BALANCE_SUNSET[]; -static const char WHITE_BALANCE_FACE[]; - -// TI extensions to add exposure preset modes to android api -static const char EXPOSURE_MODE_MANUAL[]; -static const char EXPOSURE_MODE_AUTO[]; -static const char EXPOSURE_MODE_NIGHT[]; -static const char EXPOSURE_MODE_BACKLIGHT[]; -static const char EXPOSURE_MODE_SPOTLIGHT[]; -static const char EXPOSURE_MODE_SPORTS[]; -static const char EXPOSURE_MODE_SNOW[]; -static const char EXPOSURE_MODE_BEACH[]; -static const char EXPOSURE_MODE_APERTURE[]; -static const char EXPOSURE_MODE_SMALL_APERTURE[]; -static const char EXPOSURE_MODE_FACE[]; - -// TI extensions to standard android focus presets. -static const char FOCUS_MODE_PORTRAIT[]; -static const char FOCUS_MODE_EXTENDED[]; -static const char FOCUS_MODE_FACE[]; -static const char FOCUS_MODE_OFF[]; - -// TI extensions to add iso values -static const char ISO_MODE_AUTO[]; -static const char ISO_MODE_100[]; -static const char ISO_MODE_200[]; -static const char ISO_MODE_400[]; -static const char ISO_MODE_800[]; -static const char ISO_MODE_1000[]; -static const char ISO_MODE_1200[]; -static const char ISO_MODE_1600[]; - -// TI extensions to add values for effect settings. -static const char EFFECT_NATURAL[]; -static const char EFFECT_VIVID[]; -static const char EFFECT_COLOR_SWAP[]; -static const char EFFECT_BLACKWHITE[]; - -#ifndef OMAP_TUNA -//TI extensions for stereo frame layouts -static const char KEY_S3D_PRV_FRAME_LAYOUT[]; -static const char KEY_S3D_PRV_FRAME_LAYOUT_VALUES[]; -static const char KEY_S3D_CAP_FRAME_LAYOUT[]; -static const char KEY_S3D_CAP_FRAME_LAYOUT_VALUES[]; -#endif - -#ifndef OMAP_TUNA -//TI extensions for stereo frame layouts -static const char S3D_NONE[]; -static const char S3D_TB_FULL[]; -static const char S3D_SS_FULL[]; -static const char S3D_TB_SUBSAMPLED[]; -static const char S3D_SS_SUBSAMPLED[]; -#endif - -#ifndef OMAP_TUNA -//TI extentions fo 3D resolutions -static const char KEY_SUPPORTED_PICTURE_SUBSAMPLED_SIZES[]; -static const char KEY_SUPPORTED_PICTURE_TOPBOTTOM_SIZES[]; -static const char KEY_SUPPORTED_PICTURE_SIDEBYSIDE_SIZES[]; -static const char KEY_SUPPORTED_PREVIEW_SUBSAMPLED_SIZES[]; -static const char KEY_SUPPORTED_PREVIEW_TOPBOTTOM_SIZES[]; -static const char KEY_SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES[]; -#endif - -// TI extensions to add values for AutoConvergence settings. -static const char AUTOCONVERGENCE_MODE_DISABLE[]; -static const char AUTOCONVERGENCE_MODE_FRAME[]; -static const char AUTOCONVERGENCE_MODE_CENTER[]; -static const char AUTOCONVERGENCE_MODE_TOUCH[]; -static const char AUTOCONVERGENCE_MODE_MANUAL[]; - -//TI extensions for flash mode settings -static const char FLASH_MODE_FILL_IN[]; - -//TI extensions to add sensor orientation parameters -static const char ORIENTATION_SENSOR_NONE[]; -static const char ORIENTATION_SENSOR_90[]; -static const char ORIENTATION_SENSOR_180[]; -static const char ORIENTATION_SENSOR_270[]; - - -//TI values for camera direction -static const char FACING_FRONT[]; -static const char FACING_BACK[]; - -#ifndef OMAP_TUNA -static const char KEY_MECHANICAL_MISALIGNMENT_CORRECTION_SUPPORTED[]; -static const char KEY_MECHANICAL_MISALIGNMENT_CORRECTION[]; -#endif - -#ifndef OMAP_TUNA -//TI extensions for enable/disable algos -static const char KEY_ALGO_FIXED_GAMMA[]; -static const char KEY_ALGO_NSF1[]; -static const char KEY_ALGO_NSF2[]; -static const char KEY_ALGO_SHARPENING[]; -static const char KEY_ALGO_THREELINCOLORMAP[]; -static const char KEY_ALGO_GIC[]; -#endif - -}; - -} // namespace Camera -} // namespace Ti - -#endif diff --git a/camera/inc/V4LCameraAdapter/V4LCameraAdapter.h b/camera/inc/V4LCameraAdapter/V4LCameraAdapter.h deleted file mode 100644 index cf277ac..0000000 --- a/camera/inc/V4LCameraAdapter/V4LCameraAdapter.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - -#ifndef V4L_CAMERA_ADAPTER_H -#define V4L_CAMERA_ADAPTER_H - -#include - -#include "CameraHal.h" -#include "BaseCameraAdapter.h" -#include "DebugUtils.h" - -namespace Ti { -namespace Camera { - -#define DEFAULT_PIXEL_FORMAT V4L2_PIX_FMT_YUYV - -#define NB_BUFFER 10 -#define DEVICE "/dev/videoxx" -#define DEVICE_PATH "/dev/" -#define DEVICE_NAME "videoxx" - -typedef int V4L_HANDLETYPE; - -struct CapPixelformat { - uint32_t pixelformat; - const char *param; -}; - -struct CapResolution { - size_t width, height; - char param[10]; -}; - -struct CapU32 { - uint32_t num; - const char *param; -}; - -typedef CapU32 CapFramerate; - -struct VideoInfo { - struct v4l2_capability cap; - struct v4l2_format format; - struct v4l2_buffer buf; - struct v4l2_requestbuffers rb; - void *mem[NB_BUFFER]; - void *CaptureBuffers[NB_BUFFER]; - bool isStreaming; - int width; - int height; - int formatIn; - int framesizeIn; -}; - -typedef struct V4L_TI_CAPTYPE { - uint16_t ulPreviewFormatCount; // supported preview pixelformat count - uint32_t ePreviewFormats[32]; - uint16_t ulPreviewResCount; // supported preview resolution sizes - CapResolution tPreviewRes[32]; - uint16_t ulCaptureResCount; // supported capture resolution sizes - CapResolution tCaptureRes[32]; - uint16_t ulFrameRateCount; // supported frame rate - uint16_t ulFrameRates[32]; -}V4L_TI_CAPTYPE; - -/** - * Class which completely abstracts the camera hardware interaction from camera hal - * TODO: Need to list down here, all the message types that will be supported by this class - Need to implement BufferProvider interface to use AllocateBuffer of OMX if needed - */ -class V4LCameraAdapter : public BaseCameraAdapter -{ -public: - - /*--------------------Constant declarations----------------------------------------*/ - static const int32_t MAX_NO_BUFFERS = 20; - - ///@remarks OMX Camera has six ports - buffer input, time input, preview, image, video, and meta data - static const int MAX_NO_PORTS = 6; - - ///Five second timeout - static const int CAMERA_ADAPTER_TIMEOUT = 5000*1000; - -public: - - V4LCameraAdapter(size_t sensor_index); - ~V4LCameraAdapter(); - - - ///Initialzes the camera adapter creates any resources required - virtual status_t initialize(CameraProperties::Properties*); - - //APIs to configure Camera adapter and get the current parameter set - virtual status_t setParameters(const android::CameraParameters& params); - virtual void getParameters(android::CameraParameters& params); - - // API - virtual status_t UseBuffersPreview(CameraBuffer *bufArr, int num); - virtual status_t UseBuffersCapture(CameraBuffer *bufArr, int num); - - static status_t getCaps(const int sensorId, CameraProperties::Properties* params, V4L_HANDLETYPE handle); - -protected: - -//----------Parent class method implementation------------------------------------ - virtual status_t startPreview(); - virtual status_t stopPreview(); - virtual status_t takePicture(); - virtual status_t stopImageCapture(); - virtual status_t autoFocus(); - virtual status_t useBuffers(CameraMode mode, CameraBuffer *bufArr, int num, size_t length, unsigned int queueable); - virtual status_t fillThisBuffer(CameraBuffer *frameBuf, CameraFrame::FrameType frameType); - virtual status_t getFrameSize(size_t &width, size_t &height); - virtual status_t getPictureBufferSize(CameraFrame *frame, size_t bufferCount); - virtual status_t getFrameDataSize(size_t &dataFrameSize, size_t bufferCount); - virtual void onOrientationEvent(uint32_t orientation, uint32_t tilt); -//----------------------------------------------------------------------------- - - -private: - - class PreviewThread : public android::Thread { - V4LCameraAdapter* mAdapter; - public: - PreviewThread(V4LCameraAdapter* hw) : - Thread(false), mAdapter(hw) { } - virtual void onFirstRef() { - run("CameraPreviewThread", android::PRIORITY_URGENT_DISPLAY); - } - virtual bool threadLoop() { - mAdapter->previewThread(); - // loop until we need to quit - return true; - } - }; - - //Used for calculation of the average frame rate during preview - status_t recalculateFPS(); - - char * GetFrame(int &index); - - int previewThread(); - -public: - -private: - //capabilities data - static const CapPixelformat mPixelformats []; - static const CapResolution mPreviewRes []; - static const CapFramerate mFramerates []; - static const CapResolution mImageCapRes []; - - //camera defaults - static const char DEFAULT_PREVIEW_FORMAT[]; - static const char DEFAULT_PREVIEW_SIZE[]; - static const char DEFAULT_FRAMERATE[]; - static const char DEFAULT_NUM_PREV_BUFS[]; - - static const char DEFAULT_PICTURE_FORMAT[]; - static const char DEFAULT_PICTURE_SIZE[]; - static const char DEFAULT_FOCUS_MODE[]; - static const char * DEFAULT_VSTAB; - static const char * DEFAULT_VNF; - - static status_t insertDefaults(CameraProperties::Properties*, V4L_TI_CAPTYPE&); - static status_t insertCapabilities(CameraProperties::Properties*, V4L_TI_CAPTYPE&); - static status_t insertPreviewFormats(CameraProperties::Properties* , V4L_TI_CAPTYPE&); - static status_t insertPreviewSizes(CameraProperties::Properties* , V4L_TI_CAPTYPE&); - static status_t insertImageSizes(CameraProperties::Properties* , V4L_TI_CAPTYPE&); - static status_t insertFrameRates(CameraProperties::Properties* , V4L_TI_CAPTYPE&); - static status_t sortAscend(V4L_TI_CAPTYPE&, uint16_t ) ; - - status_t v4lIoctl(int, int, void*); - status_t v4lInitMmap(int&); - status_t v4lInitUsrPtr(int&); - status_t v4lStartStreaming(); - status_t v4lStopStreaming(int nBufferCount); - status_t v4lSetFormat(int, int, uint32_t); - status_t restartPreview(); - - - int mPreviewBufferCount; - int mPreviewBufferCountQueueable; - int mCaptureBufferCount; - int mCaptureBufferCountQueueable; - android::KeyedVector mPreviewBufs; - android::KeyedVector mCaptureBufs; - mutable android::Mutex mPreviewBufsLock; - mutable android::Mutex mCaptureBufsLock; - mutable android::Mutex mStopPreviewLock; - - android::CameraParameters mParams; - - bool mPreviewing; - bool mCapturing; - android::Mutex mLock; - - int mFrameCount; - int mLastFrameCount; - unsigned int mIter; - nsecs_t mLastFPSTime; - - //variables holding the estimated framerate - float mFPS, mLastFPS; - - int mSensorIndex; - - // protected by mLock - android::sp mPreviewThread; - - struct VideoInfo *mVideoInfo; - int mCameraHandle; - - int nQueued; - int nDequeued; - -}; - -} // namespace Camera -} // namespace Ti - -#endif //V4L_CAMERA_ADAPTER_H diff --git a/camera/inc/VideoMetadata.h b/camera/inc/VideoMetadata.h deleted file mode 100644 index f05ee50..0000000 --- a/camera/inc/VideoMetadata.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef VIDEO_METADATA_H -#define VIDEO_METADATA_H - -/* This structure is used to pass buffer offset from Camera-Hal to Encoder component - * for specific algorithms like VSTAB & VNF - */ - -typedef struct -{ - int metadataBufferType; - void* handle; - int offset; -} -video_metadata_t; - -#endif diff --git a/domx/Android.mk b/domx/Android.mk deleted file mode 100644 index 6571161..0000000 --- a/domx/Android.mk +++ /dev/null @@ -1 +0,0 @@ -include $(all-subdir-makefiles) diff --git a/domx/Makefile b/domx/Makefile deleted file mode 100644 index f6fb3f0..0000000 --- a/domx/Makefile +++ /dev/null @@ -1,89 +0,0 @@ -# -# Copyright 2001-2008 Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ---------------------------------------------------------------------------- -# Revision History -# -# -# SEP xx,2002 REF=ORG Swamy MC -# Original version. -# ---------------------------------------------------------------------------- - -#PROJROOT = $(ROOTDIR)/src - -include $(PROJROOT)/make/start.mk - -# Do not change above "include" line(s) - -# Arguments to tools, will move to make system once finalized. - -CFLAGS = -CDEFS = DEBUG - -EXEC_ARGS = -ST_LIB_ARGS = -SH_LIB_ARGS = - -# Define this macro if target runs in kernel mode -#__KERNEL__ = 1 - -# Target name and extension -# static library (ST_LIB): filename.a -# shared library soname (SH_LIB): filename.so.maj_ver.min_ver -# executable (EXEC) : filename.out - -TARGETNAME = - - -# TARGETTYPE must be EXEC, ST_LIB or SH_LIB in upper case. -#TARGETTYPE = ST_LIB -TARGETTYPE = - -# For shared object library, soname is filename.so.maj_ver -SH_SONAME = - -# Folders in which gmake will run before building current target - -SUBMODULES = \ -mm_osal \ -omx_core \ -domx \ -omx_proxy_component \ - -#video/omx_proxy_component/test - -# Filename must not begin with '.', '/' or '\' - -SOURCES = - -# Search path for include files - -INCLUDES = - -# Libraries needed for linking. - -ST_LIBS = -SH_LIBS = - -# Search path for library (and linker command) files. -# Current folder and target folder are included by default. - -LIBINCLUDES = - - -# Do not change below "include" line(s) - -include $(PROJROOT)/make/build.mk - diff --git a/domx/domx/Android.mk b/domx/domx/Android.mk deleted file mode 100644 index 036b479..0000000 --- a/domx/domx/Android.mk +++ /dev/null @@ -1,41 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - omx_rpc/src/omx_rpc.c \ - omx_rpc/src/omx_rpc_skel.c \ - omx_rpc/src/omx_rpc_stub.c \ - omx_rpc/src/omx_rpc_config.c \ - omx_rpc/src/omx_rpc_platform.c \ - omx_proxy_common/src/omx_proxy_common.c \ - profiling/src/profile.c - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/omx_rpc/inc \ - $(LOCAL_PATH)/../omx_core/inc \ - $(LOCAL_PATH)/../mm_osal/inc \ - $(LOCAL_PATH)/profiling/inc \ - $(DEVICE_FOLDER)/hwc/ \ - $(DEVICE_FOLDER)/libion_ti/ \ - system/core/include/cutils \ - hardware/libhardware/include \ - frameworks/native/include/media/openmax - -LOCAL_CFLAGS += -D_Android -DENABLE_GRALLOC_BUFFERS -DANDROID_QUIRK_LOCK_BUFFER -DUSE_ENHANCED_PORTRECONFIG -DUSE_ION - -ifneq ($(DEBUG_FORCE_STRICT_ALIASING),true) - LOCAL_CFLAGS += -fno-strict-aliasing -endif - -LOCAL_SHARED_LIBRARIES := \ - libmm_osal \ - libc \ - liblog \ - libion_ti \ - libcutils - -LOCAL_MODULE := libdomx -LOCAL_MODULE_TAGS := optional - -include $(BUILD_SHARED_LIBRARY) diff --git a/domx/domx/Makefile b/domx/domx/Makefile deleted file mode 100644 index cab0b80..0000000 --- a/domx/domx/Makefile +++ /dev/null @@ -1,111 +0,0 @@ -# -# Copyright (C) Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ---------------------------------------------------------------------------- -# Revision History -# -# -# REF=ORG -# Original version. -# ---------------------------------------------------------------------------- - -#PROJROOT = .. - -include $(PROJROOT)/make/start.mk - -# Do not change above "include" line(s) - -# Arguments to tools, will move to make system once finalized. - -CFLAGS = -CDEFS = -ifeq ($(BUILD),udeb) -CDEFS += DEBUG -endif -CDEFS += - -EXEC_ARGS = -ST_LIB_ARGS = -SH_LIB_ARGS = - -# Define this macro if target runs in kernel mode -#__KERNEL__ = 1 - -# Target name and extension -# static library (ST_LIB): filename.a -# shared library soname (SH_LIB): filename.so.maj_ver.min_ver -# executable (EXEC) : filename.out - -TARGETNAME = libdomx - - -# TARGETTYPE must be EXEC, ST_LIB or SH_LIB in upper case. - -TARGETTYPE = SH_LIB - -# install directory relative to the HOSTTARGET directory -HOSTRELEASE = lib - -# install directory relative to the root filesystem -ROOTFSRELEASE = lib - -# Folders in which gmake will run before building current target - -SUBMODULES = \ - -# Filename must not begin with '.', '/' or '\' - -SOURCES = \ -omx_rpc/src/omx_rpc.c \ -omx_rpc/src/omx_rpc_skel.c \ -omx_rpc/src/omx_rpc_stub.c \ -omx_proxy_common/src/omx_proxy_common.c \ -profiling/profile.c -# The below files are currently empty, so removed them from building -# omx_rpc/src/omx_rpc_config.c \ -# omx_rpc/src/omx_rpc_platform.c \ - -# Search path for include files - -INCLUDES = \ - $(PROJROOT)/omx_core/inc \ - $(PROJROOT)/mm_osal/inc \ - $(PROJROOT)/domx \ - $(PROJROOT)/domx/omx_rpc \ - $(PROJROOT)/domx/omx_rpc/inc \ - ../../memmgrheaders \ - - -# Libraries needed for linking. - -ST_LIBS = -#mm_osal -SH_LIBS = omx_core mm_osal -#rcm ipc -#pthread rt utils procmgr ipc rcm notify -#SH_LIBS += sysmgr sysmemmgr - - -# Search path for library (and linker command) files. -# Current folder and target folder are included by default. - -LIBINCLUDES = $(PROJROOT)/mm_osal \ - $(PROJROOT)/omx_core - - -# Do not change below "include" line(s) - -include $(PROJROOT)/make/build.mk - diff --git a/domx/domx/memmgr_rpc/src/Android.mk b/domx/domx/memmgr_rpc/src/Android.mk deleted file mode 100755 index 5b61884..0000000 --- a/domx/domx/memmgr_rpc/src/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -HARDWARE_TI_OMAP4_BASE := hardware/ti/omap4xxx - -LOCAL_SRC_FILES := \ - memmgr_rpc.c - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../inc \ - $(LOCAL_PATH)/../../ \ - $(LOCAL_PATH)/../../omx_rpc/inc \ - $(LOCAL_PATH)/../../../domx \ - $(HARDWARE_TI_OMAP4_BASE)/omx/ducati/domx/system/omx_core/inc \ - $(HARDWARE_TI_OMAP4_BASE)/omx/ducati/domx/system/mm_osal/inc \ - $(HARDWARE_TI_OMAP4_BASE)/tiler \ - $(HARDWARE_TI_OMAP4_BASE)/syslink/syslink/d2c \ - $(HARDWARE_TI_OMAP4_BASE)/syslink/syslink/api/include - -LOCAL_CFLAGS += -D_Android - -LOCAL_SHARED_LIBRARIES := \ - libOMX_CoreOsal \ - libipcutils \ - libsysmgr \ - libipc \ - librcm \ - libnotify \ - libc \ - liblog \ - libd2cmap - -LOCAL_MODULE := libmemmgr_rpc - -include $(BUILD_SHARED_LIBRARY) diff --git a/domx/domx/omx_proxy_common.h b/domx/domx/omx_proxy_common.h deleted file mode 100755 index 7c7d6c8..0000000 --- a/domx/domx/omx_proxy_common.h +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_proxy_common.h - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework OMX Common Proxy. - * - * @path \WTSD_DucatiMMSW\framework\domx\omx_proxy_common\ - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 29-Mar-2010 Abhishek Ranka : Revamped DOMX implementation - *! - *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version - *================================================================*/ - -#ifdef ANDROID_QUIRK_LOCK_BUFFER -#include -#endif - -#ifndef OMX_PROXY_H -#define OMX_PROXY_H - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/* ------compilation control switches ----------------------------------------*/ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -/* ----- system and platform files ----------------------------*/ -#include -/*-------program files ----------------------------------------*/ -#include "omx_rpc.h" -#include "omx_rpc_internal.h" -#include "omx_rpc_utils.h" - -/**************************************************************** - * PUBLIC DECLARATIONS Defined here, used elsewhere - ****************************************************************/ -/*--------data declarations -----------------------------------*/ -/*OMX versions supported by DOMX*/ -#define OMX_VER_MAJOR 0x1 -#define OMX_VER_MINOR 0x1 - -#define MAX_NUM_PROXY_BUFFERS 100 -#define MAX_COMPONENT_NAME_LENGTH 128 -#define PROXY_MAXNUMOFPORTS 8 - -/****************************************************************** - * MACROS - ASSERTS - ******************************************************************/ -#define PROXY_assert PROXY_paramCheck -#define PROXY_require PROXY_paramCheck -#define PROXY_ensure PROXY_paramCheck - -#define PROXY_paramCheck(C, V, S) do {\ - if (!(C)) { eError = V;\ - if(S) DOMX_ERROR("failed check:" #C" - returning error: 0x%x - %s",V,S);\ - else DOMX_ERROR("failed check:" #C" - returning error: 0x%x",V); \ - goto EXIT; }\ - } while(0) - -#define PROXY_CHK_VERSION(_pStruct_, _sName_) do { \ - PROXY_require((((_sName_ *)_pStruct_)->nSize == sizeof(_sName_)), \ - OMX_ErrorBadParameter, "Incorrect nSize"); \ - PROXY_require(((((_sName_ *)_pStruct_)->nVersion.s.nVersionMajor == \ - OMX_VER_MAJOR) && \ - ((((_sName_ *)_pStruct_)->nVersion.s.nVersionMinor == \ - OMX_VER_MINOR) || \ - (((_sName_ *)_pStruct_)->nVersion.s.nVersionMinor == \ - 0))), \ - OMX_ErrorVersionMismatch, NULL); \ - } while(0) - -#define PROXY_checkRpcError() do { \ - if (eRPCError == RPC_OMX_ErrorNone) \ - { \ - DOMX_DEBUG("Corresponding RPC function executed successfully"); \ - eError = eCompReturn; \ - PROXY_assert((eError == OMX_ErrorNone) || (eError == OMX_ErrorNoMore), eError, "Error returned from OMX API in ducati"); \ - } else \ - { \ - DOMX_ERROR("RPC function returned error 0x%x", eRPCError); \ - switch (eRPCError) \ - { \ - case RPC_OMX_ErrorHardware: \ - eError = OMX_ErrorHardware; \ - break; \ - case RPC_OMX_ErrorInsufficientResources: \ - eError = OMX_ErrorInsufficientResources; \ - break; \ - case RPC_OMX_ErrorBadParameter: \ - eError = OMX_ErrorBadParameter; \ - break; \ - case RPC_OMX_ErrorUnsupportedIndex: \ - eError = OMX_ErrorUnsupportedIndex; \ - break; \ - case RPC_OMX_ErrorTimeout: \ - eError = OMX_ErrorTimeout; \ - break; \ - default: \ - eError = OMX_ErrorUndefined; \ - } \ - PROXY_assert((eError == OMX_ErrorNone), eError, "Error returned from OMX API in ducati"); \ - } \ -} while(0) - - typedef OMX_ERRORTYPE(*PROXY_EMPTYBUFFER_DONE) (OMX_HANDLETYPE - hComponent, OMX_U32 remoteBufHdr, OMX_U32 nfilledLen, - OMX_U32 nOffset, OMX_U32 nFlags); - - typedef OMX_ERRORTYPE(*PROXY_FILLBUFFER_DONE) (OMX_HANDLETYPE - hComponent, OMX_U32 remoteBufHdr, OMX_U32 nfilledLen, - OMX_U32 nOffset, OMX_U32 nFlags, OMX_TICKS nTimeStamp, - OMX_HANDLETYPE hMarkTargetComponent, OMX_PTR pMarkData); - - typedef OMX_ERRORTYPE(*PROXY_EVENTHANDLER) (OMX_HANDLETYPE hComponent, - OMX_PTR pAppData, OMX_EVENTTYPE eEvent, OMX_U32 nData1, - OMX_U32 nData2, OMX_PTR pEventData); - -/******************************************************************************* -* Structures -*******************************************************************************/ -/*===============================================================*/ -/** PROXY_BUFFER_INFO : This structure maintains a table of A9 and - * Ducati side buffers and headers. - * - * @param pBufHeader : This is a pointer to the A9 bufferheader. - * - * @param pBufHeaderRemote : This is pointer to Ducati side bufferheader. - * - * @param pRegisteredAufBux0 - * @param pRegisteredAufBux1 - * @param pRegisteredAufBux2 : These are pointers to buffers registered with rpc driver - * They will assigned when registering and used when - * unregistering the buffer - */ -/*===============================================================*/ - typedef struct PROXY_BUFFER_INFO - { - OMX_BUFFERHEADERTYPE *pBufHeader; - OMX_U32 pBufHeaderRemote; - OMX_PTR pYBuffer; - OMX_PTR pMetaDataBuffer; -#ifdef USE_ION - int mmap_fd; - int mmap_fd_metadata_buff; - OMX_PTR pRegisteredAufBux0; - OMX_PTR pRegisteredAufBux1; - OMX_PTR pRegisteredAufBux2; -#endif - } PROXY_BUFFER_INFO; - -/*===============================================================*/ -/** PROXY_BUFFER_TYPE : This enumeration tells the type of buffer pointers coming to OMX in - UseBuffer call. - */ -/*===============================================================*/ - typedef enum PROXY_BUFFER_TYPE - { - VirtualPointers, /*Used when buffer pointers come from the normal A9 virtual space */ - GrallocPointers, /*Used when buffer pointers come from Gralloc allocations */ - IONPointers, /*Used when buffer pointers come from ION allocations */ - EncoderMetadataPointers, /*Used when buffer pointers come from Stagefright in camcorder usecase */ - BufferDescriptorVirtual2D /*Virtual unpacked buffers passed via OMX_TI_BUFFERDESCRIPTOR_TYPE */ - } PROXY_BUFFER_TYPE; - -/*===============================================================*/ -/** PROXY_BUFFER_TYPE : This enumeration tells the type of buffer pointers coming to OMX in - UseBuffer call. - */ -/*===============================================================*/ - typedef struct PROXY_PORT_TYPE - { - PROXY_BUFFER_TYPE proxyBufferType; /*Used when buffer pointers come from the normal A9 virtual space */ - OMX_U32 IsBuffer2D; /*Used when buffer pointers come from Gralloc allocations */ - } PROXY_PORT_TYPE; - -#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY -/*===============================================================*/ -/** DebugFrame_Dump : Structure holding the info about frames to dump - * @param fromFrame: From which frame to start dumping - * @param toFrame: till which frame to dump - * @param frame_width: Width of the frame - * @param frame_height: Height of the frame - * @param padded_width: Width of the buffer - * @param padded_height: Height of the buffer - * @param stride: Stride of the Buffer - * @param runningFrame: running counter to track the frames - */ -/*===============================================================*/ - typedef struct DebugFrame_Dump - { - OMX_S32 fromFrame; - OMX_S32 toFrame; - OMX_U32 frame_width; - OMX_U32 frame_height; - OMX_U32 frame_xoffset; - OMX_U32 frame_yoffset; - OMX_U32 stride; - OMX_S32 runningFrame; - OMX_U32 *y_uv[2]; - }DebugFrame_Dump; -#endif - -/* ========================================================================== */ -/** -* PROXY_COMPONENT_PRIVATE -* -*/ -/* ========================================================================== */ - typedef struct PROXY_COMPONENT_PRIVATE - { - /* OMX Related Information */ - OMX_CALLBACKTYPE tCBFunc; - OMX_PTR pILAppData; - OMX_HANDLETYPE hRemoteComp; - - PROXY_BUFFER_INFO tBufList[MAX_NUM_PROXY_BUFFERS]; - PROXY_PORT_TYPE proxyPortBuffers[PROXY_MAXNUMOFPORTS]; - OMX_BOOL IsLoadedState; - OMX_U32 nTotalBuffers; - OMX_U32 nAllocatedBuffers; - - /* PROXY specific data - PROXY PRIVATE DATA */ - OMX_PTR pCompProxyPrv; - char *cCompName; - - PROXY_EMPTYBUFFER_DONE proxyEmptyBufferDone; - PROXY_FILLBUFFER_DONE proxyFillBufferDone; - PROXY_EVENTHANDLER proxyEventHandler; - -#ifdef ANDROID_QUIRK_LOCK_BUFFER - gralloc_module_t const *grallocModule; -#endif -#ifdef USE_ION - int ion_fd; - OMX_BOOL bUseIon; - OMX_BOOL bMapIonBuffers; -#endif -#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY - DebugFrame_Dump debugframeInfo; -#endif - int secure_misc_drv_fd; - } PROXY_COMPONENT_PRIVATE; - - - -/*===============================================================*/ -/** PROXY_MARK_DATA : A pointer to this structure is sent as mark data to - * the remote core when a MarkBuffer command is made. - * - * @param hComponentActual : This is the actual handle of the component to be - * marked. When marked buffers come from the remote - * to the local core then remote handle of the mark - * component is replaced by this in the header. - * - * @param pMarkdataActual : This is the mark data set by the client. - */ -/*===============================================================*/ - typedef struct PROXY_MARK_DATA - { - OMX_HANDLETYPE hComponentActual; - OMX_PTR pMarkDataActual; - } PROXY_MARK_DATA; -/******************************************************************************* -* Functions -*******************************************************************************/ - OMX_ERRORTYPE OMX_ProxyCommonInit(OMX_HANDLETYPE hComponent); - OMX_ERRORTYPE PROXY_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct); - OMX_ERRORTYPE PROXY_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct); - OMX_ERRORTYPE PROXY_EventHandler(OMX_HANDLETYPE hComponent, - OMX_PTR pAppData, OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2, - OMX_PTR pEventData); - OMX_ERRORTYPE PROXY_SendCommand(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_COMMANDTYPE eCmd, - OMX_IN OMX_U32 nParam, OMX_IN OMX_PTR pCmdData); - OMX_ERRORTYPE PROXY_EmptyThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr); - OMX_ERRORTYPE PROXY_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE * pIndexType); - OMX_ERRORTYPE PROXY_FillBufferDone(OMX_HANDLETYPE hComponent, - OMX_U32 remoteBufHdr, OMX_U32 nfilledLen, OMX_U32 nOffset, OMX_U32 nFlags, - OMX_TICKS nTimeStamp, OMX_HANDLETYPE hMarkTargetComponent, - OMX_PTR pMarkData); - OMX_ERRORTYPE PROXY_FillThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr); - OMX_ERRORTYPE PROXY_AllocateBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr,OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, OMX_IN OMX_U32 nSizeBytes); - OMX_ERRORTYPE PROXY_FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_BUFFERHEADERTYPE * pBufferHdr); - OMX_ERRORTYPE PROXY_ComponentDeInit(OMX_HANDLETYPE hComponent); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/domx/domx/omx_proxy_common/src/omx_proxy_common.c b/domx/domx/omx_proxy_common/src/omx_proxy_common.c deleted file mode 100644 index b1df157..0000000 --- a/domx/domx/omx_proxy_common/src/omx_proxy_common.c +++ /dev/null @@ -1,2563 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_proxy_common.c - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework OMX Common Proxy . - * - * @path \WTSD_DucatiMMSW\framework\domx\omx_proxy_common\src - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 29-Mar-2010 Abhishek Ranka : Revamped DOMX implementation - *! - *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version - *================================================================*/ - -/* ------compilation control switches ----------------------------------------*/ -#define TILER_BUFF -#define ALLOCATE_TILER_BUFFER_IN_PROXY -// This has been enabled enbled only in Android.mk -// #define ENABLE_GRALLOC_BUFFER -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -/* ----- system and platform files ----------------------------*/ -#include - -#include "timm_osal_memory.h" -#include "timm_osal_mutex.h" -#include "OMX_TI_Common.h" -#include "OMX_TI_Index.h" -#include "OMX_TI_Core.h" -/*-------program files ----------------------------------------*/ -#include "omx_proxy_common.h" -#include "omx_rpc.h" -#include "omx_rpc_stub.h" -#include "omx_rpc_utils.h" -#include "OMX_TI_IVCommon.h" -#include "profile.h" - -#ifdef ALLOCATE_TILER_BUFFER_IN_PROXY - -#ifdef USE_ION -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#endif - -#ifdef ENABLE_GRALLOC_BUFFERS -#include "native_handle.h" -#include "hal_public.h" -#endif - -#ifdef TILER_BUFF -#define PortFormatIsNotYUV 0 - -static OMX_ERRORTYPE _RPC_IsProxyComponent(OMX_HANDLETYPE hComponent, - OMX_BOOL * bIsProxy); -OMX_ERRORTYPE RPC_UTIL_GetStride(OMX_COMPONENTTYPE * hRemoteComp, - OMX_U32 nPortIndex, OMX_U32 * nStride); -OMX_ERRORTYPE RPC_UTIL_GetNumLines(OMX_COMPONENTTYPE * hComp, - OMX_U32 nPortIndex, OMX_U32 * nNumOfLines); - -#endif - -#ifdef ALLOCATE_TILER_BUFFER_IN_PROXY - -static OMX_ERRORTYPE PROXY_UseBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr, - OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_PTR pAppPrivate, - OMX_IN OMX_U32 nSizeBytes, OMX_IN OMX_U8 * pBuffer); -#endif - -#define LINUX_PAGE_SIZE 4096 -#define MAXNAMESIZE 128 - -#define CORE_MAX 4 -#define CORE_CHIRON 3 -#define CORE_SYSM3 2 -#define CORE_APPM3 1 -#define CORE_TESLA 0 - -#define MAX_CORENAME_LENGTH 32 -char Core_Array[][MAX_CORENAME_LENGTH] = - { "TESLA", "DUCATI1", "DUCATI0", "CHIRON" }; - -/****************************************************************** - * MACROS - LOCAL - ******************************************************************/ - -#ifdef USE_ION - - -RPC_OMX_ERRORTYPE RPC_RegisterBuffer(OMX_HANDLETYPE hRPCCtx, int fd, - OMX_PTR *handle1, OMX_PTR *handle2, - PROXY_BUFFER_TYPE proxyBufferType) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - int status; - RPC_OMX_CONTEXT *pRPCCtx = (RPC_OMX_CONTEXT *) hRPCCtx; - - if ((fd < 0) || (handle1 == NULL) || - ((proxyBufferType == GrallocPointers) && (handle2 == NULL))) { - eRPCError = RPC_OMX_ErrorBadParameter; - goto EXIT; - } - - if (proxyBufferType != GrallocPointers) { - struct ion_fd_data ion_data; - - ion_data.fd = fd; - ion_data.handle = NULL; - status = ioctl(pRPCCtx->fd_omx, OMX_IOCIONREGISTER, &ion_data); - if (status < 0) { - DOMX_ERROR("RegisterBuffer ioctl call failed"); - eRPCError = RPC_OMX_ErrorInsufficientResources; - goto EXIT; - } - if (ion_data.handle) - *handle1 = ion_data.handle; - } else { -#ifdef OMX_IOCPVRREGISTER - struct omx_pvr_data pvr_data; - - pvr_data.fd = fd; - memset(pvr_data.handles, 0x0, sizeof(pvr_data.handles)); - status = ioctl(pRPCCtx->fd_omx, OMX_IOCPVRREGISTER, &pvr_data); - if (status < 0) { - if (errno == ENOTTY) { - DOMX_DEBUG("OMX_IOCPVRREGISTER not supported with current kernel version"); - } else { - DOMX_ERROR("RegisterBuffer ioctl call failed"); - eRPCError = RPC_OMX_ErrorInsufficientResources; - } - goto EXIT; - } - - if (pvr_data.handles[0]) - *handle1 = pvr_data.handles[0]; - if (pvr_data.handles[1]) - *handle2 = pvr_data.handles[1]; -#endif - } - - - EXIT: - return eRPCError; -} - -RPC_OMX_ERRORTYPE RPC_UnRegisterBuffer(OMX_HANDLETYPE hRPCCtx, OMX_PTR handle) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - int status; - struct ion_fd_data data; - RPC_OMX_CONTEXT *pRPCCtx = (RPC_OMX_CONTEXT *) hRPCCtx; - - if (handle == NULL) { - eRPCError = RPC_OMX_ErrorBadParameter; - goto EXIT; - } - - data.handle = handle; - status = ioctl(pRPCCtx->fd_omx, OMX_IOCIONUNREGISTER, &data); - if (status < 0) { - eRPCError = RPC_OMX_ErrorInsufficientResources; - goto EXIT; - } - - EXIT: - return eRPCError; -} - -static OMX_ERRORTYPE PROXY_AllocateBufferIonCarveout(PROXY_COMPONENT_PRIVATE *pCompPrv, - size_t len, struct ion_handle **handle) -{ - int fd; - int ret; - struct ion_handle *temp; - size_t stride; - - ret = ion_alloc(pCompPrv->ion_fd, len, 0x1000, 1 << ION_HEAP_TYPE_CARVEOUT, &temp); - - if (ret || ((int)temp == -ENOMEM)) { - ret = ion_alloc_tiler(pCompPrv->ion_fd, len, 1, TILER_PIXEL_FMT_PAGE, - OMAP_ION_HEAP_TILER_MASK, &temp, &stride); - } - - if (ret || ((int)temp == -ENOMEM)) { - DOMX_ERROR("FAILED to allocate buffer of size=%d. ret=0x%x",len, ret); - return OMX_ErrorInsufficientResources; - } - - if (ret) - return OMX_ErrorInsufficientResources; - *handle = temp; - return OMX_ErrorNone; -} -#endif - -/* ===========================================================================*/ -/** - * @name PROXY_EventHandler() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_EventHandler(OMX_HANDLETYPE hComponent, - OMX_PTR pAppData, OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2, - OMX_PTR pEventData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_PTR pTmpData = NULL; - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, - "This is fatal error, processing cant proceed - please debug"); - - DOMX_ENTER - ("hComponent=%p, pCompPrv=%p, eEvent=%p, nData1=%p, nData2=%p, pEventData=%p", - hComponent, pCompPrv, eEvent, nData1, nData2, pEventData); - - switch (eEvent) - { -#if 0 // This feature is currently not supported, so kept in if(0) to be supported in the future - case OMX_TI_EventBufferRefCount: - DOMX_DEBUG("Received Ref Count Event"); - /*nData1 will be pBufferHeader, nData2 will be present count. Need to find local - buffer header for nData1 which is remote buffer header */ - - PROXY_assert((nData1 != 0), OMX_ErrorBadParameter, - "Received NULL buffer header from OMX component"); - - /*find local buffer header equivalent */ - for (count = 0; count < pCompPrv->nTotalBuffers; ++count) - { - if (pCompPrv->tBufList[count].pBufHeaderRemote == - nData1) - { - pLocalBufHdr = - pCompPrv->tBufList[count].pBufHeader; - pLocalBufHdr->pBuffer = - (OMX_U8 *) pCompPrv->tBufList[count]. - pBufferActual; - break; - } - } - PROXY_assert((count != pCompPrv->nTotalBuffers), - OMX_ErrorBadParameter, - "Received invalid-buffer header from OMX component"); - - /*update local buffer header */ - nData1 = (OMX_U32) pLocalBufHdr; - break; -#endif - case OMX_EventMark: - DOMX_DEBUG("Received Mark Event"); - PROXY_assert((pEventData != NULL), OMX_ErrorUndefined, - "MarkData corrupted"); - pTmpData = pEventData; - pEventData = - ((PROXY_MARK_DATA *) pEventData)->pMarkDataActual; - TIMM_OSAL_Free(pTmpData); - break; - - default: - break; - } - - EXIT: - if (eError == OMX_ErrorNone) - { - pCompPrv->tCBFunc.EventHandler(hComponent, - pCompPrv->pILAppData, eEvent, nData1, nData2, pEventData); - } else if (pCompPrv) - { - pCompPrv->tCBFunc.EventHandler(hComponent, - pCompPrv->pILAppData, OMX_EventError, eError, 0, NULL); - } - - DOMX_EXIT("eError: %d", eError); - return OMX_ErrorNone; -} - -/* ===========================================================================*/ -/** - * @name PROXY_EmptyBufferDone() - * @brief - * @param - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -static OMX_ERRORTYPE PROXY_EmptyBufferDone(OMX_HANDLETYPE hComponent, - OMX_U32 remoteBufHdr, OMX_U32 nfilledLen, OMX_U32 nOffset, OMX_U32 nFlags) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_U16 count; - OMX_BUFFERHEADERTYPE *pBufHdr = NULL; - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, - "This is fatal error, processing cant proceed - please debug"); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent=%p, pCompPrv=%p, remoteBufHdr=%p, nFilledLen=%d, nOffset=%d, nFlags=%08x", - hComponent, pCompPrv, remoteBufHdr, nfilledLen, nOffset, nFlags); - - for (count = 0; count < pCompPrv->nTotalBuffers; ++count) - { - if (pCompPrv->tBufList[count].pBufHeaderRemote == - remoteBufHdr) - { - pBufHdr = pCompPrv->tBufList[count].pBufHeader; - pBufHdr->nFilledLen = nfilledLen; - pBufHdr->nOffset = nOffset; - pBufHdr->nFlags = nFlags; - /* Setting mark info to NULL. This would always be - NULL in EBD, whether component has propagated the - mark or has generated mark event */ - pBufHdr->hMarkTargetComponent = NULL; - pBufHdr->pMarkData = NULL; - break; - } - } - PROXY_assert((count != pCompPrv->nTotalBuffers), - OMX_ErrorBadParameter, - "Received invalid-buffer header from OMX component"); - - KPI_OmxCompBufferEvent(KPI_BUFFER_EBD, hComponent, &(pCompPrv->tBufList[count])); - - EXIT: - if (eError == OMX_ErrorNone) - { - pCompPrv->tCBFunc.EmptyBufferDone(hComponent, - pCompPrv->pILAppData, pBufHdr); - } else if (pCompPrv) - { - pCompPrv->tCBFunc.EventHandler(hComponent, - pCompPrv->pILAppData, OMX_EventError, eError, 0, NULL); - } - - DOMX_EXIT("eError: %d", eError); - return OMX_ErrorNone; -} - -/* ===========================================================================*/ -/** - * @name PROXY_FillBufferDone() - * @brief - * @param - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_FillBufferDone(OMX_HANDLETYPE hComponent, - OMX_U32 remoteBufHdr, OMX_U32 nfilledLen, OMX_U32 nOffset, OMX_U32 nFlags, - OMX_TICKS nTimeStamp, OMX_HANDLETYPE hMarkTargetComponent, - OMX_PTR pMarkData) -{ - - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_U16 count; - OMX_BUFFERHEADERTYPE *pBufHdr = NULL; - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, - "This is fatal error, processing cant proceed - please debug"); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent=%p, pCompPrv=%p, remoteBufHdr=%p, nFilledLen=%d, nOffset=%d, nFlags=%08x", - hComponent, pCompPrv, remoteBufHdr, nfilledLen, nOffset, nFlags); - - for (count = 0; count < pCompPrv->nTotalBuffers; ++count) - { - if (pCompPrv->tBufList[count].pBufHeaderRemote == - remoteBufHdr) - { - pBufHdr = pCompPrv->tBufList[count].pBufHeader; - pBufHdr->nFilledLen = nfilledLen; - pBufHdr->nOffset = nOffset; - pBufHdr->nFlags = nFlags; - pBufHdr->nTimeStamp = nTimeStamp; - if (pMarkData != NULL) - { - /*Update mark info in the buffer header */ - pBufHdr->pMarkData = - ((PROXY_MARK_DATA *) - pMarkData)->pMarkDataActual; - pBufHdr->hMarkTargetComponent = - ((PROXY_MARK_DATA *) - pMarkData)->hComponentActual; - TIMM_OSAL_Free(pMarkData); - } - break; - } - } - PROXY_assert((count != pCompPrv->nTotalBuffers), - OMX_ErrorBadParameter, - "Received invalid-buffer header from OMX component"); - - KPI_OmxCompBufferEvent(KPI_BUFFER_FBD, hComponent, &(pCompPrv->tBufList[count])); - - EXIT: - if (eError == OMX_ErrorNone) - { - pCompPrv->tCBFunc.FillBufferDone(hComponent, - pCompPrv->pILAppData, pBufHdr); - } else if (pCompPrv) - { - pCompPrv->tCBFunc.EventHandler(hComponent, - pCompPrv->pILAppData, OMX_EventError, eError, 0, NULL); - } - - DOMX_EXIT("eError: %d", eError); - return OMX_ErrorNone; -} - -/* ===========================================================================*/ -/** - * @name PROXY_EmptyThisBuffer() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_EmptyThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_U32 count = 0; - OMX_COMPONENTTYPE *pMarkComp = NULL; - PROXY_COMPONENT_PRIVATE *pMarkCompPrv = NULL; - OMX_PTR pMarkData = NULL; - OMX_BOOL bFreeMarkIfError = OMX_FALSE; - OMX_BOOL bIsProxy = OMX_FALSE , bMapBuffer; - - PROXY_require(pBufferHdr != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, - NULL); - PROXY_CHK_VERSION(pBufferHdr, OMX_BUFFERHEADERTYPE); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent=%p, pCompPrv=%p, nFilledLen=%d, nOffset=%d, nFlags=%08x", - hComponent, pCompPrv, pBufferHdr->nFilledLen, - pBufferHdr->nOffset, pBufferHdr->nFlags); - - /*First find the index of this buffer header to retrieve remote buffer header */ - for (count = 0; count < pCompPrv->nTotalBuffers; count++) - { - if (pCompPrv->tBufList[count].pBufHeader == pBufferHdr) - { - DOMX_DEBUG("Buffer Index of Match %d ", count); - break; - } - } - PROXY_assert((count != pCompPrv->nTotalBuffers), - OMX_ErrorBadParameter, - "Could not find the remote header in buffer list"); - - if (pBufferHdr->hMarkTargetComponent != NULL) - { - pMarkComp = - (OMX_COMPONENTTYPE *) (pBufferHdr->hMarkTargetComponent); - /* Check is mark comp is proxy */ - eError = _RPC_IsProxyComponent(pMarkComp, &bIsProxy); - PROXY_assert(eError == OMX_ErrorNone, eError, ""); - - /*Replacing original mark data with proxy specific structure */ - pMarkData = pBufferHdr->pMarkData; - pBufferHdr->pMarkData = - TIMM_OSAL_Malloc(sizeof(PROXY_MARK_DATA), TIMM_OSAL_TRUE, - 0, TIMMOSAL_MEM_SEGMENT_INT); - PROXY_assert(pBufferHdr->pMarkData != NULL, - OMX_ErrorInsufficientResources, "Malloc failed"); - bFreeMarkIfError = OMX_TRUE; - ((PROXY_MARK_DATA *) (pBufferHdr-> - pMarkData))->hComponentActual = pMarkComp; - ((PROXY_MARK_DATA *) (pBufferHdr-> - pMarkData))->pMarkDataActual = pMarkData; - - /* If proxy comp then replace hMarkTargetComponent with remote - handle */ - if (bIsProxy) - { - pMarkCompPrv = pMarkComp->pComponentPrivate; - PROXY_assert(pMarkCompPrv != NULL, - OMX_ErrorBadParameter, NULL); - - /* Replacing with remote component handle */ - pBufferHdr->hMarkTargetComponent = - ((RPC_OMX_CONTEXT *) pMarkCompPrv->hRemoteComp)-> - hActualRemoteCompHandle; - } - } - - bMapBuffer = - pCompPrv->proxyPortBuffers[pBufferHdr->nInputPortIndex].proxyBufferType == - EncoderMetadataPointers; - - KPI_OmxCompBufferEvent(KPI_BUFFER_ETB, hComponent, &(pCompPrv->tBufList[count])); - - eRPCError = - RPC_EmptyThisBuffer(pCompPrv->hRemoteComp, pBufferHdr, - pCompPrv->tBufList[count].pBufHeaderRemote, &eCompReturn,bMapBuffer); - - PROXY_checkRpcError(); - - EXIT: - /*If ETB is about to return an error then this means that buffer has not - been accepted by the component. Thus the allocated mark data will be - lost so free it here. Also replace original mark data in the header */ - if ((eError != OMX_ErrorNone) && bFreeMarkIfError) - { - pBufferHdr->hMarkTargetComponent = - ((PROXY_MARK_DATA *) (pBufferHdr-> - pMarkData))->hComponentActual; - pMarkData = - ((PROXY_MARK_DATA *) (pBufferHdr-> - pMarkData))->pMarkDataActual; - TIMM_OSAL_Free(pBufferHdr->pMarkData); - pBufferHdr->pMarkData = pMarkData; - } - - DOMX_EXIT("eError: %d", eError); - return eError; -} - - -/* ===========================================================================*/ -/** - * @name PROXY_FillThisBuffer() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_FillThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_U32 count = 0; - - PROXY_require(pBufferHdr != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, - NULL); - PROXY_CHK_VERSION(pBufferHdr, OMX_BUFFERHEADERTYPE); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nFilledLen = %d, nOffset = %d, nFlags = %08x", - hComponent, pCompPrv, pBufferHdr->nFilledLen, - pBufferHdr->nOffset, pBufferHdr->nFlags); - - /*First find the index of this buffer header to retrieve remote buffer header */ - for (count = 0; count < pCompPrv->nTotalBuffers; count++) - { - if (pCompPrv->tBufList[count].pBufHeader == pBufferHdr) - { - DOMX_DEBUG("Buffer Index of Match %d ", count); - break; - } - } - PROXY_assert((count != pCompPrv->nTotalBuffers), - OMX_ErrorBadParameter, - "Could not find the remote header in buffer list"); - - KPI_OmxCompBufferEvent(KPI_BUFFER_FTB, hComponent, &(pCompPrv->tBufList[count])); - - eRPCError = RPC_FillThisBuffer(pCompPrv->hRemoteComp, pBufferHdr, - pCompPrv->tBufList[count].pBufHeaderRemote, &eCompReturn); - - PROXY_checkRpcError(); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - - -/* ===========================================================================*/ -/** - * @name PROXY_AllocateBuffer() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_AllocateBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, OMX_IN OMX_U32 nSizeBytes) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_U32 currentBuffer = 0, i = 0; - OMX_BOOL bSlotFound = OMX_FALSE; -#ifdef USE_ION - struct ion_handle *handle = NULL; - OMX_PTR pIonMappedBuffer = NULL; -#endif - -#ifdef ALLOCATE_TILER_BUFFER_IN_PROXY - // Do the tiler allocations in Proxy and call use buffers on Ducati. - - //Round Off the size to allocate and map to next page boundary. - OMX_U32 nSize = (nSizeBytes + LINUX_PAGE_SIZE - 1) & ~(LINUX_PAGE_SIZE - 1); - OMX_U32 nStride = 0; - OMX_U8* pMemptr = NULL; - OMX_CONFIG_RECTTYPE tParamRect; - OMX_PARAM_PORTDEFINITIONTYPE tParamPortDef; - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - PROXY_require(ppBufferHdr != NULL, OMX_ErrorBadParameter, - "Pointer to buffer header is NULL"); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nPortIndex = %p, pAppPrivate = %p, nSizeBytes = %d", - hComponent, pCompPrv, nPortIndex, pAppPrivate, nSizeBytes); - - /*Pick up 1st empty slot */ - /*The same empty spot will be picked up by the subsequent - Use buffer call to fill in the corresponding buffer - Buffer header in the list */ - - bSlotFound = OMX_FALSE; - for (i = 0; i < pCompPrv->nTotalBuffers; i++) - { - if (pCompPrv->tBufList[i].pBufHeader == NULL) - { - currentBuffer = i; - bSlotFound = OMX_TRUE; - break; - } - } - - if (bSlotFound == OMX_FALSE) - { - currentBuffer = pCompPrv->nTotalBuffers; - } - - /*To find whether buffer is 2D or 1D */ - eError = - RPC_UTIL_GetStride(pCompPrv->hRemoteComp, nPortIndex, &nStride); - PROXY_assert(eError == OMX_ErrorNone, eError, - "Failed to get stride of component"); - - if (nStride == LINUX_PAGE_SIZE && \ - pCompPrv->proxyPortBuffers[nPortIndex].proxyBufferType != EncoderMetadataPointers) //Allocate 2D buffer - { -#if USE_ION - DOMX_ERROR ("Tiler 2d port buffers not implemented"); - eError = OMX_ErrorNotImplemented; - goto EXIT; -#endif - } -#ifdef USE_ION - else if (pCompPrv->bUseIon == OMX_TRUE) - { - eError = PROXY_AllocateBufferIonCarveout(pCompPrv, nSize, &handle); - pCompPrv->tBufList[currentBuffer].pYBuffer = handle; - if (pCompPrv->bMapIonBuffers == OMX_TRUE) - { - DOMX_DEBUG("before mapping, handle = %x, nSize = %d",handle,nSize); - if (ion_map(pCompPrv->ion_fd, handle, nSize, PROT_READ | PROT_WRITE, MAP_SHARED, 0, - &pIonMappedBuffer, &(pCompPrv->tBufList[currentBuffer].mmap_fd)) < 0) - { - DOMX_ERROR("userspace mapping of ION buffers returned error"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - } else { - if (ion_share(pCompPrv->ion_fd, handle, &(pCompPrv->tBufList[currentBuffer].mmap_fd)) < 0) { - DOMX_ERROR("ion_share failed !!! \n"); - goto EXIT; - } else { - DOMX_DEBUG("ion_share success pMemptr: 0x%x \n", pCompPrv->tBufList[currentBuffer].mmap_fd); - } - } - pMemptr = pCompPrv->tBufList[currentBuffer].mmap_fd; - DOMX_DEBUG ("Ion handle recieved = %x",handle); - if (eError != OMX_ErrorNone) - goto EXIT; - } -#endif - - /*No need to increment Allocated buffers here. - It will be done in the subsequent use buffer call below*/ - eError = PROXY_UseBuffer(hComponent, ppBufferHdr, nPortIndex, pAppPrivate, nSize, pMemptr); - - if(eError != OMX_ErrorNone) { - DOMX_ERROR("PROXY_UseBuffer in PROXY_AllocateBuffer failed with error %d (0x%08x)", eError, eError); -#ifdef USE_ION - ion_free(pCompPrv->ion_fd, - (struct ion_handle *)pCompPrv->tBufList[currentBuffer].pYBuffer); - close(pCompPrv->tBufList[currentBuffer].mmap_fd); -#endif - goto EXIT; - } - else { -#ifndef USE_ION - pCompPrv->tBufList[currentBuffer].pYBuffer = pMemptr; -#endif - } - -#ifdef USE_ION - if (pCompPrv->bUseIon == OMX_TRUE && pCompPrv->bMapIonBuffers == OMX_TRUE) - { - DOMX_DEBUG("before mapping, handle = %x, nSize = %d",handle,nSize); - (*ppBufferHdr)->pBuffer = pIonMappedBuffer; - } else { - (*ppBufferHdr)->pBuffer = (OMX_U8 *)handle; - } -#endif - -#else - //This code is the un-changed version of original implementation. - OMX_BUFFERHEADERTYPE *pBufferHeader = NULL; - OMX_U32 pBufHeaderRemote = 0; - OMX_U32 currentBuffer = 0, i = 0; - OMX_U8 *pBuffer = NULL; - OMX_TI_PLATFORMPRIVATE *pPlatformPrivate = NULL; - OMX_BOOL bSlotFound = OMX_FALSE; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_ERRORTYPE eCompReturn = OMX_ErrorNone; - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - PROXY_require(ppBufferHdr != NULL, OMX_ErrorBadParameter, - "Pointer to buffer header is NULL"); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nPortIndex = %p, pAppPrivate = %p, nSizeBytes = %d", - hComponent, pCompPrv, nPortIndex, pAppPrivate, nSizeBytes); - - /*Pick up 1st empty slot */ - for (i = 0; i < pCompPrv->nTotalBuffers; i++) - { - if (pCompPrv->tBufList[i].pBufHeader == 0) - { - currentBuffer = i; - bSlotFound = OMX_TRUE; - break; - } - } - if (!bSlotFound) - { - currentBuffer = pCompPrv->nTotalBuffers; - } - - DOMX_DEBUG("In AB, no. of buffers = %d", pCompPrv->nTotalBuffers); - PROXY_assert((pCompPrv->nTotalBuffers < MAX_NUM_PROXY_BUFFERS), - OMX_ErrorInsufficientResources, - "Proxy cannot handle more than MAX buffers"); - - //Allocating Local bufferheader to be maintained locally within proxy - pBufferHeader = - (OMX_BUFFERHEADERTYPE *) - TIMM_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE), TIMM_OSAL_TRUE, 0, - TIMMOSAL_MEM_SEGMENT_INT); - PROXY_assert((pBufferHeader != NULL), OMX_ErrorInsufficientResources, - "Allocation of Buffer Header structure failed"); - - pPlatformPrivate = - (OMX_TI_PLATFORMPRIVATE *) - TIMM_OSAL_Malloc(sizeof(OMX_TI_PLATFORMPRIVATE), TIMM_OSAL_TRUE, - 0, TIMMOSAL_MEM_SEGMENT_INT); - PROXY_assert(pPlatformPrivate != NULL, OMX_ErrorInsufficientResources, - "Allocation of platform private structure failed"); - pBufferHeader->pPlatformPrivate = pPlatformPrivate; - - DOMX_DEBUG(" Calling RPC "); - - eRPCError = - RPC_AllocateBuffer(pCompPrv->hRemoteComp, &pBufferHeader, - nPortIndex, &pBufHeaderRemote, pAppPrivate, nSizeBytes, - &eCompReturn); - - PROXY_checkRpcError(); - - DOMX_DEBUG("Allocate Buffer Successful"); - DOMX_DEBUG("Value of pBufHeaderRemote: %p LocalBufferHdr :%p", - pBufHeaderRemote, pBufferHeader); - - pCompPrv->tBufList[currentBuffer].pBufHeader = pBufferHeader; - pCompPrv->tBufList[currentBuffer].pBufHeaderRemote = pBufHeaderRemote; - - - //keeping track of number of Buffers - pCompPrv->nAllocatedBuffers++; - - if (pCompPrv->nTotalBuffers < pCompPrv->nAllocatedBuffers) - { - pCompPrv->nTotalBuffers = pCompPrv->nAllocatedBuffers; - } - - *ppBufferHdr = pBufferHeader; - - EXIT: - if (eError != OMX_ErrorNone) - { - if (pPlatformPrivate) - TIMM_OSAL_Free(pPlatformPrivate); - if (pBufferHeader) - TIMM_OSAL_Free(pBufferHeader); - } - DOMX_EXIT("eError: %d", eError); - return eError; -#endif //ALLOCATE_TILER_BUFFER_IN_PROXY - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - - -/* ===========================================================================*/ -/** - * @name PROXY_UseBuffer() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -static OMX_ERRORTYPE PROXY_UseBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr, - OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_PTR pAppPrivate, - OMX_IN OMX_U32 nSizeBytes, OMX_IN OMX_U8 * pBuffer) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - OMX_BUFFERHEADERTYPE *pBufferHeader = NULL; - OMX_U32 pBufHeaderRemote = 0; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_U32 currentBuffer = 0, i = 0, nStride = 0, nNumLines = 0; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_TI_PLATFORMPRIVATE *pPlatformPrivate = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_BOOL bSlotFound = OMX_FALSE; - OMX_PTR pAuxBuf0 = pBuffer; - //OMX_PTR pMappedMetaDataBuffer = NULL; - OMX_TI_PARAM_METADATABUFFERINFO tMetaDataBuffer; - OMX_U32 nBufferHeight = 0; - OMX_CONFIG_RECTTYPE tParamRect; - OMX_PARAM_PORTDEFINITIONTYPE tParamPortDef; - -#ifdef USE_ION - OMX_PTR pMetadataBuffer = NULL; -#endif - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - PROXY_require(pBuffer != NULL, OMX_ErrorBadParameter, "Pointer to buffer is NULL"); - PROXY_require(ppBufferHdr != NULL, OMX_ErrorBadParameter, - "Pointer to buffer header is NULL"); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nPortIndex = %p, pAppPrivate = %p, nSizeBytes = %d, pBuffer = %p", - hComponent, pCompPrv, nPortIndex, pAppPrivate, nSizeBytes, - pBuffer); - - /*Pick up 1st empty slot */ - for (i = 0; i < pCompPrv->nTotalBuffers; i++) - { - if (pCompPrv->tBufList[i].pBufHeader == 0) - { - currentBuffer = i; - bSlotFound = OMX_TRUE; - break; - } - } - if (!bSlotFound) - { - currentBuffer = pCompPrv->nTotalBuffers; - } - DOMX_DEBUG("In UB, no. of buffers = %d", pCompPrv->nTotalBuffers); - - PROXY_assert((pCompPrv->nTotalBuffers < MAX_NUM_PROXY_BUFFERS), - OMX_ErrorInsufficientResources, - "Proxy cannot handle more than MAX buffers"); - - //Allocating Local bufferheader to be maintained locally within proxy - pBufferHeader = - (OMX_BUFFERHEADERTYPE *) - TIMM_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE), TIMM_OSAL_TRUE, 0, - TIMMOSAL_MEM_SEGMENT_INT); - PROXY_assert((pBufferHeader != NULL), OMX_ErrorInsufficientResources, - "Allocation of Buffer Header structure failed"); - - pPlatformPrivate = - (OMX_TI_PLATFORMPRIVATE *) - TIMM_OSAL_Malloc(sizeof(OMX_TI_PLATFORMPRIVATE), TIMM_OSAL_TRUE, - 0, TIMMOSAL_MEM_SEGMENT_INT); - PROXY_assert(pPlatformPrivate != NULL, OMX_ErrorInsufficientResources, - "Allocation of platform private structure failed"); - TIMM_OSAL_Memset(pPlatformPrivate, 0, sizeof(OMX_TI_PLATFORMPRIVATE)); - - pBufferHeader->pPlatformPrivate = pPlatformPrivate; - ((OMX_TI_PLATFORMPRIVATE *)pBufferHeader->pPlatformPrivate)->nSize = sizeof(OMX_TI_PLATFORMPRIVATE); - -#ifdef ENABLE_GRALLOC_BUFFERS - - if(pCompPrv->proxyPortBuffers[nPortIndex].proxyBufferType == GrallocPointers) - { - //Extracting buffer pointer from the gralloc buffer - pAuxBuf0 = (OMX_U8 *)(((IMG_native_handle_t*)pBuffer)->fd[0]); - } -#endif - - DOMX_DEBUG("Preparing buffer to Remote Core..."); - pBufferHeader->pBuffer = pBuffer; - /*To find whether buffer is 2D or 1D */ - eError = - RPC_UTIL_GetStride(pCompPrv->hRemoteComp, nPortIndex, &nStride); - PROXY_assert(eError == OMX_ErrorNone, eError, - "Failed to get stride of component"); - if (nStride == LINUX_PAGE_SIZE) - { - // Change this to extract UV pointer from gralloc handle once new gralloc interface is available - /*2D buffer, assume NV12 format */ - eError = - RPC_UTIL_GetNumLines(pCompPrv->hRemoteComp, nPortIndex, - &nNumLines); - PROXY_assert(eError == OMX_ErrorNone, eError, - "Failed to get num of lines"); - - if(pCompPrv->proxyPortBuffers[nPortIndex].proxyBufferType == GrallocPointers) - { - ((OMX_TI_PLATFORMPRIVATE *) pBufferHeader->pPlatformPrivate)-> - pAuxBuf1 = (OMX_U8 *)(((IMG_native_handle_t*)pBuffer)->fd[1]); - } - - if(pCompPrv->proxyPortBuffers[nPortIndex].proxyBufferType == EncoderMetadataPointers) - { - ((OMX_TI_PLATFORMPRIVATE *) pBufferHeader->pPlatformPrivate)-> - pAuxBuf1 = NULL; - } -#ifndef OMAP_TUNA - if(pCompPrv->proxyPortBuffers[nPortIndex].proxyBufferType == BufferDescriptorVirtual2D) - { - pAuxBuf0 = (OMX_U8 *)(((OMX_TI_BUFFERDESCRIPTOR_TYPE*)pBuffer)->pBuf[0]); - - ((OMX_TI_PLATFORMPRIVATE *) pBufferHeader->pPlatformPrivate)-> - pAuxBuf1 = (OMX_U8 *)(((OMX_TI_BUFFERDESCRIPTOR_TYPE*)pBuffer)->pBuf[1]); - } -#endif - } - - /*Initializing Structure */ - tMetaDataBuffer.nSize = sizeof(OMX_TI_PARAM_METADATABUFFERINFO); - tMetaDataBuffer.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - tMetaDataBuffer.nVersion.s.nVersionMinor = OMX_VER_MINOR; - tMetaDataBuffer.nVersion.s.nRevision = 0x0; - tMetaDataBuffer.nVersion.s.nStep = 0x0; - tMetaDataBuffer.nPortIndex = nPortIndex; - eError = PROXY_GetParameter(hComponent, (OMX_INDEXTYPE)OMX_TI_IndexParamMetaDataBufferInfo, (OMX_PTR)&tMetaDataBuffer); - PROXY_assert(eError == OMX_ErrorNone, eError, - "Get Parameter for Metadata infor failed"); - - DOMX_DEBUG("Metadata size = %d",tMetaDataBuffer.nMetaDataSize); - - if(tMetaDataBuffer.bIsMetaDataEnabledOnPort) - { -#ifdef USE_ION - ((OMX_TI_PLATFORMPRIVATE *)pBufferHeader->pPlatformPrivate)->nMetaDataSize = - (tMetaDataBuffer.nMetaDataSize + LINUX_PAGE_SIZE - 1) & ~(LINUX_PAGE_SIZE -1); - eError = PROXY_AllocateBufferIonCarveout(pCompPrv, ((OMX_TI_PLATFORMPRIVATE *)pBufferHeader->pPlatformPrivate)->nMetaDataSize, - (struct ion_handle **)(&(((OMX_TI_PLATFORMPRIVATE *)pBufferHeader->pPlatformPrivate)->pMetaDataBuffer))); - pCompPrv->tBufList[currentBuffer].pMetaDataBuffer = ((OMX_TI_PLATFORMPRIVATE *)pBufferHeader-> - pPlatformPrivate)->pMetaDataBuffer; - DOMX_DEBUG("Metadata buffer ion handle = %d",((OMX_TI_PLATFORMPRIVATE *)pBufferHeader->pPlatformPrivate)->pMetaDataBuffer); - if (pCompPrv->bMapIonBuffers == OMX_TRUE) { - if (ion_map(pCompPrv->ion_fd, pPlatformPrivate->pMetaDataBuffer, - pPlatformPrivate->nMetaDataSize, - PROT_READ | PROT_WRITE, MAP_SHARED, 0, - &pMetadataBuffer, - &(pCompPrv->tBufList[currentBuffer].mmap_fd_metadata_buff)) < 0) - { - DOMX_ERROR("userspace mapping of ION metadata buffers returned error"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - } -#endif - } - -#ifdef USE_ION - { - // Need to register buffers when using ion and rpmsg - eRPCError = RPC_RegisterBuffer(pCompPrv->hRemoteComp, pAuxBuf0, - &pCompPrv->tBufList[currentBuffer].pRegisteredAufBux0, - &pCompPrv->tBufList[currentBuffer].pRegisteredAufBux1, - pCompPrv->proxyPortBuffers[nPortIndex].proxyBufferType); - PROXY_checkRpcError(); - if (pCompPrv->tBufList[currentBuffer].pRegisteredAufBux0) - pAuxBuf0 = pCompPrv->tBufList[currentBuffer].pRegisteredAufBux0; - if (pCompPrv->tBufList[currentBuffer].pRegisteredAufBux1) - pPlatformPrivate->pAuxBuf1 = pCompPrv->tBufList[currentBuffer].pRegisteredAufBux1; - - if (pPlatformPrivate->pMetaDataBuffer != NULL) - { - int fd = -1; - if (pCompPrv->bMapIonBuffers == OMX_TRUE) { - fd = pCompPrv->tBufList[currentBuffer].mmap_fd_metadata_buff; - } else { - ion_share (pCompPrv->ion_fd, pPlatformPrivate->pMetaDataBuffer, &fd); - pCompPrv->tBufList[currentBuffer].mmap_fd_metadata_buff = fd; - } - eRPCError = RPC_RegisterBuffer(pCompPrv->hRemoteComp, fd, - &pCompPrv->tBufList[currentBuffer].pRegisteredAufBux2, NULL, IONPointers); - PROXY_checkRpcError(); - if (pCompPrv->tBufList[currentBuffer].pRegisteredAufBux2) - pPlatformPrivate->pMetaDataBuffer = pCompPrv->tBufList[currentBuffer].pRegisteredAufBux2; - } - } -#endif - - eRPCError = RPC_UseBuffer(pCompPrv->hRemoteComp, &pBufferHeader, nPortIndex, - pAppPrivate, nSizeBytes, pAuxBuf0, &pBufHeaderRemote, &eCompReturn); - - PROXY_checkRpcError(); - - DOMX_DEBUG("Use Buffer Successful"); - DOMX_DEBUG - ("Value of pBufHeaderRemote: %p LocalBufferHdr :%p, LocalBuffer :%p", - pBufHeaderRemote, pBufferHeader, pBufferHeader->pBuffer); - -#ifdef USE_ION - if (pCompPrv->bUseIon == OMX_TRUE && pCompPrv->bMapIonBuffers == OMX_TRUE && tMetaDataBuffer.bIsMetaDataEnabledOnPort) - { - ((OMX_TI_PLATFORMPRIVATE *)pBufferHeader->pPlatformPrivate)->pMetaDataBuffer = pMetadataBuffer; - //ion_free(pCompPrv->ion_fd, handleToMap); - memset(((OMX_TI_PLATFORMPRIVATE *)pBufferHeader->pPlatformPrivate)->pMetaDataBuffer, - 0x0, tMetaDataBuffer.nMetaDataSize); - } -#endif - - //Storing details of pBufferHeader/Mapped/Actual buffer address locally. - pCompPrv->tBufList[currentBuffer].pBufHeader = pBufferHeader; - pCompPrv->tBufList[currentBuffer].pBufHeaderRemote = pBufHeaderRemote; - - //keeping track of number of Buffers - pCompPrv->nAllocatedBuffers++; - if (pCompPrv->nTotalBuffers < pCompPrv->nAllocatedBuffers) - pCompPrv->nTotalBuffers = pCompPrv->nAllocatedBuffers; - - DOMX_DEBUG("Updating no. of buffer to %d", pCompPrv->nTotalBuffers); - - *ppBufferHdr = pBufferHeader; - - EXIT: - if (eError != OMX_ErrorNone) - { - if (pPlatformPrivate) - TIMM_OSAL_Free(pPlatformPrivate); - if (pBufferHeader) - TIMM_OSAL_Free(pBufferHeader); - } - DOMX_EXIT("eError: %d", eError); - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_FreeBuffer() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone, eTmpRPCError = - RPC_OMX_ErrorNone; - OMX_U32 count = 0, nStride = 0; - OMX_U32 pBuffer = 0; - OMX_PTR pMetaDataBuffer = NULL; - OMX_PTR pAuxBuf0 = NULL; - OMX_TI_PLATFORMPRIVATE * pPlatformPrivate = NULL; - - PROXY_require(pBufferHdr != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, - NULL); - PROXY_CHK_VERSION(pBufferHdr, OMX_BUFFERHEADERTYPE); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nPortIndex = %p, pBufferHdr = %p, pBuffer = %p", - hComponent, pCompPrv, nPortIndex, pBufferHdr, - pBufferHdr->pBuffer); - - for (count = 0; count < pCompPrv->nTotalBuffers; count++) - { - if (pCompPrv->tBufList[count].pBufHeader == pBufferHdr) - { - DOMX_DEBUG("Buffer Index of Match %d", count); - break; - } - } - PROXY_assert((count != pCompPrv->nTotalBuffers), - OMX_ErrorBadParameter, - "Could not find the mapped address in component private buffer list"); - - pBuffer = (OMX_U32)pBufferHdr->pBuffer; - pAuxBuf0 = (OMX_PTR) pBuffer; - -#ifdef ENABLE_GRALLOC_BUFFERS - if (pCompPrv->proxyPortBuffers[nPortIndex].proxyBufferType == GrallocPointers) - { - //Extracting buffer pointer from the gralloc buffer - pAuxBuf0 = (OMX_U8 *)(((IMG_native_handle_t*)pBuffer)->fd[0]); - } -#endif - - /*To find whether buffer is 2D or 1D */ - /*Not having asserts from this point since even if error occurs during - unmapping/freeing, still trying to clean up as much as possible */ - eError = - RPC_UTIL_GetStride(pCompPrv->hRemoteComp, nPortIndex, &nStride); -#ifndef OMAP_TUNA - if (eError == OMX_ErrorNone && nStride == LINUX_PAGE_SIZE) - { - if (pCompPrv->proxyPortBuffers[nPortIndex].proxyBufferType == BufferDescriptorVirtual2D) - { - pAuxBuf0 = (OMX_U8 *)(((OMX_TI_BUFFERDESCRIPTOR_TYPE*)pBuffer)->pBuf[0]); - } - } -#endif - - /*Not having asserts from this point since even if error occurs during - unmapping/freeing, still trying to clean up as much as possible */ - - if (pCompPrv->tBufList[count].pRegisteredAufBux0 != NULL) - pAuxBuf0 = pCompPrv->tBufList[count].pRegisteredAufBux0; - - eRPCError = - RPC_FreeBuffer(pCompPrv->hRemoteComp, nPortIndex, - pCompPrv->tBufList[count].pBufHeaderRemote, (OMX_U32) pAuxBuf0, - &eCompReturn); - - if (eRPCError != RPC_OMX_ErrorNone) - eTmpRPCError = eRPCError; - - pPlatformPrivate = (OMX_TI_PLATFORMPRIVATE *)(pCompPrv->tBufList[count].pBufHeader)-> - pPlatformPrivate; - - if (pCompPrv->tBufList[count].pBufHeader) - { -#ifdef ALLOCATE_TILER_BUFFER_IN_PROXY -#ifdef USE_ION - if(pCompPrv->tBufList[count].pYBuffer) - { - if (pCompPrv->bUseIon == OMX_TRUE) - { - if(pCompPrv->bMapIonBuffers == OMX_TRUE && pBufferHdr->pBuffer) - { - munmap(pBufferHdr->pBuffer, pBufferHdr->nAllocLen); - close(pCompPrv->tBufList[count].mmap_fd); - } - ion_free(pCompPrv->ion_fd, pCompPrv->tBufList[count].pYBuffer); - pCompPrv->tBufList[count].pYBuffer = NULL; - } - } -#endif -#endif - pMetaDataBuffer = pPlatformPrivate->pMetaDataBuffer; - if (pMetaDataBuffer) - { -#ifdef USE_ION - if (pCompPrv->bUseIon == OMX_TRUE) - { - if(pCompPrv->bMapIonBuffers == OMX_TRUE) - { - munmap(pMetaDataBuffer, pPlatformPrivate->nMetaDataSize); - } - close(pCompPrv->tBufList[count].mmap_fd_metadata_buff); - ion_free(pCompPrv->ion_fd, pCompPrv->tBufList[count].pMetaDataBuffer); - pPlatformPrivate->pMetaDataBuffer = NULL; - } -#endif - } - -#ifdef USE_ION - { - // Need to unregister buffers when using ion and rpmsg - if (pCompPrv->tBufList[count].pRegisteredAufBux0 != NULL) - { - eTmpRPCError = RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, - pCompPrv->tBufList[count].pRegisteredAufBux0); - if (eTmpRPCError != RPC_OMX_ErrorNone) { - eRPCError = eTmpRPCError; - } - } - - if (pCompPrv->tBufList[count].pRegisteredAufBux1 != NULL) - { - eTmpRPCError = RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, - pCompPrv->tBufList[count].pRegisteredAufBux1); - if (eTmpRPCError != RPC_OMX_ErrorNone) { - eRPCError = eTmpRPCError; - } - } - if (pCompPrv->tBufList[count].pRegisteredAufBux2 != NULL) - { - eTmpRPCError = RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, - pCompPrv->tBufList[count].pRegisteredAufBux2); - if (eTmpRPCError != RPC_OMX_ErrorNone) { - eRPCError = eTmpRPCError; - } - } - } -#endif - if (pCompPrv->tBufList[count].pBufHeader->pPlatformPrivate) - { - TIMM_OSAL_Free(pCompPrv->tBufList[count].pBufHeader-> - pPlatformPrivate); - } - TIMM_OSAL_Free(pCompPrv->tBufList[count].pBufHeader); - TIMM_OSAL_Memset(&(pCompPrv->tBufList[count]), 0, - sizeof(PROXY_BUFFER_INFO)); - } - pCompPrv->nAllocatedBuffers--; - - PROXY_checkRpcError(); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - - -/* ===========================================================================*/ -/** - * @name PROXY_SetParameter() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE __PROXY_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR pParamStruct, - OMX_PTR pLocBufNeedMap, OMX_U32 nNumOfLocalBuf) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; -#ifndef OMAP_TUNA - OMX_TI_PARAM_USEBUFFERDESCRIPTOR *ptBufDescParam = NULL; -#endif -#ifdef ENABLE_GRALLOC_BUFFERS - OMX_TI_PARAMUSENATIVEBUFFER *pParamNativeBuffer = NULL; -#endif -#ifdef USE_ION - OMX_PTR *pAuxBuf = pLocBufNeedMap; - OMX_PTR pRegistered = NULL; -#endif - - PROXY_require((pParamStruct != NULL), OMX_ErrorBadParameter, NULL); - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nParamIndex = %d, pParamStruct = %p", - hComponent, pCompPrv, nParamIndex, pParamStruct); - - switch(nParamIndex) - { -#ifdef ENABLE_GRALLOC_BUFFERS - case OMX_TI_IndexUseNativeBuffers: - { - //Add check version. - pParamNativeBuffer = (OMX_TI_PARAMUSENATIVEBUFFER* )pParamStruct; - if(pParamNativeBuffer->bEnable == OMX_TRUE) - { - pCompPrv->proxyPortBuffers[pParamNativeBuffer->nPortIndex].proxyBufferType = GrallocPointers; - pCompPrv->proxyPortBuffers[pParamNativeBuffer->nPortIndex].IsBuffer2D = OMX_TRUE; - } else - { - /* Reset to defaults */ - pCompPrv->proxyPortBuffers[pParamNativeBuffer->nPortIndex].proxyBufferType = VirtualPointers; - pCompPrv->proxyPortBuffers[pParamNativeBuffer->nPortIndex].IsBuffer2D = OMX_FALSE; - } - - break; - } -#endif -#ifndef OMAP_TUNA - case OMX_TI_IndexUseBufferDescriptor: - ptBufDescParam = (OMX_TI_PARAM_USEBUFFERDESCRIPTOR *) pParamStruct; - if(ptBufDescParam->bEnabled == OMX_TRUE) - { - if(ptBufDescParam->eBufferType == OMX_TI_BufferTypeVirtual2D) - { - pCompPrv->proxyPortBuffers[ptBufDescParam->nPortIndex].proxyBufferType = BufferDescriptorVirtual2D; - pCompPrv->proxyPortBuffers[ptBufDescParam->nPortIndex].IsBuffer2D = OMX_TRUE; - } - } - else if(ptBufDescParam->bEnabled == OMX_FALSE) - { - /* Reset to defaults*/ - pCompPrv->proxyPortBuffers[ptBufDescParam->nPortIndex].proxyBufferType = VirtualPointers; - pCompPrv->proxyPortBuffers[ptBufDescParam->nPortIndex].IsBuffer2D = OMX_FALSE; - } - eRPCError = - RPC_SetParameter(pCompPrv->hRemoteComp, nParamIndex, pParamStruct, - pLocBufNeedMap, nNumOfLocalBuf, &eCompReturn); - break; -#endif - default: - { -#ifdef USE_ION - if (pAuxBuf != NULL) { - int fd = *((int*)pAuxBuf); - if (fd > -1) { - eRPCError = RPC_RegisterBuffer(pCompPrv->hRemoteComp, *((int*)pAuxBuf), - &pRegistered, NULL, IONPointers); - PROXY_checkRpcError(); - if (pRegistered) - *pAuxBuf = pRegistered; - } - } -#endif - eRPCError = - RPC_SetParameter(pCompPrv->hRemoteComp, nParamIndex, pParamStruct, - pLocBufNeedMap, nNumOfLocalBuf, &eCompReturn); -#ifdef USE_ION - PROXY_checkRpcError(); - if (pRegistered != NULL) { - eRPCError = RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, pRegistered); - PROXY_checkRpcError(); - } -#endif - } - } - - PROXY_checkRpcError(); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_SetParameter() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR pParamStruct) -{ - return __PROXY_SetParameter(hComponent, nParamIndex, pParamStruct, NULL, 0); -} - - -/* ===========================================================================*/ -/** - * @name __PROXY_GetParameter() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE __PROXY_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct, - OMX_PTR pLocBufNeedMap) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; -#ifndef OMAP_TUNA - OMX_TI_PARAM_USEBUFFERDESCRIPTOR *ptBufDescParam = NULL; -#endif -#ifdef USE_ION - OMX_PTR *pAuxBuf = pLocBufNeedMap; - OMX_PTR pRegistered = NULL; -#endif - - PROXY_require((pParamStruct != NULL), OMX_ErrorBadParameter, NULL); - PROXY_assert((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nParamIndex = %d, pParamStruct = %p", - hComponent, pCompPrv, nParamIndex, pParamStruct); - - switch(nParamIndex) - { -#ifndef OMAP_TUNA - case OMX_TI_IndexUseBufferDescriptor: - ptBufDescParam = (OMX_TI_PARAM_USEBUFFERDESCRIPTOR *) pParamStruct; - if(pCompPrv->proxyPortBuffers[ptBufDescParam->nPortIndex].proxyBufferType == BufferDescriptorVirtual2D) - { - ptBufDescParam->bEnabled = OMX_TRUE; - ptBufDescParam->eBufferType = OMX_TI_BufferTypeVirtual2D; - } - else - { - ptBufDescParam->bEnabled = OMX_FALSE; - ptBufDescParam->eBufferType = OMX_TI_BufferTypeMax; - } - break; -#endif - default: - { -#ifdef USE_ION - if (pAuxBuf != NULL) { - int fd = *((int*)pAuxBuf); - if (fd > -1) { - eRPCError = RPC_RegisterBuffer(pCompPrv->hRemoteComp, *((int*)pAuxBuf), - &pRegistered, NULL, IONPointers); - PROXY_checkRpcError(); - if (pRegistered) - *pAuxBuf = pRegistered; - } - } -#endif - eRPCError = RPC_GetParameter(pCompPrv->hRemoteComp, nParamIndex, pParamStruct, - pLocBufNeedMap, &eCompReturn); -#ifdef USE_ION - PROXY_checkRpcError(); - if (pRegistered != NULL) { - eRPCError = RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, pRegistered); - PROXY_checkRpcError(); - } -#endif - } - } - - PROXY_checkRpcError(); - -EXIT: - DOMX_EXIT("eError: %d index: 0x%x", eError, nParamIndex); - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_GetParameter() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct) -{ - return __PROXY_GetParameter(hComponent, nParamIndex, pParamStruct, NULL); -} - -/* ===========================================================================*/ -/** - * @name __PROXY_GetConfig() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE __PROXY_GetConfig(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nConfigIndex, OMX_PTR pConfigStruct, OMX_PTR pLocBufNeedMap) -{ -#ifdef USE_ION - OMX_PTR *pAuxBuf = pLocBufNeedMap; - OMX_PTR pRegistered = NULL; -#endif - - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - - PROXY_require((pConfigStruct != NULL), OMX_ErrorBadParameter, NULL); - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER("hComponent = %p, pCompPrv = %p, nConfigIndex = %d, " - "pConfigStruct = %p", - hComponent, pCompPrv, nConfigIndex, - pConfigStruct); - -#ifdef USE_ION - if (pAuxBuf != NULL) { - int fd = *((int*)pAuxBuf); - if (fd > -1) { - eRPCError = RPC_RegisterBuffer(pCompPrv->hRemoteComp, *((int*)pAuxBuf), - &pRegistered, NULL, IONPointers); - PROXY_checkRpcError(); - if (pRegistered) - *pAuxBuf = pRegistered; - } - } -#endif - - eRPCError = - RPC_GetConfig(pCompPrv->hRemoteComp, nConfigIndex, pConfigStruct, - pLocBufNeedMap, &eCompReturn); -#ifdef USE_ION - PROXY_checkRpcError(); - if (pRegistered != NULL) { - eRPCError = RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, pRegistered); - PROXY_checkRpcError(); - } -#endif - - PROXY_checkRpcError(); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_GetConfig() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_GetConfig(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nConfigIndex, OMX_PTR pConfigStruct) -{ - return __PROXY_GetConfig(hComponent, nConfigIndex, pConfigStruct, NULL); -} - -/* ===========================================================================*/ -/** - * @name __PROXY_SetConfig() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE __PROXY_SetConfig(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nConfigIndex, OMX_IN OMX_PTR pConfigStruct, - OMX_PTR pLocBufNeedMap) -{ -#ifdef USE_ION - OMX_PTR *pAuxBuf = pLocBufNeedMap; - OMX_PTR pRegistered = NULL; -#endif - - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - - PROXY_require((pConfigStruct != NULL), OMX_ErrorBadParameter, NULL); - - PROXY_assert((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER("hComponent = %p, pCompPrv = %p, nConfigIndex = %d, " - "pConfigStruct = %p", - hComponent, pCompPrv, nConfigIndex, - pConfigStruct); - -#ifdef USE_ION - if (pAuxBuf != NULL) { - int fd = *((int*)pAuxBuf); - if (fd > -1) { - eRPCError = RPC_RegisterBuffer(pCompPrv->hRemoteComp, *((int*)pAuxBuf), - &pRegistered, NULL, IONPointers); - PROXY_checkRpcError(); - if (pRegistered) - *pAuxBuf = pRegistered; - } - } -#endif - - eRPCError = - RPC_SetConfig(pCompPrv->hRemoteComp, nConfigIndex, pConfigStruct, - pLocBufNeedMap, &eCompReturn); - -#ifdef USE_ION - PROXY_checkRpcError(); - if (pRegistered != NULL) { - eRPCError = RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, pRegistered); - PROXY_checkRpcError(); - } -#endif - - PROXY_checkRpcError(); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_SetConfig() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_SetConfig(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nConfigIndex, OMX_IN OMX_PTR pConfigStruct) -{ - return __PROXY_SetConfig(hComponent, nConfigIndex, pConfigStruct, NULL); -} - - -/* ===========================================================================*/ -/** - * @name PROXY_GetState() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -static OMX_ERRORTYPE PROXY_GetState(OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_STATETYPE * pState) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_COMPONENTTYPE *hComp = hComponent; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - - PROXY_require((pState != NULL), OMX_ErrorBadParameter, NULL); - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER("hComponent = %p, pCompPrv = %p", hComponent, pCompPrv); - - eRPCError = RPC_GetState(pCompPrv->hRemoteComp, pState, &eCompReturn); - - DOMX_DEBUG("Returned from RPC_GetState, state: = %x", *pState); - - PROXY_checkRpcError(); - - EXIT: - if (eError == OMX_ErrorHardware) - { - *pState = OMX_StateInvalid; - eError = OMX_ErrorNone; - DOMX_DEBUG("Invalid state returned from RPC_GetState, state due to ducati in faulty state"); - } - DOMX_EXIT("eError: %d", eError); - return eError; -} - - - -/* ===========================================================================*/ -/** - * @name PROXY_SendCommand() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_SendCommand(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_COMMANDTYPE eCmd, - OMX_IN OMX_U32 nParam, OMX_IN OMX_PTR pCmdData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_COMPONENTTYPE *pMarkComp = NULL; - PROXY_COMPONENT_PRIVATE *pMarkCompPrv = NULL; - OMX_PTR pMarkData = NULL, pMarkToBeFreedIfError = NULL; - OMX_BOOL bIsProxy = OMX_FALSE; - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, eCmd = %d, nParam = %d, pCmdData = %p", - hComponent, pCompPrv, eCmd, nParam, pCmdData); - - if (eCmd == OMX_CommandMarkBuffer) - { - PROXY_require(pCmdData != NULL, OMX_ErrorBadParameter, NULL); - pMarkComp = (OMX_COMPONENTTYPE *) - (((OMX_MARKTYPE *) pCmdData)->hMarkTargetComponent); - PROXY_require(pMarkComp != NULL, OMX_ErrorBadParameter, NULL); - - /* To check if mark comp is a proxy or a real component */ - eError = _RPC_IsProxyComponent(pMarkComp, &bIsProxy); - PROXY_assert(eError == OMX_ErrorNone, eError, ""); - - /*Replacing original mark data with proxy specific structure */ - pMarkData = ((OMX_MARKTYPE *) pCmdData)->pMarkData; - ((OMX_MARKTYPE *) pCmdData)->pMarkData = - TIMM_OSAL_Malloc(sizeof(PROXY_MARK_DATA), TIMM_OSAL_TRUE, - 0, TIMMOSAL_MEM_SEGMENT_INT); - PROXY_assert(((OMX_MARKTYPE *) pCmdData)->pMarkData != NULL, - OMX_ErrorInsufficientResources, "Malloc failed"); - pMarkToBeFreedIfError = - ((OMX_MARKTYPE *) pCmdData)->pMarkData; - ((PROXY_MARK_DATA *) (((OMX_MARKTYPE *) - pCmdData)->pMarkData))->hComponentActual = - pMarkComp; - ((PROXY_MARK_DATA *) (((OMX_MARKTYPE *) - pCmdData)->pMarkData))->pMarkDataActual = - pMarkData; - - /* If it is proxy component then replace hMarkTargetComponent - with remote handle */ - if (bIsProxy) - { - pMarkCompPrv = pMarkComp->pComponentPrivate; - PROXY_assert(pMarkCompPrv != NULL, - OMX_ErrorBadParameter, NULL); - - /* Replacing with remote component handle */ - ((OMX_MARKTYPE *) pCmdData)->hMarkTargetComponent = - ((RPC_OMX_CONTEXT *) pMarkCompPrv->hRemoteComp)-> - hActualRemoteCompHandle; - } - } - - eRPCError = - RPC_SendCommand(pCompPrv->hRemoteComp, eCmd, nParam, pCmdData, - &eCompReturn); - - if (eCmd == OMX_CommandMarkBuffer && bIsProxy) - { - /*Resetting to original values */ - ((OMX_MARKTYPE *) pCmdData)->hMarkTargetComponent = pMarkComp; - ((OMX_MARKTYPE *) pCmdData)->pMarkData = pMarkData; - } - - PROXY_checkRpcError(); - - EXIT: - /*If SendCommand is about to return an error then this means that the - command has not been accepted by the component. Thus the allocated mark data - will be lost so free it here */ - if ((eError != OMX_ErrorNone) && pMarkToBeFreedIfError) - { - TIMM_OSAL_Free(pMarkToBeFreedIfError); - } - DOMX_EXIT("eError: %d", eError); - return eError; -} - - - -/* ===========================================================================*/ -/** - * @name PROXY_GetComponentVersion() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -static OMX_ERRORTYPE PROXY_GetComponentVersion(OMX_IN OMX_HANDLETYPE - hComponent, OMX_OUT OMX_STRING pComponentName, - OMX_OUT OMX_VERSIONTYPE * pComponentVersion, - OMX_OUT OMX_VERSIONTYPE * pSpecVersion, - OMX_OUT OMX_UUIDTYPE * pComponentUUID) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = hComponent; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - - DOMX_ENTER("hComponent = %p, pCompPrv = %p", hComponent, pCompPrv); - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - PROXY_require(pComponentName != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(pComponentVersion != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(pSpecVersion != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(pComponentUUID != NULL, OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - eRPCError = RPC_GetComponentVersion(pCompPrv->hRemoteComp, - pComponentName, - pComponentVersion, pSpecVersion, pComponentUUID, &eCompReturn); - - PROXY_checkRpcError(); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - - - -/* ===========================================================================*/ -/** - * @name PROXY_GetExtensionIndex() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE * pIndexType) -{ - - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = hComponent; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - PROXY_require(cParameterName != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(pIndexType != NULL, OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER("hComponent = %p, pCompPrv = %p, cParameterName = %s", - hComponent, pCompPrv, cParameterName); - - -#ifdef ENABLE_GRALLOC_BUFFERS - // Check for NULL Parameters - PROXY_require((cParameterName != NULL && pIndexType != NULL), - OMX_ErrorBadParameter, NULL); - - // Ensure that String length is not greater than Max allowed length - PROXY_require(strlen(cParameterName) <= 127, OMX_ErrorBadParameter, NULL); - - if(strcmp(cParameterName, "OMX.google.android.index.enableAndroidNativeBuffers") == 0) - { - // If Index type is 2D Buffer Allocated Dimension - *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexUseNativeBuffers; - goto EXIT; - } - else if (strcmp(cParameterName, "OMX.google.android.index.useAndroidNativeBuffer2") == 0) - { - //This is call just a dummy for android to support backward compatibility - *pIndexType = (OMX_INDEXTYPE) NULL; - goto EXIT; - } - else - { - eRPCError = RPC_GetExtensionIndex(pCompPrv->hRemoteComp, - cParameterName, pIndexType, &eCompReturn); - - PROXY_checkRpcError(); - } -#else - eRPCError = RPC_GetExtensionIndex(pCompPrv->hRemoteComp, - cParameterName, pIndexType, &eCompReturn); - - PROXY_checkRpcError(); -#endif - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - - - - -/* ===========================================================================*/ -/** - * @name PROXY_ComponentRoleEnum() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -static OMX_ERRORTYPE PROXY_ComponentRoleEnum(OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_U8 * cRole, OMX_IN OMX_U32 nIndex) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - - DOMX_ENTER("hComponent = %p", hComponent); - DOMX_DEBUG(" EMPTY IMPLEMENTATION "); - - DOMX_EXIT("eError: %d", eError); - return eError; -} - - -/* ===========================================================================*/ -/** - * @name PROXY_ComponentTunnelRequest() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -static OMX_ERRORTYPE PROXY_ComponentTunnelRequest(OMX_IN OMX_HANDLETYPE - hComponent, OMX_IN OMX_U32 nPort, OMX_IN OMX_HANDLETYPE hTunneledComp, - OMX_IN OMX_U32 nTunneledPort, - OMX_INOUT OMX_TUNNELSETUPTYPE * pTunnelSetup) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - - DOMX_ENTER("hComponent = %p", hComponent); - DOMX_DEBUG(" EMPTY IMPLEMENTATION "); - PROXY_COMPONENT_PRIVATE *pOutCompPrv = NULL; - PROXY_COMPONENT_PRIVATE *pInCompPrv = NULL; - OMX_COMPONENTTYPE *hOutComp = hComponent; - OMX_COMPONENTTYPE *hInComp = hTunneledComp; - OMX_ERRORTYPE eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - PROXY_assert((hOutComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - PROXY_assert((hInComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - //TBD - //PROXY_assert(nPort != 1, OMX_ErrorBadParameter, NULL); - //PROXY_assert(nTunnelPort != 0, OMX_ErrorBadParameter, NULL); - pOutCompPrv = (PROXY_COMPONENT_PRIVATE *) hOutComp->pComponentPrivate; - pInCompPrv = (PROXY_COMPONENT_PRIVATE *) hInComp->pComponentPrivate; - DOMX_ENTER("hOutComp=%p, pOutCompPrv=%p, hInComp=%p, pInCompPrv=%p, nOutPort=%d, nInPort=%d \n", - hOutComp, pOutCompPrv, hInComp, pInCompPrv, nPort, nTunneledPort); - - DOMX_INFO("PROXY_ComponentTunnelRequest:: hOutComp=%p, pOutCompPrv=%p, hInComp=%p, pInCompPrv=%p, nOutPort=%d, nInPort=%d \n ", - hOutComp, pOutCompPrv, hInComp, pInCompPrv, nPort, nTunneledPort); - eRPCError = RPC_ComponentTunnelRequest(pOutCompPrv->hRemoteComp, nPort, - pInCompPrv->hRemoteComp, nTunneledPort, pTunnelSetup, &eCompReturn); - DOMX_INFO("\nafter: RPC_ComponentTunnelRequest = 0x%x\n ", eRPCError); - PROXY_checkRpcError(); - -EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - - -/* ===========================================================================*/ -/** - * @name PROXY_SetCallbacks() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -static OMX_ERRORTYPE PROXY_SetCallbacks(OMX_HANDLETYPE hComponent, - OMX_CALLBACKTYPE * pCallBacks, OMX_PTR pAppData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - - PROXY_require((pCallBacks != NULL), OMX_ErrorBadParameter, NULL); - - PROXY_assert((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER("hComponent = %p, pCompPrv = %p", hComponent, pCompPrv); - - /*Store App callback and data to proxy- managed by proxy */ - pCompPrv->tCBFunc = *pCallBacks; - pCompPrv->pILAppData = pAppData; - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - - -/* ===========================================================================*/ -/** - * @name PROXY_UseEGLImage() - * @brief : This returns error not implemented by default as no component - * implements this. In case there is a requiremet, support for this - * can be added later. - * - */ -/* ===========================================================================*/ -static OMX_ERRORTYPE PROXY_UseEGLImage(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE ** ppBufferHdr, - OMX_U32 nPortIndex, OMX_PTR pAppPrivate, void *pBuffer) -{ - return OMX_ErrorNotImplemented; -} - - -/* ===========================================================================*/ -/** - * @name PROXY_ComponentDeInit() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_ComponentDeInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone, eTmpRPCError = - RPC_OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_U32 count = 0, nStride = 0; - OMX_PTR pMetaDataBuffer = NULL; - - DOMX_ENTER("hComponent = %p", hComponent); - - PROXY_assert((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - ion_close(pCompPrv->ion_fd); - - for (count = 0; count < pCompPrv->nTotalBuffers; count++) - { - if (pCompPrv->tBufList[count].pBufHeader) - { -#ifdef ALLOCATE_TILER_BUFFER_IN_PROXY - if(pCompPrv->tBufList[count].pYBuffer) - { -#ifdef USE_ION - if(pCompPrv->tBufList[count].pYBuffer) - { - if (pCompPrv->bUseIon == OMX_TRUE) - { - if(pCompPrv->bMapIonBuffers == OMX_TRUE) - { - munmap(pCompPrv->tBufList[count].pBufHeader->pBuffer, pCompPrv->tBufList[count].pBufHeader->nAllocLen); - close(pCompPrv->tBufList[count].mmap_fd); - } - ion_free(pCompPrv->ion_fd, pCompPrv->tBufList[count].pYBuffer); - pCompPrv->tBufList[count].pYBuffer = NULL; - } - } -#endif - } -#endif - pMetaDataBuffer = ((OMX_TI_PLATFORMPRIVATE *)(pCompPrv->tBufList[count].pBufHeader)-> - pPlatformPrivate)->pMetaDataBuffer; - if (pMetaDataBuffer) - { -#ifdef USE_ION - if (pCompPrv->bUseIon == OMX_TRUE) - { - if(pCompPrv->bMapIonBuffers == OMX_TRUE) - { - munmap(pMetaDataBuffer, ((OMX_TI_PLATFORMPRIVATE *)(pCompPrv->tBufList[count].pBufHeader)-> - pPlatformPrivate)->nMetaDataSize); - } - close(pCompPrv->tBufList[count].mmap_fd_metadata_buff); - ion_free(pCompPrv->ion_fd, pMetaDataBuffer); - ((OMX_TI_PLATFORMPRIVATE *)(pCompPrv->tBufList[count].pBufHeader)-> - pPlatformPrivate)->pMetaDataBuffer = NULL; - } -#endif - } - if (pCompPrv->tBufList[count].pBufHeader->pPlatformPrivate) - { - TIMM_OSAL_Free(pCompPrv->tBufList[count].pBufHeader-> - pPlatformPrivate); - } - TIMM_OSAL_Free(pCompPrv->tBufList[count].pBufHeader); - TIMM_OSAL_Memset(&(pCompPrv->tBufList[count]), 0, - sizeof(PROXY_BUFFER_INFO)); - } - } - - KPI_OmxCompDeinit(hComponent); - - eRPCError = RPC_FreeHandle(pCompPrv->hRemoteComp, &eCompReturn); - if (eRPCError != RPC_OMX_ErrorNone) - eTmpRPCError = eRPCError; - - eRPCError = RPC_InstanceDeInit(pCompPrv->hRemoteComp); - if (eRPCError != RPC_OMX_ErrorNone) - eTmpRPCError = eRPCError; - - if (pCompPrv->cCompName) - { - TIMM_OSAL_Free(pCompPrv->cCompName); - } - - if (pCompPrv) - { - TIMM_OSAL_Free(pCompPrv); - } - - eRPCError = eTmpRPCError; - PROXY_checkRpcError(); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - - -/* ===========================================================================*/ -/** - * @name OMX_ProxyCommonInit() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE OMX_ProxyCommonInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_HANDLETYPE hRemoteComp = NULL; - OMX_U32 i = 0; - - DOMX_ENTER("hComponent = %p", hComponent); - - TIMM_OSAL_UpdateTraceLevel(); - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - pCompPrv->nTotalBuffers = 0; - pCompPrv->nAllocatedBuffers = 0; - pCompPrv->proxyEmptyBufferDone = PROXY_EmptyBufferDone; - pCompPrv->proxyFillBufferDone = PROXY_FillBufferDone; - pCompPrv->proxyEventHandler = PROXY_EventHandler; - - for (i=0; iproxyPortBuffers[i].proxyBufferType = VirtualPointers; - } - - eRPCError = RPC_InstanceInit(pCompPrv->cCompName, &hRemoteComp); - PROXY_assert(eRPCError == RPC_OMX_ErrorNone, - OMX_ErrorUndefined, "Error initializing RPC"); - PROXY_assert(hRemoteComp != NULL, - OMX_ErrorUndefined, "Error initializing RPC"); - - //Send the proxy component handle for pAppData - eRPCError = - RPC_GetHandle(hRemoteComp, pCompPrv->cCompName, - (OMX_PTR) hComponent, NULL, &eCompReturn); - - PROXY_checkRpcError(); - - hComp->SetCallbacks = PROXY_SetCallbacks; - hComp->ComponentDeInit = PROXY_ComponentDeInit; - hComp->UseBuffer = PROXY_UseBuffer; - hComp->GetParameter = PROXY_GetParameter; - hComp->SetParameter = PROXY_SetParameter; - hComp->EmptyThisBuffer = PROXY_EmptyThisBuffer; - hComp->FillThisBuffer = PROXY_FillThisBuffer; - hComp->GetComponentVersion = PROXY_GetComponentVersion; - hComp->SendCommand = PROXY_SendCommand; - hComp->GetConfig = PROXY_GetConfig; - hComp->SetConfig = PROXY_SetConfig; - hComp->GetState = PROXY_GetState; - hComp->GetExtensionIndex = PROXY_GetExtensionIndex; - hComp->FreeBuffer = PROXY_FreeBuffer; - hComp->ComponentRoleEnum = PROXY_ComponentRoleEnum; - hComp->AllocateBuffer = PROXY_AllocateBuffer; - hComp->ComponentTunnelRequest = PROXY_ComponentTunnelRequest; - hComp->UseEGLImage = PROXY_UseEGLImage; - - pCompPrv->hRemoteComp = hRemoteComp; - -#ifdef USE_ION - pCompPrv->bUseIon = OMX_TRUE; - pCompPrv->bMapIonBuffers = OMX_TRUE; - - pCompPrv->ion_fd = ion_open(); - if(pCompPrv->ion_fd == 0) - { - DOMX_ERROR("ion_open failed!!!"); - return OMX_ErrorInsufficientResources; - } -#endif - - KPI_OmxCompInit(hComponent); - - EXIT: - if (eError != OMX_ErrorNone) - RPC_InstanceDeInit(hRemoteComp); - DOMX_EXIT("eError: %d", eError); - - return eError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_UTIL_GetStride() - * @brief Gets stride on this port. Used to determine whether buffer is 1D or 2D - * @param hRemoteComp [IN] : Remote component handle. - * @param nPortIndex [IN] : Port index. - * @param nStride [OUT] : Stride returned by the component. - * @return OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ -OMX_ERRORTYPE RPC_UTIL_GetStride(OMX_COMPONENTTYPE * hRemoteComp, - OMX_U32 nPortIndex, OMX_U32 * nStride) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_PARAM_PORTDEFINITIONTYPE sPortDef; - - /*Initializing Structure */ - sPortDef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); - sPortDef.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - sPortDef.nVersion.s.nVersionMinor = OMX_VER_MINOR; - sPortDef.nVersion.s.nRevision = 0x0; - sPortDef.nVersion.s.nStep = 0x0; - sPortDef.nPortIndex = nPortIndex; - - eRPCError = - RPC_GetParameter(hRemoteComp, OMX_IndexParamPortDefinition, - (OMX_PTR) (&sPortDef), NULL, &eCompReturn); - PROXY_checkRpcError(); - - if (sPortDef.eDomain == OMX_PortDomainVideo) - { - *nStride = sPortDef.format.video.nStride; - } else if (sPortDef.eDomain == OMX_PortDomainImage) - { - *nStride = sPortDef.format.image.nStride; - } else if (sPortDef.eDomain == OMX_PortDomainMax && nPortIndex == 0) - { - /*Temp - just for testing sample */ - *nStride = LINUX_PAGE_SIZE; - } else - { - *nStride = 0; - } - - EXIT: - return eError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_UTIL_GetNumLines() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE RPC_UTIL_GetNumLines(OMX_COMPONENTTYPE * hRemoteComp, - OMX_U32 nPortIndex, OMX_U32 * nNumOfLines) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_ERRORTYPE eCompReturn; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_BOOL bUseEnhancedPortReconfig = OMX_FALSE; - - OMX_PARAM_PORTDEFINITIONTYPE portDef; - OMX_CONFIG_RECTTYPE sRect; - - DOMX_ENTER(""); - - /*initializing Structure */ - portDef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); - portDef.nVersion.s.nVersionMajor = 0x1; - portDef.nVersion.s.nVersionMinor = 0x1; - portDef.nVersion.s.nRevision = 0x0; - portDef.nVersion.s.nStep = 0x0; - - portDef.nPortIndex = nPortIndex; - - sRect.nSize = sizeof(OMX_CONFIG_RECTTYPE); - sRect.nVersion.s.nVersionMajor = 0x1; - sRect.nVersion.s.nVersionMinor = 0x1; - sRect.nVersion.s.nRevision = 0x0; - sRect.nVersion.s.nStep = 0x0; - - sRect.nPortIndex = nPortIndex; - sRect.nLeft = 0; - sRect.nTop = 0; - sRect.nHeight = 0; - sRect.nWidth = 0; - -#ifdef USE_ENHANCED_PORTRECONFIG - bUseEnhancedPortReconfig = OMX_TRUE; -#endif - eRPCError = RPC_GetParameter(hRemoteComp, - OMX_TI_IndexParam2DBufferAllocDimension, - (OMX_PTR) & sRect, NULL, &eCompReturn); - if (eRPCError == RPC_OMX_ErrorNone) - { - DOMX_DEBUG(" PROXY_UTIL Get Parameter Successful"); - eError = eCompReturn; - } else - { - DOMX_ERROR("RPC_GetParameter returned error 0x%x", eRPCError); - eError = OMX_ErrorUndefined; - goto EXIT; - } - - if (eCompReturn == OMX_ErrorNone && bUseEnhancedPortReconfig == OMX_FALSE) - { - *nNumOfLines = sRect.nHeight; - } else if (eCompReturn == OMX_ErrorUnsupportedIndex || bUseEnhancedPortReconfig == OMX_TRUE) - { - eRPCError = - RPC_GetParameter(hRemoteComp, - OMX_IndexParamPortDefinition, (OMX_PTR) & portDef, - NULL, &eCompReturn); - - if (eRPCError == RPC_OMX_ErrorNone) - { - DOMX_DEBUG(" PROXY_UTIL Get Parameter Successful"); - eError = eCompReturn; - } else - { - DOMX_ERROR("RPC_GetParameter returned error 0x%x", - eRPCError); - eError = OMX_ErrorUndefined; - goto EXIT; - } - - if (eCompReturn == OMX_ErrorNone) - { - - //start with 1 meaning 1D buffer - *nNumOfLines = 1; - - if (portDef.eDomain == OMX_PortDomainVideo) - { - *nNumOfLines = - portDef.format.video.nFrameHeight; - //DOMX_DEBUG("Port definition Type is video..."); - //DOMX_DEBUG("&&Colorformat is:%p", portDef.format.video.eColorFormat); - //DOMX_DEBUG("nFrameHeight is:%d", portDef.format.video.nFrameHeight); - //*nNumOfLines = portDef.format.video.nFrameHeight; - - //if((portDef.format.video.eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar) || - // (portDef.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar)) - //{ - //DOMX_DEBUG("Setting FrameHeight as Number of lines..."); - //*nNumOfLines = portDef.format.video.nFrameHeight; - //} - } else if (portDef.eDomain == OMX_PortDomainImage) - { - DOMX_DEBUG - ("Image DOMAIN TILER SUPPORT for NV12 format only"); - *nNumOfLines = - portDef.format.image.nFrameHeight; - } else if (portDef.eDomain == OMX_PortDomainAudio) - { - DOMX_DEBUG("Audio DOMAIN TILER SUPPORT"); - } else if (portDef.eDomain == OMX_PortDomainOther) - { - DOMX_DEBUG("Other DOMAIN TILER SUPPORT"); - } else - { //this is the sample component test - //Temporary - just to get check functionality - DOMX_DEBUG("Sample component TILER SUPPORT"); - *nNumOfLines = 4; - } - } else - { - DOMX_ERROR(" ERROR IN RECOVERING UV POINTER"); - } - } else - { - DOMX_ERROR(" ERROR IN RECOVERING UV POINTER"); - } - - DOMX_DEBUG("Port Number: %d :: NumOfLines %d", nPortIndex, - *nNumOfLines); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - - -/* ===========================================================================*/ -/** - * @name _RPC_IsProxyComponent() - * @brief This function calls GetComponentVersion API on the component and - * based on the component name decidec whether the component is a proxy - * or real component. The naming component convention assumed is - * .... with - * all characters in upper case for e.g. OMX.TI.DUCATI1.VIDEO.H264E - * @param hComponent [IN] : The component handle - * bIsProxy [OUT] : Set to true is handle is for a proxy component - * @return OMX_ErrorNone = Successful - * - **/ -/* ===========================================================================*/ -OMX_ERRORTYPE _RPC_IsProxyComponent(OMX_HANDLETYPE hComponent, - OMX_BOOL * bIsProxy) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_S8 cComponentName[MAXNAMESIZE] = { 0 } - , cCoreName[32] = - { - 0}; - OMX_VERSIONTYPE sCompVer, sSpecVer; - OMX_UUIDTYPE sCompUUID; - OMX_U32 i = 0, ret = 0; - - eError = - OMX_GetComponentVersion(hComponent, (OMX_STRING) cComponentName, - &sCompVer, &sSpecVer, &sCompUUID); - PROXY_assert(eError == OMX_ErrorNone, eError, ""); - ret = - sscanf((char *)cComponentName, "%*[^'.'].%*[^'.'].%[^'.'].%*s", - cCoreName); - PROXY_assert(ret == 1, OMX_ErrorBadParameter, - "Incorrect component name"); - for (i = 0; i < CORE_MAX; i++) - { - if (strcmp((char *)cCoreName, Core_Array[i]) == 0) - break; - } - PROXY_assert(i < CORE_MAX, OMX_ErrorBadParameter, - "Unknown core name"); - - /* If component name indicates remote core, it means proxy - component */ - if ((i == CORE_SYSM3) || (i == CORE_APPM3) || (i == CORE_TESLA)) - *bIsProxy = OMX_TRUE; - else - *bIsProxy = OMX_FALSE; - - EXIT: - return eError; -} diff --git a/domx/domx/omx_rpc.h b/domx/domx/omx_rpc.h deleted file mode 100755 index 84c00d0..0000000 --- a/domx/domx/omx_rpc.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_rpc.h - * @brief This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework RPC. - * - * @path \WTSD_DucatiMMSW\framework\domx\omx_rpc\ - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 29-Mar-2010 Abhishek Ranka : Revamped DOMX implementation - *! - *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version - *================================================================*/ - -#ifndef OMXRPC_H -#define OMXRPC_H - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -#include -#include -#include - - -/****************************************************************** - * DATA TYPES - ******************************************************************/ - - - /******************************************************************************* -* Enumerated Types -*******************************************************************************/ - typedef enum RPC_OMX_ERRORTYPE - { - RPC_OMX_ErrorNone = 0, - - /* OMX Error Mapped */ - RPC_OMX_ErrorInsufficientResources = 0x81000, - RPC_OMX_ErrorUndefined = 0x81001, - RPC_OMX_ErrorBadParameter = 0x81005, - RPC_OMX_ErrorHardware = 0x81009, - RPC_OMX_ErrorUnsupportedIndex = 0x8101A, - RPC_OMX_ErrorTimeout = 0x81011, - /* END OF OMX Error */ - - /* RPC Specific Error - to depricate */ - RPC_OMX_ErrorUnknown = 0x70000, - RPC_OMX_ErrorProccesorInit = 0x70001, - RPC_OMX_InvalidRPCCmd = 0x70002, - RPC_OMX_ErrorHLOS = 0x70003, - RPC_OMX_ErrorInvalidMsg = 0x70004, - - /* RCM Specific */ - RPC_OMX_RCM_ErrorExecFail = 0x70005, - RPC_OMX_RCM_ErrorExecDpcFail = 0x70006, - RPC_OMX_RCM_ErrorTimeout = 0x70007, - RPC_OMX_RCM_ServerFail = 0x70008, - RPC_OMX_RCM_ClientFail = 0x70009, - - } RPC_OMX_ERRORTYPE; - - -/**************************************************************** - * PUBLIC DECLARATIONS Defined here, used elsewhere - -****************************************************************/ -/* ===========================================================================*/ -/** - * @name RPC_InstanceInit() - * @brief RPC instance init is used to bring up a instance of a client - this should be ideally invokable from any core - * For this the parameters it would require are - * Heap ID - this needs to be configured at startup (CFG) and indicates the heaps available for a RCM client to pick from - * Server - this contains the RCM server name that the client should connect to - * rcmHndl - Contains the Client once the call is completed - * rcmParams - - * These values can be picked up from the RPC handle. But an unique identifier is required -Server - * @param cComponentName : Pointer to the Components Name that is requires the RCM client to be initialized - * @return RPC_OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ - RPC_OMX_ERRORTYPE RPC_InstanceInit(OMX_STRING cComponentName, - OMX_HANDLETYPE * phRPCCtx); - - - -/* ===========================================================================*/ -/** - * @name RPC_InstanceDeInit() - * @brief This function Removes or deinitializes RCM client instances. This also manages the number of active users - * of a given RCM client - * @param cComponentName : Pointer to the Components Name that is active user of the RCM client to be deinitialized - * @return RPC_OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ - RPC_OMX_ERRORTYPE RPC_InstanceDeInit(OMX_HANDLETYPE hRPCCtx); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/domx/domx/omx_rpc/inc/omx_rpc_internal.h b/domx/domx/omx_rpc/inc/omx_rpc_internal.h deleted file mode 100755 index b33bf2d..0000000 --- a/domx/domx/omx_rpc/inc/omx_rpc_internal.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_rpc_internal.h - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework RPC. - * - * @path \WTSD_DucatiMMSW\framework\domx\omx_rpc\inc - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 29-Mar-2010 Abhishek Ranka : Revamped DOMX implementation - *! - *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version - *================================================================*/ - - -#ifndef OMXRPC_INTERNAL_H -#define OMXRPC_INTERNAL_H - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -/* ----- system and platform files ----------------------------*/ -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -/*-------program files ----------------------------------------*/ -#include "omx_rpc.h" - - -/****************************************************************** - * DEFINES - CONSTANTS - ******************************************************************/ -/* *********************** OMX RPC DEFINES***********************************/ - -/*This defines the maximum number of remote functions that can be registered*/ -#define RPC_OMX_MAX_FUNCTION_LIST 21 -/*Packet size for each message*/ -#define RPC_PACKET_SIZE 0x12C - - - -/******************************************************************************* -* Enumerated Types -*******************************************************************************/ - - typedef enum OMX_RPC_CORE_TYPE - { - OMX_RPC_CORE_TESLA = 0, - OMX_RPC_CORE_APPM3 = 1, - OMX_RPC_CORE_SYSM3 = 2, - RPC_CORE_CHIRON = 3, - OMX_RPC_CORE_MAX = 4 - } OMX_RPC_CORE_TYPE; - - - -/*===============================================================*/ -/** RPC_OMX_FXN_IDX_TYPE : A unique function index for each OMX function - */ -/*===============================================================*/ - typedef enum RPC_OMX_FXN_IDX_TYPE - { - - RPC_OMX_FXN_IDX_GET_HANDLE = 0, - RPC_OMX_FXN_IDX_SET_PARAMETER = 1, - RPC_OMX_FXN_IDX_GET_PARAMETER = 2, - RPC_OMX_FXN_IDX_USE_BUFFER = 3, - RPC_OMX_FXN_IDX_FREE_HANDLE = 4, - RPC_OMX_FXN_IDX_SET_CONFIG = 5, - RPC_OMX_FXN_IDX_GET_CONFIG = 6, - RPC_OMX_FXN_IDX_GET_STATE = 7, - RPC_OMX_FXN_IDX_SEND_CMD = 8, - RPC_OMX_FXN_IDX_GET_VERSION = 9, - RPC_OMX_FXN_IDX_GET_EXT_INDEX = 10, - RPC_OMX_FXN_IDX_FILLTHISBUFFER = 11, - RPC_OMX_FXN_IDX_FILLBUFFERDONE = 12, - RPC_OMX_FXN_IDX_FREE_BUFFER = 13, - RPC_OMX_FXN_IDX_EMPTYTHISBUFFER = 14, - RPC_OMX_FXN_IDX_EMPTYBUFFERDONE = 15, - RPC_OMX_FXN_IDX_EVENTHANDLER = 16, - RPC_OMX_FXN_IDX_ALLOCATE_BUFFER = 17, - RPC_OMX_FXN_IDX_COMP_TUNNEL_REQUEST = 18, - RPC_OMX_FXN_IDX_MAX = RPC_OMX_MAX_FUNCTION_LIST - } RPC_OMX_FXN_IDX_TYPE; - - - -/*===============================================================*/ -/** RPC_OMX_MAP_INFO_TYPE : Tells the no. of buffers that the kernel has to - map to remote core. - */ -/*===============================================================*/ - typedef enum RPC_OMX_MAP_INFO_TYPE - { - RPC_OMX_MAP_INFO_NONE = 0, - RPC_OMX_MAP_INFO_ONE_BUF = 1, - RPC_OMX_MAP_INFO_TWO_BUF = 2, - RPC_OMX_MAP_INFO_THREE_BUF = 3, - RPC_OMX_MAP_INFO_MAX = 0x7FFFFFFF - } RPC_OMX_MAP_INFO_TYPE; - - - -/******************************************************************************* -* STRUCTURES -*******************************************************************************/ - -/*===============================================================*/ -/** RPC_OMX_CONTEXT : RPC context structure - * - * @ param fd_omx : File descriptor corresponding to this - * instance on remote core. - * @ param fd_killcb : File descriptor used to shut down the - * callback thread. - * @ param cbThread : Callback thread. - * @ param pMsgPipe : Array of message pipes. One for each OMX - * function. Used to post and receive the - * return messages of each function. - * @ param hRemoteHandle : Handle to the context structure on the - * remote core. - * @ param hActualRemoteCompHandle : Actual component handle on remote core. - * @ param pAppData : App data of RPC caller - * - */ -/*===============================================================*/ - typedef struct RPC_OMX_CONTEXT - { - OMX_S32 fd_omx; - OMX_S32 fd_killcb; - pthread_t cbThread; - OMX_PTR pMsgPipe[RPC_OMX_MAX_FUNCTION_LIST]; - OMX_HANDLETYPE hRemoteHandle; - OMX_HANDLETYPE hActualRemoteCompHandle; - OMX_PTR pAppData; - } RPC_OMX_CONTEXT; - -#ifdef __cplusplus -} -#endif -#endif diff --git a/domx/domx/omx_rpc/inc/omx_rpc_skel.h b/domx/domx/omx_rpc/inc/omx_rpc_skel.h deleted file mode 100755 index b36281c..0000000 --- a/domx/domx/omx_rpc/inc/omx_rpc_skel.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_rpc_skel.h - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework RPC. - * - * @path \WTSD_DucatiMMSW\framework\domx\omx_rpc\inc - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 29-Mar-2010 Abhishek Ranka : Revamped DOMX implementation - *! - *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version - *================================================================*/ - - -#ifndef OMX_RPC_SKELH -#define OMX_RPC_SKELH - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ - -#include "../inc/omx_rpc_internal.h" -#include "../inc/omx_rpc_stub.h" - - RPC_OMX_ERRORTYPE RPC_SKEL_EmptyBufferDone(void *data); - RPC_OMX_ERRORTYPE RPC_SKEL_FillBufferDone(void *data); - RPC_OMX_ERRORTYPE RPC_SKEL_EventHandler(void *data); - -/*Empty SKEL*/ - RPC_OMX_ERRORTYPE RPC_SKEL_GetHandle(uint32_t size, uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_SetParameter(uint32_t size, - uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_GetParameter(uint32_t size, - uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_FreeHandle(uint32_t size, uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_EmptyThisBuffer(uint32_t size, - uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_FillThisBuffer(uint32_t size, - uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_UseBuffer(uint32_t size, uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_FreeBuffer(uint32_t size, uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_SetConfig(uint32_t size, uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_GetConfig(uint32_t size, uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_GetState(uint32_t size, uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_SendCommand(uint32_t size, - uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_GetComponentVersion(uint32_t size, - uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_GetExtensionIndex(uint32_t size, - uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_AllocateBuffer(uint32_t size, - uint32_t * data); - RPC_OMX_ERRORTYPE RPC_SKEL_ComponentTunnelRequest(uint32_t size, - uint32_t * data); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/domx/domx/omx_rpc/inc/omx_rpc_stub.h b/domx/domx/omx_rpc/inc/omx_rpc_stub.h deleted file mode 100755 index fd06506..0000000 --- a/domx/domx/omx_rpc/inc/omx_rpc_stub.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_rpc_stub.h - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework RPC. - * - * @path \WTSD_DucatiMMSW\framework\domx\omx_rpc\inc - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 29-Mar-2010 Abhishek Ranka : Revamped DOMX implementation - *! - *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version - *================================================================*/ - -#ifndef OMX_RPC_STUBH -#define OMX_RPC_STUBH - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -#include "omx_rpc.h" -#include "omx_rpc_internal.h" - - RPC_OMX_ERRORTYPE RPC_GetHandle(OMX_HANDLETYPE hRPCCtx, - OMX_STRING cComponentName, OMX_PTR pAppData, - OMX_CALLBACKTYPE * pCallBacks, OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_FreeHandle(OMX_HANDLETYPE hRPCCtx, - OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_UseBuffer(OMX_HANDLETYPE hRPCCtx, - OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr, OMX_U32 nPortIndex, - OMX_PTR pAppPrivate, OMX_U32 nSizeBytes, OMX_U8 * pBuffer, - OMX_U32 * pBufHeaderRemote, OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_SetParameter(OMX_HANDLETYPE hRPCCtx, - OMX_INDEXTYPE nParamIndex, OMX_PTR pCompParam, - OMX_PTR pLocBufNeedMap, OMX_U32 nNumOfLocalBuf, OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_GetParameter(OMX_HANDLETYPE hRPCCtx, - OMX_INDEXTYPE nParamIndex, OMX_PTR pCompParam, - OMX_PTR pLocBufNeedMap, OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_FillThisBuffer(OMX_HANDLETYPE hRPCCtx, - OMX_BUFFERHEADERTYPE * pBufferHdr, OMX_U32 BufHdrRemote, - OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_EmptyThisBuffer(OMX_HANDLETYPE hRPCCtx, - OMX_BUFFERHEADERTYPE * pBufferHdr, OMX_U32 BufHdrRemote, - OMX_ERRORTYPE * nCmdStatus,OMX_BOOL bMapBuffer); - - RPC_OMX_ERRORTYPE RPC_FreeBuffer(OMX_HANDLETYPE hRPCCtx, - OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_U32 BufHdrRemote, - OMX_U32 pBuffer, OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_SetConfig(OMX_HANDLETYPE hRPCCtx, - OMX_INDEXTYPE nConfigIndex, OMX_PTR pCompConfig, - OMX_PTR pLocBufNeedMap, OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_GetConfig(OMX_HANDLETYPE hRPCCtx, - OMX_INDEXTYPE nConfigIndex, OMX_PTR pCompConfig, - OMX_PTR pLocBufNeedMap, OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_GetComponentVersion(OMX_HANDLETYPE hRPCCtx, - OMX_STRING pComponentName, OMX_VERSIONTYPE * pComponentVersion, - OMX_VERSIONTYPE * pSpecVersion, OMX_UUIDTYPE * pComponentUUID, - OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_SendCommand(OMX_HANDLETYPE hRPCCtx, - OMX_COMMANDTYPE eCmd, OMX_U32 nParam, OMX_PTR pCmdData, - OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_GetState(OMX_HANDLETYPE hRPCCtx, - OMX_STATETYPE * pState, OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_GetExtensionIndex(OMX_HANDLETYPE hComponent, - OMX_STRING cParameterName, OMX_INDEXTYPE * pIndexType, - OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_AllocateBuffer(OMX_HANDLETYPE hRPCCtx, - OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr, - OMX_IN OMX_U32 nPortIndex, OMX_U32 * pBufHeaderRemote, - OMX_PTR pAppPrivate, OMX_U32 nSizeBytes, - OMX_ERRORTYPE * nCmdStatus); - - RPC_OMX_ERRORTYPE RPC_ComponentTunnelRequest(OMX_HANDLETYPE hRPCCtx, - OMX_IN OMX_U32 nPort, OMX_HANDLETYPE hTunneledremoteHandle, - OMX_U32 nTunneledPort, - OMX_INOUT OMX_TUNNELSETUPTYPE * pTunnelSetup, - OMX_ERRORTYPE * nCmdStatus); - -/*Empty Stubs*/ - OMX_ERRORTYPE RPC_EventHandler(OMX_HANDLETYPE hRPCCtx, - OMX_PTR pAppData, OMX_EVENTTYPE eEvent, OMX_U32 nData1, - OMX_U32 nData2, OMX_PTR pEventData); - OMX_ERRORTYPE RPC_EmptyBufferDone(OMX_HANDLETYPE hRPCCtx, - OMX_PTR pAppData, OMX_BUFFERHEADERTYPE * pBuffer); - OMX_ERRORTYPE RPC_FillBufferDone(OMX_HANDLETYPE hRPCCtx, - OMX_PTR pAppData, OMX_BUFFERHEADERTYPE * pBuffer); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/domx/domx/omx_rpc/inc/omx_rpc_utils.h b/domx/domx/omx_rpc/inc/omx_rpc_utils.h deleted file mode 100755 index d8334c9..0000000 --- a/domx/domx/omx_rpc/inc/omx_rpc_utils.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_rpc_utils.h - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework RPC. - * - * @path \WTSD_DucatiMMSW\framework\domx\omx_rpc\inc - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 29-Mar-2010 Abhishek Ranka : Revamped DOMX implementation - *! - *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version - *================================================================*/ - -#ifndef OMX_RPC_UTILSH -#define OMX_RPC_UTILSH - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -#include "omx_rpc.h" -#include "omx_rpc_internal.h" - -#include - -#define DOMX_ERROR(fmt,...) TIMM_OSAL_Error(fmt, ##__VA_ARGS__) -#define DOMX_WARN(fmt,...) TIMM_OSAL_Warning(fmt, ##__VA_ARGS__) -#define DOMX_PROF(fmt,...) TIMM_OSAL_Profiling(fmt, ##__VA_ARGS__) -#define DOMX_INFO(fmt,...) TIMM_OSAL_Info(fmt, ##__VA_ARGS__) -#define DOMX_DEBUG(fmt,...) TIMM_OSAL_Debug(fmt, ##__VA_ARGS__) -#define DOMX_ENTER(fmt,...) TIMM_OSAL_Entering(fmt, ##__VA_ARGS__) -#define DOMX_EXIT(fmt,...) TIMM_OSAL_Exiting(fmt, ##__VA_ARGS__) - - -/****************************************************************** - * MACROS - ASSERTS - ******************************************************************/ -#define RPC_assert RPC_paramCheck -#define RPC_require RPC_paramCheck -#define RPC_ensure RPC_paramCheck - -#define RPC_paramCheck(C, V, S) do { \ - if (!(C)) { eRPCError = V;\ - if(S) DOMX_ERROR("failed check:" #C" - returning error: 0x%x - %s",V,S);\ - else DOMX_ERROR("failed check:" #C" - returning error: 0x%x",V); \ - goto EXIT; } \ - } while(0) - -/* ************************* OFFSET DEFINES ******************************** */ -#define GET_PARAM_DATA_OFFSET (sizeof(RPC_OMX_HANDLE) + sizeof(OMX_INDEXTYPE) + sizeof(OMX_U32) /*4 bytes for offset*/ ) -#define USE_BUFFER_DATA_OFFSET (sizeof(OMX_U32)*5) - -/****************************************************************** - * MACROS - ******************************************************************/ -#define RPC_UTIL_GETSTRUCTSIZE(PTR) *((OMX_U32*)PTR) - -/****************************************************************** - * MACROS - COMMON MARSHALLING UTILITIES - ******************************************************************/ -#define RPC_SETFIELDVALUE(MSGBODY, POS, VALUE, TYPE) do { \ - *((TYPE *) ((OMX_U32)MSGBODY+POS)) = (TYPE)VALUE; \ - POS += sizeof(TYPE); \ - } while(0) - -#define RPC_SETFIELDOFFSET(MSGBODY, POS, OFFSET, TYPE) do { \ - *((TYPE *) ((OMX_U32)MSGBODY+POS)) = OFFSET; \ - POS += sizeof(TYPE); \ - } while(0) - -#define RPC_SETFIELDCOPYGEN(MSGBODY, POS, PTR, SIZE) do { \ - TIMM_OSAL_Memcpy((OMX_U8*)((OMX_U32)MSGBODY+POS), PTR, SIZE); \ - POS += SIZE; \ - } while (0) - -#define RPC_SETFIELDCOPYTYPE(MSGBODY, POS, PSTRUCT, TYPE) do { \ - *((TYPE *)((OMX_U32)MSGBODY+POS)) = *PSTRUCT; \ - POS += sizeof(TYPE); \ - } while (0) - -/****************************************************************** - * MACROS - COMMON UNMARSHALLING UTILITIES - ******************************************************************/ -#define RPC_GETFIELDVALUE(MSGBODY, POS, VALUE, TYPE) do { \ - VALUE = *((TYPE *) ((OMX_U32)MSGBODY+POS)); \ - POS += sizeof(TYPE); \ - } while(0) - -#define RPC_GETFIELDOFFSET(MSGBODY, POS, OFFSET, TYPE) do { \ - OFFSET = *((TYPE *) ((OMX_U32)MSGBODY+POS)); \ - POS += sizeof(TYPE); \ - } while(0) - -#define RPC_GETFIELDCOPYGEN(MSGBODY, POS, PTR, SIZE) do { \ - TIMM_OSAL_Memcpy(PTR, (OMX_U8*)((OMX_U32)MSGBODY+POS), SIZE); \ - POS += SIZE; \ - } while(0) - -#define RPC_GETFIELDCOPYTYPE(MSGBODY, POS, PSTRUCT, TYPE) do { \ - *PSTRUCT = *((TYPE *)((OMX_U32)MSGBODY+POS)); \ - POS += sizeof(TYPE); \ - } while(0) - -#define RPC_GETFIELDPATCHED(MSGBODY, OFFSET, PTR, TYPE) \ -PTR = (TYPE *) (MSGBODY+OFFSET); - -/****************************************************************** - * FUNCTIONS - ******************************************************************/ - RPC_OMX_ERRORTYPE RPC_UnMapBuffer(OMX_U32 mappedBuffer); - RPC_OMX_ERRORTYPE RPC_MapBuffer(OMX_U32 mappedBuffer); - RPC_OMX_ERRORTYPE RPC_FlushBuffer(OMX_U8 * pBuffer, OMX_U32 size, - OMX_U32 nTargetCoreId); - RPC_OMX_ERRORTYPE RPC_InvalidateBuffer(OMX_U8 * pBuffer, - OMX_U32 size, OMX_U32 nTargetCoreId); - - RPC_OMX_ERRORTYPE RPC_UTIL_GetTargetServerName(OMX_STRING - ComponentName, OMX_STRING ServerName); - RPC_OMX_ERRORTYPE RPC_UTIL_GetLocalServerName(OMX_STRING - ComponentName, OMX_STRING * ServerName); - RPC_OMX_ERRORTYPE RPC_UTIL_GenerateLocalServerName(OMX_STRING - cServerName); - RPC_OMX_ERRORTYPE RPC_UTIL_GetTargetCore(OMX_STRING cComponentName, - OMX_U32 * nCoreId); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/domx/domx/omx_rpc/src/omx_rpc.c b/domx/domx/omx_rpc/src/omx_rpc.c deleted file mode 100755 index 0743491..0000000 --- a/domx/domx/omx_rpc/src/omx_rpc.c +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_rpc_stub.c - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework RPC Stub implementations. - * - * @path \WTSD_DucatiMMSW\framework\domx\omx_rpc\src - * - * @rev 1.0 - */ - - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -/* ----- system and platform files ----------------------------*/ -#include -//#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -/*-------program files ----------------------------------------*/ -#include "omx_rpc.h" -#include "omx_proxy_common.h" -#include "omx_rpc_stub.h" -#include "omx_rpc_skel.h" -#include "omx_rpc_internal.h" -#include "omx_rpc_utils.h" - -#include "rpmsg_omx_defs.h" - -#define RPC_MSGPIPE_SIZE (4) -#define RPC_MSG_SIZE_FOR_PIPE (sizeof(OMX_PTR)) -#define MAX_ATTEMPTS 15 - -#define RPC_getPacket(nPacketSize, pPacket) do { \ - pPacket = TIMM_OSAL_Malloc(nPacketSize, TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); \ - RPC_assert(pPacket != NULL, RPC_OMX_ErrorInsufficientResources, \ - "Error Allocating RCM Message Frame"); \ - } while(0) - -#define RPC_freePacket(pPacket) do { \ - if(pPacket != NULL) TIMM_OSAL_Free(pPacket); \ - } while(0) - -OMX_U8 pBufferError[RPC_PACKET_SIZE]; - -void *RPC_CallbackThread(void *data); - - -/* ===========================================================================*/ -/** -* @name RPC_InstanceInit() -* @brief RPC instance init is used for initialization. It is called once for -* every instance of an OMX component. -* @param cComponentName [IN] : Name of the component. -* @param phRPCCtx [OUT] : RPC Context structure - to be filled in and returned -* @return RPC_OMX_ErrorNone = Successful -*/ -/* ===========================================================================*/ - -RPC_OMX_ERRORTYPE RPC_InstanceInit(OMX_STRING cComponentName, - OMX_HANDLETYPE * phRPCCtx) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - RPC_OMX_CONTEXT *pRPCCtx = NULL; - OMX_S32 status = 0; - struct omx_conn_req sReq = { .name = "OMX" }; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - OMX_U32 i = 0, nAttempts = 0; - - *(RPC_OMX_CONTEXT **) phRPCCtx = NULL; - - //pthread_t cbThread; - -// sReq.name = "OMX"; - - /*pRPCCtx contains context information for each instance */ - pRPCCtx = - (RPC_OMX_CONTEXT *) TIMM_OSAL_Malloc(sizeof(RPC_OMX_CONTEXT), - TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); - RPC_assert(pRPCCtx != NULL, RPC_OMX_ErrorInsufficientResources, - "Malloc failed"); - TIMM_OSAL_Memset(pRPCCtx, 0, sizeof(RPC_OMX_CONTEXT)); - - /*Assuming that open maintains an internal count for multi instance */ - DOMX_DEBUG("Calling open on the device"); - while (1) - { - pRPCCtx->fd_omx = open("/dev/rpmsg-omx1", O_RDWR); - if(pRPCCtx->fd_omx >= 0 || errno != ENOENT || nAttempts == MAX_ATTEMPTS) - break; - DOMX_DEBUG("errno from open= %d, REATTEMPTING OPEN!!!!",errno); - nAttempts++; - usleep(1000000); - } - if(pRPCCtx->fd_omx < 0) - { - DOMX_ERROR("Can't open device, errorno from open = %d",errno); - eError = RPC_OMX_ErrorInsufficientResources; - goto EXIT; - } - DOMX_DEBUG("Open was successful, pRPCCtx->fd_omx = %d", - pRPCCtx->fd_omx); -//AD -// strncpy(sReq.name, cComponentName, OMX_MAX_STRINGNAME_SIZE); - - DOMX_DEBUG("Calling ioctl"); - status = ioctl(pRPCCtx->fd_omx, OMX_IOCCONNECT, &sReq); - RPC_assert(status >= 0, RPC_OMX_ErrorInsufficientResources, - "Can't connect"); - - for (i = 0; i < RPC_OMX_MAX_FUNCTION_LIST; i++) - { - eError = - TIMM_OSAL_CreatePipe(&(pRPCCtx->pMsgPipe[i]), - RPC_MSGPIPE_SIZE, RPC_MSG_SIZE_FOR_PIPE, 1); - RPC_assert(eError == TIMM_OSAL_ERR_NONE, - RPC_OMX_ErrorInsufficientResources, - "Pipe creation failed"); - } - - DOMX_DEBUG("Creating event fd"); - pRPCCtx->fd_killcb = eventfd(0, 0); - RPC_assert(pRPCCtx->fd_killcb >= 0, - RPC_OMX_ErrorInsufficientResources, "Can't create kill fd"); - /*Create a listener/server thread to listen for Ducati callbacks */ - DOMX_DEBUG("Create listener thread"); - status = - pthread_create(&(pRPCCtx->cbThread), NULL, RPC_CallbackThread, - pRPCCtx); - RPC_assert(status == 0, RPC_OMX_ErrorInsufficientResources, - "Can't create cb thread"); - - EXIT: - if (eRPCError != RPC_OMX_ErrorNone) - { - RPC_InstanceDeInit(pRPCCtx); - } - else - { - *(RPC_OMX_CONTEXT **) phRPCCtx = pRPCCtx; - } - return eRPCError; -} - - - -/* ===========================================================================*/ -/** -* @name RPC_InstanceDeInit() -* @brief RPC instance deinit is used for tear down. It is called once when an -* instance of OMX component is going down. -* @param phRPCCtx [IN] : RPC Context structure. -* @return RPC_OMX_ErrorNone = Successful -*/ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_InstanceDeInit(OMX_HANDLETYPE hRPCCtx) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - RPC_OMX_CONTEXT *pRPCCtx = (RPC_OMX_CONTEXT *) hRPCCtx; - OMX_S32 status = 0; - OMX_U32 i = 0; - OMX_U64 nKillEvent = 1; - - RPC_assert(hRPCCtx != NULL, RPC_OMX_ErrorUndefined, - "NULL context handle supplied to RPC Deinit"); - - if (pRPCCtx->fd_killcb) - { - status = - write(pRPCCtx->fd_killcb, &nKillEvent, sizeof(OMX_U64)); - if (status <= 0) - { - DOMX_ERROR - ("Write to kill fd failed - cb thread may not exit"); - eRPCError = RPC_OMX_ErrorUndefined; - } else if (pRPCCtx->cbThread) - { - DOMX_DEBUG("Waiting for cb thread to exit"); - status = pthread_join(pRPCCtx->cbThread, NULL); - if (status != 0) - { - DOMX_ERROR("Join for cb thread failed"); - eRPCError = RPC_OMX_ErrorUndefined; - } - } - DOMX_DEBUG("Closing the kill fd"); - status = close(pRPCCtx->fd_killcb); - pRPCCtx->fd_killcb = 0; - if (status != 0) - { - DOMX_ERROR("Close failed on kill fd"); - eRPCError = RPC_OMX_ErrorUndefined; - } - } - - for (i = 0; i < RPC_OMX_MAX_FUNCTION_LIST; i++) - { - if (pRPCCtx->pMsgPipe[i]) - { - eError = TIMM_OSAL_DeletePipe(pRPCCtx->pMsgPipe[i]); - pRPCCtx->pMsgPipe[i] = NULL; - if (eError != TIMM_OSAL_ERR_NONE) - { - DOMX_ERROR("Pipe deletion failed"); - eRPCError = RPC_OMX_ErrorUndefined; - } - } - } - - DOMX_DEBUG("Closing the omx fd"); - if (pRPCCtx->fd_omx) - { - status = close(pRPCCtx->fd_omx); - pRPCCtx->fd_omx = 0; - if (status != 0) - { - DOMX_ERROR("Close failed on omx fd"); - eRPCError = RPC_OMX_ErrorUndefined; - } - } - - TIMM_OSAL_Free(pRPCCtx); - - EXIT: - return eRPCError; -} - - - -/* ===========================================================================*/ -/** -* @name RPC_CallbackThread() -* @brief This is the entry function of the thread which keeps spinning, waiting -* for messages from Ducati. -* @param data [IN] : The RPC Context structure is passed here. -* @return RPC_OMX_ErrorNone = Successful -*/ -/* ===========================================================================*/ -void *RPC_CallbackThread(void *data) -{ - OMX_PTR pBuffer = NULL; - RPC_OMX_CONTEXT *pRPCCtx = (RPC_OMX_CONTEXT *) data; - fd_set readfds; - OMX_S32 maxfd = 0, status = 0; - OMX_U32 nFxnIdx = 0, nPacketSize = RPC_PACKET_SIZE, nPos = 0; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - OMX_COMPONENTTYPE *hComp = NULL; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_PTR pBuff = pBufferError; - - maxfd = - (pRPCCtx->fd_killcb > - pRPCCtx->fd_omx ? pRPCCtx->fd_killcb : pRPCCtx->fd_omx) + 1; - while (1) - { - FD_ZERO(&readfds); - FD_SET(pRPCCtx->fd_omx, &readfds); - FD_SET(pRPCCtx->fd_killcb, &readfds); - - DOMX_DEBUG("Waiting for messages from remote core"); - status = select(maxfd, &readfds, NULL, NULL, NULL); - RPC_assert(status > 0, RPC_OMX_ErrorUndefined, - "select failed"); - - if (FD_ISSET(pRPCCtx->fd_killcb, &readfds)) - { - DOMX_DEBUG("Recd. kill message - exiting the thread"); - break; - } - - if (FD_ISSET(pRPCCtx->fd_omx, &readfds)) - { - DOMX_DEBUG("Recd. omx message"); - RPC_getPacket(nPacketSize, pBuffer); - status = read(pRPCCtx->fd_omx, pBuffer, nPacketSize); - if(status < 0) - { - if(errno == ENXIO) - { - for(nFxnIdx = 0; nFxnIdx < RPC_OMX_MAX_FUNCTION_LIST; nFxnIdx++) - { - ((struct omx_packet *) pBufferError)->result = OMX_ErrorHardware; - TIMM_OSAL_WriteToPipe(pRPCCtx->pMsgPipe[nFxnIdx], &pBuff, RPC_MSG_SIZE_FOR_PIPE, TIMM_OSAL_SUSPEND); - if(eError != TIMM_OSAL_ERR_NONE) - DOMX_ERROR("Write to pipe failed"); - } - /*Indicate fatal error and exit*/ - RPC_assert(0, RPC_OMX_ErrorHardware, - "Remote processor fatal error"); - } - else - { - RPC_assert(0, RPC_OMX_ErrorUndefined, - "read failed"); - } - } - - nPos = 0; - nFxnIdx = ((struct omx_packet *) pBuffer)->fxn_idx; - /*Indices from static table will have bit 31 set */ - if (nFxnIdx & 0x80000000) - nFxnIdx &= 0x0FFFFFFF; - RPC_assert(nFxnIdx < RPC_OMX_MAX_FUNCTION_LIST, - RPC_OMX_ErrorUndefined, - "Bad function index recd"); - switch (nFxnIdx) - { - case RPC_OMX_FXN_IDX_EVENTHANDLER: - RPC_SKEL_EventHandler(((struct omx_packet *) - pBuffer)->data); - RPC_freePacket(pBuffer); - pBuffer = NULL; - break; - case RPC_OMX_FXN_IDX_EMPTYBUFFERDONE: - RPC_SKEL_EmptyBufferDone(((struct omx_packet *) - pBuffer)->data); - RPC_freePacket(pBuffer); - pBuffer = NULL; - break; - case RPC_OMX_FXN_IDX_FILLBUFFERDONE: - RPC_SKEL_FillBufferDone(((struct omx_packet *) - pBuffer)->data); - RPC_freePacket(pBuffer); - pBuffer = NULL; - break; - default: - eError = - TIMM_OSAL_WriteToPipe(pRPCCtx-> - pMsgPipe[nFxnIdx], &pBuffer, - RPC_MSG_SIZE_FOR_PIPE, TIMM_OSAL_SUSPEND); - RPC_assert(eError == TIMM_OSAL_ERR_NONE, - RPC_OMX_ErrorUndefined, - "Write to pipe failed"); - break; - } - } -EXIT: - if (eRPCError != RPC_OMX_ErrorNone) - { - //AD TODO: Send error CB to client and then go back in loop to wait for killfd - if (pBuffer != NULL) - { - RPC_freePacket(pBuffer); - pBuffer = NULL; - } - /*Report all hardware errors as fatal and exit from listener thread*/ - if (eRPCError == RPC_OMX_ErrorHardware) - { - /*Implicit detail: pAppData is proxy component handle updated during - RPC_GetHandle*/ - hComp = (OMX_COMPONENTTYPE *) pRPCCtx->pAppData; - if(hComp != NULL) - { - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - /*Indicate fatal error. Users are expected to cleanup the OMX instance - to ensure all resources are cleaned up.*/ - pCompPrv->proxyEventHandler(hComp, pCompPrv->pILAppData, OMX_EventError, - OMX_ErrorHardware, 0, NULL); - } - break; - } - } - } - return (void*)0; -} diff --git a/domx/domx/omx_rpc/src/omx_rpc_config.c b/domx/domx/omx_rpc/src/omx_rpc_config.c deleted file mode 100755 index 8b13789..0000000 --- a/domx/domx/omx_rpc/src/omx_rpc_config.c +++ /dev/null @@ -1 +0,0 @@ - diff --git a/domx/domx/omx_rpc/src/omx_rpc_platform.c b/domx/domx/omx_rpc/src/omx_rpc_platform.c deleted file mode 100755 index 8b13789..0000000 --- a/domx/domx/omx_rpc/src/omx_rpc_platform.c +++ /dev/null @@ -1 +0,0 @@ - diff --git a/domx/domx/omx_rpc/src/omx_rpc_skel.c b/domx/domx/omx_rpc/src/omx_rpc_skel.c deleted file mode 100755 index 5b8d423..0000000 --- a/domx/domx/omx_rpc/src/omx_rpc_skel.c +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_rpc_skel.c - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework RPC Skeleton implementations. - * - * @path \WTSD_DucatiMMSW\framework\domx\omx_rpc\src - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 29-Mar-2010 Abhishek Ranka : Revamped DOMX implementation - *! - *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version - *================================================================*/ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ - -#include -#include - -#include -#include - -#include "omx_rpc.h" -#include "omx_proxy_common.h" -#include "omx_rpc_skel.h" -#include "omx_rpc_utils.h" -#include "omx_rpc_internal.h" - -/* FUNCTION LIST*/ -/* -RPC_OMX_ERRORTYPE RPC_SKEL_EmptyBufferDone(uint32_t size, uint32_t *data) -RPC_OMX_ERRORTYPE RPC_SKEL_FillBufferDone(uint32_t size, uint32_t *data) -RPC_OMX_ERRORTYPE RPC_SKEL_EventHandler(uint32_t size, uint32_t *data) -*/ - - -/* ===========================================================================*/ -/** - * @name RPC_SKEL_FillBufferDone() - * @brief Skeleton for OMX_AllocateBuffer() - * @param size : Size of the incoming RCM message (parameter used in the RCM alloc call) - * @param *data : Pointer to the RCM message/buffer received - * @return RPC_OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_SKEL_EmptyBufferDone(void *data) -{ - - OMX_HANDLETYPE hComp; - RPC_OMX_ERRORTYPE tRPCError = RPC_OMX_ErrorNone; - OMX_U32 nfilledLen = 0; - OMX_U32 nOffset = 0; - OMX_U32 nFlags = 0; - OMX_U32 bufferHdr; - OMX_COMPONENTTYPE *pHandle = NULL; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_U32 nPos = 0; - //RPC_OMX_MESSAGE *recdMsg; - OMX_U8 *pMsgBody = NULL; - //recdMsg = (RPC_OMX_MESSAGE *) (data); - - pMsgBody = data; //&recdMsg->msgBody[0]; - - DOMX_ENTER(""); - - //Marshalled:[>hComp|>bufferHdr|>nFilledLen|>nOffset|>nFlags] - - RPC_GETFIELDVALUE(pMsgBody, nPos, hComp, OMX_HANDLETYPE); - pHandle = (OMX_COMPONENTTYPE *) hComp; - pCompPrv = (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - - RPC_GETFIELDVALUE(pMsgBody, nPos, bufferHdr, OMX_U32); - - RPC_GETFIELDVALUE(pMsgBody, nPos, nfilledLen, OMX_U32); - RPC_GETFIELDVALUE(pMsgBody, nPos, nOffset, OMX_U32); - RPC_GETFIELDVALUE(pMsgBody, nPos, nFlags, OMX_U32); - - tRPCError = - pCompPrv->proxyEmptyBufferDone(hComp, bufferHdr, nfilledLen, - nOffset, nFlags); - - DOMX_EXIT(""); - return tRPCError; -} - -/* ===========================================================================*/ -/** - * @name RPC_SKEL_FillBufferDone() - * @brief Skeleton for OMX_AllocateBuffer() - * @param size : Size of the incoming RCM message (parameter used in the RCM alloc call) - * @param *data : Pointer to the RCM message/buffer received - * @return RPC_OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_SKEL_FillBufferDone(void *data) -{ - - OMX_HANDLETYPE hComp; - RPC_OMX_ERRORTYPE tRPCError = RPC_OMX_ErrorNone; - OMX_U32 nfilledLen = 0; - OMX_U32 nOffset = 0; - OMX_U32 nFlags = 0; - OMX_TICKS nTimeStamp; - OMX_U32 bufferHdr; - OMX_COMPONENTTYPE *pHandle = NULL; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_U32 nPos = 0; - //RPC_OMX_MESSAGE *recdMsg; - OMX_U8 *pMsgBody = NULL; - OMX_HANDLETYPE hMarkTargetComponent = NULL; - OMX_PTR pMarkData = NULL; - //recdMsg = (RPC_OMX_MESSAGE *) (data); - - pMsgBody = data; //&recdMsg->msgBody[0]; - - DOMX_ENTER(""); - - //Marshalled:[>hComp|>bufferHdr|>nFilledLen|>nOffset|>nFlags|>nTimeStamp] - - RPC_GETFIELDVALUE(pMsgBody, nPos, hComp, OMX_HANDLETYPE); - pHandle = (OMX_COMPONENTTYPE *) hComp; - pCompPrv = (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - - RPC_GETFIELDVALUE(pMsgBody, nPos, bufferHdr, OMX_U32); - RPC_GETFIELDVALUE(pMsgBody, nPos, nfilledLen, OMX_U32); - RPC_GETFIELDVALUE(pMsgBody, nPos, nOffset, OMX_U32); - RPC_GETFIELDVALUE(pMsgBody, nPos, nFlags, OMX_U32); - RPC_GETFIELDVALUE(pMsgBody, nPos, nTimeStamp, OMX_TICKS); - RPC_GETFIELDVALUE(pMsgBody, nPos, hMarkTargetComponent, - OMX_HANDLETYPE); - RPC_GETFIELDVALUE(pMsgBody, nPos, pMarkData, OMX_PTR); - - tRPCError = - pCompPrv->proxyFillBufferDone(hComp, bufferHdr, nfilledLen, - nOffset, nFlags, nTimeStamp, hMarkTargetComponent, pMarkData); - - DOMX_EXIT(""); - return tRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_SKEL_EventHandler() - * @brief Skeleton for OMX_AllocateBuffer() - * @param size : Size of the incoming RCM message (parameter used in the RCM alloc call) - * @param *data : Pointer to the RCM message/buffer received - * @return RPC_OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_SKEL_EventHandler(void *data) -{ - OMX_HANDLETYPE hComp; - RPC_OMX_ERRORTYPE tRPCError = RPC_OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_EVENTTYPE eEvent; - OMX_U32 nData1; - OMX_U32 nData2; - OMX_PTR pEventData; - OMX_U32 nPos = 0; - //RPC_OMX_MESSAGE *recdMsg; - OMX_U8 *pMsgBody = NULL; - //recdMsg = (RPC_OMX_MESSAGE *) (data); - pMsgBody = data; //&recdMsg->msgBody[0]; - - DOMX_ENTER(""); - - //Marshalled:[>hComp|>eEvent|>nData1|>nData2|>pEventData] - - RPC_GETFIELDVALUE(pMsgBody, nPos, hComp, OMX_HANDLETYPE); - pHandle = (OMX_COMPONENTTYPE *) hComp; - pCompPrv = (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - - RPC_GETFIELDVALUE(pMsgBody, nPos, eEvent, OMX_EVENTTYPE); - RPC_GETFIELDVALUE(pMsgBody, nPos, nData1, OMX_U32); - RPC_GETFIELDVALUE(pMsgBody, nPos, nData2, OMX_U32); - RPC_GETFIELDVALUE(pMsgBody, nPos, pEventData, OMX_PTR); - - DOMX_DEBUG - ("\n**__**Got eventhandler from Remote Core succesffuly - values are : **__**"); - DOMX_DEBUG - ("hComp :0x%x,eEvent: 0x%x,nData1: 0x%x,nData2: 0x%x,pEventData: 0x%x", - hComp, eEvent, nData1, nData2, pEventData); - DOMX_DEBUG("Just Before Entering Proxy Event handler call"); - - tRPCError = - pCompPrv->proxyEventHandler(hComp, pCompPrv->pILAppData, eEvent, - nData1, nData2, pEventData); - - DOMX_EXIT(""); - return tRPCError; - -} - -/* ===========================================================================*/ -/** - * @name EMPTY-SKEL - * @brief - * @param - * @return - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_SKEL_GetHandle(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_SetParameter(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_GetParameter(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_FreeHandle(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_EmptyThisBuffer(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_FillThisBuffer(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_UseBuffer(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_FreeBuffer(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_SetConfig(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_GetConfig(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_GetState(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_SendCommand(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_GetComponentVersion(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_GetExtensionIndex(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_AllocateBuffer(uint32_t size, uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_SKEL_ComponentTunnelRequest(uint32_t size, - uint32_t * data) -{ - return RPC_OMX_ErrorNone; -} diff --git a/domx/domx/omx_rpc/src/omx_rpc_stub.c b/domx/domx/omx_rpc/src/omx_rpc_stub.c deleted file mode 100755 index 0c28ba1..0000000 --- a/domx/domx/omx_rpc/src/omx_rpc_stub.c +++ /dev/null @@ -1,1489 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_rpc_stub.c - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework RPC Stub implementations. - * - * @path \WTSD_DucatiMMSW\framework\domx\omx_rpc\src - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 30-Apr-2010 Abhishek Ranka : Fixed GetExtension issue - *! - *! 29-Mar-2010 Abhishek Ranka : Revamped DOMX implementation - *! - *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version - *================================================================*/ -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -#include -#include -#include -#include - -#include "omx_rpc.h" -#include "omx_rpc_utils.h" -#include "omx_proxy_common.h" -#include "omx_rpc_stub.h" -#include -#include - -#include -#include "rpmsg_omx_defs.h" - -/****************************************************************** - * EXTERNS - ******************************************************************/ - -/****************************************************************** - * MACROS - LOCAL - ******************************************************************/ - -//#define RPC_MSGPIPE_SIZE (4) -#define RPC_MSG_SIZE_FOR_PIPE (sizeof(OMX_PTR)) - -/* When this is defined ETB/FTB calls are made in sync mode. Undefining will - * result in these calls being sent via async mode. Sync mode leads to correct - * functionality as per OMX spec but has a slight performance penalty. Async - * mode sacrifices strict adherence to spec for some gain in performance. */ -#define RPC_SYNC_MODE - - -#define RPC_getPacket(nPacketSize, pPacket) do { \ - pPacket = TIMM_OSAL_Malloc(nPacketSize, TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); \ - RPC_assert(pPacket != NULL, RPC_OMX_ErrorInsufficientResources, \ - "Error Allocating RCM Message Frame"); \ - TIMM_OSAL_Memset(pPacket, 0, nPacketSize); \ - } while(0) - -#define RPC_freePacket(pPacket) do { \ - if(pPacket != NULL) TIMM_OSAL_Free(pPacket); \ - } while(0) - -#define RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, nSize) do { \ - status = write(hCtx->fd_omx, pPacket, nPacketSize); \ - RPC_freePacket(pPacket); \ - pPacket = NULL; \ - if(status < 0 && errno == ENXIO) { \ - RPC_assert(0, RPC_OMX_ErrorHardware, "Write failed - Ducati in faulty state"); \ - } \ - if(status != (signed)nPacketSize) { \ - DOMX_ERROR("Write failed returning status = 0x%x",status); \ - RPC_assert(0, RPC_OMX_ErrorUndefined, "Write failed"); \ - } \ - eError = TIMM_OSAL_ReadFromPipe(hCtx->pMsgPipe[nFxnIdx], &pRetPacket, \ - RPC_MSG_SIZE_FOR_PIPE, (TIMM_OSAL_U32 *)(&nSize), TIMM_OSAL_SUSPEND); \ - RPC_assert(eError == TIMM_OSAL_ERR_NONE, eError, \ - "Read failed"); \ - } while(0) - -/*Set bit 31 on fxn idx as it is static function*/ -#define RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize) do { \ - pOmxPacket = (struct omx_packet *)pPacket; \ - pData = pOmxPacket->data; \ - pOmxPacket->desc |= OMX_DESC_MSG << OMX_DESC_TYPE_SHIFT; \ - pOmxPacket->msg_id = 0; \ - pOmxPacket->flags = OMX_POOLID_JOBID_DEFAULT; \ - pOmxPacket->fxn_idx = (nFxnIdx | 0x80000000); \ - pOmxPacket->result = 0; \ - pOmxPacket->data_size = nPacketSize; \ - } while(0) - -//Async to be checked later - most probably same as sync but without the read -#if 0 - -#define RPC_sendPacket_async(HRCM, pPacket, nFxnIdx) do { \ - pPacket->nFxnIdx = nFxnIdx; \ - status = RcmClient_execCmd(HRCM, pPacket); \ - if(status < 0) { \ - RPC_freePacket(HRCM, pPacket); \ - pPacket = NULL; \ - RPC_assert(0, RPC_OMX_RCM_ErrorExecFail, \ - "RcmClient_exec failed"); \ - } \ - } while(0) - -#define RPC_checkAsyncErrors(rcmHndl, pPacket) do { \ - status = RcmClient_checkForError(rcmHndl, &pPacket); \ - if(status < 0) { \ - RPC_freePacket(rcmHndl, pPacket); \ - pPacket = NULL; \ - } \ - RPC_assert(status >= 0, RPC_OMX_RCM_ClientFail, \ - "Async error check returned error"); \ - } while(0) - -#endif -/* ===========================================================================*/ -/** - * @name RPC_GetHandle() - * @brief Remote invocation stub for OMX_GetHandle - * @param hRPCCtx [OUT] : The RPC context handle. - * @param cComponentName [IN] : Name of the component that is to be created - * on Remote core. - * @param pAppData [IN] : The AppData passed by the user. - * @param pCallBacks [IN] : The callback pointers passed by the caller. - * @param eCompReturn [OUT] : This is return value returned by the remote - * component. - * @return RPC_OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_GetHandle(OMX_HANDLETYPE hRPCCtx, - OMX_STRING cComponentName, OMX_PTR pAppData, - OMX_CALLBACKTYPE * pCallBacks, OMX_ERRORTYPE * eCompReturn) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = - NULL, pRetData = NULL; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = NULL; - OMX_HANDLETYPE hActualComp = NULL; - OMX_S32 status = 0; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - struct omx_packet *pOmxPacket = NULL; - - DOMX_ENTER(""); - DOMX_DEBUG("RPC_GetHandle: Recieved GetHandle request from %s", - cComponentName); - - nFxnIdx = RPC_OMX_FXN_IDX_GET_HANDLE; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - DOMX_DEBUG("Packing data"); - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, - RPC_OMX_MAP_INFO_TYPE); - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDCOPYGEN(pData, nPos, cComponentName, - OMX_MAX_STRINGNAME_SIZE); - RPC_SETFIELDVALUE(pData, nPos, pAppData, OMX_PTR); - - DOMX_DEBUG("Sending data"); - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - if (*eCompReturn == OMX_ErrorNone) - { - pRetData = ((struct omx_packet *) pRetPacket)->data; - RPC_GETFIELDVALUE(pRetData, nPos, hComp, OMX_HANDLETYPE); - DOMX_DEBUG("Remote Handle 0x%x", hComp); - hCtx->hRemoteHandle = hComp; - /* The handle received above is used for all communications - with the remote component but is not the actual component - handle (it is actually the rpc context handle which - contains lot of other info). The handle recd. below is the - actual remote component handle. This is used at present for - mark buffer implementation since in that case it is not - feasible to send the context handle */ - RPC_GETFIELDVALUE(pRetData, nPos, hActualComp, - OMX_HANDLETYPE); - DOMX_DEBUG("Actual Remote Comp Handle 0x%x", hActualComp); - hCtx->hActualRemoteCompHandle = hActualComp; - } - - /* Save context information */ - hCtx->pAppData = pAppData; - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_FreeHandle() - * @brief Remote invocation stub for OMX_FreeHandle - * @param hRPCCtx [IN] : The RPC context handle. - * @param eCompReturn [OUT] : Return value returned by the remote component. - * @return RPC_OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_FreeHandle(OMX_HANDLETYPE hRPCCtx, - OMX_ERRORTYPE * eCompReturn) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL; - OMX_S32 status = 0; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - struct omx_packet *pOmxPacket = NULL; - - DOMX_ENTER(""); - - nFxnIdx = RPC_OMX_FXN_IDX_FREE_HANDLE; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, - RPC_OMX_MAP_INFO_TYPE); - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; - -} - - - -/* ===========================================================================*/ -/** - * @name RPC_SetParameter() - * @brief Remote invocation stub for OMX_SetParameter - * @param hRPCCtx [IN] : The RPC context handle. - * @param nParamIndex [IN] : Same as nParamIndex received at the proxy. - * @param pCompParam [IN] : Same as pCompParam recieved at the proxy. - * @param eCompReturn [OUT] : Return value returned by the remote component. - * @return RPC_OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_SetParameter(OMX_HANDLETYPE hRPCCtx, - OMX_INDEXTYPE nParamIndex, OMX_PTR pCompParam, - OMX_PTR pLocBufNeedMap, OMX_U32 nNumOfLocalBuf, OMX_ERRORTYPE * eCompReturn) -{ - - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - OMX_S32 status = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - OMX_U32 structSize = 0; - struct omx_packet *pOmxPacket = NULL; - - nFxnIdx = RPC_OMX_FXN_IDX_SET_PARAMETER; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - if (pLocBufNeedMap != NULL && (pLocBufNeedMap - pCompParam) >= 0 ) { - if (nNumOfLocalBuf == 1) { - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_ONE_BUF, - RPC_OMX_MAP_INFO_TYPE); - } - else if (nNumOfLocalBuf == 2) { - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_TWO_BUF, - RPC_OMX_MAP_INFO_TYPE); - } - nOffset = (pLocBufNeedMap - pCompParam) + - sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) + - sizeof(OMX_HANDLETYPE) + sizeof(OMX_INDEXTYPE); - } else { - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, - RPC_OMX_MAP_INFO_TYPE); - } - - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, nParamIndex, OMX_INDEXTYPE); - structSize = RPC_UTIL_GETSTRUCTSIZE(pCompParam); - RPC_SETFIELDCOPYGEN(pData, nPos, pCompParam, structSize); - - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_GetParameter() - * @brief Remote invocation stub for OMX_GetParameter - * @param hRPCCtx [IN] : The RPC context handle. - * @param nParamIndex [IN] : Same as nParamIndex received at the proxy. - * @param pCompParam [IN] : Same as pCompParam recieved at the proxy. - * @param eCompReturn [OUT] : Return value returned by the remote component. - * @return RPC_OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_GetParameter(OMX_HANDLETYPE hRPCCtx, - OMX_INDEXTYPE nParamIndex, OMX_PTR pCompParam, - OMX_PTR pLocBufNeedMap, OMX_ERRORTYPE * eCompReturn) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = - NULL, pRetData = NULL; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nDataOffset = 0, nOffset = 0; - OMX_S32 status = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - OMX_U32 structSize = 0; - struct omx_packet *pOmxPacket = NULL; - - DOMX_ENTER(""); - - nFxnIdx = RPC_OMX_FXN_IDX_GET_PARAMETER; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - if (pLocBufNeedMap != NULL && (pLocBufNeedMap - pCompParam) >= 0 ) { - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_ONE_BUF, - RPC_OMX_MAP_INFO_TYPE); - nOffset = (pLocBufNeedMap - pCompParam) + - sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) + - sizeof(OMX_HANDLETYPE) + sizeof(OMX_INDEXTYPE); - } else { - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, - RPC_OMX_MAP_INFO_TYPE); - } - - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, nParamIndex, OMX_INDEXTYPE); - nDataOffset = nPos; - structSize = RPC_UTIL_GETSTRUCTSIZE(pCompParam); - RPC_SETFIELDCOPYGEN(pData, nPos, pCompParam, structSize); - - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - if (*eCompReturn == OMX_ErrorNone) - { - pRetData = ((struct omx_packet *) pRetPacket)->data; - /*pCompParam is returned in the same location in which it was sent */ - RPC_GETFIELDCOPYGEN(pRetData, nDataOffset, pCompParam, - structSize); - } - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - //In case of Error Hardware this packet gets freed in omx_rpc.c - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_SetConfig() - * @brief Remote invocation stub for OMX_SetConfig - * @param hRPCCtx [IN] : The RPC context handle. - * @param nConfigIndex [IN] : Same as nConfigIndex received at the proxy. - * @param pCompConfig [IN] : Same as pCompConfig recieved at the proxy. - * @param eCompReturn [OUT] : Return value returned by the remote component. - * @return RPC_OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_SetConfig(OMX_HANDLETYPE hRPCCtx, - OMX_INDEXTYPE nConfigIndex, OMX_PTR pCompConfig, - OMX_PTR pLocBufNeedMap, OMX_ERRORTYPE * eCompReturn) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - OMX_S32 status = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - OMX_U32 structSize = 0; - struct omx_packet *pOmxPacket = NULL; - - DOMX_ENTER(""); - - nFxnIdx = RPC_OMX_FXN_IDX_SET_CONFIG; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - if (pLocBufNeedMap != NULL && (pLocBufNeedMap - pCompConfig) >= 0 ) { - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_ONE_BUF, - RPC_OMX_MAP_INFO_TYPE); - nOffset = (pLocBufNeedMap - pCompConfig) + - sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) + - sizeof(OMX_HANDLETYPE) + sizeof(OMX_INDEXTYPE); - } else { - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, - RPC_OMX_MAP_INFO_TYPE); - } - - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, nConfigIndex, OMX_INDEXTYPE); - structSize = RPC_UTIL_GETSTRUCTSIZE(pCompConfig); - RPC_SETFIELDCOPYGEN(pData, nPos, pCompConfig, structSize); - - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; -} - -/* ===========================================================================*/ -/** - * @name RPC_GetConfig() - * @brief Remote invocation stub for OMX_GetConfig - * @param hRPCCtx [IN] : The RPC context handle. - * @param nConfigIndex [IN] : Same as nConfigIndex received at the proxy. - * @param pCompConfig [IN] : Same as pCompConfig recieved at the proxy. - * @param eCompReturn [OUT] : Return value returned by the remote component. - * @return RPC_OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_GetConfig(OMX_HANDLETYPE hRPCCtx, - OMX_INDEXTYPE nConfigIndex, OMX_PTR pCompConfig, - OMX_PTR pLocBufNeedMap, OMX_ERRORTYPE * eCompReturn) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = - NULL, pRetData = NULL; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0, nDataOffset = 0; - OMX_S32 status = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - OMX_U32 structSize = 0; - struct omx_packet *pOmxPacket = NULL; - - DOMX_ENTER(""); - - nFxnIdx = RPC_OMX_FXN_IDX_GET_CONFIG; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - if (pLocBufNeedMap != NULL && (pLocBufNeedMap - pCompConfig) >= 0 ) { - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_ONE_BUF, - RPC_OMX_MAP_INFO_TYPE); - nOffset = (pLocBufNeedMap - pCompConfig) + - sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) + - sizeof(OMX_HANDLETYPE) + sizeof(OMX_INDEXTYPE); - } else { - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, - RPC_OMX_MAP_INFO_TYPE); - } - - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, nConfigIndex, OMX_INDEXTYPE); - nDataOffset = nPos; - structSize = RPC_UTIL_GETSTRUCTSIZE(pCompConfig); - RPC_SETFIELDCOPYGEN(pData, nPos, pCompConfig, structSize); - - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - if (*eCompReturn == RPC_OMX_ErrorNone) - { - pRetData = ((struct omx_packet *) pRetPacket)->data; - /*pCompParam is returned in the same location in which it was sent */ - RPC_GETFIELDCOPYGEN(pRetData, nDataOffset, pCompConfig, - structSize); - } - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_SendCommand() - * @brief Remote invocation stub for OMX_SendCommand - * @param hRPCCtx [IN] : The RPC context handle. - * @param eCmd [IN] : Same as eCmd received at the proxy. - * @param nParam [IN] : Same as nParam recieved at the proxy. - * @param pCmdData [IN] : Same as pCmdData recieved at the proxy. - * @param eCompReturn [OUT] : Return value returned by the remote component. - * @return RPC_OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_SendCommand(OMX_HANDLETYPE hRPCCtx, - OMX_COMMANDTYPE eCmd, OMX_U32 nParam, OMX_PTR pCmdData, - OMX_ERRORTYPE * eCompReturn) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - OMX_S32 status = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - OMX_U32 structSize = 0; - struct omx_packet *pOmxPacket = NULL; - - DOMX_ENTER(""); - - nFxnIdx = RPC_OMX_FXN_IDX_SEND_CMD; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, - RPC_OMX_MAP_INFO_TYPE); - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, eCmd, OMX_COMMANDTYPE); - RPC_SETFIELDVALUE(pData, nPos, nParam, OMX_U32); - - if (pCmdData != NULL && eCmd == OMX_CommandMarkBuffer) - { - /*The RPC_UTIL_GETSTRUCTSIZE will not work here since OMX_MARKTYPE structure - does not have nSize field */ - structSize = sizeof(OMX_MARKTYPE); - RPC_SETFIELDCOPYGEN(pData, nPos, pCmdData, structSize); - } else if (pCmdData != NULL) - { - structSize = RPC_UTIL_GETSTRUCTSIZE(pCmdData); - RPC_SETFIELDCOPYGEN(pData, nPos, pCmdData, structSize); - } - - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_GetState() - * @brief Remote invocation stub for OMX_GetState - * @param hRPCCtx [IN] : The RPC context handle. - * @param pState [OUT] : State variable, to be filled in and returned by - * the remote component.. - * @param eCompReturn [OUT] : Return value returned by the remote component. - * @return RPC_OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_GetState(OMX_HANDLETYPE hRPCCtx, OMX_STATETYPE * pState, - OMX_ERRORTYPE * eCompReturn) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = - NULL, pRetData = NULL; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - OMX_S32 status = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - struct omx_packet *pOmxPacket = NULL; - - DOMX_ENTER(""); - - nFxnIdx = RPC_OMX_FXN_IDX_GET_STATE; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, - RPC_OMX_MAP_INFO_TYPE); - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - if (*eCompReturn == OMX_ErrorNone) - { - pRetData = ((struct omx_packet *) pRetPacket)->data; - RPC_GETFIELDCOPYTYPE(pRetData, nPos, pState, OMX_STATETYPE); - } - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_GetComponentVersion() - * @brief Remote invocation stub for OMX_GetComponentVersion - * @param hRPCCtx [IN] : The RPC context handle. - * @param pComponentName [OUT] : Component name, to be filled in and returned - * by the remote component. - * @param pComponentVersion [OUT] : Component version info, to be filled in and - * returned by the remote component. - * @param pSpecVersion [OUT] : Spec version info, to be filled in and - * returned by the remote component. - * @param pComponentUUID [OUT] : Component UUID info, to be filled in and - * returned by the remote component (optional). - * @param eCompReturn [OUT] : Return value returned by the remote - * component. - * @return RPC_OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_GetComponentVersion(OMX_HANDLETYPE hRPCCtx, - OMX_STRING pComponentName, OMX_VERSIONTYPE * pComponentVersion, - OMX_VERSIONTYPE * pSpecVersion, OMX_UUIDTYPE * pComponentUUID, - OMX_ERRORTYPE * eCompReturn) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = - NULL, pRetData = NULL; - OMX_S32 status = 0; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - struct omx_packet *pOmxPacket = NULL; - - DOMX_ENTER(""); - - nFxnIdx = RPC_OMX_FXN_IDX_GET_VERSION; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, - RPC_OMX_MAP_INFO_TYPE); - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - if (*eCompReturn == OMX_ErrorNone) - { - pRetData = ((struct omx_packet *) pRetPacket)->data; - RPC_GETFIELDCOPYGEN(pRetData, nPos, pComponentName, - OMX_MAX_STRINGNAME_SIZE); - RPC_GETFIELDCOPYTYPE(pRetData, nPos, pComponentVersion, - OMX_VERSIONTYPE); - RPC_GETFIELDCOPYTYPE(pRetData, nPos, pSpecVersion, - OMX_VERSIONTYPE); - memcpy(pComponentUUID,(OMX_UUIDTYPE *)( (OMX_U32)pRetData + nPos), sizeof(OMX_UUIDTYPE)); - } - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_GetExtensionIndex() - * @brief Remote invocation stub for OMX_GetExtensionIndex - * @param hRPCCtx [IN] : The RPC context handle. - * @param cParameterName [IN] : The parameter name sent by the user. - * @param pIndexType [OUT] : Index type returned by the remote component. - * @param eCompReturn [OUT] : Return value returned by the remote component. - * @return RPC_OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_GetExtensionIndex(OMX_HANDLETYPE hRPCCtx, - OMX_STRING cParameterName, OMX_INDEXTYPE * pIndexType, - OMX_ERRORTYPE * eCompReturn) -{ - - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = - NULL, pRetData = NULL; - OMX_S32 status = 0; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - struct omx_packet *pOmxPacket = NULL; - - nFxnIdx = RPC_OMX_FXN_IDX_GET_EXT_INDEX; - - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, - RPC_OMX_MAP_INFO_TYPE); - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - RPC_SETFIELDCOPYGEN(pData, nPos, cParameterName, - OMX_MAX_STRINGNAME_SIZE); - - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - if (*eCompReturn == OMX_ErrorNone) - { - pRetData = ((struct omx_packet *) pRetPacket)->data; - RPC_GETFIELDCOPYTYPE(pRetData, nPos, pIndexType, - OMX_INDEXTYPE); - } - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - return eRPCError; - -} - -/* ***************************** DATA APIs ******************************** */ - -/* ===========================================================================*/ -/** - * @name RPC_AllocateBuffer() - * @brief Remote invocation stub for OMX_AllcateBuffer() - * @param size : Size of the incoming RCM message (parameter used in the RCM alloc call) - * @param *data : Pointer to the RCM message/buffer received - * @return RPC_OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_AllocateBuffer(OMX_HANDLETYPE hRPCCtx, - OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr, OMX_IN OMX_U32 nPortIndex, - OMX_U32 * pBufHeaderRemote, OMX_PTR pAppPrivate, OMX_U32 nSizeBytes, - OMX_ERRORTYPE * eCompReturn) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = - NULL, pRetData = NULL; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - OMX_S32 status = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - OMX_TI_PLATFORMPRIVATE *pPlatformPrivate = NULL; - OMX_BUFFERHEADERTYPE *pBufferHdr = *ppBufferHdr; - struct omx_packet *pOmxPacket = NULL; - - DOMX_ENTER(""); - - nFxnIdx = RPC_OMX_FXN_IDX_ALLOCATE_BUFFER; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, - RPC_OMX_MAP_INFO_TYPE); - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, nPortIndex, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, pAppPrivate, OMX_PTR); - RPC_SETFIELDVALUE(pData, nPos, nSizeBytes, OMX_U32); - - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - if (*eCompReturn == OMX_ErrorNone) - { - pRetData = ((struct omx_packet *) pRetPacket)->data; - RPC_GETFIELDVALUE(pRetData, nPos, *pBufHeaderRemote, OMX_U32); - //save platform private before overwriting - pPlatformPrivate = (*ppBufferHdr)->pPlatformPrivate; - //RPC_GETFIELDCOPYTYPE(pData, nPos, pBufferHdr, OMX_BUFFERHEADERTYPE); - /*Copying each field of the header separately due to padding issues in - the buffer header structure */ - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nSize, OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nVersion, - OMX_VERSIONTYPE); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->pBuffer, - OMX_U8 *); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nAllocLen, - OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nFilledLen, - OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nOffset, - OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->pAppPrivate, - OMX_PTR); - RPC_GETFIELDVALUE(pRetData, nPos, - pBufferHdr->pPlatformPrivate, OMX_PTR); - RPC_GETFIELDVALUE(pRetData, nPos, - pBufferHdr->pInputPortPrivate, OMX_PTR); - RPC_GETFIELDVALUE(pRetData, nPos, - pBufferHdr->pOutputPortPrivate, OMX_PTR); - RPC_GETFIELDVALUE(pRetData, nPos, - pBufferHdr->hMarkTargetComponent, OMX_HANDLETYPE); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->pMarkData, - OMX_PTR); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nTickCount, - OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nTimeStamp, - OMX_TICKS); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nFlags, - OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, - pBufferHdr->nInputPortIndex, OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, - pBufferHdr->nOutputPortIndex, OMX_U32); - - (*ppBufferHdr)->pPlatformPrivate = pPlatformPrivate; - -#ifdef TILER_BUFF - DOMX_DEBUG(" Copying plat pvt. "); - //if (offset != 0) - { - RPC_GETFIELDCOPYTYPE(pRetData, nPos, - (OMX_TI_PLATFORMPRIVATE - *) ((*ppBufferHdr)->pPlatformPrivate), - OMX_TI_PLATFORMPRIVATE); - DOMX_DEBUG("Done copying plat pvt., aux buf = 0x%x", - ((OMX_TI_PLATFORMPRIVATE - *) ((*ppBufferHdr)->pPlatformPrivate))-> - pAuxBuf1); - } -#endif - - } else - { - //DOMX_DEBUG("OMX Error received: 0x%x", - // pRPCMsg->msgHeader.nOMXReturn); - } - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; -} - -/* ===========================================================================*/ -/** - * @name RPC_UseBuffer() - * @brief Remote invocation stub for OMX_AllcateBuffer() - * @param hComp: This is the handle on the Remote core, the proxy will replace - it's handle with actual OMX Component handle that recides on the specified core - * @param ppBufferHdr: - * @param nPortIndex: - * @param pAppPrivate: - * @param eCompReturn: This is return value that will be supplied by Proxy to the caller. - * This is actual return value returned by the Remote component - * @return RPC_OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_UseBuffer(OMX_HANDLETYPE hRPCCtx, - OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr, OMX_U32 nPortIndex, - OMX_PTR pAppPrivate, OMX_U32 nSizeBytes, OMX_U8 * pBuffer, - OMX_U32 * pBufHeaderRemote, OMX_ERRORTYPE * eCompReturn) -{ - - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = - NULL, pRetData = NULL; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - OMX_S32 status = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - OMX_TI_PLATFORMPRIVATE *pPlatformPrivate = NULL; - OMX_BUFFERHEADERTYPE *pBufferHdr = *ppBufferHdr; - struct omx_packet *pOmxPacket = NULL; - RPC_OMX_MAP_INFO_TYPE eMapInfo = RPC_OMX_MAP_INFO_NONE; - OMX_PTR pMetaDataBuffer = NULL; - OMX_U32 a =32; - - DOMX_ENTER(""); - - nFxnIdx = RPC_OMX_FXN_IDX_USE_BUFFER; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - DOMX_DEBUG("Marshaling data"); - /*Buffer mapping required */ - eMapInfo = RPC_OMX_MAP_INFO_ONE_BUF; - if (((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)-> - pAuxBuf1 != NULL) - eMapInfo = RPC_OMX_MAP_INFO_TWO_BUF; - if (((OMX_TI_PLATFORMPRIVATE *)pBufferHdr->pPlatformPrivate)-> - pMetaDataBuffer != NULL) - eMapInfo = RPC_OMX_MAP_INFO_THREE_BUF; - - /*Offset is the location of the buffer pointer from the start of the data packet */ - nOffset = - sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) + - sizeof(OMX_HANDLETYPE) + sizeof(OMX_U32) + sizeof(OMX_PTR) + - sizeof(OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, eMapInfo, RPC_OMX_MAP_INFO_TYPE); - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, nPortIndex, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, pAppPrivate, OMX_PTR); - RPC_SETFIELDVALUE(pData, nPos, nSizeBytes, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, pBuffer, OMX_U32); - DOMX_DEBUG("eMapInfo = %x",eMapInfo); - if (eMapInfo >= RPC_OMX_MAP_INFO_TWO_BUF) - { - RPC_SETFIELDVALUE(pData, nPos, - ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr-> - pPlatformPrivate)->pAuxBuf1, OMX_U32); - DOMX_DEBUG("UV buffer fd= %d",((OMX_TI_PLATFORMPRIVATE *)pBufferHdr->pPlatformPrivate)->pAuxBuf1); - } - - if (eMapInfo >= RPC_OMX_MAP_INFO_THREE_BUF) - { - RPC_SETFIELDVALUE(pData, nPos, - ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr-> - pPlatformPrivate)->pMetaDataBuffer, OMX_U32); - DOMX_DEBUG("Metadata buffer = %d",((OMX_TI_PLATFORMPRIVATE *)pBufferHdr->pPlatformPrivate)->pMetaDataBuffer); - } - - DOMX_DEBUG("About to send packet"); - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - DOMX_DEBUG("Remote call returned"); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - if (*eCompReturn == OMX_ErrorNone) - { - pRetData = ((struct omx_packet *) pRetPacket)->data; - RPC_GETFIELDVALUE(pRetData, nPos, *pBufHeaderRemote, OMX_U32); - //save platform private before overwriting - pPlatformPrivate = (*ppBufferHdr)->pPlatformPrivate; - - /*Copying each field of the header separately due to padding issues in - the buffer header structure */ - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nSize, OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nVersion, - OMX_VERSIONTYPE); - /* - Do not expect buffer pointer - local buffer pointer is already - present in the local header. - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->pBuffer, - OMX_U8 *); - */ - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nAllocLen, - OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nFilledLen, - OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nOffset, - OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->pAppPrivate, - OMX_PTR); - //Do not expect PlatformPrivate from Ducati - //RPC_GETFIELDVALUE(pRetData, nPos,pBufferHdr->pPlatformPrivate, OMX_PTR); - RPC_GETFIELDVALUE(pRetData, nPos, - pBufferHdr->pInputPortPrivate, OMX_PTR); - RPC_GETFIELDVALUE(pRetData, nPos, - pBufferHdr->pOutputPortPrivate, OMX_PTR); - RPC_GETFIELDVALUE(pRetData, nPos, - pBufferHdr->hMarkTargetComponent, OMX_HANDLETYPE); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->pMarkData, - OMX_PTR); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nTickCount, - OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nTimeStamp, - OMX_TICKS); - RPC_GETFIELDVALUE(pRetData, nPos, pBufferHdr->nFlags, - OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, - pBufferHdr->nInputPortIndex, OMX_U32); - RPC_GETFIELDVALUE(pRetData, nPos, - pBufferHdr->nOutputPortIndex, OMX_U32); - - //Do not expect PlatformPrivate from Ducati - /* - (*ppBufferHdr)->pPlatformPrivate = pPlatformPrivate; - - DOMX_DEBUG(" Copying plat pvt. "); - RPC_GETFIELDCOPYTYPE(pRetData, nPos, - (OMX_TI_PLATFORMPRIVATE *) ((*ppBufferHdr)-> - pPlatformPrivate), OMX_TI_PLATFORMPRIVATE);*/ - - /*Resetting size as it might be diff on Ducati due to padding issues */ - pBufferHdr->nSize = sizeof(OMX_BUFFERHEADERTYPE); - } - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; -} - -/* ===========================================================================*/ -/** - * @name RPC_FreeBuffer() - * @brief Remote invocation stub for OMX_AllcateBuffer() - * @param size : Size of the incoming RCM message (parameter used in the RCM alloc call) - * @param *data : Pointer to the RCM message/buffer received - * @return RPC_OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_FreeBuffer(OMX_HANDLETYPE hRPCCtx, - OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_U32 BufHdrRemote, OMX_U32 pBuffer, - OMX_ERRORTYPE * eCompReturn) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - OMX_S32 status = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - struct omx_packet *pOmxPacket = NULL; - - DOMX_ENTER(""); - - nFxnIdx = RPC_OMX_FXN_IDX_FREE_BUFFER; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - /*Offset is the location of the buffer pointer from the start of the data packet */ - nOffset = sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) + - sizeof(OMX_HANDLETYPE) + sizeof(OMX_U32) + sizeof(OMX_U32); - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_ONE_BUF, - RPC_OMX_MAP_INFO_TYPE); - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, nPortIndex, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, BufHdrRemote, OMX_U32); - /* Buffer is being sent separately only to catch NULL buffer errors - in PA mode */ - RPC_SETFIELDVALUE(pData, nPos, pBuffer, OMX_U32); - - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; -} - - -/* ===========================================================================*/ -/** - * @name RPC_EmptyThisBuffer() - * @brief - * @param size : Size of the incoming RCM message (parameter used in the RCM alloc call) - * @param *data : Pointer to the RCM message/buffer received - * @return RPC_OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ - -RPC_OMX_ERRORTYPE RPC_EmptyThisBuffer(OMX_HANDLETYPE hRPCCtx, - OMX_BUFFERHEADERTYPE * pBufferHdr, OMX_U32 BufHdrRemote, - OMX_ERRORTYPE * eCompReturn, OMX_BOOL bMapBuffer) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - OMX_S32 status = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - OMX_U8 *pAuxBuf1 = NULL; - struct omx_packet *pOmxPacket = NULL; - RPC_OMX_MAP_INFO_TYPE eMapInfo = RPC_OMX_MAP_INFO_NONE; -#ifdef RPC_SYNC_MODE - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL; -#endif - - DOMX_ENTER(""); - - nFxnIdx = RPC_OMX_FXN_IDX_EMPTYTHISBUFFER; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - if(bMapBuffer == OMX_TRUE) - { - pAuxBuf1 = ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->pAuxBuf1; - /*Buffer mapping required */ - if (((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->pAuxBuf1 == NULL) - eMapInfo = RPC_OMX_MAP_INFO_ONE_BUF; - else - eMapInfo = RPC_OMX_MAP_INFO_TWO_BUF; - /*Offset is the location of the buffer pointer from the start of the data packet */ - nOffset = - sizeof(RPC_OMX_MAP_INFO_TYPE) + sizeof(OMX_U32) + - sizeof(OMX_HANDLETYPE) + sizeof(OMX_BUFFERHEADERTYPE *) + 3*sizeof(OMX_U32) + - sizeof(OMX_TICKS) + sizeof(OMX_HANDLETYPE) + sizeof(OMX_PTR) + 3*sizeof(OMX_U32); - } - - RPC_SETFIELDVALUE(pData, nPos, eMapInfo, RPC_OMX_MAP_INFO_TYPE); - - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, - (OMX_BUFFERHEADERTYPE *) BufHdrRemote, OMX_BUFFERHEADERTYPE *); - - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nFilledLen, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nOffset, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nFlags, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nTimeStamp, OMX_TICKS); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->hMarkTargetComponent, - OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->pMarkData, OMX_PTR); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nAllocLen, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nOutputPortIndex, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nInputPortIndex, OMX_U32); - - if(bMapBuffer == OMX_TRUE) - { - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->pBuffer, OMX_U32); - if (eMapInfo == RPC_OMX_MAP_INFO_TWO_BUF) - { - RPC_SETFIELDVALUE(pData, nPos, - ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->pAuxBuf1, OMX_U32); - } - } - - DOMX_DEBUG(" pBufferHdr = %x BufHdrRemote %x", pBufferHdr, - BufHdrRemote); - -#ifdef RPC_SYNC_MODE - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); -#else - RPC_sendPacket_async(hCtx->ClientHndl[RCM_DEFAULT_CLIENT], pPacket, - nFxnIdx); - RPC_checkAsyncErrors(hCtx->ClientHndl[RCM_DEFAULT_CLIENT], pPacket); - - *eCompReturn = OMX_ErrorNone; -#endif - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; -} - - -/* ===========================================================================*/ -/** - * @name RPC_FillThisBuffer() - * @brief Remote invocation stub for OMX_AllcateBuffer() - * @param size : Size of the incoming RCM message (parameter used in the RCM alloc call) - * @param *data : Pointer to the RCM message/buffer received - * @return RPC_OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_FillThisBuffer(OMX_HANDLETYPE hRPCCtx, - OMX_BUFFERHEADERTYPE * pBufferHdr, OMX_U32 BufHdrRemote, - OMX_ERRORTYPE * eCompReturn) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - OMX_S32 status = 0; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - OMX_U8 *pAuxBuf1 = NULL; - struct omx_packet *pOmxPacket = NULL; -#ifdef RPC_SYNC_MODE - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL; -#endif - - DOMX_ENTER(""); - - nFxnIdx = RPC_OMX_FXN_IDX_FILLTHISBUFFER; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - /*No buffer mapping required */ - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, - RPC_OMX_MAP_INFO_TYPE); - RPC_SETFIELDVALUE(pData, nPos, nOffset, OMX_U32); - - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, - (OMX_BUFFERHEADERTYPE *) BufHdrRemote, OMX_BUFFERHEADERTYPE *); - - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nFilledLen, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nOffset, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nFlags, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nAllocLen, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nOutputPortIndex, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, pBufferHdr->nInputPortIndex, OMX_U32); - - DOMX_DEBUG(" pBufferHdr = %x BufHdrRemote %x", pBufferHdr, - BufHdrRemote); - -#ifdef RPC_SYNC_MODE - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - -#else - RPC_sendPacket_async(hCtx->ClientHndl[RCM_DEFAULT_CLIENT], pPacket, - nFxnIdx); - RPC_checkAsyncErrors(hCtx->ClientHndl[RCM_DEFAULT_CLIENT], pPacket); - - *eCompReturn = OMX_ErrorNone; -#endif - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket && *eCompReturn != OMX_ErrorHardware) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; -} - - -/* ***************************** EMPTY APIs ******************************** */ - -/* ===========================================================================*/ -/** - * @name EMPTY-STUB - * @brief - * @param - * @return - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE RPC_EventHandler(OMX_HANDLETYPE hRPCCtx, OMX_PTR pAppData, - OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2, OMX_PTR pEventData) -{ - return RPC_OMX_ErrorNone; -} - -OMX_ERRORTYPE RPC_EmptyBufferDone(OMX_HANDLETYPE hRPCCtx, OMX_PTR pAppData, - OMX_BUFFERHEADERTYPE * pBuffer) -{ - return RPC_OMX_ErrorNone; -} - -OMX_ERRORTYPE RPC_FillBufferDone(OMX_HANDLETYPE hRPCCtx, OMX_PTR pAppData, - OMX_BUFFERHEADERTYPE * pBuffer) -{ - return RPC_OMX_ErrorNone; -} - -RPC_OMX_ERRORTYPE RPC_ComponentTunnelRequest(OMX_HANDLETYPE hRPCCtx, - OMX_IN OMX_U32 nPort, OMX_HANDLETYPE hTunneledRemoteHandle, - OMX_U32 nTunneledPort, OMX_INOUT OMX_TUNNELSETUPTYPE * pTunnelSetup, - OMX_ERRORTYPE * eCompReturn) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - OMX_U32 nPacketSize = RPC_PACKET_SIZE; - RPC_OMX_CONTEXT *hCtx = hRPCCtx; - OMX_HANDLETYPE hComp = hCtx->hRemoteHandle; - RPC_OMX_CONTEXT *hTunneledCtx = hTunneledRemoteHandle; - OMX_HANDLETYPE hTunneledComp = hTunneledCtx->hRemoteHandle; - RPC_OMX_FXN_IDX_TYPE nFxnIdx; - struct omx_packet *pOmxPacket = NULL; - OMX_U32 nPos = 0, nSize = 0, nOffset = 0; - OMX_S32 status = 0; -#ifdef RPC_SYNC_MODE - TIMM_OSAL_PTR pPacket = NULL, pRetPacket = NULL, pData = NULL; -#endif - - printf(" Entering rpc:domx_stub.c:ComponentTunnelRequest\n"); - - nFxnIdx = RPC_OMX_FXN_IDX_COMP_TUNNEL_REQUEST; - RPC_getPacket(nPacketSize, pPacket); - RPC_initPacket(pPacket, pOmxPacket, pData, nFxnIdx, nPacketSize); - - /*Pack the values into a packet*/ - //Marshalled:[>ParentComp|>ParentPort|>TunnelComp|>TunneledPort>TunnelSetup] - RPC_SETFIELDVALUE(pData, nPos, RPC_OMX_MAP_INFO_NONE, RPC_OMX_MAP_INFO_TYPE); - RPC_SETFIELDVALUE(pData, nPos, hComp, OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, nPort, OMX_U32); - RPC_SETFIELDVALUE(pData, nPos, hTunneledComp, OMX_HANDLETYPE); - RPC_SETFIELDVALUE(pData, nPos, nTunneledPort, OMX_U32); - printf("\n after RPC_sendPacket_sync"); - RPC_sendPacket_sync(hCtx, pPacket, nPacketSize, nFxnIdx, pRetPacket, - nSize); - - printf("\n after RPC_sendPacket_sync: *eCompReturn : 0x%x\n", (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result)); - *eCompReturn = (OMX_ERRORTYPE) (((struct omx_packet *) pRetPacket)->result); - - EXIT: - if (pPacket) - RPC_freePacket(pPacket); - if (pRetPacket) - RPC_freePacket(pRetPacket); - - DOMX_EXIT(""); - return eRPCError; - -} diff --git a/domx/domx/omx_rpc/src/omx_rpc_utils.c b/domx/domx/omx_rpc/src/omx_rpc_utils.c deleted file mode 100755 index b1e47a8..0000000 --- a/domx/domx/omx_rpc/src/omx_rpc_utils.c +++ /dev/null @@ -1,446 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_rpc_utils.c - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework RPC. - * - * @path \WTSD_DucatiMMSW\framework\domx\omx_rpc\src - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 29-Mar-2010 Abhishek Ranka : Revamped DOMX implementation - *! - *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version - *================================================================*/ -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -#include -#include - -#include "omx_rpc.h" -#include "omx_rpc_internal.h" -#include "omx_rpc_utils.h" -#include -#include - -extern char rcmservertable[MAX_PROC][MAX_SERVER_NAME_LENGTH]; -extern char Core_Array[MAX_PROC][MAX_CORENAME_LENGTH]; - -/* ===========================================================================*/ -/** - * @name EMPTY-STUB - * @brief - * @param - * @return - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_UTIL_GetTargetServerName(OMX_STRING ComponentName, - OMX_STRING ServerName) -{ - OMX_U8 count = 0; - OMX_U8 i = 0; - OMX_U8 servertable_idx = 0; - OMX_STRING str; - char Core[MAX_CORENAME_LENGTH]; - - DOMX_ENTER(""); - DOMX_DEBUG(" Calling Component Name %s", ComponentName); - - while (*ComponentName != '\0') - { - if (*ComponentName == '.') - { - count++; - if (count == 2) - { - ComponentName++; - str = ComponentName; - - while (*str != '.') - { - Core[i] = *str; - i++; - str++; - } - Core[i] = '\0'; - break; - } - - } - - ComponentName++; - } - - DOMX_DEBUG(" CORE NAME RECOVERED: %s", Core); - DOMX_DEBUG - ("____________________________________________________________"); - DOMX_DEBUG("Recovering Server Table Index"); - for (i = 0; i < CORE_MAX; i++) - { - - if (strcmp(Core, Core_Array[i]) == 0) - { - servertable_idx = i; - DOMX_DEBUG("Recovered Server table index = %d", i); - break; - } - } - strncpy(ServerName, (OMX_STRING) rcmservertable[servertable_idx], - MAX_SERVER_NAME_LENGTH); - DOMX_DEBUG(" ServerName recovered = %s", ServerName); - - return RPC_OMX_ErrorNone; -} - -/* ===========================================================================*/ -/** - * @name EMPTY-STUB - * @brief - * @param - * @return - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_UTIL_GetLocalServerName(OMX_STRING ComponentName, - OMX_STRING * ServerName) -{ -/* Implementation returns only current core ID - But this is a place holder to abstract out the -default server and other additional servers available on the current core. This additional servers -should be available in the RPC global that is indexed using the calling component name*/ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_U8 servertable_idx = 0; - - servertable_idx = MultiProc_getId(NULL); //This can be replace with the mechanism to obtain new addition rcm servers - if (MultiProc_INVALIDID != servertable_idx) - *ServerName = rcmservertable[servertable_idx]; - else - eRPCError = RPC_OMX_ErrorUndefined; - - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_UTIL_GenerateLocalServerName() - * @brief This function generates a server name to be used while creating the - * RCM server. The name is based on the pid so that eacj process gets a - * unique server name. - * @param cServerName - This is filled in and returned with a valid value. - * @return RPC_OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_UTIL_GenerateLocalServerName(OMX_STRING cServerName) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_S32 pid = 0; - OMX_U32 nProcId = 0; - - pid = getpid(); - /*Using pid as the server name, thus limiting to only 1 server per process. - This limitaion is partly enforce by syslink as well since max size of server - name is 32 so only pid can fit into the name */ - sprintf(cServerName, "%ld", pid); - - nProcId = MultiProc_getId(NULL); - if (MultiProc_INVALIDID != nProcId) - /*Fill the server table with the newly generated name */ - strncpy(rcmservertable[nProcId], cServerName, - MAX_SERVER_NAME_LENGTH); - else - eRPCError = RPC_OMX_ErrorUndefined; - - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_UTIL_GetTargetCore() - * @brief This function gets the target core id by parsing the component name. - * It is assumed that component names follow the convention - * .... with - * all characters in upper case for e.g. OMX.TI.DUCATI1.VIDEO.H264E - * @param cComponentName - Name of the component. - * @param nCoreId - Core ID, this is filled in and returned. - * @return RPC_OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_UTIL_GetTargetCore(OMX_STRING cComponentName, - OMX_U32 * nCoreId) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_S8 cCoreName[MAX_SERVER_NAME_LENGTH] = { 0 }; - OMX_S32 ret = 0; - OMX_U32 i = 0; - - ret = - sscanf(cComponentName, "%*[^'.'].%*[^'.'].%[^'.'].%*s", - cCoreName); - RPC_assert(ret == 1, RPC_OMX_ErrorBadParameter, - "Incorrect component name"); - - for (i = 0; i < CORE_MAX; i++) - { - if (strcmp((char *)cCoreName, Core_Array[i]) == 0) - break; - } - RPC_assert(i < CORE_MAX, RPC_OMX_ErrorBadParameter, - "Unknown core name"); - *nCoreId = i; - - EXIT: - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name EMPTY-STUB - * @brief the Api creates the RCM client on the target core(where the component sits). -This happens in the context of the Default RCM server on the target core. -The RCM server name to connect for this client will be the default RCM server on the calling core. -This can be provided as an option as the name that you pass in the string server is used as the RCM server name -input to the client create call. -@Default_RcmServer - The default rcm server on the target core -@Server - The name of the server on the calling core to connect to - * @param - * @return - * - */ -/* ===========================================================================*/ -/* -RPC_OMX_ERRORTYPE RPC_GetTargetClient(OMX_STRING Default_RcmServer, OMX_STRING server, rcmhHndl) -{ - - -} -*/ - -/* ===========================================================================*/ -/** - * @name EMPTY-STUB - * @brief - * @param - * @return - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_MapBuffer(OMX_U32 mappedBuffer) -{ - DOMX_ENTER(""); - DOMX_DEBUG("Empty implementation "); - //PlaceHolder for Mapping Buffers - Cuurently no implementation here - return RPC_OMX_ErrorNone; -} - -/* ===========================================================================*/ -/** - * @name EMPTY-STUB - * @brief - * @param - * @return - * - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_UnMapBuffer(OMX_U32 mappedBuffer) -{ - DOMX_ENTER(""); - DOMX_DEBUG("Empty implementation "); - //PlaceHolder for UnMapping Buffers - Cuurently no implementation here - return RPC_OMX_ErrorNone; -} - -/* ===========================================================================*/ -/** - * @name RPC_FlushBuffer - * @brief Used to flush buffers from cache to memory. Used when buffers are - * being transferred across processor boundaries. - * @param pBuffer : Pointer to the data that has to be flushed. - * size : Size of the data to be flushed. - * nTargetCoreId : Core to which buffer is being transferred. - * @return RPC_OMX_ErrorNone : Success. - * RPC_OMX_ErrorUndefined : Flush operation failed. - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_FlushBuffer(OMX_U8 * pBuffer, OMX_U32 size, - OMX_U32 nTargetCoreId) -{ - DOMX_ENTER(""); - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_S32 nStatus = 0; - - DOMX_DEBUG("About to flush %d bytes", size); - nStatus = ProcMgr_flushMemory((OMX_PTR) pBuffer, size, - (ProcMgr_ProcId) nTargetCoreId); - RPC_assert(nStatus >= 0, RPC_OMX_ErrorUndefined, - "Cache flush failed"); - - EXIT: - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_InvalidateBuffer - * @brief Used to flush buffers from cache to memory. Used when buffers are - * being transferred across processor boundaries. - * @param pBuffer : Pointer to the data that has to be flushed. - * size : Size of the data to be flushed. - * nTargetCoreId : Core to which buffer is being transferred. - * @return RPC_OMX_ErrorNone : Success. - * RPC_OMX_ErrorUndefined : Invalidate operation failed. - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_InvalidateBuffer(OMX_U8 * pBuffer, OMX_U32 size, - OMX_U32 nTargetCoreId) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_S32 nStatus = 0; - DOMX_ENTER(""); - - DOMX_DEBUG("About to invalidate %d bytes", size); - nStatus = ProcMgr_invalidateMemory((OMX_PTR) pBuffer, size, - (ProcMgr_ProcId) nTargetCoreId); - RPC_assert(nStatus >= 0, RPC_OMX_ErrorUndefined, - "Cache invalidate failed"); - - EXIT: - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_Util_AcquireJobId - * @brief Used to get a new job id from syslink - all messages sent with the - * same job id will be processed serially. Messages with different job id - * will be processed parallely. - * @param hRPCCtx : RPC context handle. - * pJobId : Pointer to job id - this'll be filled in and returned. - * @return RPC_OMX_ErrorNone : Success. - * Any other : Operation failed. - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_Util_AcquireJobId(RPC_OMX_CONTEXT * hRPCCtx, - OMX_U16 * pJobId) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_S32 nStatus = 0; - DOMX_ENTER(""); - - nStatus = - RcmClient_acquireJobId(hRPCCtx->ClientHndl[RCM_DEFAULT_CLIENT], - pJobId); - RPC_assert(nStatus >= 0, RPC_OMX_ErrorUndefined, - "Acquire job id failed"); - - EXIT: - DOMX_EXIT("eRPCError = %d", eRPCError); - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_Util_ReleaseJobId - * @brief Used to release job id to syslink. Once release, this job id cannot be - * reused. - * @param hRPCCtx : RPC context handle. - * nJobId : Job ID to be released. - * @return RPC_OMX_ErrorNone : Success. - * Any other : Operation failed. - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_Util_ReleaseJobId(RPC_OMX_CONTEXT * hRPCCtx, - OMX_U16 nJobId) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_S32 nStatus = 0; - DOMX_ENTER(""); - - nStatus = - RcmClient_releaseJobId(hRPCCtx->ClientHndl[RCM_DEFAULT_CLIENT], - nJobId); - RPC_assert(nStatus >= 0, RPC_OMX_ErrorUndefined, - "Release job id failed"); - - EXIT: - DOMX_EXIT("eRPCError = %d", eRPCError); - return eRPCError; -} - - - -/* ===========================================================================*/ -/** - * @name RPC_Util_GetPoolId - * @brief Used to get pool id. Messages sent with same pool id will get - * processed at the same priority on remote core. - * @param hRPCCtx : RPC context handle. - * pPoolId : Pointer to pool id - this'll be filled in and - * returned. - * @return RPC_OMX_ErrorNone : Success. - * Any other : Operation failed. - */ -/* ===========================================================================*/ -RPC_OMX_ERRORTYPE RPC_Util_GetPoolId(RPC_OMX_CONTEXT * hRPCCtx, - OMX_U16 * pPoolId) -{ - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - DOMX_ENTER(""); - - *pPoolId = 0x8001; - -//EXIT: - DOMX_EXIT("eRPCError = %d", eRPCError); - return eRPCError; -} diff --git a/domx/domx/profiling/inc/profile.h b/domx/domx/profiling/inc/profile.h deleted file mode 100644 index 352a91c..0000000 --- a/domx/domx/profiling/inc/profile.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file profile.h -* The header file defines the trace events definitions. -* @path platform\hardware\ti\domx\domx\profiling\inc\ -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 1.0: Created the first draft version - * ========================================================================= */ - -#ifndef _PROFILE_H_ -#define _PROFILE_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* #ifdef __cplusplus */ - -#include -#include - -#include "omx_rpc_utils.h" -#include "omx_proxy_common.h" - -enum KPI_BUFFER_EVENT { - KPI_BUFFER_ETB = 1, - KPI_BUFFER_FTB = 2, - KPI_BUFFER_EBD = 3, - KPI_BUFFER_FBD = 4 -}; - -/** - * OMX monitoring component init. Registers component - */ -void KPI_OmxCompInit(OMX_HANDLETYPE hComponent); - -/** - * OMX monitoring component deinit. Unregisters component - */ -void KPI_OmxCompDeinit(OMX_HANDLETYPE hComponent); - -/** - * OMA monitoring buffer event trace. Traces FTB/ETB/FBD/EBD event - */ -void KPI_OmxCompBufferEvent(enum KPI_BUFFER_EVENT event, OMX_HANDLETYPE hComponent, PROXY_BUFFER_INFO* pBuffer); - -#ifdef __cplusplus -} -#endif /* #ifdef __cplusplus */ - -#endif /* #ifndef _PROFILE_H_ */ diff --git a/domx/domx/profiling/src/profile.c b/domx/domx/profiling/src/profile.c deleted file mode 100644 index bc050b7..0000000 --- a/domx/domx/profiling/src/profile.c +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file profile.c - * This file contains methods to profile DOMX - * - * @path ...\hardware\ti\domx\domx\profiling\inc - * - * @rev 1.0 - */ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -/* ----- system and platform files ----------------------------*/ -#include -#include -#include - -#ifdef _Android -#include -#endif - -#include -#include - -/*-------program files ----------------------------------------*/ -#include "omx_rpc_utils.h" -#include "omx_proxy_common.h" -#include "profile.h" - - -/****************************************************************** - * DEFINES - CONSTANTS - ******************************************************************/ -/* Events that can be dynamically enabled */ -enum KPI_STATUS { - KPI_BUFFER_EVENTS = 1 -}; - -/* OMX buffer events per component */ -typedef struct { - OMX_HANDLETYPE hComponent; - OMX_U32 count_ftb; - OMX_U32 count_fbd; - OMX_U32 count_etb; - OMX_U32 count_ebd; - char name[50]; -} kpi_omx_component; - -/* we trace up to MAX_OMX_COMP components */ -#define MAX_OMX_COMP 8 - - -/*************************************************************** - * kpi_omx_monitor - * ------------------------------------------------------------- - * Contains up to 8 components data - * - ***************************************************************/ -kpi_omx_component kpi_omx_monitor[MAX_OMX_COMP]; /* we trace up to MAX_OMX_COMP components */ -OMX_U32 kpi_omx_monitor_cnt = 0; /* no component yet */ -unsigned int kpi_status = 0; - - -/* ===========================================================================*/ -/** - * @name KPI_GetTime() - * @brief Compute time since boot to timestamp events - * @param void - * @return OMX_U64 = time since boot in us - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_U64 KPI_GetTime(void) -{ - struct timespec tp; - - clock_gettime(CLOCK_MONOTONIC, &tp); - return (tp.tv_sec * 1000000 + tp.tv_nsec / 1000); -} - -/* ===========================================================================*/ -/** - * @name KPI_OmxCompKpiUpdateStatus() - * @brief Update dynamic activation of traces - * @param void - * @return void - * @sa TBD - * - */ -/* ===========================================================================*/ -void KPI_OmxCompKpiUpdateStatus(void) -{ - char *val = getenv("DEBUG_DOMX_KPI_STATUS"); - - if (val) - { - kpi_status = strtol(val, NULL, 0); - } -#ifdef _Android - else - { - char value[PROPERTY_VALUE_MAX]; - int val; - - property_get("debug.domx.kpi_status", value, "0"); - val = atoi(value); - if (val >= 0) - kpi_status = val; - } -#endif -} - -/* ===========================================================================*/ -/** - * @name KPI_OmxCompInit() - * @brief Prepare monitoring structure for new component starting - * @param void - * @return void - * @sa TBD - * - */ -/* ===========================================================================*/ -void KPI_OmxCompInit(OMX_HANDLETYPE hComponent) -{ - OMX_VERSIONTYPE nVersionComp; - OMX_VERSIONTYPE nVersionSpec; - OMX_UUIDTYPE compUUID; - char compName[OMX_MAX_STRINGNAME_SIZE]; - char* p; - OMX_U32 omx_cnt; - struct timespec tp; - - /* Check if some profiling events have been enabled/disabled */ - KPI_OmxCompKpiUpdateStatus(); - - if ( !(kpi_status & KPI_BUFFER_EVENTS) ) - return; - - /* First init: clear kpi_omx_monitor components */ - if( kpi_omx_monitor_cnt == 0) { - for (omx_cnt = 0; omx_cnt < MAX_OMX_COMP; omx_cnt++) { - /*clear handler registry */ - kpi_omx_monitor[omx_cnt].hComponent = 0; - } - } - - /* find an empty monitoring structure */ - for( omx_cnt = 0; omx_cnt < MAX_OMX_COMP; omx_cnt++ ) { - if( kpi_omx_monitor[omx_cnt].hComponent == 0 ) break; - } - - /* too omany components started, do not monitor */ - if( omx_cnt >= MAX_OMX_COMP) return; - - /* current comp num and update */ - kpi_omx_monitor_cnt++; - - /* register the component handle */ - kpi_omx_monitor[omx_cnt].hComponent = hComponent; - - /* reset event counts */ - kpi_omx_monitor[omx_cnt].count_ftb = 0; - kpi_omx_monitor[omx_cnt].count_fbd = 0; - kpi_omx_monitor[omx_cnt].count_etb = 0; - kpi_omx_monitor[omx_cnt].count_ebd = 0; - - /* register the component name */ - ((OMX_COMPONENTTYPE*) hComponent)->GetComponentVersion(hComponent, compName, &nVersionComp, &nVersionSpec, &compUUID); - - /* get the end of the string compName... */ - p = compName + strlen( compName ) - 1; - while( (*p != '.' ) && (p != compName) ) p--; - strncpy(kpi_omx_monitor[omx_cnt].name, p + 1, 6); - - /* trace component init */ - DOMX_PROF(" OMX %-6s Init %-8lld", kpi_omx_monitor[omx_cnt].name, KPI_GetTime()); - - return; -} - -/* ===========================================================================*/ -/** - * @name KPI_OmxCompDeinit() - * @brief Reset monitoring structure for component stopping - * @param void - * @return void - * @sa TBD - * - */ -/* ===========================================================================*/ -void KPI_OmxCompDeinit( OMX_HANDLETYPE hComponent) -{ - OMX_U32 omx_cnt; - - if ( !(kpi_status & KPI_BUFFER_EVENTS) ) - return; - - if( kpi_omx_monitor_cnt == 0) return; - - /* identify the component from the registry */ - for( omx_cnt = 0; omx_cnt < MAX_OMX_COMP; omx_cnt++ ) { - if( kpi_omx_monitor[omx_cnt].hComponent == hComponent ) break; - } - - /* trace component init */ - DOMX_PROF( " OMX %-6s Deinit %-8lld", kpi_omx_monitor[omx_cnt].name, KPI_GetTime()); - - /* unregister the component */ - kpi_omx_monitor[omx_cnt].hComponent = 0; - - kpi_omx_monitor_cnt--; - - return; -} - -/* ===========================================================================*/ -/** - * @name KPI_OmxCompBufferEvent() - * @brief Trace FTB/ETB/FBD/EBD events - * @param void - * @return void - * @sa TBD - * - */ -/* ===========================================================================*/ -void KPI_OmxCompBufferEvent(enum KPI_BUFFER_EVENT event, OMX_HANDLETYPE hComponent, PROXY_BUFFER_INFO* pBuffer) -{ - OMX_U32 omx_cnt; - - if ( !(kpi_status & KPI_BUFFER_EVENTS) ) - return; - - if (kpi_omx_monitor_cnt == 0) return; - - /* identify the component from the registry */ - for (omx_cnt = 0; omx_cnt < MAX_OMX_COMP; omx_cnt++) { - if( kpi_omx_monitor[omx_cnt].hComponent == hComponent ) break; - } - - /* Update counts and trace the event */ - if( omx_cnt < MAX_OMX_COMP ) { - /* trace the event, we trace remote address to correlate to Ducati trace */ - switch(event) { - case KPI_BUFFER_ETB: - DOMX_PROF("ETB %-6s %-4u %-8lld x%-8x", kpi_omx_monitor[omx_cnt].name, \ - (unsigned int)++kpi_omx_monitor[omx_cnt].count_etb, KPI_GetTime(), (unsigned int)pBuffer->pBufHeaderRemote); - break; - case KPI_BUFFER_FTB: - DOMX_PROF("FTB %-6s %-4u %-8lld x%-8x", kpi_omx_monitor[omx_cnt].name, \ - (unsigned int)++kpi_omx_monitor[omx_cnt].count_ftb, KPI_GetTime(), (unsigned int)pBuffer->pBufHeaderRemote); - break; - case KPI_BUFFER_EBD: - DOMX_PROF("EBD %-6s %-4u %-8lld x%-8x", kpi_omx_monitor[omx_cnt].name, \ - (unsigned int)++kpi_omx_monitor[omx_cnt].count_ebd, KPI_GetTime(), (unsigned int)pBuffer->pBufHeaderRemote); - break; - /* we add timestamp metadata because this is a unique identifier of buffer among all SW layers */ - case KPI_BUFFER_FBD: - DOMX_PROF("FBD %-6s %-4u %-8lld x%-8x %lld", kpi_omx_monitor[omx_cnt].name, \ - (unsigned int)++kpi_omx_monitor[omx_cnt].count_fbd, KPI_GetTime(), (unsigned int)pBuffer->pBufHeaderRemote, pBuffer->pBufHeader->nTimeStamp); - break; - - } - } - - return; -} diff --git a/domx/domx/rpmsg_omx_defs.h b/domx/domx/rpmsg_omx_defs.h deleted file mode 100644 index d3df1f5..0000000 --- a/domx/domx/rpmsg_omx_defs.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * OMX offloading remote processor driver - */ - -#ifndef RPMSG_OMX_DEFS_H -#define RPMSG_OMX_DEFS_H - -#include - -//AD - from SDO -/* - * ======== OMX_Packet ======== - * - * OMX_Packet.desc: the package descriptor field. Note that the - * format is different for out-bound and in-bound messages. - * - * out-bound message descriptor - * - * Bits Description - * -------------------------------------------------------------------- - * [15:12] reserved - * [11:8] omx message type - * [7:0] omx client protocol version - * - * - * in-bound message descriptor - * - * Bits Description - * -------------------------------------------------------------------- - * [15:12] reserved - * [11:8] omx server status code - * [7:0] omx server protocol version - */ -/* message type values */ -#define OMX_DESC_MSG 0x1 // exec sync command -#define OMX_DESC_SYM_ADD 0x3 // symbol add message -#define OMX_DESC_SYM_IDX 0x4 // query symbox index -#define OMX_DESC_CMD 0x5 // exec non-blocking command. -#define OMX_DESC_TYPE_MASK 0x0F00 // field mask -#define OMX_DESC_TYPE_SHIFT 8 // field shift width - -/* omx server status codes must be 0 - 15, it has to fit in a 4-bit field */ -#define OMXSERVER_STATUS_SUCCESS ((uint16_t)0) // success -#define OMXSERVER_STATUS_INVALID_FXN ((uint16_t)1) // invalid fxn index -#define OMXSERVER_STATUS_SYMBOL_NOT_FOUND ((uint16_t)2) // symbol not found -#define OMXSERVER_STATUS_INVALID_MSG_TYPE ((uint16_t)3) // invalid msg type -#define OMXSERVER_STATUS_MSG_FXN_ERR ((uint16_t)4) // msg function error -#define OMXSERVER_STATUS_ERROR ((uint16_t)5) // general failure -#define OMXSERVER_STATUS_UNPROCESSED ((uint16_t)6) // unprocessed message - -#define OMX_POOLID_JOBID_DEFAULT (0x00008000) -#define OMX_INVALIDFXNIDX ((uint32_t)(0xFFFFFFFF)) - -#endif /* RPMSG_OMX_DEFS_H */ diff --git a/domx/make/build.mk b/domx/make/build.mk deleted file mode 100644 index 2faeffa..0000000 --- a/domx/make/build.mk +++ /dev/null @@ -1,379 +0,0 @@ -# -# Copyright 2001-2009 Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# dspbridge/mpu_api/make/build.mk -# -# DSP-BIOS Bridge build rules. - -# ALL PATHS IN MAKEFILE MUST BE RELATIVE TO ITS DIRECTORY - -CDEFS += $(CMDDEFS) # Add command line definitions -CDEFS += $(PROCFAMILY) # Processor Family e.g. 3430 -CDEFS += $(CMDDEFS_START) # Definitions from start.mk -# ---------------------------------------------------------- -# REMOVE LEADING AND TRAILING SPACES FROM MAKEFILE MACROS -# ---------------------------------------------------------- - -TARGETNAME := $(strip $(TARGETNAME)) -TARGETTYPE := $(strip $(TARGETTYPE)) -SUBMODULES := $(strip $(SUBMODULES)) -SOURCES := $(strip $(SOURCES)) -INCLUDES := $(strip $(INCLUDES)) -LIBINCLUDES := $(strip $(LIBINCLUDES)) - -SH_SONAME := $(strip $(SH_SONAME)) -ST_LIBS := $(strip $(ST_LIBS)) -SH_LIBS := $(strip $(SH_LIBS)) - -CFLAGS := $(strip $(CFLAGS)) -CDEFS := $(strip $(CDEFS)) -EXEC_ARGS := $(strip $(EXEC_ARGS)) -ST_LIB_ARGS := $(strip $(ST_LIB_ARGS)) -SH_LIB_ARGS := $(strip $(SH_LIB_ARGS)) - -# ---------------------------------------------------------- -# COMPILER OPTIONS -# ---------------------------------------------------------- - -# Preprocessor : dependency file generation -ifndef NODEPENDS -ifndef nodepends -CFLAGS += -MD -endif -endif - -# Overall -CFLAGS += -pipe -# Preprocessor -CFLAGS += -# Debugging -ifeq ($(BUILD),deb) -CFLAGS += -g -else -CFLAGS += -fomit-frame-pointer -endif -# Warnings -CFLAGS += -Wall -Wno-trigraphs -Werror-implicit-function-declaration #-Wno-format -# Optimizations -#CFLAGS += -O2 -fno-strict-aliasing -#CFLAGS += -Os -fno-strict-aliasing -CFLAGS += -fno-strict-aliasing -# Machine dependent - -ifeq ($(PROCFAMILY),OMAP_3430) -CFLAGS += -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork -march=armv7-a -msoft-float -Uarm -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR($(basename $(TARGETNAME)))" -D"KBUILD_MODNAME=KBUILD_STR($(basename $(TARGETNAME)))" -DMODULE -D__LINUX_ARM_ARCH__=7 -endif - -ifeq ($(PROCFAMILY),OMAP_4430) -CFLAGS += -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork -march=armv7-a -msoft-float -Uarm -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR($(basename $(TARGETNAME)))" -D"KBUILD_MODNAME=KBUILD_STR($(basename $(TARGETNAME)))" -DMODULE -D__LINUX_ARM_ARCH__=7 -endif - -# Code generation -CFLAGS += -fno-common -# Macros -CFLAGS += -DLINUX $(addprefix -D, $(CDEFS)) - -ifdef __KERNEL__ -CFLAGS += -D__KERNEL__ -fno-builtin -endif - -# ---------------------------------------------------------- -# OBJECTS -# ---------------------------------------------------------- - -BUILDDIR = .obj/ - -# setup the target - check the given type - make sure we have the -# correct suffix on it -# TARGETNAME should not have a suffix on it - give an error if it does -#ifneq ($(suffix $(TARGETNAME)),) -# $(error TARGETNAME can not have a suffix) -#endif -ifeq ($(TARGETTYPE),SH_LIB) - TARGET := $(basename $(TARGETNAME)).so -else -ifeq ($(TARGETTYPE),MODULE) - TARGET := $(basename $(TARGETNAME)).o - TARGETKO := $(addsuffix .ko,$(basename $(TARGET))) - TARGETMOD := $(addsuffix .mod,$(basename $(TARGET))) -else -ifeq ($(TARGETTYPE),ST_LIB) - TARGET := $(basename $(TARGETNAME)).a -else -ifeq ($(TARGETTYPE),EXEC) - TARGET := $(basename $(TARGETNAME)).out -else -ifneq ($(TARGETTYPE),) -TARGET := $(error Invalid TARGETTYPE) -endif -endif -endif -endif -endif - -#LIBINCLUDES += $(TARGETDIR) $(TGTROOT)/lib $(TGTROOT)/usr/lib -LIBINCLUDES += $(TARGETDIR)/lib $(TARGETDIR)/usr/lib -SRCDIRS := $(sort $(dir $(SOURCES))) -OBJDIRS := $(addprefix $(BUILDDIR),$(SRCDIRS)) $(BUILDDIR) - -BASEOBJ := $(addsuffix .o,$(basename $(SOURCES))) -OBJECTS := $(addprefix $(BUILDDIR), $(BASEOBJ)) - -ST_LIBNAMES := $(addsuffix .a, $(addprefix lib, $(ST_LIBS))) -DL_LIBNAMES := $(addsuffix .so, $(addprefix lib, $(SH_LIBS))) - -vpath %.a $(LIBINCLUDES) $(TGTROOT)/lib $(TGTROOT)/usr/lib -vpath %.so $(LIBINCLUDES) $(TGTROOT)/lib $(TGTROOT)/usr/lib - -# ---------------------------------------------------------- -# BUILD ARGUMENTS -# ---------------------------------------------------------- - -MAPFILE := -Wl,-Map,$(TARGET).map -INCPATH := $(addprefix -I, . $(INCLUDES)) $(LINUXINCLUDE) -LIBPATH := $(addprefix -L, $(LIBINCLUDES)) -LIBFILE := $(addprefix -l, $(ST_LIBS) $(SH_LIBS)) $(LIB_OBJS) - -ifeq ($(TARGETTYPE),SH_LIB) -CFLAGS += -fpic -TARGETARGS := $(SH_LIB_ARGS) -nostartfiles -nodefaultlibs -nostdlib -shared -Wl -ifneq ($(SH_SONAME),) -TARGETARGS += -Wl,-soname,$(SH_SONAME) -endif -endif - -ifeq ($(TARGETTYPE),MODULE) -TARGETARGS := $(SH_LIB_ARGS) -nostartfiles -nodefaultlibs -nostdlib -Wl,-r -ifneq ($(SH_SONAME),) -TARGETARGS += -Wl,-soname,$(SH_SONAME) -endif -endif - -ifeq ($(TARGETTYPE),ST_LIB) -TARGETARGS := $(ST_LIB_ARGS) -nostartfiles -nodefaultlibs -nostdlib -Wl,-r -endif - -ifeq ($(TARGETTYPE),EXEC) -TARGETARGS := $(EXEC_ARGS) -endif - -.PHONY : all $(SUBMODULES) clean cleantrg SHELLERR Debug - -# ========================================================== -# all -# ========================================================== -all : $(CHECKSHELL) $(SUBMODULES) - -# ========================================================== -# Make submodules -# ========================================================== -$(SUBMODULES): -ifndef NORECURSE -ifndef norecurse - $(MAKE) -C $@ $(filter-out $(SUBMODULES),$(MAKECMDGOALS)) -endif -endif - -ifneq ($(TARGETTYPE),) - -# if this is driver module level , build KO file too -ifneq ($(TOPLEVEL),) -all : $(OBJDIRS) $(TARGETKO) -else -all : $(OBJDIRS) $(TARGET) -endif - -# ========================================================== -# Create directories -# ========================================================== -$(OBJDIRS) $(TARGETDIR) : - @$(call MKDIR, $@) - -# ========================================================== -# Product 2.6.x kernel module based on target -# ========================================================== - -# Link module .o with vermagic .o -$(TARGETKO): $(TARGETMOD).o $(TARGET) - $(LD) -EL -r -o $@ $^ - -# Compile vermagic -$(TARGETMOD).o: $(TARGETMOD).c - $(CC) -c $(TARGETARGS) $(CFLAGS) $(INCPATH) -o $@ $< - -# Generate Module vermagic -$(TARGETMOD).c: $(TARGET) - $(MODPOST) $(TARGET) -# removed - need to be done as a pre-step to building -# $(MAKE) -C $(KRNLSRC) modules - -# ========================================================== -# Build target -# ========================================================== -$(TARGET):$(OBJECTS) $(ST_LIBNAMES) $(DL_LIBNAMES) -# @$(SHELLCMD) echo Building $@ -# $(CC) $(TARGETARGS) $(CFLAGS) $(LIBPATH) $(MAPFILE) -o $@ $(BASEOBJ) $(LIBFILE) -# $(CC) $(TARGETARGS) $(CFLAGS) $(LIBPATH) $(MAPFILE) -o $@ $(OBJECTS) $(LIBFILE) -ifeq ($(TARGETTYPE),ST_LIB) - $(AR) r $@ $(OBJECTS) -else - $(CC) $(TARGETARGS) $(CFLAGS) $(LIBPATH) $(MAPFILE) -o $@ $(OBJECTS) $(LIBFILE) -endif - -# ========================================================== -# Compile .c file -# ========================================================== -$(BUILDDIR)%.o:%.c -# echo Compiling $(patsubst $(BUILDDIR)%.o,%.c, $@) - $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $(patsubst $(BUILDDIR)%.o,%.c, $@) - -# ========================================================== -# Compile .S file -# ========================================================== -$(BUILDDIR)%.o:%.S -# echo Compiling $(patsubst $(BUILDDIR)%.o,%.S, $@) - $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $(patsubst $(BUILDDIR)%.o,%.S, $@) - -endif # ifneq ($(TARGETTYPE),) - -# ---------------------------------------------------------- -# install - install the files -# ---------------------------------------------------------- -install:: $(TARGETDIR) $(SUBMODULES) $(TARGET) -ifdef HOSTRELEASE -ifdef SH_SONAME - $(INSTALL) -D $(TARGET) $(TARGETDIR)/$(HOSTRELEASE)/$(SH_SONAME) - $(RM) -f $(TARGETDIR)/$(HOSTRELEASE)/$(TARGET) - ln -s $(SH_SONAME) $(TARGETDIR)/$(HOSTRELEASE)/$(TARGET) -else -ifneq ($(TOPLEVEL),) - $(INSTALL) -D $(TARGETKO) $(TARGETDIR)/$(HOSTRELEASE)/$(TARGETKO) -else - $(INSTALL) -D $(TARGET) $(TARGETDIR)/$(HOSTRELEASE)/$(TARGET) -endif -endif -endif -ifdef 0 # removed - components shouldn't put things in the production fs -ifdef ROOTFSRELEASE - $(call MKDIR, $(ROOTFSDIR)/$(ROOTFSRELEASE)) -ifdef SH_SONAME - $(STRIP) --strip-unneeded -xgo $(ROOTFSDIR)/$(ROOTFSRELEASE)/$(SH_SONAME) $(TARGET) - $(RM) -f $(ROOTFSDIR)/$(ROOTFSRELEASE)/$(TARGET) - ln -s $(SH_SONAME) $(ROOTFSDIR)/$(ROOTFSRELEASE)/$(TARGET) -else -ifneq ($(TOPLEVEL),) - $(STRIP) --strip-unneeded -xgo $(ROOTFSDIR)/$(ROOTFSRELEASE)/$(TARGETKO) $(TARGETKO) -else - $(STRIP) --strip-unneeded -xgo $(ROOTFSDIR)/$(ROOTFSRELEASE)/$(TARGET) $(TARGET) -endif -endif -endif -endif - -# ---------------------------------------------------------- -# clean - Remove build directory and target files -# Linux : Removes object and dependency files in build folder -# DOS : Removes object dirs in build folder -# ---------------------------------------------------------- -clean : $(SUBMODULES) -ifneq ($(TARGETTYPE),) -ifneq ($(OBJECTS),) - - $(call RM,-f $(OBJECTS)) - - $(call RM,-f $(OBJECTS:.o=.d)) - - $(call RMDIR,-f $(BUILDDIR)) -endif - - $(call RM,-f $(TARGET)) - - $(call RM,-f $(TARGET).map) - - $(call RM,-f $(TARGETKO)) - - $(call RM,-f $(TARGETMOD).c) - - $(call RM,-f $(TARGETMOD).o) - - $(call RM,-f $(TARGETMOD).d) -ifneq ($(TOPLEVEL),) - - @$(call RM,-f $(TARGETKO)) - - @$(call RM,-f $(TARGETMOD).c) - - @$(call RM,-f $(TARGETMOD).o) - - @$(call RM,-f $(TARGETMOD).d) -endif -endif - -cleantrg : $(SUBMODULES) -ifneq ($(TARGETTYPE),) - - @$(call RM, $(TARGET)) - - @$(call RM, $(TARGET).map) -ifneq ($(TOPLEVEL),) - - @$(call RM, $(TARGETKO)) - - @$(call RM, $(TARGETMOD).c) - - @$(call RM, $(TARGETMOD).o) - - @$(call RM, $(TARGETMOD).d) -endif -endif - -# ---------------------------------------------------------- -# Include dependency files generated by preprocessor. -# -# Dependency files are placed in main object directory because -# dependent files' paths for same source file varies with the -# directory from where gmake is run -# ---------------------------------------------------------- -ifndef NODEPENDS -ifndef nodepends -ifneq ($(OBJECTS),) --include $(OBJECTS:.o=.d) -endif -endif -endif - -# ---------------------------------------------------------- -# Generate fatal error if make variable SHELL is incorrect -# ---------------------------------------------------------- -SHELLERR:: - @$(SHELLCMD) echo Fatal error: SHELL set to $(SHELL) instead of $(MYSHELL) - @$(SHELLCMD) echo set $(MYSHELL) to correct path and CASE SENSITIVE FILE NAME and EXTENSTION - @$(SHELLCMD) echo of your command shell - $(ERR) - - -# ---------------------------------------------------------- -# For debugging script -# ---------------------------------------------------------- -Debug::$(SUBMODULES) - @$(SHELLCMD) echo SHELL: $(SHELL) - @$(SHELLCMD) echo - @$(SHELLCMD) echo CDEFS: $(CDEFS) - @$(SHELLCMD) echo - @$(SHELLCMD) echo CONFIG_SHELL: $(CONFIG_SHELL) - @$(SHELLCMD) echo - @$(SHELLCMD) echo CURDIR: $(CURDIR) - @$(SHELLCMD) echo - @$(SHELLCMD) echo SRCDIRS: $(SRCDIRS) - @$(SHELLCMD) echo - @$(SHELLCMD) echo OBJDIRS: $(OBJDIRS) - @$(SHELLCMD) echo - @$(SHELLCMD) echo OBJECTS: $(OBJECTS) - @$(SHELLCMD) echo - @$(SHELLCMD) echo BUILDDIR: $(BUILDDIR) - @$(SHELLCMD) echo - @$(SHELLCMD) echo TARGETDIR TARGETNAME: $(TARGET) - @$(SHELLCMD) echo - @$(SHELLCMD) echo MAKEDIR: $(MAKEDIR) - @$(SHELLCMD) echo - @$(SHELLCMD) echo INCLUDES: $(INCLUDES) - @$(SHELLCMD) echo - @$(SHELLCMD) echo DL_LIBNAMES: $(DL_LIBNAMES) - @$(SHELLCMD) echo - @$(SHELLCMD) echo LIBFILE: $(LIBFILE) - @$(SHELLCMD) echo - diff --git a/domx/make/start.mk b/domx/make/start.mk deleted file mode 100644 index 57921ac..0000000 --- a/domx/make/start.mk +++ /dev/null @@ -1,101 +0,0 @@ -# -# Copyright 2001-2009 Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# dspbridge/mpu_api/make/start.mk -# -# DSP-BIOS Bridge build rules. -# - -# make sure we have a rootdir -ifndef PROJROOT -$(error Error: variable PROJROOT not defined) -endif - -# make sure we have a bridgeroot -#ifndef BRIDGEROOT -#$(error Error: variable BRIDGEROOT not defined) -#endif - - -CMDDEFS = -CMDDEFS_START = - - -CROSS=arm-none-linux-gnueabi- -PROCFAMILY=OMAP_4430 - - -ifndef PROCFAMILY -$(error Error: PROCFAMILY can not be determined from Kernel .config) -endif - -ifndef TARGETDIR -TARGETDIR=$(PROJROOT)/target -endif - - - -#default (first) target should be "all" -#make sure the target directories are created -#all: $(HOSTDIR) $(ROOTFSDIR) $(TARGETDIR) -#all: $(TARGETDIR) - -CONFIG_SHELL := /bin/bash - -SHELL := $(CONFIG_SHELL) - -# Current version of gmake (3.79.1) cannot run windows shell's internal commands -# We need to invoke command interpreter explicitly to do so. -# for winnt it is cmd /c -SHELLCMD:= - -ifneq ($(SHELL),$(CONFIG_SHELL)) -CHECKSHELL:=SHELLERR -else -CHECKSHELL:= -endif - -# Error string to generate fatal error and abort gmake -ERR = $(error Makefile generated fatal error while building target "$@") - -CP := cp - -MAKEFLAGS = r - -QUIET := &> /dev/null - -# Should never be := -RM = rm $(1) -MV = mv $(1) $(2) -RMDIR = rm -r $(1) -MKDIR = mkdir -p $(1) -INSTALL = install - -# Current Makefile directory -MAKEDIR := $(CURDIR) - -# Implicit rule search not needed for *.d, *.c, *.h -%.d: -%.c: -%.h: - -# Tools -CC := $(CROSS)gcc -AR := $(CROSS)ar -LD := $(CROSS)ld -STRIP := $(CROSS)strip - - diff --git a/domx/mm_osal/Android.mk b/domx/mm_osal/Android.mk deleted file mode 100644 index ee4719a..0000000 --- a/domx/mm_osal/Android.mk +++ /dev/null @@ -1,30 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - src/timm_osal.c \ - src/timm_osal_events.c \ - src/timm_osal_memory.c \ - src/timm_osal_mutex.c \ - src/timm_osal_pipes.c \ - src/timm_osal_semaphores.c \ - src/timm_osal_task.c \ - src/timm_osal_trace.c - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/inc - -LOCAL_SHARED_LIBRARIES := \ - libdl \ - liblog \ - libc \ - libcutils - -LOCAL_CFLAGS += -DOMAP_2430 -DOMX_DEBUG -D_Android -D_POSIX_VERSION_1_ -#LOCAL_CFLAGS += -DTIMM_OSAL_DEBUG_TRACE_DETAIL=1 # quiet - -LOCAL_MODULE := libmm_osal -LOCAL_MODULE_TAGS := optional - -include $(BUILD_SHARED_LIBRARY) diff --git a/domx/mm_osal/Makefile b/domx/mm_osal/Makefile deleted file mode 100644 index a83814f..0000000 --- a/domx/mm_osal/Makefile +++ /dev/null @@ -1,61 +0,0 @@ - -include $(PROJROOT)/make/start.mk - - - -# Target name and extension -# static library (ST_LIB): filename.a -# shared library soname (SH_LIB): filename.so.maj_ver.min_ver -# executable (EXEC) : filename.out - -TARGETNAME = libmm_osal - - -# TARGETTYPE must be EXEC, ST_LIB or SH_LIB in upper case. - -TARGETTYPE = SH_LIB - -# install directory relative to the HOSTTARGET directory -HOSTRELEASE = lib - -# install directory relative to the root filesystem -ROOTFSRELEASE = lib - -# Filename must not begin with '.', '/' or '\' - -SOURCES = \ - src/timm_osal.c \ - src/timm_osal_events.c \ - src/timm_osal_memory.c \ - src/timm_osal_mutex.c \ - src/timm_osal_pipes.c \ - src/timm_osal_semaphores.c \ - src/timm_osal_task.c \ - src/timm_osal_trace.c - - - -# Search path for include files - -INCLUDES = \ - inc/ \ - - - -ST_LIBS = -SH_LIBS = -#pthread -#pthread rt utils procmgr ipc rcm notify -#SH_LIBS += sysmgr sysmemmgr - - -# Search path for library (and linker command) files. -# Current folder and target folder are included by default. - -LIBINCLUDES = - - -# Do not change below "include" line(s) - -include $(PROJROOT)/make/build.mk - diff --git a/domx/mm_osal/inc/timm_osal_error.h b/domx/mm_osal/inc/timm_osal_error.h deleted file mode 100755 index 37b20e7..0000000 --- a/domx/mm_osal/inc/timm_osal_error.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_timm_osal_error.h -* The osal header file defines the error codes -* @path -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -#ifndef _TIMM_OSAL_ERROR_H_ -#define _TIMM_OSAL_ERROR_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include "timm_osal_types.h" - -/** A unique ID for each component*/ - typedef TIMM_OSAL_U16 TIMM_OSAL_COMPID; - -/** TIMM_OSAL_ERROR is a 32 bits unsigned integer. - * Each error code can be broken up into three fields as given below: - * - Type of error (2 bits): NO_ERROR: 00, WARNING: 01, FATAL_ERROR: 10 - * - Component ID (14 bits): A unique ID which indicates which of the component generated the error - * - Error ID (16 bits): The specific error generated by a component - */ - typedef TIMM_OSAL_U32 TIMM_OSAL_ERRORTYPE; - -#define TIMM_OSAL_OK 0 -#define TIMM_OSAL_WAR 1 -#define TIMM_OSAL_ERR 2 - - -/* Macro to process TIMM_OSAL_ERROR */ - -/** This macro tests if the provided M4OSA_ERR is a warning or not*/ -#define TIMM_OSAL_IS_WARNING(error) ((((error)>>30) == TIMM_OSAL_WAR) ? 1:0) - -/** This macro tests if the provided M4OSA_ERR is a fatal error or not*/ -#define TIMM_OSAL_IS_ERROR(error) ((((error)>>30) == TIMM_OSAL_ERR) ? 1:0) - -/** This macro returns an error code accroding to the 3 provided fields: - * @arg Type: (IN) [TIMM_OSAL_U32] Type of error to put in the error code - * @arg compID: (IN) [TIMM_OSAL_U32] CompID to put in the error code - * @arg errorID: (IN) [TIMM_OSAL_U32] ErrorID to put in the error code*/ -#define TIMM_OSAL_ERR_CREATE(type, compID, errorID)\ - (((type)<<30)+(((compID)&0x003FFF)<<16)+((errorID)&0x00FFFF)) - -/** This macro extracts the 3 fields from the error: - * @arg error: (IN) [TIMM_OSAL_ERRORTYPE] Error code - * @arg type: (OUT) [TIMM_OSAL_U32] Type of error in the error code - * @arg compID: (OUT) [TIMM_OSAL_U32] CompID to put in the error code - * @arg errorID: (OUT) [TIMM_OSAL_U32] ErrorID to put in the error code*/ -#define TIMM_OSAL_ERR_SPLIT(error, type, compID, errorID)\ - { type=(TIMM_OSAL_U32)((error)>>30);\ - compID=(TIMM_OSAL_U32)(((error)>>16)&0x003FFF);\ - (TIMM_OSAL_U32)(errorID=(error)&0x00FFFF); } - -/* Component IDs */ -#define TIMM_OSAL_COMP_GENERAL 0x00 -#define TIMM_OSAL_COMP_MEMORY 0x01 -#define TIMM_OSAL_COMP_PIPES 0x02 -#define TIMM_OSAL_COMP_EVENTS 0x03 -#define TIMM_OSAL_COMP_SEMAPHORES 0x04 -#define TIMM_OSAL_COMP_TASK 0x05 - -/* Definition of common error codes */ -/** there is no error*/ -#define TIMM_OSAL_ERR_NONE ((TIMM_OSAL_ERRORTYPE) 0x00000000) - - -/** There is no more memory available*/ -#define TIMM_OSAL_ERR_ALLOC ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000001)) -#define TIMM_OSAL_ERR_OUT_OF_RESOURCE ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000002)) - -/** Time out */ -#define TIMM_OSAL_WAR_TIMEOUT ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_WAR,TIMM_OSAL_COMP_GENERAL,0x000003)) -#define TIMM_OSAL_ERR_PARAMETER ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000004)) -#define TIMM_OSAL_ERR_NOT_READY ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000005)) -#define TIMM_OSAL_ERR_OMX ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000006)) -#define TIMM_OSAL_ERR_PIPE_FULL ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000007)) -#define TIMM_OSAL_ERR_PIPE_EMPTY ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000008)) -#define TIMM_OSAL_ERR_PIPE_DELETED ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000009)) -#define TIMM_OSAL_ERR_PIPE_RESET ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x00000A)) -#define TIMM_OSAL_ERR_GROUP_DELETED ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x00000B)) -#define TIMM_OSAL_ERR_UNKNOWN ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x00000C)) - - -#define TIMM_OSAL_ERR_SEM_CREATE_FAILED ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_SEMAPHORE,0x000001)) - -/*Added during Linux Porting*/ -#define TIMM_OSAL_ERR_NO_PERMISSIONS ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x00000D)) -#define TIMM_OSAL_ERR_RESOURCE_EXISTS ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x00000E)) -#define TIMM_OSAL_ERR_RESOURCE_REMOVED ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x00000F)) -#define TIMM_OSAL_ERR_SYSTEM_LIMIT_EXCEEDED ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000010)) -#define TIMM_OSAL_ERR_NOT_SUPPORTED ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000011)) -#define TIMM_OSAL_ERR_SIGNAL_CAUGHT ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000012)) -#define TIMM_OSAL_ERR_TIMEOUT ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_GENERAL,0x000013)) - - - -#define TIMM_OSAL_COMP_MSG_Q 0x06 -#define TIMM_OSAL_ERR_MSG_SIZE_MISMATCH ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_MSG_Q,0x000001)) -#define TIMM_OSAL_ERR_MSG_TYPE_NOT_FOUND ((TIMM_OSAL_ERRORTYPE) TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR,TIMM_OSAL_COMP_MSG_Q,0x000002)) - - -/* -#define GOTO_EXIT_IF(_Cond,_ErrorCode) { \ - if ((_Cond)) { \ - status = _ErrorCode; \ - printf ("Error :: %s : %s : %d :: Exiting because : %s\n", \ - __FILE__, __FUNCTION__, __LINE__, #_Cond); \ - goto EXIT; \ - } \ -} -*/ - -#define SWITCH_CASE(_Case, _ErrCode, _ErrMsg)\ - case _Case:\ - TIMM_OSAL_Error(_ErrMsg);\ - bReturnStatus = _ErrCode;\ - break; - -#define SWITCH_DEFAULT_CASE(_ErrCode, _ErrMsg )\ - default:\ - TIMM_OSAL_Error(_ErrMsg);\ - bReturnStatus = _ErrCode;\ - break; - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /*_TIMM_OSAL_ERROR_H_*/ diff --git a/domx/mm_osal/inc/timm_osal_events.h b/domx/mm_osal/inc/timm_osal_events.h deleted file mode 100755 index 20a4d84..0000000 --- a/domx/mm_osal/inc/timm_osal_events.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_defines.h -* The osal header file defines -* @path -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -#ifndef _TIMM_OSAL_EVENTS_H_ -#define _TIMM_OSAL_EVENTS_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include "timm_osal_types.h" - - typedef enum TIMM_OSAL_EVENT_OPERATION - { - TIMM_OSAL_EVENT_AND, - TIMM_OSAL_EVENT_AND_CONSUME, - TIMM_OSAL_EVENT_OR, - TIMM_OSAL_EVENT_OR_CONSUME - } TIMM_OSAL_EVENT_OPERATION; - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_EventCreate(TIMM_OSAL_PTR * pEvents); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_EventDelete(TIMM_OSAL_PTR pEvents); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_EventSet(TIMM_OSAL_PTR pEvents, - TIMM_OSAL_U32 uEventFlag, TIMM_OSAL_EVENT_OPERATION eOperation); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_EventRetrieve(TIMM_OSAL_PTR pEvents, - TIMM_OSAL_U32 uRequestedEvents, - TIMM_OSAL_EVENT_OPERATION eOperation, - TIMM_OSAL_U32 * pRetrievedEvents, TIMM_OSAL_U32 uTimeOut); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _TIMM_OSAL_EVENTS_H_ */ diff --git a/domx/mm_osal/inc/timm_osal_interfaces.h b/domx/mm_osal/inc/timm_osal_interfaces.h deleted file mode 100755 index dd3fd81..0000000 --- a/domx/mm_osal/inc/timm_osal_interfaces.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_memory.h -* The osal header file defines -* @path -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -#ifndef _TIMM_OSAL_INTERFACES_H_ -#define _TIMM_OSAL_INTERFACES_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/******************************************************************************* -* External interface -*******************************************************************************/ -#include "timm_osal_types.h" -#include "timm_osal_error.h" -#include "timm_osal_memory.h" -#include "timm_osal_pipes.h" -#include "timm_osal_events.h" -#include "timm_osal_semaphores.h" -#include "timm_osal_mutex.h" -#include "timm_osal_task.h" -#include "timm_osal_osal.h" - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _TIMM_OSAL_INTERFACES_H_ */ diff --git a/domx/mm_osal/inc/timm_osal_memory.h b/domx/mm_osal/inc/timm_osal_memory.h deleted file mode 100755 index ed21636..0000000 --- a/domx/mm_osal/inc/timm_osal_memory.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_memory.h -* The osal header file defines -* @path -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -#ifndef _TIMM_OSAL_MEMORY_H_ -#define _TIMM_OSAL_MEMORY_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/******************************************************************************* -* Includes -*******************************************************************************/ - -#include "timm_osal_types.h" -#include "timm_osal_error.h" - - -/* Enumeration Flag for Memory Segmenation Id */ - typedef enum TIMMOSAL_MEM_SEGMENTID - { - - TIMMOSAL_MEM_SEGMENT_EXT = 0, - TIMMOSAL_MEM_SEGMENT_INT, - TIMMOSAL_MEM_SEGMENT_UNCACHED - } TIMMOSAL_MEM_SEGMENTID; - - -/******************************************************************************* -* External interface -*******************************************************************************/ - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_CreateMemoryPool(void); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_DeleteMemoryPool(void); - - TIMM_OSAL_PTR TIMM_OSAL_Malloc(TIMM_OSAL_U32 size, - TIMM_OSAL_BOOL bBlockContiguous, TIMM_OSAL_U32 unBlockAlignment, - TIMMOSAL_MEM_SEGMENTID tMemSegId); - - void TIMM_OSAL_Free(TIMM_OSAL_PTR pData); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_Memset(TIMM_OSAL_PTR pBuffer, - TIMM_OSAL_U8 uValue, TIMM_OSAL_U32 uSize); - - TIMM_OSAL_S32 TIMM_OSAL_Memcmp(TIMM_OSAL_PTR pBuffer1, - TIMM_OSAL_PTR pBuffer2, TIMM_OSAL_U32 uSize); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_Memcpy(TIMM_OSAL_PTR pBufDst, - TIMM_OSAL_PTR pBufSrc, TIMM_OSAL_U32 uSize); - - TIMM_OSAL_U32 TIMM_OSAL_GetMemCounter(void); - -#define TIMM_OSAL_MallocExtn(size, bBlockContiguous, unBlockAlignment, tMemSegId, hHeap) \ - TIMM_OSAL_Malloc(size, bBlockContiguous, unBlockAlignment, tMemSegId ) - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _TIMM_OSAL_DEFINES_H_ */ diff --git a/domx/mm_osal/inc/timm_osal_mutex.h b/domx/mm_osal/inc/timm_osal_mutex.h deleted file mode 100755 index 1d12c91..0000000 --- a/domx/mm_osal/inc/timm_osal_mutex.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_defines.h -* The osal header file defines -* @path -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -#ifndef _TIMM_OSAL_MUTEX_H_ -#define _TIMM_OSAL_MUTEX_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/******************************************************************************* -* Includes -*******************************************************************************/ - -#include "timm_osal_types.h" - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_MutexCreate(TIMM_OSAL_PTR * pMutex); - TIMM_OSAL_ERRORTYPE TIMM_OSAL_MutexDelete(TIMM_OSAL_PTR pMutex); - TIMM_OSAL_ERRORTYPE TIMM_OSAL_MutexObtain(TIMM_OSAL_PTR pMutex, - TIMM_OSAL_U32 uTimeOut); - TIMM_OSAL_ERRORTYPE TIMM_OSAL_MutexRelease(TIMM_OSAL_PTR pMutex); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _TIMM_OSAL_MUTEX_H_ */ diff --git a/domx/mm_osal/inc/timm_osal_osal.h b/domx/mm_osal/inc/timm_osal_osal.h deleted file mode 100755 index a4e0e9e..0000000 --- a/domx/mm_osal/inc/timm_osal_osal.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_osal.h -* The osal header file defines -* @path -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -#ifndef _TIMM_OSAL_OSAL_H_ -#define _TIMM_OSAL_OSAL_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/******************************************************************************* -* Includes -*******************************************************************************/ - -#include "timm_osal_types.h" - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_Init(void); - TIMM_OSAL_ERRORTYPE TIMM_OSAL_Deinit(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _TIMM_OSAL_OSAL_H_ */ diff --git a/domx/mm_osal/inc/timm_osal_pipes.h b/domx/mm_osal/inc/timm_osal_pipes.h deleted file mode 100755 index 79d7d61..0000000 --- a/domx/mm_osal/inc/timm_osal_pipes.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_defines.h -* The osal header file defines -* @path -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -#ifndef _TIMM_OSAL_PIPES_H_ -#define _TIMM_OSAL_PIPES_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include "timm_osal_types.h" - -/* -* Defined for Pipe timeout value -*/ - TIMM_OSAL_ERRORTYPE TIMM_OSAL_CreatePipe(TIMM_OSAL_PTR * pPipe, - TIMM_OSAL_U32 pipeSize, - TIMM_OSAL_U32 messageSize, TIMM_OSAL_U8 isFixedMessage); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_DeletePipe(TIMM_OSAL_PTR pPipe); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_WriteToPipe(TIMM_OSAL_PTR pPipe, - void *pMessage, TIMM_OSAL_U32 size, TIMM_OSAL_S32 timeout); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_WriteToFrontOfPipe(TIMM_OSAL_PTR pPipe, - void *pMessage, TIMM_OSAL_U32 size, TIMM_OSAL_S32 timeout); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_ReadFromPipe(TIMM_OSAL_PTR pPipe, - void *pMessage, - TIMM_OSAL_U32 size, - TIMM_OSAL_U32 * actualSize, TIMM_OSAL_S32 timeout); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_ClearPipe(TIMM_OSAL_PTR pPipe); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_IsPipeReady(TIMM_OSAL_PTR pPipe); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_GetPipeReadyMessageCount(TIMM_OSAL_PTR - pPipe, TIMM_OSAL_U32 * count); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _TIMM_OSAL_PIPES_H_ */ diff --git a/domx/mm_osal/inc/timm_osal_semaphores.h b/domx/mm_osal/inc/timm_osal_semaphores.h deleted file mode 100755 index 86037d7..0000000 --- a/domx/mm_osal/inc/timm_osal_semaphores.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_defines.h -* The osal header file defines -* @path -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -#ifndef _TIMM_OSAL_SEMAPHORE_H_ -#define _TIMM_OSAL_SEMAPHORE_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/******************************************************************************* -* Includes -*******************************************************************************/ - -#include "timm_osal_types.h" - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreCreate(TIMM_OSAL_PTR * - pSemaphore, TIMM_OSAL_U32 uInitCount); - TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreDelete(TIMM_OSAL_PTR - pSemaphore); - TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreObtain(TIMM_OSAL_PTR - pSemaphore, TIMM_OSAL_U32 uTimeOut); - TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreRelease(TIMM_OSAL_PTR - pSemaphore); - TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreReset(TIMM_OSAL_PTR pSemaphore, - TIMM_OSAL_U32 uInitCount); - TIMM_OSAL_ERRORTYPE TIMM_OSAL_GetSemaphoreCount(TIMM_OSAL_PTR - pSemaphore, TIMM_OSAL_U32 * count); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _TIMM_OSAL_SEMAPHORE_H_ */ diff --git a/domx/mm_osal/inc/timm_osal_task.h b/domx/mm_osal/inc/timm_osal_task.h deleted file mode 100755 index 6f67a82..0000000 --- a/domx/mm_osal/inc/timm_osal_task.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_task.h -* The osal header file defines -* @path -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -#ifndef _TIMM_OSAL_TASK_H_ -#define _TIMM_OSAL_TASK_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/******************************************************************************* -* Includes -*******************************************************************************/ - -#include "timm_osal_types.h" - -/******************************************************************************* -* Tasks -*******************************************************************************/ - -/** -* prototype for the task function -*/ - /*typedef void (*TIMM_OSAL_TaskProc)(TIMM_OSAL_U32 argc, TIMM_OSAL_PTR argv);*//*Nucleus */ - - typedef void *(*TIMM_OSAL_TaskProc) (void *arg); /*Linux */ - - - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_CreateTask(TIMM_OSAL_PTR * pTask, - TIMM_OSAL_TaskProc pFunc, - TIMM_OSAL_U32 uArgc, - TIMM_OSAL_PTR pArgv, - TIMM_OSAL_U32 uStackSize, - TIMM_OSAL_U32 uPriority, TIMM_OSAL_S8 * pName); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_DeleteTask(TIMM_OSAL_PTR pTask); - - TIMM_OSAL_ERRORTYPE TIMM_OSAL_SleepTask(TIMM_OSAL_U32 mSec); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _TIMM_OSAL_TASK_H_ */ diff --git a/domx/mm_osal/inc/timm_osal_trace.h b/domx/mm_osal/inc/timm_osal_trace.h deleted file mode 100755 index 412c5a9..0000000 --- a/domx/mm_osal/inc/timm_osal_trace.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_trace.h -* The timm_osal_types header file defines the primative osal type definitions. -* @path -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -#ifndef _TIMM_OSAL_TRACES_H_ -#define _TIMM_OSAL_TRACES_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -/******************************************************************************* -* Traces -*******************************************************************************/ - - -/****************************************************************************** -* Debug Trace defines -******************************************************************************/ - - typedef enum TIMM_OSAL_TRACEGRP_TYPE - { - TIMM_OSAL_TRACEGRP_SYSTEM = 1, - TIMM_OSAL_TRACEGRP_OMXBASE = (1 << 1), - TIMM_OSAL_TRACEGRP_DOMX = (1 << 2), - TIMM_OSAL_TRACEGRP_OMXVIDEOENC = (1 << 3), - TIMM_OSAL_TRACEGRP_OMXVIDEODEC = (1 << 4), - TIMM_OSAL_TRACEGRP_OMXCAM = (1 << 5), - TIMM_OSAL_TRACEGRP_OMXIMGDEC = (1 << 6), - TIMM_OSAL_TRACEGRP_DRIVERS = (1 << 7), - TIMM_OSAL_TRACEGRP_SIMCOPALGOS = (1 << 8) - } TIMM_OSAL_TRACEGRP; - - typedef enum TIMM_OSAL_TRACE_LEVEL_TYPE - { - TIMM_OSAL_TRACE_LEVEL_ERROR = 1, - TIMM_OSAL_TRACE_LEVEL_WARNING = 2, - TIMM_OSAL_TRACE_LEVEL_PROFILING = 3, - TIMM_OSAL_TRACE_LEVEL_INFO = 4, - TIMM_OSAL_TRACE_LEVEL_DEBUG = 5, - TIMM_OSAL_TRACE_LEVEL_ENTERING = 6, - TIMM_OSAL_TRACE_LEVEL_EXITING = TIMM_OSAL_TRACE_LEVEL_ENTERING - } TIMM_OSAL_TRACE_LEVEL; - - -/** -* The OSAL debug trace level can be set at runtime by defining the environment -* variable TIMM_OSAL_DEBUG_TRACE_LEVEL=. The default level is 1 -* The debug levels are: -* Level 0 - No trace -* Level 1 - Error [Errors] -* Level 2 - Warning [Warnings that are useful to know about] -* Level 3 - Profiling [performance analysis trace that must not impact use case perf] -* Level 4 - Info [General information] -* Level 5 - Debug [most-commonly used statement for us developers] -* Level 6 - Trace ["ENTERING " and "EXITING " statements] -* -* Example: if TIMM_OSAL_DEBUG_TRACE_LEVEL=3, then level 1,2 and 3 traces messages -* are enabled. -*/ - -/** - * Information about the trace location/type, passed as a single pointer to - * internal trace function. Not part of the public API - */ - typedef struct - { - const char *file; - const char *function; - const int line; - const short level; - const short tracegrp; /* TIMM_OSAL_TRACEGRP */ - } __TIMM_OSAL_TRACE_LOCATION; - - -/** - * Trace level update function. Updates trace level if env variable - * or Android property is set. Env variable has precedence over it - */ - void TIMM_OSAL_UpdateTraceLevel(void); - -/** - * Trace implementation function. Not part of public API. Default - * implementation uses printf(), but you can use LD_PRELOAD to plug in - * alternative trace system at runtime. - */ - void __TIMM_OSAL_TraceFunction(const __TIMM_OSAL_TRACE_LOCATION * loc, - const char *fmt, ...); - -/** - * Internal trace macro. Not part of public API. - */ -#define __TIMM_OSAL_Trace(level, tracegrp, fmt, ...) \ - do { \ - static const __TIMM_OSAL_TRACE_LOCATION loc = { \ - __FILE__, __FUNCTION__, __LINE__, (level), (tracegrp) \ - }; \ - __TIMM_OSAL_TraceFunction(&loc, fmt "\n", ##__VA_ARGS__); \ - } while(0) - -/** -* TIMM_OSAL_Error() -- Fatal errors -*/ -#define TIMM_OSAL_Error(fmt,...) TIMM_OSAL_ErrorExt(TIMM_OSAL_TRACEGRP_SYSTEM, fmt, ##__VA_ARGS__) - -/** -* TIMM_OSAL_Warning() -- Warnings that are useful to know about -*/ -#define TIMM_OSAL_Warning(fmt,...) TIMM_OSAL_WarningExt(TIMM_OSAL_TRACEGRP_SYSTEM, fmt, ##__VA_ARGS__) - -/** -* TIMM_OSAL_Profiling() -- performance analysis trace that must not impact use case perf] -*/ -#define TIMM_OSAL_Profiling(fmt,...) TIMM_OSAL_ProfilingExt(TIMM_OSAL_TRACEGRP_SYSTEM, fmt, ##__VA_ARGS__) - -/** -* TIMM_OSAL_Info() -- general information -*/ -#define TIMM_OSAL_Info(fmt,...) TIMM_OSAL_InfoExt(TIMM_OSAL_TRACEGRP_SYSTEM, fmt, ##__VA_ARGS__) - -/** -* TIMM_OSAL_Debug() -- debug traces, most-commonly useful for developers -*/ -#define TIMM_OSAL_Debug(fmt,...) TIMM_OSAL_DebugExt(TIMM_OSAL_TRACEGRP_SYSTEM, fmt, ##__VA_ARGS__) - -/** -* TIMM_OSAL_Entering() -- "ENTERING " statements -* TIMM_OSAL_Exiting() -- "EXITING " statements -*/ -#define TIMM_OSAL_Entering(fmt,...) TIMM_OSAL_EnteringExt(TIMM_OSAL_TRACEGRP_SYSTEM, fmt, ##__VA_ARGS__) -#define TIMM_OSAL_Exiting(fmt,...) TIMM_OSAL_ExitingExt(TIMM_OSAL_TRACEGRP_SYSTEM, fmt, ##__VA_ARGS__) - -/******************************************************************************* -** New Trace to be used by Applications -*******************************************************************************/ - -/** -* TIMM_OSAL_ErrorExt() -- Fatal errors -*/ -#define TIMM_OSAL_ErrorExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_ERROR, tracegrp, "ERROR: " fmt, ##__VA_ARGS__) - -/** -* TIMM_OSAL_WarningExt() -- Warnings that are useful to know about -*/ -#define TIMM_OSAL_WarningExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_WARNING, tracegrp, "WARNING: " fmt, ##__VA_ARGS__) - -/** -* TIMM_OSAL_ProfilingExt() -- performance analysis trace that must not impact use case perf] -*/ -#define TIMM_OSAL_ProfilingExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_PROFILING, tracegrp, "PROFILING: " fmt, ##__VA_ARGS__) - -/** -* TIMM_OSAL_InfoExt() -- general information -*/ -#define TIMM_OSAL_InfoExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_INFO, tracegrp, "INFO: " fmt, ##__VA_ARGS__) - -/** -* TIMM_OSAL_DebugExt() -- most-commonly used statement for us developers -*/ -#define TIMM_OSAL_DebugExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_DEBUG, tracegrp, "TRACE: " fmt, ##__VA_ARGS__) - -/** -* TIMM_OSAL_EnteringExt() -- "ENTERING " statements -* TIMM_OSAL_ExitingExt() -- "EXITING " statements -*/ -#define TIMM_OSAL_EnteringExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_ENTERING, tracegrp, "ENTER: " fmt, ##__VA_ARGS__) -#define TIMM_OSAL_ExitingExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_EXITING, tracegrp, "EXIT: " fmt, ##__VA_ARGS__) - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _TIMM_OSAL_TRACES_H_ */ diff --git a/domx/mm_osal/inc/timm_osal_types.h b/domx/mm_osal/inc/timm_osal_types.h deleted file mode 100755 index 882148d..0000000 --- a/domx/mm_osal/inc/timm_osal_types.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_types.h -* The timm_osal_types header file defines the primative osal type definitions. -* @path -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -#ifndef _TIMM_OSAL_TYPES_H_ -#define _TIMM_OSAL_TYPES_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - - - -#ifdef __KERNEL__ -#include -#else -#include -#endif - - typedef int8_t TIMM_OSAL_S8; /*INT8 */ - typedef int16_t TIMM_OSAL_S16; /*INT16 */ - typedef int32_t TIMM_OSAL_S32; /*INT32 */ - -#define TIMM_OSAL_INT8_MIN 0xFF -#define TIMM_OSAL_INT8_MAX 0x7F - -#define TIMM_OSAL_INT16_MIN 0xFFFF -#define TIMM_OSAL_INT16_MAX 0x7FFF - -#define TIMM_OSAL_INT32_MIN 0xFFFFFFFF -#define TIMM_OSAL_INT32_MAX 0x7FFFFFFF - - typedef uint8_t TIMM_OSAL_U8; /*UINT8 */ - typedef uint16_t TIMM_OSAL_U16; /*UINT16 */ - typedef uint32_t TIMM_OSAL_U32; /*UINT32 */ - -#define TIMM_OSAL_UINT8_MIN 0 -#define TIMM_OSAL_UINT8_MAX 0xFF - -#define TIMM_OSAL_UINT16_MIN 0 -#define TIMM_OSAL_UINT16_MAX 0xFFFF - -#define TIMM_OSAL_UINT32_MIN 0 -#define TIMM_OSAL_UINT32_MAX 0xFFFFFFFF - - - typedef char TIMM_OSAL_CHAR; - /*CHAR*/ typedef void *TIMM_OSAL_HANDLE; - typedef void *TIMM_OSAL_PTR; - - typedef enum TIMM_OSAL_BOOL - { - TIMM_OSAL_FALSE = 0, - TIMM_OSAL_TRUE = !TIMM_OSAL_FALSE, - TIMM_OSAL_BOOL_MAX = 0x7FFFFFFF - } TIMM_OSAL_BOOL; - -#define TIMM_OSAL_SUSPEND 0xFFFFFFFFUL -#define TIMM_OSAL_NO_SUSPEND 0x0 -#define TIMM_OSAL_TIMED_OUT 0x7FFFFFFFUL - - -#define SUCCESS 0 -#define NO_SUCCESS -1 - -#define ERROR 1 -/* -#define TRUE 0 -#define FALSE 1 -*/ -#define URGENT_MESSAGE 2 -#define NORMAL_MESSAGE 1 - - -#define TIMM_OSAL_NULL 0 - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _TIMM_OSAL_TYPES_H_ */ diff --git a/domx/mm_osal/src/timm_osal.c b/domx/mm_osal/src/timm_osal.c deleted file mode 100755 index 85fdb66..0000000 --- a/domx/mm_osal/src/timm_osal.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file tiimm_osal.c -* This file contains methods that provides the functionality -* initializing/deinitializing the osal. -* -* @path \ -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 20-Oct-2008 Maiya ShreeHarsha:Linux specific changes - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -/****************************************************************************** -* Includes -******************************************************************************/ -#include "timm_osal_types.h" -#include "timm_osal_error.h" -#include "timm_osal_memory.h" -/*#include "timm_osal_trace.h"*/ - - -/****************************************************************************** -* Function Prototypes -******************************************************************************/ - -/**************************************************************** -* PRIVATE DECLARATIONS : only used in this file -****************************************************************/ -/*--------data declarations -----------------------------------*/ - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_Init function initilize the osal with initial settings. -* -* @return TIMM_OSAL_ERR_NONE if successful -* !TIMM_OSAL_ERR_NONE if an error occurs -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_Init(void) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE; - return bReturnStatus; -} - - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_Init function de-initilize the osal. -* -* @return TIMM_OSAL_ERR_NONE if successful -* !TIMM_OSAL_ERR_NONE if an error occurs -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_Deinit(void) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE; - return bReturnStatus; -} diff --git a/domx/mm_osal/src/timm_osal_events.c b/domx/mm_osal/src/timm_osal_events.c deleted file mode 100755 index 96f8e59..0000000 --- a/domx/mm_osal/src/timm_osal_events.c +++ /dev/null @@ -1,420 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_events.c -* This file contains methods that provides the functionality -* for creating/using events. -* -* @path \ -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 06-Nov-2008 Maiya ShreeHarsha: Linux specific changes - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -/****************************************************************************** -* Includes -******************************************************************************/ -#include -#include /*for POSIX calls */ -#include -#include - -#include "timm_osal_types.h" -#include "timm_osal_trace.h" -#include "timm_osal_error.h" -#include "timm_osal_memory.h" -#include "timm_osal_events.h" - - -typedef struct -{ - TIMM_OSAL_BOOL bSignaled; - TIMM_OSAL_U32 eFlags; - pthread_mutex_t mutex; - pthread_cond_t condition; -} TIMM_OSAL_THREAD_EVENT; - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_EventCreate function -* -* -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_EventCreate(TIMM_OSAL_PTR * pEvents) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - TIMM_OSAL_THREAD_EVENT *plEvent = NULL; - - plEvent = - (TIMM_OSAL_THREAD_EVENT *) - TIMM_OSAL_Malloc(sizeof(TIMM_OSAL_THREAD_EVENT), 0, 0, 0); - - if (TIMM_OSAL_NULL == plEvent) - { - bReturnStatus = TIMM_OSAL_ERR_ALLOC; - goto EXIT; - } - plEvent->bSignaled = TIMM_OSAL_FALSE; - plEvent->eFlags = 0; - - if (SUCCESS != pthread_mutex_init(&(plEvent->mutex), NULL)) - { - TIMM_OSAL_Error("Event Create:Mutex Init failed !"); - goto EXIT; /*bReturnStatus = TIMM_OSAL_ERR_UNKNOWN */ - } - - if (SUCCESS != pthread_cond_init(&(plEvent->condition), NULL)) - { - TIMM_OSAL_Error - ("Event Create:Conditional Variable Init failed !"); - pthread_mutex_destroy(&(plEvent->mutex)); - /*TIMM_OSAL_Free(plEvent); */ - } else - { - *pEvents = (TIMM_OSAL_PTR) plEvent; - bReturnStatus = TIMM_OSAL_ERR_NONE; - } - EXIT: - if ((TIMM_OSAL_ERR_NONE != bReturnStatus) && - (TIMM_OSAL_NULL != plEvent)) - { - TIMM_OSAL_Free(plEvent); - } - return bReturnStatus; -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_EventDelete function -* -* -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_EventDelete(TIMM_OSAL_PTR pEvents) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_THREAD_EVENT *plEvent = (TIMM_OSAL_THREAD_EVENT *) pEvents; - - if (TIMM_OSAL_NULL == plEvent) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - if (SUCCESS != pthread_mutex_lock(&(plEvent->mutex))) - { - TIMM_OSAL_Error("Event Delete: Mutex Lock failed !"); - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - } - if (SUCCESS != pthread_cond_destroy(&(plEvent->condition))) - { - TIMM_OSAL_Error - ("Event Delete: Conditional Variable Destroy failed !"); - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - } - - if (SUCCESS != pthread_mutex_unlock(&(plEvent->mutex))) - { - TIMM_OSAL_Error("Event Delete: Mutex Unlock failed !"); - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - } - - if (SUCCESS != pthread_mutex_destroy(&(plEvent->mutex))) - { - TIMM_OSAL_Error("Event Delete: Mutex Destory failed !"); - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - } - - TIMM_OSAL_Free(plEvent); - EXIT: - return bReturnStatus; -} - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_EventSet function -* -* -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_EventSet(TIMM_OSAL_PTR pEvents, - TIMM_OSAL_U32 uEventFlags, TIMM_OSAL_EVENT_OPERATION eOperation) -{ - - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - TIMM_OSAL_THREAD_EVENT *plEvent = (TIMM_OSAL_THREAD_EVENT *) pEvents; - - if (TIMM_OSAL_NULL == plEvent) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - if (SUCCESS != pthread_mutex_lock(&(plEvent->mutex))) - { - TIMM_OSAL_Error("Event Set: Mutex Lock failed !"); - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - goto EXIT; - } - - switch (eOperation) - { - case TIMM_OSAL_EVENT_AND: - plEvent->eFlags = plEvent->eFlags & uEventFlags; - break; - case TIMM_OSAL_EVENT_OR: - plEvent->eFlags = plEvent->eFlags | uEventFlags; - break; - default: - TIMM_OSAL_Error("Event Set: Bad eOperation !"); - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - pthread_mutex_unlock(&plEvent->mutex); - goto EXIT; - } - - plEvent->bSignaled = TIMM_OSAL_TRUE; - - if (SUCCESS != pthread_cond_signal(&plEvent->condition)) - { - TIMM_OSAL_Error - ("Event Set: Condition Variable Signal failed !"); - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - pthread_mutex_unlock(&plEvent->mutex); - goto EXIT; - } - - if (SUCCESS != pthread_mutex_unlock(&plEvent->mutex)) - { - TIMM_OSAL_Error("Event Set: Mutex Unlock failed !"); - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - } else - bReturnStatus = TIMM_OSAL_ERR_NONE; - - EXIT: - return bReturnStatus; - - -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_EventRetrieve function -* -*Spurious wakeups from the pthread_cond_timedwait() or pthread_cond_wait() functions may occur. -* -*A representative sequence for using condition variables is shown below -* -*Thread A (Retrieve Events) |Thread B (Set Events) -*------------------------------------------------------------------------------------------------------------ -*1) Do work up to the point where a certain condition |1)Do work -* must occur (such as "count" must reach a specified |2)Lock associated mutex -* value) |3)Change the value of the global variable -*2) Lock associated mutex and check value of a global | that Thread-A is waiting upon. -* variable |4)Check value of the global Thread-A wait -*3) Call pthread_cond_wait() to perform a blocking wait | variable. If it fulfills the desired -* for signal from Thread-B. Note that a call to | condition, signal Thread-A. -* pthread_cond_wait() automatically and atomically |5)Unlock mutex. -* unlocks the associated mutex variable so that it can |6)Continue -* be used by Thread-B. | -*4) When signalled, wake up. Mutex is automatically and | -* atomically locked. | -*5) Explicitly unlock mutex | -*6) Continue | -* -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_EventRetrieve(TIMM_OSAL_PTR pEvents, - TIMM_OSAL_U32 uRequestedEvents, - TIMM_OSAL_EVENT_OPERATION eOperation, - TIMM_OSAL_U32 * pRetrievedEvents, TIMM_OSAL_U32 uTimeOutMsec) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - struct timespec timeout; - struct timeval now; - TIMM_OSAL_U32 timeout_us; - TIMM_OSAL_U32 isolatedFlags; - int status = -1; - int and_operation; - TIMM_OSAL_THREAD_EVENT *plEvent = (TIMM_OSAL_THREAD_EVENT *) pEvents; - - if (TIMM_OSAL_NULL == plEvent) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - /* Lock the mutex for access to the eFlags global variable */ - if (SUCCESS != pthread_mutex_lock(&(plEvent->mutex))) - { - TIMM_OSAL_Error("Event Retrieve: Mutex Lock failed !"); - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - goto EXIT; - } - - /*Check the eOperation and put it in a variable */ - and_operation = ((TIMM_OSAL_EVENT_AND == eOperation) || - (TIMM_OSAL_EVENT_AND_CONSUME == eOperation)); - - /* Isolate the flags. The & operation is suffice for an TIMM_OSAL_EVENT_OR eOperation */ - isolatedFlags = plEvent->eFlags & uRequestedEvents; - - /*Check if it is the AND operation. If yes then, all the flags must match */ - if (and_operation) - { - isolatedFlags = (isolatedFlags == uRequestedEvents); - } - - - if (isolatedFlags) - { - - /*We have got required combination of the eFlags bits and will return it back */ - *pRetrievedEvents = plEvent->eFlags; - bReturnStatus = TIMM_OSAL_ERR_NONE; - } else - { - - /*Required combination of bits is not yet available */ - if (TIMM_OSAL_NO_SUSPEND == uTimeOutMsec) - { - *pRetrievedEvents = 0; - bReturnStatus = TIMM_OSAL_ERR_NONE; - } - - else if (TIMM_OSAL_SUSPEND == uTimeOutMsec) - { - - /*Wait till we get the required combination of bits. We we get the required - *bits then we go out of the while loop - */ - while (!isolatedFlags) - { - - /*Wait on the conditional variable for another thread to set the eFlags and signal */ - pthread_cond_wait(&(plEvent->condition), - &(plEvent->mutex)); - - /* eFlags set by some thread. Now, isolate the flags. - * The & operation is suffice for an TIMM_OSAL_EVENT_OR eOperation - */ - isolatedFlags = - plEvent->eFlags & uRequestedEvents; - - /*Check if it is the AND operation. If yes then, all the flags must match */ - if (and_operation) - { - isolatedFlags = - (isolatedFlags == - uRequestedEvents); - } - } - - /* Obtained the requested combination of bits on eFlags */ - *pRetrievedEvents = plEvent->eFlags; - bReturnStatus = TIMM_OSAL_ERR_NONE; - - } else - { - - /* Calculate uTimeOutMsec in terms of the absolute time. uTimeOutMsec is in milliseconds */ - gettimeofday(&now, NULL); - timeout_us = now.tv_usec + 1000 * uTimeOutMsec; - timeout.tv_sec = now.tv_sec + timeout_us / 1000000; - timeout.tv_nsec = (timeout_us % 1000000) * 1000; - - while (!isolatedFlags) - { - - /* Wait till uTimeOutMsec for a thread to signal on the conditional variable */ - status = - pthread_cond_timedwait(&(plEvent-> - condition), &(plEvent->mutex), - &timeout); - - /*Timedout or error and returned without being signalled */ - if (SUCCESS != status) - { - if (ETIMEDOUT == status) - bReturnStatus = - TIMM_OSAL_ERR_NONE; - *pRetrievedEvents = 0; - break; - } - - /* eFlags set by some thread. Now, isolate the flags. - * The & operation is suffice for an TIMM_OSAL_EVENT_OR eOperation - */ - isolatedFlags = - plEvent->eFlags & uRequestedEvents; - - /*Check if it is the AND operation. If yes then, all the flags must match */ - if (and_operation) - { - isolatedFlags = - (isolatedFlags == - uRequestedEvents); - } - - } - } - } - - /*If we have got the required combination of bits, we will have to reset the eFlags if CONSUME is mentioned - *in the eOperations - */ - if (isolatedFlags && ((eOperation == TIMM_OSAL_EVENT_AND_CONSUME) || - (eOperation == TIMM_OSAL_EVENT_OR_CONSUME))) - { - plEvent->eFlags = 0; - } - - /*Manually unlock the mutex */ - if (SUCCESS != pthread_mutex_unlock(&(plEvent->mutex))) - { - TIMM_OSAL_Error("Event Retrieve: Mutex Unlock failed !"); - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - } - - EXIT: - return bReturnStatus; - -} diff --git a/domx/mm_osal/src/timm_osal_memory.c b/domx/mm_osal/src/timm_osal_memory.c deleted file mode 100755 index 22eb0a4..0000000 --- a/domx/mm_osal/src/timm_osal_memory.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_memory.c -* This file contains methods that provides the functionality -* for allocating/deallocating memory. -* -* @path \ -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *!23-Oct-2008 Maiya ShreeHarsha: Linux specific changes - *!0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -/****************************************************************************** -* Includes -******************************************************************************/ - -#include -#include - -#ifdef __KERNEL__ -#include -#else -#include -#endif - - -#include "timm_osal_types.h" -#include "timm_osal_trace.h" -#include "timm_osal_error.h" -#include "timm_osal_memory.h" - - - -static TIMM_OSAL_U32 gMallocCounter = 0; - -/****************************************************************************** -* Function Prototypes -******************************************************************************/ - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_createMemoryPool function -* -* @see -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_CreateMemoryPool(void) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE; - return bReturnStatus; -} - - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_DeleteMemoryPool function -* -* @see -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_DeleteMemoryPool(void) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE; - return bReturnStatus; - -} - - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_Malloc function -* -* @see -*/ -/* ========================================================================== */ -TIMM_OSAL_PTR TIMM_OSAL_Malloc(TIMM_OSAL_U32 size, - TIMM_OSAL_BOOL bBlockContiguous, - TIMM_OSAL_U32 unBlockAlignment, TIMMOSAL_MEM_SEGMENTID tMemSegId) -{ - - TIMM_OSAL_PTR pData = TIMM_OSAL_NULL; - -#ifdef HAVE_MEMALIGN - if (0 == unBlockAlignment) - { - pData = malloc((size_t) size); - } else - { - pData = memalign((size_t) unBlockAlignment, (size_t) size); - } -#else - if (0 != unBlockAlignment) - { - TIMM_OSAL_Warning - ("Memory Allocation:Not done for specified nBufferAlignment. Alignment of 0 will be used"); - - } - pData = malloc((size_t) size); /*size_t is long long */ -#endif - if (TIMM_OSAL_NULL == pData) - { - TIMM_OSAL_Error("Malloc failed!!!"); - } else - { - /* Memory Allocation was successfull */ - gMallocCounter++; - } - - - return pData; -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_Free function .... -* -* @see -*/ -/* ========================================================================== */ - -void TIMM_OSAL_Free(TIMM_OSAL_PTR pData) -{ - if (TIMM_OSAL_NULL == pData) - { - /*TIMM_OSAL_Warning("TIMM_OSAL_Free called on NULL pointer"); */ - goto EXIT; - } - - free(pData); - pData = NULL; - gMallocCounter--; - EXIT: - return; -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_Memset function .... -* -* @see -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_Memset(TIMM_OSAL_PTR pBuffer, - TIMM_OSAL_U8 uValue, TIMM_OSAL_U32 uSize) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - - memset((void *)pBuffer, (int)uValue, (size_t) uSize); - bReturnStatus = TIMM_OSAL_ERR_NONE; - - return bReturnStatus; -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_Memcmp function .... -* -* @see -*/ -/* ========================================================================== */ - -TIMM_OSAL_S32 TIMM_OSAL_Memcmp(TIMM_OSAL_PTR pBuffer1, TIMM_OSAL_PTR pBuffer2, - TIMM_OSAL_U32 uSize) -{ - TIMM_OSAL_S32 result = memcmp(pBuffer1, pBuffer2, uSize); - - if (result > 0) - { - return 1; - } else if (result < 0) - { - return -1; - } - - return 0; -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_Memcpy function .... -* -* @see -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_Memcpy(TIMM_OSAL_PTR pBufDst, - TIMM_OSAL_PTR pBufSrc, TIMM_OSAL_U32 uSize) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - - memcpy(pBufDst, pBufSrc, uSize); - bReturnStatus = TIMM_OSAL_ERR_NONE; - - return bReturnStatus; -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_GetMemCounter function .... -* -* @see -*/ -/* ========================================================================== */ - -TIMM_OSAL_U32 TIMM_OSAL_GetMemCounter(void) -{ - - return gMallocCounter; -} diff --git a/domx/mm_osal/src/timm_osal_mutex.c b/domx/mm_osal/src/timm_osal_mutex.c deleted file mode 100755 index 5cfecf8..0000000 --- a/domx/mm_osal/src/timm_osal_mutex.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_Mutexs.c -* This file contains methods that provides the functionality -* -* @path \ -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 04-Nov-2008 Maiya ShreeHarsha: Linux specific changes - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -/****************************************************************************** -* Includes -******************************************************************************/ - - -#include "timm_osal_types.h" -#include "timm_osal_trace.h" -#include "timm_osal_error.h" -#include "timm_osal_memory.h" -#include "timm_osal_semaphores.h" - -#include - -#include -#include - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_MutexCreate function -* -* -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_MutexCreate(TIMM_OSAL_PTR * pMutex) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - pthread_mutex_t *plMutex = TIMM_OSAL_NULL; - - plMutex = - (pthread_mutex_t *) TIMM_OSAL_Malloc(sizeof(pthread_mutex_t), 0, - 0, 0); - if (TIMM_OSAL_NULL == plMutex) - { - bReturnStatus = TIMM_OSAL_ERR_ALLOC; - goto EXIT; - } - - /*if (SUCCESS != pthread_mutex_init(plMutex, pAttr)) */ - if (SUCCESS != pthread_mutex_init(plMutex, TIMM_OSAL_NULL)) - { - /*TIMM_OSAL_Error ("Mutex Create failed !"); */ - /*goto EXIT; */ - } else - { - /**pMutex = (TIMM_OSAL_PTR *)plMutex;*/ - *pMutex = (TIMM_OSAL_PTR) plMutex; - bReturnStatus = TIMM_OSAL_ERR_NONE; - } - EXIT: - /*if((TIMM_OSAL_ERR_NONE != bReturnStatus)) { - TIMM_OSAL_Free(plMutex); - } */ - if ((TIMM_OSAL_ERR_NONE != bReturnStatus) && - (TIMM_OSAL_NULL != plMutex)) - { - TIMM_OSAL_Free(plMutex); - } - return bReturnStatus; - -/**********************************************************/ -/*return TIMM_OSAL_SemaphoreCreate(pMutex, 1);*/ -/**********************************************************/ -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_MutexDelete function -* -* -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_MutexDelete(TIMM_OSAL_PTR pMutex) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE; - pthread_mutex_t *plMutex = (pthread_mutex_t *) pMutex; - - if (plMutex == TIMM_OSAL_NULL) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - /*can we do away with if or with switch case */ - if (SUCCESS != pthread_mutex_destroy(plMutex)) - { - /*TIMM_OSAL_Error("Delete Mutex failed !"); */ - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN;; - } - - TIMM_OSAL_Free(plMutex); - EXIT: - return bReturnStatus; -/**********************************************************/ -/*return TIMM_OSAL_SemaphoreDelete(pMutex);*/ -/**********************************************************/ - -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_MutexObtain function -* -* -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_MutexObtain(TIMM_OSAL_PTR pMutex, - TIMM_OSAL_U32 uTimeOut) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - struct timespec abs_timeout; - struct timeval ltime_now; - TIMM_OSAL_U32 ltimenow_us; - pthread_mutex_t *plMutex = (pthread_mutex_t *) pMutex; - - if (plMutex == TIMM_OSAL_NULL) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - if (TIMM_OSAL_SUSPEND == uTimeOut) - { - if (SUCCESS != pthread_mutex_lock(plMutex)) - { - /*TIMM_OSAL_Error("Lock Mutex failed !"); */ - goto EXIT; - } - } else if (TIMM_OSAL_NO_SUSPEND == uTimeOut) - { - if (SUCCESS != pthread_mutex_trylock(plMutex)) - { - /*TIMM_OSAL_Error("Lock Mutex failed !"); */ - goto EXIT; - } - } else - { - gettimeofday(<ime_now, NULL); - /*uTimeOut is assumed to be in milliseconds */ - ltimenow_us = ltime_now.tv_usec + 1000 * uTimeOut; - abs_timeout.tv_sec = ltime_now.tv_sec + uTimeOut / 1000; - abs_timeout.tv_nsec = (ltimenow_us % 1000000) * 1000; - -#ifdef _POSIX_VERSION_1_ - if (SUCCESS != pthread_mutex_lock(plMutex)) - { //Some Posix versions dont support timeout -#else - if (SUCCESS != pthread_mutex_timedlock(plMutex, &abs_timeout)) - { -#endif - /*TIMM_OSAL_Error("Lock Mutex failed !"); */ - goto EXIT; - } - } - bReturnStatus = TIMM_OSAL_ERR_NONE; - - EXIT: - return bReturnStatus; -/**********************************************************/ -/*return TIMM_OSAL_SemaphoreObtain(pMutex, uTimeOut);*/ -/**********************************************************/ -} - - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_MutexRelease function -* -* -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_MutexRelease(TIMM_OSAL_PTR pMutex) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - pthread_mutex_t *plMutex = (pthread_mutex_t *) pMutex; - - if (TIMM_OSAL_NULL == plMutex) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - if (SUCCESS != pthread_mutex_unlock(plMutex)) - { - /*TIMM_OSAL_Error("Unlock Mutex failed !"); */ - } else - { - bReturnStatus = TIMM_OSAL_ERR_NONE; - } - EXIT: - return bReturnStatus; -/**********************************************************/ -/*return TIMM_OSAL_SemaphoreRelease(pMutex);*/ -/**********************************************************/ -} diff --git a/domx/mm_osal/src/timm_osal_pipes.c b/domx/mm_osal/src/timm_osal_pipes.c deleted file mode 100755 index 1c38354..0000000 --- a/domx/mm_osal/src/timm_osal_pipes.c +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_pipes.c -* This file contains methods that provides the functionality -* for creating/using Nucleus pipes. -* -* @path \ -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 07-Nov-2008 Maiya ShreeHarsha: Linux specific changes - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -/****************************************************************************** -* Includes -******************************************************************************/ - -#include "timm_osal_types.h" -#include "timm_osal_error.h" -#include "timm_osal_memory.h" -#include "timm_osal_trace.h" - -#include -#include -#include -#include - -/** -* TIMM_OSAL_PIPE structure define the OSAL pipe -*/ -typedef struct TIMM_OSAL_PIPE -{ - int pfd[2]; - TIMM_OSAL_U32 pipeSize; - TIMM_OSAL_U32 messageSize; - TIMM_OSAL_U8 isFixedMessage; - int messageCount; - int totalBytesInPipe; -} TIMM_OSAL_PIPE; - - -/****************************************************************************** -* Function Prototypes -******************************************************************************/ - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_CreatePipe function -* -* -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_CreatePipe(TIMM_OSAL_PTR * pPipe, - TIMM_OSAL_U32 pipeSize, - TIMM_OSAL_U32 messageSize, TIMM_OSAL_U8 isFixedMessage) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - TIMM_OSAL_PIPE *pHandle = TIMM_OSAL_NULL; - - pHandle = - (TIMM_OSAL_PIPE *) TIMM_OSAL_Malloc(sizeof(TIMM_OSAL_PIPE), 0, 0, - 0); - - if (TIMM_OSAL_NULL == pHandle) - { - bReturnStatus = TIMM_OSAL_ERR_ALLOC; - goto EXIT; - } - TIMM_OSAL_Memset(pHandle, 0x0, sizeof(TIMM_OSAL_PIPE)); - - pHandle->pfd[0] = -1; - pHandle->pfd[1] = -1; - if (SUCCESS != pipe(pHandle->pfd)) - { - TIMM_OSAL_Error("Pipe failed: %s!!!", strerror(errno)); - goto EXIT; - } - - pHandle->pipeSize = pipeSize; - pHandle->messageSize = messageSize; - pHandle->isFixedMessage = isFixedMessage; - pHandle->messageCount = 0; - pHandle->totalBytesInPipe = 0; - - *pPipe = (TIMM_OSAL_PTR) pHandle; - - bReturnStatus = TIMM_OSAL_ERR_NONE; - - - return bReturnStatus; -EXIT: - TIMM_OSAL_Free(pHandle); - return bReturnStatus; -} - - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_DeletePipe function -* -* -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_DeletePipe(TIMM_OSAL_PTR pPipe) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE; - - TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *) pPipe; - - if (TIMM_OSAL_NULL == pHandle) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - if (SUCCESS != close(pHandle->pfd[0])) - { - TIMM_OSAL_Error("Delete_Pipe Read fd failed!!!"); - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - } - if (SUCCESS != close(pHandle->pfd[1])) - { - TIMM_OSAL_Error("Delete_Pipe Write fd failed!!!"); - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - } - - TIMM_OSAL_Free(pHandle); -EXIT: - return bReturnStatus; -} - - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_WriteToPipe function -* -* -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_WriteToPipe(TIMM_OSAL_PTR pPipe, - void *pMessage, TIMM_OSAL_U32 size, TIMM_OSAL_S32 timeout) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - TIMM_OSAL_U32 lSizeWritten = -1; - - TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *) pPipe; - - if (size == 0) - { - TIMM_OSAL_Error("0 size!!!"); - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - lSizeWritten = write(pHandle->pfd[1], pMessage, size); - - if (lSizeWritten != size) - { - TIMM_OSAL_Error("Write of pipe failed!!!"); - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - /*Update message count and size */ - pHandle->messageCount++; - pHandle->totalBytesInPipe += size; - - bReturnStatus = TIMM_OSAL_ERR_NONE; - - EXIT: - return bReturnStatus; -} - - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_WriteToFrontOfPipe function -* -* -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_WriteToFrontOfPipe(TIMM_OSAL_PTR pPipe, - void *pMessage, TIMM_OSAL_U32 size, TIMM_OSAL_S32 timeout) -{ - - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - TIMM_OSAL_U32 lSizeWritten = -1; - TIMM_OSAL_U32 lSizeRead = -1; - TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *) pPipe; - TIMM_OSAL_U8 *tempPtr = NULL; - - - /*First write to this pipe */ - if (size == 0) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - lSizeWritten = write(pHandle->pfd[1], pMessage, size); - - if (lSizeWritten != size) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - /*Update number of messages */ - pHandle->messageCount++; - - - if (pHandle->messageCount > 1) - { - /*First allocate memory */ - tempPtr = - (TIMM_OSAL_U8 *) TIMM_OSAL_Malloc(pHandle-> - totalBytesInPipe, 0, 0, 0); - - if (tempPtr == NULL) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - /*Read out of pipe */ - lSizeRead = - read(pHandle->pfd[0], tempPtr, pHandle->totalBytesInPipe); - - /*Write back to pipe */ - lSizeWritten = - write(pHandle->pfd[1], tempPtr, - pHandle->totalBytesInPipe); - - if (lSizeWritten != size) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - /*Update Total bytes in pipe */ - pHandle->totalBytesInPipe += size; - } - - - EXIT: - TIMM_OSAL_Free(tempPtr); - - return bReturnStatus; - -} - - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_ReadFromPipe function -* -* -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_ReadFromPipe(TIMM_OSAL_PTR pPipe, - void *pMessage, - TIMM_OSAL_U32 size, TIMM_OSAL_U32 * actualSize, TIMM_OSAL_S32 timeout) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - TIMM_OSAL_U32 lSizeRead = -1; - TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *) pPipe; - - if (size == 0) - { - TIMM_OSAL_Error("nRead size has error!!!"); - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - if ((pHandle->messageCount == 0) && (timeout == TIMM_OSAL_NO_SUSPEND)) - { - /*If timeout is 0 and pipe is empty, return error */ - TIMM_OSAL_Error("Pipe is empty!!!"); - bReturnStatus = TIMM_OSAL_ERR_PIPE_EMPTY; - goto EXIT; - } - if ((timeout !=TIMM_OSAL_NO_SUSPEND) && - (timeout != (TIMM_OSAL_S32)TIMM_OSAL_SUSPEND)) - { - TIMM_OSAL_Warning("Only infinite or no timeouts \ - supported. Going to read with infinite timeout now"); - } - /*read blocks infinitely until message is available */ - *actualSize = lSizeRead = read(pHandle->pfd[0], pMessage, size); - if (0 == lSizeRead) - { - TIMM_OSAL_Error("EOF reached or no data in pipe!!!"); - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - bReturnStatus = TIMM_OSAL_ERR_NONE; - - pHandle->messageCount--; - pHandle->totalBytesInPipe -= size; - - EXIT: - return bReturnStatus; - -} - - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_ClearPipe function -* -* -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_ClearPipe(TIMM_OSAL_PTR pPipe) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR; - - TIMM_OSAL_Warning("This function is currently not implemented"); - - return bReturnStatus; -} - - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_IsPipeReady function -* -* -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_IsPipeReady(TIMM_OSAL_PTR pPipe) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR; - TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *) pPipe; - - if (pHandle->messageCount <= 0) - { - bReturnStatus = TIMM_OSAL_ERR_NOT_READY; - } else - { - bReturnStatus = TIMM_OSAL_ERR_NONE; - } - - return bReturnStatus; - -} - - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_GetPipeReadyMessageCount function -* -* -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_GetPipeReadyMessageCount(TIMM_OSAL_PTR pPipe, - TIMM_OSAL_U32 * count) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *) pPipe; - - *count = pHandle->messageCount; - return bReturnStatus; - -} diff --git a/domx/mm_osal/src/timm_osal_semaphores.c b/domx/mm_osal/src/timm_osal_semaphores.c deleted file mode 100755 index b69ee3c..0000000 --- a/domx/mm_osal/src/timm_osal_semaphores.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_semaphores.c -* This file contains methods that provides the functionality -* -* @path \ -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 30-Oct-2008 Maiya ShreeHarsha: Linux specific changes - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -/****************************************************************************** -* Includes -******************************************************************************/ - -#include - -#include -#include - - -#include "timm_osal_types.h" -#include "timm_osal_trace.h" -#include "timm_osal_error.h" -#include "timm_osal_memory.h" - - -#define SEMNAME_MAX 7 - -/* -typedef struct TIMM_OSAL_SEMAPHORE { - sem_t sem; - CHAR name[SEMNAME_MAX]; -} TIMM_OSAL_SEMAPHORE; -*/ - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_SemaphoreCreate function -* -* -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreCreate(TIMM_OSAL_PTR * pSemaphore, - TIMM_OSAL_U32 uInitCount) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - *pSemaphore = TIMM_OSAL_NULL; - - sem_t *psem = (sem_t *) TIMM_OSAL_Malloc(sizeof(sem_t), 0, 0, 0); - - if (TIMM_OSAL_NULL == psem) - { - bReturnStatus = TIMM_OSAL_ERR_ALLOC; - goto EXIT; - } - - /*Unnamed semaphore */ - if (SUCCESS != sem_init(psem, 0, uInitCount)) - { - /*TIMM_OSAL_Error("Semaphore Create failed !"); */ - /*goto EXIT; */ - } else - { - *pSemaphore = (TIMM_OSAL_PTR) psem; - bReturnStatus = TIMM_OSAL_ERR_NONE; - } - EXIT: - if ((TIMM_OSAL_ERR_NONE != bReturnStatus) && (TIMM_OSAL_NULL != psem)) - { - TIMM_OSAL_Free(psem); - } - return bReturnStatus; -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_SemaphoreDelete function -* -* -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreDelete(TIMM_OSAL_PTR pSemaphore) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE; - sem_t *psem = (sem_t *) pSemaphore; - - if (psem == TIMM_OSAL_NULL) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - /* Release the semaphore. */ - if (SUCCESS != sem_destroy(psem)) - { - /*TIMM_OSAL_Error("Semaphore Delete failed !"); */ - bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - } - - TIMM_OSAL_Free(psem); - EXIT: - return bReturnStatus; -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_SemaphoreObtain function -* -* -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreObtain(TIMM_OSAL_PTR pSemaphore, - TIMM_OSAL_U32 uTimeOut) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - struct timeval ltime_now; - struct timespec abs_timeout; - sem_t *psem = (sem_t *) pSemaphore; - - if (psem == TIMM_OSAL_NULL) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - if (TIMM_OSAL_SUSPEND == uTimeOut) - { - if (SUCCESS != sem_wait(psem)) - { - /*TIMM_OSAL_Error("Semaphore Wait failed !"); */ - goto EXIT; - } - - } else if (TIMM_OSAL_NO_SUSPEND == uTimeOut) - { - if (SUCCESS != sem_trywait(psem)) - { - /*TIMM_OSAL_Error("Semaphore blocked !"); */ - goto EXIT; - } - } else - { - /*Some delay in calling gettimeofday and sem_timedwait - cant - be avoided. Possibility of thread switch after gettimeofday - in which case time out will be less than expected */ - gettimeofday(<ime_now, NULL); - /*uTimeOut is assumed to be in milliseconds */ - abs_timeout.tv_sec = ltime_now.tv_sec + (uTimeOut / 1000); - abs_timeout.tv_nsec = - 1000 * (ltime_now.tv_usec + ((uTimeOut % 1000) * 1000)); - - if (SUCCESS != sem_timedwait(psem, &abs_timeout)) - { - /*TIMM_OSAL_Error("Semaphore Timed Wait failed !"); */ - goto EXIT; - } - } - bReturnStatus = TIMM_OSAL_ERR_NONE; - - EXIT: - return bReturnStatus; -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_SemaphoreRelease function -* -* -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreRelease(TIMM_OSAL_PTR pSemaphore) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - sem_t *psem = (sem_t *) pSemaphore; - - if (TIMM_OSAL_NULL == psem) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - /* Release the semaphore. */ - if (SUCCESS != sem_post(psem)) - { - /*TIMM_OSAL_Error("Release failed !"); */ - } else - { - bReturnStatus = TIMM_OSAL_ERR_NONE; - } - - EXIT: - return bReturnStatus; -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_SemaphoreReset function -* -* -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreReset(TIMM_OSAL_PTR pSemaphore, - TIMM_OSAL_U32 uInitCount) -{ - /* TIMM_OSAL_SEMAPHORE *pHandle = (TIMM_OSAL_SEMAPHORE *)pSemaphore; - STATUS status; - TIMM_OSAL_ERRORTYPE bReturnStatus; */ - - - /* Release the semaphore. */ - /*status = NU_Reset_Semaphore(&(pHandle->sem), - uInitCount); - */ - /* switch(status) - { - case NU_SUCCESS: - bReturnStatus = TIMM_OSAL_ERR_NONE; - break; - default: - bReturnStatus = TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR, TIMM_OSAL_COMP_SEMAPHORES, status); - break; - } - */ - /* return bReturnStatus; */ - return TIMM_OSAL_ERR_UNKNOWN; -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_GetSemaphoreCount function -* -* -*/ -/* ========================================================================== */ -TIMM_OSAL_ERRORTYPE TIMM_OSAL_GetSemaphoreCount(TIMM_OSAL_PTR pSemaphore, - TIMM_OSAL_U32 * count) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - int sval = -2; /*value that is not possible */ - sem_t *psem = (sem_t *) pSemaphore; - - if (TIMM_OSAL_NULL == psem) - { - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - - /* Release the semaphore. */ - if (SUCCESS != sem_getvalue(psem, &sval)) - { - /*TIMM_OSAL_Error("Get Semaphore Count failed !"); */ - } else - { - *count = sval; - bReturnStatus = TIMM_OSAL_ERR_NONE; - } - - EXIT: - return bReturnStatus; -} diff --git a/domx/mm_osal/src/timm_osal_task.c b/domx/mm_osal/src/timm_osal_task.c deleted file mode 100755 index 7a243a9..0000000 --- a/domx/mm_osal/src/timm_osal_task.c +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_task.c -* This file contains methods that provides the functionality -* for creating/destroying tasks. -* -* @path \ -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! 21-Oct-2008 Maiya ShreeHarsha: Linux specific changes - *! 0.1: Created the first draft version, ksrini@ti.com - * ========================================================================= */ - -/****************************************************************************** -* Includes -******************************************************************************/ - -#include -#include /*for POSIX calls */ -#include /*for sched structure */ -#include - - - -#include "timm_osal_types.h" -#include "timm_osal_trace.h" -#include "timm_osal_error.h" -#include "timm_osal_memory.h" -#include "timm_osal_task.h" - - - - -/** -* TIMM_OSAL_TASK describe the different task information -*/ -typedef struct TIMM_OSAL_TASK -{ - pthread_t threadID; /*SHM check */ - /* To set the priority and stack size */ - pthread_attr_t ThreadAttr; /*For setting the priority and stack size */ - /** Name of the task */ - /* TIMM_OSAL_S8 name[8];*//* eight character plus null char */ - /** Pointer to the task stack memory */ -/* TIMM_OSAL_PTR stackPtr;*/ - /** Size of the task stack */ -/* TIMM_OSAL_S32 stackSize;*/ - /*parameters to the task */ - TIMM_OSAL_U32 uArgc; - TIMM_OSAL_PTR pArgv; - /** task priority */ -/* TIMM_OSAL_S32 priority;*/ - /** flag to check if task got created */ - TIMM_OSAL_BOOL isCreated; -} TIMM_OSAL_TASK; - - -/****************************************************************************** -* Function Prototypes -******************************************************************************/ - - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_CreateTask function -* -* @see -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_CreateTask(TIMM_OSAL_PTR * pTask, - TIMM_OSAL_TaskProc pFunc, - TIMM_OSAL_U32 uArgc, - TIMM_OSAL_PTR pArgv, - TIMM_OSAL_U32 uStackSize, TIMM_OSAL_U32 uPriority, TIMM_OSAL_S8 * pName) -{ - - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - TIMM_OSAL_TASK *pHandle = TIMM_OSAL_NULL; - struct sched_param sched; - size_t stackSize; - *pTask = TIMM_OSAL_NULL; - - - /*Task structure allocation */ - pHandle = - (TIMM_OSAL_TASK *) TIMM_OSAL_Malloc(sizeof(TIMM_OSAL_TASK), 0, 0, - 0); - if (pHandle == TIMM_OSAL_NULL) - { - bReturnStatus = TIMM_OSAL_ERR_ALLOC; - goto EXIT; - } - - /* Initial cleaning of the task structure */ - TIMM_OSAL_Memset((TIMM_OSAL_PTR) pHandle, 0, sizeof(TIMM_OSAL_TASK)); - - /*Arguments for task */ - pHandle->uArgc = uArgc; - pHandle->pArgv = pArgv; - - pHandle->isCreated = TIMM_OSAL_FALSE; - - - if (SUCCESS != pthread_attr_init(&pHandle->ThreadAttr)) - { - /*TIMM_OSAL_Error("Task Init Attr Init failed!"); */ - goto EXIT; - } - /* Updation of the priority and the stack size */ - - if (SUCCESS != pthread_attr_getschedparam(&pHandle->ThreadAttr, - &sched)) - { - /*TIMM_OSAL_Error("Task Init Get Sched Params failed!"); */ - goto EXIT; - } - - sched.sched_priority = uPriority; /* relative to the default priority */ - if (SUCCESS != pthread_attr_setschedparam(&pHandle->ThreadAttr, - &sched)) - { - /*TIMM_OSAL_Error("Task Init Set Sched Paramsfailed!"); */ - goto EXIT; - } - - /*First get the default stack size */ - if (SUCCESS != pthread_attr_getstacksize(&pHandle->ThreadAttr, - &stackSize)) - { - /*TIMM_OSAL_Error("Task Init Set Stack Size failed!"); */ - goto EXIT; - } - - /*Check if requested stack size is larger than the current default stack size */ - if (uStackSize > stackSize) - { - stackSize = uStackSize; - if (SUCCESS != pthread_attr_setstacksize(&pHandle->ThreadAttr, - stackSize)) - { - /*TIMM_OSAL_Error("Task Init Set Stack Size failed!"); */ - goto EXIT; - } - } - - - - if (SUCCESS != pthread_create(&pHandle->threadID, - &pHandle->ThreadAttr, pFunc, pArgv)) - { - /*TIMM_OSAL_Error ("Create_Task failed !"); */ - goto EXIT; - } - - - /* Task was successfully created */ - pHandle->isCreated = TIMM_OSAL_TRUE; - *pTask = (TIMM_OSAL_PTR) pHandle; - bReturnStatus = TIMM_OSAL_ERR_NONE; - /**pTask = (TIMM_OSAL_PTR *)pHandle;*/ - - EXIT: -/* if((TIMM_OSAL_ERR_NONE != bReturnStatus) && (TIMM_OSAL_NULL != pHandle)) { - TIMM_OSAL_Free (pHandle->stackPtr);*/ - if ((TIMM_OSAL_ERR_NONE != bReturnStatus)) - { - TIMM_OSAL_Free(pHandle); - } - return bReturnStatus; - -} - -/* ========================================================================== */ -/** -* @fn TIMM_OSAL_DeleteTask -* -* @see -*/ -/* ========================================================================== */ - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_DeleteTask(TIMM_OSAL_PTR pTask) -{ - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN; - - TIMM_OSAL_TASK *pHandle = (TIMM_OSAL_TASK *) pTask; - void *retVal; - - if ((NULL == pHandle) || (TIMM_OSAL_TRUE != pHandle->isCreated)) - { - /* this task was never created */ - bReturnStatus = TIMM_OSAL_ERR_PARAMETER; - goto EXIT; - } - if (pthread_attr_destroy(&pHandle->ThreadAttr)) - { - /*TIMM_OSAL_Error("Delete_Task failed !"); */ - goto EXIT; - } - if (pthread_join(pHandle->threadID, &retVal)) - { - /*TIMM_OSAL_Error("Delete_Task failed !"); */ - goto EXIT; - /* bReturnStatus = TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR, TIMM_OSAL_COMP_TASK, status);*//*shm to be done */ - } - bReturnStatus = TIMM_OSAL_ERR_NONE; - TIMM_OSAL_Free(pHandle); - EXIT: - return bReturnStatus; -} - - -TIMM_OSAL_ERRORTYPE TIMM_OSAL_SleepTask(TIMM_OSAL_U32 mSec) -{ - TIMM_OSAL_S32 nReturn = 0; - -#ifdef _POSIX_VERSION_1_ - usleep(1000 * mSec); -#else - nReturn = usleep(1000 * mSec); -#endif - if (nReturn == 0) - return TIMM_OSAL_ERR_NONE; - else - return TIMM_OSAL_ERR_UNKNOWN; -} diff --git a/domx/mm_osal/src/timm_osal_trace.c b/domx/mm_osal/src/timm_osal_trace.c deleted file mode 100755 index 498054f..0000000 --- a/domx/mm_osal/src/timm_osal_trace.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -* @file timm_osal_trace.c -* This file contains methods that provides the functionality -* for logging errors/warings/information/etc. -* -* @path \ -* -*/ -/* -------------------------------------------------------------------------- */ -/* ========================================================================= - *! - *! Revision History - *! =================================== - *! - * ========================================================================= */ - -/****************************************************************************** -* Includes -******************************************************************************/ - -/*#include "typedefs.h"*/ -#include -#include -#include -#include "timm_osal_trace.h" - -#ifdef _Android -#define LOG_TAG "DOMX" -#include -#include -#endif - -/** -* The OSAL debug trace detail can be set at compile time by defining the flag -* TIMM_OSAL_DEBUG_TRACE_DETAIL=
-* detail - 0 - no detail -* 1 - function name -* 2 - function name, line number -* Prefix is added to every debug trace message -*/ -#ifndef TIMM_OSAL_DEBUG_TRACE_DETAIL -#define TIMM_OSAL_DEBUG_TRACE_DETAIL 2 -#endif - -#define DEFAULT_TRACE_LEVEL TIMM_OSAL_TRACE_LEVEL_ERROR - -static int trace_level = -1; - -/* strip out leading ../ stuff that happens to __FILE__ for out-of-tree builds */ -static const char *simplify_path(const char *file) -{ - while (file) - { - char c = file[0]; - if ((c != '.') && (c != '/') && (c != '\\')) - break; - file++; - } - return file; -} - -void TIMM_OSAL_UpdateTraceLevel(void) -{ - char *val = getenv("TIMM_OSAL_DEBUG_TRACE_LEVEL"); - - if (val) - { - trace_level = strtol(val, NULL, 0); - } - else - { -#ifdef _Android - char value[PROPERTY_VALUE_MAX]; - int val; - - property_get("debug.domx.trace_level", value, "0"); - val = atoi(value); - if ( (!val) || (val < 0) ) - { - trace_level = DEFAULT_TRACE_LEVEL; - } - else - trace_level = val; -#else - trace_level = DEFAULT_TRACE_LEVEL; -#endif - } -} - -void __TIMM_OSAL_TraceFunction(const __TIMM_OSAL_TRACE_LOCATION * loc, - const char *fmt, ...) -{ - if (trace_level == -1) - { - char *val = getenv("TIMM_OSAL_DEBUG_TRACE_LEVEL"); - trace_level = - val ? strtol(val, NULL, 0) : DEFAULT_TRACE_LEVEL; - } - - if (trace_level >= loc->level) - { - va_list ap; - - va_start(ap, fmt); /* make ap point to first arg after 'fmt' */ - -#ifdef _Android - -#if 0 // Original for reference -#if ( TIMM_OSAL_DEBUG_TRACE_DETAIL > 1 ) - ALOGD("%s:%d\t%s()\t", simplify_path(loc->file), loc->line, - loc->function); -#endif -#else // Prints function_name for ERROR, WARNING and ENTRY/EXIT - if ( (loc->level == TIMM_OSAL_TRACE_LEVEL_ERROR) || (loc->level == TIMM_OSAL_TRACE_LEVEL_WARNING) || (loc->level == TIMM_OSAL_TRACE_LEVEL_ENTERING) ) - ALOGD("%s:%d\t%s()\t", simplify_path(loc->file), loc->line, - loc->function); -#endif - - char string[1000]; - vsprintf(string, fmt, ap); - ALOGD("%s",string); - -#else - -#if 0 // Original for reference -#if ( TIMM_OSAL_DEBUG_TRACE_DETAIL > 1 ) - printf("%s:%d\t%s()\t", simplify_path(loc->file), loc->line, - loc->function); -#endif -#else // Prints function_name for ERROR, WARNING and ENTRY/EXIT - if ( (loc->level == 1) || (loc->level == 2) || (loc->level == 5) ) - printf("%s:%d\t%s()\t", simplify_path(loc->file), loc->line, - loc->function); -#endif - - vprintf(fmt, ap); - -#endif - - va_end(ap); - } -} diff --git a/domx/omx_core/Android.mk b/domx/omx_core/Android.mk deleted file mode 100644 index d52947a..0000000 --- a/domx/omx_core/Android.mk +++ /dev/null @@ -1,24 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - src/OMX_Core.c \ - src/OMX_Core_Wrapper.c - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/inc \ - $(LOCAL_PATH)/../mm_osal/inc \ - frameworks/native/include/media/openmax - -LOCAL_SHARED_LIBRARIES := \ - libdl \ - liblog \ - libmm_osal - -LOCAL_CFLAGS += -DSTATIC_TABLE -D_Android -DCHECK_SECURE_STATE - -LOCAL_MODULE := libOMX_Core -LOCAL_MODULE_TAGS := optional - -include $(BUILD_SHARED_LIBRARY) diff --git a/domx/omx_core/Makefile b/domx/omx_core/Makefile deleted file mode 100644 index 5c6c563..0000000 --- a/domx/omx_core/Makefile +++ /dev/null @@ -1,99 +0,0 @@ -# -# Copyright (C) Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ---------------------------------------------------------------------------- -# Revision History -# -# -# REF=ORG -# Original version. -# ---------------------------------------------------------------------------- - -#PROJROOT = .. - -include $(PROJROOT)/make/start.mk - -# Do not change above "include" line(s) - -# Arguments to tools, will move to make system once finalized. - -CFLAGS += -DSTATIC_TABLE -CDEFS = -ifeq ($(BUILD),udeb) -CDEFS += DEBUG -endif -CDEFS += - -EXEC_ARGS = -ST_LIB_ARGS = -SH_LIB_ARGS = - -# Define this macro if target runs in kernel mode -#__KERNEL__ = 1 - -# Target name and extension -# static library (ST_LIB): filename.a -# shared library soname (SH_LIB): filename.so.maj_ver.min_ver -# executable (EXEC) : filename.out - -TARGETNAME = libomx_core - - -# TARGETTYPE must be EXEC, ST_LIB or SH_LIB in upper case. - -TARGETTYPE = SH_LIB - -# install directory relative to the HOSTTARGET directory -HOSTRELEASE = lib - -# install directory relative to the root filesystem -ROOTFSRELEASE = lib - -# Folders in which gmake will run before building current target - -SUBMODULES = \ - -# Filename must not begin with '.', '/' or '\' - -SOURCES = \ - src/OMX_Core.c \ - - -# Search path for include files - -INCLUDES = \ - $(PROJROOT)/omx_core/inc \ - $(PROJROOT)/mm_osal/inc \ - -# Libraries needed for linking. - -ST_LIBS = -#mm_osal omx_proxy_component -SH_LIBS = mm_osal dl -#pthread rt utils procmgr ipc rcm notify -#SH_LIBS += sysmgr sysmemmgr - - -# Search path for library (and linker command) files. -# Current folder and target folder are included by default. - -LIBINCLUDES = $(PROJROOT)/mm_osal -# $(PROJROOT)/video/omx_proxy_component/src - - -# Do not change below "include" line(s) - -include $(PROJROOT)/make/build.mk - diff --git a/domx/omx_core/inc/OMX_ComponentExt.h b/domx/omx_core/inc/OMX_ComponentExt.h deleted file mode 100755 index e32dcbe..0000000 --- a/domx/omx_core/inc/OMX_ComponentExt.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2010 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ - -/** OMX_ComponentExt.h - OpenMax IL version 1.1.2 - * The OMX_ComponentExt header file contains extensions to the definitions used - * by both the application and the component to access common items. - */ - -#ifndef OMX_ComponentExt_h -#define OMX_ComponentExt_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Each OMX header must include all required header files to allow the - * header to compile without errors. The includes below are required - * for this header file to compile successfully - */ -#include - - -/** Set/query the commit mode */ -typedef struct OMX_CONFIG_COMMITMODETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bDeferred; -} OMX_CONFIG_COMMITMODETYPE; - -/** Explicit commit */ -typedef struct OMX_CONFIG_COMMITTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; -} OMX_CONFIG_COMMITTYPE; - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* OMX_ComponentExt_h */ diff --git a/domx/omx_core/inc/OMX_ComponentRegistry.h b/domx/omx_core/inc/OMX_ComponentRegistry.h deleted file mode 100755 index 7bedcfc..0000000 --- a/domx/omx_core/inc/OMX_ComponentRegistry.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#define MAX_ROLES 20 -#define MAX_TABLE_SIZE 50 - -typedef struct _ComponentTable { - OMX_STRING name; - OMX_U16 nRoles; - OMX_STRING pRoleArray[MAX_ROLES]; -}ComponentTable; - - -OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent ( - OMX_IN OMX_STRING compName, - OMX_INOUT OMX_U32 *pNumRoles, - OMX_OUT OMX_U8 **roles); - -OMX_ERRORTYPE OMX_PrintComponentTable(); -OMX_ERRORTYPE OMX_BuildComponentTable(); -OMX_ERRORTYPE ComponentTable_EventHandler( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData); - -OMX_ERRORTYPE ComponentTable_EmptyBufferDone( - OMX_OUT OMX_HANDLETYPE hComponent, - OMX_OUT OMX_PTR pAppData, - OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer); - -OMX_ERRORTYPE ComponentTable_FillBufferDone( - OMX_OUT OMX_HANDLETYPE hComponent, - OMX_OUT OMX_PTR pAppData, - OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer); diff --git a/domx/omx_core/inc/OMX_CoreExt.h b/domx/omx_core/inc/OMX_CoreExt.h deleted file mode 100755 index 5974d02..0000000 --- a/domx/omx_core/inc/OMX_CoreExt.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2010 The Khronos Group Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - */ - -/** OMX_CoreExt.h - OpenMax IL version 1.1.2 - * The OMX_CoreExt header file contains extensions to the definitions used - * by both the application and the component to access common items. - */ - -#ifndef OMX_CoreExt_h -#define OMX_CoreExt_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Each OMX header shall include all required header files to allow the - * header to compile without errors. The includes below are required - * for this header file to compile successfully - */ -#include - -/** Extensions to the standard IL errors. */ -typedef enum OMX_ERROREXTTYPE -{ - OMX_ErrorInvalidMode = (OMX_S32) (OMX_ErrorKhronosExtensions + 0x00000001), - OMX_ErrorExtMax = 0x7FFFFFFF -} OMX_ERROREXTTYPE; - - -/** Event type extensions. */ -typedef enum OMX_EVENTEXTTYPE -{ - OMX_EventIndexSettingChanged = OMX_EventKhronosExtensions, /**< component signals the IL client of a change - in a param, config, or extension */ - OMX_EventExtMax = 0x7FFFFFFF -} OMX_EVENTEXTTYPE; - - -/** Enable or disable a callback event. */ -typedef struct OMX_CONFIG_CALLBACKREQUESTTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_INDEXTYPE nIndex; /**< the index the callback is requested for */ - OMX_BOOL bEnable; /**< enable (OMX_TRUE) or disable (OMX_FALSE) the callback */ -} OMX_CONFIG_CALLBACKREQUESTTYPE; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* OMX_CoreExt_h */ -/* File EOF */ diff --git a/domx/omx_core/inc/OMX_Core_Wrapper.h b/domx/omx_core/inc/OMX_Core_Wrapper.h deleted file mode 100755 index 567a357..0000000 --- a/domx/omx_core/inc/OMX_Core_Wrapper.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** OMX_Core.h - * The OMX_Core header file contains the definitions used for PV core - */ - -#ifndef OMX_TI_Core_h -#define OMX_TI_Core_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -/* Each OMX header shall include all required header files to allow the - * header to compile without errors. The includes below are required - * for this header file to compile successfully - */ - -#include -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_Init(void); -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_Deinit(void); -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_ComponentNameEnum( - OMX_OUT OMX_STRING cComponentName, - OMX_IN OMX_U32 nNameLength, - OMX_IN OMX_U32 nIndex); -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_GetHandle( - OMX_OUT OMX_HANDLETYPE* pHandle, - OMX_IN OMX_STRING cComponentName, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_CALLBACKTYPE* pCallBacks); -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_FreeHandle( - OMX_IN OMX_HANDLETYPE hComponent); -OMX_API OMX_ERRORTYPE TIOMX_GetComponentsOfRole ( - OMX_IN OMX_STRING role, - OMX_INOUT OMX_U32 *pNumComps, - OMX_INOUT OMX_U8 **compNames); -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_SetupTunnel( - OMX_IN OMX_HANDLETYPE hOutput, - OMX_IN OMX_U32 nPortOutput, - OMX_IN OMX_HANDLETYPE hInput, - OMX_IN OMX_U32 nPortInput); -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_GetContentPipe( - OMX_OUT OMX_HANDLETYPE *hPipe, - OMX_IN OMX_STRING szURI); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ - diff --git a/domx/omx_core/inc/OMX_Debug.h b/domx/omx_core/inc/OMX_Debug.h deleted file mode 100755 index 0ccc351..0000000 --- a/domx/omx_core/inc/OMX_Debug.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef OMX_DEBUG_H -#define OMX_DEBUG_H - -#include "OMX_DebugMem.h" - -#define OMX_NO_MESSAGES 0x00000000 -#define OMX_ALL_MESSAGES 0xffff0000 - -#define OMX_MASK_FATAL 0x80000000 -#define OMX_MASK_ERROR 0x40000000 -#define OMX_MASK_WARN 0x20000000 -#define OMX_MASK_INFO 0x10000000 -#define OMX_MASK_DEBUG 0x08000000 -#define OMX_MASK_TRACE 0x04000000 -#define OMX_MASK_RESERVE1 0x02000000 -#define OMX_MASK_RESERVE2 0x01000000 - -#define OMX_MASK_USERMASK 0x00FF0000 - -#define OMX_OPTION_FILE 0x00000001 -#define OMX_OPTION_FUNC 0x00000002 -#define OMX_OPTION_LINE 0x00000004 - -#define OMX_MASK_HANDLES 0x0000FFFF - - - -/* - * ANSI escape sequences for outputing text in various colors - */ -#define DBG_TEXT_WHITE "\x1b[1;37;40m" -#define DBG_TEXT_YELLOW "\x1b[1;33;40m" -#define DBG_TEXT_MAGENTA "\x1b[1;35;40m" -#define DBG_TEXT_GREEN "\x1b[1;32;40m" -#define DBG_TEXT_CYAN "\x1b[1;36;40m" -#define DBG_TEXT_RED "\x1b[1;31;40m" - - -/* Setup log format (adds newline if no newline provided) */ -// do not use this one directly.... -#define OMX_LOG_PRINT(HANDLE, STR, ARG...) \ - (OMX_Log(HANDLE, __FILE__, __LINE__, __FUNCTION__, STR, ##ARG)) - -#ifdef OMX_DEBUG - #define OMX_DPRINT(HANDLE, STR, ARG...) OMX_LOG_PRINT(OMX_MASK_DEBUG | HANDLE, STR, ##ARG) - #define OMX_TPRINT(HANDLE, STR, ARG...) OMX_LOG_PRINT(OMX_MASK_TRACE | HANDLE, STR, ##ARG) -#else - #define OMX_DPRINT(HANDLE, STR, ARG...) - #define OMX_TPRINT(HANDLE, STR, ARG...) -#endif - -/* Later this will be able to be turned on/off separately as a trace */ -#define OMX_DENTER(handle) OMX_TPRINT((handle), "+++ENTERING") -#define OMX_DEXIT(handle,retVal) OMX_TPRINT((handle), "---EXITING(0x%x)", (retVal)) - -#define OMX_DBG_INT(handle, intVar) OMX_DPRINT(OMX_MASK_DEBUG | (handle), #intVar ": %d", (intVar)) -#define OMX_DBG_PTR(handle, ptrVar) OMX_DPRINT(OMX_MASK_DEBUG | (handle), #ptrVar ": 0x%08x", (ptrVar)) -#define OMX_DBG_STR(handle, strVar) OMX_DPRINT(OMX_MASK_DEBUG | (handle), #strVar ": %s", (strVar)) - - -/* Error/warning printing defines to be used by all sub-components */ -#define OMX_INFOPRINT(handle, str,arg...) (OMX_LOG_PRINT(OMX_MASK_INFO | (handle), "(INFO) "str, ##arg)) -#define OMX_WARNPRINT(handle, str,arg...) (OMX_LOG_PRINT(OMX_MASK_WARN | (handle), "(WARN) "str, ##arg)) -#define OMX_ERRPRINT(handle, str,arg...) (OMX_LOG_PRINT(OMX_MASK_ERROR | (handle), "(ERROR) "str, ##arg)) -#define OMX_FATALPRINT(handle, str,arg...) (OMX_LOG_PRINT(OMX_MASK_FATAL | (handle), "(FATAL) "str, ##arg)) - -/* assert macros */ -#ifdef OMX_DEBUG - #define OMX_ASSERT(COND) ((!(COND))?OMX_FATALPRINT(0,"OMX_ASSERT("#COND")"),abort():0) -#else - #define OMX_ASSERT(COND) -#endif - -#define OMX_LOG_ADD_MASK(HANDLE,NEW_BITS) (OMX_Log_SetMask((HANDLE), OMX_Log_GetMask(HANDLE) | (NEW_BITS))) -#define OMX_LOG_CLEAR_MASK(HANDLE,NEW_BITS) (OMX_Log_SetMask((HANDLE), OMX_Log_GetMask(HANDLE) & ~(NEW_BITS))) - -#define OMX_LOG_ADD_OPTIONS(HANDLE,NEW_BITS) (OMX_Log_SetOptions((HANDLE), OMX_Log_GetOptions(HANDLE) | (NEW_BITS))) -#define OMX_LOG_CLEAR_OPTIONS(HANDLE,NEW_BITS) (OMX_Log_SetOptions((HANDLE), OMX_Log_GetOptions(HANDLE) & ~(NEW_BITS))) - -typedef unsigned int OMX_DBG_HANDLE; - -OMX_DBG_HANDLE OMX_Log_GetDebugHandle(const char *description); -void OMX_Log_ReleaseDebugHandle(OMX_DBG_HANDLE hDebug); -unsigned int OMX_Log_GetMask(OMX_DBG_HANDLE hDebug); -unsigned int OMX_Log_SetMask(OMX_DBG_HANDLE hDebug, unsigned int uiNewMask); - -unsigned int OMX_Log_GetOptions(OMX_DBG_HANDLE hDebug); -unsigned int OMX_Log_SetOptions(OMX_DBG_HANDLE hDebug, unsigned int uiNewOptions); - -void OMX_Log(unsigned int mask, const char *szFileName, int iLineNum, - const char *szFunctionName, const char *strFormat, ...); - -const char *OMX_GetErrorString(OMX_ERRORTYPE error); - -OMX_ERRORTYPE OMX_Log_LoadConfigFile(char* szConfigFile); - - -/* - * The following macros are intended to make accessing a debug handle easier. - * - * For example, for the Util library, you would create a header file called - * OMX_Util_Private.h. This file will be included in all source files - * compiled into the Util library. The header file uses the 'define' macro - * to generate a prototype for the getDebugHandle() function: - * - * DEFINE_DEBUG_HANDLE_FN(UTIL); - * - * Now, in your private header file, define easier macros for printing: - * - * #define UTIL_DPRINT(str,args...) OMX_DPRINT(ACCESS_DEBUG_HANDLE(UTIL),str,##args) - * #define UTIL_WARNPRINT(str,args...) OMX_WARNPRINT(ACCESS_DEBUG_HANDLE(UTIL),str,##args) - * #define UTIL_ERRPRINT(str,args...) OMX_ERRPRINT(ACCESS_DEBUG_HANDLE(UTIL),str,##args) - * - * Finally, in a source file which will be compiled into the lib, for example - * OMX_Util_Private.c, you implement the function with the 'implement' macro: - * - * IMPLEMENT_DEBUG_HANDLE_FN(UTIL) - * - */ -#define DEFINE_DEBUG_HANDLE_FN(MOD) OMX_DBG_HANDLE getDebugHandle_##MOD(void); - -#define ACCESS_DEBUG_HANDLE(MOD) getDebugHandle_##MOD() - -#define IMPLMENT_DEBUG_HANDLE_FN(MOD) \ -OMX_DBG_HANDLE getDebugHandle_##MOD(void) \ -{ \ - static OMX_DBG_HANDLE hDebug = 0; \ - if(!hDebug) { \ - hDebug = OMX_Log_GetDebugHandle(#MOD); \ - OMX_DPRINT(0,"Component "#MOD": hDebug %d",hDebug); \ - } \ - return hDebug; \ -} - - - -#endif - diff --git a/domx/omx_core/inc/OMX_DebugMem.h b/domx/omx_core/inc/OMX_DebugMem.h deleted file mode 100755 index f45cfe0..0000000 --- a/domx/omx_core/inc/OMX_DebugMem.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef OMX_DEBUGMEM_H -#define OMX_DEBUGMEM_H - -#include // for size_t - -#if OMX_DEBUG -void* OMX_DebugMem_calloc(size_t num, size_t size, - const char* file, const char* func, int line); -void* OMX_DebugMem_malloc(size_t size, - const char* file, const char* func, int line); -void* OMX_DebugMem_realloc(void *ptr, size_t size, - const char* file, const char* func, int line); -void OMX_DebugMem_free(void* ptr, - const char* file, const char* func, int line); -int OMX_DebugMem_validate(void *ptr, - const char* file, const char* func, int line); - -void OMX_DebugMem_dump(const char *file, const char *func, int line); -#endif - -#define OMX_MASK_MEMORY 0x00010000 /** One of the reserved bits from OMX_MASK_USERMASK */ - -#define MEM_DEBUG_HANDLE_DESCR "DebugMemory" - -#if OMX_DEBUG - #define malloc(x) OMX_DebugMem_malloc(x,__FILE__,__FUNCTION__,__LINE__) - #define calloc(n,s) OMX_DebugMem_calloc(n,s,__FILE__,__FUNCTION__,__LINE__) - #define realloc(x,s) OMX_DebugMem_realloc(x,s,__FILE__,__FUNCTION__,__LINE__) - #define free(x) OMX_DebugMem_free(x,__FILE__,__FUNCTION__ ,__LINE__) - #define validate(x) OMX_DebugMem_validate(x, __FILE__,__FUNCTION__ ,__LINE__) - #define dump() OMX_DebugMem_dump( __FILE__,__FUNCTION__ ,__LINE__) -#else - #define validate(x) - #define dump() -#endif - - -#endif - diff --git a/domx/omx_core/inc/OMX_TI_Common.h b/domx/omx_core/inc/OMX_TI_Common.h deleted file mode 100755 index 457adb6..0000000 --- a/domx/omx_core/inc/OMX_TI_Common.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_ti_common.h - * - * - * @path \OMAPSW_SysDev\multimedia\omx\khronos1_1\omx_core\inc - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 20-Dec-2008 x0052661@ti.com, initial version - *================================================================*/ - -#ifndef _OMX_TI_COMMON_H_ -#define _OMX_TI_COMMON_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -#include - -/******************************************************************* - * EXTERNAL REFERENCE NOTE: only use if not found in header file - *******************************************************************/ -/*---------- function prototypes ------------------- */ -/*---------- data declarations ------------------- */ -/******************************************************************* - * PUBLIC DECLARATIONS: defined here, used elsewhere - *******************************************************************/ -/*---------- function prototypes ------------------- */ -/*---------- data declarations ------------------- */ -#define OMX_BUFFERHEADERFLAG_MODIFIED 0x00000100 - -#define OMX_TI_BUFFERFLAG_READONLY 0x00000200 - -/* TI extra data will be passed in the platform private structure rather than - * appended at the end of the buffer. Adding a new custom flag to indicate - * this.*/ -#define OMX_TI_BUFFERFLAG_DETACHEDEXTRADATA 0x00000400 - -typedef struct OMX_CONFIG_CHANNELNAME { - - OMX_U32 nSize; /**< Size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Index of the port */ - OMX_STRING cChannelName; /**< Channel name */ - -} OMX_CONFIG_CHANNELNAME; - -typedef struct OMX_TI_PLATFORMPRIVATE -{ - OMX_U32 nSize; - OMX_PTR pExtendedPlatformPrivate; - OMX_BOOL bReadViaCPU; - OMX_BOOL bWriteViaCPU; - OMX_PTR pMetaDataBuffer; - OMX_U32 nMetaDataSize; - OMX_PTR pAuxBuf1; - OMX_U32 pAuxBufSize1; -}OMX_TI_PLATFORMPRIVATE; - -/*===============================================================*/ -/** OMX_TI_PARAM_BUFFERPREANNOUNCE : This parameter is used to enable/disable - * buffer pre announcement. Buffer pre - * announcement is enabled by default i.e. - * if buffer is being allocated by client - * then the buffer ptrs will be made known - * to the component at the time of - * UseBuffer and these will not change in - * lifetime of the component. If pre - * announcement is disabled then new - * buffers can be allocated by the client - * at runtime and passed in ETB/FTB. This - * parameter is valid only in cases where - * client allocates the buffer - * (i.e. UseBuffer cases). - * - * @ param nSize : Size of the structure. - * @ param nVersion : Version. - * @ param nPortIndex : Port index on which the parameter will - * be applied. - * @ param bEnabled : Whether buffer pre announcement is - * enabled or not. Set to TRUE (enabled) - * by default. - */ -/*===============================================================*/ -typedef struct OMX_TI_PARAM_BUFFERPREANNOUNCE -{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnabled; -}OMX_TI_PARAM_BUFFERPREANNOUNCE; - - - -/*===============================================================*/ -/** OMX_TI_CONFIG_BUFFERREFCOUNTNOTIFYTYPE : This config is used to - * enable/disable notification when - * reference count of a buffer changes - * This happens usually when buffers - * are locked/unlocked by codecs. By - * DEFAULT all notifications are - * DISABLED. - * - * @ param nSize : Size of the structure. - * @ param nVersion : Version. - * @ param nPortIndex : Port index on which the config will - * be applied. - * @param bNotifyOnIncrease : Enable notification when reference - * count is increased. - * @ param bNotifyOnDecrease : Enable notification when reference - * count is decreased. - * @ param nCountForNotification : Count at which to trigger - * notification. Count indicates no. - * of copies of the buffer in - * circulation e.g. - * 1 - Only the original buffer is in - * circulation i.e. no buffers are - * currently locked. - * 2 - There are two copies of the - * buffer i.e. one original and - * one copy which has been locked - * by the codec. - * And so on - * SPECIAL CASE - * 0 - Indicates notify always - * irrespective of count value. - */ -/*===============================================================*/ -typedef struct OMX_TI_CONFIG_BUFFERREFCOUNTNOTIFYTYPE -{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bNotifyOnIncrease; - OMX_BOOL bNotifyOnDecrease; - OMX_U32 nCountForNotification; -}OMX_TI_CONFIG_BUFFERREFCOUNTNOTIFYTYPE; - - - - - -/* OMX_TI_SEVERITYTYPE enumeration is used to indicate severity level of errors returned by TI OpenMax components. - Critcal Requires reboot/reset DSP - Severe Have to unload components and free memory and try again - Major Can be handled without unloading the component - Minor Essentially informational -*/ -typedef enum OMX_TI_SEVERITYTYPE { - OMX_TI_ErrorCritical=1, - OMX_TI_ErrorSevere, - OMX_TI_ErrorMajor, - OMX_TI_ErrorMinor -} OMX_TI_SEVERITYTYPE; - -/* ============================================================================= */ -/* -@brief OMX_TI_PARAM_METADATABUFFERINFO : Structure to access metadata buffer info needed - by proxy to allocate metadat buffers. - -*/ -/* ============================================================================= */ -typedef struct OMX_TI_PARAM_METADATABUFFERINFO { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bIsMetaDataEnabledOnPort; - OMX_U32 nMetaDataSize; -} OMX_TI_PARAM_METADATABUFFERINFO; - -/******************************************************************* - * PRIVATE DECLARATIONS: defined here, used only here - *******************************************************************/ -/*---------- data declarations ------------------- */ -/*---------- function prototypes ------------------- */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _OMX_TI_COMMON_H_ */ diff --git a/domx/omx_core/inc/OMX_TI_Core.h b/domx/omx_core/inc/OMX_TI_Core.h deleted file mode 100755 index eb4993e..0000000 --- a/domx/omx_core/inc/OMX_TI_Core.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * @file omx_ti_core.h - * This file contains the vendor(TI) specific core extensions - * - * @path domx/system/omx_core/inc - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 19-Jul-2010 admonga@ti.com : Initial version - *================================================================*/ - -#ifndef _OMX_TI_CORE_H_ -#define _OMX_TI_CORE_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/****************************************************************** - INCLUDE FILES - ******************************************************************/ -#include -#include - -/******************************************************************* - * EXTERNAL REFERENCE NOTE: only use if not found in header file - *******************************************************************/ -/*---------- function prototypes ------------------- */ -/*---------- data declarations ------------------- */ -/******************************************************************* - * PUBLIC DECLARATIONS: defined here, used elsewhere - *******************************************************************/ -/*---------- function prototypes ------------------- */ -/*---------- data declarations ------------------- */ - - - -typedef enum OMX_TI_ERRORTYPE -{ - /* Vendor specific area for storing TI custom extended events */ - - /*Control attribute is pending - Dio_Dequeue will not work until attribute - is retreived*/ - OMX_TI_WarningAttributePending = (OMX_S32)((OMX_ERRORTYPE)OMX_ErrorVendorStartUnused + 1), - /*Attribute buffer size is insufficient - reallocate the attribute buffer*/ - OMX_TI_WarningInsufficientAttributeSize, - /*EOS buffer has been received*/ - OMX_TI_WarningEosReceived, - /*Port enable is called on an already enabled port*/ - OMX_TI_ErrorPortIsAlreadyEnabled, - /*Port disable is called on an already disabled port*/ - OMX_TI_ErrorPortIsAlreadyDisabled -} OMX_TI_ERRORTYPE; - - - -typedef enum OMX_TI_EVENTTYPE -{ - /* Vendor specific area for storing indices */ - /*Reference count for the buffer has changed. In the callback, nData1 will - pBufferHeader, nData2 will be present count*/ - OMX_TI_EventBufferRefCount = (OMX_S32)((OMX_EVENTTYPE)OMX_EventVendorStartUnused + 1) -}OMX_TI_EVENTTYPE; - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _OMX_TI_INDEX_H_ */ - diff --git a/domx/omx_core/inc/OMX_TI_IVCommon.h b/domx/omx_core/inc/OMX_TI_IVCommon.h deleted file mode 100755 index 84bcbac..0000000 --- a/domx/omx_core/inc/OMX_TI_IVCommon.h +++ /dev/null @@ -1,2657 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* -------------------------------------------------------------------------- * - * - * @file:OMX_TI_IVCommon.h - * This header defines the structures specific to the config indices of msp_VPPM. - * - * @path ..\OMAPSW_SysDev\multimedia\omx\khronos1_1\omx_core\inc - * - * -------------------------------------------------------------------------- */ - -/* ======================================================================== *! - *! Revision History - *! ==================================================================== */ - -#ifndef OMX_TI_IVCommon_H -#define OMX_TI_IVCommon_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include -#include - -#define DCC_PATH "/data/misc/camera/" -#define MAX_URI_LENGTH (OMX_MAX_STRINGNAME_SIZE) -#define MAX_ALGOAREAS (35) - -/*======================================================================= */ -/* Enumerated values for operation mode for compressed image - * - * ENUMS: - * Chunk : Chunk based operation - * NonChunk : Non-chunk based operation - */ - /* ======================================================================= */ -typedef enum OMX_JPEG_COMPRESSEDMODETYPE { - OMX_JPEG_ModeChunk = 0, - OMX_JPEG_ModeNonChunk -}OMX_JPEG_COMPRESSEDMODETYPE ; - - -/*======================================================================= */ -/* Enumerated values for operation mode for uncompressed image - * - * ENUMS: - * Frame : Frame based operation - * Slice : Slice based operation - * Stitch : For stitching between image frames - * Burst : For stitching between image frames - */ - /* ======================================================================= */ -typedef enum OMX_JPEG_UNCOMPRESSEDMODETYPE { - OMX_JPEG_UncompressedModeFrame = 0, - OMX_JPEG_UncompressedModeSlice, - OMX_JPEG_UncompressedModeStitch, - OMX_JPEG_UncompressedModeBurst -}OMX_JPEG_UNCOMPRESSEDMODETYPE; - - - -/*======================================================================= */ -/* Configuration structure for compressed image - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eCompressedImageMode : Operating mode enumeration for compressed image - */ - /*======================================================================= */ -typedef struct OMX_JPEG_PARAM_COMPRESSEDMODETYPE{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_JPEG_COMPRESSEDMODETYPE eCompressedImageMode; -}OMX_JPEG_PARAM_COMPRESSEDMODETYPE; - - - -/*======================================================================= */ -/* Uncompressed image Operating mode configuration structure - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nBurstLength : No of frames to be dumped in burst mode - * eUncompressedImageMode : uncompressed image mode information - * eSourceType : Image encode souce info - * tRotationInfo : Rotation related information - */ - /*======================================================================= */ -typedef struct OMX_JPEG_PARAM_UNCOMPRESSEDMODETYPE{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nBurstLength; - OMX_JPEG_UNCOMPRESSEDMODETYPE eUncompressedImageMode; -}OMX_JPEG_PARAM_UNCOMPRESSEDMODETYPE; - - -/*======================================================================= */ -/* Subregion Decode Parameter configuration structure - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nXOrg : Sectional decoding X origin - * nYOrg : Sectional decoding Y origin - * nXLength : Sectional decoding X length - * nYLength : Sectional decoding Y length - */ - /*======================================================================= */ -typedef struct OMX_IMAGE_PARAM_DECODE_SUBREGION{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nXOrg; - OMX_U32 nYOrg; - OMX_U32 nXLength; - OMX_U32 nYLength; -}OMX_IMAGE_PARAM_DECODE_SUBREGION; - - -/** - * sensor select types - */ -typedef enum OMX_SENSORSELECT{ - OMX_PrimarySensor = 0, - OMX_SecondarySensor, - OMX_TI_StereoSensor, - OMX_SensorTypeMax = 0x7fffffff -}OMX_SENSORSELECT; - -/** - * - * Sensor Select - */ -typedef struct OMX_CONFIG_SENSORSELECTTYPE { -OMX_U32 nSize; /**< Size of the structure in bytes */ -OMX_VERSIONTYPE nVersion; /**< OMX specification version info */ -OMX_U32 nPortIndex; /**< Port that this struct applies to */ -OMX_SENSORSELECT eSensor; /**< sensor select */ -} OMX_CONFIG_SENSORSELECTTYPE; - -/** - * Flicker cancellation types - */ -typedef enum OMX_COMMONFLICKERCANCELTYPE{ - OMX_FlickerCancelOff = 0, - OMX_FlickerCancelAuto, - OMX_FlickerCancel50, - OMX_FlickerCancel60, - OMX_FlickerCancel100, - OMX_FlickerCancel120, - OMX_FlickerCancelMax = 0x7fffffff -}OMX_COMMONFLICKERCANCELTYPE; - -typedef struct OMX_CONFIG_FLICKERCANCELTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_COMMONFLICKERCANCELTYPE eFlickerCancel; -} OMX_CONFIG_FLICKERCANCELTYPE; - - -/** - * Sensor caleberation types - */ -typedef enum OMX_SENSORCALTYPE{ - OMX_SensorCalFull = 0, - OMX_SensorCalQuick, - OMX_SensorCalMax = 0x7fffffff -}OMX_SENSORCALTYPE; - -typedef struct OMX_CONFIG_SENSORCALTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_SENSORCALTYPE eSensorCal; -} OMX_CONFIG_SENSORCALTYPE; - -/** - * Scene mode types - */ -typedef enum OMX_SCENEMODETYPE{ - - OMX_Manual = 0, - OMX_Closeup, - OMX_Portrait, - OMX_Landscape, - OMX_Underwater, - OMX_Sport, - OMX_SnowBeach, - OMX_Mood, - OMX_NightPortrait, - OMX_NightIndoor, - OMX_Fireworks, - OMX_Document, /**< for still image */ - OMX_Barcode, /**< for still image */ - OMX_SuperNight, /**< for video */ - OMX_Cine, /**< for video */ - OMX_OldFilm, /**< for video */ - OMX_TI_Action, - OMX_TI_Beach, - OMX_TI_Candlelight, - OMX_TI_Night, - OMX_TI_Party, - OMX_TI_Portrait, - OMX_TI_Snow, - OMX_TI_Steadyphoto, - OMX_TI_Sunset, - OMX_TI_Theatre, - OMX_SceneModeMax = 0x7fffffff -}OMX_SCENEMODETYPE; - -typedef struct OMX_CONFIG_SCENEMODETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_SCENEMODETYPE eSceneMode; -} OMX_CONFIG_SCENEMODETYPE; - - /** - * Port specific capture trigger - * useful for the usecases with multiple capture ports. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bExtCapturing : Start Captre at the specified port. Can be queried to know the status of a specific port. - */ -typedef struct OMX_CONFIG_EXTCAPTURING { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bExtCapturing; -} OMX_CONFIG_EXTCAPTURING; - - - /** - * Digital Zoom Speed - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nDigitalZoomSpeed : Optical zoom speed level. Special values: - * 0 - stop current movement - * values from 1 to 254 are mapped proportionally to supported zoom speeds inside optical zoom driver. - * So 1 is slowest available optical zoom speed and 254 is fastest available optical zoom speed - * 255 - default optical zoom speed value - */ -typedef struct OMX_CONFIG_DIGITALZOOMSPEEDTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U8 nDigitalZoomSpeed; -} OMX_CONFIG_DIGITALZOOMSPEEDTYPE; - - - /** - * Digital Zoom Target - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nDigitalZoomTarget : Default and minimum is 0. Maximum is determined by the current supported range - */ - -typedef struct OMX_CONFIG_DIGITALZOOMTARGETTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nDigitalZoomTarget; -} OMX_CONFIG_DIGITALZOOMTARGETTYPE; - - -/** -* Scale quality enums -*/ -typedef enum OMX_SCALEQUALITY{ - OMX_DefaultScaling = 0, /** */ - OMX_BetterScaling, /** */ - OMX_BestScaling, /** */ - OMX_AutoScalingQuality, /** */ - OMX_FastScaling, /** */ - OMX_ScaleQualityMax = 0x7fffffff -}OMX_SCALEQUALITY; - -/** -* Scaling Quality Mode -*/ -typedef enum OMX_SCALEQUALITYMODE{ - OMX_SingleFrameScalingMode = 0, /** */ - OMX_MultiFrameScalingMode, /** */ - OMX_AutoScalingMode, /** */ - OMX_ScaleModeMax = 0x7fffffff -}OMX_SCALEQUALITYMODE; - - /** - * Rescale quality control type - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * eScaleQuality : controls the quality level. - * eScaleQualityMode : controls the scaling algo types - */ -typedef struct OMX_CONFIG_SCALEQUALITYTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_SCALEQUALITY eScaleQuality; - OMX_SCALEQUALITYMODE eScaleQualityMode; -} OMX_CONFIG_SCALEQUALITYTYPE; - -/** -* Smooth Zoom mode enum -* Starts or stops the Smooth Zoom. Selecting INCREASE will cause an increasing digital zoom factor (increased cropping), -* with a shrinking viewable area and crop height percentage. Selecting DECREASE will cause a decreasing digital zoom (decreased cropping), -* with a growing viewable area and crop height percentage. The CaptureCropHeight will continue to update based on the SmoothZoomRate until -* the SmoothZoomMin or SmoothZoomMax zoom step is reached, the framework minimum zoom step is reached, the SmoothZoomRate becomes 0, -* or the SmoothZoomMode is set to OFF. -* NOTE: The message payload includes all parts of the message that is NOT part of the message header as listed for the CAM_SEND_DATA message. -*/ -typedef enum OMX_SMOOTHZOOMMODE{ - OMX_Off=0, /**< default OFF */ - OMX_Increase, - OMX_Decrease -}OMX_SMOOTHZOOMMODE; - - - /** - * Rescale quality control type - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * eSmoothZoomMode : controls the smooth zoom feature. - * nSmoothZoomRate : Values from 0 to 65535 which represents percentage to increase per second, where 65535 = 100%, and 0 = 0%. - * nSmoothZoomQuantize: - * nSmoothZoomThresh - * nSmoothZoomMin - * nSmoothZoomMax - */ -typedef struct OMX_CONFIG_SMOOTHZOOMTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_SMOOTHZOOMMODE eSmoothZoomMode; - OMX_U32 nSmoothZoomRate; - OMX_U32 nSmoothZoomQuantize; - OMX_U32 nSmoothZoomThresh; - OMX_U32 nSmoothZoomMin; - OMX_U32 nSmoothZoomMax; -} OMX_CONFIG_SMOOTHZOOMTYPE; - -/** - * Enumeration of possible Extended image filter types for OMX_CONFIG_IMAGEFILTERTYPE - */ -typedef enum OMX_EXTIMAGEFILTERTYPE { - OMX_ImageFilterSepia = 0x7F000001, - OMX_ImageFilterGrayScale, - OMX_ImageFilterNatural, - OMX_ImageFilterVivid, - OMX_ImageFilterColourSwap, - OMX_ImageFilterOutOfFocus, - OMX_ImageFilterWaterColour, - OMX_ImageFilterPastel, - OMX_ImageFilterFilm, - OMX_TI_ImageFilterBlackWhite, - OMX_TI_ImageFilterWhiteBoard, - OMX_TI_ImageFilterBlackBoard, - OMX_TI_ImageFilterAqua, - OMX_TI_ImageFilterPosterize -} OMX_EXTIMAGEFILTERTYPE; - - -/** - * Image filter configuration extended - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bBlemish : Enable/Disable Blemish correction - */ -typedef struct OMX_CONFIG_BLEMISHTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bBlemish; -} OMX_CONFIG_BLEMISHTYPE; - -/** - * Enumeration of Bracket types - * OMX_BracketExposureRelativeInEV: - * Exposure value is changed relative to the value set by automatic exposure. - * nBracketStartValue and nBracketStep are in Q16. Increment is additive. - * OMX_BracketExposureAbsoluteMs: - * Exposure value is changed in absolute value in ms. - * nBracketStartValue and nBracketStep are in Q16. Increment is multiplicative. - * OMX_BracketFocusRelative: - * Focus is adjusted relative to the focus set by auto focus. - * The value is S32 integer, and is the same as adjusting nFocusSteps of OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE relatively. - * Increment is additive. - * OMX_BracketFocusAbsolute: - * Focus position is adjusted absolutely. It is the same as setting nFocusSteps of - * OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE relatively for each captures. - * The value should be interpreted as U32 value. Increment is additive. - * OMX_BracketFlashPower: - * Power of flash is adjusted relative to the automatic level. Increment is multiplicative. - * OMX_BracketAperture: - * Aperture number relative to the automatic setting. Data in Q16 format. Increment is multiplicative. - * OMX_BracketTemporal: - * To suppport temporal bracketing. - */ -typedef enum OMX_BRACKETMODETYPE { - OMX_BracketExposureRelativeInEV = 0, - OMX_BracketExposureAbsoluteMs, - OMX_BracketFocusRelative, - OMX_BracketFocusAbsolute, - OMX_BracketFlashPower, - OMX_BracketAperture, - OMX_BracketTemporal, - OMX_BrackerTypeKhronosExtensions = 0x6f000000, - OMX_BrackerTypeVendorStartUnused = 0x7f000000, - OMX_BracketTypeMax = 0x7FFFFFFF -} OMX_BRACKETMODETYPE; - -typedef struct OMX_CONFIG_BRACKETINGTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BRACKETMODETYPE eBracketMode; - OMX_U32 nNbrBracketingValues; - OMX_S32 nBracketValues[10]; /**< 10 can be assumed */ -} OMX_CONFIG_BRACKETINGTYPE; - - -/** - * Capture mode types - * Note: this list could get extended modified based on the type of interenal use-case pipelines implemented within the camera component. - * - * OMX_CaptureImageHighSpeedBurst = 0, - * OMX_CaptureImageHighSpeedTemporalBracketing, - * OMX_CaptureImageProfileBase(Base): - * Base one almost same as Highspeed one. - * OMX_CaptureImageProfileLowLight1(LL1): - * Includes NSF2 in addition to Base processing - * OMX_CaptureImageProfileLowLight2(LL2): - * Includes NSF2 and LBCE in addition to Base processing. - * OMX_CaptureImageProfileOpticalCorr1(OC1): - * Includes LDC in addition to Base processing. - * OMX_CaptureImageProfileOpticalCorr2(OC2): - * Includes LDC and CAC in addition to Base processing. - * OMX_CaptureImageProfileExtended1(Ext1): - * Includes NSF2, LBCE, LDC, and CAC in addition to Base - * OMX_CaptureStereoImageCapture: - * Stereo image capture use-case. - * OMX_CaptureImageMemoryInput: - * need to take sensor input from INPUT port. - * OMX_CaptureVideo: - * OMX_CaptureHighSpeedVideo: - * OMX_CaptureVideoMemoryInput: - * - */ -typedef enum OMX_CAMOPERATINGMODETYPE { - OMX_CaptureImageHighSpeedBurst = 0, - OMX_CaptureImageHighSpeedTemporalBracketing, - OMX_CaptureImageProfileBase, - OMX_CaptureImageProfileLowLight1, - OMX_CaptureImageProfileLowLight2, - OMX_CaptureImageProfileOpticalCorr1, - OMX_CaptureImageProfileOpticalCorr2, - OMX_CaptureImageProfileExtended1, - OMX_CaptureStereoImageCapture, - OMX_CaptureImageMemoryInput, - OMX_CaptureVideo, - OMX_CaptureHighSpeedVideo, - OMX_CaptureVideoMemoryInput, - OMX_TI_CaptureDummy, - OMX_TI_CaptureGestureRecognition, - OMX_TI_CaptureImageProfileZeroShutterLag, - OMX_CamOperatingModeMax = 0x7fffffff -} OMX_CAMOPERATINGMODETYPE; -/** - * Capture mode setting: applicable to multi shot capture also including bracketing. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eCamOperatingMode : specifies the camera operating mode. - */ -typedef struct OMX_CONFIG_CAMOPERATINGMODETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_CAMOPERATINGMODETYPE eCamOperatingMode; -} OMX_CONFIG_CAMOPERATINGMODETYPE; - - -/** - * Capture mode setting: applicable to multi shot capture also including bracketing. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nFrameRate : when bContinuous is FALSE, need to define the frame rate of the muti-shot scenario. Since this would be applicable to IMAGE domain port, there is no port specific frame rate. - * nFrameBefore : - * is specifying how many frames before the capture trigger shall be used. - * It is implementation dependent how many is supported. This shall only be supported for images and not for video frames. - * bPrepareCapture : - * should be set to true when nFrameBefore is greater than zero and before capturing of before-frames should start. - * The component is not allowed to deliver buffers until capturing starts. This shall only be supported for images and not for video frames. - * bEnableBracketing : - * should be enabled when bracketing is used. In bracketing mode, one parameter can be changed per each capture. - * tBracketConfigType : - * specifies bracket mode to use. Valid only when bEnableBracketing is set. - */ -typedef struct OMX_CONFIG_EXTCAPTUREMODETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nFrameRate; - OMX_U32 nFrameBefore; - OMX_BOOL bPrepareCapture; - OMX_BOOL bEnableBracketing; - OMX_CONFIG_BRACKETINGTYPE tBracketConfigType; -} OMX_CONFIG_EXTCAPTUREMODETYPE; - -/** - * For Extended Focus region Type - - */ -typedef struct OMX_CONFIG_EXTFOCUSREGIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nRefPortIndex; - OMX_S32 nLeft; - OMX_S32 nTop; - OMX_U32 nWidth; - OMX_U32 nHeight; -} OMX_CONFIG_EXTFOCUSREGIONTYPE; - -/** - * Digital Flash Control - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bDigitalFlash : Digital flash type Enable/Disable - - * Specifies whether the digital flash algorithm is enabled or disabled. This overrides the contrast and brightness settings. - */ -typedef struct OMX_CONFIG_DIGITALFLASHTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bDigitalFlash; -} OMX_CONFIG_DIGITALFLASHTYPE; - - - -/** - * Privacy Indicator Enable/Disable - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bPrivacyIndicator : - * Specifies whether the flash should be used to indicate image or video capture. When flash is not used for exposure, - * flash will be activated after exposure to indicate image capture. - * If video light is not used, the flash can be blinking or constant at low intensity to indicate capture but not affect exposure. - * Specifies whether the digital flash algorithm is enabled or disabled. This overrides the contrast and brightness settings. - */ -typedef struct OMX_CONFIG_PRIVACYINDICATOR { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bPrivacyIndicator; -} OMX_CONFIG_PRIVACYINDICATOR; - - -/** - * Privacy Indicator Enable/Disable - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bTorchMode : - * Enable/Disable - * nIntensityLevel : relative intensity from 0 - 100 - * nDuration : duration in msec - */ -typedef struct OMX_CONFIG_TORCHMODETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bTorchMode; - OMX_U32 nIntensityLevel; - OMX_U32 nDuration; -} OMX_CONFIG_TORCHMODETYPE; - - - -/** - * Privacy Indicator Enable/Disable - * DISABLE - Fire the xenon flash in the usual manner - * ENABLE - Reduce the light intensity of the main flash (ex 1EV) - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bSlowSync : - * Enable - OMX_TRUE/Disable - OMX_FALSE - */ -typedef struct OMX_CONFIG_SLOWSYNCTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bSlowSync; -} OMX_CONFIG_SLOWSYNCTYPE; - - -/** - * Focus control extended enums. use this along with OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE - */ -typedef enum OMX_IMAGE_EXTFOCUSCONTROLTYPE { - OMX_IMAGE_FocusControlAutoMacro = 0x7F000001, /**< Reserved region for introducing Vendor Extensions */ - OMX_IMAGE_FocusControlAutoInfinity, - OMX_IMAGE_FocusControlHyperfocal, - OMX_IMAGE_FocusControlPortrait, /**< from Xena */ - OMX_IMAGE_FocusControlExtended, /**< from Xena */ - OMX_IMAGE_FocusControlContinousNormal, /**< from Xena */ - OMX_IMAGE_FocusControlContinousExtended /**< from Xena */ -} OMX_IMAGE_EXTFOCUSCONTROLTYPE; - - - -/** - * Specifies whether the LED can be used to assist in autofocus, due to low lighting conditions. - * ENABLE means use as determined by the auto exposure algorithm. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bFocusAssist : - * Enable - OMX_TRUE/Disable - OMX_FALSE - */ -typedef struct OMX_CONFIG_FOCUSASSISTTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bFocusAssist; -} OMX_CONFIG_FOCUSASSISTTYPE; - - - -/** - *for locking the focus - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bFocusLock : - * Enable - OMX_TRUE/Disable - OMX_FALSE - */ -typedef struct OMX_CONFIG_FOCUSLOCKTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bFocusLock; -} OMX_CONFIG_FOCUSLOCKTYPE; - - -/** - *for locking the White balance - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bWhiteBalanceLock : - * Enable - OMX_TRUE/Disable - OMX_FALSE - */ -typedef struct OMX_CONFIG_WHITEBALANCELOCKTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bWhiteBalanceLock; -} OMX_CONFIG_WHITEBALANCELOCKTYPE; - -/** - *for locking the Exposure - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bExposureLock : - * Enable - OMX_TRUE/Disable - OMX_FALSE - */ -typedef struct OMX_CONFIG_EXPOSURELOCKTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bExposureLock; -} OMX_CONFIG_EXPOSURELOCKTYPE; - -/** - *for locking the Exposure - * Simultaneously lock focus, white balance and exposure (and relevant other settings). - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bAllLock : - * Enable - OMX_TRUE/Disable - OMX_FALSE - */ -typedef struct OMX_CONFIG_ALLLOCKTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bAllLock; -} OMX_CONFIG_ALLLOCKTYPE; - -/** - *for locking - * Simultaneously lock focus, white balance and exposure (and relevant other settings). - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bLock : - * Enable - OMX_TRUE/Disable - OMX_FALSE - * bAtCapture: - * - */ -typedef struct OMX_IMAGE_CONFIG_LOCKTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bLock; - OMX_BOOL bAtCapture; -} OMX_IMAGE_CONFIG_LOCKTYPE; - -/** - * processig level types enum - */ -typedef enum OMX_PROCESSINGLEVEL{ - OMX_Min = 0, - OMX_Low, - OMX_Medium, - OMX_High, - OMX_Max, - OMX_ProcessingLevelMax = 0x7fffffff -}OMX_PROCESSINGLEVEL; - -/** - *processing level type - * Simultaneously lock focus, white balance and exposure (and relevant other settings). - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nLevel : - * nLevel hinting processing amount. Range of values is -100 to 100. - * 0 causes no change to the image. Increased values cause increased processing to occur, with 100 applying maximum processing. - * Negative values have the opposite effect of positive values. - * bAuto: - * sets if the processing should be applied according to input data. - It is allowed to combine the hint level with the auto setting, - * i.e. to give a bias to the automatic setting. When set to false, the processing should not take input data into account. - */ - -typedef struct OMX_IMAGE_CONFIG_PROCESSINGLEVELTYPE { -OMX_U32 nSize; -OMX_VERSIONTYPE nVersion; -OMX_U32 nPortIndex; -OMX_S32 nLevel; -OMX_BOOL bAuto; -} OMX_IMAGE_CONFIG_PROCESSINGLEVELTYPE; - - -/** - * White Balance control type extended enums - to be used along with the structure @OMX_CONFIG_WHITEBALCONTROLTYPE - * - * - * - */ -typedef enum OMX_EXTWHITEBALCONTROLTYPE { - OMX_WhiteBalControlFacePriorityMode = OMX_WhiteBalControlVendorStartUnused + 1, /**< */ - OMX_TI_WhiteBalControlSunset, - OMX_TI_WhiteBalControlShade, - OMX_TI_WhiteBalControlTwilight, - OMX_TI_WhiteBalControlWarmFluorescent -} OMX_EXTWHITEBALCONTROLTYPE; - -/** - *white balance gain type - * xWhiteBalanceGain and xWhiteBalanceOffset represents gain and offset for R, Gr, Gb, B channels respectively in Q16 format. \ - * For example, new red pixel value = xWhiteBalanceGain[1]* the current pixel value + xWhiteBalanceOffset[1]. - * All values assume that maximum value is 255. If internal implementation uses higher dynamic range, this value should be adjusted internally. - * nWhiteThreshhold represents thresholds for "white" area measurments in Q16 format. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * - */ -typedef struct OMX_CONFIG_WHITEBALGAINTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_S32 xWhiteBalanceGain[4]; - OMX_S32 xWhiteBalanceOffset[4]; - OMX_S32 nWhiteThreshhold[4]; -} OMX_CONFIG_WHITEBALGAINTYPE; - -/** - * This structure represents linear color conversion from one space to another. For example, to conversion from one RGB color into another RGB color space can be represented as - * R' = xColorMatrix[1][1]*R + xColorMatrix[1][2]*G + xColorMatrix[1][3]*B + xColorOffset[1] - * G' = xColorMatrix[2][1]*R + xColorMatrix[2][2]*G + xColorMatrix[2][3]*B + xColorOffset[2] - * B' = xColorMatrix[3][1]*R + xColorMatrix[3][2]*G + xColorMatrix[3][3]*B + xColorOffset[3] - * Both xColorMatrix and xColorOffset are represented as Q16 value. - * bFullColorRange represents represents whether valid range of color is 0 to 255 (when set to TRUE) or 16 to 235 (for FALSE). - * Again all values assume that maximum value is 255. If internal implementation uses higher dynamic range, this value should be adjusted internally. - * - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * - */ -typedef struct OMX_CONFIG_EXT_COLORCONVERSIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_S32 xColorMatrix[3][3]; - OMX_S32 xColorOffset[3]; - OMX_BOOL bFullColorRange; -}OMX_CONFIG_EXT_COLORCONVERSIONTYPE; - - -/** - * xGamma represents lool-up table for gamma correction in Q16 format. - * All values assume that maximum value is 255. If internal implementation uses higher dynamic range, this value should be adjusted internally. - * - * - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * - */ -typedef struct OMX_CONFIG_GAMMATABLETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 xGamma[3][256]; -}OMX_CONFIG_GAMMATABLETYPE; - - - -/** - * processig types - */ -typedef enum OMX_PROCESSINGTYPE{ - OMX_BloomingReduction = 0, - OMX_Denoise, - OMX_Sharpening, - OMX_Deblurring, - OMX_Demosaicing, - OMX_ContrastEnhancement, - OMX_ProcessingTypeMax = 0x7fffffff -}OMX_PROCESSINGTYPE; - - -typedef struct OMX_CONFIGPROCESSINGORDERTYPE { -OMX_U32 nSize; /**< Size of the structure in bytes */ -OMX_VERSIONTYPE nVersion; /**< OMX specification version info */ -OMX_U32 nPortIndex; /**< Port that this struct applies to */ -OMX_U32 nIndex; -OMX_PROCESSINGTYPE eProc; -} OMX_CONFIGPROCESSINGORDERTYPE; - -/** - * HIST TYPE - */ -typedef enum OMX_HISTTYPE{ - OMX_HistControlLuminance = 0, /**< Luminance histogram is calculated (Y)*/ - OMX_HistControlColorComponents, /**< A histogram per color component (R, G, B) is calculated*/ - OMX_HistControlChrominanceComponents /**< A histogram per chrominance component (Cb, Cr) is calculated.*/ -}OMX_HISTTYPE; - -/** - * Histogram Setting - * nPortIndex is an output port. The port index decides on which port the extra data structur is sent on. - * bFrameLimited is a Boolean used to indicate if measurement shall be terminated after the specified number of - * frames if true frame limited measurement is enabled; otherwise the port does not terminate measurement until - * instructed to do so by the client. - * nFrameLimit is the limit on number of frames measured, this parameter is only valid if bFrameLimited is enabled. - * bMeasure is a Boolean that should be set to true when measurement shall begin, otherwise set to false. Query will give status information on if measurement is ongoing or not. - * nBins specifies the number of histogram bins. When queried with set to zero, the respons gives the maximum number of bins allowed. - * nLeft is the leftmost coordinate of the measurement area rectangle. - * nTop is the topmost coordinate of the measurement area rectangle. - * nWidth is the width of the measurement area rectangle in pixels. - * nHeight is the height of the measurement area rectangle in pixels. - * eHistType is an enumeration specifying the histogram type - * - * - */ - -typedef struct OMX_CONFIG_HISTOGRAMTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bFrameLimited; - OMX_U32 nFrameLimit; - OMX_BOOL bMeasure; - OMX_U32 nBins; - OMX_S32 nLeft; - OMX_S32 nTop; - OMX_U32 nWidth; - OMX_U32 nHeight; - OMX_HISTTYPE eHistType; -} OMX_CONFIG_HISTOGRAMTYPE; - -/** - * Enums for HIST component type. - */ -typedef enum OMX_HISTCOMPONENTTYPE{ - OMX_HISTCOMP_Y = 0, /**< Luminance histogram (Y) */ - OMX_HISTCOMP_YLOG, /**< Logarithmic luminance histogram (Y)*/ - OMX_HISTCOMP_R, /**< Red histogram component (R)*/ - OMX_HISTCOMP_G, /**< Green histogram component (G)*/ - OMX_HISTCOMP_B, /**< Blue histogram component (B)*/ - OMX_HISTCOMP_Cb, /**< Chroma blue histogram component (Cb)*/ - OMX_HISTCOMP_Cr /**< Chroma red histogram component (Cr) */ -}OMX_HISTCOMPONENTTYPE; - - /** - * The OMX_TI_CAMERAVIEWTYPE enumeration is used to identify the - * particular camera view that the rest of the data in the structure is - * associated with. - */ -typedef enum OMX_TI_CAMERAVIEWTYPE -{ - OMX_2D, /**< Camera view in 2D sensor configuration */ - OMX_Left, /**< Left camera view in stereo sensor configuration */ - OMX_Right, /**< Right camera view in stereo sensor configuration */ - OMX_TI_CAMERAVIEWTYPE_32BIT_PATCH = 0x7FFFFFFF -} OMX_TI_CAMERAVIEWTYPE; -/** - * nSize is the size of the structure including the length of data field containing - * the histogram data. - * nBins is the number of bins in the histogram. - * eComponentType specifies the type of the histogram bins according to enum. - * It can be selected to generate multiple component types, then the extradata struct - * is repeated for each component type. - * data[1] first byte of the histogram data - */ -typedef struct OMX_HISTOGRAMTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_CAMERAVIEWTYPE eCameraView; - OMX_U32 nBins; - OMX_HISTCOMPONENTTYPE eComponentType; - OMX_U8 data[1]; -} OMX_HISTOGRAMTYPE; - -#define OMX_OTHER_EXTRADATATYPE_SIZE ( (OMX_U32)(((OMX_OTHER_EXTRADATATYPE*)0x0)->data) ) /**< Size of OMX_OTHER_EXTRADATATYPE**/ -/** - * The extra data having ancillary data is described with the following structure. - * This data contains single flags and values - * (not arrays) that have general usage for camera applications. - */ -typedef struct OMX_TI_ANCILLARYDATATYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_CAMERAVIEWTYPE eCameraView; - OMX_U32 nAncillaryDataVersion; - OMX_U32 nFrameNumber; - OMX_U32 nShotNumber; - OMX_U16 nInputImageHeight; - OMX_U16 nInputImageWidth; - OMX_U16 nOutputImageHeight; - OMX_U16 nOutputImageWidth; - OMX_U16 nDigitalZoomFactor; - OMX_S16 nCropCenterColumn; - OMX_S16 nCropCenterRow; - OMX_U16 nOpticalZoomValue; - OMX_U8 nFlashConfiguration; - OMX_U8 nFlashUsage; - OMX_U32 nFlashStatus; - OMX_U8 nAFStatus; - OMX_U8 nAWBStatus; - OMX_U8 nAEStatus; - OMX_U32 nExposureTime; - OMX_U16 nEVCompensation; - OMX_U8 nDigitalGainValue; - OMX_U8 nAnalogGainValue; - OMX_U16 nCurrentISO; - OMX_U16 nReferenceISO; - OMX_U8 nApertureValue; - OMX_U8 nPixelRange; - OMX_U16 nPixelAspectRatio; - OMX_U8 nCameraShake; - OMX_U16 nFocalDistance; - OMX_U64 nParameterChangeFlags; - OMX_U8 nNumFacesDetected; - OMX_U8 nConvergenceMode; - OMX_U8 nConvergenceStatus; - OMX_U8 nDCCStatus; -} OMX_TI_ANCILLARYDATATYPE; - -typedef struct OMX_TI_WHITEBALANCERESULTTYPE { - OMX_U32 nSize; /**< Size */ - OMX_VERSIONTYPE nVersion; /**< Version */ - OMX_U32 nPortIndex; /**< Port Index */ - OMX_TI_CAMERAVIEWTYPE eCameraView; - OMX_U16 nColorTemperature; /**< White Balance Color Temperature in Kelvins */ - OMX_U16 nGainR; /**< Bayer applied R color channel gain in (U13Q9) */ - OMX_U16 nGainGR; /**< Bayer applied Gr color channel gain in (U13Q9) */ - OMX_U16 nGainGB; /**< Bayer applied Gb color channel gain in (U13Q9) */ - OMX_U16 nGainB; /**< Bayer applied B color channel gain in (U13Q9) */ - OMX_S16 nOffsetR; /**< Bayer applied R color channel offset */ - OMX_S16 nOffsetGR; /**< Bayer applied Gr color channel offset */ - OMX_S16 nOffsetGB; /**< Bayer applied Gb color channel offset */ - OMX_S16 nOffsetB; /**< Bayer applied B color channel offset */ -} OMX_TI_WHITEBALANCERESULTTYPE; - -/** - * Unsaturated Regions data - * The extra data having unsaturated regions data is - * described with the following structure.. - */ -typedef struct OMX_TI_UNSATURATEDREGIONSTYPE { - OMX_U32 nSize; /**< Size */ - OMX_VERSIONTYPE nVersion; /**< Version */ - OMX_U32 nPortIndex; /**< Port Index */ - OMX_U16 nPaxelsX; /**< The number of paxels in the horizontal direction */ - OMX_U16 nPaxelsY; /**< The number of paxels in the vertical direction */ - OMX_U16 data[1]; /**< the first value of an array of values that represent */ -} OMX_TI_UNSATURATEDREGIONSTYPE; - -/** - * OMX_BARCODETYPE - */ -typedef enum OMX_BARCODETYPE{ - OMX_BARCODE1D = 0, /**< 1D barcode */ - OMX_BARCODE2D, /**< 2D barcode */ -}OMX_BARCODETYPE; -/** - * Brcode detection data - * nLeft is the leftmost coordinate of the detected area rectangle. - * nTop is the topmost coordinate of the detected area rectangle. - * nWidth is the width of the detected area rectangle in pixels. - * nHeight is the height of the detected area rectangle in pixels. - * nOrientation is the orientation of the axis of the detected object. This refers to the angle between the vertical axis of barcode and the horizontal axis. - * eBarcodetype is an enumeration specifying the barcode type, as listed in the given table. - */ -typedef struct OMX_BARCODEDETECTIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_CAMERAVIEWTYPE eCameraView; - OMX_S32 nLeft; - OMX_S32 nTop; - OMX_U32 nWidth; - OMX_U32 nHeight; - OMX_S32 nOrientation; - OMX_BARCODETYPE eBarcodetype; - } OMX_BARCODEDETECTIONTYPE; - -/** - * Front object detection data - * nLeft is the leftmost coordinate of the detected area rectangle. - * nTop is the topmost coordinate of the detected area rectangle. - * nWidth is the width of the detected area rectangle in pixels. - * nHeight is the height of the detected area rectangle in pixels. - */ -typedef struct OMX_FRONTOBJDETECTIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_CAMERAVIEWTYPE eCameraView; - OMX_S32 nLeft; - OMX_S32 nTop; - OMX_U32 nWidth; - OMX_U32 nHeight; -} OMX_FRONTOBJDETECTIONTYPE; - -/** - * Distance estimation data - * nDistance is the estimated distance to the object in millimeters. - * nLargestDiscrepancy is the estimated largest discrepancy of the distance to the object in millimeters. When equal to MAX_INT the discrepancy is unknown. - */ -typedef struct OMX_DISTANCEESTIMATIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_CAMERAVIEWTYPE eCameraView; - OMX_U32 nDistance; - OMX_U32 nLargestDiscrepancy; -} OMX_DISTANCEESTIMATIONTYPE; - -/** - * Distance estimation data - * nDistance is the estimated distance to the object in millimeters. - * nLargestDiscrepancy is the estimated largest discrepancy of the distance to the object in millimeters. When equal to MAX_INT the discrepancy is unknown. - */ - -typedef struct OMX_MOTIONESTIMATIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_CAMERAVIEWTYPE eCameraView; - OMX_S32 nPanX; - OMX_S32 nPanY; -} OMX_MOTIONESTIMATIONTYPE; - - -/** - * Focus region data - * nRefPortIndex is the port the image frame size is defined on. This image frame size is used as reference for the focus region rectangle. - * nLeft is the leftmost coordinate of the focus region rectangle. - * nTop is the topmost coordinate of the focus region rectangle. - * nWidth is the width of the focus region rectangle in pixels. - * nHeight is the height of the focus region rectangle in pixels. - * - */ -typedef struct OMX_FOCUSREGIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_CAMERAVIEWTYPE eCameraView; - OMX_U32 nRefPortIndex; - OMX_S32 nLeft; - OMX_S32 nTop; - OMX_U32 nWidth; - OMX_U32 nHeight; -} OMX_FOCUSREGIONTYPE; - -/** - * OMX_ISOSETTINGTYPE: specifies its auto or manual setting - * - */ -typedef enum OMX_ISOSETTINGTYPE{ - OMX_Auto = 0, /**< */ - OMX_IsoManual /**< */ -}OMX_ISOSETTINGTYPE; - -/** - * nSize is the size of the structure including the length of data field containing - * the histogram data. - * eISOMode: - * specifies the ISO seetting mode - auto/manual - * nISOSetting: - * for manual mode client can specify the ISO setting. - */ - -typedef struct OMX_CONFIG_ISOSETTINGTYPE{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_ISOSETTINGTYPE eISOMode; - OMX_U32 nISOSetting; -}OMX_CONFIG_ISOSETTINGTYPE; - -/** - * custom RAW format - */ -typedef struct OMX_CONFIG_RAWFORMATTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VERSIONTYPE nFormatVersion; - OMX_STRING cVendorName; -} OMX_CONFIG_RAWFORMATTYPE; - -/** - * Sensor type - */ -typedef struct OMX_CONFIG_SENSORTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VERSIONTYPE nSensorVersion; - OMX_STRING cModelName; -} OMX_CONFIG_SENSORTYPE; - -/** - * Sensor custom data type - */ -typedef struct OMX_CONFIG_SENSORCUSTOMDATATYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nDataLength; - OMX_U8 xSensorData[1]; -} OMX_CONFIG_SENSORCUSTOMDATATYPE; - -/** - * OMX_OBJDETECTQUALITY - * - */ -typedef enum OMX_OBJDETECTQUALITY{ - OMX_FastDetection = 0, /**< A detection that prioritizes speed*/ - OMX_Default, /**< The default detection, should be used when no control of the detection quality is given.*/ - OMX_BetterDetection, /**< A detection that levels correct detection with speed*/ - OMX_BestDtection, /**< A detection that prioritizes correct detection*/ - OMX_AUTODETECTION /**< Automatically decide which object detection quality is best.*/ -}OMX_OBJDETECTQUALITY; - -/** - * OBJECT DETECTION Type - * nPortIndex: is an output port. The port index decides on which port the extra data structur of detected object is sent on. - * bEnable : this controls ON/OFF for this object detection algirithm. - * bFrameLimited: is a Boolean used to indicate if detection shall be terminated after the specified number of frames if - * true frame limited detection is enabled; otherwise the port does not terminate detection until instructed to do so by the client. - * nFrameLimit: is the limit on number of frames detection is executed for, this parameter is only valid if bFrameLimited is enabled. - * nMaxNbrObjects: specifies the maximum number of objects that should be found in each frame. It is implementation dependent which objects are found. - * nLeft: is the leftmost coordinate of the detection area rectangle. - * nTop: is the topmost coordinate of the detection area rectangle. - * nWidth: is the width of the detection area rectangle in pixels. - * nHeight: is the height of the detection area rectangle in pixels. - * eObjDetectQuality: is an enumeration specifying the quality desired by the detection. - * nPriority: represents priority of each object when there are multiple objects detected. - */ - -typedef struct OMX_CONFIG_OBJDETECTIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnable; - OMX_BOOL bFrameLimited; - OMX_U32 nFrameLimit; - OMX_U32 nMaxNbrObjects; - OMX_S32 nLeft; - OMX_S32 nTop; - OMX_U32 nWidth; - OMX_U32 nHeight; - OMX_OBJDETECTQUALITY eObjDetectQuality; - OMX_U32 nPriority; - OMX_U32 nDeviceOrientation; - } OMX_CONFIG_OBJDETECTIONTYPE; - - -/** - * OMX_OBJDETECTQUALITY - * - */ -typedef enum OMX_DISTTYPE{ - OMX_DistanceControlFocus = 0, /**< focus objects distance type*/ - OMX_DISTANCECONTROL_RECT /**< Evaluated distance to the object found in the rectangelar area indicated as input region. */ -}OMX_DISTTYPE; - - -/** - * Distance mesurement - * bStarted is a Boolean. The IL client sets it to true to start the measurement . - * the IL client sets to false to stop the measurement. The IL client can query it to check if the measurement is ongoing. - * nLeft : is the leftmost coordinate of the rectangle. - * nTop : is the topmost coordinate of the rectangle. - * nWidth: is the width of the rectangle in pixels. - * nHeight: is the height of the rectangle in pixels. - * eDistType: is an enumeration specifying the distance measurement type, as shown in - */ -typedef struct OMX_CONFIG_DISTANCETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bStarted; - OMX_S32 nLeft; - OMX_S32 nTop; - OMX_U32 nWidth; - OMX_U32 nHeight; - OMX_DISTTYPE eDistType; -} OMX_CONFIG_DISTANCETYPE; - - -/** - * face detect data - face attribute - * nARGBEyeColor: is the indicates a 32-bit eye color of the person, where bits 0-7 are blue, - * bits 15-8 are green, bits 24-16 are red, and bits 31-24 are for alpha. - * nARGBSkinColor: is the indicates a 32-bit skin color of the person, where bits 0-7 are blue, - * bits 15-8 are green, bits 24-16 are red, and bits 31-24 are for alpha. - * nARGBHairColor: is the indicates a 32-bit hair color of the person, where bits 0-7 are blue, - * bits 15-8 are green, bits 24-16 are red, and bits 31-24 are for alpha. - * nSmileScore: a smile detection score between 0 and 100, where 0 means not detecting, - * 1 means least certain and 100 means most certain a smile is detected. - * nBlinkScore: a eye-blink detection score between 0 and 100, where 0 means not detecting, - * 1 means least certain and 100 means most certain an eye-blink is detected. - * xIdentity: represents the identity of the face. With identity equal to zero this is not supported. - * This can be used by a face recognition application. The component shall not reuse an identity value unless the same face. - * Can be used to track detected faces when it moves between frames. Specific usage of this field is implementation dependent. - * It can be some kind of ID. - * - */ -typedef struct OMX_FACEATTRIBUTE { - OMX_U32 nARGBEyeColor; - OMX_U32 nARGBSkinColor; - OMX_U32 nARGBHairColor; - OMX_U32 nSmileScore; - OMX_U32 nBlinkScore; - OMX_U32 xIdentity[4]; -} OMX_FACEATTRIBUTE; - -/** - * xGamma represents lool-up table for gamma correction in Q16 format. - * All values assume that maximum value is 255. If internal implementation uses higher dynamic range, this value should be adjusted internally. - * - * - * - * STRUCT MEMBERS: - * nScore: is a detection score between 0 and 100, where 0 means unknown score, 1 means least certain and 100 means most certain the detection is correct. - * nLeft: is the leftmost coordinate of the detected area rectangle. - * nTop: is the topmost coordinate of the detected area rectangle. - * nWidth: is the width of the detected area rectangle in pixels. - * nHeight: is the height of the detected area rectangle in pixels. - * nOrientationRoll/Yaw/Pitch is the orientation of the axis of the detected object. Here roll angle is defined as the angle between the vertical axis of face and the horizontal axis. All angles can have the value of -180 to 180 degree in Q16 format. Some face detection algorithm may not be able to fill in the angles, this is denoted by the use of MAX_INT value. - * nPriority represents priority of each object when there are multiple objects detected. - * nFaceAttr describe the attributes of the detected face object with the following structure: - * - * - */ -typedef struct OMX_TI_FACERESULT { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_CAMERAVIEWTYPE eCameraView; - OMX_U32 nScore; - OMX_S32 nLeft; - OMX_S32 nTop; -OMX_U32 nWidth; -OMX_U32 nHeight; -OMX_S32 nOrientationRoll; -OMX_S32 nOrientationYaw; -OMX_S32 nOrientationPitch; -OMX_U32 nPriority; -OMX_FACEATTRIBUTE nFaceAttr; -} OMX_TI_FACERESULT; - - -/** - * Face detection data - * The extra data having face detection data is described with the following structure. - * The parser should only assume that the first tFacePosition[ulFaceCount] of the 35 elements - * of the array should contain valid data. - */ -typedef struct OMX_FACEDETECTIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_CAMERAVIEWTYPE eCameraView; - OMX_U16 ulFaceCount; - OMX_TI_FACERESULT tFacePosition[35];// 35 is max faces supported by FDIF -} OMX_FACEDETECTIONTYPE; - -/** - * MTIS Vendor Specific Motion estimation - * The extra data having MTIS motion estimation data is - * described with the following structure. - */ -typedef struct OMX_TI_MTISTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_CAMERAVIEWTYPE eCameraView; - OMX_S32 nMaxMVh; /**< The maximum MV for horizontal direction */ - OMX_S32 nMaxMVv; /**< The maximum MV for vertical direction */ - OMX_U16 nMVRelY[9]; /**< The mask for MV reliability */ - OMX_U16 nMVRelX[9]; /**< The mask for MV reliability */ - OMX_S32 nMVh[9]; /**< The MVs for horizontal direction */ - OMX_S32 nMVv[9]; /**< The MVs for vertical direction */ -} OMX_TI_MTISTYPE; - -/** - * The OMX_EXTRADATATYPE enumeration is used to define the - * possible extra data payload types. - */ -typedef enum OMX_EXT_EXTRADATATYPE -{ - OMX_ExifAttributes = 0x7F000001, /**< Reserved region for introducing Vendor Extensions */ - OMX_AncillaryData, /**< 0x7F000002 ancillary data */ - OMX_WhiteBalance, /**< 0x7F000003 white balance resultant data */ - OMX_UnsaturatedRegions, /**< 0x7F000004 unsaturated regions data */ - OMX_FaceDetection, /**< face detect data */ - OMX_BarcodeDetection, /**< bar-code detct data */ - OMX_FrontObjectDetection, /**< Front object detection data */ - OMX_MotionEstimation, /**< motion Estimation data */ - OMX_TI_MTISType, /**< 0x7F000009 MTIS motion Estimation data */ - OMX_DistanceEstimation, /**< disctance estimation */ - OMX_Histogram, /**< histogram */ - OMX_FocusRegion, /**< focus region data */ - OMX_ExtraDataPanAndScan, /**< 0x7F00000D pan and scan data */ - OMX_RawFormat, /**< custom RAW data format */ - OMX_SensorType, /**< vendor & model of the sensor being used */ - OMX_SensorCustomDataLength, /**< vendor specific custom data length */ - OMX_SensorCustomData, /**< vendor specific data */ - OMX_TI_FrameLayout, /**< 0x7F000012 vendor specific data */ - OMX_TI_SEIinfo2004Frame1, /**< 0x7F000013 Used for 2004 SEI message to be provided by video decoders */ - OMX_TI_SEIinfo2004Frame2, /**< 0x7F000014 Used for 2004 SEI message to be provided by video decoders */ - OMX_TI_SEIinfo2010Frame1, /**< 0x7F000015 Used for 2010 SEI message to be provided by video decoders */ - OMX_TI_SEIinfo2010Frame2, /**< 0x7F000016 Used for 2010 SEI message to be provided by video decoders */ - OMX_TI_RangeMappingInfo, /**< 0x7F000017 Used for Range mapping info provided by Video Decoders */ - OMX_TI_RescalingInfo, /**< 0x7F000018 Used for width/height rescaling info provided by Video Decoders */ - OMX_TI_WhiteBalanceOverWrite, /**< 0x7F000019 Used for manual AWB settings */ - OMX_TI_ExtraData_Count, - OMX_TI_ExtraData_Max = OMX_TI_ExtraData_Count - 1, -} OMX_EXT_EXTRADATATYPE; - - -/** - * Enable Extra-data on a specific port. - * - * - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port on which this extra data to be assosiated - * eExtraDataType : Extra data type - * bEnable : Eneble/Disable this extra-data through port. - * - */ -typedef struct OMX_CONFIG_EXTRADATATYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_EXT_EXTRADATATYPE eExtraDataType; - OMX_TI_CAMERAVIEWTYPE eCameraView; - OMX_BOOL bEnable; -} OMX_CONFIG_EXTRADATATYPE; - -/** - * JPEG header type - * */ - -typedef enum OMX_JPEGHEADERTYPE{ - OMX_NoHeader = 0, - OMX_JFIF, - OMX_EXIF -}OMX_JPEGHEADERTYPE; -/** - * Re-start marker configuration - * - * - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port on which this extra data to be assosiated - * eJpegHeaderType : JPEG header type EXIF, JFIF, or No heeader. - */ - -typedef struct OMX_CONFIG_JPEGHEEADERTYPE{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_JPEGHEADERTYPE eJpegHeaderType; -}OMX_CONFIG_JPEGHEEADERTYPE; - -/** - * Re-start marker configuration - * - * - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port on which this extra data to be assosiated - * nRstInterval : interval at which RST markers are to be inserted. - * bEnable : Eneble/Disable this RST marker insertion feature. - * - */ - -typedef struct OMX_CONFIG_RSTMARKER{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nRstInterval; - OMX_BOOL nEnable; -}OMX_CONFIG_RSTMARKER; - -/** - * Enable Extra-data on a specific port. - * - * - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nMaxSize : max size - * - * - */ -typedef struct OMX_IMAGE_JPEGMAXSIZE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nMaxSize; -} OMX_IMAGE_JPEGMAXSIZE; - - -typedef enum OMX_IMAGESTAMPOPERATION{ - OMX_NewImageStamp = 0, - OMX_Continuation -}OMX_IMAGESTAMPOPERATION; - - -/** - * Enable Extra-data on a specific port. - * - * - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nMaxSize : max size - * - * - */ -typedef struct OMX_PARAM_IMAGESTAMPOVERLAYTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_IMAGESTAMPOPERATION nOp; - OMX_U32 nLeft; - OMX_U32 nTop; - OMX_U32 nHeight; - OMX_U32 nWidth; - OMX_COLOR_FORMATTYPE eFormat; - OMX_U8 * pBitMap; -} OMX_PARAM_IMAGESTAMPOVERLAYTYPE; - - -/** - * Enable Extra-data on a specific port. - * - * - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nMaxSize : max size - * - * - */ -typedef struct OMX_PARAM_THUMBNAILTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nHeight; - OMX_U32 nWidth; - OMX_IMAGE_CODINGTYPE eCompressionFormat; - OMX_COLOR_FORMATTYPE eColorFormat; - OMX_U32 nQuality; - OMX_U32 nMaxSize; -} OMX_PARAM_THUMBNAILTYPE; - -/** - * Red-Eye Removal Enum - */ -typedef enum OMX_REDEYEREMOVALTYPE{ - OMX_RedEyeRemovalOff = 0, /** No red eye removal*/ - OMX_RedEyeRemovalOn, /** Red eye removal on*/ - OMX_RedEyeRemovalAuto, /** Red eye removal will be done automatically when detected*/ - OMX_RedEyeRemovalKhronosExtensions = 0x6F000000, /** Reserved region for introducing Khronos Standard Extensions*/ - OMX_RedEyeRemovalVendorStartUnused = 0x7F000000, /** Reserved region for introducing Vendor Extensions*/ - OMX_RedEyeRemovalMax = 0x7FFFFFFF -}OMX_REDEYEREMOVALTYPE; - -/** - * Enable Extra-data on a specific port. - * - * - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nLeft: is the leftmost coordinate of the detection area rectangle (such as face region). - * nTop: is the topmost coordinate of the detection area rectangle (such as face region). - * nWidth: is the width of the detection area rectangle in pixels. - * nHeight: is the height of the detection area rectangle in pixels. - * nARGBEyeColor indicates a 32-bit eye color to replace the red-eye, where bits 0-7 are blue, bits 15-8 are green, bits 24-16 are red, and bits 31-24 are for alpha. When all zero indicates automatic choice. - - * - */ -typedef struct OMX_CONFIG_REDEYEREMOVALTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_S32 nLeft; - OMX_S32 nTop; - OMX_U32 nWidth; - OMX_U32 nHeight; - OMX_U32 nARGBEyeColor; - OMX_REDEYEREMOVALTYPE eMode; -} OMX_CONFIG_REDEYEREMOVALTYPE; - - - - - - -/** - * Video capture YUV Range Enum - */ -typedef enum OMX_VIDEOYUVRANGETYPE{ - OMX_ITURBT601 = 0, - OMX_Full8Bit, - OMX_VideoYUVRangeKhronosExtensions = 0x6F000000, /** Reserved region for introducing Khronos Standard Extensions*/ - OMX_VideoYUVRangeVendorStartUnused = 0x7F000000, /** Reserved region for introducing Vendor Extensions*/ - OMX_VideoYUVRangeMax = 0x7FFFFFFF -}OMX_VIDEOYUVRANGETYPE; - -/** - * Enable Extra-data on a specific port. - * - * - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * - */ -typedef struct OMX_PARAM_VIDEOYUVRANGETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEOYUVRANGETYPE eYUVRange; -} OMX_PARAM_VIDEOYUVRANGETYPE; - -/** - * Video noise filter mode range enum - */ -typedef enum OMX_VIDEONOISEFILTERMODETYPE{ - OMX_VideoNoiseFilterModeOff = 0, - OMX_VideoNoiseFilterModeOn, - OMX_VideoNoiseFilterModeAuto, - OMX_VideoNoiseFilterModeExtensions = 0x6F000000, /** Reserved region for introducing Khronos Standard Extensions */ - OMX_VideoNoiseFilterModeStartUnused = 0x7F000000, /** Reserved region for introducing Vendor Extensions */ - OMX_VideoNoiseFilterModeMax = 0x7FFFFFFF -} OMX_VIDEONOISEFILTERMODETYPE; - -/** - * Enable video noise filter. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eMode : Video noise filter mode (on/off/auto) - */ -typedef struct OMX_PARAM_VIDEONOISEFILTERTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEONOISEFILTERMODETYPE eMode; -} OMX_PARAM_VIDEONOISEFILTERTYPE; - - -/** - * High ISO Noise filter mode range enum - */ -typedef enum OMX_ISONOISEFILTERMODETYPE{ - OMX_ISONoiseFilterModeOff = 0, - OMX_ISONoiseFilterModeOn, - OMX_ISONoiseFilterModeAuto, - OMX_ISONoiseFilterModeExtensions = 0x6F000000, /** Reserved region for introducing Khronos Standard Extensions */ - OMX_ISONoiseFilterModeStartUnused = 0x7F000000, /** Reserved region for introducing Vendor Extensions */ - OMX_ISONoiseFilterModeMax = 0x7FFFFFFF -} OMX_ISONOISEFILTERMODETYPE; - -/** - * Enable ISO noise filter. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eMode : ISO noise filter (NSF2 is used) mode (on/off/auto) - */ -typedef struct OMX_PARAM_ISONOISEFILTERTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_ISONOISEFILTERMODETYPE eMode; -} OMX_PARAM_ISONOISEFILTERTYPE; - -/** - * Structure used to to call OMX_GetParams() for each - * increment of "Index" starting with "0" - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nIndex : Index of the sDCCURI 0..MAX_URI_LENGTH - * sDCCURI : Look-up table containing strings. Ends with '\0' - */ -typedef struct OMX_TI_PARAM_DCCURIINFO { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nIndex; - OMX_S8 sDCCURI[MAX_URI_LENGTH]; -} OMX_TI_PARAM_DCCURIINFO; - -/** - * Structure used to configure DCC buffer - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nDCCURIBuffSize : Size of the pDCCURIBuff in bytes - * pDCCURIBuff : Pointer to a buffer - */ -typedef struct OMX_TI_PARAM_DCCURIBUFFER { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nDCCURIBuffSize; - OMX_U8 *pDCCURIBuff; -} OMX_TI_PARAM_DCCURIBUFFER; - -/** - * Manual White Balance color temperature - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nColorTemperature : Color Temperature in K - */ -typedef struct OMX_TI_CONFIG_WHITEBALANCECOLORTEMPTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nColorTemperature; -} OMX_TI_CONFIG_WHITEBALANCECOLORTEMPTYPE; - -/** - * Focus spot weighting range enum - */ -typedef enum OMX_TI_CONFIG_FOCUSSPOTMODETYPE { - OMX_FocusSpotDefault = 0, /** Makes CommonFocusRegion to be used. */ - OMX_FocusSpotSinglecenter, - OMX_FocusSpotMultiNormal, - OMX_FocusSpotMultiAverage, - OMX_FocusSpotMultiCenter, - OMX_FocusSpotExtensions = 0x6F000000, /** Reserved region for introducing Khronos Standard Extensions */ - OMX_FocusSpotModeStartUnused = 0x7F000000, /** Reserved region for introducing Vendor Extensions */ - OMX_FocusSpotModeMax = 0x7FFFFFFF -} OMX_TI_CONFIG_FOCUSSPOTMODETYPE; - -/** - * Focus Spot Weighting configuration. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eMode : Spot Weighting mode - */ -typedef struct OMX_TI_CONFIG_FOCUSSPOTWEIGHTINGTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_CONFIG_FOCUSSPOTMODETYPE eMode; -} OMX_TI_CONFIG_FOCUSSPOTWEIGHTINGTYPE; - -/** - * Enumeration of possible Exposure control types for OMX_EXPOSURECONTROLTYPE - */ -typedef enum OMX_TI_EXTEXPOSURECONTROLTYPE { - OMX_TI_ExposureControlVeryLong = OMX_ExposureControlVendorStartUnused + 1 -} OMX_TI_EXTEXPOSURECONTROLTYPE; - -/** - * Variable frame rate configuration. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * xMinFramerate : Minimum variable frame rate value - */ -typedef struct OMX_TI_PARAM_VARFRAMERATETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 xMinFramerate; -} OMX_TI_PARAM_VARFRAMERATETYPE; - -/** - * Exposure config for right frame - */ -typedef struct OMX_TI_CONFIG_EXPOSUREVALUERIGHTTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nApertureFNumber; /**< e.g. nApertureFNumber = 2 implies "f/2" - Q16 format */ - OMX_U32 nShutterSpeedMsec; /**< Shutterspeed in milliseconds */ - OMX_U32 nSensitivity; /**< e.g. nSensitivity = 100 implies "ISO 100" */ -} OMX_TI_CONFIG_EXPOSUREVALUERIGHTTYPE; - -/** - * Auto Convergence mode enum - */ -typedef enum OMX_TI_AUTOCONVERGENCEMODETYPE { - OMX_TI_AutoConvergenceModeDisable, - OMX_TI_AutoConvergenceModeFrame, - OMX_TI_AutoConvergenceModeCenter, - OMX_TI_AutoConvergenceModeFocusFaceTouch, - OMX_TI_AutoConvergenceModeManual, - OMX_TI_AutoConvergenceExtensions = 0x6F000000, /** Reserved region for introducing Khronos Standard Extensions */ - OMX_TI_AutoConvergenceStartUnused = 0x7F000000, /** Reserved region for introducing Vendor Extensions */ - OMX_TI_AutoConvergenceModeMax = 0x7FFFFFFF -} OMX_TI_AUTOCONVERGENCEMODETYPE; - -/** - * Variable farame rate configuration. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eACMode : Auto convergence mode - * nManualConverence : Manual Converence value - * nACProcWinStartX : Start X AC Window - * nACProcWinStartY : Start Y AC Window - * nACProcWinWidth : Width of AC Window - * nACProcWinHeight : Height of AC Window - * bACStatus : output status from AL alg - */ -typedef struct OMX_TI_CONFIG_CONVERGENCETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_AUTOCONVERGENCEMODETYPE eACMode; - OMX_S32 nManualConverence; - OMX_U32 nACProcWinStartX; - OMX_U32 nACProcWinStartY; - OMX_U32 nACProcWinWidth; - OMX_U32 nACProcWinHeight; - OMX_BOOL bACStatus; -} OMX_TI_CONFIG_CONVERGENCETYPE; - -/** - * Camera specific version. - * - * STRUCT MEMBERS: - * nBranch : Branch - * nCommitID : Commit ID - * nBuildDateTime : Build date and time - * nExtraInfo : rederved for future use - */ -typedef struct OMX_TI_CAMERASPECVERSIONTYPE { - OMX_U8 nBranch[64]; - OMX_U8 nCommitID[64]; - OMX_U8 nBuildDateTime[64]; - OMX_U8 nExtraInfo[64]; -} OMX_TI_CAMERASPECVERSIONTYPE; - -/** - * Stereo frame layout enum - */ -typedef enum OMX_TI_STEREOFRAMELAYOUTTYPE { - OMX_TI_StereoFrameLayout2D, - OMX_TI_StereoFrameLayoutTopBottom, - OMX_TI_StereoFrameLayoutLeftRight, - OMX_TI_StereoFrameLayoutMax = 0x7FFFFFFF -} OMX_TI_STEREOFRAMELAYOUTTYPE; - -/** - * Camera frame layout type. - * - * STRUCT MEMBERS: - * eFrameLayout : frame layout - * nSubsampleRatio : subsample ratio - */ -typedef struct OMX_TI_FRAMELAYOUTTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_STEREOFRAMELAYOUTTYPE eFrameLayout; - OMX_U32 nSubsampleRatio; /** Subsampling ratio, Q15.7 */ -} OMX_TI_FRAMELAYOUTTYPE; - -/** - * The OMX_TI_COLOR_FORMATTYPE enumeration is used to define the - * extended color format types. - */ -typedef enum OMX_TI_COLOR_FORMATTYPE { - OMX_TI_COLOR_FormatYUV420PackedSemiPlanarInterlaced = - (OMX_COLOR_FORMATTYPE) OMX_COLOR_FormatVendorStartUnused + 1, - OMX_TI_COLOR_FormatRawBayer10bitStereo = - OMX_COLOR_FormatVendorStartUnused + 2, /**< 10 bit raw for stereo */ -/* OMX_TI_COLOR_FormatYUV420PackedSemiPlanar = - (OMX_COLOR_FORMATTYPE) OMX_COLOR_FormatVendorStartUnused + 0x100, *//* 0x100 is used since it is the corresponding HAL pixel fromat */ -/* OMX_COLOR_FormatAndroidOpaque = - (OMX_COLOR_FORMATTYPE) OMX_COLOR_FormatVendorStartUnused + 0x789 *//**< Platform specified opaque format set to unique value 0x789*/ -} OMX_TI_COLOR_FORMATTYPE; - -/** - * The OMX_TI_EXIFTAGSTATUS enumeration is used to define the - * tag status types. - */ -typedef enum OMX_TI_EXIFTAGSTATUS { - OMX_TI_TagReadOnly, /**< implies this tag is generated within omx-camera >*/ - OMX_TI_TagReadWrite, /**< implies this tag can be overwritten by client >*/ - OMX_TI_TagUpdated, /**< client has to use this to indicate the specific tag is overwritten >*/ - OMX_TI_ExifStatus_Max = 0x7fffffff -} OMX_TI_EXIFTAGSTATUS; - -typedef struct OMX_TI_CONFIG_EXIF_TAGS { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_EXIFTAGSTATUS eStatusImageWidth; - OMX_U32 ulImageWidth; - OMX_TI_EXIFTAGSTATUS eStatusImageHeight; - OMX_U32 ulImageHeight; - OMX_TI_EXIFTAGSTATUS eStatusBitsPerSample; - OMX_U16 usBitsPerSample[3]; - OMX_TI_EXIFTAGSTATUS eStatusCompression; - OMX_U16 usCompression; - OMX_TI_EXIFTAGSTATUS eStatusPhotometricInterpretation; - OMX_U16 usPhotometricInterpretation; - OMX_TI_EXIFTAGSTATUS eStatusOrientation; - OMX_U16 usOrientation; - OMX_TI_EXIFTAGSTATUS eStatusSamplesPerPixel; - OMX_U16 usSamplesPerPixel; - OMX_TI_EXIFTAGSTATUS eStatusPlanarConfiguration; - OMX_U16 usPlanarConfiguration; - OMX_TI_EXIFTAGSTATUS eStatusYCbCrSubSampling; - OMX_U16 usYCbCrSubSampling[2]; - OMX_TI_EXIFTAGSTATUS eStatusYCbCrPositioning; - OMX_U16 usYCbCrPositioning; - OMX_TI_EXIFTAGSTATUS eStatusXResolution; - OMX_U32 ulXResolution[2]; - OMX_TI_EXIFTAGSTATUS eStatusYResolution; - OMX_U32 ulYResolution[2]; - OMX_TI_EXIFTAGSTATUS eStatusResolutionUnit; - OMX_U16 usResolutionUnit; - - OMX_TI_EXIFTAGSTATUS eStatusRowsPerStrip; - OMX_U32 ulRowsPerStrip; - OMX_TI_EXIFTAGSTATUS eStatusDataSize; - OMX_U32 ulDataSize; - - OMX_TI_EXIFTAGSTATUS eStatusTransferFunction; - OMX_U16 usTransferFunction[3*256]; - OMX_TI_EXIFTAGSTATUS eStatusWhitePoint; - OMX_U32 ulWhitePoint[4]; //2x2 - OMX_TI_EXIFTAGSTATUS eStatusPrimaryChromaticities; - OMX_U32 ulPrimaryChromaticities[12]; //2x6 - OMX_TI_EXIFTAGSTATUS eStatusYCbCrCoefficients; - OMX_U32 ulYCbCrCoefficients[6]; //2x3 - OMX_TI_EXIFTAGSTATUS eStatusReferenceBlackWhite; - OMX_U32 ulReferenceBlackWhite[12]; //2x6 - OMX_TI_EXIFTAGSTATUS eStatusDateTime; - OMX_S8* pDateTimeBuff; - OMX_U32 ulDateTimeBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusImageDescription; - OMX_S8* pImageDescriptionBuff; - OMX_U32 ulImageDescriptionBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusMake; - OMX_S8* pMakeBuff; - OMX_U32 ulMakeBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusModel; - OMX_S8* pModelBuff; - OMX_U32 ulModelBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusSoftware; - OMX_S8* pSoftwareBuff; - OMX_U32 ulSoftwareBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusArtist; - OMX_S8* pArtistBuff; - OMX_U32 ulArtistBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusCopyright; - OMX_S8* pCopyrightBuff; - OMX_U32 ulCopyrightBuffSizeBytes; - - OMX_TI_EXIFTAGSTATUS eStatusExifVersion; - OMX_S8 cExifVersion[4]; - OMX_TI_EXIFTAGSTATUS eStatusFlashpixVersion; - OMX_S8 cFlashpixVersion[4]; - OMX_TI_EXIFTAGSTATUS eStatusColorSpace; - OMX_U16 usColorSpace; - OMX_TI_EXIFTAGSTATUS eStatusComponentsConfiguration; - OMX_S8 cComponentsConfiguration[4]; - OMX_TI_EXIFTAGSTATUS eStatusCompressedBitsPerPixel; - OMX_U32 ulCompressedBitsPerPixel[2]; - OMX_TI_EXIFTAGSTATUS eStatusPixelXDimension; - OMX_U32 ulPixelXDimension; - OMX_TI_EXIFTAGSTATUS eStatusPixelYDimension; - OMX_U32 ulPixelYDimension; - OMX_TI_EXIFTAGSTATUS eStatusMakerNote; - OMX_S8* pMakerNoteBuff; - OMX_U32 ulMakerNoteBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusUserComment; - OMX_S8* pUserCommentBuff; - OMX_U32 ulUserCommentBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusRelatedSoundFile; - OMX_S8 cRelatedSoundFile[13]; - OMX_TI_EXIFTAGSTATUS eStatusDateTimeOriginal; - OMX_S8* pDateTimeOriginalBuff; - OMX_U32 ulDateTimeOriginalBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusDateTimeDigitized; - OMX_S8* pDateTimeDigitizedBuff; - OMX_U32 ulDateTimeDigitizedBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusSubSecTime; - OMX_S8* pSubSecTimeBuff; - OMX_U32 ulSubSecTimeBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusSubSecTimeOriginal; - OMX_S8* pSubSecTimeOriginalBuff; - OMX_U32 ulSubSecTimeOriginalBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusSubSecTimeDigitized; - OMX_S8* pSubSecTimeDigitizedBuff; - OMX_U32 ulSubSecTimeDigitizedBuffSizeBytes; - - OMX_TI_EXIFTAGSTATUS eStatusExposureTime; - OMX_U32 ulExposureTime[2]; - OMX_TI_EXIFTAGSTATUS eStatusFNumber; - OMX_U32 ulFNumber[2]; - OMX_TI_EXIFTAGSTATUS eStatusExposureProgram; - OMX_U16 usExposureProgram; - OMX_TI_EXIFTAGSTATUS eStatusSpectralSensitivity; - OMX_S8* pSpectralSensitivityBuff; - OMX_U32 ulSpectralSensitivityBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusISOCount; - OMX_U16 usISOCount; - OMX_TI_EXIFTAGSTATUS eStatusISOSpeedRatings; - OMX_U16* pISOSpeedRatings; - OMX_TI_EXIFTAGSTATUS eStatusOECF; - OMX_S8* pOECFBuff; - OMX_U32 ulOECFBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusShutterSpeedValue; - OMX_S32 slShutterSpeedValue[2]; - OMX_TI_EXIFTAGSTATUS eStatusApertureValue; - OMX_U32 ulApertureValue[2]; - OMX_TI_EXIFTAGSTATUS eStatusBrightnessValue; - OMX_S32 slBrightnessValue[2]; - OMX_TI_EXIFTAGSTATUS eStatusExposureBiasValue; - OMX_S32 slExposureBiasValue[2]; - OMX_TI_EXIFTAGSTATUS eStatusMaxApertureValue; - OMX_U32 ulMaxApertureValue[2]; - OMX_TI_EXIFTAGSTATUS eStatusSubjectDistance; - OMX_U32 ulSubjectDistance[2]; - OMX_TI_EXIFTAGSTATUS eStatusMeteringMode; - OMX_U16 usMeteringMode; - OMX_TI_EXIFTAGSTATUS eStatusLightSource; - OMX_U16 usLightSource; - OMX_TI_EXIFTAGSTATUS eStatusFlash; - OMX_U16 usFlash; - OMX_TI_EXIFTAGSTATUS eStatusFocalLength; - OMX_U32 ulFocalLength[2]; - OMX_TI_EXIFTAGSTATUS eStatusSubjectArea; - OMX_U16 usSubjectArea[4]; - OMX_TI_EXIFTAGSTATUS eStatusFlashEnergy; - OMX_U32 ulFlashEnergy[2]; - OMX_TI_EXIFTAGSTATUS eStatusSpatialFrequencyResponse; - OMX_S8* pSpatialFrequencyResponseBuff; - OMX_U32 ulSpatialFrequencyResponseBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusFocalPlaneXResolution; - OMX_U32 ulFocalPlaneXResolution[2]; - OMX_TI_EXIFTAGSTATUS eStatusFocalPlaneYResolution; - OMX_U32 ulFocalPlaneYResolution[2]; - OMX_TI_EXIFTAGSTATUS eStatusFocalPlaneResolutionUnit; - OMX_U16 usFocalPlaneResolutionUnit; - OMX_TI_EXIFTAGSTATUS eStatusSubjectLocation; - OMX_U16 usSubjectLocation[2]; - OMX_TI_EXIFTAGSTATUS eStatusExposureIndex; - OMX_U32 ulExposureIndex[2]; - OMX_TI_EXIFTAGSTATUS eStatusSensingMethod; - OMX_U16 usSensingMethod; - OMX_TI_EXIFTAGSTATUS eStatusFileSource; - OMX_S8 cFileSource; - OMX_TI_EXIFTAGSTATUS eStatusSceneType; - OMX_S8 cSceneType; - OMX_TI_EXIFTAGSTATUS eStatusCFAPattern; - OMX_S8* pCFAPatternBuff; - OMX_U32 ulCFAPatternBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusCustomRendered; - OMX_U16 usCustomRendered; - OMX_TI_EXIFTAGSTATUS eStatusExposureMode; - OMX_U16 usExposureMode; - OMX_TI_EXIFTAGSTATUS eStatusWhiteBalance; - OMX_U16 usWhiteBalance; - OMX_TI_EXIFTAGSTATUS eStatusDigitalZoomRatio; - OMX_U32 ulDigitalZoomRatio[2]; - OMX_TI_EXIFTAGSTATUS eStatusFocalLengthIn35mmFilm; - OMX_U16 usFocalLengthIn35mmFilm; - OMX_TI_EXIFTAGSTATUS eStatusSceneCaptureType; - OMX_U16 usSceneCaptureType; - OMX_TI_EXIFTAGSTATUS eStatusGainControl; - OMX_U16 usGainControl; - OMX_TI_EXIFTAGSTATUS eStatusContrast; - OMX_U16 usContrast; - OMX_TI_EXIFTAGSTATUS eStatusSaturation; - OMX_U16 usSaturation; - OMX_TI_EXIFTAGSTATUS eStatusSharpness; - OMX_U16 usSharpness; - OMX_TI_EXIFTAGSTATUS eStatusDeviceSettingDescription; - OMX_S8* pDeviceSettingDescriptionBuff; - OMX_U32 ulDeviceSettingDescriptionBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusSubjectDistanceRange; - OMX_U16 usSubjectDistanceRange; - - OMX_TI_EXIFTAGSTATUS eStatusImageUniqueID; - OMX_S8 cImageUniqueID[33]; - OMX_U8* pPrivateNextIFDPointer; //Should not be used by the application - OMX_U8* pPrivateThumbnailSize; //Should not be used by the application - OMX_U8* pPrivateTiffHeaderPointer; //Should not be used by the application - - OMX_TI_EXIFTAGSTATUS eStatusGpsVersionId; - OMX_U8 ucGpsVersionId[4]; - OMX_TI_EXIFTAGSTATUS eStatusGpslatitudeRef; - OMX_S8 cGpslatitudeRef[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsLatitude; - OMX_U32 ulGpsLatitude[6]; - OMX_TI_EXIFTAGSTATUS eStatusGpsLongitudeRef; - OMX_S8 cGpsLongitudeRef[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsLongitude; - OMX_U32 ulGpsLongitude[6]; - OMX_TI_EXIFTAGSTATUS eStatusGpsAltitudeRef; - OMX_U8 ucGpsAltitudeRef; - OMX_TI_EXIFTAGSTATUS eStatusGpsAltitude; - OMX_U32 ulGpsAltitude[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsTimeStamp; - OMX_U32 ulGpsTimeStamp[6]; - OMX_TI_EXIFTAGSTATUS eStatusGpsSatellites; - OMX_S8* pGpsSatellitesBuff; - OMX_U32 ulGpsSatellitesBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusGpsStatus; - OMX_S8 cGpsStatus[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsMeasureMode; - OMX_S8 cGpsMeasureMode[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsDop; - OMX_U32 ulGpsDop[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsSpeedRef; - OMX_S8 cGpsSpeedRef[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsSpeed; - OMX_U32 ulGpsSpeed[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsTrackRef; - OMX_S8 cGpsTrackRef[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsTrack; - OMX_U32 ulGpsTrack[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsImgDirectionRef; - OMX_S8 cGpsImgDirectionRef[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsImgDirection; - OMX_U32 ulGpsImgDirection[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsMapDatum; - OMX_S8* pGpsMapDatumBuff; - OMX_U32 ulGpsMapDatumBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusGpsDestLatitudeRef; - OMX_S8 cGpsDestLatitudeRef[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsDestLatitude; - OMX_U32 ulGpsDestLatitude[6]; - OMX_TI_EXIFTAGSTATUS eStatusGpsDestLongitudeRef; - OMX_S8 cGpsDestLongitudeRef[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsDestLongitude; - OMX_U32 ulGpsDestLongitude[6]; - OMX_TI_EXIFTAGSTATUS eStatusGpsDestBearingRef; - OMX_S8 cGpsDestBearingRef[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsDestBearing; - OMX_U32 ulGpsDestBearing[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsDestDistanceRef; - OMX_S8 cGpsDestDistanceRef[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsDestDistance; - OMX_U32 ulGpsDestDistance[2]; - OMX_TI_EXIFTAGSTATUS eStatusGpsProcessingMethod; - OMX_S8* pGpsProcessingMethodBuff; - OMX_U32 ulGpsProcessingMethodBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusGpsAreaInformation; - OMX_S8* pGpsAreaInformationBuff; - OMX_U32 ulGpsAreaInformationBuffSizeBytes; - OMX_TI_EXIFTAGSTATUS eStatusGpsDateStamp; - OMX_S8 cGpsDateStamp[11]; - OMX_TI_EXIFTAGSTATUS eStatusGpsDifferential; - OMX_U16 usGpsDifferential; -} OMX_TI_CONFIG_EXIF_TAGS; - -/** - * Structure used to configure current OMX_TI_SENMOUNT_TYPE - * - * @param nSenId - * @param nRotation - */ -typedef struct OMX_TI_SENMOUNT_TYPE { - OMX_U32 nSenId; - OMX_U32 nRotation; -}OMX_TI_SENMOUNT_TYPE; - -/** - * Structure used to configure current OMX_TI_VARFPSTYPE - * - * @param nVarFPSMin Number of the smallest FPS supported. - * @param nVarFPSMax Number of the biggest FPS supported. - */ -typedef struct OMX_TI_VARFPSTYPE { - OMX_U32 nVarFPSMin; - OMX_U32 nVarFPSMax; -} OMX_TI_VARFPSTYPE; - -/** - * Structure used to configure current OMX_TI_CONFIG_SHAREDBUFFER - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nSharedBuffSize : Size of the pSharedBuff in bytes - * pSharedBuff : Pointer to a buffer - */ -typedef struct OMX_TI_CONFIG_SHAREDBUFFER { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nSharedBuffSize; - OMX_U8* pSharedBuff; -} OMX_TI_CONFIG_SHAREDBUFFER; - -/** - * Structure used to configure current OMX_TI_CAPRESTYPE - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nWidthMin : Number of the smallest width supported - * nHeightMin : Number of the smallest height supported - * nWidthMax : Number of the biggest width supported - * nHeightMax : Number of the biggest height supported - */ -typedef struct OMX_TI_CAPRESTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nWidthMin; // smallest width supported - OMX_U32 nHeightMin; // smallest height supported - OMX_U32 nWidthMax; // biggest width supported - OMX_U32 nHeightMax; // biggest height supported -} OMX_TI_CAPRESTYPE; - -/** - * Structure used to configure current OMX_TI_CAPTYPE - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * ulPreviewFormatCount : Number of the supported preview pixelformat count - * ePreviewFormats : Array containing the supported preview pixelformat count - * ulImageFormatCount : Number of the supported image pixelformat count - * eImageFormats : Array containing the supported image pixelformat count - * tPreviewResRange : Supported preview resolution range - * tImageResRange : Supported image resolution range - * tThumbResRange : Supported thumbnail resolution range - * ulWhiteBalanceCount : Supported whitebalance mode count - * eWhiteBalanceModes : Array containing the whitebalance modes - * ulColorEffectCount : Supported effects count - * eColorEffects : Array containing the supported effects - * xMaxWidthZoom : Fixed point value stored as Q16 representing the maximum value for the Zoom allowed on Width - * xMaxHeightZoom : Fixed point value stored as Q16 representing the maximum value for the Zoom allowed on Height - * ulFlickerCount : Number of the supported anti-flicker modes - * eFlicker : Array containing the supported anti-flicker modes - * ulExposureModeCount : Number of the supported exposure modes - * eExposureModes : Array containing the supported exposure modes - * bLensDistortionCorrectionSupported : Flag for Lens Distortion Correction Algorithm support - * bISONoiseFilterSupported : Flag for Noise Filter Algorithm support - * xEVCompensationMin : Fixed point value stored as Q16 representing the EVCompensation minumum allowed value - * xEVCompensationMax : Fixed point value stored as Q16 representing the EVCompensation maximum allowed value - * nSensitivityMax : nSensitivityMax = 100 implies maximum supported equal to "ISO 100" - * ulFocusModeCount : Number of the supported focus modes - * eFocusModes : Array containing the supported focus modes - * ulSceneCount : Number of the supported scenes - * eSceneModes : Array containing the supported scenes - * ulFlashCount : Number of the supported flash modes - * eFlashModes : Array containing the supported flash modes - * xFramerateMin : Fixed point value stored as Q16 representing the minimum framerate allowed - * xFramerateMax : Fixed point value stored as Q16 representing the maximum framerate allowed - * bContrastSupported : Flag showing if the contrast is supported - * bSaturationSupported : Flag showing if the saturation is supported - * bBrightnessSupported : Flag showing if the brightness is supported - * bProcessingLevelSupported : Flag showing if the processing level is supported - * bQFactorSupported : Flag showing if the QFactor is supported - * ulPrvVarFPSModesCount : Number of preview FPS modes - * tPrvVarFPSModes : Preview FPS modes - * ulCapVarFPSModesCount : Number of capture FPS modes - * tCapVarFPSModes : Capture FPS modes - * tSenMounting : Sensor mount information - */ -typedef struct OMX_TI_CAPTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U16 ulPreviewFormatCount; // supported preview pixelformat count - OMX_COLOR_FORMATTYPE ePreviewFormats[100]; - OMX_U16 ulImageFormatCount; // supported image pixelformat count - OMX_COLOR_FORMATTYPE eImageFormats[100]; - OMX_TI_CAPRESTYPE tPreviewResRange; // supported preview resolution range - OMX_TI_CAPRESTYPE tImageResRange; // supported image resolution range - OMX_TI_CAPRESTYPE tThumbResRange; // supported thumbnail resolution range - OMX_U16 ulWhiteBalanceCount; // supported whitebalance mode count - OMX_WHITEBALCONTROLTYPE eWhiteBalanceModes[100]; - OMX_U16 ulColorEffectCount; // supported effects count - OMX_IMAGEFILTERTYPE eColorEffects[100]; - OMX_S32 xMaxWidthZoom; // Fixed point value stored as Q16 - OMX_S32 xMaxHeightZoom; // Fixed point value stored as Q16 - OMX_U16 ulFlickerCount; // supported anti-flicker mode count - OMX_COMMONFLICKERCANCELTYPE eFlicker[100]; - OMX_U16 ulExposureModeCount; // supported exposure mode count - OMX_EXPOSURECONTROLTYPE eExposureModes[100]; - OMX_BOOL bLensDistortionCorrectionSupported; - OMX_BOOL bISONoiseFilterSupported; - OMX_S32 xEVCompensationMin; // Fixed point value stored as Q16 - OMX_S32 xEVCompensationMax; // Fixed point value stored as Q16 - OMX_U32 nSensitivityMax; // nSensitivityMax = 100 implies maximum supported equal to "ISO 100" - OMX_U16 ulFocusModeCount; // supported focus mode count - OMX_IMAGE_FOCUSCONTROLTYPE eFocusModes[100]; - OMX_U16 ulSceneCount; // supported scene count - OMX_SCENEMODETYPE eSceneModes[100]; - OMX_U16 ulFlashCount; // supported flash modes count - OMX_IMAGE_FLASHCONTROLTYPE eFlashModes[100]; - OMX_U32 xFramerateMin; // Fixed point value stored as Q16 - OMX_U32 xFramerateMax; // Fixed point value stored as Q16 - OMX_BOOL bContrastSupported; - OMX_BOOL bSaturationSupported; - OMX_BOOL bBrightnessSupported; - OMX_BOOL bProcessingLevelSupported; - OMX_BOOL bQFactorSupported; - OMX_U16 ulPrvVarFPSModesCount; // supported variable FPS preview modes count - OMX_TI_VARFPSTYPE tPrvVarFPSModes[10]; - OMX_U16 ulCapVarFPSModesCount; // supported variable FPS capture modes count - OMX_TI_VARFPSTYPE tCapVarFPSModes[10]; - OMX_TI_SENMOUNT_TYPE tSenMounting; - OMX_U16 ulAlgoAreasFocusCount; // supported number of AlgoAreas for focus areas - OMX_U16 ulAlgoAreasExposureCount; // supported number of AlgoAreas for exposure areas -} OMX_TI_CAPTYPE; - - - -/** - * Defines 3A Face priority mode. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bAwbFaceEnable : Enable Face priority for Auto White Balance - * bAeFaceEnable : Enable Face priority for Auto Exposure - * bAfFaceEnable : Enable Face priority for Auto Focus - */ -typedef struct OMX_TI_CONFIG_3A_FACE_PRIORITY { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bAwbFaceEnable; - OMX_BOOL bAeFaceEnable; - OMX_BOOL bAfFaceEnable; -} OMX_TI_CONFIG_3A_FACE_PRIORITY; - -/** - * Defines 3A Region priority mode. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bAwbFaceEnable : Enable Region priority for Auto White Balance - * bAeFaceEnable : Enable Region priority for Auto Exposure - * bAfFaceEnable : Enable Region priority for Auto Focus - */ -typedef struct OMX_TI_CONFIG_3A_REGION_PRIORITY { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bAwbRegionEnable; - OMX_BOOL bAeRegionEnable; - OMX_BOOL bAfRegionEnable; -} OMX_TI_CONFIG_3A_REGION_PRIORITY; - -/* -* STRUCT MEMBERS: -* nSize : Size of the structure in bytes -* nVersion : OMX specification version information -* nPortIndex : Port that this structure applies to -* bAutoConvergence : Enable/Disable Auto Convergence -*/ -typedef struct OMX_TI_PARAM_AUTOCONVERGENCETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bAutoConvergence; -} OMX_TI_PARAM_AUTOCONVERGENCETYPE; - -/** - * Focus distance configuration - * - * STRUCT MEMBERS: - * nSize: Size of the structure in bytes - * nVersion: OMX specification version information - * nPortIndex: Port that this structure applies to - * nFocusDistanceNear : Specifies the near focus distance in mm ( 0 equals infinity ) - * nFocusDistanceOptimal : Specifies the optimal focus distance in mm ( 0 equals infinity ) - * nFocusDistanceFar : Specifies the far focus distance in mm ( 0 equals infinity ) - * nLensPosition : Specifies the current lens position in driver units - */ -typedef struct OMX_TI_CONFIG_FOCUSDISTANCETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nFocusDistanceNear; - OMX_U32 nFocusDistanceOptimal; - OMX_U32 nFocusDistanceFar; - OMX_S32 nLensPosition; -} OMX_TI_CONFIG_FOCUSDISTANCETYPE; - -/* -* STRUCT MEMBERS: -* nSize : Size of the structure in bytes -* nVersion : OMX specification version information -* nPortIndex : Port that this structure applies to -* pAAAskipBuff : Pointer to a buffer -* AAAskipBuffId : Id of the send buffer -* AAAskipBuffSize : Size of the sent buffer -*/ -typedef struct OMX_TI_CONFIG_AAASKIPBUFFERTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_PTR pAAAskipBuff; - OMX_U32 AAAskipBuffId; - OMX_U32 AAAskipBuffSize; -} OMX_TI_CONFIG_AAASKIPBUFFERTYPE; - - -/** - * The OMX_TI_BRIGHTNESSCONTRASTCRTLTYPE enumeration is used to define the - * brightness and contrast mode types. - */ -typedef enum OMX_TI_BRIGHTNESSCONTRASTCRTLTYPE { - OMX_TI_BceModeOff = 0, - OMX_TI_BceModeOn, - OMX_TI_BceModeAuto, - OMX_TI_BceModeMax = 0x7FFFFFFF -} OMX_TI_BRIGHTNESSCONTRASTCRTLTYPE; - -/** - * Local and global brightness contrast type. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eControl : Control field for GLBCE - */ -typedef struct OMX_TI_CONFIG_LOCAL_AND_GLOBAL_BRIGHTNESSCONTRASTTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TI_BRIGHTNESSCONTRASTCRTLTYPE eControl; -} OMX_TI_CONFIG_LOCAL_AND_GLOBAL_BRIGHTNESSCONTRASTTYPE; - -/** - * Uncompressed image operating mode configuration structure. - * - * @param nSize Size of the structure in bytes. - * @param nVersion OMX specification version information. - * @param xMin The minimum frame rate allowed. - * Units are Q16 frames per second. - * @param xMax The maximum frame rate allowed. - * Units are Q16 frames per second. - */ - -typedef struct OMX_TI_CONFIG_VARFRMRANGETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 xMin; - OMX_U32 xMax; -} OMX_TI_CONFIG_VARFRMRANGETYPE; - -/** -* A pointer to this struct is passed to the OMX_SetParameter when the extension -* index for the 'OMX.google.android.index.enableAndroidNativeBuffers' extension -* is given. -* The corresponding extension Index is OMX_TI_IndexUseNativeBuffers. -* This will be used to inform OMX about the presence of gralloc pointers instead -* of virtual pointers -*/ -typedef struct OMX_TI_PARAMUSENATIVEBUFFER { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnable; -} OMX_TI_PARAMUSENATIVEBUFFER; - -/** -* A pointer to this struct is passed to OMX_GetParameter when the extension -* index for the 'OMX.google.android.index.getAndroidNativeBufferUsage' -* extension is given. -* The corresponding extension Index is OMX_TI_IndexAndroidNativeBufferUsage. -* The usage bits returned from this query will be used to allocate the Gralloc -* buffers that get passed to the useAndroidNativeBuffer command. -*/ -typedef struct OMX_TI_PARAMNATIVEBUFFERUSAGE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nUsage; -} OMX_TI_PARAMNATIVEBUFFERUSAGE; - -/*==========================================================================*/ -/*! -@brief OMX_TI_PARAM_ENHANCEDPORTRECONFIG : Suport added to new port reconfig usage -@param bUsePortReconfigForCrop Enables port reconfig for crop. -@param bUsePortReconfigForPadding Enables port reconfig for padding -*/ -/*==========================================================================*/ - -typedef struct OMX_TI_PARAM_ENHANCEDPORTRECONFIG { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bUsePortReconfigForCrop; - OMX_BOOL bUsePortReconfigForPadding; -} OMX_TI_PARAM_ENHANCEDPORTRECONFIG; - -/** -* Define the frames queue len for ZSL -* -* STRUCT MEMBERS: -* nSize: Size of the structure in bytes -* nVersion: OMX specification version information -* nHistoryLen: History len in number of frames -*/ -typedef struct OMX_TI_PARAM_ZSLHISTORYLENTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nHistoryLen; -} OMX_TI_PARAM_ZSLHISTORYLENTYPE; - -/** -* Define the frame delay in ms for ZSL -* -* STRUCT MEMBERS: -* nSize: Size of the structure in bytes -* nVersion: OMX specification version information -* nDelay: Capture frame delay in ms -*/ -typedef struct OMX_TI_CONFIG_ZSLDELAYTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_S32 nDelay; -} OMX_TI_CONFIG_ZSLDELAYTYPE; - -/** - * AlogAreas purpose - * This type specifies the purpose of areas specified in OMX_ALGOAREASTYPE. - * */ -typedef enum OMX_ALGOAREAPURPOSE{ - OMX_AlgoAreaFocus = 0, // Multi region focus - OMX_AlgoAreaExposure, -}OMX_ALGOAREAPURPOSE; - -typedef struct OMX_ALGOAREA { - OMX_S32 nLeft; /**< The leftmost coordinate of the area rectangle */ - OMX_S32 nTop; /**< The topmost coordinate of the area rectangle */ - OMX_U32 nWidth; /**< The width of the area rectangle in pixels */ - OMX_U32 nHeight; /**< The height of the area rectangle in pixels */ - OMX_U32 nPriority; /**< Priority - ranges from 1 to 1000 */ -}OMX_ALGOAREA; - -/** - * Algorythm areas type - * This type defines areas for Multi Region Focus, - * or another algorithm region parameters, - * such as Multi Region Auto Exposure. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port index - * tAreaPosition : Area definition - coordinates and purpose - Multi Region Focus, Auto Exposure, etc. - * nNumAreas : Number of areas defined in the array - * nAlgoAreaPurpose : Algo area purpose - eg. Multi Region Focus is OMX_AlgoAreaFocus - */ -typedef struct OMX_ALGOAREASTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - - OMX_U32 nNumAreas; - OMX_ALGOAREA tAlgoAreas[MAX_ALGOAREAS]; - OMX_ALGOAREAPURPOSE nAlgoAreaPurpose; -} OMX_ALGOAREASTYPE; - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif - - diff --git a/domx/omx_core/inc/OMX_TI_Image.h b/domx/omx_core/inc/OMX_TI_Image.h deleted file mode 100755 index 4035218..0000000 --- a/domx/omx_core/inc/OMX_TI_Image.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * @file:OMX_TI_Image.h - * This header defines the structures specific to the param or config - * indices of Openmax Image Component. - * - * @path domx/system/omx_core/inc - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 11-Oct-2010 KMotov x0106653@ti.com Initial Version - *================================================================*/ - -#ifndef OMX_TI_IMAGE_H -#define OMX_TI_IMAGE_H - -/** - * The OMX_TI_IMAGE_CODINGTYPE enumeration is used to define the - * extended image coding types. - */ -typedef enum OMX_TI_IMAGE_CODINGTYPE -{ - OMX_TI_IMAGE_CodingJPS = OMX_IMAGE_CodingVendorStartUnused + 1, /**< JPS format */ - OMX_TI_IMAGE_CodingMPO /**< MPO format */ -} OMX_TI_IMAGE_CODINGTYPE; - -#endif /* OMX_TI_IMAGE_H */ diff --git a/domx/omx_core/inc/OMX_TI_Index.h b/domx/omx_core/inc/OMX_TI_Index.h deleted file mode 100755 index 61b1e27..0000000 --- a/domx/omx_core/inc/OMX_TI_Index.h +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_ti_index.h - * This file contains the vendor(TI) specific indexes - * - * @path \OMAPSW_SysDev\multimedia\omx\khronos1_1\omx_core\inc - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 20-Dec-2008 x0052661@ti.com, initial version - *================================================================*/ - -#ifndef _OMX_TI_INDEX_H_ -#define _OMX_TI_INDEX_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -#include - -/******************************************************************* - * EXTERNAL REFERENCE NOTE: only use if not found in header file - *******************************************************************/ -/*---------- function prototypes ------------------- */ -/*---------- data declarations ------------------- */ -/******************************************************************* - * PUBLIC DECLARATIONS: defined here, used elsewhere - *******************************************************************/ -/*---------- function prototypes ------------------- */ -/*---------- data declarations ------------------- */ - -typedef enum OMX_TI_INDEXTYPE { - - OMX_IndexConfigAutoPauseAfterCapture = OMX_IndexAutoPauseAfterCapture, - - /* Vendor specific area for storing indices */ - OMX_TI_IndexConfigChannelName = ((OMX_INDEXTYPE)OMX_IndexVendorStartUnused + 1), /**< reference: OMX_CONFIG_CHANNELNAME */ - - OMX_TI_IndexParamJPEGUncompressedMode, /**< reference: OMX_JPEG_PARAM_UNCOMPRESSEDMODETYPE */ - OMX_TI_IndexParamJPEGCompressedMode, /**< reference: OMX_JPEG_PARAM_COMPRESSEDMODETYPE */ - OMX_TI_IndexParamDecodeSubregion, /**< reference: OMX_IMAGE_PARAM_DECODE_SUBREGION */ - - /* H264 Encoder Indices*/ - OMX_TI_IndexParamVideoDataSyncMode, //!< Refer to OMX_VIDEO_PARAM_DATASYNCMODETYPE structure - OMX_TI_IndexParamVideoNALUsettings, //!< use OMX_VIDEO_PARAM_AVCNALUCONTROLTYPE to configure the type os NALU to send along with the Different Frame Types - OMX_TI_IndexParamVideoMEBlockSize, //!< use OMX_VIDEO_PARAM_MEBLOCKSIZETYPE to specify the minimum block size used for motion estimation - OMX_TI_IndexParamVideoIntraPredictionSettings, //!< use OMX_VIDEO_PARAM_INTRAPREDTYPE to configure the intra prediction modes used for different block sizes - OMX_TI_IndexParamVideoEncoderPreset, //!< use OMX_VIDEO_PARAM_ENCODER_PRESETTYPE to select the encoding mode & rate control preset - OMX_TI_IndexParamVideoFrameDataContentSettings, //!< use OMX_TI_VIDEO_PARAM_FRAMEDATACONTENTTYPE to configure the data content tpye - OMX_TI_IndexParamVideoTransformBlockSize, //!< use OMX_VIDEO_PARAM_TRANSFORM_BLOCKSIZETYPE to specify the block size used for ttransformation - OMX_TI_IndexParamVideoVUIsettings, //!use OMX_VIDEO_PARAM_VUIINFOTYPE - OMX_TI_IndexParamVideoAdvancedFMO, - OMX_TI_IndexConfigVideoPixelInfo, //!< Use OMX_VIDEO_CONFIG_PIXELINFOTYPE structure to know the pixel aspectratio & pixel range - OMX_TI_IndexConfigVideoMESearchRange, //!< use OMX_VIDEO_CONFIG_MESEARCHRANGETYPE to specify the ME Search settings - OMX_TI_IndexConfigVideoQPSettings, //!< use OMX_TI_VIDEO_CONFIG_QPSETTINGS to specify the ME Search settings - OMX_TI_IndexConfigSliceSettings, //! - -/** - * @brief mode selection for the data that is given to the Codec - */ - -typedef enum OMX_VIDEO_DATASYNCMODETYPE { - OMX_Video_FixedLength, //!< Interms of multiples of 4K - OMX_Video_SliceMode, //!< Slice mode - OMX_Video_NumMBRows, //!< Number of rows, each row is 16 lines of video - OMX_Video_EntireFrame //!< Processing of entire frame data -} OMX_VIDEO_DATASYNCMODETYPE; - - -/* ========================================================================== */ -/*! - @brief OMX_TI_VIDEO_PARAM_DATAMODE :to configure how the input and output data is fed to the Codec - @param nPortIndex to specify the index of the port - @param eDataMode to specify the data mode - @sa OMX_VIDEO_DATASYNCMODETYPE - @param nNumDataUnits to specify the number of data units (where units are of type defined by eDataMode) - */ -/* ==========================================================================*/ -typedef struct OMX_VIDEO_PARAM_DATASYNCMODETYPE{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_DATASYNCMODETYPE eDataMode; - OMX_U32 nNumDataUnits; -} OMX_VIDEO_PARAM_DATASYNCMODETYPE; - -/** - * @brief Aspect Ratio type selection for the encoded bit stream - */ -typedef enum OMX_VIDEO_ASPECTRATIOTYPE{ - OMX_Video_AR_Unspecified, //!< Unspecified aspect ratio - OMX_Video_AR_Square , //!< 1:1 (square) aspect ratio - OMX_Video_AR_12_11 , //!< 12:11 aspect ratio - OMX_Video_AR_10_11 , //!< 10:11 aspect ratio - OMX_Video_AR_16_11 , //!< 16:11 aspect ratio - OMX_Video_AR_40_33 , //!< 40:33 aspect ratio - OMX_Video_AR_24_11 , //!< 24:11 aspect ratio - OMX_Video_AR_20_11 , //!< 20:11 aspect ratio - OMX_Video_AR_32_11 , //!< 32:11 aspect ratio - OMX_Video_AR_80_33 , //!< 80:33 aspect ratio - OMX_Video_AR_18_11 , //!< 18:11 aspect ratio - OMX_Video_AR_15_15 , //!< 15:15 aspect ratio - OMX_Video_AR_64_33 , //!< 64:33 aspect ratio - OMX_Video_AR_160_99 , //!< 160:99 aspect ratio - OMX_Video_AR_4_3 , //!< 4:3 aspect ratio - OMX_Video_AR_3_2 , //!< 3:2 aspect ratio - OMX_Video_AR_2_1 , //!< 2:1 aspect ratio - OMX_Video_AR_Extended = 255, //!< Extended aspect ratio - OMX_Video_AR_Extended_MAX = 0X7FFFFFFF -}OMX_VIDEO_ASPECTRATIOTYPE; - - -/* ========================================================================== */ -/*! - @brief OMX_TI_VIDEO_PARAM_VUI_SELECT :to select the VUI Settings - @param bAspectRatioPresent flag to indicate the insertion of aspect ratio information in VUI part of bit-stream - @param ePixelAspectRatio to specify the Aspect Ratio - @param bFullRange to indicate whether pixel value range is specified as full range or not (0 to 255) -*/ -/* ==========================================================================*/ -typedef struct OMX_VIDEO_PARAM_VUIINFOTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bAspectRatioPresent; - OMX_VIDEO_ASPECTRATIOTYPE ePixelAspectRatio; - OMX_BOOL bFullRange; -}OMX_VIDEO_PARAM_VUIINFOTYPE; - -/* ========================================================================== */ -/*! - @brief OMX_VIDEO_CONFIG_PIXELINFOTYPE :to specify the information related to the input pixel data (aspect ratio & range) to the Codec - so that codec can incorporate this info in the coded bit stream - @param nWidth to specify the Aspect ratio: width of the pixel - @param nHeight to specify the Aspect ratio: height of the pixel - */ -/* ==========================================================================*/ -typedef struct OMX_VIDEO_CONFIG_PIXELINFOTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nWidth; - OMX_U32 nHeight; -} OMX_VIDEO_CONFIG_PIXELINFOTYPE; - -/* ========================================================================== */ -/*! - @brief OMX_VIDEO_PARAM_AVCNALUCONTROLTYPE : to configure what NALU need to send along the frames of different types (Intra,IDR...etc) - @param nStartofSequence to configure the different NALU (specified via enabling/disabling (1/0) the bit positions) that need to send along with the Start of sequence frame - @param nEndofSequence to to configure the different NALU (specified via enabling/disabling (1/0) the bit positions) that need to send along with the End of sequence frame - @param nIDR to to configure the different NALU (specified via enabling/disabling (1/0) the bit positions) that need to send along with the IDR frame - @param nIntraPicture to to configure the different NALU (specified via enabling/disabling (1/0) the bit positions) that need to send along with the Intra frame - @param nNonIntraPicture to to configure the different NALU (specified via enabling/disabling (1/0) the bit positions) that need to send along with the Non Intra frame - -Bit Position: 13| 12| 11| 10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0 -NALU TYPE: SPS_VUI|FILLER|EOSTREAM|EOSEQ|AUD|PPS|SPS|SEI|IDR_SLICE|SLICE_DP_C|SLICE_DP_B|SLICE_DP_A|SLICE|UNSPECIFIED \n -*/ -/* ==========================================================================*/ -typedef struct OMX_VIDEO_PARAM_AVCNALUCONTROLTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nStartofSequence; - OMX_U32 nEndofSequence; - OMX_U32 nIDR; - OMX_U32 nIntraPicture; - OMX_U32 nNonIntraPicture; -}OMX_VIDEO_PARAM_AVCNALUCONTROLTYPE; - - -/* ========================================================================== */ -/*! - @brief OMX_VIDEO_CONFIG_MESEARCHRANGETYPE : to configure Motion Estimation Parameters - @param eMVAccuracy to specify the Motion Vector Accuracy - @sa OMX_VIDEO_MOTIONVECTORTYPE - @param sHorSearchRangeP to Specify the Horizontal Search range for P Frame - @param sVerSearchRangeP to Specify the Vertical Search range for P Frame - @param sHorSearchRangeB to Specify the Horizontal Search range for B Frame - @param sVerSearchRangeB to Specify the Vertical Search range for B Frame -*/ -/* ==========================================================================*/ -typedef struct OMX_VIDEO_CONFIG_MESEARCHRANGETYPE{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_MOTIONVECTORTYPE eMVAccuracy; - OMX_U32 nHorSearchRangeP; - OMX_U32 nVerSearchRangeP; - OMX_U32 nHorSearchRangeB; - OMX_U32 nVerSearchRangeB; -}OMX_VIDEO_CONFIG_MESEARCHRANGETYPE; - -/** - * @brief Block size specification - */ -typedef enum OMX_VIDEO_BLOCKSIZETYPE { - OMX_Video_Block_Size_16x16=0, - OMX_Video_Block_Size_8x8, - OMX_Video_Block_Size_8x4, - OMX_Video_Block_Size_4x8, - OMX_Video_Block_Size_4x4, - OMX_Video_Block_Size_MAX = 0X7FFFFFFF -}OMX_VIDEO_BLOCKSIZETYPE; - -/* ========================================================================== */ -/*! - @brief OMX_VIDEO_PARAM_MEBLOCKSIZETYPE : to configure the Min Motion Estimation block size for P and B frames - @param eMinBlockSizeP to specify the Min Block size used for Motion Estimation incase of P Frames - @sa OMX_VIDEO_BLOCKSIZETYPE - @param eMinBlockSizeB to specify the Min Block size used for Motion Estimation incase of B Frames -*/ -/* ==========================================================================*/ -typedef struct OMX_VIDEO_PARAM_MEBLOCKSIZETYPE{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_BLOCKSIZETYPE eMinBlockSizeP; - OMX_VIDEO_BLOCKSIZETYPE eMinBlockSizeB; -}OMX_VIDEO_PARAM_MEBLOCKSIZETYPE; - -/** - * @brief to select the chroma component used for Intra Prediction - */ -typedef enum OMX_VIDEO_CHROMACOMPONENTTYPE { - OMX_Video_Chroma_Component_Cr_Only=0, //!< consider only Cr chroma component for Intra prediction - OMX_Video_Chroma_Component_Cb_Cr_Both, //!< consider both (Cb & Cr) chroma components for Intra prediction - OMX_Video_Chroma_Component_MAX = 0X7FFFFFFF -}OMX_VIDEO_CHROMACOMPONENTTYPE; - -/* ========================================================================== */ -/*! - @brief OMX_VIDEO_PARAM_INTRAPREDTYPE : to configure the Modes for the different block sizes during Intra Prediction - @param nLumaIntra4x4Enable to configure the Modes for 4x4 block size during luma intra prediction: bit position specifies the modes that are enabled/disabled - HOR_UP|VERT_LEFT|HOR_DOWN|VERT_RIGHT|DIAG_DOWN_RIGHT|DIAG_DOWN_LEFT|DC|HOR|VER - @param nLumaIntra8x8Enable to configure the Modes for 4x4 block size during luma intra prediction - HOR_UP|VERT_LEFT|HOR_DOWN|VERT_RIGHT|DIAG_DOWN_RIGHT|DIAG_DOWN_LEFT|DC|HOR|VER - @param nLumaIntra16x16Enable to configure the Modes for 4x4 block size during luma intra prediction - PLANE|DC|HOR|VER - @param nChromaIntra8x8Enable to configure the Modes for 4x4 block size during luma intra prediction - PLANE|DC|HOR|VER - @param eChromaComponentEnable to select the chroma components used for the intra prediction - @sa OMX_VIDEO_CHROMACOMPONENTTYPE -*/ -/* ==========================================================================*/ -typedef struct OMX_VIDEO_PARAM_INTRAPREDTYPE{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nLumaIntra4x4Enable; - OMX_U32 nLumaIntra8x8Enable; - OMX_U32 nLumaIntra16x16Enable; - OMX_U32 nChromaIntra8x8Enable; - OMX_VIDEO_CHROMACOMPONENTTYPE eChromaComponentEnable; -}OMX_VIDEO_PARAM_INTRAPREDTYPE; - - -/** - * @brief Encoding Mode Preset - */ -typedef enum OMX_VIDEO_ENCODING_MODE_PRESETTYPE { - OMX_Video_Enc_Default=0, //!< for all the params default values are taken - OMX_Video_Enc_High_Quality, //!< todo: mention the parameters that takes specific values depending on this selection - OMX_Video_Enc_User_Defined, - OMX_Video_Enc_High_Speed_Med_Quality, - OMX_Video_Enc_Med_Speed_Med_Quality, - OMX_Video_Enc_Med_Speed_High_Quality, - OMX_Video_Enc_High_Speed, - OMX_Video_Enc_Preset_MAX = 0X7FFFFFFF -}OMX_VIDEO_ENCODING_MODE_PRESETTYPE; - -/** - * @brief Rate Control Preset - */ -typedef enum OMX_VIDEO_RATECONTROL_PRESETTYPE { - OMX_Video_RC_Low_Delay, //!> minPicSizeRatio. Allowed values are 1 to 4. Setting this to 0 will enable encoder chosen ratio. -@param maxPicSizeRatio : This ratio is used to compute maximum picture size in the following manner, -maxPicSize = averagePicSize * maxPicSizeRatio. Allowed values are 2 to 30. Setting this to 0 or 1 will enable encoder chosen ratio. -*/ -/* ============================================================================= */ -typedef struct OMX_TI_VIDEO_CONFIG_PICSIZECONTROLINFO { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U16 minPicSizeRatio; - OMX_U16 maxPicSizeRatio; -} OMX_TI_VIDEO_CONFIG_PICSIZECONTROLINFO; - - -/*!====================================================================! - - Currently we only support SVC baseline profile - - * !====================================================================!*/ - typedef enum OMX_TI_VIDEO_SVCPROFILETYPE { - OMX_VIDEO_SVCProfileBaseline = 0x01, /**< Baseline profile */ - OMX_VIDEO_SVCProfileHigh = 0x02, /**< High profile */ - OMX_VIDEO_SVCProfileHighIntra = 0x03, /**< High Intra profile */ - OMX_VIDEO_SVCProfileMax = 0x7FFFFFFF - } OMX_TI_VIDEO_SVCPROFILETYPE; - - -/*!====================================================================! - - Currently we support only SVC baseline profile upto level 4 for SVC encoder. - - * !====================================================================!*/ - typedef enum OMX_TI_VIDEO_SVCLEVELTYPE { - OMX_VIDEO_SVCLevel1 = 0x01, /**< Level 1 */ - OMX_VIDEO_SVCLevel1b = 0x02, /**< Level 1b */ - OMX_VIDEO_SVCLevel11 = 0x04, /**< Level 1.1 */ - OMX_VIDEO_SVCLevel12 = 0x08, /**< Level 1.2 */ - OMX_VIDEO_SVCLevel13 = 0x10, /**< Level 1.3 */ - OMX_VIDEO_SVCLevel2 = 0x20, /**< Level 2 */ - OMX_VIDEO_SVCLevel21 = 0x40, /**< Level 2.1 */ - OMX_VIDEO_SVCLevel22 = 0x80, /**< Level 2.2 */ - OMX_VIDEO_SVCLevel3 = 0x100, /**< Level 3 */ - OMX_VIDEO_SVCLevel31 = 0x200, /**< Level 3.1 */ - OMX_VIDEO_SVCLevel32 = 0x400, /**< Level 3.2 */ - OMX_VIDEO_SVCLevel4 = 0x800, /**< Level 4 */ - OMX_VIDEO_SVCLevel41 = 0x1000, /**< Level 4.1 */ - OMX_VIDEO_SVCLevel42 = 0x2000, /**< Level 4.2 */ - OMX_VIDEO_SVCLevel5 = 0x4000, /**< Level 5 */ - OMX_VIDEO_SVCLevel51 = 0x8000, /**< Level 5.1 */ - OMX_VIDEO_SVCLevelMax = 0x7FFFFFFF - } OMX_TI_VIDEO_SVCLEVELTYPE; - - - typedef struct OMX_VIDEO_SVC_STD_PARAMS { - OMX_U32 nSliceHeaderSpacing; - OMX_U32 nPFrames; - OMX_U32 nBFrames; - OMX_BOOL bUseHadamard; - OMX_U32 nRefFrames; - OMX_U32 nRefIdx10ActiveMinus1; - OMX_U32 nRefIdx11ActiveMinus1; - OMX_BOOL bEnableUEP; - /* Not needed as per SVC encoder requirements - OMX_BOOL bEnableFMO; - OMX_BOOL bEnableASO; - OMX_BOOL bEnableRS; - */ - OMX_VIDEO_AVCLOOPFILTERTYPE eLoopFilterMode; - OMX_U32 nAllowedPictureTypes; - OMX_BOOL bFrameMBsOnly; - OMX_BOOL bMBAFF; - OMX_BOOL bEntropyCodingCABAC; - OMX_BOOL bWeightedPPrediction; - OMX_U32 nWeightedBipredicitonMode; - OMX_BOOL bconstIpred; - OMX_BOOL bDirect8x8Inference; - OMX_BOOL bDirectSpatialTemporal; - OMX_U32 nCabacInitIdc; - } OMX_VIDEO_SVC_STD_PARAMS; - - - typedef struct OMX_VIDEO_SVC_RECTTYPE { - OMX_S32 nLeft; - OMX_S32 nTop; - OMX_U32 nWidth; - OMX_U32 nHeight; - } OMX_VIDEO_SVC_RECTTYPE; - - - typedef struct OMX_VIDEO_SVC_BITRATETYPE { - OMX_VIDEO_CONTROLRATETYPE eControlRate; - OMX_U32 nTargetBitrate; - } OMX_VIDEO_SVC_BITRATETYPE; - - - typedef struct OMX_VIDEO_SVC_MOTIONVECTORTYPE { - OMX_VIDEO_MOTIONVECTORTYPE eAccuracy; - OMX_BOOL bUnrestrictedMVs; - OMX_BOOL bFourMV; - OMX_S32 sXSearchRange; - OMX_S32 sYSearchRange; - } OMX_VIDEO_SVC_MOTIONVECTORTYPE; - - - typedef struct OMX_VIDEO_SVC_QUANTIZATIONTYPE { - OMX_U32 nQpI; - OMX_U32 nQpP; - OMX_U32 nQpB; - } OMX_VIDEO_SVC_QUANTIZATIONTYPE; - - - typedef struct OMX_VIDEO_SVC_INTRAREFRESHTYPE { - OMX_VIDEO_INTRAREFRESHTYPE eRefreshMode; - OMX_U32 nAirMBs; - OMX_U32 nAirRef; - OMX_U32 nCirMBs; - } OMX_VIDEO_SVC_INTRAREFRESHTYPE; - - - typedef struct OMX_VIDEO_SVC_VBSMCTYPE { - OMX_BOOL b16x16; - OMX_BOOL b16x8; - OMX_BOOL b8x16; - OMX_BOOL b8x8; - OMX_BOOL b8x4; - OMX_BOOL b4x8; - OMX_BOOL b4x4; - } OMX_VIDEO_SVC_VBSMCTYPE; - - - typedef struct OMX_VIDEO_SVC_NALUCONTROLTYPE { - OMX_U32 nStartofSequence; - OMX_U32 nEndofSequence; - OMX_U32 nIDR; - OMX_U32 nIntraPicture; - OMX_U32 nNonIntraPicture; - }OMX_VIDEO_SVC_NALUCONTROLTYPE; - - - typedef struct OMX_VIDEO_SVC_MEBLOCKSIZETYPE { - OMX_VIDEO_BLOCKSIZETYPE eMinBlockSizeP; - OMX_VIDEO_BLOCKSIZETYPE eMinBlockSizeB; - }OMX_VIDEO_SVC_MEBLOCKSIZETYPE; - - - typedef struct OMX_VIDEO_SVC_INTRAPREDTYPE { - OMX_U32 nLumaIntra4x4Enable; - OMX_U32 nLumaIntra8x8Enable; - OMX_U32 nLumaIntra16x16Enable; - OMX_U32 nChromaIntra8x8Enable; - OMX_VIDEO_CHROMACOMPONENTTYPE eChromaComponentEnable; - }OMX_VIDEO_SVC_INTRAPREDTYPE; - - - typedef struct OMX_VIDEO_SVC_ENCODER_PRESETTYPE { - OMX_VIDEO_ENCODING_MODE_PRESETTYPE eEncodingModePreset; - OMX_VIDEO_RATECONTROL_PRESETTYPE eRateControlPreset; - }OMX_VIDEO_SVC_ENCODER_PRESETTYPE; - - - typedef struct OMX_VIDEO_SVC_VUIINFOTYPE { - OMX_BOOL bAspectRatioPresent; - OMX_VIDEO_ASPECTRATIOTYPE ePixelAspectRatio; - OMX_BOOL bFullRange; - }OMX_VIDEO_SVC_VUIINFOTYPE; - - - typedef struct OMX_VIDEO_SVC_HRDBUFFERSETTING { - OMX_U32 nInitialBufferLevel; - OMX_U32 nHRDBufferSize; - OMX_U32 nTargetBitrate; - }OMX_VIDEO_SVC_HRDBUFFERSETTING; - - - typedef struct OMX_VIDEO_SVC_INTRAPERIOD { - OMX_U32 nIDRPeriod; - OMX_U32 nPFrames; - } OMX_VIDEO_SVC_INTRAPERIOD; - - - typedef struct OMX_VIDEO_SVC_PIXELINFOTYPE { - OMX_U32 nWidth; - OMX_U32 nHeight; - } OMX_VIDEO_SVC_PIXELINFOTYPE; - - - typedef struct OMX_VIDEO_SVC_MESEARCHRANGETYPE { - OMX_VIDEO_MOTIONVECTORTYPE eMVAccuracy; - OMX_U32 nHorSearchRangeP; - OMX_U32 nVerSearchRangeP; - OMX_U32 nHorSearchRangeB; - OMX_U32 nVerSearchRangeB; - }OMX_VIDEO_SVC_MESEARCHRANGETYPE; - - - typedef struct OMX_VIDEO_SVC_QPSETTINGSTYPE { - OMX_U32 nQpI; - OMX_U32 nQpMaxI; - OMX_U32 nQpMinI; - OMX_U32 nQpP; - OMX_U32 nQpMaxP; - OMX_U32 nQpMinP; - OMX_U32 nQpOffsetB; - OMX_U32 nQpMaxB; - OMX_U32 nQpMinB; - }OMX_VIDEO_SVC_QPSETTINGSTYPE; - - - typedef struct OMX_VIDEO_SVC_SLICECODINGTYPE { - OMX_VIDEO_AVCSLICEMODETYPE eSliceMode; - OMX_U32 nSlicesize; - }OMX_VIDEO_SVC_SLICECODINGTYPE; - - - typedef struct OMX_VIDEO_EXEC_SVC_HRDBUFFERSETTING { - OMX_U32 nHRDBufferSize; - OMX_U32 nEncodeBitrate; - }OMX_VIDEO_EXEC_SVC_HRDBUFFERSETTING; - -/** - * SVC params - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nSliceHeaderSpacing : Number of macroblocks between slice header, put - * zero if not used - * nPFrames : Number of P frames between each I frame - * nBFrames : Number of B frames between each I frame - * bUseHadamard : Enable/disable Hadamard transform - * nRefFrames : Max number of reference frames to use for inter - * motion search (1-16) - * nRefIdxTrailing : Pic param set ref frame index (index into ref - * frame buffer of trailing frames list), B frame - * support - * nRefIdxForward : Pic param set ref frame index (index into ref - * frame buffer of forward frames list), B frame - * support - * bEnableUEP : Enable/disable unequal error protection. This - * is only valid of data partitioning is enabled. - * bEnableFMO : Enable/disable flexible macroblock ordering - * bEnableASO : Enable/disable arbitrary slice ordering - * bEnableRS : Enable/disable sending of redundant slices - * eProfile : AVC profile(s) to use - * eLevel : AVC level(s) to use - * nAllowedPictureTypes : Specifies the picture types allowed in the - * bitstream - * bFrameMBsOnly : specifies that every coded picture of the - * coded video sequence is a coded frame - * containing only frame macroblocks - * bMBAFF : Enable/disable switching between frame and - * field macroblocks within a picture - * bEntropyCodingCABAC : Entropy decoding method to be applied for the - * syntax elements for which two descriptors appear - * in the syntax tables - * bWeightedPPrediction : Enable/disable weighted prediction shall not - * be applied to P and SP slices - * nWeightedBipredicitonMode : Default weighted prediction is applied to B - * slices - * bconstIpred : Enable/disable intra prediction - * bDirect8x8Inference : Specifies the method used in the derivation - * process for luma motion vectors for B_Skip, - * B_Direct_16x16 and B_Direct_8x8 as specified - * in subclause 8.4.1.2 of the AVC spec - * bDirectSpatialTemporal : Flag indicating spatial or temporal direct - * mode used in B slice coding (related to - * bDirect8x8Inference) . Spatial direct mode is - * more common and should be the default. - * nCabacInitIdx : Index used to init CABAC contexts - * eLoopFilterMode : Enable/disable loop filter - */ - typedef struct OMX_TI_VIDEO_PARAM_SVCTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - - OMX_U32 nActualFrameWidth; - OMX_U32 nActualFrameHeight; - OMX_S32 nStride; - OMX_U32 xFramerate; - OMX_COLOR_FORMATTYPE eColorFormat; - OMX_VIDEO_SVC_RECTTYPE sRecType; - - OMX_VIDEO_SVC_STD_PARAMS sBasicParams; - - OMX_U32 nRefFrames; - OMX_TI_VIDEO_SVCPROFILETYPE eProfile; - OMX_TI_VIDEO_SVCLEVELTYPE eLevel; - - OMX_U32 xEncodeFramerate; - OMX_VIDEO_SVC_BITRATETYPE sBitRateParams; - - OMX_VIDEO_SVC_MOTIONVECTORTYPE sMotionVectorParams; - OMX_VIDEO_SVC_QUANTIZATIONTYPE sQuantizationParams; - OMX_VIDEO_SVC_INTRAREFRESHTYPE sIntraRefreshParams; - OMX_VIDEO_SVC_VBSMCTYPE sVBSMCParams; - - //OMX_NALUFORMATSTYPE eNaluFormat; - OMX_VIDEO_SVC_NALUCONTROLTYPE sNalUnitParams; - - OMX_VIDEO_SVC_MEBLOCKSIZETYPE sMEBlockSizeParams; - OMX_VIDEO_SVC_INTRAPREDTYPE sIntraPredParams; - OMX_VIDEO_SVC_ENCODER_PRESETTYPE sEncPresetParams; - OMX_VIDEO_TRANSFORMBLOCKSIZETYPE eTransformBlocksize; - OMX_VIDEO_SVC_VUIINFOTYPE sVUIInfoParams; - OMX_VIDEO_SVC_HRDBUFFERSETTING sHRDBufferParams; - - OMX_U32 nNumTemporalLayers; - OMX_S32 nDependencyID; - OMX_S32 nQualityID; - //OMX_VIDEO_SVC_ENCODE_MODE eModeOfEncode; - - OMX_U32 nErrorConcealmentMode; - OMX_U32 nDeblockFilterMode; - } OMX_TI_VIDEO_PARAM_SVCTYPE; - - typedef struct OMX_TI_VIDEO_CONFIG_SVCLAYERDETAILS { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - - OMX_U32 nNumLayers; - OMX_U32 nLayerId; - OMX_U8 nPriorityId; - OMX_U8 nDependencyId; - OMX_U8 nQualityId; - OMX_U8 nTemporalId; - OMX_U8 nBitrateInfoPresentFlag; - OMX_U8 nFramerateInfoPresentFlag; - OMX_U8 nFramesizeInfoPresentFlag; - OMX_U16 nAvgBitrate; - OMX_U16 nMaxBitrate; - OMX_U16 nAvgFramerate; - OMX_U32 nFrameWidth; - OMX_U32 nFrameHeight; - - OMX_U32 nLayerIndex; /* Used to query for individual layer details */ - -} OMX_TI_VIDEO_CONFIG_SVCLAYERDETAILS; - -typedef struct OMX_TI_VIDEO_CONFIG_SVCTARGETLAYER { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - - OMX_U32 nSvcTargetLayerDID; - OMX_U32 nSvcTargetLayerTID; - OMX_U32 nSvcTargetLayerQID; - -} OMX_TI_VIDEO_CONFIG_SVCTARGETLAYER; -/* ========================================================================== */ -/*! -@brief OMX_TI_VIDEO_SLICEDATAINFO : to configure the Slice Settings -@param nNumofSlices number of validfields to be read -@param nSliceSizeConfigured variable that indicates the MaxSlice configured - & (n*nSliceSizeConfigured) gives the buff offset - for nth slice in the o/p buffer -@param nSliceSize gives the SliceSize -*/ -/* ==========================================================================*/ -typedef struct OMX_TI_VIDEO_SLICEDATAINFO { - OMX_U32 nNumofSlices; - OMX_U32 nSliceSizeConfigured; - OMX_U32 nSliceSize[OMXH264E_MAX_SLICE_SUPPORTED]; -} OMX_TI_VIDEO_SLICEDATAINFO; -/** -* @brief mode selection for the data that is given to the Codec - */ - -typedef enum _OMX_VIDEO_AVCLTRMODE { - OMX_H264ENC_LTRP_NONE = 0, - /**< No longterm refernce frame in the sequnce - */ - OMX_H264ENC_LTRP_REFERTOIDR = 1, - /**< Mark all the I frames as long term-reference frames and - * based on the frame control IH264ENC_Control, refere to - * a long-term reference frame (I frame). - */ - OMX_H264ENC_LTRP_REFERTOP_PROACTIVE =2, - /**< Two long term frames are supported in this schme and - * long-term index marking and refernce frame update is done based - * the IH264ENC_Control values - */ - OMX_H264ENC_LTRP_REFERTOP_REACTIVE = 3 - /**< This is not supported in the current version of encoder - */ -} OMX_VIDEO_AVCLTRMODE; - - -/* ============================================================================= */ -/* -@brief OMX_TI_VIDEO_PARAM_AVC_LTRP : Structure to enable the configuration of Long Term reference Picture feature in H264 Encoder for the session -Enabling this parameter will instruct encoder to keep its recent I/IDR frame in its reference buffer list. -So it increases the DDR foot print by one frame buffer -@param eLTRMode : enables the LongTerm Reference Picture, possible modes: 0, 1, 2 -@param nLTRInterval : interval of the write indicating to codec interms of the frame number -*/ -/* ============================================================================= */ -typedef struct OMX_TI_VIDEO_PARAM_AVC_LTRP{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_AVCLTRMODE eLTRMode; - OMX_U32 nLTRInterval; -} OMX_TI_VIDEO_PARAM_AVC_LTRP; - -/* -@brief OMX_TI_VIDEO_CONFIG_AVC_LTRP : Structure to provide the configuration to acknowledge successful decode of previous LTR -@param eLTRFrameDecoded : tells the decoder that the LTR has been decoded successfully when set to TRUE -*/ -/* ============================================================================= */ -typedef struct OMX_TI_VIDEO_CONFIG_AVC_LTRP{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnableNextLTR; -} OMX_TI_VIDEO_CONFIG_AVC_LTRP; - -/* ============================================================================= */ -/* -@brief OMX_TI_VIDEO_CONFIG_AVC_LTRP_INTERVAL : Structure to enable the update of the LTRP -Interval during runtime -@param nLTRInterval : interval of the write indicating to codec interms of the frame number -*/ -/* ============================================================================= */ -typedef struct OMX_TI_VIDEO_CONFIG_AVC_LTRP_INTERVAL{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nLTRInterval; -} OMX_TI_VIDEO_CONFIG_AVC_LTRP_INTERVAL; - -/* ============================================================================= */ -/* -@brief OMX_TI_VIDEO_CONFIG_AVC_LTRP_INTERVAL : Structure to enable timestamps in decode order - at i/p of decoders. -*/ -/* ============================================================================= */ -typedef struct OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bEnabled; -} OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER; - -/* ============================================================================= */ -/* -@brief OMX_TI_VIDEO_PARAM_AUTO_FRAMERATE_UPDATE : Structure to enable dynamic update of frame rate -*/ -/* ============================================================================= */ -typedef struct OMX_TI_VIDEO_PARAM_AUTO_FRAMERATE_UPDATE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnableAutoVFRUpdate; - OMX_U32 nDiffThresholdtoUpdate; - OMX_U32 nMaxSessionFrameRate; -} OMX_TI_VIDEO_PARAM_AUTO_FRAMERATE_UPDATE; - -/* ============================================================================= */ -/* -@brief OMX_TI_PARAM_SKIP_GREY_OUTPUT_FRAMES : Structure to enable feature to skip grey output - frames which doesn't have proper reference. -*/ -/* ============================================================================= */ -typedef struct OMX_TI_PARAM_SKIP_GREY_OUTPUT_FRAMES { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bEnabled; -} OMX_TI_PARAM_SKIP_GREY_OUTPUT_FRAMES; - -/* ============================================================================= */ -/* -@brief OMX_TI_PARAM_DECMETADATA : Structure to enable different codec metadata - for video decoders. -*/ -/* ============================================================================= */ -typedef struct OMX_TI_PARAM_DECMETADATA { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnableMBInfo; - OMX_BOOL bEnableTranscodeMode; - OMX_BOOL bEnableSEIInfo; - OMX_BOOL bEnableVUIInfo; -} OMX_TI_PARAM_DECMETADATA; - -/** - ****************************************************************************** - * @enum OMX_TI_VIDEO_MBERRSTATUS - * @brief This enum indicates if a MB was in error or not - * - ****************************************************************************** -*/ -typedef enum { - OMX_TI_VIDEO_MB_NOERROR = 0, - /** - * MB was non-erroneous - */ - OMX_TI_VIDEO_MB_ERROR = 1 - /** - * MB was erroneous - */ -} OMX_TI_VIDEO_MBERRSTATUS; - - -/** - * Macro definitions required for SEI support: HRD sequence parameter set - */ -#define OMX_TI_VIDEO_H264VDEC_MAXCPBCNT 32 - -/** - * Macro definitions required for SEI support: HRD sequence parameter set - */ -#define OMX_TI_VIDEO_H264VDEC_MAXUSERDATA_PAYLOAD 300 - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_HrdParams - * - * @brief This structure contains the HRD parameter elements. - * - * @param cpb_cnt_minus1 : Number of alternative CPB specifications in the - * bit-stream - * @param bit_rate_scale : Together with bit_rate_value[i], it specifies the - * maximum input bit-rate for the ith CPB. - * @param cpb_size_scale : Together with cpb_size_value[i], specifies the - * maximum CPB size for the ith CPB. - * @param bit_rate_value_minus1[OMX_TI_VIDEO_H264VDEC_MAXCPBCNT] :Maximum input bitrate - * for the ith CPB - * @param cpb_size_value_minus1[OMX_TI_VIDEO_H264VDEC_MAXCPBCNT] :Maximum CPB size for the - * ith CPB - * @param vbr_cbr_flag[OMX_TI_VIDEO_H264VDEC_MAXCPBCNT] :Specifies the ith CPB is operated - * in Constant Bit-rate mode or variable bit-rate mode - * @param initial_cpb_removal_delay_length_minus1 :Length in bits of - * initial_cpb_removal_length syntax element - * @param cpb_removal_delay_length_minus1 :Length in bits of - * cpb_removal_delay_length syntax element - * @param dpb_output_delay_length_minus1 :Length in bits of - * dpb_output_delay_length syntax element - * @param time_offset_length : Length in bits of time_offset syntax element - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_HrdParams { - OMX_U32 cpb_cnt_minus1; - OMX_U8 bit_rate_scale; - OMX_U8 cpb_size_scale; - OMX_U32 bit_rate_value_minus1[OMX_TI_VIDEO_H264VDEC_MAXCPBCNT]; - OMX_U32 cpb_size_value_minus1[OMX_TI_VIDEO_H264VDEC_MAXCPBCNT]; - OMX_U8 vbr_cbr_flag[OMX_TI_VIDEO_H264VDEC_MAXCPBCNT]; - OMX_U8 initial_cpb_removal_delay_length_minus1; - OMX_U8 cpb_removal_delay_length_minus1; - OMX_U8 dpb_output_delay_length_minus1; - OMX_U8 time_offset_length; -} OMX_TI_VIDEO_H264VDEC_HrdParams; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SVCVuiParams - * - * @brief This structure contains VUI message syntax elements for scalable - * video stream - * - * @param parsed_flag :1 - Indicates that in the current process call, c - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * - * @param svc_vui_ext_num_entries_minus1:(svc_vui_ext_num_entries_minus1 + 1) - * specifies the number of information - * entries that are present in the SVC - * VUI parameters extension syntax - * structure - * @param svc_vui_ext_dependency_id:indicate the max value of DId for the - * i-th subset of coded video sequences - * @param svc_vui_ext_quality_id:indicate the max value of QId for the - * i-th subset of coded video sequences - * @param svc_vui_ext_temporal_id: indicate the max value of TId for the - * i-th subset of coded video sequences - * @param svc_vui_ext_timing_info_present_flag: Flag to tells that - * svc_vui_ext_num_units_in_tick, - * svc_vui_ext_time_scale, - * svc_vui_ext_fixed_frame_rate_flag - * are present for current coded - * sequence or not. - * @param svc_vui_ext_num_units_in_tick: specifies the value of num_units_in_tick - * @param svc_vui_ext_time_scale: specifies the value of time_scale - * @param svc_vui_ext_fixed_frame_rate_flag: specifies the value of - * fixed_frame_rate_flag - * @param svc_vui_ext_nal_hrd_parameters_present_flag:specifies the - * value of nal_hrd_parameters_present_flag - * @param svc_vui_ext_vcl_hrd_parameters_present_flag: ] specifies the - * value of vcl_hrd_parameters_present_flag - * @param svc_vui_ext_low_delay_hrd_flag: specifies the value - * of low_delay_hrd_flag - * @param svc_vui_ext_pic_struct_present_flag: specifies the value - * of pic_struct_present_flag - * - ****************************************************************************** -*/ - -typedef struct sOMX_TI_VIDEO_H264VDEC_SVCVuiParams { - OMX_U32 parsed_flag; - OMX_U16 svc_vui_ext_num_entries_minus1; - OMX_U16 svc_vui_ext_dependency_id; - OMX_U16 svc_vui_ext_quality_id; - OMX_U16 svc_vui_ext_temporal_id; - OMX_U16 svc_vui_ext_timing_info_present_flag; - OMX_U32 svc_vui_ext_num_units_in_tick; - OMX_U32 svc_vui_ext_time_scale; - OMX_U16 svc_vui_ext_fixed_frame_rate_flag; - OMX_U16 svc_vui_ext_nal_hrd_parameters_present_flag; - OMX_U16 svc_vui_ext_vcl_hrd_parameters_present_flag; - OMX_U16 svc_vui_ext_low_delay_hrd_flag; - OMX_U16 svc_vui_ext_pic_struct_present_flag; -} OMX_TI_VIDEO_H264VDEC_SVCVuiParams; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_VuiParams - * - * @brief This structure contains the VUI Sequence Parameter elements. - * - * @param parsed_flag :1 - Indicates that in the current process call, c - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param aspect_ratio_info_present_flag :Indicates whether aspect ratio idc - * is present or not. - * @param aspect_ratio_idc : Aspect ratio of Luma samples - * @param sar_width : Horizontal size of sample aspect ratio - * @param sar_height : Vertical size of sample aspect ratio - * @param overscan_info_present_flag : Cropped decoded pictures are suitable - * for display or not. - * @param overscan_appropriate_flag : Overscan_appropriate_flag - * @param video_signal_type_present_flag : Flag indicates whether - * video_format, video_full_range_flag and colour_description_present_ - * flag are present or not - * @param video_format :Video format indexed by a table. For example,PAL/NTSC - * @param video_full_range_flag : Black level, luma and chroma ranges. It - * should be used for BT.601 compliance - * @param colour_description_present_flag:Indicates whether colour_primaries, - * transfer_characteristics and matrix_coefficients are present. - * @param colour_primaries :Chromaticity co-ordinates of source primaries - * @param transfer_characteristics :Opto-electronic transfer characteristics - * of the source picture - * @param matrix_coefficients :Matrix coefficients for deriving Luma and - * chroma data from RGB components. - * @param chroma_location_info_present_flag : Flag indicates whether - * chroma_sample_loc_type_top field and chroma_sample_loctype - * bottom_field are present. - * @param chroma_sample_loc_type_top_field : Location of chroma_sample top - * field - * @param chroma_sample_loc_type_bottom_field :Location of chroma_sample - * bottom field - * @param timing_info_present_flag :Indicates whether num_units_in_tick, - * time_scale, and fixed_frame_rate_flag are present. - * @param num_units_in_tick :Number of units of a clock that corresponds to 1 - * increment of a clock tick counter - * @param time_scale :Indicates actual increase in time for 1 increment of a - * clock tick counter - * @param fixed_frame_rate_flag :Indicates how the temporal distance between - * HRD output times of any two output pictures is constrained - * @param nal_hrd_parameters_present_flag :Indicates whether - * nal_hrd_parameters are present - * @param nal_hrd_pars : NAL HRD Parameters - * @param vcl_hrd_parameters_present_flag :Indicates whether - * vcl_hrd_parameters are present - * @param vcl_hrd_pars : VCL HRD Parameters - * @param low_delay_hrd_flag :HRD operational mode as in Annex C of the - * standard - * @param pic_struct_present_flag :Indicates whether picture timing SEI - * messages are present - * @param bitstream_restriction_flag :Indicates if the bit-stream restriction - * parameters are present - * @param motion_vectors_over_pic_boundaries_flag :Specifies whether motion - * vectors can point to regions outside the picture boundaries - * @param max_bytes_per_pic_denom :Maximum number of bytes not exceeded by - * the sum of sizes of all VCL NAL units of a single coded picture - * @param max_bits_per_mb_denom :Maximum number of bits taken by any coded MB - * @param log2_max_mv_length_vertical :Maximum value of any motion vector\u2019s - * vertical component - * @param log2_max_mv_length_horizontal :Maximum value of any motion vector\u2019s - * horizontal component - * @param max_dec_frame_reordering : - * @param num_reorder_frames :Maximum number of frames that need to be - * re-ordered - * @param max_dec_frame_buffering :Size of HRD decoded buffer (DPB) in terms - * of frame buffers - * @param svcVuiParams : struct instance of vui parameters for svc - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_VuiParams { - OMX_U32 parsed_flag; - OMX_U8 aspect_ratio_info_present_flag; - OMX_U32 aspect_ratio_idc; - OMX_U32 sar_width; - OMX_U32 sar_height; - OMX_U8 overscan_info_present_flag; - OMX_U8 overscan_appropriate_flag; - OMX_U8 video_signal_type_present_flag; - OMX_U8 video_format; - OMX_U8 video_full_range_flag; - OMX_U8 colour_description_present_flag; - OMX_U8 colour_primaries; - OMX_U8 transfer_characteristics; - OMX_U8 matrix_coefficients; - OMX_U8 chroma_location_info_present_flag; - OMX_U32 chroma_sample_loc_type_top_field; - OMX_U32 chroma_sample_loc_type_bottom_field; - OMX_U8 timing_info_present_flag; - OMX_U32 num_units_in_tick; - OMX_U32 time_scale; - OMX_U8 fixed_frame_rate_flag; - OMX_U8 nal_hrd_parameters_present_flag; - OMX_TI_VIDEO_H264VDEC_HrdParams nal_hrd_pars; - OMX_U8 vcl_hrd_parameters_present_flag; - OMX_TI_VIDEO_H264VDEC_HrdParams vcl_hrd_pars; - OMX_U8 low_delay_hrd_flag; - OMX_U8 pic_struct_present_flag; - OMX_U8 bitstream_restriction_flag; - OMX_U8 motion_vectors_over_pic_boundaries_flag; - OMX_U32 max_bytes_per_pic_denom; - OMX_U32 max_bits_per_mb_denom; - OMX_U32 log2_max_mv_length_vertical; - OMX_U32 log2_max_mv_length_horizontal; - OMX_U32 max_dec_frame_reordering; - OMX_U32 num_reorder_frames; - OMX_U32 max_dec_frame_buffering; - OMX_TI_VIDEO_H264VDEC_SVCVuiParams svcVuiParams; -} OMX_TI_VIDEO_H264VDEC_VuiParams; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiUserDataRegITUT - * - * @brief This structure contains the user data SEI msg elements - * - * @param parsed_flag :1 - Indicates that in the current process call, - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param num_payload_bytes :Specifies the size of the payload - * @param itu_t_t35_country_code : A byte having a value specified as a - * country code by ITU-T Recommendation T.35 Annex A - * @param itu_t_t35_country_code_extension_byte :A byte having a value - * specified as a country code by ITU-T Recommendation T.35 Annex B - * @param itu_t_t35_payload_byte[] : A byte containing data registered as - * specified by ITU-T Recommendation T.35. - * @param dataOverflowFlag: This indicates if pay load data is more than the - * array size i.e., OMX_TI_VIDEO_H264VDEC_MAXUSERDATA_PAYLOAD. - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiUserDataRegITUT { - OMX_U32 parsed_flag; - OMX_U32 num_payload_bytes; - OMX_U8 itu_t_t35_country_code; - OMX_U8 itu_t_t35_country_code_extension_byte; - OMX_U8 itu_t_t35_payload_byte[OMX_TI_VIDEO_H264VDEC_MAXUSERDATA_PAYLOAD]; - OMX_U8 dataOverflowFlag; -} OMX_TI_VIDEO_H264VDEC_SeiUserDataRegITUT; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiUserDataUnReg - * - * @brief This structure contains the user data SEI msg elements - * - * @param parsed_flag :1 - Indicates that in the current process call, - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param num_payload_bytes :Specifies the size of the payload - * @param uuid_iso_iec_11578 :Value specified as a UUID according to the - * procedures of ISO/IEC 11578:1996 Annex A. - * @param user_data_payload_byte :Byte containing data having syntax and - * semantics as specified by the UUID generator. - * @param dataOverflowFlag: This indicates if pay load data is more than the - * array size i.e., OMX_TI_VIDEO_H264VDEC_MAXUSERDATA_PAYLOAD. - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiUserDataUnReg { - OMX_U32 parsed_flag; - OMX_U32 num_payload_bytes; - OMX_U8 uuid_iso_iec_11578[16]; - OMX_U8 user_data_payload_byte[OMX_TI_VIDEO_H264VDEC_MAXUSERDATA_PAYLOAD]; - OMX_U8 dataOverflowFlag; -} OMX_TI_VIDEO_H264VDEC_SeiUserDataUnReg; - - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiBufferingPeriod - * - * @brief This structure contains the buffering period SEI msg elements - * - * @param parsed_flag :1 - Indicates that in the current process call, - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param seq_parameter_set_id :Specifies the sequence parameter set that - * contains the sequence HRD attributes - * @param nal_cpb_removal_delay :Specifies the delay for the indexed NAL CPB - * between the time of arrival in the CPB of the first bit of the - * coded data associated with the access unit associated with the - * buffering period SEI message and the time of removal from the CPB - * of the coded data associated with the same access unit, for the - * first buffering period after HRD initialization. - * @param nal_cpb_removal_delay_offset :Used for the indexed NAL CPB in - * combination with the cpb_removal_delay to specify the initial - * delivery time of coded access units to the CPB - * @param vcl_cpb_removal_delay :Specifies the delay for the indexed VCL CPB - * between the time of arrival in the CPB of the first bit of the - * coded data associated with the access unit associated with the - * buffering period SEI message and the time of removal from the CPB - * of the coded data associated with the same access unit, for the - * first buffering period after HRD initialization. - * @param vcl_cpb_removal_delay_offset :Used for the indexed VCL CPB in - * combination with the cpb_removal_delay to specify the initial - * delivery time of coded access units to the CPB - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiBufferingPeriod { - OMX_U32 parsed_flag; - OMX_U32 seq_parameter_set_id; - OMX_U32 nal_cpb_removal_delay[OMX_TI_VIDEO_H264VDEC_MAXCPBCNT]; - OMX_U32 nal_cpb_removal_delay_offset[OMX_TI_VIDEO_H264VDEC_MAXCPBCNT]; - OMX_U32 vcl_cpb_removal_delay[OMX_TI_VIDEO_H264VDEC_MAXCPBCNT]; - OMX_U32 vcl_cpb_removal_delay_offset[OMX_TI_VIDEO_H264VDEC_MAXCPBCNT]; -}OMX_TI_VIDEO_H264VDEC_SeiBufferingPeriod; -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiPanScanRect - * - * @brief This structure contains the pan scan rectangle SEI msg elements - * - * @param parsed_flag :1 - Indicates that in the current process call, - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param pan_scan_rect_id :Specifies an identifying number that may be used - * to identify the purpose of the pan-scan rectangle - * @param pan_scan_rect_cancel_flag :Equal to 1 indicates that the SEI - * message cancels the persistence of any previous pan-scan - * rectangle SEI message in output order. - * pan_scan_rect_cancel_flag equal to 0 indicates that - * pan-scan rectangle information follows. - * @param pan_scan_cnt_minus1 :Specifies the number of pan-scan rectangles - * that are present in the SEI message - * @param pan_scan_rect_left_offset :Specifies as signed integer quantities - * in units of one-sixteenth sample spacing relative to the luma - * sampling grid, the location of the pan-scan rectangle - * @param pan_scan_rect_right_offset :Specifies as signed integer quantities - * in units of one-sixteenth sample spacing relative to the luma - * sampling grid, the location of the pan-scan rectangle - * @param pan_scan_rect_top_offset : Top offset - * @param pan_scan_rect_bottom_offset : Bottom offset - * @param pan_scan_rect_repetition_period :Specifies the persistence of the - * pan-scan rectangle SEI message and may specify a picture order - * count interval within which another pan-scan rectangle SEI message - * with the same value of pan_scan_rect_id or the end of the coded - * video sequence shall be present in the bit-stream - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiPanScanRect { - OMX_U32 parsed_flag; - OMX_U32 pan_scan_rect_id; - OMX_U32 pan_scan_rect_cancel_flag; - OMX_U32 pan_scan_cnt_minus1; - OMX_S32 pan_scan_rect_left_offset[3]; - OMX_S32 pan_scan_rect_right_offset[3]; - OMX_S32 pan_scan_rect_top_offset[3]; - OMX_S32 pan_scan_rect_bottom_offset[3]; - OMX_U32 pan_scan_rect_repetition_period; -} OMX_TI_VIDEO_H264VDEC_SeiPanScanRect; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiProgRefineStart - * - * @brief This structure contains the progressive refinement start SEI msg - * elements - * - * @param parsed_flag :1 - Indicates that in the current process call, - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param progressive_refinement_id :Specifies an identification number for - * the progressive refinement operation. - * @param num_refinement_steps_minus1 :Specifies the number of reference - * frames in the tagged set of consecutive coded pictures - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiProgRefineStart { - OMX_U32 parsed_flag; - OMX_U32 progressive_refinement_id; - OMX_U32 num_refinement_steps_minus1; -} OMX_TI_VIDEO_H264VDEC_SeiProgRefineStart; -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiProgRefineEnd - * - * @brief TThis structure contains the progressive refinement end SEI msg - * elements - * - * @param parsed_flag :1 - Indicates that in the current process call, - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param progressive_refinement_id :Specifies an identification number for - * the progressive refinement operation. - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiProgRefineEnd { - OMX_U32 parsed_flag; - OMX_U32 progressive_refinement_id; -} OMX_TI_VIDEO_H264VDEC_SeiProgRefineEnd; -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiRecoveryPointInfo - * - * @brief This structure contains the sRecovery Point Info SEI msg elements - * - * @param parsed_flag :1 - Indicates that in the current process call, - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param exact_match_flag :Indicates whether decoded pictures at and - * subsequent to the specified recovery point in output order derived - * by starting the decoding process at the access unit associated with - * the recovery point SEI message, will be an exact match to the - * pictures that would be produced by starting the decoding process - * at the location of a previous IDR access unit in the NAL unit stream. - * @param recovery_frame_cnt :Specifies the recovery point of output pictures - * in output order - * @param broken_link_flag :Indicates the presence or absence of a broken - * link in the NAL unit stream - * @param changing_slice_group_idc :Indicates whether decoded pictures are - * correct or approximately correct in content at and subsequent to - * the recovery point in output order when all macro-blocks of the - * primary coded pictures are decoded within the changing slice group - * period. - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiRecoveryPointInfo { - OMX_U32 parsed_flag; - OMX_U32 recovery_frame_cnt; - OMX_U32 exact_match_flag; - OMX_U32 broken_link_flag; - OMX_U32 changing_slice_group_idc; -} OMX_TI_VIDEO_H264VDEC_SeiRecoveryPointInfo; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiPictureTiming - * - * @brief This structure contains the picture timing SEI msg elements - * - * @param parsed_flag :1 - Indicates that in the current process call, - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param NumClockTs : - * @param cpb_removal_delay :Specifies how many clock ticks to wait after - * removal from the CPB of the access unit associated with the - * most recent buffering period SEI message before removing from - * the buffer the access unit data associated with the picture - * timing SEI message. - * @param dpb_output_delay : Used to compute the DPB output time of the - * picture. - * @param pic_struct : Indicates whether a picture should be displayed as - * a frame or field - * @param clock_time_stamp_flag[4]:1 - Indicates number of clock timestamp - * syntax elements present and follow immediately - * 0 \u2013 Indicates associated clock timestamp syntax - * elements not present - * @param ct_type[4] : Indicates the scan type(interlaced or progressive) - * of the source material - * @param nuit_field_based_flag[4] : Used to calculate the clockTimestamp - * @param counting_type[4] : Specifies the method of dropping values of - * n_frames - * @param full_timestamp_flag[4] : 1 - Specifies that the n_frames syntax - * element is followed by seconds_value, - * minutes_value, and hours_value. - * 0 - Specifies that the n_frames syntax - * element is followed by seconds_flag - * @param discontinuity_flag[4] : Indicates whether the difference between - * the current value of clockTimestamp and the value of - * clockTimestamp computed from the previous clockTimestamp in - * output order can be interpreted as the time difference between - * the times of origin or capture of the associated frames or - * fields. - * @param cnt_dropped_flag[4] : Specifies the skipping of one or more - * values of n_frames using the counting method - * @param n_frames[4] : Specifies the value of nFrames used to compute - * clockTimestamp. - * @param seconds_flag[4] : equal to 1 specifies that seconds_value and - * minutes_flag are present when - * full_timestamp_flag is equal to 0. - * @param minutes_flag[4] : equal to 1 specifies that minutes_value and - * hours_flag are present when full_timestamp_flag - * is equal to 0 and seconds_flag is equal to 1. - * @param hours_flag[4] : equal to 1 specifies that hours_value is - * present when full_timestamp_flag is equal to 0 - * and seconds_flag is equal to 1 and minutes_flag - * is equal to 1. - * @param seconds_value[4] : Specifies the value of sS used to compute - * clockTimestamp. - * @param minutes_value[4] : Specifies the value of mM used to compute - * clockTimestamp. - * @param hours_value[4] : Specifies the value of tOffset used to compute - * clockTimestamp - * @param time_offset[4] : Specifies the value of tOffset used to compute - * clockTimestamp - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiPictureTiming { - OMX_U32 parsed_flag; - OMX_U32 NumClockTs; - OMX_U32 cpb_removal_delay; - OMX_U32 dpb_output_delay; - OMX_U32 pic_struct; - OMX_U32 clock_time_stamp_flag[4]; - OMX_U32 ct_type[4]; - OMX_U32 nuit_field_based_flag[4]; - OMX_U32 counting_type[4]; - OMX_U32 full_timestamp_flag[4]; - OMX_U32 discontinuity_flag[4]; - OMX_U32 cnt_dropped_flag[4]; - OMX_U32 n_frames[4]; - OMX_U32 seconds_flag[4]; - OMX_U32 minutes_flag[4]; - OMX_U32 hours_flag[4]; - OMX_U32 seconds_value[4]; - OMX_U32 minutes_value[4]; - OMX_U32 hours_value[4]; - OMX_S32 time_offset[4]; -}OMX_TI_VIDEO_H264VDEC_SeiPictureTiming; -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiFullFrameFreezeRep - * - * @brief This structure contains the full frmae freeze repetition SEI msg - * elements - * - * @param parsed_flag :1 - Indicates that in the current process call, - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param full_frame_freeze_repetition_period :Specifies the persistence of - * the full-frame freeze SEI message - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiFullFrameFreezeRep { - OMX_U32 parsed_flag; - OMX_U32 full_frame_freeze_repetition_period; -} OMX_TI_VIDEO_H264VDEC_SeiFullFrameFreezeRep; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiFullFrameFreezeRel - * - * @brief This structure contains frame freeze release SEI msg elements - * - * @param parsed_flag :1 - Indicates that in the current process call, - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param payloadSize : Size of the frame_freeze_release payload - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiFullFrameFreezeRel { - OMX_U32 parsed_flag; - OMX_U32 payloadSize; -} OMX_TI_VIDEO_H264VDEC_SeiFullFrameFreezeRel; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiStereoVideoInfo - * - * @brief This structure contains stereo video information SEI msg elements - * - * @param parsed_flag :1 - Indicates that in the current process call, - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param field_views_flag : 1 - indicates that all pictures in the current - * coded video sequence are fields - * 0 - indicates that all pictures in the current - * coded video sequence are frames. - * @param top_field_is_left_view_flag : - * 1 - top field is a left view. - * 0 - topfield is right view. - * @param current_frame_is_left_view_flag : - * 1 - current frame is left view. - * 0 - current frame is right view. - * @param next_frame_is_second_view_flag : - * 1 - current picture and a next picture in - * output order form a stereo video pair. - * 0 - current picture and a previous picture in - * output order form a stereo video pair. - * @param left_view_self_contained_flag : - * 1 - it will not use right view as a reference - * picture for inter prediction - * 0 - it may use right view as a reference - * picture for inter prediction. - * @param right_view_self_contained_flag : - * 1 - it will not use left view as a reference - * picture for inter prediction - * 0 - it may use left view as a reference - * picture for inter prediction. - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiStereoVideoInfo { - OMX_U32 parsed_flag; - OMX_U32 field_views_flag; - OMX_U32 top_field_is_left_view_flag; - OMX_U32 current_frame_is_left_view_flag; - OMX_U32 next_frame_is_second_view_flag; - OMX_U32 left_view_self_contained_flag; - OMX_U32 right_view_self_contained_flag; -} OMX_TI_VIDEO_H264VDEC_SeiStereoVideoInfo; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiFramePacking - * - * @brief This structure contains frame packing arrangement SEI msg elements - * - * @param frame_packing_arrangement_id : - * contains an identifying number that may be used to identify - * the usage of the frame packing arrangement SEI message. - * @param frame_packing_arrangement_cancel_flag : - * 1 - equal to 1 indicates that the frame packing arrangement - * SEI message cancels the persistence of any previous frame - * packing arrangement SEI message in output order. - * 0 - indicates that frame packing arrangement info follows - * @param frame_packing_arrangement_type : - * indicates the type of packing arrangement of the frames - * @param quincunx_sampling_flag : - * 1 - indicates that each color component plane of each - * constituent frame is quincunx sampled - * 0 - indicates that each color component plane of each - * constituent frame is not quincunx sampled - * @param content_interpretation_type : - * 1 - frame 0 being associated with the left view and frame 1 - * being associated with the right view - * 2 - frame 0 being associated with the right view and frame 1 - * being associated with the left view - * @param spatial_flipping_flag : - * 1 - spatial flipping is enabled for any one of the frame - * constituent, if frame_packing_arrangement_type is 3 or 4. - * 0 - spatial flipping is disabled for any one of the frame - * constituent, if frame_packing_arrangement_type is 3 or 4. - * @param frame0_flipped_flag : - * 1 - frame 0 is spatially flipped - * 0 - frame 1 is spatially flipped - * @param field_views_flag : - * 1 - indicates that all pictures in the current coded video - * sequence are coded as complementary field pairs. - * 0 - indicates that all pictures in the current coded video - * sequence are coded as frame. - * @param current_frame_is_frame0_flag : - * 1 - indicates that the current decoded frame is constituent - * frame 0 and the next decoded frame in output order - * is constituent frame 1. - * 0 - indicates that the current decoded frame is constituent - * frame 1 and the next decoded frame in output order - * is constituent frame 0. - * @param frame0_self_contained_flag : - * 1 - indicates that the constituent frame 0 is dependent on - * constituent frame 1 in decoding process - * 0 - indicates that the constituent frame 0 may dependent on - * constituent frame 1 in decoding process - * @param frame1_self_contained_flag : - * 1 - indicates that the constituent frame 1 is dependent on - * constituent frame 0 in decoding process - * 0 - indicates that the constituent frame 1 may dependent on - * constituent frame 0 in decoding process - * @param frame0_grid_position_x : - * specifies the horizontal location of the upper left - * sample of constituent frame 0 in the units of one - * sixteenth of the luma samples - * @param frame0_grid_position_y : - * specifies the vertical location of the upper left - * sample of constituent frame 0 in the units of one - * sixteenth of the luma samples - * @param frame1_grid_position_x : - * specifies the horizontal location of the upper left - * sample of constituent frame 1 in the units of one - * sixteenth of the luma samples - * @param frame1_grid_position_y : - * specifies the vertical location of the upper left - * sample of constituent frame 1 in the units of one - * sixteenth of the luma samples - * @param frame_packing_arrangement_reserved_byte : - * reserved for the future use. - * @param frame_packing_arrangement_repetition_period : - * specifies the persistence of the frame packing arrangement - * SEI message and may specify a frame order count interval - * within which another frame packing arrangement SEI message - * with the same value of frame_packing_arrangement_id or the - * end of the coded video sequence shall be present in the - * bitstream. - * @param frame_packing_arrangement_extension_flag : - * 0 - indicates that no additional data follows within the - * frame packing arrangement SEI message. - * 1 - Reserved for the future use. - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiFramePacking { - OMX_U32 parsed_flag; - OMX_U32 frame_packing_arrangement_id; - OMX_U32 frame_packing_arrangement_repetition_period; - OMX_U8 frame_packing_arrangement_cancel_flag; - OMX_U8 frame_packing_arrangement_type; - OMX_U8 quincunx_sampling_flag; - OMX_U8 content_interpretation_type; - OMX_U8 spatial_flipping_flag; - OMX_U8 frame0_flipped_flag; - OMX_U8 field_views_flag; - OMX_U8 current_frame_is_frame0_flag; - OMX_U8 frame0_self_contained_flag; - OMX_U8 frame1_self_contained_flag; - OMX_U8 frame0_grid_position_x; - OMX_U8 frame0_grid_position_y; - OMX_U8 frame1_grid_position_x; - OMX_U8 frame1_grid_position_y; - OMX_U8 frame_packing_arrangement_reserved_byte; - OMX_U8 frame_packing_arrangement_extension_flag; -} OMX_TI_VIDEO_H264VDEC_SeiFramePacking; - - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_SeiMessages - * - * @brief This structure contains all the supported SEI msg objects - * - * @param parsed_flag :1 - Indicates that in the current process call, - * contents of the structure is updated - * 0 - Indicates contents of the structure is not updated - * @param full_frame_freeze : Full-frame freeze SEI message - * @param full_frame_freeze_release :Cancels the effect of any full-frame - * freeze SEI message sent with pictures that precede the current - * picture in the output order. - * @param prog_refine_start :Specifies the beginning of a set of consecutive - * coded pictures that is labeled as the current picture followed - * by a sequence of one or more pictures of refinement of the - * quality of the current picture, rather than as a representation - * of a continually moving scene. - * @param prog_refine_end : Specifies end of progressive refinement. - * @param user_data_registered :Message contains user data registered as - * specified by ITU-T Recommendation T.35 - * @param user_data_unregistered :Message contains unregistered user data - * identified by a UUID - * @param buffering_period_info :Message specifies the buffering period - * @param pan_scan_rect :Message specifies the coordinates of a rectangle - * relative to the cropping rectangle of the sequence parameter set - * @param recovery_pt_info :The recovery point SEI message assists a decoder - * in determining when the decoding process will produce acceptable - * pictures for display after the decoder initiates random access or - * after the encoder indicates a broken link in the sequence. - * @param pic_timing :Specifies timing information regarding cpb delays, dpb -* output delay, and so on. - * @param stereo_video_info :stereo video information SEI message consist of - * pair of picture forming stereo view content. - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_SeiMessages { - OMX_U32 parsed_flag; - OMX_TI_VIDEO_H264VDEC_SeiFullFrameFreezeRep full_frame_freeze; - OMX_TI_VIDEO_H264VDEC_SeiFullFrameFreezeRel full_frame_freeze_release; - OMX_TI_VIDEO_H264VDEC_SeiProgRefineStart prog_refine_start; - OMX_TI_VIDEO_H264VDEC_SeiProgRefineEnd prog_refine_end; - OMX_TI_VIDEO_H264VDEC_SeiUserDataRegITUT user_data_registered; - OMX_TI_VIDEO_H264VDEC_SeiUserDataUnReg user_data_unregistered; - OMX_TI_VIDEO_H264VDEC_SeiBufferingPeriod buffering_period_info; - OMX_TI_VIDEO_H264VDEC_SeiPanScanRect pan_scan_rect; - OMX_TI_VIDEO_H264VDEC_SeiRecoveryPointInfo recovery_pt_info; - OMX_TI_VIDEO_H264VDEC_SeiPictureTiming pic_timing; - OMX_TI_VIDEO_H264VDEC_SeiStereoVideoInfo stereo_video_info; - OMX_TI_VIDEO_H264VDEC_SeiFramePacking frame_packing; -} OMX_TI_VIDEO_H264VDEC_SeiMessages; - - -/** - ****************************************************************************** - * @struct _sErrConcealStr - * @brief This str holds up the required Info for implementing the SCV EC, - * this will get updated by H.264 decoder while decoding the SVC - * Base/Target Layers - * - * @param CurrMbInfoBufPointer :Base Address of the current decoded frame - * MB Info buffer - * - * @param CurrMbStatusBufPointer: Base Address of the current decoded frame - * MB staus buffer pointer - * - * @param currFrameY : Base Address of the current decoded Luma - * frame buffer pointer (physical pointer) - * - * @param currFrameUV : Base Address of the current decoded Chroma - * frame buffer pointer (physical pointer) - * - * @param refConclY : Base Address of the ref decoded Luma - * frame buffer pointer (virtual pointer) - * - * @param refConclUV : Base Address of the ref decoded Chroma - * frame buffer pointer (virtual pointer) - * - * @param TilerBaseAddress : TBA vaule for the VDMA - * - * @param pSliceInfoFlags : Flag to enable slice info - * - * @param ref_width : Resultant Horizontal LUMA picture size - * after Pad size addition on both Left - * & Right sides. This gets used as - * stride during vDMA programming. - * In case of TILER,the stride is fixed, - * independant of Picture width, and - * only changes with TILER mode. - * - * @param ref_width_c : Resultant Horizontal CHROMA picture size - * after Pad size addition on both Left & - * Right sides. - * - * - * @param ref_frame_height : In case of Interlaced streams,the picure - * store is different i.e., store each field - * by applying PAD on top & bottom lines. - * Hence the picture height will be Height - * plus four times the Pad size. This - * variable holds this resultant value. - * - * @param mb_width : Picture width in terms of Macroblocks - * - * @param mb_height : Picture height in terms of Macroblocks. - * - * @param image_width : Image width of the decoded frame - * - * @param image_width : Image height of the decoded frame - * - * @param frameType : Frame type of the current frame. - * - * @param picaff_frame : Flag to indicate whether current picture - * is of Frame type & referring to Field - * picture as reference. - * - * @param mb_aff_frame_flag : Flag to indicate whether the current - * decoding picture is MBAFF type. - * - * @param field_pic_flag : Flag to indicate whether the current - * decoding picture is field type. - * - * @param bottom_field_flag : This parameter equal to 1 specifies that - * the slice is part of a coded bottom field. - * bottom_field_flag equalto 0 specifies - * that the picture is a coded top field. - * - * @param nonPairedFieldPic : Flag to indicate Non paired field picture. - * - * @param prev_pic_bottom_field : this variable Indicates if the previous - * picture was a bottom field or not (a Flag) - ****************************************************************************** -*/ - -typedef struct OMX_TI_VIDEO_H264VDEC_ErrConcealStr { - OMX_S32 ErrConcealmentEnable; - OMX_S32 CurrMbInfoBufPointer; - OMX_S32 CurrMbStatusBufPointer; - OMX_S32 CurrMbInfoIresBufPointer; - OMX_S32 currFrameY; - OMX_S32 currFrameUV; - OMX_S32 refConclY; - OMX_S32 refConclUV; - OMX_U32 TilerBaseAddress; - OMX_U16 ref_width; - OMX_U16 ref_width_c; - OMX_U16 ref_frame_height; - OMX_U16 mb_width; - OMX_U16 mb_height; - OMX_U16 image_width; - OMX_U16 image_height; - OMX_U8 frameType; - OMX_U8 picaff_frame; - OMX_U8 mb_aff_frame_flag; - OMX_U8 field_pic_flag; - OMX_U8 bottom_field_flag; - OMX_U8 nonPairedFieldPic; - OMX_U8 prev_pic_bottom_field; -}OMX_TI_VIDEO_H264VDEC_ErrConcealStr; - -/** - * Size of sliceinfo flags - We have two slice info flag arrays in SL2, one - * for ECD3 and the other for MC3. ECD3 flag is one bit per MB. Since Maximum - * supported number of MBs in a frame is 128 x 128 = 16384, we need 16384/8 = - * 2048 bytes for the slice info flag array for ECD3. But for the MC3 array, - * we always make the next bit also as 1 to enable loading into ping and pong - * memories of MCBUF. So we need an extra bit for the MC3 array, to avoid - * buffer overflow when the last MB is a new slice. To keep the next SL2 buffer - * in 16-byte aligned position (some buffers need it) we round the size to next - * multiple of 16, i.e., 2064. -*/ -#define OMX_TI_VIDEO_SLICEINFO_FLAGSIZE 2064 - -/** - ****************************************************************************** - * @struct _sErrConcealLayerStr - * @brief This str holds up the required Info for implementing the SCV EC, - * this will get updated by H.264 decoder while decoding the SVC - * Base/Target Layers - * - * @param svcEcStr : structure instance of sSVCErrConcealStr - * - * @param pSliceInfoFlags : Array to store the sliceInfo flag - * - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_ErrConcealLayerStr { - OMX_TI_VIDEO_H264VDEC_ErrConcealStr sECStr; - OMX_U8 pSliceInfoFlags[OMX_TI_VIDEO_SLICEINFO_FLAGSIZE]; -}OMX_TI_VIDEO_H264VDEC_ErrConcealLayerStr; - - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_CommonInfo - * - * @brief - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_CommonInfo { - OMX_U32 codec_type : 8; - OMX_U32 fmt_type : 8; - OMX_U32 mb_ll_avail : 1; - OMX_U32 mb_ul_avail : 1; - OMX_U32 mb_uu_avail : 1; - OMX_U32 mb_ur_avail : 1; - OMX_U32 pic_bound_l : 1; - OMX_U32 pic_bound_u : 1; - OMX_U32 pic_bound_r : 1; - OMX_U32 pic_bound_b : 1; - OMX_U32 first_mb_flag : 1; - OMX_U32 error_flag : 1; - OMX_U32 zero : 6; - OMX_U32 zeroes : 16; - OMX_U32 mb_addr : 16; - -} OMX_TI_VIDEO_H264VDEC_CommonInfo; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_MotionVector - * - * @brief - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_MotionVector { - OMX_S16 x; - OMX_S16 y; -} OMX_TI_VIDEO_H264VDEC_MotionVector; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_CabacContext - * - * @brief - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_CabacContext { - OMX_TI_VIDEO_H264VDEC_MotionVector mvd_l0[4]; - OMX_TI_VIDEO_H264VDEC_MotionVector mvd_l1[4]; - -} OMX_TI_VIDEO_H264VDEC_CabacContext; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_TotalCoefLuma - * - * @brief - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_TotalCoefLuma { - OMX_U8 right[3]; - OMX_U8 bottom_right; - OMX_U8 bottom[3]; - OMX_U8 zero; -} OMX_TI_VIDEO_H264VDEC_TotalCoefLuma; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_TotalCoefChroma - * - * @brief - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_TotalCoefChroma { - OMX_U8 right_cb; - OMX_U8 bottom_right_cb; - OMX_U8 bottom_cb; - OMX_U8 zero; - OMX_U8 right_cr; - OMX_U8 bottom_right_cr; - OMX_U8 bottom_cr; - OMX_U8 zero1; -} OMX_TI_VIDEO_H264VDEC_TotalCoefChroma; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_CavlcContext - * - * @brief - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_CavlcContext { - unsigned long long zeroes[2]; - OMX_TI_VIDEO_H264VDEC_TotalCoefLuma total_coef_luma; - OMX_TI_VIDEO_H264VDEC_TotalCoefChroma total_coef_chroma; - -} OMX_TI_VIDEO_H264VDEC_CavlcContext; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_IntraPredMode - * - * @brief - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_IntraPredMode { - OMX_U32 ipred_mode0 : 4; - OMX_U32 ipred_mode1 : 4; - OMX_U32 ipred_mode2 : 4; - OMX_U32 ipred_mode3 : 4; - OMX_U32 ipred_mode4 : 4; - OMX_U32 ipred_mode5 : 4; - OMX_U32 ipred_mode6 : 4; - OMX_U32 ipred_mode7 : 4; - OMX_U32 ipred_mode8 : 4; - OMX_U32 ipred_mode9 : 4; - OMX_U32 ipred_mode10 : 4; - OMX_U32 ipred_mode11 : 4; - OMX_U32 ipred_mode12 : 4; - OMX_U32 ipred_mode13 : 4; - OMX_U32 ipred_mode14 : 4; - OMX_U32 ipred_mode15 : 4; - -} OMX_TI_VIDEO_H264VDEC_IntraPredMode; - - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_MbPredType - * - * @brief - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_MbPredType { - OMX_U32 mbskip : 1; - OMX_U32 tr8x8 : 1; - OMX_U32 mb_field : 1; - OMX_U32 cond_mbskip : 1; - OMX_U32 c_ipred_mode : 2; - OMX_U32 zero : 1; - OMX_U32 end_of_slice : 1; - OMX_U32 mb_y_mod2 : 1; - OMX_U32 zero1 : 7; - OMX_U32 refidx_equal_flag_l0 : 1; - OMX_U32 refidx_equal_flag_l1 : 1; - OMX_U32 mv_equal_flag_l0 : 1; - OMX_U32 mv_equal_flag_l1 : 1; - OMX_U32 zeroes : 4; - OMX_U32 mb_type : 8; - OMX_U8 sub_mb_type[4]; - -} OMX_TI_VIDEO_H264VDEC_MbPredType; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_QpCbp - * - * @brief - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_QpCbp { - OMX_U32 cbp; - OMX_U8 qp_y; - OMX_U8 qp_cb; - OMX_U8 qp_cr; - OMX_U8 zero; -} OMX_TI_VIDEO_H264VDEC_QpCbp; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_RefPicControl - * - * @brief - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_RefPicControl { - OMX_U8 refidx[4]; - OMX_U8 refpicid[4]; - -} OMX_TI_VIDEO_H264VDEC_RefPicControl; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_MvBidirectional16 - * - * @brief - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_MvBidirectional16 { - OMX_TI_VIDEO_H264VDEC_MotionVector mv_forward[16]; - OMX_TI_VIDEO_H264VDEC_MotionVector mv_backward[16]; -} OMX_TI_VIDEO_H264VDEC_MvBidirectional16; - - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_MvBidirectional4 - * - * @brief - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_MvBidirectional4 { - OMX_TI_VIDEO_H264VDEC_MotionVector mv_forward[4]; - OMX_TI_VIDEO_H264VDEC_MotionVector mv_backward[4]; - -} OMX_TI_VIDEO_H264VDEC_MvBidirectional4; - -/** - ****************************************************************************** - * @struct OMX_TI_VIDEO_H264VDEC_MbInfo - * - * @brief This structure details the data format for MB information shared to - * application. This helps application to understand all fields - * the way codec uses MB info internally. This structure is of size - * 208 Bytes. - * - * @param info : This elements gives details about the MB placement in the - * frame. - * - * @param cabac: This field holds the context data for a CABAC coded MB - * - * @param cavlc: This field holds the context data for a CAVLC coded MB - * - * @param ipred_mode: This field holds information of intra prediction modes - * at 4x4 level, for intra coded MB. - * - * @param mb_pred_type: This indicates prediction specific details for inter - * coded MB - * - * @param qp_cbp: This gives coded & QP informations for both LUMA & CHROMA - * components of a Macro Block. - * - * @param l0_ref_pic_control: Informs all details about reference indices - * at 8x8 block level in L0 direction - * - * @param l1_ref_pic_control: Informs all details about reference indices - * at 8x8 block level in L1 direction - * - * @param mv_forward: Lists all Motion vectors at 4x4 level in L0 direction - * - * @param bidirectional16: Lists all Motion vectors at 4x4 level in both - * directions - * - * @param bidirectional4: Lists all Motion vectors at 8x8 level in both - * directions - * - ****************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_H264VDEC_MbInfo { - OMX_TI_VIDEO_H264VDEC_CommonInfo info; - - union { - OMX_TI_VIDEO_H264VDEC_CabacContext cabac; - OMX_TI_VIDEO_H264VDEC_CavlcContext cavlc; - } OMX_TI_VIDEO_H264VDEC_context; - - OMX_TI_VIDEO_H264VDEC_IntraPredMode ipred_mode; - OMX_TI_VIDEO_H264VDEC_MbPredType mb_pred_type; - OMX_TI_VIDEO_H264VDEC_QpCbp qp_cbp; - OMX_TI_VIDEO_H264VDEC_RefPicControl l0_ref_pic_control; - OMX_TI_VIDEO_H264VDEC_RefPicControl l1_ref_pic_control; - - union { - OMX_TI_VIDEO_H264VDEC_MotionVector mv_forward[16]; - OMX_TI_VIDEO_H264VDEC_MvBidirectional16 bidirectional16; - OMX_TI_VIDEO_H264VDEC_MvBidirectional4 bidirectional4; - } OMX_TI_VIDEO_H264VDEC_motion_vecs; - -} OMX_TI_VIDEO_H264VDEC_MbInfo; - - - -/** -******************************************************************************** -* @struct OMX_TI_VIDEO_VC1VDEC_MbInfo -* -* @brief MB information structure that is written out by the IVA-HD hardware. -* -* @note None: -* -******************************************************************************** -*/ -typedef struct OMX_TI_VIDEO_VC1VDEC_MbInfo { - /* MB address */ - OMX_U8 mb_addr; - /* Error flag */ - OMX_U8 error_flag; - /* First MB flag */ - OMX_U8 first_mb_flag; - /* Picture bound */ - OMX_U8 pic_bound_b; - /* Upper picture bound */ - OMX_U8 pic_bound_u; - /* Right picture bound */ - OMX_U8 pic_bound_r; - /* Left picture bound */ - OMX_U8 pic_bound_l; - /* Availability of upper right MB */ - OMX_U8 mb_ur_avail; - /* Availability of upper MB */ - OMX_U8 mb_uu_avail; - /* Availability of upper left MB */ - OMX_U8 mb_ul_avail; - /* Availability of left MB */ - OMX_U8 mb_ll_avail; - /* Macroblock header format type */ - OMX_U8 fmt_type; - /* Codec type */ - OMX_U8 codec_type; - /* Indicates DC values of each Y block in current MB */ - OMX_U8 dc_coef_q_y[4]; - /* Indicates DC values of Cr block in current MB */ - OMX_U8 dc_coef_q_cr; - /* Indicates DC values of Cb block in current MB */ - OMX_U8 dc_coef_q_cb; - /* Block type of cr block */ - OMX_U8 block_type_cr; - /* Block type of cb block */ - OMX_U8 block_type_cb; - /* Block types of luma */ - OMX_U8 block_type_y[4]; - /* In decoding, if the current macroblock is the last macroblock in a slice,*/ - /* ECD sets 1 to this field during executing the macroblock. Otherwise, ECD */ - /* sets 0 to this field */ - OMX_U8 end_of_slice; - /* 1 : allow skipping current MB if CBP = 0 */ - OMX_U8 cond_skip_flag; - /* Skipped / non skipped MB */ - OMX_U8 skip; - /* 1 indicates that overlap filtering is in use for the macroblock. */ - OMX_U8 overlap; - /* 1 indicates that AC prediction is in use for the macroblock */ - OMX_U8 acpred; - /* Denotes inter-prediction direction for the macroblock in B-picture */ - OMX_U8 b_picture_direction; - /* Denotes the number of motion vectors. */ - OMX_U8 mv_mode; - /* 1 indicates that the field transform is in use for the macroblock. */ - OMX_U8 fieldtx; - /* 1 indicates that field inter-prediction is in use */ - OMX_U8 mv_type; - /* Equals the reference frame distance */ - OMX_U8 refdist; - /* 1 indicates that macroblock quantizer-scale (MQUANT) overflows */ - OMX_U8 mquant_overflow; - /* Equals the quantizer-scale for the macroblock */ - OMX_U8 quant; - /* 1 indicates that 0.5 shall be added to PQUANT in calculation of */ - /* quantizer-scale. This field is valid for decoding only. */ - OMX_U8 halfqp; - /* Equals the DC coefficient step size which is derived from MQUANT in the */ - /* bit-stream */ - OMX_U8 dc_step_size; - /* Denotes the coded sub-block pattern for cr block */ - OMX_U8 cbp_cr; - /* Denotes the coded sub-block pattern for cb block */ - OMX_U8 cbp_cb; - /* Denotes the coded sub-block pattern for luma blocks */ - OMX_U8 cbp_y[3]; - /* Denotes the backward reference field picture */ - OMX_U8 mv_bw_ref_y[4]; - /* Denotes the forward reference field picture */ - OMX_U8 mv_fw_ref_y[3]; - /* Unclipped forward motion vector for luma */ - OMX_U8 mv_fw_y[4][4]; - /* Unclipped backward motion vector for luma */ - OMX_U8 mv_bw_y[1][1]; - /* Unclipped backward motion vector for chroma */ - OMX_U8 mv_bw_c[2]; - /* Unclipped forward motion vector for chroma */ - OMX_U8 mv_fw_c[2]; - /* Clipped forward motion vector for luma */ - OMX_U8 cmv_fw_y[4][4]; - /* Clipped backward motion vector for luma */ - OMX_U8 cmv_bw_y[4][4]; - /* Clipped forward motion vector for chroma */ - OMX_U8 cmv_fw_c[4][4]; - /* Clipped backward motion vector for chroma */ - OMX_U8 cmv_bw_c[4][4]; - -}OMX_TI_VIDEO_VC1VDEC_MbInfo; - -#endif /* OMX_TI_VIDEO_H */ - diff --git a/domx/omx_core/src/OMX_Core.c b/domx/omx_core/src/OMX_Core.c deleted file mode 100755 index 8d9b529..0000000 --- a/domx/omx_core/src/OMX_Core.c +++ /dev/null @@ -1,953 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include /* For dynamic loading */ -#include -#include -#include -#include - - -/* #include "OMX_RegLib.h" */ -#include "OMX_Component.h" -#include "OMX_Core.h" -#include "OMX_ComponentRegistry.h" - -#include "timm_osal_types.h" -#include "timm_osal_error.h" -#include "timm_osal_trace.h" -#include "timm_osal_mutex.h" - -#ifdef CHECK_SECURE_STATE -#include -#include -#include -#endif - -/** size for the array of allocated components. Sets the maximum - * number of components that can be allocated at once */ -#define MAXCOMP (50) -#define MAXNAMESIZE (128) -#define EMPTY_STRING "\0" - -/** Determine the number of elements in an array */ -#define COUNTOF(x) (sizeof(x)/sizeof(x[0])) - -/** Array to hold the DLL pointers for each allocated component */ -static void *pModules[MAXCOMP] = { 0 }; - -/** Array to hold the component handles for each allocated component */ -static void *pComponents[COUNTOF(pModules)] = { 0 }; - -/* count for call OMX_Init() */ -int count = 0; -pthread_mutex_t mutex; -TIMM_OSAL_PTR pCoreInitMutex = NULL; - -int tableCount = 0; -ComponentTable componentTable[MAX_TABLE_SIZE]; -char *sRoleArray[60][20]; -char compName[60][200]; - - -char *tComponentName[MAXCOMP][MAX_ROLES] = { - /*video and image components */ - {"OMX.TI.DUCATI1.VIDEO.DECODER", - "video_decoder.mpeg4", - "video_decoder.avc", - "video_decoder.h263", - "video_decoder.wmv", - "video_decoder.mpeg2", - "video_decoder.svc", - "video_decoder.sorspk", NULL}, - {"OMX.TI.DUCATI1.VIDEO.DECODER.secure", - "video_decoder.mpeg4", - "video_decoder.avc", - "video_decoder.h263", NULL}, - {"OMX.TI.DUCATI1.VIDEO.H264E", - "video_encoder.avc", NULL}, - {"OMX.TI.DUCATI1.VIDEO.MPEG4E", - "video_encoder.mpeg4", - "video_encoder.h263",NULL}, - {"OMX.TI.DUCATI1.VIDEO.CAMERA", "camera.omx", NULL}, -#ifdef USE_ITTIAM_AAC - {"OMX.ITTIAM.AAC.decode", "audio_decoder.aac", NULL}, - {"OMX.ITTIAM.BSAC.decode", "audio_decoder.aac", NULL}, -#endif - {"OMX.ITTIAM.WMA.decode", "audio_decoder.wma", NULL}, - {"OMX.ITTIAM.WMALSL.decode", "audio_decoder.wmalsl", NULL}, - {"OMX.ITTIAM.WMAPRO.decode", "audio_decoder.wmapro", NULL}, - /* terminate the table */ - {NULL, NULL}, -}; - -//AD -extern OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent); - -#define CORE_assert CORE_paramCheck -#define CORE_require CORE_paramCheck -#define CORE_ensure CORE_paramCheck - -#define CORE_paramCheck(C, V, S) do {\ - if (!(C)) { eError = V;\ - TIMM_OSAL_Error("failed check: " #C);\ - TIMM_OSAL_Error(" - returning error: " #V);\ - if(S) TIMM_OSAL_Error(" - %s", S);\ - goto EXIT; }\ - } while(0) - -/******************************Public*Routine******************************\ -* OMX_Init() -* -* Description:This method will initialize the OMX Core. It is the -* responsibility of the application to call OMX_Init to ensure the proper -* set up of core resources. -* -* Returns: OMX_NOERROR Successful -* -* Note -* -\**************************************************************************/ -OMX_ERRORTYPE OMX_Init() -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE; - - eOsalError = TIMM_OSAL_MutexObtain(pCoreInitMutex, TIMM_OSAL_SUSPEND); - CORE_assert(eOsalError == TIMM_OSAL_ERR_NONE, - OMX_ErrorInsufficientResources, "Mutex lock failed"); - - count++; - - if (count == 1) - { - pthread_mutex_init(&mutex, NULL); - eError = OMX_BuildComponentTable(); - } - - eOsalError = TIMM_OSAL_MutexRelease(pCoreInitMutex); - CORE_assert(eOsalError == TIMM_OSAL_ERR_NONE, - OMX_ErrorInsufficientResources, "Mutex release failed"); - EXIT: - return eError; -} - -/******************************Public*Routine******************************\ -* OMX_GetHandle -* -* Description: This method will create the handle of the COMPONENTTYPE -* If the component is currently loaded, this method will reutrn the -* hadle of existingcomponent or create a new instance of the component. -* It will call the OMX_ComponentInit function and then the setcallback -* method to initialize the callback functions -* Parameters: -* @param[out] pHandle Handle of the loaded components -* @param[in] cComponentName Name of the component to load -* @param[in] pAppData Used to identify the callbacks of component -* @param[in] pCallBacks Application callbacks -* -* @retval OMX_ErrorUndefined -* @retval OMX_ErrorInvalidComponentName -* @retval OMX_ErrorInvalidComponent -* @retval OMX_ErrorInsufficientResources -* @retval OMX_NOERROR Successful -* -* Note -* -\**************************************************************************/ - -OMX_ERRORTYPE OMX_GetHandle(OMX_HANDLETYPE * pHandle, - OMX_STRING cComponentName, OMX_PTR pAppData, - OMX_CALLBACKTYPE * pCallBacks) -{ - static const char prefix[] = "lib"; - static const char postfix[] = ".so"; - OMX_ERRORTYPE(*pComponentInit) (OMX_HANDLETYPE *); - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *componentType; - int i; - char buf[sizeof(prefix) + MAXNAMESIZE + sizeof(postfix)]; - const char *pErr = dlerror(); - char *dlError = NULL; -#ifdef CHECK_SECURE_STATE - int secure_misc_drv_fd,ret; - OMX_U8 mode, enable=1; -#endif - if (pthread_mutex_lock(&mutex) != 0) - { - TIMM_OSAL_Error("Core: Error in Mutex lock"); - } - - CORE_require(NULL != cComponentName, OMX_ErrorBadParameter, NULL); - CORE_require(NULL != pHandle, OMX_ErrorBadParameter, NULL); - CORE_require(NULL != pCallBacks, OMX_ErrorBadParameter, NULL); - CORE_require(count > 0, OMX_ErrorUndefined, - "OMX_GetHandle called without calling OMX_Init first"); - - /* Verify that the name is not too long and could cause a crash. Notice - * that the comparison is a greater than or equals. This is to make - * sure that there is room for the terminating NULL at the end of the - * name. */ - CORE_require(strlen(cComponentName) < MAXNAMESIZE, - OMX_ErrorInvalidComponentName, NULL); - - /* Locate the first empty slot for a component. If no slots - * are available, error out */ - for (i = 0; i < (int)COUNTOF(pModules); i++) - { - if (pModules[i] == NULL) - break; - } - CORE_assert(i != COUNTOF(pModules), OMX_ErrorInsufficientResources, - NULL); - - /* load the component and check for an error. If filename is not an - * absolute path (i.e., it does not begin with a "/"), then the - * file is searched for in the following locations: - * - * The LD_LIBRARY_PATH environment variable locations - * The library cache, /etc/ld.so.cache. - * /lib - * /usr/lib - * - * If there is an error, we can't go on, so set the error code and exit */ - strcpy(buf, prefix); /* the lengths are defined herein or have been */ - strcat(buf, cComponentName); /* checked already, so strcpy and strcat are */ - strcat(buf, postfix); /* are safe to use in this context. */ - -#ifdef CHECK_SECURE_STATE - //Dont return errors from misc driver to the user if any. - //Since this affects all usecases, secure and non-secure. - //Do log the errors though. - secure_misc_drv_fd = open("/dev/rproc_user", O_SYNC | O_RDONLY); - if (secure_misc_drv_fd < 0) - { - TIMM_OSAL_Error("Can't open misc driver device 0x%x\n", errno); - } - else - { - ret = read(secure_misc_drv_fd, &mode, sizeof(mode)); - if (ret != sizeof(mode)) - { - TIMM_OSAL_Error("Can't read from the misc driver"); - } - else - { - if(mode == enable && strstr(cComponentName,"secure") == NULL) - { - TIMM_OSAL_Error("non-secure component not supported in secure mode"); - eError = OMX_ErrorComponentNotFound; - } - } - ret = close(secure_misc_drv_fd); - if (ret < 0) - { - TIMM_OSAL_Error("Can't close the misc driver"); - } - } - /* Don't allow non-secure usecases if we are in secure state. - * Else some of the memory regions will be unexpected firewalled. - * This provides a clean exit in case we are in secure mode. */ - if (eError == OMX_ErrorComponentNotFound) - { - goto EXIT; - } -#endif //CHECK_SECURE_STATE - - -//#if 0 - pModules[i] = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL); - if (pModules[i] == NULL) - { - dlError = (char *)dlerror(); - TIMM_OSAL_Error("Failed because %s", dlError); - eError = OMX_ErrorComponentNotFound; - goto EXIT; - } - - /* Get a function pointer to the "OMX_ComponentInit" function. If - * there is an error, we can't go on, so set the error code and exit */ - pComponentInit = dlsym(pModules[i], "OMX_ComponentInit"); - pErr = dlerror(); - CORE_assert(((pErr == NULL) && (pComponentInit != NULL)), - OMX_ErrorInvalidComponent, NULL); -//#endif - - /* We now can access the dll. So, we need to call the "OMX_ComponentInit" - * method to load up the "handle" (which is just a list of functions to - * call) and we should be all set.*/ - *pHandle = malloc(sizeof(OMX_COMPONENTTYPE)); - CORE_assert((*pHandle != NULL), OMX_ErrorInsufficientResources, - "Malloc of pHandle* failed"); - - pComponents[i] = *pHandle; - componentType = (OMX_COMPONENTTYPE *) * pHandle; - componentType->nSize = sizeof(OMX_COMPONENTTYPE); - - componentType->nVersion.s.nVersionMajor = 1; - componentType->nVersion.s.nVersionMinor = 1; - componentType->nVersion.s.nRevision = 0; - componentType->nVersion.s.nStep = 0; - - eError = (*pComponentInit) (*pHandle); -//eError = OMX_ComponentInit(*pHandle); - if (OMX_ErrorNone == eError) - { - eError = - (componentType->SetCallbacks) (*pHandle, pCallBacks, - pAppData); - CORE_assert(eError == OMX_ErrorNone, eError, - "Core: Error returned from component SetCallBack"); - } else - { - /* when the component fails to initialize, release the - component handle structure */ - free(*pHandle); - /* mark the component handle as NULL to prevent the caller from - actually trying to access the component with it, should they - ignore the return code */ - *pHandle = NULL; - pComponents[i] = NULL; - dlclose(pModules[i]); - goto EXIT; - } - eError = OMX_ErrorNone; - EXIT: - if (pthread_mutex_unlock(&mutex) != 0) - { - TIMM_OSAL_Error("Core: Error in Mutex unlock"); - } - return (eError); -} - - -/******************************Public*Routine******************************\ -* OMX_FreeHandle() -* -* Description:This method will unload the OMX component pointed by -* OMX_HANDLETYPE. It is the responsibility of the calling method to ensure that -* the Deinit method of the component has been called prior to unloading component -* -* Parameters: -* @param[in] hComponent the component to unload -* -* Returns: OMX_NOERROR Successful -* -* Note -* -\**************************************************************************/ -OMX_ERRORTYPE OMX_FreeHandle(OMX_HANDLETYPE hComponent) -{ - - OMX_ERRORTYPE eError = OMX_ErrorUndefined; - OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *) hComponent; - int i; - - if (pthread_mutex_lock(&mutex) != 0) - { - TIMM_OSAL_Error("Core: Error in Mutex lock"); - } - - CORE_require(pHandle != NULL, OMX_ErrorBadParameter, NULL); - CORE_require(count > 0, OMX_ErrorUndefined, - "OMX_FreeHandle called without calling OMX_Init first"); - - /* Locate the component handle in the array of handles */ - for (i = 0; i < (int)COUNTOF(pModules); i++) - { - if (pComponents[i] == hComponent) - break; - } - - CORE_assert(i != COUNTOF(pModules), OMX_ErrorBadParameter, NULL); - - eError = pHandle->ComponentDeInit(hComponent); - if (eError != OMX_ErrorNone) - { - TIMM_OSAL_Error("Error From ComponentDeInit.."); - } - - /* release the component and the component handle */ - dlclose(pModules[i]); - pModules[i] = NULL; - free(pComponents[i]); - - pComponents[i] = NULL; - eError = OMX_ErrorNone; - - EXIT: - /* The unload is now complete, so set the error code to pass and exit */ - if (pthread_mutex_unlock(&mutex) != 0) - { - TIMM_OSAL_Error("Core: Error in Mutex unlock"); - } - - return eError; -} - -/******************************Public*Routine******************************\ -* OMX_DeInit() -* -* Description:This method will release the resources of the OMX Core. It is the -* responsibility of the application to call OMX_DeInit to ensure the clean up of these -* resources. -* -* Returns: OMX_NOERROR Successful -* -* Note -* -\**************************************************************************/ -OMX_ERRORTYPE OMX_Deinit() -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE; - - eOsalError = TIMM_OSAL_MutexObtain(pCoreInitMutex, TIMM_OSAL_SUSPEND); - if (eOsalError != TIMM_OSAL_ERR_NONE) - { - TIMM_OSAL_Error("Mutex lock failed"); - } - /*Returning error none because of OMX spec limitation on error codes that - can be returned by OMX_Deinit */ - CORE_assert(count > 0, OMX_ErrorNone, - "OMX_Deinit being called without a corresponding OMX_Init"); - count--; - - if (pthread_mutex_lock(&mutex) != 0) - TIMM_OSAL_Error("Core: Error in Mutex lock"); - - if (count == 0) - { - if (pthread_mutex_unlock(&mutex) != 0) - TIMM_OSAL_Error("Core: Error in Mutex unlock"); - if (pthread_mutex_destroy(&mutex) != 0) - { - /*printf("%d :: Core: Error in Mutex destroy\n",__LINE__); */ - } - } else - { - if (pthread_mutex_unlock(&mutex) != 0) - TIMM_OSAL_Error("Core: Error in Mutex unlock"); - } - - EXIT: - eOsalError = TIMM_OSAL_MutexRelease(pCoreInitMutex); - if (eOsalError != TIMM_OSAL_ERR_NONE) - { - TIMM_OSAL_Error("Mutex release failed"); - } - return eError; -} - -/************************************************************************* -* OMX_SetupTunnel() -* -* Description: Setup the specified tunnel the two components -* -* Parameters: -* @param[in] hOutput Handle of the component to be accessed -* @param[in] nPortOutput Source port used in the tunnel -* @param[in] hInput Component to setup the tunnel with. -* @param[in] nPortInput Destination port used in the tunnel -* -* Returns: OMX_NOERROR Successful -* -* Note -* -**************************************************************************/ -/* OMX_SetupTunnel */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_SetupTunnel(OMX_IN OMX_HANDLETYPE - hOutput, OMX_IN OMX_U32 nPortOutput, OMX_IN OMX_HANDLETYPE hInput, - OMX_IN OMX_U32 nPortInput) -{ - OMX_ERRORTYPE eError = OMX_ErrorNotImplemented; - OMX_COMPONENTTYPE *pCompIn, *pCompOut; - OMX_TUNNELSETUPTYPE oTunnelSetup; - - if (hOutput == NULL && hInput == NULL) - return OMX_ErrorBadParameter; - - oTunnelSetup.nTunnelFlags = 0; - oTunnelSetup.eSupplier = OMX_BufferSupplyUnspecified; - - pCompOut = (OMX_COMPONENTTYPE *) hOutput; - - if (hOutput) - { - eError = - pCompOut->ComponentTunnelRequest(hOutput, nPortOutput, - hInput, nPortInput, &oTunnelSetup); - } - - - if (eError == OMX_ErrorNone && hInput) - { - pCompIn = (OMX_COMPONENTTYPE *) hInput; - eError = - pCompIn->ComponentTunnelRequest(hInput, nPortInput, - hOutput, nPortOutput, &oTunnelSetup); - if (eError != OMX_ErrorNone && hOutput) - { - /* cancel tunnel request on output port since input port failed */ - pCompOut->ComponentTunnelRequest(hOutput, nPortOutput, - NULL, 0, NULL); - } - } - - return eError; -} - -/************************************************************************* -* OMX_ComponentNameEnum() -* -* Description: This method will provide the name of the component at the given nIndex -* -*Parameters: -* @param[out] cComponentName The name of the component at nIndex -* @param[in] nNameLength The length of the component name -* @param[in] nIndex The index number of the component -* -* Returns: OMX_NOERROR Successful -* -* Note -* -**************************************************************************/ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(OMX_OUT OMX_STRING - cComponentName, OMX_IN OMX_U32 nNameLength, OMX_IN OMX_U32 nIndex) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - - CORE_require(cComponentName != NULL, OMX_ErrorBadParameter, NULL); - CORE_require(count > 0, OMX_ErrorUndefined, - "OMX_GetHandle called without calling OMX_Init first"); - - if (nIndex >= (OMX_U32)tableCount) - { - eError = OMX_ErrorNoMore; - } else - { - strcpy(cComponentName, componentTable[nIndex].name); - } - EXIT: - return eError; -} - - -/************************************************************************* -* OMX_GetRolesOfComponent() -* -* Description: This method will query the component for its supported roles -* -*Parameters: -* @param[in] cComponentName The name of the component to query -* @param[in] pNumRoles The number of roles supported by the component -* @param[in] roles The roles of the component -* -* Returns: OMX_NOERROR Successful -* OMX_ErrorBadParameter Faliure due to a bad input parameter -* -* Note -* -**************************************************************************/ -OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent(OMX_IN OMX_STRING - cComponentName, OMX_INOUT OMX_U32 * pNumRoles, OMX_OUT OMX_U8 ** roles) -{ - - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_U32 i = 0; - OMX_U32 j = 0; - OMX_BOOL bFound = OMX_FALSE; - - CORE_require(cComponentName != NULL, OMX_ErrorBadParameter, NULL); - CORE_require(pNumRoles != NULL, OMX_ErrorBadParameter, NULL); - CORE_require(strlen(cComponentName) < MAXNAMESIZE, - OMX_ErrorInvalidComponentName, NULL); - CORE_require(count > 0, OMX_ErrorUndefined, - "OMX_GetHandle called without calling OMX_Init first"); - - while (!bFound && i < (OMX_U32)tableCount) - { - if (strcmp(cComponentName, componentTable[i].name) == 0) - { - bFound = OMX_TRUE; - } else - { - i++; - } - } - if (roles == NULL) - { - *pNumRoles = componentTable[i].nRoles; - goto EXIT; - } else - { - if (bFound && (*pNumRoles == componentTable[i].nRoles)) - { - for (j = 0; j < componentTable[i].nRoles; j++) - { - strcpy((OMX_STRING) roles[j], - componentTable[i].pRoleArray[j]); - } - } - } - EXIT: - return eError; -} - -/************************************************************************* -* OMX_GetComponentsOfRole() -* -* Description: This method will query the component for its supported roles -* -*Parameters: -* @param[in] role The role name to query for -* @param[in] pNumComps The number of components supporting the given role -* @param[in] compNames The names of the components supporting the given role -* -* Returns: OMX_NOERROR Successful -* -* Note -* -**************************************************************************/ -OMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole(OMX_IN OMX_STRING role, - OMX_INOUT OMX_U32 * pNumComps, OMX_INOUT OMX_U8 ** compNames) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_U32 i = 0; - OMX_U32 j = 0; - OMX_U32 k = 0; - - CORE_require(role != NULL, OMX_ErrorBadParameter, NULL); - CORE_require(pNumComps != NULL, OMX_ErrorBadParameter, NULL); - CORE_require(count > 0, OMX_ErrorUndefined, - "OMX_GetHandle called without calling OMX_Init first"); - - /* This implies that the componentTable is not filled */ - CORE_assert(componentTable[i].pRoleArray[j] != NULL, - OMX_ErrorBadParameter, NULL); - - for (i = 0; i < (OMX_U32)tableCount; i++) - { - for (j = 0; j < componentTable[i].nRoles; j++) - { - if (strcmp(componentTable[i].pRoleArray[j], - role) == 0) - { - /* the first call to this function should only count the number - of roles so that for the second call compNames can be allocated - with the proper size for that number of roles */ - if (compNames != NULL) - { - strncpy((OMX_STRING) (compNames[k]), - (OMX_STRING) componentTable[i]. - name, MAXNAMESIZE); - } - k++; - } - } - *pNumComps = k; - } - - EXIT: - return eError; -} - - -/*************************************** -PRINT TABLE FOR DEBUGGING PURPOSES ONLY -***************************************/ - -OMX_API OMX_ERRORTYPE OMX_PrintComponentTable() -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - int i = 0; - int j = 0; - - TIMM_OSAL_Info - ("--------Component Table:: %d Components found-------------", - tableCount); - - for (i = 0; i < tableCount; i++) - { - TIMM_OSAL_Info("%i:: %s", i, componentTable[i].name); - for (j = 0; j < componentTable[i].nRoles; j++) - { - TIMM_OSAL_Info(" %s", - componentTable[i].pRoleArray[j]); - } - } - - TIMM_OSAL_Info - ("-----------------End Component Table ------------------"); - - return eError; - -} - - -OMX_ERRORTYPE OMX_BuildComponentTable() -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CALLBACKTYPE sCallbacks; -#ifndef STATIC_TABLE - OMX_HANDLETYPE hComp = 0; - OMX_U8 cRole[MAXNAMESIZE]; - OMX_STRING tempName = NULL; - OMX_STRING temp = NULL; - static OMX_STRING namePrefix = "OMX"; - static OMX_STRING filePrefix = "libOMX."; - static OMX_STRING suffix = ".so"; -#endif - int j = 0; - int numFiles = 0; - int i, k; - int componentfound = 0; - - /* set up dummy call backs */ - sCallbacks.EventHandler = ComponentTable_EventHandler; - sCallbacks.EmptyBufferDone = ComponentTable_EmptyBufferDone; - sCallbacks.FillBufferDone = ComponentTable_FillBufferDone; - -#ifndef STATIC_TABLE - /* allocate the name table */ - /* - compName = (OMX_STRING *) malloc(MAX_TABLE_SIZE * sizeof(OMX_STRING)); - sRoleArray = (OMX_STRING**) malloc(MAX_TABLE_SIZE * sizeof(OMX_STRING)); - */ - - /* scan the target/lib directory and create a list of files in the directory */ - numFiles = scandir(libdir, &namelist, 0, 0); - tableCount = 0; - while (numFiles--) - { - /* check if the file is an OMX component */ - if (strncmp(namelist[numFiles]->d_name, filePrefix, - strlen(filePrefix)) == 0) - { - - /* if the file is an OMX component, trim the prefix and suffix */ - tempName = (OMX_STRING) malloc(sizeof(namelist[numFiles]->d_name) + 1); /* adding one ensures */ - memset(tempName, 0x00, sizeof(namelist[numFiles]->d_name) + 1); /* that a null terminator will */ - /* always be present */ - /* copy only the name without the suffix */ - strncpy(tempName, namelist[numFiles]->d_name, - strlen(namelist[numFiles]->d_name) - - strlen(suffix)); - /* set a pointer to be after the lib prefix, i.e the beginning of the component name */ - temp = strstr(tempName, namePrefix); - - /* then copy the component name to the table */ - /* - compName[tableCount]= (OMX_STRING) malloc(MAXNAMESIZE); - */ - strncpy(compName[tableCount], temp, strlen(temp) + 1); - componentTable[tableCount].name = - compName[tableCount]; - - /* get the handle for the component and query for the roles of each component */ - eError = - OMX_GetHandle(&hComp, - componentTable[tableCount].name, 0x0, - &sCallbacks); - if (eError == OMX_ErrorNone) - { - j = 0; - while (eError != OMX_ErrorNoMore) - { - eError = - ((OMX_COMPONENTTYPE *) hComp)-> - ComponentRoleEnum(hComp, cRole, - j++); - if (eError == OMX_ErrorNotImplemented) - { - j = 1; - break; - } - } - nRoles = j - 1; - componentTable[tableCount].nRoles = nRoles; - /* sRoleArray[tableCount] = (OMX_STRING *) malloc(nRoles * sizeof(OMX_STRING)); */ - if (nRoles > 0) - { - /* sRoleArray[tableCount] = (OMX_STRING *) malloc(nRoles * sizeof(OMX_STRING)); */ - for (j = 0; j < nRoles; j++) - { - sRoleArray[tableCount][j] = - (OMX_STRING) - malloc(sizeof(OMX_U8) * - MAXNAMESIZE); - ((OMX_COMPONENTTYPE *) - hComp)-> - ComponentRoleEnum(hComp, - (OMX_U8 *) - sRoleArray[tableCount][j], - j); - componentTable[tableCount]. - pRoleArray[j] = - sRoleArray[tableCount][j]; - } - } else - { - /* sRoleArray[tableCount] = (OMX_STRING *) malloc(sizeof(OMX_STRING)); */ - sRoleArray[tableCount][j] = - (OMX_STRING) malloc(sizeof(OMX_U8) - * MAXNAMESIZE); - strcpy(sRoleArray[tableCount][j], - EMPTY_STRING); - componentTable[tableCount]. - pRoleArray[j] = - sRoleArray[tableCount][j]; - } - } - if (hComp) - { - /* free the component handle */ - eError = OMX_FreeHandle(hComp); - if (eError != OMX_ErrorNone) - { - goto EXIT; - } - } - /* increment the table counter index only if above was successful */ - tableCount++; - if (tempName != NULL) - { - free(tempName); - } - - } - } - -#endif - - for (i = 0, numFiles = 0; i < MAXCOMP; i++) - { - if (tComponentName[i][0] == NULL) - { - break; - } - - for (j = 0; j < numFiles; j++) - { - if (!strcmp(componentTable[j].name, - tComponentName[i][0])) - { - componentfound = 1; - break; - } - } - if (componentfound == 1) - { - continue; - } - - if (j == numFiles) - { /* new component */ - k = 1; - while (tComponentName[i][k] != NULL) - { - componentTable[numFiles].pRoleArray[k - 1] = - tComponentName[i][k]; - k++; - } - componentTable[numFiles].nRoles = k - 1; - strcpy(compName[numFiles], tComponentName[i][0]); - componentTable[numFiles].name = compName[numFiles]; - numFiles++; - } - } - tableCount = numFiles; - - CORE_assert(eError == OMX_ErrorNone, eError, - "Could not build Component Table"); - EXIT: - return eError; -} - -OMX_ERRORTYPE ComponentTable_EventHandler(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData) -{ - return OMX_ErrorNotImplemented; -} - -OMX_ERRORTYPE ComponentTable_EmptyBufferDone(OMX_OUT OMX_HANDLETYPE - hComponent, OMX_OUT OMX_PTR pAppData, - OMX_OUT OMX_BUFFERHEADERTYPE * pBuffer) -{ - return OMX_ErrorNotImplemented; -} - -OMX_ERRORTYPE ComponentTable_FillBufferDone(OMX_OUT OMX_HANDLETYPE hComponent, - OMX_OUT OMX_PTR pAppData, OMX_OUT OMX_BUFFERHEADERTYPE * pBuffer) -{ - return OMX_ErrorNotImplemented; -} - - - -/*===============================================================*/ -/** @fn Core_Setup : This function is called when the the OMX Core library is - * loaded. It creates a mutex, which is used during OMX_Init() - */ -/*===============================================================*/ -void __attribute__ ((constructor)) Core_Setup(void) -{ - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - - eError = TIMM_OSAL_MutexCreate(&pCoreInitMutex); - if (eError != TIMM_OSAL_ERR_NONE) - { - TIMM_OSAL_Error("Creation of default mutex failed"); - } -} - - - -/*===============================================================*/ -/** @fn Core_Destroy : This function is called when the the OMX Core library is - * unloaded. It destroys the mutex which was created by - * Core_Setup(). - * - */ -/*===============================================================*/ -void __attribute__ ((destructor)) Core_Destroy(void) -{ - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - - eError = TIMM_OSAL_MutexDelete(pCoreInitMutex); - if (eError != TIMM_OSAL_ERR_NONE) - { - TIMM_OSAL_Error("Destruction of default mutex failed"); - } -} diff --git a/domx/omx_core/src/OMX_Core_Wrapper.c b/domx/omx_core/src/OMX_Core_Wrapper.c deleted file mode 100755 index 6fbf3d7..0000000 --- a/domx/omx_core/src/OMX_Core_Wrapper.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifdef _Android - -/* #include "OMX_RegLib.h" */ -#include "OMX_Component.h" -#include "OMX_Core.h" -#include "OMX_ComponentRegistry.h" - -#include "OMX_Core_Wrapper.h" -#include "timm_osal_trace.h" -#undef LOG_TAG -#define LOG_TAG "OMX_CORE" - -/** determine capabilities of a component before acually using it */ -extern OMX_BOOL TIOMXConfigParser(OMX_PTR aInputParameters, - OMX_PTR aOutputParameters); - -#endif - - -#ifdef _Android -#ifdef _FROYO -OMX_BOOL TIOMXConfigParserRedirect(OMX_PTR aInputParameters, - OMX_PTR aOutputParameters) -{ - TIMM_OSAL_Entering("OMXConfigParserRedirect +\n"); - OMX_BOOL Status = OMX_FALSE; - - Status = TIOMXConfigParser(aInputParameters, aOutputParameters); - - TIMM_OSAL_Exiting("OMXConfigParserRedirect -\n"); - return Status; -} -#endif -OMX_ERRORTYPE TIComponentTable_EventHandler(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData) -{ - return OMX_ErrorNotImplemented; -} - -OMX_ERRORTYPE TIComponentTable_EmptyBufferDone(OMX_OUT OMX_HANDLETYPE - hComponent, OMX_OUT OMX_PTR pAppData, - OMX_OUT OMX_BUFFERHEADERTYPE * pBuffer) -{ - return OMX_ErrorNotImplemented; -} - -OMX_ERRORTYPE TIComponentTable_FillBufferDone(OMX_OUT OMX_HANDLETYPE - hComponent, OMX_OUT OMX_PTR pAppData, - OMX_OUT OMX_BUFFERHEADERTYPE * pBuffer) -{ - return OMX_ErrorNotImplemented; -} - - -OMX_API OMX_ERRORTYPE TIOMX_Init(void) -{ - TIMM_OSAL_Entering("TIOMX_Init\n"); - - return OMX_Init(); -} - -OMX_API OMX_ERRORTYPE TIOMX_Deinit(void) -{ - TIMM_OSAL_Entering("TIOMX_Deinit\n"); - - return OMX_Deinit(); -} - -OMX_API OMX_ERRORTYPE TIOMX_ComponentNameEnum(OMX_OUT OMX_STRING - cComponentName, OMX_IN OMX_U32 nNameLength, OMX_IN OMX_U32 nIndex) -{ - - TIMM_OSAL_Entering("TIOMX_ComponentNameEnum\n"); - - return OMX_ComponentNameEnum(cComponentName, nNameLength, nIndex); -} - -OMX_API OMX_ERRORTYPE TIOMX_GetHandle(OMX_OUT OMX_HANDLETYPE * pHandle, - OMX_IN OMX_STRING cComponentName, - OMX_IN OMX_PTR pAppData, OMX_IN OMX_CALLBACKTYPE * pCallBacks) -{ - - TIMM_OSAL_Entering("TIOMX_GetHandle\n"); - - return OMX_GetHandle(pHandle, cComponentName, pAppData, pCallBacks); -} - -OMX_API OMX_ERRORTYPE TIOMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent) -{ - TIMM_OSAL_Entering("TIOMX_FreeHandle\n"); - - return OMX_FreeHandle(hComponent); -} - -OMX_API OMX_ERRORTYPE TIOMX_GetComponentsOfRole(OMX_IN OMX_STRING role, - OMX_INOUT OMX_U32 * pNumComps, OMX_INOUT OMX_U8 ** compNames) -{ - - TIMM_OSAL_Entering("TIOMX_GetComponentsOfRole\n"); - - return OMX_GetComponentsOfRole(role, pNumComps, compNames); -} - -OMX_API OMX_ERRORTYPE TIOMX_GetRolesOfComponent(OMX_IN OMX_STRING compName, - OMX_INOUT OMX_U32 * pNumRoles, OMX_OUT OMX_U8 ** roles) -{ - - TIMM_OSAL_Entering("TIOMX_GetRolesOfComponent\n"); - - return OMX_GetRolesOfComponent(compName, pNumRoles, roles); -} - -OMX_API OMX_ERRORTYPE TIOMX_SetupTunnel(OMX_IN OMX_HANDLETYPE hOutput, - OMX_IN OMX_U32 nPortOutput, - OMX_IN OMX_HANDLETYPE hInput, OMX_IN OMX_U32 nPortInput) -{ - - TIMM_OSAL_Entering("TIOMX_SetupTunnel\n"); - - return OMX_SetupTunnel(hOutput, nPortOutput, hInput, nPortInput); -} - -OMX_API OMX_ERRORTYPE TIOMX_GetContentPipe(OMX_OUT OMX_HANDLETYPE * hPipe, - OMX_IN OMX_STRING szURI) -{ - - TIMM_OSAL_Entering("TIOMX_GetContentPipe\n"); - - //return OMX_GetContentPipe( - // hPipe, - // szURI); - return 0; -} -#endif diff --git a/domx/omx_proxy_component/Android.mk b/domx/omx_proxy_component/Android.mk deleted file mode 100644 index 93386e9..0000000 --- a/domx/omx_proxy_component/Android.mk +++ /dev/null @@ -1,208 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -# -# libOMX.TI.DUCATI1.VIDEO.DECODER -# - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../omx_core/inc \ - $(LOCAL_PATH)/../mm_osal/inc \ - $(LOCAL_PATH)/../domx \ - $(LOCAL_PATH)/../domx/omx_rpc/inc \ - hardware/libhardware/include \ - $(DEVICE_FOLDER)/hwc/ \ - frameworks/native/include/media/openmax - -LOCAL_SHARED_LIBRARIES := \ - libmm_osal \ - libc \ - libOMX_Core \ - liblog \ - libdomx \ - libhardware - -LOCAL_CFLAGS += -DLINUX -DTMS32060 -D_DB_TIOMAP -DSYSLINK_USE_SYSMGR -DSYSLINK_USE_LOADER -LOCAL_CFLAGS += -D_Android -DSET_STRIDE_PADDING_FROM_PROXY -DANDROID_QUIRK_CHANGE_PORT_VALUES -DUSE_ENHANCED_PORTRECONFIG -LOCAL_CFLAGS += -DANDROID_QUIRK_LOCK_BUFFER -DUSE_ION -DENABLE_GRALLOC_BUFFERS - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := omx_video_dec/src/omx_proxy_videodec.c omx_video_dec/src/omx_proxy_videodec_utils.c -LOCAL_MODULE := libOMX.TI.DUCATI1.VIDEO.DECODER -include $(BUILD_SHARED_LIBRARY) - -# -# libOMX.TI.DUCATI1.MISC.SAMPLE -# - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../omx_core/inc \ - $(LOCAL_PATH)/../mm_osal/inc \ - $(LOCAL_PATH)/../domx \ - $(LOCAL_PATH)/../domx/omx_rpc/inc \ - frameworks/native/include/media/openmax - -LOCAL_SHARED_LIBRARIES := \ - libmm_osal \ - libc \ - libOMX_Core \ - liblog \ - libdomx - -LOCAL_CFLAGS += -DTMS32060 -D_DB_TIOMAP -DSYSLINK_USE_SYSMGR -DSYSLINK_USE_LOADER -LOCAL_CFLAGS += -D_Android -DSET_STRIDE_PADDING_FROM_PROXY -DANDROID_QUIRK_CHANGE_PORT_VALUES -DUSE_ENHANCED_PORTRECONFIG -LOCAL_CFLAGS += -DANDROID_QUIRK_LOCK_BUFFER -DUSE_ION - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := omx_sample/src/omx_proxy_sample.c -LOCAL_MODULE := libOMX.TI.DUCATI1.MISC.SAMPLE -include $(BUILD_SHARED_LIBRARY) - - -# -# libOMX.TI.DUCATI1.VIDEO.CAMERA -# - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../omx_core/inc \ - $(LOCAL_PATH)/../mm_osal/inc \ - $(LOCAL_PATH)/../domx \ - $(DEVICE_FOLDER)/libion_ti/ \ - $(LOCAL_PATH)/../domx/omx_rpc/inc \ - frameworks/native/include/media/openmax - -LOCAL_SHARED_LIBRARIES := \ - libmm_osal \ - libc \ - libOMX_Core \ - liblog \ - libion_ti \ - libdomx - -LOCAL_CFLAGS += -DTMS32060 -D_DB_TIOMAP -DSYSLINK_USE_SYSMGR -DSYSLINK_USE_LOADER -LOCAL_CFLAGS += -D_Android -DSET_STRIDE_PADDING_FROM_PROXY -DANDROID_QUIRK_CHANGE_PORT_VALUES -DUSE_ENHANCED_PORTRECONFIG -LOCAL_CFLAGS += -DANDROID_QUIRK_LOCK_BUFFER -DUSE_ION - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := omx_camera/src/omx_proxy_camera.c -LOCAL_MODULE := libOMX.TI.DUCATI1.VIDEO.CAMERA -include $(BUILD_SHARED_LIBRARY) - -# -# libOMX.TI.DUCATI1.VIDEO.H264E -# - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../omx_core/inc \ - $(LOCAL_PATH)/../mm_osal/inc \ - $(LOCAL_PATH)/../domx \ - $(LOCAL_PATH)/../domx/omx_rpc/inc \ - system/core/include/cutils \ - $(DEVICE_FOLDER)/hwc \ - $(DEVICE_FOLDER)/camera/inc \ - frameworks/base/include/media/stagefright \ - frameworks/native/include/media/hardware \ - frameworks/native/include/media/openmax - -LOCAL_SHARED_LIBRARIES := \ - libmm_osal \ - libc \ - libOMX_Core \ - liblog \ - libdomx \ - libhardware \ - libcutils - - -LOCAL_CFLAGS += -DLINUX -DTMS32060 -D_DB_TIOMAP -DSYSLINK_USE_SYSMGR -DSYSLINK_USE_LOADER -LOCAL_CFLAGS += -D_Android -DSET_STRIDE_PADDING_FROM_PROXY -DANDROID_QUIRK_CHANGE_PORT_VALUES -DUSE_ENHANCED_PORTRECONFIG -LOCAL_CFLAGS += -DENABLE_GRALLOC_BUFFER -DANDROID_QUIRK_LOCK_BUFFER -DUSE_ION -LOCAL_CFLAGS += -DANDROID_CUSTOM_OPAQUECOLORFORMAT - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := omx_h264_enc/src/omx_proxy_h264enc.c -LOCAL_MODULE := libOMX.TI.DUCATI1.VIDEO.H264E -include $(BUILD_SHARED_LIBRARY) - -# -# libOMX.TI.DUCATI1.VIDEO.MPEG4E -# - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../omx_core/inc \ - $(LOCAL_PATH)/../mm_osal/inc \ - $(LOCAL_PATH)/../domx \ - $(LOCAL_PATH)/../domx/omx_rpc/inc \ - system/core/include/cutils \ - $(DEVICE_FOLDER)/hwc \ - $(DEVICE_FOLDER)/camera/inc \ - frameworks/base/include/media/stagefright \ - frameworks/native/include/media/hardware \ - frameworks/native/include/media/openmax - -LOCAL_SHARED_LIBRARIES := \ - libmm_osal \ - libc \ - libOMX_Core \ - liblog \ - libdomx \ - libhardware \ - libcutils - -LOCAL_CFLAGS += -DLINUX -DTMS32060 -D_DB_TIOMAP -DSYSLINK_USE_SYSMGR -DSYSLINK_USE_LOADER -LOCAL_CFLAGS += -D_Android -DSET_STRIDE_PADDING_FROM_PROXY -DANDROID_QUIRK_CHANGE_PORT_VALUES -DUSE_ENHANCED_PORTRECONFIG -LOCAL_CFLAGS += -DENABLE_GRALLOC_BUFFER -DANDROID_QUIRK_LOCK_BUFFER -DUSE_ION -LOCAL_CFLAGS += -DANDROID_CUSTOM_OPAQUECOLORFORMAT - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := omx_mpeg4_enc/src/omx_proxy_mpeg4enc.c -LOCAL_MODULE := libOMX.TI.DUCATI1.VIDEO.MPEG4E -include $(BUILD_SHARED_LIBRARY) - -# -# libOMX.TI.DUCATI1.VIDEO.DECODER.secure -# - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../omx_core/inc \ - $(LOCAL_PATH)/../mm_osal/inc \ - $(LOCAL_PATH)/../domx \ - $(LOCAL_PATH)/../domx/omx_rpc/inc \ - hardware/libhardware/include \ - $(DEVICE_FOLDER)/hwc/ \ - frameworks/native/include/media/openmax - -LOCAL_SHARED_LIBRARIES := \ - libmm_osal \ - libc \ - libOMX_Core \ - liblog \ - libdomx \ - libhardware \ - libOMX.TI.DUCATI1.VIDEO.DECODER - -LOCAL_CFLAGS += -DLINUX -DTMS32060 -D_DB_TIOMAP -DSYSLINK_USE_SYSMGR -DSYSLINK_USE_LOADER -LOCAL_CFLAGS += -D_Android -DSET_STRIDE_PADDING_FROM_PROXY -DANDROID_QUIRK_CHANGE_PORT_VALUES -DUSE_ENHANCED_PORTRECONFIG -LOCAL_CFLAGS += -DANDROID_QUIRK_LOCK_BUFFER -DUSE_ION -DENABLE_GRALLOC_BUFFERS - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := omx_video_dec/src/omx_proxy_videodec_secure.c -LOCAL_MODULE := libOMX.TI.DUCATI1.VIDEO.DECODER.secure -include $(BUILD_SHARED_LIBRARY) diff --git a/domx/omx_proxy_component/Makefile b/domx/omx_proxy_component/Makefile deleted file mode 100755 index 1ddc22b..0000000 --- a/domx/omx_proxy_component/Makefile +++ /dev/null @@ -1,89 +0,0 @@ -# -# Copyright 2001-2008 Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ---------------------------------------------------------------------------- -# Revision History -# -# -# SEP xx,2002 REF=ORG Swamy MC -# Original version. -# ---------------------------------------------------------------------------- - -#PROJROOT = $(ROOTDIR)/src - -include $(PROJROOT)/make/start.mk - -# Do not change above "include" line(s) - -# Arguments to tools, will move to make system once finalized. - -CFLAGS = -CDEFS = DEBUG - -EXEC_ARGS = -ST_LIB_ARGS = -SH_LIB_ARGS = - -# Define this macro if target runs in kernel mode -#__KERNEL__ = 1 - -# Target name and extension -# static library (ST_LIB): filename.a -# shared library soname (SH_LIB): filename.so.maj_ver.min_ver -# executable (EXEC) : filename.out - -TARGETNAME = - - -# TARGETTYPE must be EXEC, ST_LIB or SH_LIB in upper case. -#TARGETTYPE = ST_LIB -TARGETTYPE = - -# For shared object library, soname is filename.so.maj_ver -SH_SONAME = - -# Folders in which gmake will run before building current target - -SUBMODULES = \ -omx_sample \ -omx_video_dec \ -omx_h264_enc \ -omx_mpeg4_enc \ - -#video/omx_proxy_component/test - -# Filename must not begin with '.', '/' or '\' - -SOURCES = - -# Search path for include files - -INCLUDES = - -# Libraries needed for linking. - -ST_LIBS = -SH_LIBS = - -# Search path for library (and linker command) files. -# Current folder and target folder are included by default. - -LIBINCLUDES = - - -# Do not change below "include" line(s) - -include $(PROJROOT)/make/build.mk - diff --git a/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c b/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c deleted file mode 100755 index 0afb95e..0000000 --- a/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c +++ /dev/null @@ -1,909 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_proxy_camera.c - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework Tunnel Proxy component. - ****************************************************************************** - This is the proxy specific wrapper that passes the component name to the - generic proxy init() The proxy wrapper also does some runtime/static time - config on per proxy basis This is a thin wrapper that is called when - componentiit() of the proxy is called static OMX_ERRORTYPE PROXY_Wrapper_init - (OMX_HANDLETYPE hComponent, OMX_PTR pAppData); - this layer gets called first whenever a proxy s get handle is called - ****************************************************************************** - * @path WTSD_DucatiMMSW\omx\omx_il_1_x\omx_proxy_component\src - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version - *================================================================*/ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "omx_proxy_common.h" -#include "timm_osal_mutex.h" - -#ifdef USE_ION -#include -#include -#include -#include -#include -#include -#include -#endif - -#define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.CAMERA" -/*Needs to be specific for every configuration wrapper*/ - -#undef LOG_TAG -#define LOG_TAG "CameraHAL" - -#define DEFAULT_DCC 1 - -#define LINUX_PAGE_SIZE (4 * 1024) - -#define _PROXY_OMX_INIT_PARAM(param,type) do { \ - TIMM_OSAL_Memset((param), 0, sizeof (type)); \ - (param)->nSize = sizeof (type); \ - (param)->nVersion.s.nVersionMajor = 1; \ - (param)->nVersion.s.nVersionMinor = 1; \ - } while(0) - -/* VTC specific changes */ -#define MAX_NUM_INTERNAL_BUFFERS 4 -#define MAX_VTC_WIDTH 1920 -#define MAX_VTC_HEIGHT 1080 -#define BORDER_WIDTH 32 -#define BORDER_HEIGHT 32 -#define MAX_VTC_WIDTH_WITH_VNF (MAX_VTC_WIDTH + BORDER_WIDTH) -#define MAX_VTC_HEIGHT_WITH_VNF (MAX_VTC_HEIGHT + BORDER_HEIGHT) -#ifndef OMAP_TUNA -OMX_PTR gCamIonHdl[MAX_NUM_INTERNAL_BUFFERS][2]; -#endif - -/* Tiler heap resservation specific */ -#define OMAP_ION_HEAP_TILER_ALLOCATION_MASK (1<<4) -#ifndef OMAP_TUNA -/* store handles for tracking and freeing */ -OMX_PTR gComponentBufferAllocation[PROXY_MAXNUMOFPORTS][MAX_NUM_INTERNAL_BUFFERS]; -#endif - -/* Incase of multiple instance, making sure DCC is initialized only for - first instance */ -static OMX_S16 numofInstance = 0; -int dcc_flag = 0; -TIMM_OSAL_PTR cam_mutex = NULL; - -/* To store DCC buffer size */ -OMX_S32 dccbuf_size = 0; - -/* Ducati Mapped Addr */ -OMX_PTR DCC_Buff = NULL; - -#ifdef USE_ION -OMX_PTR DCC_Buff_ptr = NULL; -int ion_fd; -int mmap_fd; -#endif - -OMX_S32 read_DCCdir(OMX_PTR, OMX_STRING *, OMX_U16); -OMX_ERRORTYPE DCC_Init(OMX_HANDLETYPE); -OMX_ERRORTYPE send_DCCBufPtr(OMX_HANDLETYPE hComponent); -void DCC_DeInit(); -OMX_ERRORTYPE PROXY_ComponentDeInit(OMX_HANDLETYPE); -OMX_ERRORTYPE __PROXY_SetConfig(OMX_HANDLETYPE, OMX_INDEXTYPE, - OMX_PTR, OMX_PTR); -OMX_ERRORTYPE __PROXY_GetConfig(OMX_HANDLETYPE, OMX_INDEXTYPE, - OMX_PTR, OMX_PTR); -OMX_ERRORTYPE __PROXY_SetParameter(OMX_IN OMX_HANDLETYPE, OMX_INDEXTYPE, - OMX_PTR, OMX_PTR, OMX_U32); -OMX_ERRORTYPE __PROXY_GetParameter(OMX_IN OMX_HANDLETYPE, OMX_INDEXTYPE, - OMX_PTR, OMX_PTR); -OMX_ERRORTYPE PROXY_SendCommand(OMX_HANDLETYPE, OMX_COMMANDTYPE, - OMX_U32,OMX_PTR); -OMX_ERRORTYPE CameraMaptoTilerDuc(OMX_TI_CONFIG_SHAREDBUFFER *, OMX_PTR *); -//COREID TARGET_CORE_ID = CORE_APPM3; - -static OMX_ERRORTYPE ComponentPrivateDeInit(OMX_IN OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_U32 i, j; - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - if (dcc_flag) - { - eOsalError = - TIMM_OSAL_MutexObtain(cam_mutex, TIMM_OSAL_SUSPEND); - if (eOsalError != TIMM_OSAL_ERR_NONE) - { - TIMM_OSAL_Error("Mutex Obtain failed"); - } - - numofInstance = numofInstance - 1; - - eOsalError = TIMM_OSAL_MutexRelease(cam_mutex); - PROXY_assert(eOsalError == TIMM_OSAL_ERR_NONE, - OMX_ErrorInsufficientResources, "Mutex release failed"); - } -#ifndef OMAP_TUNA - for(i=0; i < MAX_NUM_INTERNAL_BUFFERS; i++) { - if (gCamIonHdl[i][0] != NULL) { - ion_free(pCompPrv->ion_fd, gCamIonHdl[i][0]); - gCamIonHdl[i][0] = NULL; - } - if (gCamIonHdl[i][1] != NULL) { - ion_free(pCompPrv->ion_fd, gCamIonHdl[i][1]); - gCamIonHdl[i][1] = NULL; - } - } - - for (i = 0; i < PROXY_MAXNUMOFPORTS; i++) { - for (j = 0; j < MAX_NUM_INTERNAL_BUFFERS; j++) { - if (gComponentBufferAllocation[i][j]) { - ion_free(pCompPrv->ion_fd, gComponentBufferAllocation[i][j]); - } - gComponentBufferAllocation[i][j] = NULL; - } - } -#endif - - eError = PROXY_ComponentDeInit(hComponent); - - EXIT: - return eError; -} - -static OMX_ERRORTYPE Camera_SendCommand(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_COMMANDTYPE eCmd, - OMX_IN OMX_U32 nParam, OMX_IN OMX_PTR pCmdData) - -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - static OMX_BOOL dcc_loaded = OMX_FALSE; - - OMX_ERRORTYPE dcc_eError = OMX_ErrorNone; - TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE; - OMX_U32 i; - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - if ((eCmd == OMX_CommandStateSet) && - (nParam == (OMX_STATETYPE) OMX_StateIdle)) - { - if (!dcc_loaded) - { - dcc_eError = DCC_Init(hComponent); - if (dcc_eError != OMX_ErrorNone) - { - DOMX_ERROR(" Error in DCC Init"); - } - /* Configure Ducati to use DCC buffer from A9 side - *ONLY* if DCC_Init is successful. */ - if (dcc_eError == OMX_ErrorNone) - { - dcc_eError = send_DCCBufPtr(hComponent); - if (dcc_eError != OMX_ErrorNone) - { - DOMX_ERROR(" Error in Sending DCC Buf ptr"); - } - DCC_DeInit(); - } - dcc_loaded = OMX_TRUE; - } - } -#ifndef OMAP_TUNA - else if (eCmd == OMX_CommandPortDisable) { - int i, j; - for (i = 0; i < MAX_NUM_INTERNAL_BUFFERS; i++) { - for (j = 0; j < PROXY_MAXNUMOFPORTS; j++) { - if (((j == nParam) || (nParam == OMX_ALL)) && - gComponentBufferAllocation[i][j]) - { - ion_free(pCompPrv->ion_fd, gComponentBufferAllocation[i][j]); - gComponentBufferAllocation[i][j] = NULL; - } - } - } - } -#endif - - eError = - PROXY_SendCommand(hComponent,eCmd,nParam,pCmdData); - - -EXIT: - - DOMX_EXIT("eError: %d", eError); - return eError; - -} - -/* ===========================================================================*/ -/** - * @name CameraGetConfig() - * @brief For some specific indices, buffer allocated on A9 side - * needs to be mapped and sent to Ducati. - * @param - * @return OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ - -static OMX_ERRORTYPE CameraGetConfig(OMX_IN OMX_HANDLETYPE - hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR pComponentParameterStructure) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_TI_CONFIG_SHAREDBUFFER *pConfigSharedBuffer = NULL; - OMX_PTR pTempSharedBuff = NULL; - OMX_U32 status = 0; - - switch (nParamIndex) - { - case OMX_TI_IndexConfigAAAskipBuffer: - case OMX_TI_IndexConfigCamCapabilities: - case OMX_TI_IndexConfigExifTags: - case OMX_TI_IndexConfigAlgoAreas: - pConfigSharedBuffer = - (OMX_TI_CONFIG_SHAREDBUFFER *) pComponentParameterStructure; - - pTempSharedBuff = pConfigSharedBuffer->pSharedBuff; - - // TODO(XXX): Cache API is not yet available. Client needs to - // allocate tiler buffer directly and assign to pSharedBuff. - // Ptr allocated by MemMgr_Alloc in uncacheable so there - // would be no need to cache API - - eError = __PROXY_GetConfig(hComponent, - nParamIndex, - pConfigSharedBuffer, - &(pConfigSharedBuffer->pSharedBuff)); - - PROXY_assert((eError == OMX_ErrorNone), eError, - "Error in GetConfig"); - - pConfigSharedBuffer->pSharedBuff = pTempSharedBuff; - - goto EXIT; - break; - default: - break; - } - - return __PROXY_GetConfig(hComponent, - nParamIndex, - pComponentParameterStructure, - NULL); - - EXIT: - return eError; -} - -/* ===========================================================================*/ -/** - * @name CameraSetConfig() - * @brief For some specific indices, buffer allocated on A9 side needs to - * be mapped and sent to Ducati. - * @param - * @return OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ - - -static OMX_ERRORTYPE CameraSetConfig(OMX_IN OMX_HANDLETYPE - hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR pComponentParameterStructure) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_TI_CONFIG_SHAREDBUFFER *pConfigSharedBuffer = NULL; - OMX_PTR pTempSharedBuff = NULL; - OMX_U32 status = 0; - - switch (nParamIndex) - { - case OMX_TI_IndexConfigAAAskipBuffer: - case OMX_TI_IndexConfigCamCapabilities: - case OMX_TI_IndexConfigExifTags: - case OMX_TI_IndexConfigAlgoAreas: - pConfigSharedBuffer = - (OMX_TI_CONFIG_SHAREDBUFFER *) - pComponentParameterStructure; - - pTempSharedBuff = pConfigSharedBuffer->pSharedBuff; - - // TODO(XXX): Cache API is not yet available. Client needs to - // allocate tiler buffer directly and assign to pSharedBuff. - // Ptr allocated by MemMgr_Alloc in uncacheable so there - // would be no need to cache API - - eError = __PROXY_SetConfig(hComponent, - nParamIndex, - pConfigSharedBuffer, - &(pConfigSharedBuffer->pSharedBuff)); - - PROXY_assert((eError == OMX_ErrorNone), eError, - "Error in GetConfig"); - - pConfigSharedBuffer->pSharedBuff = pTempSharedBuff; - - goto EXIT; - break; - default: - break; - } - - return __PROXY_SetConfig(hComponent, - nParamIndex, - pComponentParameterStructure, - NULL); - - EXIT: - return eError; -} - -static OMX_ERRORTYPE CameraSetParam(OMX_IN OMX_HANDLETYPE - hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR pComponentParameterStructure) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *)hComponent; -#ifndef OMAP_TUNA - struct ion_handle *handle; - OMX_U32 i =0; - OMX_S32 ret = 0; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_U32 stride_Y = 0, stride_UV = 0; -#ifndef OMAP_TUNA - OMX_TI_PARAM_VTCSLICE *pVtcConfig;// = (OMX_TI_PARAM_VTCSLICE *)pComponentParameterStructure; - OMX_TI_PARAM_COMPONENTBUFALLOCTYPE *bufferalloc = NULL; -#endif - int size = 0; - int fd1 = -1, fd2 = -1; - - pCompPrv = (PROXY_COMPONENT_PRIVATE *)hComp->pComponentPrivate; - //fprintf(stdout, "DOMX: CameraSetParam: called!!!\n"); - switch (nParamIndex) - { -#ifndef OMAP_TUNA - case OMX_TI_IndexParamVtcSlice: - pVtcConfig = (OMX_TI_PARAM_VTCSLICE *)pComponentParameterStructure; - fprintf(stdout, "DOMX: CameraSetParam: OMX_TI_IndexParamVtcSlice is called!!!\n"); - DOMX_ERROR("CameraSetParam Called for Vtc Slice index\n"); - - //fprintf(stdout, "CameraSetParam Called for Vtc Slice height = %d\n", ((OMX_TI_PARAM_VTCSLICE *)pComponentParameterStructure)->nSliceHeight); - // MAX_NUM_INTERNAL_BUFFERS; - - for(i=0; i < MAX_NUM_INTERNAL_BUFFERS; i++) { - pVtcConfig->nInternalBuffers = i; - ret = ion_alloc_tiler(pCompPrv->ion_fd, MAX_VTC_WIDTH_WITH_VNF, MAX_VTC_HEIGHT_WITH_VNF, TILER_PIXEL_FMT_8BIT, OMAP_ION_HEAP_TILER_MASK, &handle, (size_t *)&stride_Y); - if (ret < 0) { - DOMX_ERROR ("ION allocation failed - %s", strerror(errno)); - goto EXIT; - } - - ret = ion_share(pCompPrv->ion_fd, handle, &fd1); - if (ret < 0) { - DOMX_ERROR("ION share failed"); - ion_free(pCompPrv->ion_fd, handle); - goto EXIT; - } - - pVtcConfig->IonBufhdl[0] = (OMX_PTR)(fd1); - - //fprintf(stdout, "DOMX: ION Buffer#%d: Y: 0x%x\n", i, pVtcConfig->IonBufhdl[0]); - - ret = ion_alloc_tiler(pCompPrv->ion_fd, MAX_VTC_WIDTH_WITH_VNF/2, MAX_VTC_HEIGHT_WITH_VNF/2, TILER_PIXEL_FMT_16BIT, OMAP_ION_HEAP_TILER_MASK, &handle, (size_t *)&stride_UV); - if (ret < 0) { - DOMX_ERROR ("ION allocation failed - %s", strerror(errno)); - goto EXIT; - } - - ret = ion_share(pCompPrv->ion_fd, handle, &fd2); - if (ret < 0) { - DOMX_ERROR("ION share failed"); - ion_free(pCompPrv->ion_fd, handle); - goto EXIT; - } - - pVtcConfig->IonBufhdl[1] = (OMX_PTR)(fd2); - gCamIonHdl[i][0] = pVtcConfig->IonBufhdl[0]; - gCamIonHdl[i][1] = pVtcConfig->IonBufhdl[1]; - //fprintf(stdout, "DOMX: ION Buffer#%d: UV: 0x%x\n", i, pVtcConfig->IonBufhdl[1]); - eError = __PROXY_SetParameter(hComponent, - OMX_TI_IndexParamVtcSlice, - pVtcConfig, - pVtcConfig->IonBufhdl, 2); - close(fd1); - close(fd2); - } - goto EXIT; - case OMX_TI_IndexParamComponentBufferAllocation: { - OMX_U32 port = 0, index = 0; - int fd; - bufferalloc = (OMX_TI_PARAM_COMPONENTBUFALLOCTYPE *) - pComponentParameterStructure; - - port = bufferalloc->nPortIndex; - index = bufferalloc->nIndex; - - size = bufferalloc->nAllocWidth * bufferalloc->nAllocLines; - ret = ion_alloc_tiler (pCompPrv->ion_fd, size, 1, - TILER_PIXEL_FMT_PAGE, - OMAP_ION_HEAP_TILER_ALLOCATION_MASK, - &handle, &stride_Y); - if (ret < 0) { - DOMX_ERROR ("ION allocation failed - %s", strerror(errno)); - goto EXIT; - } - - ret = ion_share(pCompPrv->ion_fd, handle, &fd); - if (ret < 0) { - DOMX_ERROR("ION share failed"); - ion_free(pCompPrv->ion_fd, handle); - goto EXIT; - } - - bufferalloc->pBuf[0] = fd; - eError = __PROXY_SetParameter(hComponent, - OMX_TI_IndexParamComponentBufferAllocation, - bufferalloc, &bufferalloc->pBuf[0], 1); - if (eError != OMX_ErrorNone) { - ion_free(pCompPrv->ion_fd, handle); - } else { - if (gComponentBufferAllocation[port][index]) { - ion_free(pCompPrv->ion_fd, gComponentBufferAllocation[port][index]); - } - gComponentBufferAllocation[port][index] = handle; - } - close (fd); - } - goto EXIT; - break; -#endif - default: - break; - } -#endif - eError = __PROXY_SetParameter(hComponent, - nParamIndex, - pComponentParameterStructure, - NULL, 0); - - if (eError != OMX_ErrorNone) { - DOMX_ERROR(" CameraSetParam: Error in SetParam 0x%x", eError); - } -EXIT: - return eError; -} -OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_ERRORTYPE dcc_eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - PROXY_COMPONENT_PRIVATE *pComponentPrivate; - OMX_U32 i = 0, j = 0; - pHandle = (OMX_COMPONENTTYPE *) hComponent; - TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE; - DOMX_ENTER("_____________________INSIDE CAMERA PROXY" - "WRAPPER__________________________\n"); - pHandle->pComponentPrivate = (PROXY_COMPONENT_PRIVATE *) - TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), - TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); - - pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - if (pHandle->pComponentPrivate == NULL) - { - DOMX_ERROR(" ERROR IN ALLOCATING PROXY COMPONENT" - "PRIVATE STRUCTURE"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - TIMM_OSAL_Memset(pComponentPrivate, 0, - sizeof(PROXY_COMPONENT_PRIVATE)); - - pComponentPrivate->cCompName = - TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8), - TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); - /*Copying component Name - this will be picked up in the proxy common */ - assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH); - TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, - strlen(COMPONENT_NAME) + 1); - - /*Calling Proxy Common Init() */ - eError = OMX_ProxyCommonInit(hComponent); - if (eError != OMX_ErrorNone) - { - DOMX_ERROR("\Error in Initializing Proxy"); - TIMM_OSAL_Free(pComponentPrivate->cCompName); - TIMM_OSAL_Free(pComponentPrivate); - goto EXIT; - } -#ifndef OMAP_TUNA - for(i=0; i < MAX_NUM_INTERNAL_BUFFERS; i++) { - gCamIonHdl[i][0] = NULL; - gCamIonHdl[i][1] = NULL; - } - - for (i = 0; i < PROXY_MAXNUMOFPORTS; i++) { - for (j = 0; j < MAX_NUM_INTERNAL_BUFFERS; j++) { - gComponentBufferAllocation[i][j] = NULL; - } - } -#endif - pHandle->ComponentDeInit = ComponentPrivateDeInit; - pHandle->GetConfig = CameraGetConfig; - pHandle->SetConfig = CameraSetConfig; - pHandle->SendCommand = Camera_SendCommand; - pHandle->SetParameter = CameraSetParam; - - EXIT: - return eError; -} - -/* ===========================================================================*/ -/** - * @name DCC_Init() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE DCC_Init(OMX_HANDLETYPE hComponent) -{ - OMX_TI_PARAM_DCCURIINFO param; - OMX_PTR ptempbuf; - OMX_U16 nIndex = 0; - OMX_ERRORTYPE eError = OMX_ErrorNone; -#ifdef USE_ION - int ret; - size_t stride; -#endif - - OMX_S32 status = 0; - OMX_STRING dcc_dir[200]; - OMX_U16 i; - _PROXY_OMX_INIT_PARAM(¶m, OMX_TI_PARAM_DCCURIINFO); - - DOMX_ENTER("ENTER"); - /* Read the the DCC URI info */ - for (nIndex = 0; eError != OMX_ErrorNoMore; nIndex++) - { - param.nIndex = nIndex; - eError = - OMX_GetParameter(hComponent, - OMX_TI_IndexParamDccUriInfo, ¶m); - - PROXY_assert((eError == OMX_ErrorNone) || - (eError == OMX_ErrorNoMore), eError, - "Error in GetParam for Dcc URI info"); - - if (eError == OMX_ErrorNone) - { - DOMX_DEBUG("DCC URI's %s ", param.sDCCURI); - dcc_dir[nIndex] = - TIMM_OSAL_Malloc(sizeof(OMX_U8) * - (strlen(DCC_PATH) + MAX_URI_LENGTH + 1), - TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); - PROXY_assert(dcc_dir[nIndex] != NULL, - OMX_ErrorInsufficientResources, "Malloc failed"); - strcpy(dcc_dir[nIndex], DCC_PATH); - strncat(dcc_dir[nIndex], (OMX_STRING) param.sDCCURI, MAX_URI_LENGTH); - strcat(dcc_dir[nIndex], "/"); - } - } - - /* setting back errortype OMX_ErrorNone */ - if (eError == OMX_ErrorNoMore) - { - eError = OMX_ErrorNone; - } - - dccbuf_size = read_DCCdir(NULL, dcc_dir, nIndex); - - if(dccbuf_size <= 0) - { - DOMX_DEBUG("No DCC files found, switching back to default DCC"); - return OMX_ErrorInsufficientResources; - } - -#ifdef USE_ION - ion_fd = ion_open(); - if(ion_fd == 0) - { - DOMX_ERROR("ion_open failed!!!"); - return OMX_ErrorInsufficientResources; - } - dccbuf_size = (dccbuf_size + LINUX_PAGE_SIZE -1) & ~(LINUX_PAGE_SIZE - 1); - ret = ion_alloc(ion_fd, dccbuf_size, 0x1000, 1 << ION_HEAP_TYPE_CARVEOUT, - (struct ion_handle **)&DCC_Buff); - - if (ret || ((int)DCC_Buff == -ENOMEM)) { - ret = ion_alloc_tiler(ion_fd, dccbuf_size, 1, TILER_PIXEL_FMT_PAGE, - OMAP_ION_HEAP_TILER_MASK, &DCC_Buff, &stride); - } - - if (ret || ((int)DCC_Buff == -ENOMEM)) { - DOMX_ERROR("FAILED to allocate DCC buffer of size=%d. ret=0x%x", - dccbuf_size, ret); - return OMX_ErrorInsufficientResources; - } - - if (ion_map(ion_fd, DCC_Buff, dccbuf_size, PROT_READ | PROT_WRITE, MAP_SHARED, 0, - (unsigned char **)&DCC_Buff_ptr, &mmap_fd) < 0) - { - DOMX_ERROR("userspace mapping of ION buffers returned error"); - return OMX_ErrorInsufficientResources; - } - ptempbuf = DCC_Buff_ptr; -#endif - dccbuf_size = read_DCCdir(ptempbuf, dcc_dir, nIndex); - - PROXY_assert(dccbuf_size > 0, OMX_ErrorInsufficientResources, - "ERROR in copy DCC files into buffer"); - - EXIT: - for (i = 0; i < nIndex - 1; i++) - { - TIMM_OSAL_Free(dcc_dir[i]); - } - - return eError; - -} - -/* ===========================================================================*/ -/** - * @name send_DCCBufPtr() - * @brief : Sending the DCC uri buff addr to ducati - * @param void - * @return return = 0 is successful - * @sa TBD - * - */ -/* ===========================================================================*/ - -OMX_ERRORTYPE send_DCCBufPtr(OMX_HANDLETYPE hComponent) -{ - OMX_TI_CONFIG_SHAREDBUFFER uribufparam; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - _PROXY_OMX_INIT_PARAM(&uribufparam, OMX_TI_CONFIG_SHAREDBUFFER); - uribufparam.nPortIndex = OMX_ALL; - - DOMX_ENTER("ENTER"); - - uribufparam.nSharedBuffSize = dccbuf_size; -#ifdef USE_ION - uribufparam.pSharedBuff = (OMX_PTR) mmap_fd; -#else - uribufparam.pSharedBuff = (OMX_PTR) DCC_Buff; -#endif - - DOMX_DEBUG("SYSLINK MAPPED ADDR: 0x%x sizeof buffer %d", - uribufparam.pSharedBuff, uribufparam.nSharedBuffSize); - - eError = __PROXY_SetParameter(hComponent, - OMX_TI_IndexParamDccUriBuffer, - &uribufparam, - &(uribufparam.pSharedBuff), 1); - - if (eError != OMX_ErrorNone) { - DOMX_ERROR(" Error in SetParam for DCC Uri Buffer 0x%x", eError); - } - - DOMX_EXIT("EXIT"); - return eError; -} - -/* ===========================================================================*/ -/** - * @name read_DCCdir() - * @brief : copies all the dcc profiles into the allocated 1D-Tiler buffer - * and returns the size of the buffer. - * @param void : OMX_PTR is null then returns the size of the DCC directory - * @return return = size of the DCC directory or error in case of any failures - * in file read or open - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_S32 read_DCCdir(OMX_PTR buffer, OMX_STRING * dir_path, OMX_U16 numofURI) -{ - FILE *pFile; - OMX_S32 lSize; - OMX_S32 dcc_buf_size = 0; - size_t result; - OMX_STRING filename; - char temp[200]; - OMX_STRING dotdot = ".."; - DIR *d; - struct dirent *dir; - OMX_U16 i = 0; - OMX_S32 ret = 0; - - DOMX_ENTER("ENTER"); - for (i = 0; i < numofURI - 1; i++) - { - d = opendir(dir_path[i]); - if (d) - { - /* read each filename */ - while ((dir = readdir(d)) != NULL) - { - filename = dir->d_name; - strcpy(temp, dir_path[i]); - strcat(temp, filename); - if ((*filename != *dotdot)) - { - DOMX_DEBUG - ("\n\t DCC Profiles copying into buffer => %s mpu_addr: %p", - temp, buffer); - pFile = fopen(temp, "rb"); - if (pFile == NULL) - { - DOMX_ERROR("File open error"); - ret = -1; - } else - { - fseek(pFile, 0, SEEK_END); - lSize = ftell(pFile); - rewind(pFile); - /* buffer is not NULL then copy all the DCC profiles into buffer - else return the size of the DCC directory */ - if (buffer) - { - // copy file into the buffer: - result = - fread(buffer, 1, - lSize, pFile); - if (result != (size_t) lSize) - { - DOMX_ERROR - ("fread: Reading error"); - ret = -1; - } - buffer = - buffer + lSize; - } - /* getting the size of the total dcc files available in FS */ - dcc_buf_size = - dcc_buf_size + lSize; - // terminate - fclose(pFile); - } - } - } - closedir(d); - } - } - if (ret == 0) - ret = dcc_buf_size; - - DOMX_EXIT("return %d", ret); - return ret; -} - -/* ===========================================================================*/ -/** - * @name DCC_Deinit() - * @brief - * @param void - * @return void - * @sa TBD - * - */ -/* ===========================================================================*/ -void DCC_DeInit() -{ - DOMX_ENTER("ENTER"); - - if (DCC_Buff) - { -#ifdef USE_ION - munmap(DCC_Buff_ptr, dccbuf_size); - close(mmap_fd); - ion_free(ion_fd, DCC_Buff); - ion_close(ion_fd); - DCC_Buff = NULL; -#endif - } - - DOMX_EXIT("EXIT"); -} - - - -/*===============================================================*/ -/** @fn Cam_Setup : This function is called when the the OMX Camera library is - * loaded. It creates a mutex, which is used during DCC_Init() - */ -/*===============================================================*/ -void __attribute__ ((constructor)) Cam_Setup(void) -{ - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - - eError = TIMM_OSAL_MutexCreate(&cam_mutex); - if (eError != TIMM_OSAL_ERR_NONE) - { - TIMM_OSAL_Error("Creation of default mutex failed"); - } -} - - -/*===============================================================*/ -/** @fn Cam_Destroy : This function is called when the the OMX Camera library is - * unloaded. It destroys the mutex which was created by - * Core_Setup(). - * - */ -/*===============================================================*/ -void __attribute__ ((destructor)) Cam_Destroy(void) -{ - TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; - - eError = TIMM_OSAL_MutexDelete(cam_mutex); - if (eError != TIMM_OSAL_ERR_NONE) - { - TIMM_OSAL_Error("Destruction of default mutex failed"); - } -} diff --git a/domx/omx_proxy_component/omx_h264_enc/Makefile b/domx/omx_proxy_component/omx_h264_enc/Makefile deleted file mode 100755 index c528740..0000000 --- a/domx/omx_proxy_component/omx_h264_enc/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -# -# Copyright (C) Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ---------------------------------------------------------------------------- -# Revision History -# -# -# REF=ORG -# Original version. -# ---------------------------------------------------------------------------- - - - -include $(PROJROOT)/make/start.mk - -# Do not change above "include" line(s) - -# Arguments to tools, will move to make system once finalized. - -CFLAGS = -CDEFS = -ifeq ($(BUILD),udeb) -CDEFS += DEBUG -endif -CDEFS += - -EXEC_ARGS = -ST_LIB_ARGS = -SH_LIB_ARGS = - -# Define this macro if target runs in kernel mode -#__KERNEL__ = 1 - -# Target name and extension -# static library (ST_LIB): filename.a -# shared library soname (SH_LIB): filename.so.maj_ver.min_ver -# executable (EXEC) : filename.out - -TARGETNAME = libOMX.TI.DUCATI1.VIDEO.H264E.so - - -# TARGETTYPE must be EXEC, ST_LIB or SH_LIB in upper case. - -TARGETTYPE = SH_LIB - -# install directory relative to the HOSTTARGET directory -HOSTRELEASE = lib - -# install directory relative to the root filesystem -ROOTFSRELEASE = lib - -# Folders in which gmake will run before building current target - -SUBMODULES = \ - -# Filename must not begin with '.', '/' or '\' - -SOURCES = \ -src/omx_proxy_h264enc.c \ - - - -# Search path for include files - -INCLUDES = \ - $(PROJROOT)/omx_core/inc \ - $(PROJROOT)/mm_osal/inc \ - $(PROJROOT)/domx \ - $(PROJROOT)/domx/omx_rpc/inc \ - - -# Libraries needed for linking. - -ST_LIBS = -#mm_osal domx -SH_LIBS = domx omx_core mm_osal -#pthread rt utils procmgr ipc rcm notify -#SH_LIBS += sysmgr sysmemmgr - - -# Search path for library (and linker command) files. -# Current folder and target folder are included by default. - -LIBINCLUDES = $(PROJROOT)/mm_osal \ - $(PROJROOT)/domx \ - $(PROJROOT)/omx_core - - -# Do not change below "include" line(s) - -include $(PROJROOT)/make/build.mk diff --git a/domx/omx_proxy_component/omx_h264_enc/src/omx_proxy_h264enc.c b/domx/omx_proxy_component/omx_h264_enc/src/omx_proxy_h264enc.c deleted file mode 100644 index 21cc417..0000000 --- a/domx/omx_proxy_component/omx_h264_enc/src/omx_proxy_h264enc.c +++ /dev/null @@ -1,1099 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_proxy_h264enc.c - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework Proxy component. - ********************************************************************************************* - This is the proxy specific wrapper that passes the component name to the generic proxy init() - The proxy wrapper also does some runtime/static time onfig on per proxy basis - This is a thin wrapper that is called when componentiit() of the proxy is called - static OMX_ERRORTYPE PROXY_Wrapper_init(OMX_HANDLETYPE hComponent, OMX_PTR pAppData); - this layer gets called first whenever a proxy's get handle is called - ************************************************************************************************ - * @path WTSD_DucatiMMSW\omx\omx_il_1_x\omx_proxy_component\src - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - * 26-August-2011 Abhishek Ranka : Support for color conv at encoder - * input port - * - *! 20-August-2010 Sarthak Aggarwal sarthak@ti.com: Initial Version - *================================================================*/ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ - -#include -#include -#include -#include "omx_proxy_common.h" -#include -#include "OMX_TI_IVCommon.h" -#include "OMX_TI_Video.h" -#include "OMX_TI_Index.h" - -#include -#ifdef ENABLE_GRALLOC_BUFFER -#include "native_handle.h" -#include -#include -#endif - -#include -#include - -#define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.H264E" -/* needs to be specific for every configuration wrapper */ - -#define OMX_H264E_INPUT_PORT 0 -#define LINUX_PAGE_SIZE 4096 - -#ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES - -OMX_ERRORTYPE LOCAL_PROXY_H264E_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct); - -OMX_ERRORTYPE LOCAL_PROXY_H264E_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct); - -#endif - - -#define OMX_INIT_STRUCT(_s_, _name_) \ - memset(&(_s_), 0x0, sizeof(_name_)); \ - (_s_).nSize = sizeof(_name_); \ - (_s_).nVersion.s.nVersionMajor = 0x1; \ - (_s_).nVersion.s.nVersionMinor = 0x1; \ - (_s_).nVersion.s.nRevision = 0x0; \ - (_s_).nVersion.s.nStep = 0x0 - - -/* Params needed for Dynamic Frame Rate Control*/ -#define FRAME_RATE_THRESHOLD 1 /* Change in Frame rate to configure the encoder */ -OMX_U32 nFrameRateThreshold = 0;/* Frame Rate threshold for every frame rate update */ -OMX_U32 nPortFrameRate = 0; /* Port FPS initially set to the Encoder */ -OMX_U32 nFrameCounter = 0; /* Number of input frames recieved since last framerate calculation */ -OMX_TICKS nVideoTime = 0; /* Video duration since last framerate calculation */ -OMX_TICKS nLastFrameRateUpdateTime = 0; /*Time stamp at last frame rate update */ -OMX_U16 nBFrames = 0; /* Number of B Frames in H264 Encoder */ - - -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT -/* Opaque color format requires below quirks to be enabled - * ENABLE_GRALLOC_BUFFER - * ANDROID_QUIRCK_CHANGE_PORT_VALUES - */ -#define OMX_H264VE_NUM_INTERNAL_BUF (8) -#ifndef HAL_PIXEL_FORMAT_TI_NV12 -#define HAL_PIXEL_FORMAT_TI_NV12 (0x100) -#endif - -#define COLORCONVERT_MAX_SUB_BUFFERS (3) - -#define COLORCONVERT_BUFTYPE_VIRTUAL (0x0) -#define COLORCONVERT_BUFTYPE_ION (0x1) -#define COLORCONVERT_BUFTYPE_GRALLOCOPAQUE (0x2) - -int COLORCONVERT_open(void **hCC, PROXY_COMPONENT_PRIVATE *pCompPrv); -int COLORCONVERT_PlatformOpaqueToNV12(void *hCC, void *pSrc[], - void *pDst[], int nWidth, - int nHeight, int nStride, - int nSrcBufType, int nDstBufType); -int COLORCONVERT_close(void *hCC,PROXY_COMPONENT_PRIVATE *pCompPrv); -static int COLORCONVERT_AllocateBuffer(OMX_HANDLETYPE hComponent, OMX_U32 nStride); -static OMX_ERRORTYPE LOCAL_PROXY_H264E_AllocateBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr, OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, OMX_IN OMX_U32 nSizeBytes); - -static OMX_ERRORTYPE LOCAL_PROXY_H264E_FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_BUFFERHEADERTYPE * pBufferHdr); - -static OMX_ERRORTYPE LOCAL_PROXY_H264E_ComponentDeInit(OMX_HANDLETYPE hComponent); - -typedef struct _OMX_PROXY_H264E_PRIVATE -{ - OMX_PTR hBufPipe; - OMX_BOOL bAndroidOpaqueFormat; - OMX_PTR hCC; - IMG_native_handle_t* gralloc_handle[OMX_H264VE_NUM_INTERNAL_BUF]; - OMX_S32 nCurBufIndex; - alloc_device_t* mAllocDev; -}OMX_PROXY_H264E_PRIVATE; - -RPC_OMX_ERRORTYPE RPC_RegisterBuffer(OMX_HANDLETYPE hRPCCtx, int fd, - OMX_PTR *handle1, OMX_PTR *handle2, - PROXY_BUFFER_TYPE proxyBufferType); -RPC_OMX_ERRORTYPE RPC_UnRegisterBuffer(OMX_HANDLETYPE hRPCCtx, OMX_PTR handle); -#endif - - -OMX_ERRORTYPE LOCAL_PROXY_H264E_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE * pIndexType); - -OMX_ERRORTYPE LOCAL_PROXY_H264E_EmptyThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr); - -static OMX_ERRORTYPE OMX_ConfigureDynamicFrameRate( OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_U32 nTargetFrameRate = 0; /* Target Frame Rate to be provided to Encoder */ - OMX_U32 nCurrentFrameRate = 0; /* Current Frame Rate currently set in Encoder */ - OMX_CONFIG_FRAMERATETYPE tFrameRate; - OMX_COMPONENTTYPE *pHandle; - if (hComponent == NULL){ - DOMX_ERROR("Component is invalid/ not present "); - return OMX_ErrorBadParameter; - } - pHandle = (OMX_COMPONENTTYPE *) hComponent; - - /* Initialise the OMX structures */ - OMX_INIT_STRUCT(tFrameRate,OMX_CONFIG_FRAMERATETYPE); - - /* Intialise nLastFrameRateUpdateTime for the 1st frame */ - if((!nFrameCounter) && (!nLastFrameRateUpdateTime)){ - nLastFrameRateUpdateTime = pBufferHdr-> nTimeStamp; - } - - /* Increment the Frame Counter and Calculate Frame Rate*/ - nFrameCounter++; - nVideoTime = pBufferHdr->nTimeStamp - nLastFrameRateUpdateTime; - - if(nVideoTime < 0) { - return OMX_ErrorBadParameter; - } - - /*Get Port Frame Rate if not read yet*/ - if(!nFrameRateThreshold) { - tFrameRate.nPortIndex = OMX_H264E_INPUT_PORT; /* As per ducati support-set for input port */ - - /* Read Current FrameRate */ - eError = pHandle->GetConfig(hComponent,OMX_IndexConfigVideoFramerate,&tFrameRate); - if (eError != OMX_ErrorNone) - DOMX_ERROR ("pHandle->GetConfig OMX_IndexConfigVideoFramerate eError :0x%x \n",eError); - nFrameRateThreshold = tFrameRate.xEncodeFramerate >>16; - nPortFrameRate = nFrameRateThreshold; - DOMX_DEBUG(" Port Frame Rate is %d ", nPortFrameRate); - } - nCurrentFrameRate = nFrameRateThreshold; - - /* If Number of frames is less than the Threshold - * Frame Rate udpate is not necessary - */ - if(nFrameCounter < nFrameRateThreshold){ - DOMX_EXIT(" Threshold not reached, no update necessary"); - return OMX_ErrorNone; - } - - /*Calculate the new target Frame Rate*/ - if (nVideoTime != 0) - nTargetFrameRate = nFrameCounter * 1000000 / nVideoTime; - - /* For 1080p record, max FPS supported by Codec for profile 4.1 is 30. - * When Dynamic Frame Rate is enabled, there might be scenario when FPS - * calculated is more than 30. Hence adding the check so that Dynamic Frame - * Rate set is never greater than the port FPS initially set. - */ - if(nTargetFrameRate > nPortFrameRate){ - DOMX_DEBUG("Frame Rate Calculated is more than initial port set Frame Rate"); - nTargetFrameRate = nPortFrameRate; - } - - /* Difference in Frame Rate is more than Threshold - Only then update Frame Rate*/ - if((( (OMX_S32)nTargetFrameRate) -((OMX_S32) nCurrentFrameRate) >= FRAME_RATE_THRESHOLD) || - (((OMX_S32) nCurrentFrameRate) - ( (OMX_S32)nTargetFrameRate) >= FRAME_RATE_THRESHOLD)) { - - /* Now Send the new Frame Rate */ - tFrameRate.nPortIndex = OMX_H264E_INPUT_PORT; /* As per ducati support-set for input port */ - tFrameRate.xEncodeFramerate = (OMX_U32)(nTargetFrameRate * (1 << 16)); - eError = pHandle->SetConfig(hComponent,OMX_IndexConfigVideoFramerate,&tFrameRate); - if(eError != OMX_ErrorNone){ - DOMX_ERROR(" Error while configuring Dynamic Frame Rate,Error info = %d",eError); - return eError; - } else { - DOMX_DEBUG("Dynamic Frame Rate configuration successful \n"); - } - nFrameRateThreshold = nTargetFrameRate; /*Update the threshold */ - } - - /* reset all params */ - nFrameCounter = 0 ; - nVideoTime = 0; - nLastFrameRateUpdateTime = pBufferHdr->nTimeStamp; - return OMX_ErrorNone; -} - -static OMX_ERRORTYPE ComponentPrivateEmptyThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - - eError = OMX_ConfigureDynamicFrameRate(hComponent, pBufferHdr); - if( eError != OMX_ErrorNone) - DOMX_ERROR(" Error while configuring FrameRate Dynamically.Error info = %d",eError); - - DOMX_DEBUG("Redirection from ComponentPricateEmptyThisBuffer to PROXY_EmptyThisBuffer"); - return LOCAL_PROXY_H264E_EmptyThisBuffer (hComponent,pBufferHdr); -} - -OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL; - pHandle = (OMX_COMPONENTTYPE *) hComponent; - OMX_TI_PARAM_ENHANCEDPORTRECONFIG tParamStruct; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - TIMM_OSAL_ERRORTYPE eOSALStatus = TIMM_OSAL_ERR_NONE; - OMX_PROXY_H264E_PRIVATE *pProxy = NULL; -#endif - char value[OMX_MAX_STRINGNAME_SIZE]; - OMX_U32 mEnableVFR = 1; /* Flag used to enable/disable VFR for Encoder */ - property_get("debug.vfr.enable", value, "1"); - mEnableVFR = atoi(value); - - DOMX_ENTER(""); - - DOMX_DEBUG("Component name provided is %s", COMPONENT_NAME); - - pHandle->pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) - TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), TIMM_OSAL_TRUE, - 0, TIMMOSAL_MEM_SEGMENT_INT); - - PROXY_assert(pHandle->pComponentPrivate != NULL, - OMX_ErrorInsufficientResources, - "ERROR IN ALLOCATING PROXY COMPONENT PRIVATE STRUCTURE"); - - pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - - TIMM_OSAL_Memset(pComponentPrivate, 0, - sizeof(PROXY_COMPONENT_PRIVATE)); - - pComponentPrivate->cCompName = - TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8), - TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); - - PROXY_assert(pComponentPrivate->cCompName != NULL, - OMX_ErrorInsufficientResources, - " Error in Allocating space for proxy component table"); - -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - pComponentPrivate->pCompProxyPrv = - (OMX_PROXY_H264E_PRIVATE *) - TIMM_OSAL_Malloc(sizeof(OMX_PROXY_H264E_PRIVATE), TIMM_OSAL_TRUE, - 0, TIMMOSAL_MEM_SEGMENT_INT); - - PROXY_assert(pComponentPrivate->pCompProxyPrv != NULL, - OMX_ErrorInsufficientResources, - " Could not allocate proxy component private"); - - TIMM_OSAL_Memset(pComponentPrivate->pCompProxyPrv, 0, - sizeof(OMX_PROXY_H264E_PRIVATE)); - - pProxy = (OMX_PROXY_H264E_PRIVATE *) pComponentPrivate->pCompProxyPrv; - - /* Create Pipe of for encoder input buffers */ - eOSALStatus = TIMM_OSAL_CreatePipe(&pProxy->hBufPipe, sizeof(OMX_U32), - OMX_H264VE_NUM_INTERNAL_BUF, 1); - PROXY_assert(eOSALStatus == TIMM_OSAL_ERR_NONE, - OMX_ErrorInsufficientResources, - "Pipe creation failed"); -#endif - - // Copying component Name - this will be picked up in the proxy common - PROXY_assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH, - OMX_ErrorInvalidComponentName, - "Length of component name is longer than the max allowed"); - TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, - strlen(COMPONENT_NAME) + 1); - - eError = OMX_ProxyCommonInit(hComponent); // Calling Proxy Common Init() -#ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES - pHandle->SetParameter = LOCAL_PROXY_H264E_SetParameter; - pHandle->GetParameter = LOCAL_PROXY_H264E_GetParameter; -#endif - pComponentPrivate->IsLoadedState = OMX_TRUE; - pHandle->EmptyThisBuffer = LOCAL_PROXY_H264E_EmptyThisBuffer; - pHandle->GetExtensionIndex = LOCAL_PROXY_H264E_GetExtensionIndex; - -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - pHandle->ComponentDeInit = LOCAL_PROXY_H264E_ComponentDeInit; - pHandle->FreeBuffer = LOCAL_PROXY_H264E_FreeBuffer; - pHandle->AllocateBuffer = LOCAL_PROXY_H264E_AllocateBuffer; -#endif - - if(mEnableVFR) - pHandle->EmptyThisBuffer = ComponentPrivateEmptyThisBuffer; - - EXIT: - if (eError != OMX_ErrorNone) - { - DOMX_DEBUG("Error in Initializing Proxy"); - -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - if(pProxy->hBufPipe != NULL) - { - TIMM_OSAL_DeletePipe(pProxy->hBufPipe); - pProxy->hBufPipe = NULL; - } - - if(pComponentPrivate->pCompProxyPrv != NULL) - { - TIMM_OSAL_Free(pComponentPrivate->pCompProxyPrv); - pComponentPrivate->pCompProxyPrv = NULL; - pProxy = NULL; - } -#endif - if (pComponentPrivate->cCompName != NULL) - { - TIMM_OSAL_Free(pComponentPrivate->cCompName); - pComponentPrivate->cCompName = NULL; - } - if (pComponentPrivate != NULL) - { - TIMM_OSAL_Free(pComponentPrivate); - pComponentPrivate = NULL; - } - } - return eError; -} - -#ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES - -/* ===========================================================================*/ -/** - * @name PROXY_H264E_GetParameter() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE LOCAL_PROXY_H264E_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_PARAM_PORTDEFINITIONTYPE* pPortDef = NULL; - OMX_VIDEO_PARAM_PORTFORMATTYPE* pPortParam = NULL; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - OMX_PROXY_H264E_PRIVATE *pProxy = NULL; -#endif - - PROXY_require((pParamStruct != NULL), OMX_ErrorBadParameter, NULL); - PROXY_assert((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - pProxy = (OMX_PROXY_H264E_PRIVATE *) pCompPrv->pCompProxyPrv; -#endif - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nParamIndex = %d, pParamStruct = %p", - hComponent, pCompPrv, nParamIndex, pParamStruct); - - eError = PROXY_GetParameter(hComponent,nParamIndex, pParamStruct); - - if(nParamIndex == OMX_IndexParamPortDefinition) - { - pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; - - if(pPortDef->format.video.eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar) - { -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - if(pProxy->bAndroidOpaqueFormat == OMX_TRUE) - { - pPortDef->format.video.eColorFormat = OMX_COLOR_FormatAndroidOpaque; - } - else -#endif - { - pPortDef->format.video.eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar; - } - } - - if(pPortDef->nPortIndex == OMX_H264E_INPUT_PORT) - { - if(pCompPrv->proxyPortBuffers[OMX_H264E_INPUT_PORT].proxyBufferType == EncoderMetadataPointers) - { - pPortDef->nBufferSize = sizeof(video_metadata_t); - } - } - } - else if (nParamIndex == OMX_IndexParamVideoPortFormat) - { - pPortParam = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct; - - if((eError == OMX_ErrorNone) && - (pPortParam->eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar)) - { - pPortParam->eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar; - } -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - else if ((eError == OMX_ErrorNoMore) && - (pPortParam->nIndex == 1)) - { - /* HACK:Remote OMX-H264E supports only 1 color format (index 0). The - * OMX_COLOR_FormatAndroidOpaque is supported only at the proxy. - * Call GetParameter() to fill in defaults for parameters and - * override color format and index for the additional - * OMX_COLOR_FormatAndroidOpaque support*/ - pPortParam->nIndex = 0; - eError = PROXY_GetParameter(hComponent, nParamIndex, pParamStruct); - pPortParam->nIndex = 1; - pPortParam->eColorFormat = OMX_COLOR_FormatAndroidOpaque; - eError = OMX_ErrorNone; - } -#endif - } -#ifndef OMAP_TUNA - else if (nParamIndex == OMX_TI_IndexComponentHandle) - { - OMX_TI_COMPONENT_HANDLE * pCompHandle = pParamStruct; - pCompHandle->pHandle = hComponent; - eError = OMX_ErrorNone; - } -#endif - PROXY_assert((eError == OMX_ErrorNone) || (eError == OMX_ErrorNoMore), - eError," Error in Proxy GetParameter"); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_H264E_SetParameter() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE LOCAL_PROXY_H264E_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_PARAM_PORTDEFINITIONTYPE* pPortDef = NULL; - OMX_VIDEO_PARAM_PORTFORMATTYPE* pPortParams = NULL; - OMX_VIDEO_STOREMETADATAINBUFFERSPARAMS* pStoreMetaData = NULL; - OMX_TI_PARAM_BUFFERPREANNOUNCE tParamSetNPA; - OMX_PARAM_PORTDEFINITIONTYPE sPortDef; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - OMX_PROXY_H264E_PRIVATE *pProxy = NULL; -#endif - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nParamIndex = %d, pParamStruct = %p", - hComponent, pCompPrv, nParamIndex, pParamStruct); - - PROXY_require((pParamStruct != NULL), OMX_ErrorBadParameter, NULL); - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - pProxy = (OMX_PROXY_H264E_PRIVATE *) pCompPrv->pCompProxyPrv; -#endif - - if(nParamIndex == OMX_IndexParamPortDefinition) - { - pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; - - if(pPortDef->format.video.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar) - { - pPortDef->format.video.eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - } -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - else if(pPortDef->format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque) - { - if(COLORCONVERT_open(&pProxy->hCC,pCompPrv) != 0) - { - PROXY_assert(0, OMX_ErrorInsufficientResources, - "Failed to open Color converting service"); - } - pProxy->bAndroidOpaqueFormat = OMX_TRUE; - pPortDef->format.video.eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - } -#endif - } - else if(nParamIndex == OMX_IndexParamVideoPortFormat) - { - pPortParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct; - - if(pPortParams->eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar) - { - pPortParams->eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - } -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - else if(pPortParams->eColorFormat == OMX_COLOR_FormatAndroidOpaque) - { - if(COLORCONVERT_open(&pProxy->hCC,pCompPrv) != 0) - { - PROXY_assert(0, OMX_ErrorInsufficientResources, - "Failed to open Color converting service"); - } - pProxy->bAndroidOpaqueFormat = OMX_TRUE; - pPortParams->eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - } -#endif - } - else if(nParamIndex == (OMX_INDEXTYPE) OMX_TI_IndexEncoderStoreMetadatInBuffers) - { - pStoreMetaData = (OMX_VIDEO_STOREMETADATAINBUFFERSPARAMS *) pParamStruct; - - DOMX_DEBUG("Moving to Metadatamode"); - if (pStoreMetaData->nPortIndex == OMX_H264E_INPUT_PORT && pStoreMetaData->bStoreMetaData == OMX_TRUE) - { - tParamSetNPA.nSize = sizeof(OMX_TI_PARAM_BUFFERPREANNOUNCE); - tParamSetNPA.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - tParamSetNPA.nVersion.s.nVersionMinor = OMX_VER_MINOR; - tParamSetNPA.nVersion.s.nRevision = 0x0; - tParamSetNPA.nVersion.s.nStep = 0x0; - tParamSetNPA.nPortIndex = OMX_H264E_INPUT_PORT; - tParamSetNPA.bEnabled = OMX_FALSE; - //Call NPA on OMX encoder on ducati. - PROXY_SetParameter(hComponent,OMX_TI_IndexParamBufferPreAnnouncement, &tParamSetNPA); - pCompPrv->proxyPortBuffers[pStoreMetaData->nPortIndex].proxyBufferType = EncoderMetadataPointers; - DOMX_DEBUG("Moving to Metadatamode done"); - - /*Initializing Structure */ - sPortDef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); - sPortDef.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - sPortDef.nVersion.s.nVersionMinor = OMX_VER_MINOR; - sPortDef.nVersion.s.nRevision = 0x0; - sPortDef.nVersion.s.nStep = 0x0; - sPortDef.nPortIndex = OMX_H264E_INPUT_PORT; - - eError = PROXY_GetParameter(hComponent,OMX_IndexParamPortDefinition, &sPortDef); - PROXY_assert(eError == OMX_ErrorNone, eError," Error in Proxy GetParameter for Port Def"); - - sPortDef.format.video.nStride = LINUX_PAGE_SIZE; - - eError = PROXY_SetParameter(hComponent,OMX_IndexParamPortDefinition, &sPortDef); - - PROXY_assert(eError == OMX_ErrorNone, eError," Error in Proxy SetParameter for Port Def"); - } - goto EXIT; - } - - eError = PROXY_SetParameter(hComponent, nParamIndex, pParamStruct); - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in Proxy SetParameter"); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -#endif - - -/* ===========================================================================*/ -/** - * @name PROXY_GetExtensionIndex() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE LOCAL_PROXY_H264E_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE * pIndexType) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = hComponent; - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - PROXY_require(cParameterName != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(pIndexType != NULL, OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER("%s hComponent = %p, pCompPrv = %p, cParameterName = %s", - __FUNCTION__,hComponent, pCompPrv, cParameterName); - - // Check for NULL Parameters - PROXY_require((cParameterName != NULL && pIndexType != NULL), - OMX_ErrorBadParameter, NULL); - - // Ensure that String length is not greater than Max allowed length - PROXY_require(strlen(cParameterName) <= 127, OMX_ErrorBadParameter, NULL); - - if(strcmp(cParameterName, "OMX.google.android.index.storeMetaDataInBuffers") == 0) - { - // If Index type is 2D Buffer Allocated Dimension - *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexEncoderStoreMetadatInBuffers; - goto EXIT; - } - - eError = PROXY_GetExtensionIndex(hComponent, cParameterName, pIndexType); - - EXIT: - DOMX_EXIT("%s eError: %d",__FUNCTION__, eError); - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_H264E_EmptyThisBuffer() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE LOCAL_PROXY_H264E_EmptyThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_PTR pBufferOrig = NULL; - OMX_U32 nStride = 0, nNumLines = 0; - OMX_PARAM_PORTDEFINITIONTYPE tParamStruct; - OMX_U32 nFilledLen = 0, nAllocLen = 0; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - OMX_PROXY_H264E_PRIVATE *pProxy = NULL; - TIMM_OSAL_ERRORTYPE eOSALStatus = TIMM_OSAL_ERR_NONE; - OMX_U32 nBufIndex = 0, nSize=0, nRet=0; -#endif -#ifdef ENABLE_GRALLOC_BUFFER - OMX_PTR pAuxBuf0 = NULL, pAuxBuf1 = NULL; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_ERRORTYPE eCompReturn = OMX_ErrorNone; - IMG_native_handle_t* pGrallocHandle=NULL; -#endif - - PROXY_require(pBufferHdr != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, - NULL); - PROXY_CHK_VERSION(pBufferHdr, OMX_BUFFERHEADERTYPE); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - pProxy = (OMX_PROXY_H264E_PRIVATE *) pCompPrv->pCompProxyPrv; -#endif - - tParamStruct.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); - tParamStruct.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - tParamStruct.nVersion.s.nVersionMinor = OMX_VER_MINOR; - tParamStruct.nVersion.s.nRevision = 0x0; - tParamStruct.nVersion.s.nStep = 0x0; - tParamStruct.nPortIndex = OMX_H264E_INPUT_PORT; - - eError = PROXY_GetParameter(hComponent, OMX_IndexParamPortDefinition, &tParamStruct); - PROXY_require(eError == OMX_ErrorNone, OMX_ErrorBadParameter, "Error is Get Parameter for port def"); - nFilledLen = pBufferHdr->nFilledLen; - nAllocLen = pBufferHdr->nAllocLen; - if(nFilledLen != 0) - { - pBufferHdr->nFilledLen = tParamStruct.nBufferSize; - } - pBufferHdr->nAllocLen = tParamStruct.nBufferSize; - - DOMX_DEBUG - ("%s hComponent=%p, pCompPrv=%p, nFilledLen=%d, nOffset=%d, nFlags=%08x", - __FUNCTION__,hComponent, pCompPrv, pBufferHdr->nFilledLen, - pBufferHdr->nOffset, pBufferHdr->nFlags); - - if( pCompPrv->proxyPortBuffers[OMX_H264E_INPUT_PORT].proxyBufferType == EncoderMetadataPointers ) - { - OMX_U32 *pTempBuffer; - OMX_U32 nMetadataBufferType; - DOMX_DEBUG("Passing meta data to encoder"); - - pBufferOrig = pBufferHdr->pBuffer; - - pTempBuffer = (OMX_U32 *) (pBufferHdr->pBuffer); - nMetadataBufferType = *pTempBuffer; - - if(nMetadataBufferType == kMetadataBufferTypeCameraSource) - { -#ifdef ENABLE_GRALLOC_BUFFER - video_metadata_t* pVideoMetadataBuffer; - DOMX_DEBUG("MetadataBufferType is kMetadataBufferTypeCameraSource"); - - pVideoMetadataBuffer = (video_metadata_t*) ((OMX_U32 *)(pBufferHdr->pBuffer)); - pGrallocHandle = (IMG_native_handle_t*) (pVideoMetadataBuffer->handle); - DOMX_DEBUG("Grallloc buffer recieved in metadata buffer 0x%x",pGrallocHandle ); - if( pGrallocHandle->iFormat != HAL_PIXEL_FORMAT_TI_NV12 && pProxy->gralloc_handle[0] == NULL ) { - DOMX_DEBUG("Allocating NV12 buffers internally within DOMX actual count: %d", pCompPrv->nAllocatedBuffers); - pProxy->nCurBufIndex = 0; - - while( (unsigned) pProxy->nCurBufIndex < pCompPrv->nAllocatedBuffers ) { - eError = COLORCONVERT_AllocateBuffer(hComponent, nStride); - PROXY_require(eError == OMX_ErrorNone, eError, "Error allocating buffers for color conversion"); - pProxy->nCurBufIndex++; - } - } - pBufferHdr->pBuffer = (OMX_U8 *)(pGrallocHandle->fd[0]); - ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)-> - pAuxBuf1 = (OMX_PTR) pGrallocHandle->fd[1]; - DOMX_DEBUG("%s Gralloc=0x%x, Y-fd=%d, UV-fd=%d", __FUNCTION__, pGrallocHandle, - pGrallocHandle->fd[0], pGrallocHandle->fd[1]); - - pBufferHdr->nOffset = pVideoMetadataBuffer->offset; -#endif - } - else if(nMetadataBufferType == kMetadataBufferTypeGrallocSource) - { -#ifdef ENABLE_GRALLOC_BUFFER - buffer_handle_t tBufHandle; - DOMX_DEBUG("MetadataBufferType is kMetadataBufferTypeGrallocSource"); - - pTempBuffer++; - tBufHandle = *((buffer_handle_t *)pTempBuffer); - pGrallocHandle = (IMG_native_handle_t*) tBufHandle; - DOMX_DEBUG("Grallloc buffer recieved in metadata buffer 0x%x",pGrallocHandle ); - if( pGrallocHandle->iFormat != HAL_PIXEL_FORMAT_TI_NV12 && pProxy->gralloc_handle[0] == NULL ) { - DOMX_DEBUG("Allocating NV12 buffers internally within DOMX actual count: %d", pCompPrv->nAllocatedBuffers); - pProxy->nCurBufIndex = 0; - - while( (unsigned) pProxy->nCurBufIndex < pCompPrv->nAllocatedBuffers ) { - eError = COLORCONVERT_AllocateBuffer(hComponent, nStride); - PROXY_require(eError == OMX_ErrorNone, eError, "Error allocating buffers for color conversion"); - pProxy->nCurBufIndex++; - } - } - - pBufferHdr->pBuffer = (OMX_U8 *)(pGrallocHandle->fd[0]); - ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)-> - pAuxBuf1 = (OMX_PTR) pGrallocHandle->fd[1]; - DOMX_DEBUG("%s Gralloc=0x%x, Y-fd=%d, UV-fd=%d", __FUNCTION__, pGrallocHandle, - pGrallocHandle->fd[0], pGrallocHandle->fd[1]); -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - if (pProxy->bAndroidOpaqueFormat && pGrallocHandle->iFormat != HAL_PIXEL_FORMAT_TI_NV12) - { - /* Dequeue NV12 buffer for encoder */ - eOSALStatus = TIMM_OSAL_ReadFromPipe(pProxy->hBufPipe, &nBufIndex, - sizeof(OMX_PTR), (TIMM_OSAL_U32 *)(&nSize), - TIMM_OSAL_SUSPEND); - PROXY_assert(eOSALStatus == TIMM_OSAL_ERR_NONE, OMX_ErrorBadParameter, NULL); - - if(nFilledLen != 0) - { - /* Get NV12 data after colorconv*/ - nRet = COLORCONVERT_PlatformOpaqueToNV12(pProxy->hCC, (void **) &pGrallocHandle, (void **) &pProxy->gralloc_handle[nBufIndex], - pGrallocHandle->iWidth, - pGrallocHandle->iHeight, - 4096, COLORCONVERT_BUFTYPE_GRALLOCOPAQUE, - COLORCONVERT_BUFTYPE_GRALLOCOPAQUE ); - - if(nRet != 0) - { - eOSALStatus = TIMM_OSAL_WriteToPipe(pProxy->hBufPipe, (void *) &nBufIndex, - sizeof(OMX_U32), TIMM_OSAL_SUSPEND); - PROXY_assert(0, OMX_ErrorBadParameter, "Color conversion routine failed"); - } - } - - /* Update pBufferHdr with NV12 buffers for OMX component */ - pBufferHdr->pBuffer= (OMX_U8 *)(pProxy->gralloc_handle[nBufIndex]->fd[0]); - ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->pAuxBuf1 = (OMX_PTR)(pProxy->gralloc_handle[nBufIndex]->fd[1]); - } -#endif -#endif - } - else - { - DOMX_ERROR("MetadataBufferType is unknow. Returning 'OMX_ErrorBadParameter'"); - eError = OMX_ErrorBadParameter; - goto EXIT; //need to restore lenght fields in pBufferHdr - } -#ifdef ENABLE_GRALLOC_BUFFER - eRPCError = RPC_RegisterBuffer(pCompPrv->hRemoteComp, pBufferHdr->pBuffer, - &pAuxBuf0, &pAuxBuf1, - GrallocPointers); - PROXY_checkRpcError(); - if (pAuxBuf0) - pBufferHdr->pBuffer = pAuxBuf0; - if (pAuxBuf1) - ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->pAuxBuf1 = pAuxBuf1; -#endif - } - - eError = PROXY_EmptyThisBuffer(hComponent, pBufferHdr); -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - if (pProxy->bAndroidOpaqueFormat -#ifdef ENABLE_GRALLOC_BUFFER -&& pGrallocHandle != NULL && pGrallocHandle->iFormat != HAL_PIXEL_FORMAT_TI_NV12 -#endif -) - { - /*Write buffer to end of pipe for re-circulation for future ETB()*/ - eOSALStatus = TIMM_OSAL_WriteToPipe(pProxy->hBufPipe, (void *) &nBufIndex, - sizeof(OMX_U32), TIMM_OSAL_SUSPEND); - PROXY_assert(eOSALStatus == TIMM_OSAL_ERR_NONE, OMX_ErrorBadParameter, "Pipe write failed"); - } -#endif - -EXIT: - if( pBufferHdr!=NULL && pCompPrv->proxyPortBuffers[pBufferHdr->nInputPortIndex].proxyBufferType == EncoderMetadataPointers) - { - pBufferHdr->pBuffer = pBufferOrig; - pBufferHdr->nFilledLen = nFilledLen; - pBufferHdr->nAllocLen = nAllocLen; -#ifdef ENABLE_GRALLOC_BUFFER - RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, pAuxBuf0); - RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, pAuxBuf1); -#endif - } - return eError; -} - -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT -static OMX_ERRORTYPE LOCAL_PROXY_H264E_AllocateBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE ** ppBufferHdr, OMX_U32 nPortIndex, - OMX_PTR pAppPrivate, OMX_U32 nSizeBytes) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_PROXY_H264E_PRIVATE *pProxy = NULL; - TIMM_OSAL_ERRORTYPE eOSALStatus = TIMM_OSAL_ERR_NONE; - int err, nStride; - - PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, - NULL); - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - pProxy = (OMX_PROXY_H264E_PRIVATE *) pCompPrv->pCompProxyPrv; - - - eError = PROXY_AllocateBuffer(hComponent, ppBufferHdr, nPortIndex, - pAppPrivate, nSizeBytes); -EXIT: - return eError; -} - -static OMX_ERRORTYPE LOCAL_PROXY_H264E_FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_U32 nBufIndex, nSize, nCount=0; - OMX_PROXY_H264E_PRIVATE *pProxy = NULL; - - PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, - NULL); - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - pProxy = (OMX_PROXY_H264E_PRIVATE *) pCompPrv->pCompProxyPrv; - - if((nPortIndex == OMX_H264E_INPUT_PORT) && - (pProxy->bAndroidOpaqueFormat) && (pProxy->gralloc_handle[0] != NULL)) - { - pProxy->nCurBufIndex--; - PROXY_require(pProxy->nCurBufIndex >=0, - OMX_ErrorBadParameter, "Buffer index underflow"); - - if(pProxy->gralloc_handle[pProxy->nCurBufIndex]) - { - pProxy->mAllocDev->free(pProxy->mAllocDev, (buffer_handle_t)(pProxy->gralloc_handle[pProxy->nCurBufIndex])); - pProxy->gralloc_handle[pProxy->nCurBufIndex] = NULL; - } - - /*Clear the Bufindex pipe by dummy reads*/ - TIMM_OSAL_GetPipeReadyMessageCount(pProxy->hBufPipe, (TIMM_OSAL_U32 *)&nCount); - if(nCount) - { - TIMM_OSAL_ReadFromPipe(pProxy->hBufPipe, &nBufIndex, - sizeof(OMX_PTR), (TIMM_OSAL_U32 *)&nSize, TIMM_OSAL_NO_SUSPEND); - } - } - - eError = PROXY_FreeBuffer(hComponent, nPortIndex, pBufferHdr); - -EXIT: - return eError; -} - -int COLORCONVERT_AllocateBuffer(OMX_HANDLETYPE hComponent, OMX_U32 nStride) -{ - OMX_CONFIG_RECTTYPE tParam; - TIMM_OSAL_ERRORTYPE eOSALStatus = TIMM_OSAL_ERR_NONE; - OMX_U32 err; - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_PROXY_H264E_PRIVATE *pProxy = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - pProxy = (OMX_PROXY_H264E_PRIVATE *) pCompPrv->pCompProxyPrv; - - tParam.nSize = sizeof(OMX_CONFIG_RECTTYPE); - tParam.nVersion.s.nVersionMajor = 1; - tParam.nVersion.s.nVersionMinor = 1; - tParam.nVersion.s.nRevision = 0; - tParam.nVersion.s.nStep = 0; - tParam.nPortIndex = OMX_H264E_INPUT_PORT; - eError = PROXY_GetParameter(hComponent, (OMX_INDEXTYPE)OMX_TI_IndexParam2DBufferAllocDimension, &tParam); - PROXY_assert(eError == OMX_ErrorNone, eError, " Error in Proxy GetParameter"); - err = pProxy->mAllocDev->alloc(pProxy->mAllocDev, (int) tParam.nWidth, (int) tParam.nHeight, (int) HAL_PIXEL_FORMAT_TI_NV12, (int) GRALLOC_USAGE_HW_RENDER, (const struct native_handle_t * *)(&(pProxy->gralloc_handle[pProxy->nCurBufIndex])), (int *) &nStride); - PROXY_assert(!err, err, " Error in allocating Gralloc buffers"); - eOSALStatus = TIMM_OSAL_WriteToPipe(pProxy->hBufPipe, (void *) &pProxy->nCurBufIndex, sizeof(OMX_U32), TIMM_OSAL_SUSPEND); - PROXY_assert(eOSALStatus == TIMM_OSAL_ERR_NONE, OMX_ErrorBadParameter, "Pipe write failed"); - -EXIT: - return eError; -} -OMX_ERRORTYPE LOCAL_PROXY_H264E_ComponentDeInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_PROXY_H264E_PRIVATE *pProxy = NULL; - TIMM_OSAL_ERRORTYPE eOSALStatus = TIMM_OSAL_ERR_NONE; - OMX_U32 i; - - PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, - NULL); - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - pProxy = (OMX_PROXY_H264E_PRIVATE *) pCompPrv->pCompProxyPrv; - - if(pProxy->hBufPipe != NULL) - { - eOSALStatus = TIMM_OSAL_DeletePipe(pProxy->hBufPipe); - pProxy->hBufPipe = NULL; - - if(eOSALStatus != TIMM_OSAL_ERR_NONE) - { - DOMX_ERROR("Pipe deletion failed"); - } - } - - if(pProxy->bAndroidOpaqueFormat == OMX_TRUE) - { - /* Cleanup internal buffers in pipe if not freed on FreeBuffer */ - for(i=0; igralloc_handle[i]) - { - pProxy->mAllocDev->free(pProxy->mAllocDev, (buffer_handle_t)(pProxy->gralloc_handle[i])); - pProxy->gralloc_handle[i] = NULL; - } - } - - - COLORCONVERT_close(pProxy->hCC,pCompPrv); - pProxy->bAndroidOpaqueFormat = OMX_FALSE; - - if(pCompPrv->pCompProxyPrv != NULL) - { - TIMM_OSAL_Free(pCompPrv->pCompProxyPrv); - pCompPrv->pCompProxyPrv = NULL; - } - } - - eError = PROXY_ComponentDeInit(hComponent); -EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -int COLORCONVERT_open(void **hCC, PROXY_COMPONENT_PRIVATE *pCompPrv) -{ - int nErr = -1; - hw_module_t const* module = NULL; - OMX_PROXY_H264E_PRIVATE *pProxy = NULL; - - pProxy = (OMX_PROXY_H264E_PRIVATE *) pCompPrv->pCompProxyPrv; - nErr = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); - - if (nErr == 0) - { - *hCC = (void *) ((IMG_gralloc_module_public_t const *)module); - } - else - { - DOMX_ERROR("FATAL: gralloc api hw_get_module() returned error: Can't find \ - %s module err = %x", GRALLOC_HARDWARE_MODULE_ID, nErr); - } - - gralloc_open(module, &(pProxy->mAllocDev)); - - return nErr; -} - -int COLORCONVERT_PlatformOpaqueToNV12(void *hCC, - void *pSrc[COLORCONVERT_MAX_SUB_BUFFERS], - void *pDst[COLORCONVERT_MAX_SUB_BUFFERS], - int nWidth, int nHeight, int nStride, - int nSrcBufType,int nDstBufType) -{ - IMG_gralloc_module_public_t const* module = hCC; - int nErr = -1; - - if((nSrcBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE) && (nDstBufType == COLORCONVERT_BUFTYPE_VIRTUAL)) - { - nErr = module->Blit(module, pSrc[0], pDst, HAL_PIXEL_FORMAT_TI_NV12); - } - else if((nSrcBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE) && (nDstBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE )) - { - nErr = module->Blit2(module, pSrc[0], pDst[0], nWidth, nHeight, 0, 0); - } - - return nErr; -} - -int COLORCONVERT_close(void *hCC,PROXY_COMPONENT_PRIVATE *pCompPrv) -{ - OMX_PROXY_H264E_PRIVATE *pProxy = NULL; - pProxy = (OMX_PROXY_H264E_PRIVATE *) pCompPrv->pCompProxyPrv; - if(pProxy && pProxy->mAllocDev) - { - gralloc_close(pProxy->mAllocDev); - } - return 0; -} -#endif diff --git a/domx/omx_proxy_component/omx_mpeg4_enc/Makefile b/domx/omx_proxy_component/omx_mpeg4_enc/Makefile deleted file mode 100644 index f342e66..0000000 --- a/domx/omx_proxy_component/omx_mpeg4_enc/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -# -# Copyright (C) Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ---------------------------------------------------------------------------- -# Revision History -# -# -# REF=ORG -# Original version. -# ---------------------------------------------------------------------------- - - - -include $(PROJROOT)/make/start.mk - -# Do not change above "include" line(s) - -# Arguments to tools, will move to make system once finalized. - -CFLAGS = -CDEFS = -ifeq ($(BUILD),udeb) -CDEFS += DEBUG -endif -CDEFS += - -EXEC_ARGS = -ST_LIB_ARGS = -SH_LIB_ARGS = - -# Define this macro if target runs in kernel mode -#__KERNEL__ = 1 - -# Target name and extension -# static library (ST_LIB): filename.a -# shared library soname (SH_LIB): filename.so.maj_ver.min_ver -# executable (EXEC) : filename.out - -TARGETNAME = libOMX.TI.DUCATI1.VIDEO.MPEG4E.so - - -# TARGETTYPE must be EXEC, ST_LIB or SH_LIB in upper case. - -TARGETTYPE = SH_LIB - -# install directory relative to the HOSTTARGET directory -HOSTRELEASE = lib - -# install directory relative to the root filesystem -ROOTFSRELEASE = lib - -# Folders in which gmake will run before building current target - -SUBMODULES = \ - -# Filename must not begin with '.', '/' or '\' - -SOURCES = \ -src/omx_proxy_mpeg4enc.c \ - - - -# Search path for include files - -INCLUDES = \ - $(PROJROOT)/omx_core/inc \ - $(PROJROOT)/mm_osal/inc \ - $(PROJROOT)/domx \ - $(PROJROOT)/domx/omx_rpc/inc \ - - -# Libraries needed for linking. - -ST_LIBS = -#mm_osal domx -SH_LIBS = domx omx_core mm_osal -#pthread rt utils procmgr ipc rcm notify -#SH_LIBS += sysmgr sysmemmgr - - -# Search path for library (and linker command) files. -# Current folder and target folder are included by default. - -LIBINCLUDES = $(PROJROOT)/mm_osal \ - $(PROJROOT)/domx \ - $(PROJROOT)/omx_core - - -# Do not change below "include" line(s) - -include $(PROJROOT)/make/build.mk diff --git a/domx/omx_proxy_component/omx_mpeg4_enc/src/omx_proxy_mpeg4enc.c b/domx/omx_proxy_component/omx_mpeg4_enc/src/omx_proxy_mpeg4enc.c deleted file mode 100644 index 9767d89..0000000 --- a/domx/omx_proxy_component/omx_mpeg4_enc/src/omx_proxy_mpeg4enc.c +++ /dev/null @@ -1,1050 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_proxy_mpeg4enc.c - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework Proxy component. - ********************************************************************************************* - This is the proxy specific wrapper that passes the component name to the generic proxy init() - The proxy wrapper also does some runtime/static time onfig on per proxy basis - This is a thin wrapper that is called when componentiit() of the proxy is called - static OMX_ERRORTYPE PROXY_Wrapper_init(OMX_HANDLETYPE hComponent, OMX_PTR pAppData); - this layer gets called first whenever a proxy's get handle is called - ************************************************************************************************ - * @path WTSD_DucatiMMSW\omx\omx_il_1_x\omx_proxy_component\src - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - * 31-August-2011 Lakshman N : Support for color conv at encoder - * input port - * - *! 20-August-2010 Sarthak Aggarwal sarthak@ti.com: Initial Version - *================================================================*/ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ - -#include -#include -#include -#include "omx_proxy_common.h" -#include -#include "OMX_TI_IVCommon.h" -#include "OMX_TI_Video.h" -#include "OMX_TI_Index.h" - -#include -#ifdef ENABLE_GRALLOC_BUFFER -#include "native_handle.h" -#include -#include -#endif - -#include -#include - -#define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.MPEG4E" -/* needs to be specific for every configuration wrapper */ - -#define OMX_MPEG4E_INPUT_PORT 0 -#define LINUX_PAGE_SIZE 4096 - -#ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES -/* Opaque color format requires below quirks to be enabled - * ENABLE_GRALLOC_BUFFER - * ANDROID_QUIRK_CHANGE_PORT_VALUES - */ -OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct); - -OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct); - -#endif - - -#define OMX_INIT_STRUCT(_s_, _name_) \ - memset(&(_s_), 0x0, sizeof(_name_)); \ - (_s_).nSize = sizeof(_name_); \ - (_s_).nVersion.s.nVersionMajor = 0x1; \ - (_s_).nVersion.s.nVersionMinor = 0x1; \ - (_s_).nVersion.s.nRevision = 0x0; \ - (_s_).nVersion.s.nStep = 0x0 - - -/* Params needed for Dynamic Frame Rate Control*/ -#define FRAME_RATE_THRESHOLD 1 /* Change in Frame rate to configure the encoder */ -OMX_U32 nFrameRateThreshold = 0;/* Frame Rate threshold for every frame rate update */ -OMX_U32 nPortFrameRate = 0; /* Port FPS initially set to the Encoder */ -OMX_U32 nFrameCounter = 0; /* Number of input frames recieved since last framerate calculation */ -OMX_TICKS nVideoTime = 0; /* Video duration since last framerate calculation */ -OMX_TICKS nLastFrameRateUpdateTime = 0; /*Time stamp at last frame rate update */ -OMX_U16 nBFrames = 0; /* Number of B Frames in H264 Encoder */ - - -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT -#define OMX_MPEG4E_NUM_INTERNAL_BUF (8) -#define HAL_PIXEL_FORMAT_TI_NV12 (0x100) - -#define COLORCONVERT_MAX_SUB_BUFFERS (3) - -#define COLORCONVERT_BUFTYPE_VIRTUAL (0x0) -#define COLORCONVERT_BUFTYPE_ION (0x1) -#define COLORCONVERT_BUFTYPE_GRALLOCOPAQUE (0x2) - -int COLORCONVERT_open(void **hCC, PROXY_COMPONENT_PRIVATE *pCompPrv); -int COLORCONVERT_PlatformOpaqueToNV12(void *hCC, void *pSrc[], - void *pDst[], int nWidth, - int nHeight, int nStride, - int nSrcBufType, int nDstBufType); -int COLORCONVERT_close(void *hCC,PROXY_COMPONENT_PRIVATE *pCompPrv); - -static OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_AllocateBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE ** ppBufferHdr, OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, OMX_IN OMX_U32 nSizeBytes); - -static OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_BUFFERHEADERTYPE * pBufferHdr); - -static OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_ComponentDeInit(OMX_HANDLETYPE hComponent); - -typedef struct _OMX_PROXY_MPEG4E_PRIVATE -{ - OMX_PTR hBufPipe; - OMX_BOOL bAndroidOpaqueFormat; - OMX_PTR hCC; - IMG_native_handle_t* gralloc_handle[OMX_MPEG4E_NUM_INTERNAL_BUF]; - OMX_S32 nCurBufIndex; - alloc_device_t* mAllocDev; -}OMX_PROXY_MPEG4E_PRIVATE; - -RPC_OMX_ERRORTYPE RPC_RegisterBuffer(OMX_HANDLETYPE hRPCCtx, int fd, - OMX_PTR *handle1, OMX_PTR *handle2, - PROXY_BUFFER_TYPE proxyBufferType); -RPC_OMX_ERRORTYPE RPC_UnRegisterBuffer(OMX_HANDLETYPE hRPCCtx, OMX_PTR handle); -#endif - -OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE * pIndexType); - -OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_EmptyThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr); - -static OMX_ERRORTYPE OMX_ConfigureDynamicFrameRate( OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_U32 nTargetFrameRate = 0; /* Target Frame Rate to be provided to Encoder */ - OMX_U32 nCurrentFrameRate = 0; /* Current Frame Rate currently set in Encoder */ - OMX_CONFIG_FRAMERATETYPE tFrameRate; - OMX_COMPONENTTYPE *pHandle; - if (hComponent == NULL){ - DOMX_ERROR("Component is invalid/ not present "); - return OMX_ErrorBadParameter; - } - pHandle = (OMX_COMPONENTTYPE *) hComponent; - - /* Initialise the OMX structures */ - OMX_INIT_STRUCT(tFrameRate,OMX_CONFIG_FRAMERATETYPE); - - /* Intialise nLastFrameRateUpdateTime for the 1st frame */ - if((!nFrameCounter) && (!nLastFrameRateUpdateTime)){ - nLastFrameRateUpdateTime = pBufferHdr-> nTimeStamp; - } - - /* Increment the Frame Counter and Calculate Frame Rate*/ - nFrameCounter++; - nVideoTime = pBufferHdr->nTimeStamp - nLastFrameRateUpdateTime; - - if(nVideoTime < 0) { - return OMX_ErrorBadParameter; - } - - /*Get Port Frame Rate if not read yet*/ - if(!nFrameRateThreshold) { - tFrameRate.nPortIndex = OMX_MPEG4E_INPUT_PORT; /* As per ducati support-set for input port */ - - /* Read Current FrameRate */ - eError = pHandle->GetConfig(hComponent,OMX_IndexConfigVideoFramerate,&tFrameRate); - if (eError != OMX_ErrorNone) - DOMX_ERROR ("pHandle->GetConfig OMX_IndexConfigVideoFramerate eError :0x%x \n",eError); - nFrameRateThreshold = tFrameRate.xEncodeFramerate >>16; - nPortFrameRate = nFrameRateThreshold; - DOMX_DEBUG(" Port Frame Rate is %d ", nPortFrameRate); - } - nCurrentFrameRate = nFrameRateThreshold; - - /* If Number of frames is less than the Threshold - * Frame Rate udpate is not necessary - */ - if(nFrameCounter < nFrameRateThreshold){ - DOMX_EXIT(" Threshold not reached, no update necessary"); - return OMX_ErrorNone; - } - - /*Calculate the new target Frame Rate*/ - if (nVideoTime != 0) - nTargetFrameRate = nFrameCounter * 1000000 / nVideoTime; - - /* For 1080p record, max FPS supported by Codec for profile 4.1 is 30. - * When Dynamic Frame Rate is enabled, there might be scenario when FPS - * calculated is more than 30. Hence adding the check so that Dynamic Frame - * Rate set is never greater than the port FPS initially set. - */ - if(nTargetFrameRate > nPortFrameRate){ - DOMX_DEBUG("Frame Rate Calculated is more than initial port set Frame Rate"); - nTargetFrameRate = nPortFrameRate; - } - - /* Difference in Frame Rate is more than Threshold - Only then update Frame Rate*/ - if((( (OMX_S32)nTargetFrameRate) -((OMX_S32) nCurrentFrameRate) >= FRAME_RATE_THRESHOLD) || - (((OMX_S32) nCurrentFrameRate) - ( (OMX_S32)nTargetFrameRate) >= FRAME_RATE_THRESHOLD)) { - - /* Now Send the new Frame Rate */ - tFrameRate.nPortIndex = OMX_MPEG4E_INPUT_PORT; /* As per ducati support-set for input port */ - tFrameRate.xEncodeFramerate = (OMX_U32)(nTargetFrameRate * (1 << 16)); - eError = pHandle->SetConfig(hComponent,OMX_IndexConfigVideoFramerate,&tFrameRate); - if(eError != OMX_ErrorNone){ - DOMX_ERROR(" Error while configuring Dynamic Frame Rate,Error info = %d",eError); - return eError; - } else { - DOMX_DEBUG("Dynamic Frame Rate configuration successful \n"); - } - nFrameRateThreshold = nTargetFrameRate; /*Update the threshold */ - } - - /* reset all params */ - nFrameCounter = 0 ; - nVideoTime = 0; - nLastFrameRateUpdateTime = pBufferHdr->nTimeStamp; - return OMX_ErrorNone; -} - -static OMX_ERRORTYPE ComponentPrivateEmptyThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - - eError = OMX_ConfigureDynamicFrameRate(hComponent, pBufferHdr); - if( eError != OMX_ErrorNone) - DOMX_ERROR(" Error while configuring FrameRate Dynamically.Error info = %d",eError); - - DOMX_DEBUG("Redirection from ComponentPricateEmptyThisBuffer to PROXY_EmptyThisBuffer"); - return LOCAL_PROXY_MPEG4E_EmptyThisBuffer (hComponent,pBufferHdr); -} - -OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL; - pHandle = (OMX_COMPONENTTYPE *) hComponent; - OMX_TI_PARAM_ENHANCEDPORTRECONFIG tParamStruct; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - TIMM_OSAL_ERRORTYPE eOSALStatus = TIMM_OSAL_ERR_NONE; - OMX_PROXY_MPEG4E_PRIVATE *pProxy = NULL; -#endif - char value[OMX_MAX_STRINGNAME_SIZE]; - OMX_U32 mEnableVFR = 1; /* Flag used to enable/disable VFR for Encoder */ - property_get("debug.vfr.enable", value, "1"); - mEnableVFR = atoi(value); - - DOMX_ENTER(""); - - DOMX_DEBUG("Component name provided is %s", COMPONENT_NAME); - - pHandle->pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) - TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), TIMM_OSAL_TRUE, - 0, TIMMOSAL_MEM_SEGMENT_INT); - - PROXY_assert(pHandle->pComponentPrivate != NULL, - OMX_ErrorInsufficientResources, - "ERROR IN ALLOCATING PROXY COMPONENT PRIVATE STRUCTURE"); - - pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - - TIMM_OSAL_Memset(pComponentPrivate, 0, - sizeof(PROXY_COMPONENT_PRIVATE)); - - pComponentPrivate->cCompName = - TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8), - TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); - - PROXY_assert(pComponentPrivate->cCompName != NULL, - OMX_ErrorInsufficientResources, - " Error in Allocating space for proxy component table"); - -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - pComponentPrivate->pCompProxyPrv = - (OMX_PROXY_MPEG4E_PRIVATE *) - TIMM_OSAL_Malloc(sizeof(OMX_PROXY_MPEG4E_PRIVATE), TIMM_OSAL_TRUE, - 0, TIMMOSAL_MEM_SEGMENT_INT); - - PROXY_assert(pComponentPrivate->pCompProxyPrv != NULL, - OMX_ErrorInsufficientResources, - " Could not allocate proxy component private"); - - TIMM_OSAL_Memset(pComponentPrivate->pCompProxyPrv, 0, - sizeof(OMX_PROXY_MPEG4E_PRIVATE)); - - pProxy = (OMX_PROXY_MPEG4E_PRIVATE *) pComponentPrivate->pCompProxyPrv; - - /* Create Pipe of for encoder input buffers */ - eOSALStatus = TIMM_OSAL_CreatePipe(&pProxy->hBufPipe, sizeof(OMX_U32), - OMX_MPEG4E_NUM_INTERNAL_BUF, 1); - PROXY_assert(eOSALStatus == TIMM_OSAL_ERR_NONE, - OMX_ErrorInsufficientResources, - "Pipe creation failed"); - -#endif - - // Copying component Name - this will be picked up in the proxy common - PROXY_assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH, - OMX_ErrorInvalidComponentName, - "Length of component name is longer than the max allowed"); - TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, - strlen(COMPONENT_NAME) + 1); - - eError = OMX_ProxyCommonInit(hComponent); // Calling Proxy Common Init() -#ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES - pHandle->SetParameter = LOCAL_PROXY_MPEG4E_SetParameter; - pHandle->GetParameter = LOCAL_PROXY_MPEG4E_GetParameter; -#endif - pHandle->ComponentDeInit = LOCAL_PROXY_MPEG4E_ComponentDeInit; - pHandle->FreeBuffer = LOCAL_PROXY_MPEG4E_FreeBuffer; - pHandle->AllocateBuffer = LOCAL_PROXY_MPEG4E_AllocateBuffer; - - pComponentPrivate->IsLoadedState = OMX_TRUE; - pHandle->EmptyThisBuffer = LOCAL_PROXY_MPEG4E_EmptyThisBuffer; - pHandle->GetExtensionIndex = LOCAL_PROXY_MPEG4E_GetExtensionIndex; - - if(mEnableVFR) - pHandle->EmptyThisBuffer = ComponentPrivateEmptyThisBuffer; - - EXIT: - if (eError != OMX_ErrorNone) - { - DOMX_DEBUG("Error in Initializing Proxy"); - -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - if(pProxy->hBufPipe != NULL) - { - TIMM_OSAL_DeletePipe(pProxy->hBufPipe); - pProxy->hBufPipe = NULL; - } - - if(pComponentPrivate->pCompProxyPrv != NULL) - { - TIMM_OSAL_Free(pComponentPrivate->pCompProxyPrv); - pComponentPrivate->pCompProxyPrv = NULL; - pProxy = NULL; - } -#endif - if (pComponentPrivate->cCompName != NULL) - { - TIMM_OSAL_Free(pComponentPrivate->cCompName); - pComponentPrivate->cCompName = NULL; - } - if (pComponentPrivate != NULL) - { - TIMM_OSAL_Free(pComponentPrivate); - pComponentPrivate = NULL; - } - } - return eError; -} - -#ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES - -/* ===========================================================================*/ -/** - * @name PROXY_MPEG4E_GetParameter() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_PARAM_PORTDEFINITIONTYPE* pPortDef = NULL; - OMX_VIDEO_PARAM_PORTFORMATTYPE* pPortParam = NULL; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - OMX_PROXY_MPEG4E_PRIVATE *pProxy = NULL; -#endif - - PROXY_require((pParamStruct != NULL), OMX_ErrorBadParameter, NULL); - PROXY_assert((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - pProxy = (OMX_PROXY_MPEG4E_PRIVATE *) pCompPrv->pCompProxyPrv; -#endif - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nParamIndex = %d, pParamStruct = %p", - hComponent, pCompPrv, nParamIndex, pParamStruct); - - eError = PROXY_GetParameter(hComponent,nParamIndex, pParamStruct); - - if(nParamIndex == OMX_IndexParamPortDefinition) - { - pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; - - if(pPortDef->format.video.eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar) - { -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - if(pProxy->bAndroidOpaqueFormat == OMX_TRUE) - { - pPortDef->format.video.eColorFormat = OMX_COLOR_FormatAndroidOpaque; - } - else -#endif - { - pPortDef->format.video.eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar; - } - } - } - else if (nParamIndex == OMX_IndexParamVideoPortFormat) - { - pPortParam = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct; - - if((eError == OMX_ErrorNone) && - (pPortParam->eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar)) - { - pPortParam->eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar; - } -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - else if ((eError == OMX_ErrorNoMore) && (pPortParam->nIndex == 1)) - { - /* HACK:Remote OMX-MPEG4E supports only 1 color format (index 0). The - * OMX_COLOR_FormatAndroidOpaque is supported only at the proxy. - * Call GetParameter() to fill in defaults for parameters and - * override color format and index for the additional - * OMX_COLOR_FormatAndroidOpaque support*/ - pPortParam->nIndex = 0; - eError = PROXY_GetParameter(hComponent, nParamIndex, pParamStruct); - pPortParam->nIndex = 1; - pPortParam->eColorFormat = OMX_COLOR_FormatAndroidOpaque; - eError = OMX_ErrorNone; - } -#endif - } - - PROXY_assert((eError == OMX_ErrorNone) || (eError == OMX_ErrorNoMore), - eError," Error in Proxy GetParameter"); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_MPEG4E_SetParameter() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_PARAM_PORTDEFINITIONTYPE* pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; - OMX_VIDEO_PARAM_PORTFORMATTYPE* pPortParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct; - OMX_VIDEO_STOREMETADATAINBUFFERSPARAMS* pStoreMetaData = (OMX_VIDEO_STOREMETADATAINBUFFERSPARAMS *) pParamStruct; - OMX_TI_PARAM_BUFFERPREANNOUNCE tParamSetNPA; - OMX_PARAM_PORTDEFINITIONTYPE sPortDef; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - OMX_PROXY_MPEG4E_PRIVATE *pProxy = NULL; -#endif - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nParamIndex = %d, pParamStruct = %p", - hComponent, pCompPrv, nParamIndex, pParamStruct); - - PROXY_require((pParamStruct != NULL), OMX_ErrorBadParameter, NULL); - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - pProxy = (OMX_PROXY_MPEG4E_PRIVATE *) pCompPrv->pCompProxyPrv; -#endif - - if(nParamIndex == OMX_IndexParamPortDefinition) - { - if(pPortDef->format.video.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar) - { - pPortDef->format.video.eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - } -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - else if(pPortDef->format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque) - { - if(COLORCONVERT_open(&pProxy->hCC,pCompPrv) != 0) - { - PROXY_assert(0, OMX_ErrorInsufficientResources, - "Failed to open Color converting service"); - } - pProxy->bAndroidOpaqueFormat = OMX_TRUE; - pPortDef->format.video.eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - } -#endif - } - else if(nParamIndex == OMX_IndexParamVideoPortFormat) - { - if(pPortParams->eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar) - { - pPortParams->eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - } -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - else if(pPortParams->eColorFormat == OMX_COLOR_FormatAndroidOpaque) - { - if(COLORCONVERT_open(&pProxy->hCC,pCompPrv) != 0) - { - PROXY_assert(0, OMX_ErrorInsufficientResources, - "Failed to open Color converting service"); - } - pProxy->bAndroidOpaqueFormat = OMX_TRUE; - pPortParams->eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - } -#endif - } - else if(nParamIndex == (OMX_INDEXTYPE) OMX_TI_IndexEncoderStoreMetadatInBuffers) - { - DOMX_DEBUG("Moving to Metadatamode"); - if (pStoreMetaData->nPortIndex == OMX_MPEG4E_INPUT_PORT && pStoreMetaData->bStoreMetaData == OMX_TRUE) - { - tParamSetNPA.nSize = sizeof(OMX_TI_PARAM_BUFFERPREANNOUNCE); - tParamSetNPA.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - tParamSetNPA.nVersion.s.nVersionMinor = OMX_VER_MINOR; - tParamSetNPA.nVersion.s.nRevision = 0x0; - tParamSetNPA.nVersion.s.nStep = 0x0; - tParamSetNPA.nPortIndex = OMX_MPEG4E_INPUT_PORT; - tParamSetNPA.bEnabled = OMX_TRUE; - //Call NPA on OMX encoder on ducati. - PROXY_SetParameter(hComponent,OMX_TI_IndexParamBufferPreAnnouncement, &tParamSetNPA); - pCompPrv->proxyPortBuffers[pStoreMetaData->nPortIndex].proxyBufferType = EncoderMetadataPointers; - DOMX_DEBUG("Moving to Metadatamode done"); - - /*Initializing Structure */ - sPortDef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); - sPortDef.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - sPortDef.nVersion.s.nVersionMinor = OMX_VER_MINOR; - sPortDef.nVersion.s.nRevision = 0x0; - sPortDef.nVersion.s.nStep = 0x0; - sPortDef.nPortIndex = OMX_MPEG4E_INPUT_PORT; - - eError = PROXY_GetParameter(hComponent,OMX_IndexParamPortDefinition, &sPortDef); - PROXY_assert(eError == OMX_ErrorNone, eError," Error in Proxy GetParameter for Port Def"); - - sPortDef.format.video.nStride = LINUX_PAGE_SIZE; - - eError = PROXY_SetParameter(hComponent,OMX_IndexParamPortDefinition, &sPortDef); - - PROXY_assert(eError == OMX_ErrorNone, eError," Error in Proxy SetParameter for Port Def"); - } - goto EXIT; - } - - eError = PROXY_SetParameter(hComponent, nParamIndex, pParamStruct); - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in Proxy SetParameter"); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -#endif - - -/* ===========================================================================*/ -/** - * @name PROXY_GetExtensionIndex() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE * pIndexType) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = hComponent; - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - PROXY_require(cParameterName != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(pIndexType != NULL, OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER("%s hComponent = %p, pCompPrv = %p, cParameterName = %s", - __FUNCTION__,hComponent, pCompPrv, cParameterName); - - // Check for NULL Parameters - PROXY_require((cParameterName != NULL && pIndexType != NULL), - OMX_ErrorBadParameter, NULL); - - // Ensure that String length is not greater than Max allowed length - PROXY_require(strlen(cParameterName) <= 127, OMX_ErrorBadParameter, NULL); - - if(strcmp(cParameterName, "OMX.google.android.index.storeMetaDataInBuffers") == 0) - { - // If Index type is 2D Buffer Allocated Dimension - *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexEncoderStoreMetadatInBuffers; - goto EXIT; - } - - eError = PROXY_GetExtensionIndex(hComponent, cParameterName, pIndexType); - - EXIT: - DOMX_EXIT("%s eError: %d",__FUNCTION__, eError); - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_MPEG4E_EmptyThisBuffer() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_EmptyThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_PTR pBufferOrig = NULL; - OMX_U32 nStride = 0, nNumLines = 0; - OMX_PARAM_PORTDEFINITIONTYPE tParamStruct; - OMX_U32 nFilledLen, nAllocLen; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - OMX_PROXY_MPEG4E_PRIVATE *pProxy = NULL; - TIMM_OSAL_ERRORTYPE eOSALStatus = TIMM_OSAL_ERR_NONE; - OMX_U32 nBufIndex = 0, nSize=0, nRet=0; -#endif -#ifdef ENABLE_GRALLOC_BUFFER - OMX_PTR pAuxBuf0 = NULL, pAuxBuf1 = NULL; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - OMX_ERRORTYPE eCompReturn = OMX_ErrorNone; -#endif - - PROXY_require(pBufferHdr != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, - NULL); - PROXY_CHK_VERSION(pBufferHdr, OMX_BUFFERHEADERTYPE); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - pProxy = (OMX_PROXY_MPEG4E_PRIVATE *) pCompPrv->pCompProxyPrv; -#endif - - tParamStruct.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); - tParamStruct.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - tParamStruct.nVersion.s.nVersionMinor = OMX_VER_MINOR; - tParamStruct.nVersion.s.nRevision = 0x0; - tParamStruct.nVersion.s.nStep = 0x0; - tParamStruct.nPortIndex = OMX_MPEG4E_INPUT_PORT; - - eError = PROXY_GetParameter(hComponent, OMX_IndexParamPortDefinition, &tParamStruct); - PROXY_require(eError == OMX_ErrorNone, OMX_ErrorBadParameter, "Error is Get Parameter for port def"); - nFilledLen = pBufferHdr->nFilledLen; - nAllocLen = pBufferHdr->nAllocLen; - if(nFilledLen != 0) - { - pBufferHdr->nFilledLen = tParamStruct.nBufferSize; - } - pBufferHdr->nAllocLen = tParamStruct.nBufferSize; - - DOMX_DEBUG - ("%s hComponent=%p, pCompPrv=%p, nFilledLen=%d, nOffset=%d, nFlags=%08x", - __FUNCTION__,hComponent, pCompPrv, pBufferHdr->nFilledLen, - pBufferHdr->nOffset, pBufferHdr->nFlags); - - if( pCompPrv->proxyPortBuffers[OMX_MPEG4E_INPUT_PORT].proxyBufferType == EncoderMetadataPointers - && nFilledLen != 0) - { - OMX_U32 *pTempBuffer; - OMX_U32 nMetadataBufferType; - DOMX_DEBUG("Passing meta data to encoder"); - - pBufferOrig = pBufferHdr->pBuffer; - - pTempBuffer = (OMX_U32 *) (pBufferHdr->pBuffer); - nMetadataBufferType = *pTempBuffer; - - if(nMetadataBufferType == kMetadataBufferTypeCameraSource) - { -#ifdef ENABLE_GRALLOC_BUFFER - IMG_native_handle_t* pGrallocHandle; - video_metadata_t* pVideoMetadataBuffer; - DOMX_DEBUG("MetadataBufferType is kMetadataBufferTypeCameraSource"); - - pVideoMetadataBuffer = (video_metadata_t*) ((OMX_U32 *)(pBufferHdr->pBuffer)); - pGrallocHandle = (IMG_native_handle_t*) (pVideoMetadataBuffer->handle); - DOMX_DEBUG("Grallloc buffer recieved in metadata buffer 0x%x",pGrallocHandle ); - - pBufferHdr->pBuffer = (OMX_U8 *)(pGrallocHandle->fd[0]); - ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)-> - pAuxBuf1 = (OMX_PTR) pGrallocHandle->fd[1]; - DOMX_DEBUG("%s Gralloc=0x%x, Y-fd=%d, UV-fd=%d", __FUNCTION__, pGrallocHandle, - pGrallocHandle->fd[0], pGrallocHandle->fd[1]); - - pBufferHdr->nOffset = pVideoMetadataBuffer->offset; -#endif - } - else if(nMetadataBufferType == kMetadataBufferTypeGrallocSource) - { -#ifdef ENABLE_GRALLOC_BUFFER - IMG_native_handle_t* pGrallocHandle; - buffer_handle_t tBufHandle; - DOMX_DEBUG("MetadataBufferType is kMetadataBufferTypeGrallocSource"); - - pTempBuffer++; - tBufHandle = *((buffer_handle_t *)pTempBuffer); - pGrallocHandle = (IMG_native_handle_t*) tBufHandle; - DOMX_DEBUG("Grallloc buffer recieved in metadata buffer 0x%x",pGrallocHandle ); - - pBufferHdr->pBuffer = (OMX_U8 *)(pGrallocHandle->fd[0]); - ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)-> - pAuxBuf1 = (OMX_PTR) pGrallocHandle->fd[1]; - DOMX_DEBUG("%s Gralloc=0x%x, Y-fd=%d, UV-fd=%d", __FUNCTION__, pGrallocHandle, - pGrallocHandle->fd[0], pGrallocHandle->fd[1]); -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - if (pProxy->bAndroidOpaqueFormat) - { - DOMX_DEBUG(" ++TIMM_OSAL_ReadFromPipe() "); - /* Dequeue NV12 buffer for encoder */ - eOSALStatus = TIMM_OSAL_ReadFromPipe(pProxy->hBufPipe, &nBufIndex, - sizeof(OMX_PTR), (TIMM_OSAL_U32 *)(&nSize), - TIMM_OSAL_SUSPEND); - PROXY_assert(eOSALStatus == TIMM_OSAL_ERR_NONE, OMX_ErrorBadParameter, NULL); - - /* Get NV12 data after colorconv*/ - nRet = COLORCONVERT_PlatformOpaqueToNV12(pProxy->hCC, (void **) &pGrallocHandle, (void **) &pProxy->gralloc_handle[nBufIndex], - pGrallocHandle->iWidth, - pGrallocHandle->iHeight, - 4096, COLORCONVERT_BUFTYPE_GRALLOCOPAQUE, - COLORCONVERT_BUFTYPE_GRALLOCOPAQUE ); - if(nRet != 0) - { - eOSALStatus = TIMM_OSAL_WriteToPipe(pProxy->hBufPipe, (void *) &nBufIndex, - sizeof(OMX_U32), TIMM_OSAL_SUSPEND); - PROXY_assert(0, OMX_ErrorBadParameter, "Color conversion routine failed"); - } - DOMX_DEBUG(" --COLORCONVERT_PlatformOpaqueToNV12() "); - - /* Update pBufferHdr with NV12 buffers for OMX component */ - pBufferHdr->pBuffer= (OMX_U8 *)(pProxy->gralloc_handle[nBufIndex]->fd[0]); - ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->pAuxBuf1 = (OMX_PTR)(pProxy->gralloc_handle[nBufIndex]->fd[1]); - } -#endif -#endif - } - else - { - return OMX_ErrorBadParameter; - } -#ifdef ENABLE_GRALLOC_BUFFER - eRPCError = RPC_RegisterBuffer(pCompPrv->hRemoteComp, pBufferHdr->pBuffer, - &pAuxBuf0, &pAuxBuf1, - GrallocPointers); - PROXY_checkRpcError(); - if (pAuxBuf0) - pBufferHdr->pBuffer = pAuxBuf0; - if (pAuxBuf1) - ((OMX_TI_PLATFORMPRIVATE *) pBufferHdr->pPlatformPrivate)->pAuxBuf1 = pAuxBuf1; -#endif - } - - eError = PROXY_EmptyThisBuffer(hComponent, pBufferHdr); -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT - if (pProxy->bAndroidOpaqueFormat) - { - /*Write buffer to end of pipe for re-circulation for future ETB()*/ - eOSALStatus = TIMM_OSAL_WriteToPipe(pProxy->hBufPipe, (void *) &nBufIndex, - sizeof(OMX_U32), TIMM_OSAL_SUSPEND); - PROXY_assert(eOSALStatus == TIMM_OSAL_ERR_NONE, OMX_ErrorBadParameter, "Pipe write failed"); - } -#endif - - if( pCompPrv->proxyPortBuffers[pBufferHdr->nInputPortIndex].proxyBufferType == EncoderMetadataPointers) { - pBufferHdr->pBuffer = pBufferOrig; -#ifdef ENABLE_GRALLOC_BUFFER - RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, pAuxBuf0); - RPC_UnRegisterBuffer(pCompPrv->hRemoteComp, pAuxBuf1); -#endif - } - EXIT: - return eError; -} - -#ifdef ANDROID_CUSTOM_OPAQUECOLORFORMAT -static OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_AllocateBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE ** ppBufferHdr, OMX_U32 nPortIndex, - OMX_PTR pAppPrivate, OMX_U32 nSizeBytes) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_CONFIG_RECTTYPE tParamRect; - OMX_PROXY_MPEG4E_PRIVATE *pProxy = NULL; - TIMM_OSAL_ERRORTYPE eOSALStatus = TIMM_OSAL_ERR_NONE; - DOMX_DEBUG(" ++LOCAL_PROXY_MPEG4E_AllocateBuffer"); - int err, nStride; - - PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, - NULL); - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - pProxy = (OMX_PROXY_MPEG4E_PRIVATE *) pCompPrv->pCompProxyPrv; - - if((nPortIndex == OMX_MPEG4E_INPUT_PORT) && - (pProxy->bAndroidOpaqueFormat)) - { - tParamRect.nSize = sizeof(OMX_CONFIG_RECTTYPE); - tParamRect.nVersion.s.nVersionMajor = 1; - tParamRect.nVersion.s.nVersionMinor = 1; - tParamRect.nVersion.s.nRevision = 0; - tParamRect.nVersion.s.nStep = 0; - tParamRect.nPortIndex = nPortIndex; - - eError = PROXY_GetParameter(hComponent, (OMX_INDEXTYPE)OMX_TI_IndexParam2DBufferAllocDimension, &tParamRect); - PROXY_assert(eError == OMX_ErrorNone, eError," Error in Proxy GetParameter from 2d index in allocate buffer"); - - err = pProxy->mAllocDev->alloc(pProxy->mAllocDev,(int) tParamRect.nWidth,(int) tParamRect.nHeight, - (int) HAL_PIXEL_FORMAT_TI_NV12,(int) GRALLOC_USAGE_HW_RENDER, - (const struct native_handle_t **)(&(pProxy->gralloc_handle[pProxy->nCurBufIndex])), &nStride); - } - - eError = PROXY_AllocateBuffer(hComponent, ppBufferHdr, nPortIndex, - pAppPrivate, nSizeBytes); -EXIT: - if((nPortIndex == OMX_MPEG4E_INPUT_PORT) && - (pProxy->bAndroidOpaqueFormat)) - { - if(eError != OMX_ErrorNone) - { - err = pProxy->mAllocDev->free(pProxy->mAllocDev, (buffer_handle_t)(pProxy->gralloc_handle[pProxy->nCurBufIndex])); - } - else - { - /*Populate buffer to pipe*/ - eOSALStatus = TIMM_OSAL_WriteToPipe(pProxy->hBufPipe, (void *) &pProxy->nCurBufIndex, - sizeof(OMX_U32), TIMM_OSAL_SUSPEND); - pProxy->nCurBufIndex++; - } - } - DOMX_DEBUG(" --LOCAL_PROXY_MPEG4E_AllocateBuffer"); - return eError; -} - -static OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_U32 nBufIndex, nSize, nCount=0; - OMX_PROXY_MPEG4E_PRIVATE *pProxy = NULL; - - PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, - NULL); - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - pProxy = (OMX_PROXY_MPEG4E_PRIVATE *) pCompPrv->pCompProxyPrv; - - if((nPortIndex == OMX_MPEG4E_INPUT_PORT) && - (pProxy->bAndroidOpaqueFormat)) - { - pProxy->nCurBufIndex--; - PROXY_require(pProxy->nCurBufIndex >=0, - OMX_ErrorBadParameter, "Buffer index underflow"); - - if(pProxy->gralloc_handle[pProxy->nCurBufIndex]) - { - pProxy->mAllocDev->free(pProxy->mAllocDev, (buffer_handle_t)(pProxy->gralloc_handle[pProxy->nCurBufIndex])); - pProxy->gralloc_handle[pProxy->nCurBufIndex] = NULL; - } - - /*Clear the Bufindex pipe by dummy reads*/ - TIMM_OSAL_GetPipeReadyMessageCount(pProxy->hBufPipe, (TIMM_OSAL_U32 *)&nCount); - if(nCount) - { - TIMM_OSAL_ReadFromPipe(pProxy->hBufPipe, &nBufIndex, - sizeof(OMX_PTR), (TIMM_OSAL_U32 *)&nSize, TIMM_OSAL_NO_SUSPEND); - } - } - - eError = PROXY_FreeBuffer(hComponent, nPortIndex, pBufferHdr); - -EXIT: - return eError; -} - -OMX_ERRORTYPE LOCAL_PROXY_MPEG4E_ComponentDeInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_PROXY_MPEG4E_PRIVATE *pProxy = NULL; - TIMM_OSAL_ERRORTYPE eOSALStatus = TIMM_OSAL_ERR_NONE; - OMX_U32 i; - - PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, - NULL); - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - pProxy = (OMX_PROXY_MPEG4E_PRIVATE *) pCompPrv->pCompProxyPrv; - - if(pProxy->hBufPipe != NULL) - { - eOSALStatus = TIMM_OSAL_DeletePipe(pProxy->hBufPipe); - pProxy->hBufPipe = NULL; - - if(eOSALStatus != TIMM_OSAL_ERR_NONE) - { - DOMX_ERROR("Pipe deletion failed"); - } - } - - if(pProxy->bAndroidOpaqueFormat == OMX_TRUE) - { - /* Cleanup internal buffers in pipe if not freed on FreeBuffer */ - for(i=0; igralloc_handle[i]) - { - pProxy->mAllocDev->free(pProxy->mAllocDev, (buffer_handle_t)(pProxy->gralloc_handle[i])); - pProxy->gralloc_handle[i] = NULL; - } - } - - COLORCONVERT_close(pProxy->hCC,pCompPrv); - pProxy->bAndroidOpaqueFormat = OMX_FALSE; - - if(pCompPrv->pCompProxyPrv != NULL) - { - TIMM_OSAL_Free(pCompPrv->pCompProxyPrv); - pCompPrv->pCompProxyPrv = NULL; - } - } - - eError = PROXY_ComponentDeInit(hComponent); -EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -int COLORCONVERT_open(void **hCC, PROXY_COMPONENT_PRIVATE *pCompPrv) -{ - int nErr = -1; - hw_module_t const* module = NULL; - OMX_PROXY_MPEG4E_PRIVATE *pProxy = NULL; - - pProxy = (OMX_PROXY_MPEG4E_PRIVATE *) pCompPrv->pCompProxyPrv; - nErr = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); - - if (nErr == 0) - { - *hCC = (void *) ((IMG_gralloc_module_public_t const *)module); - } - else - { - DOMX_ERROR("FATAL: gralloc api hw_get_module() returned error: Can't find \ - %s module err = %x", GRALLOC_HARDWARE_MODULE_ID, nErr); - } - - gralloc_open(module, &(pProxy->mAllocDev)); - - return nErr; -} - -int COLORCONVERT_PlatformOpaqueToNV12(void *hCC, - void *pSrc[COLORCONVERT_MAX_SUB_BUFFERS], - void *pDst[COLORCONVERT_MAX_SUB_BUFFERS], - int nWidth, int nHeight, int nStride, - int nSrcBufType,int nDstBufType) -{ - IMG_gralloc_module_public_t const* module = hCC; - int nErr = -1; - - if((nSrcBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE) && (nDstBufType == COLORCONVERT_BUFTYPE_VIRTUAL)) - { - nErr = module->Blit(module, pSrc[0], pDst, HAL_PIXEL_FORMAT_TI_NV12); - - } - else if((nSrcBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE) && (nDstBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE )) - { - nErr = module->Blit2(module, pSrc[0], pDst[0], nWidth, nHeight, 0, 0); - } - - return nErr; -} - -int COLORCONVERT_close(void *hCC,PROXY_COMPONENT_PRIVATE *pCompPrv) -{ - OMX_PROXY_MPEG4E_PRIVATE *pProxy = NULL; - pProxy = (OMX_PROXY_MPEG4E_PRIVATE *) pCompPrv->pCompProxyPrv; - if(pProxy && pProxy->mAllocDev) - { - gralloc_close(pProxy->mAllocDev); - } - return 0; -} -#endif diff --git a/domx/omx_proxy_component/omx_sample/Makefile b/domx/omx_proxy_component/omx_sample/Makefile deleted file mode 100755 index 499d1a6..0000000 --- a/domx/omx_proxy_component/omx_sample/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -# -# Copyright (C) Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ---------------------------------------------------------------------------- -# Revision History -# -# -# REF=ORG -# Original version. -# ---------------------------------------------------------------------------- - - - -include $(PROJROOT)/make/start.mk - -# Do not change above "include" line(s) - -# Arguments to tools, will move to make system once finalized. - -CFLAGS = -CDEFS = -ifeq ($(BUILD),udeb) -CDEFS += DEBUG -endif -CDEFS += - -EXEC_ARGS = -ST_LIB_ARGS = -SH_LIB_ARGS = - -# Define this macro if target runs in kernel mode -#__KERNEL__ = 1 - -# Target name and extension -# static library (ST_LIB): filename.a -# shared library soname (SH_LIB): filename.so.maj_ver.min_ver -# executable (EXEC) : filename.out - -TARGETNAME = libOMX.TI.DUCATI1.MISC.SAMPLE.so - - -# TARGETTYPE must be EXEC, ST_LIB or SH_LIB in upper case. - -TARGETTYPE = SH_LIB - -# install directory relative to the HOSTTARGET directory -HOSTRELEASE = lib - -# install directory relative to the root filesystem -ROOTFSRELEASE = lib - -# Folders in which gmake will run before building current target - -SUBMODULES = \ - -# Filename must not begin with '.', '/' or '\' - -SOURCES = \ -src/omx_proxy_sample.c \ - - - -# Search path for include files - -INCLUDES = \ - $(PROJROOT)/omx_core/inc \ - $(PROJROOT)/mm_osal/inc \ - $(PROJROOT)/domx \ - $(PROJROOT)/domx/omx_rpc/inc \ - - -# Libraries needed for linking. - -ST_LIBS = -#mm_osal domx -SH_LIBS = domx omx_core mm_osal -#pthread rt utils procmgr ipc rcm notify -#SH_LIBS += sysmgr sysmemmgr - - -# Search path for library (and linker command) files. -# Current folder and target folder are included by default. - -LIBINCLUDES = $(PROJROOT)/mm_osal \ - $(PROJROOT)/domx \ - $(PROJROOT)/omx_core - - -# Do not change below "include" line(s) - -include $(PROJROOT)/make/build.mk diff --git a/domx/omx_proxy_component/omx_sample/src/omx_proxy_sample.c b/domx/omx_proxy_component/omx_sample/src/omx_proxy_sample.c deleted file mode 100755 index b270186..0000000 --- a/domx/omx_proxy_component/omx_sample/src/omx_proxy_sample.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_proxy_sample.c - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework Tunnel Proxy component. - ********************************************************************************************* - This is the proxy specific wrapper that passes the component name to the generic proxy init() - The proxy wrapper also does some runtime/static time onfig on per proxy basis - This is a thin wrapper that is called when componentiit() of the proxy is called - static OMX_ERRORTYPE PROXY_Wrapper_init(OMX_HANDLETYPE hComponent, OMX_PTR pAppData); - this layer gets called first whenever a proxy s get handle is called - ************************************************************************************************ - * @path WTSD_DucatiMMSW\omx\omx_il_1_x\omx_proxy_component\src - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 19-August-2009 B Ravi Kiran ravi.kiran@ti.com: Initial Version - *================================================================*/ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -#include -#include -#include -#include "omx_proxy_common.h" -#include -//change to ducati1 later -#define COMPONENT_NAME "OMX.TI.DUCATI1.MISC.SAMPLE" // needs to be specific for every configuration wrapper - -OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - PROXY_COMPONENT_PRIVATE *pComponentPrivate; - pHandle = (OMX_COMPONENTTYPE *) hComponent; - - DOMX_DEBUG - ("_____________________INSISDE PROXY WRAPPER__________________________\n"); - - pHandle->pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) - TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), TIMM_OSAL_TRUE, - 0, TIMMOSAL_MEM_SEGMENT_INT); - - pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - if (pHandle->pComponentPrivate == NULL) - { - DOMX_DEBUG - (" ERROR IN ALLOCATING PROXY COMPONENT PRIVATE STRUCTURE"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - pComponentPrivate->cCompName = - TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8), - TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); - // Copying component Name - this will be picked up in the proxy common - assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH); - TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, - strlen(COMPONENT_NAME) + 1); - eError = OMX_ProxyCommonInit(hComponent); // Calling Proxy Common Init() - - if (eError != OMX_ErrorNone) - { - DOMX_DEBUG("\Error in Initializing Proxy"); - TIMM_OSAL_Free(pComponentPrivate->cCompName); - TIMM_OSAL_Free(pComponentPrivate); - } - - - EXIT: - return eError; -} diff --git a/domx/omx_proxy_component/omx_video_dec/Makefile b/domx/omx_proxy_component/omx_video_dec/Makefile deleted file mode 100755 index cbe5c56..0000000 --- a/domx/omx_proxy_component/omx_video_dec/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -# -# Copyright (C) Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ---------------------------------------------------------------------------- -# Revision History -# -# -# REF=ORG -# Original version. -# ---------------------------------------------------------------------------- - - - -include $(PROJROOT)/make/start.mk - -# Do not change above "include" line(s) - -# Arguments to tools, will move to make system once finalized. - -CFLAGS = -CDEFS = -ifeq ($(BUILD),udeb) -CDEFS += DEBUG -endif -CDEFS += - -EXEC_ARGS = -ST_LIB_ARGS = -SH_LIB_ARGS = - -# Define this macro if target runs in kernel mode -#__KERNEL__ = 1 - -# Target name and extension -# static library (ST_LIB): filename.a -# shared library soname (SH_LIB): filename.so.maj_ver.min_ver -# executable (EXEC) : filename.out - -TARGETNAME = libOMX.TI.DUCATI1.VIDEO.DECODER.so - - -# TARGETTYPE must be EXEC, ST_LIB or SH_LIB in upper case. - -TARGETTYPE = SH_LIB - -# install directory relative to the HOSTTARGET directory -HOSTRELEASE = lib - -# install directory relative to the root filesystem -ROOTFSRELEASE = lib - -# Folders in which gmake will run before building current target - -SUBMODULES = \ - -# Filename must not begin with '.', '/' or '\' - -SOURCES = \ -src/omx_proxy_videodec.c \ - - - -# Search path for include files - -INCLUDES = \ - $(PROJROOT)/omx_core/inc \ - $(PROJROOT)/mm_osal/inc \ - $(PROJROOT)/domx \ - $(PROJROOT)/domx/omx_rpc/inc \ - - -# Libraries needed for linking. - -ST_LIBS = -#mm_osal domx -SH_LIBS = domx omx_core mm_osal -#pthread rt utils procmgr ipc rcm notify -#SH_LIBS += sysmgr sysmemmgr - - -# Search path for library (and linker command) files. -# Current folder and target folder are included by default. - -LIBINCLUDES = $(PROJROOT)/mm_osal \ - $(PROJROOT)/domx \ - $(PROJROOT)/omx_core - - -# Do not change below "include" line(s) - -include $(PROJROOT)/make/build.mk diff --git a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c deleted file mode 100755 index 8ac4c9d..0000000 --- a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c +++ /dev/null @@ -1,797 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file omx_proxy_videodecoder.c - * This file contains methods that provides the functionality for - * the OpenMAX1.1 DOMX Framework Tunnel Proxy component. - ********************************************************************************************* - This is the proxy specific wrapper that passes the component name to the generic proxy init() - The proxy wrapper also does some runtime/static time onfig on per proxy basis - This is a thin wrapper that is called when componentiit() of the proxy is called - static OMX_ERRORTYPE PROXY_Wrapper_init(OMX_HANDLETYPE hComponent, OMX_PTR pAppData); - this layer gets called first whenever a proxy's get handle is called - ************************************************************************************************ - * @path WTSD_DucatiMMSW\omx\omx_il_1_x\omx_proxy_component\src - * - * @rev 1.0 - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 20-August-2010 Sarthak Aggarwal sarthak@ti.com: Initial Version - *================================================================*/ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -#include -#include -#include -#include "omx_proxy_common.h" -#include -#include "OMX_TI_IVCommon.h" -#include "OMX_TI_Video.h" -#include "OMX_TI_Index.h" - -#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY -#define LOG_TAG "OMXPROXYVIDEODEC" -#include -#include -#include -#endif - -#define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.DECODER" -/* needs to be specific for every configuration wrapper */ - -#ifdef USE_ENHANCED_PORTRECONFIG -//Define port indices in video decoder proxy -#define OMX_VIDEODECODER_INPUT_PORT 0 -#define OMX_VIDEODECODER_OUTPUT_PORT 1 -#endif - -#ifdef SET_STRIDE_PADDING_FROM_PROXY - -#define LINUX_PAGE_SIZE (4 * 1024) -#define TOTAL_DEC_PORTS 2 -#define HAL_NV12_PADDED_PIXEL_FORMAT (OMX_TI_COLOR_FormatYUV420PackedSemiPlanar - OMX_COLOR_FormatVendorStartUnused) - -static OMX_ERRORTYPE RPC_UTIL_SetStrideAndPadding(OMX_COMPONENTTYPE * hRemoteComp, PROXY_COMPONENT_PRIVATE * pCompPrv); - -OMX_ERRORTYPE PROXY_VIDDEC_SendCommand(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_COMMANDTYPE eCmd, - OMX_IN OMX_U32 nParam, OMX_IN OMX_PTR pCmdData); - -OMX_ERRORTYPE PROXY_VIDDEC_EventHandler(OMX_HANDLETYPE hComponent, - OMX_PTR pAppData, OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2, - OMX_PTR pEventData); - -#endif //SET_STRIDE_PADDING_FROM_PROXY - -OMX_ERRORTYPE PROXY_VIDDEC_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE * pIndexType); - -#ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES - -OMX_ERRORTYPE PROXY_VIDDEC_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct); - -OMX_ERRORTYPE PROXY_VIDDEC_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct); - -#endif - -#ifdef ANDROID_QUIRK_LOCK_BUFFER -#include -#include -#include "hal_public.h" - -OMX_ERRORTYPE PROXY_VIDDEC_FillThisBuffer(OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE * pBufferHdr); -OMX_ERRORTYPE PROXY_VIDDEC_FillBufferDone(OMX_HANDLETYPE hComponent, - OMX_U32 remoteBufHdr, OMX_U32 nfilledLen, OMX_U32 nOffset, OMX_U32 nFlags, - OMX_TICKS nTimeStamp, OMX_HANDLETYPE hMarkTargetComponent, - OMX_PTR pMarkData); - -#endif -extern OMX_ERRORTYPE PrearrageEmptyThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr); - -#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY -extern void DumpVideoFrame(DebugFrame_Dump *frameInfo); -#endif - -OMX_ERRORTYPE OMX_ProxyViddecInit(OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL; - pHandle = (OMX_COMPONENTTYPE *) hComponent; - - DOMX_ENTER(""); - - DOMX_DEBUG("Component name provided is %s", COMPONENT_NAME); - - pHandle->pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) - TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), TIMM_OSAL_TRUE, - 0, TIMMOSAL_MEM_SEGMENT_INT); - - PROXY_assert(pHandle->pComponentPrivate != NULL, - OMX_ErrorInsufficientResources, - "ERROR IN ALLOCATING PROXY COMPONENT PRIVATE STRUCTURE"); - - pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - - TIMM_OSAL_Memset(pComponentPrivate, 0, - sizeof(PROXY_COMPONENT_PRIVATE)); - - pComponentPrivate->cCompName = - TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8), - TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); - - PROXY_assert(pComponentPrivate->cCompName != NULL, - OMX_ErrorInsufficientResources, - " Error in Allocating space for proxy component table"); - - eError = OMX_ProxyViddecInit(hComponent); - -#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY - if (eError == OMX_ErrorNone) - { - char value[PROPERTY_VALUE_MAX]; - property_get("debug.video.dumpframe", value, "0:0"); - /* -ve value for fromFrame would disable this automatically */ - pComponentPrivate->debugframeInfo.fromFrame = atoi(strtok(value, ":")); - pComponentPrivate->debugframeInfo.toFrame = atoi(strtok(NULL, ":")); - pComponentPrivate->debugframeInfo.runningFrame = pComponentPrivate->debugframeInfo.fromFrame; - } -#endif - EXIT: - if (eError != OMX_ErrorNone) - { - DOMX_DEBUG("Error in Initializing Proxy"); - if (pComponentPrivate->cCompName != NULL) - { - TIMM_OSAL_Free(pComponentPrivate->cCompName); - pComponentPrivate->cCompName = NULL; - } - if (pComponentPrivate != NULL) - { - TIMM_OSAL_Free(pComponentPrivate); - pComponentPrivate = NULL; - } - } - return eError; -} - -OMX_ERRORTYPE OMX_ProxyViddecInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL; - pHandle = (OMX_COMPONENTTYPE *) hComponent; - OMX_TI_PARAM_ENHANCEDPORTRECONFIG tParamStruct; - -#ifdef ANDROID_QUIRK_LOCK_BUFFER - OMX_U32 err; - hw_module_t const* module; -#endif - DOMX_ENTER(""); - - DOMX_DEBUG("Component name provided is %s", COMPONENT_NAME); - - pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - - // Copying component Name - this will be picked up in the proxy common - PROXY_assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH, - OMX_ErrorInvalidComponentName, - "Length of component name is longer than the max allowed"); - TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, - strlen(COMPONENT_NAME) + 1); - - eError = OMX_ProxyCommonInit(hComponent); // Calling Proxy Common Init() - PROXY_assert(eError == OMX_ErrorNone, eError, "Proxy common init returned error"); -#ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES - pHandle->SetParameter = PROXY_VIDDEC_SetParameter; - pHandle->GetParameter = PROXY_VIDDEC_GetParameter; -#endif - pHandle->GetExtensionIndex = PROXY_VIDDEC_GetExtensionIndex; - -#ifdef SET_STRIDE_PADDING_FROM_PROXY - pHandle->SendCommand = PROXY_VIDDEC_SendCommand; - pComponentPrivate->proxyEventHandler = PROXY_VIDDEC_EventHandler; - pComponentPrivate->IsLoadedState = OMX_TRUE; -#endif - -#ifdef ANDROID_QUIRK_LOCK_BUFFER - pComponentPrivate->proxyFillBufferDone = PROXY_VIDDEC_FillBufferDone; - pHandle->FillThisBuffer = PROXY_VIDDEC_FillThisBuffer; - - err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); - if (err == 0) - { - pComponentPrivate->grallocModule = (gralloc_module_t const *)module; - } - else - { - DOMX_ERROR("FATAL: gralloc api hw_get_module() returned error: Can't find \ - %s module err = %x", GRALLOC_HARDWARE_MODULE_ID, err); - eError = OMX_ErrorInsufficientResources; - return eError; - } -#endif - -#ifdef USE_ENHANCED_PORTRECONFIG - /*Initializing Structure */ - tParamStruct.nSize = sizeof(OMX_TI_PARAM_ENHANCEDPORTRECONFIG); - tParamStruct.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - tParamStruct.nVersion.s.nVersionMinor = OMX_VER_MINOR; - tParamStruct.nVersion.s.nRevision = 0x0; - tParamStruct.nVersion.s.nStep = 0x0; - tParamStruct.nPortIndex = OMX_VIDEODECODER_OUTPUT_PORT; - tParamStruct.bUsePortReconfigForCrop = OMX_TRUE; - tParamStruct.bUsePortReconfigForPadding = OMX_TRUE; - - eError = PROXY_SetParameter(hComponent,(OMX_INDEXTYPE)OMX_TI_IndexParamUseEnhancedPortReconfig, - &tParamStruct); - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in Proxy SetParameter for Enhanced port reconfig usage"); -#endif - /* This is required to handle WMV/VC-1 content */ - pHandle->EmptyThisBuffer = PrearrageEmptyThisBuffer; - - EXIT: - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_VIDDEC_GetExtensionIndex() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_VIDDEC_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE * pIndexType) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - - PROXY_require((hComp->pComponentPrivate != NULL), OMX_ErrorBadParameter, NULL); - PROXY_require(cParameterName != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(pIndexType != NULL, OMX_ErrorBadParameter, NULL); - - DOMX_ENTER("hComponent = %p, cParameterName = %p", hComponent, cParameterName); - -#ifdef ENABLE_GRALLOC_BUFFERS - // Ensure that String length is not greater than Max allowed length - PROXY_require(strlen(cParameterName) <= 127, OMX_ErrorBadParameter, NULL); - - if (strcmp(cParameterName, "OMX.google.android.index.getAndroidNativeBufferUsage") == 0) - { - *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexAndroidNativeBufferUsage; - } - else - { - eError = PROXY_GetExtensionIndex(hComponent, cParameterName, pIndexType); - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in PROXY_GetExtensionIndex"); - } -#else - eError = PROXY_GetExtensionIndex(hComponent, cParameterName, pIndexType); - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in PROXY_GetExtensionIndex"); -#endif - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -#ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES - -/* ===========================================================================*/ -/** - * @name PROXY_GetParameter() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_VIDDEC_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_PARAM_PORTDEFINITIONTYPE* pPortDef = NULL; - OMX_VIDEO_PARAM_PORTFORMATTYPE* pPortParam = NULL; - OMX_TI_PARAMNATIVEBUFFERUSAGE *pUsage = NULL; - - PROXY_require((pParamStruct != NULL), OMX_ErrorBadParameter, NULL); - PROXY_assert((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nParamIndex = %d, pParamStruct = %p", - hComponent, pCompPrv, nParamIndex, pParamStruct); - -#ifdef ENABLE_GRALLOC_BUFFERS - if( nParamIndex == OMX_TI_IndexAndroidNativeBufferUsage) - { - pUsage = (OMX_TI_PARAMNATIVEBUFFERUSAGE*)pParamStruct; - if(pCompPrv->proxyPortBuffers[pUsage->nPortIndex].proxyBufferType == GrallocPointers) - { - PROXY_CHK_VERSION(pParamStruct, OMX_TI_PARAMNATIVEBUFFERUSAGE); - pUsage->nUsage = GRALLOC_USAGE_HW_RENDER; -#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY - pUsage->nUsage |= GRALLOC_USAGE_SW_READ_RARELY; -#endif - goto EXIT; - } - } -#endif - eError = PROXY_GetParameter(hComponent,nParamIndex, pParamStruct); - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in Proxy GetParameter"); - - if( nParamIndex == OMX_IndexParamPortDefinition) - { - PROXY_CHK_VERSION(pParamStruct, OMX_PARAM_PORTDEFINITIONTYPE); - pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; - if(pPortDef->format.video.eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar) - { - if(pCompPrv->proxyPortBuffers[pPortDef->nPortIndex].proxyBufferType == GrallocPointers) - { - pPortDef->format.video.eColorFormat = HAL_NV12_PADDED_PIXEL_FORMAT; - } - else - { - pPortDef->format.video.eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar; - } - } - } - else if ( nParamIndex == OMX_IndexParamVideoPortFormat) - { - PROXY_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE); - pPortParam = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct; - if(pPortParam->eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar) - { - if(pCompPrv->proxyPortBuffers[pPortParam->nPortIndex].proxyBufferType == GrallocPointers) - { - pPortParam->eColorFormat = HAL_NV12_PADDED_PIXEL_FORMAT; - } - else - { - pPortParam->eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar; - } - } - } - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_SetParameter() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_VIDDEC_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, OMX_IN OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_PARAM_PORTDEFINITIONTYPE* pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; - OMX_VIDEO_PARAM_PORTFORMATTYPE* pPortParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct; - - PROXY_require((pParamStruct != NULL), OMX_ErrorBadParameter, NULL); - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, nParamIndex = %d, pParamStruct = %p", - hComponent, pCompPrv, nParamIndex, pParamStruct); - if(nParamIndex == OMX_IndexParamPortDefinition) - { - if(pPortDef->format.video.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar - || pPortDef->format.video.eColorFormat == HAL_NV12_PADDED_PIXEL_FORMAT) - { - pPortDef->format.video.eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - } - } - else if(nParamIndex == OMX_IndexParamVideoPortFormat) - { - if(pPortParams->eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar - || pPortParams->eColorFormat == HAL_NV12_PADDED_PIXEL_FORMAT) - { - pPortParams->eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - } - } - - eError = PROXY_SetParameter(hComponent, nParamIndex, pParamStruct); - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in Proxy SetParameter"); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -#endif - -#ifdef SET_STRIDE_PADDING_FROM_PROXY -/* ===========================================================================*/ -/** - * @name PROXY_VIDDEC_SendCommand() - * @brief - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_VIDDEC_SendCommand(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_COMMANDTYPE eCmd, - OMX_IN OMX_U32 nParam, OMX_IN OMX_PTR pCmdData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - DOMX_ENTER - ("hComponent = %p, pCompPrv = %p, eCmd = %d, nParam = %d, pCmdData = %p", - hComponent, pCompPrv, eCmd, nParam, pCmdData); - - if(eCmd == OMX_CommandStateSet) - { - //Set appropriate stride before Loaded to Idle transition. - if((OMX_STATETYPE)nParam == OMX_StateIdle && pCompPrv->IsLoadedState == OMX_TRUE) - { - eError = RPC_UTIL_SetStrideAndPadding(hComponent, pCompPrv); - PROXY_require(eError == OMX_ErrorNone, eError, - "Stride and padding setting from proxy returned"); - pCompPrv->IsLoadedState = OMX_FALSE; - } - } - else if(eCmd == OMX_CommandPortEnable) - { - if(nParam == OMX_ALL || nParam == OMX_VIDEODECODER_OUTPUT_PORT) - { - eError = RPC_UTIL_SetStrideAndPadding(hComponent, pCompPrv); - PROXY_require(eError == OMX_ErrorNone, eError, - "Stride and padding setting from proxy returned"); - } - } - - eError = - PROXY_SendCommand(hComponent, eCmd, nParam, pCmdData); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_EventHandler() - * @brief - * @param void - * @return OMX_ErrorNone = Successful - * @sa TBD - * - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_VIDDEC_EventHandler(OMX_HANDLETYPE hComponent, - OMX_PTR pAppData, OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2, - OMX_PTR pEventData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, - "This is fatal error, processing cant proceed - please debug"); - - DOMX_ENTER - ("hComponent=%p, pCompPrv=%p, eEvent=%p, nData1=%p, nData2=%p, pEventData=%p", - hComponent, pCompPrv, eEvent, nData1, nData2, pEventData); - - if((eEvent == OMX_EventCmdComplete) && ((OMX_COMMANDTYPE)nData1 == OMX_CommandStateSet)) - { - if((OMX_STATETYPE)nData2 == OMX_StateLoaded) - { - pCompPrv->IsLoadedState = OMX_TRUE; - } - } - eError = PROXY_EventHandler(hComponent, pAppData, eEvent, nData1, nData2, pEventData); - - EXIT: - return eError; -} - -/* ===========================================================================*/ -/** - * @name RPC_UTIL_RPC_UTIL_SetStrideAndPadding() - * @brief Gets stride on this port. Used to set stride on OMX to tell whether buffer is 1D or 2D - * @param hRemoteComp [IN] : Remote component handle. - * @return OMX_ErrorNone = Successful - */ -/* ===========================================================================*/ -OMX_ERRORTYPE RPC_UTIL_SetStrideAndPadding(OMX_COMPONENTTYPE * hComponent,PROXY_COMPONENT_PRIVATE * pCompPrv) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_PARAM_PORTDEFINITIONTYPE sPortDef; - OMX_CONFIG_RECTTYPE tParamStruct; - OMX_U32 nPortIndex = 0; - - for(nPortIndex=0; nPortIndex < TOTAL_DEC_PORTS ;nPortIndex++ ) - { - /*Initializing Structure */ - sPortDef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); - sPortDef.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - sPortDef.nVersion.s.nVersionMinor = OMX_VER_MINOR; - sPortDef.nVersion.s.nRevision = 0x0; - sPortDef.nVersion.s.nStep = 0x0; - sPortDef.nPortIndex = nPortIndex; - - eError = PROXY_GetParameter(hComponent,OMX_IndexParamPortDefinition, - &sPortDef); - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in Proxy GetParameter for Port Def"); - - if (sPortDef.eDomain == OMX_PortDomainVideo && sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingUnused) - { - if(pCompPrv->proxyPortBuffers[nPortIndex].IsBuffer2D == OMX_TRUE) - { - sPortDef.format.video.nStride = LINUX_PAGE_SIZE; - } - else - { - tParamStruct.nSize = sizeof(OMX_CONFIG_RECTTYPE); - tParamStruct.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - tParamStruct.nVersion.s.nVersionMinor = OMX_VER_MINOR; - tParamStruct.nVersion.s.nRevision = 0x0; - tParamStruct.nVersion.s.nStep = 0x0; - tParamStruct.nPortIndex = nPortIndex; - - eError = PROXY_GetParameter(hComponent,(OMX_INDEXTYPE)OMX_TI_IndexParam2DBufferAllocDimension, - &tParamStruct); - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in Proxy GetParameter for 2D index"); - - sPortDef.format.video.nStride = tParamStruct.nWidth; - } - eError = PROXY_SetParameter(hComponent,OMX_IndexParamPortDefinition, - &sPortDef); - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in Proxy SetParameter for Port Def"); - } - } - - EXIT: - return eError; -} - -#endif - -#ifdef ANDROID_QUIRK_LOCK_BUFFER -/* ===========================================================================*/ -/** - * @name PROXY_VIDDEC_FillThisBuffer() - * @brief Gets stride on this port. Used to set stride on OMX to tell whether buffer is 1D or 2D - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_VIDDEC_FillThisBuffer(OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_U32 count = 0; - IMG_native_handle_t* grallocHandle; - OMX_PARAM_PORTDEFINITIONTYPE sPortDef; - - PROXY_require(pBufferHdr != NULL, OMX_ErrorBadParameter, NULL); - PROXY_require(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, - NULL); - PROXY_CHK_VERSION(pBufferHdr, OMX_BUFFERHEADERTYPE); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - if(pCompPrv->proxyPortBuffers[OMX_VIDEODECODER_OUTPUT_PORT].proxyBufferType - == GrallocPointers) - { - /* Lock the Gralloc buffer till it gets rendered completely */ - /* Extract the Gralloc handle from the Header and then call lock on that */ - /* Note# There is no error check for the pBufferHdr here*/ - grallocHandle = (IMG_native_handle_t*)pBufferHdr->pBuffer; - - /*Initializing Structure */ - sPortDef.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); - sPortDef.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - sPortDef.nVersion.s.nVersionMinor = OMX_VER_MINOR; - sPortDef.nVersion.s.nRevision = 0x0; - sPortDef.nVersion.s.nStep = 0x0; - sPortDef.nPortIndex = OMX_VIDEODECODER_INPUT_PORT; - eError = PROXY_GetParameter(hComponent,OMX_IndexParamPortDefinition, - &sPortDef); - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in Proxy GetParameter for Port Def"); - -#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY - /* Get the Video frame crop window */ - OMX_CONFIG_RECTTYPE rect; - rect.nSize = sizeof(rect); - rect.nVersion.s.nVersionMajor = OMX_VER_MAJOR; - rect.nVersion.s.nVersionMinor = OMX_VER_MINOR; - rect.nVersion.s.nRevision = 0x0; - rect.nVersion.s.nStep = 0x0; - rect.nPortIndex = OMX_VIDEODECODER_OUTPUT_PORT; - - eError = PROXY_GetConfig(hComponent, OMX_IndexConfigCommonOutputCrop, &rect); - - PROXY_assert(eError == OMX_ErrorNone, - eError," Error while getting output crop"); - pCompPrv->debugframeInfo.frame_width = rect.nWidth; - pCompPrv->debugframeInfo.frame_height = rect.nHeight; - pCompPrv->debugframeInfo.frame_xoffset = rect.nLeft; - pCompPrv->debugframeInfo.frame_yoffset = rect.nTop; -#endif - pCompPrv->grallocModule->lock((gralloc_module_t const *) pCompPrv->grallocModule, - (buffer_handle_t)grallocHandle, GRALLOC_USAGE_HW_RENDER, - 0,0,sPortDef.format.video.nFrameWidth, sPortDef.format.video.nFrameHeight,NULL); - } - - eRPCError = PROXY_FillThisBuffer(hComponent, pBufferHdr); - - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in Proxy SetParameter for Port Def"); - - EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -/* ===========================================================================*/ -/** - * @name PROXY_VIDDEC_FillBufferDone() - * @brief Gets stride on this port. Used to set stride on OMX to tell whether buffer is 1D or 2D - */ -/* ===========================================================================*/ -OMX_ERRORTYPE PROXY_VIDDEC_FillBufferDone(OMX_HANDLETYPE hComponent, - OMX_U32 remoteBufHdr, OMX_U32 nfilledLen, OMX_U32 nOffset, OMX_U32 nFlags, - OMX_TICKS nTimeStamp, OMX_HANDLETYPE hMarkTargetComponent, - OMX_PTR pMarkData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone; - RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_U32 count = 0; - IMG_native_handle_t* grallocHandle; - - PROXY_require((hComp->pComponentPrivate != NULL), - OMX_ErrorBadParameter, - "This is fatal error, processing cant proceed - please debug"); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - - /* Lock the Gralloc buffer till it gets rendered completely */ - /* Extract the Gralloc handle from the Header and then call lock on that */ - /* Note# There is no error check for the pBufferHdr here*/ - - if(pCompPrv->proxyPortBuffers[OMX_VIDEODECODER_OUTPUT_PORT].proxyBufferType - == GrallocPointers) { - for (count = 0; count < pCompPrv->nTotalBuffers; ++count) - { - if (pCompPrv->tBufList[count].pBufHeaderRemote == remoteBufHdr) - { - grallocHandle = (IMG_native_handle_t*)(pCompPrv->tBufList[count].pBufHeader)->pBuffer; - break; - } - } - - PROXY_assert((count != pCompPrv->nTotalBuffers), - OMX_ErrorBadParameter, - "Received invalid-buffer header from OMX component"); - pCompPrv->grallocModule->unlock((gralloc_module_t const *) pCompPrv->grallocModule, (buffer_handle_t)grallocHandle); - -#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY - ALOGV("frm[%u] to[%u] run[%u]", pCompPrv->debugframeInfo.fromFrame, pCompPrv->debugframeInfo.toFrame, pCompPrv->debugframeInfo.runningFrame); - /* Fill buffer Done successed, hence start dumping if requested */ - OMX_BUFFERHEADERTYPE *pBufHdr = pCompPrv->tBufList[count].pBufHeader; - if ((pCompPrv->debugframeInfo.fromFrame == 0) && (pCompPrv->debugframeInfo.runningFrame <= pCompPrv->debugframeInfo.toFrame)) - { - /* Lock the buffer for SW read usage and then access it */ - pCompPrv->grallocModule->lock((gralloc_module_t const*) pCompPrv->grallocModule, - (buffer_handle_t)grallocHandle, - GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_SW_READ_RARELY, - pCompPrv->debugframeInfo.frame_xoffset, - pCompPrv->debugframeInfo.frame_yoffset, - pCompPrv->debugframeInfo.frame_width, - pCompPrv->debugframeInfo.frame_height, - (void*)pCompPrv->debugframeInfo.y_uv); - - DumpVideoFrame(&pCompPrv->debugframeInfo); - - pCompPrv->grallocModule->unlock((gralloc_module_t const *) pCompPrv->grallocModule, - (buffer_handle_t)grallocHandle); - pCompPrv->debugframeInfo.runningFrame++; - } - else if (pCompPrv->debugframeInfo.fromFrame > 0) - { - pCompPrv->debugframeInfo.fromFrame--; - } -#endif - } - - eRPCError = PROXY_FillBufferDone(hComponent,remoteBufHdr, nfilledLen, nOffset, nFlags, - nTimeStamp, hMarkTargetComponent, pMarkData); - - PROXY_assert(eError == OMX_ErrorNone, - eError," Error in PROXY FillBufferDone for Port Def"); - -EXIT: - DOMX_EXIT("eError: %d", eError); - return eError; -} - -#endif - diff --git a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c deleted file mode 100644 index 473a7f0..0000000 --- a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_secure.c +++ /dev/null @@ -1,157 +0,0 @@ -#include -#include -#include -#include "omx_proxy_common.h" -#include -#include -#include -#include -#include - -#define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.DECODER.secure" - -extern OMX_U32 DUCATI_IN_SECURE_MODE; -extern OMX_U32 SECURE_COMPONENTS_RUNNING; - -extern OMX_ERRORTYPE OMX_ProxyViddecInit(OMX_HANDLETYPE hComponent); -OMX_ERRORTYPE PROXY_VIDDEC_Secure_ComponentDeInit(OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL; - const OMX_U8 enable = 1, disable = 0; - OMX_U8 mode; - int ret; - - pHandle = (OMX_COMPONENTTYPE *) hComponent; - - DOMX_ENTER(""); - - DOMX_DEBUG("Component name provided is %s", COMPONENT_NAME); - - pHandle->pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) - TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), TIMM_OSAL_TRUE, - 0, TIMMOSAL_MEM_SEGMENT_INT); - - PROXY_assert(pHandle->pComponentPrivate != NULL, - OMX_ErrorInsufficientResources, - "ERROR IN ALLOCATING PROXY COMPONENT PRIVATE STRUCTURE"); - - pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - - TIMM_OSAL_Memset(pComponentPrivate, 0, - sizeof(PROXY_COMPONENT_PRIVATE)); - - pComponentPrivate->cCompName = - TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8), - TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); - - PROXY_assert(pComponentPrivate->cCompName != NULL, - OMX_ErrorInsufficientResources, - " Error in Allocating space for proxy component table"); - - // Copying component Name - this will be picked up in the proxy common - PROXY_assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH, - OMX_ErrorInvalidComponentName, - "Length of component name is longer than the max allowed"); - TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME, - strlen(COMPONENT_NAME) + 1); - - pComponentPrivate->secure_misc_drv_fd = open("/dev/rproc_user", O_SYNC | O_RDWR); - if (pComponentPrivate->secure_misc_drv_fd < 0) - { - DOMX_ERROR("Can't open rproc_user device 0x%x\n", errno); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - - ret = write(pComponentPrivate->secure_misc_drv_fd, &enable, sizeof(enable)); - if(ret != 1) - { - DOMX_ERROR("errno from setting secure mode = %x",errno); - ret = write(pComponentPrivate->secure_misc_drv_fd, &disable, sizeof(disable)); - if (ret < 0) - { - DOMX_ERROR("Setting unsecure mode failed"); - } - - ret = close(pComponentPrivate->secure_misc_drv_fd); - if (ret < 0) - { - DOMX_ERROR("Can't close the driver"); - } - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - - ret = read(pComponentPrivate->secure_misc_drv_fd, &mode, sizeof(mode)); - PROXY_assert(mode == enable, OMX_ErrorUndefined,"ERROR: We are not in secure mode"); - DOMX_DEBUG("secure mode recieved from Misc driver for secure playback = 0x%x\n", mode); - - eError = OMX_ProxyViddecInit(hComponent); - pHandle->ComponentDeInit = PROXY_VIDDEC_Secure_ComponentDeInit; - -#ifdef USE_ION - pComponentPrivate->bUseIon = OMX_TRUE; - pComponentPrivate->bMapIonBuffers = OMX_FALSE; -#endif - EXIT: - if (eError != OMX_ErrorNone) - { - DOMX_DEBUG("Error in Initializing Proxy"); - if (pComponentPrivate->cCompName != NULL) - { - TIMM_OSAL_Free(pComponentPrivate->cCompName); - pComponentPrivate->cCompName = NULL; - } - if (pComponentPrivate != NULL) - { - TIMM_OSAL_Free(pComponentPrivate); - pComponentPrivate = NULL; - } - } - return eError; -} - -OMX_ERRORTYPE PROXY_VIDDEC_Secure_ComponentDeInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - PROXY_COMPONENT_PRIVATE *pComponentPrivate = NULL; - int ret; - const OMX_U8 disable = 0; - int secure_misc_drv_fd; - - pHandle = (OMX_COMPONENTTYPE *) hComponent; - - pComponentPrivate = - (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; - - secure_misc_drv_fd = pComponentPrivate->secure_misc_drv_fd; - - eError = PROXY_ComponentDeInit(hComponent); - if(eError != OMX_ErrorNone) - { - DOMX_ERROR("Proxy common deinit returned error = %x",eError); - } - pComponentPrivate = NULL; - - ret = write(secure_misc_drv_fd, &disable, sizeof(disable)); - if (ret < 0) - { - DOMX_ERROR("Setting unsecure mode failed"); - } - - ret = close(secure_misc_drv_fd); - if (ret < 0) - { - DOMX_ERROR("Can't close the driver"); - } - - return eError; -} - diff --git a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_utils.c b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_utils.c deleted file mode 100755 index 53922fd..0000000 --- a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec_utils.c +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/*============================================================== - *! Revision History - *! ============================ - *! 21-Oct-2011 Rajesh vandanapu sarthav@ti.com: Initial Version - *================================================================*/ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -#include -#include -#include -#include "omx_proxy_common.h" -#include -#include "OMX_TI_IVCommon.h" -#include "OMX_TI_Video.h" -#include "OMX_TI_Index.h" - -#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY -#define LOG_TAG "OMXPROXYVIDEODEC" -#include -#include -#include -#include -#include -#endif - -#define COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.DECODER" -/* needs to be specific for every configuration wrapper */ - -/* DEFINITIONS for parsing the config information & sequence header for WMV*/ -#define VIDDEC_GetUnalignedDword( pb, dw ) \ - (dw) = ((OMX_U32) *(pb + 3) << 24) + \ - ((OMX_U32) *(pb + 2) << 16) + \ - ((OMX_U16) *(pb + 1) << 8) + *pb; - -#define VIDDEC_GetUnalignedDwordEx( pb, dw ) VIDDEC_GetUnalignedDword( pb, dw ); (pb) += sizeof(OMX_U32); -#define VIDDEC_LoadDWORD( dw, p ) VIDDEC_GetUnalignedDwordEx( p, dw ) -#define VIDDEC_MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((OMX_U32)(OMX_U8)(ch0) | ((OMX_U32)(OMX_U8)(ch1) << 8) | \ - ((OMX_U32)(OMX_U8)(ch2) << 16) | ((OMX_U32)(OMX_U8)(ch3) << 24 )) - -#define VIDDEC_FOURCC(ch0, ch1, ch2, ch3) VIDDEC_MAKEFOURCC(ch0, ch1, ch2, ch3) - -#define FOURCC_WMV3 VIDDEC_FOURCC('W','M','V','3') -#define FOURCC_WMV2 VIDDEC_FOURCC('W','M','V','2') -#define FOURCC_WMV1 VIDDEC_FOURCC('W','M','V','1') -#define FOURCC_WVC1 VIDDEC_FOURCC('W','V','C','1') - -#define CSD_POSITION 51 /*Codec Specific Data position on the "stream propierties object"(ASF spec)*/ - -typedef struct VIDDEC_WMV_RCV_struct { - OMX_U32 nNumFrames : 24; - OMX_U32 nFrameType : 8; - OMX_U32 nID : 32; - OMX_U32 nStructData : 32; //STRUCT_C - OMX_U32 nVertSize; //STRUCT_A-1 - OMX_U32 nHorizSize; //STRUCT_A-2 - OMX_U32 nID2 : 32; - OMX_U32 nSequenceHdr : 32; //STRUCT_B -} VIDDEC_WMV_RCV_struct; - -typedef struct VIDDEC_WMV_VC1_struct { - OMX_U32 nNumFrames : 24; - OMX_U32 nFrameType : 8; - OMX_U32 nID : 32; - OMX_U32 nStructData : 32; //STRUCT_C - OMX_U32 nVertSize; //STRUCT_A-1 - OMX_U32 nHorizSize; //STRUCT_A-2 - OMX_U32 nID2 : 32; - OMX_U32 nSequenceHdr : 32; //STRUCT_B -} VIDDEC_WMV_VC1_struct; - - -OMX_ERRORTYPE PrearrageEmptyThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * pBufferHdr) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - PROXY_COMPONENT_PRIVATE *pCompPrv = NULL; - OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent; - OMX_U8* pBuffer = NULL; - OMX_U8* pData = NULL; - OMX_U32 nValue = 0; - OMX_U32 nWidth = 0; - OMX_U32 nHeight = 0; - OMX_U32 nActualCompression = 0; - OMX_U8* pCSD = NULL; - OMX_U32 nSize_CSD = 0; - DOMX_ENTER(""); - - PROXY_assert(pBufferHdr != NULL, OMX_ErrorBadParameter, NULL); - - if (pBufferHdr->nFlags & OMX_BUFFERFLAG_CODECCONFIG){ - PROXY_assert(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, NULL); - - pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate; - /* Get component role */ - OMX_PARAM_COMPONENTROLETYPE compRole; - compRole.nSize = sizeof(OMX_PARAM_COMPONENTROLETYPE); - compRole.nVersion.s.nVersionMajor = 1; - compRole.nVersion.s.nVersionMinor = 1; //Ducati OMX version - compRole.nVersion.s.nRevision = 0; - compRole.nVersion.s.nStep = 0; - - eError = PROXY_GetParameter(hComp, OMX_IndexParamStandardComponentRole, &compRole); - if(eError != OMX_ErrorNone){ - DOMX_ERROR("Error getting OMX_IndexParamStandardComponentRole"); - } - - if(!strcmp((char *)(compRole.cRole), "video_decoder.wmv")){ - pBuffer = pBufferHdr->pBuffer; - - VIDDEC_WMV_RCV_struct sStructRCV; - - DOMX_DEBUG("nFlags: %x", pBufferHdr->nFlags); - - pData = pBufferHdr->pBuffer + 15; /*Position to Width & Height*/ - VIDDEC_LoadDWORD(nValue, pData); - nWidth = nValue; - VIDDEC_LoadDWORD(nValue, pData); - nHeight = nValue; - - pData += 4; /*Position to compression type*/ - VIDDEC_LoadDWORD(nValue, pData); - nActualCompression = nValue; - - /*Seting pCSD to proper position*/ - pCSD = pBufferHdr->pBuffer; - pCSD += CSD_POSITION; - nSize_CSD = pBufferHdr->nFilledLen - CSD_POSITION; - - if(nActualCompression == FOURCC_WMV3){ - - //From VC-1 spec: Table 265: Sequence Layer Data Structure - sStructRCV.nNumFrames = 0xFFFFFF; /*Infinite frame number*/ - sStructRCV.nFrameType = 0xc5; /*0x85 is the value given by ASF to rcv converter*/ - sStructRCV.nID = 0x04; /*WMV3*/ - sStructRCV.nStructData = 0x018a3106; /*0x06318a01zero fill 0x018a3106*/ - sStructRCV.nVertSize = nHeight; - sStructRCV.nHorizSize = nWidth; - sStructRCV.nID2 = 0x0c; /* Fix value */ - sStructRCV.nSequenceHdr = 0x00002a9f; /* This value is not provided by parser, so giving a value from a video*/ - - DOMX_DEBUG("initial: nStructData: %x", sStructRCV.nStructData); - DOMX_DEBUG("pCSD = %x", (OMX_U32)*pCSD); - - sStructRCV.nStructData = (OMX_U32)pCSD[0] << 0 | - pCSD[1] << 8 | - pCSD[2] << 16 | - pCSD[3] << 24; - - DOMX_DEBUG("FINAL: nStructData: %x", sStructRCV.nStructData); - - //Copy RCV structure to actual buffer - assert(pBufferHdr->nFilledLen < pBufferHdr->nAllocLen); - pBufferHdr->nFilledLen = sizeof(VIDDEC_WMV_RCV_struct); - TIMM_OSAL_Memcpy(pBufferHdr->pBuffer, (OMX_U8*)(&sStructRCV), - pBufferHdr->nFilledLen); - - } - else if (nActualCompression == FOURCC_WVC1){ - DOMX_DEBUG("VC-1 Advance Profile prearrange"); - pBufferHdr->nOffset = pBufferHdr->nOffset+52; - pBufferHdr->nFilledLen= pBufferHdr->nFilledLen-52; - } - } - } - - EXIT: - DOMX_EXIT("eError: %d", eError); - - return PROXY_EmptyThisBuffer(hComponent, pBufferHdr); -} - -#ifdef ENABLE_RAW_BUFFERS_DUMP_UTILITY -/** -* Usage# -* By default this feature is kept disabled to avoid security leaks. -* -* (1) Uncomment the below 2 lines from Android.mk -* #LOCAL_CFLAGS += -DENABLE_RAW_BUFFERS_DUMP_UTILITY -* #LOCAL_SHARED_LIBRARIES += libcutils -* And rebuild the omx proxy common component -* -* (2) Before start playback, make sure that "data" folder has r/w -* permissions. For this, execute the below -* mount -o rw,remount -t ext3 /dev/block/mmcblk0p1 /data/ -* chmod 777 /data/ -* -* (3) Set the property for number of frames to dump -* eg: setprop debug.video.dumpframe 10:20 -* would dump frames from 10 to 20. -* -* (4) Pull the frames to PC over adb -* adb pull /data/frame_10.txt -* -* (5) Analyse on PC tools. -*/ - -/* -* Method to convert NV12 to YUV420p for PC analysis -*/ -static void convertNV12ToYuv420(DebugFrame_Dump *frameInfo, void *dst) -{ - int stride = 4096; /* ARM Page size = 4k */ - uint32_t ybuf_offset = frameInfo->frame_yoffset * stride + frameInfo->frame_xoffset; - uint8_t* p1y = (uint8_t*)frameInfo->y_uv[0] + ybuf_offset; - uint8_t* p2y = (uint8_t*) dst; - int i, j, j1; - int width = frameInfo->frame_width; - int height = frameInfo->frame_height; - - LOGD("Coverting NV-12 to YUV420p Width[%d], Height[%d] and Stride[%d] offset[%d]", - width, height, stride, ybuf_offset); - - /* copy y-buffer, almost bytewise copy, except for stride jumps.*/ - for(i=0;iframe_xoffset + - (frameInfo->frame_yoffset * stride)/2; - - const uint8_t* p1uv = (uint8_t*)frameInfo->y_uv[1] + UV_offset; - - uint8_t* p2u = ((uint8_t*) dst + (width * height)); - uint8_t* p2v = ((uint8_t*) p2u + ((width/2) * (height/2))); - for(i=0;(i < height/2);i++) - { - for(j=0,j1=0;(j< width/2);j++,j1+=2) - { - p2u[j] = p1uv[j1]; - p2v[j] = p1uv[j1+1]; - } - p1uv+=stride; - p2u+=width/2; - p2v+=width/2; - } -} - -void DumpVideoFrame(DebugFrame_Dump *frameInfo) -{ - /* First convert the frame to 420p and then write to SD Card */ - OMX_U32 framesize = (frameInfo->frame_width * - frameInfo->frame_height * 3) / 2; - OMX_U8* localbuffer = malloc(framesize); - if (localbuffer == NULL) - { - LOGE("NO HEAP"); - goto EXIT; - } - convertNV12ToYuv420(frameInfo, localbuffer); - int filedes = -1; - char framenumber[100]; - sprintf(framenumber, "/data/frame_%ld.txt", frameInfo->runningFrame); - LOGD("file path %s",framenumber); - filedes = open(framenumber, O_CREAT | O_WRONLY | O_SYNC | O_TRUNC, 0777); - if(filedes < 0) - { - LOGE("\n!!!!!!!!!Error in file open!!!!!!!! [%d][%s]\n", filedes, strerror(errno)); - goto EXIT; - } - int ret = write (filedes, (void*)localbuffer, framesize); - if (ret < (int)framesize) - { - LOGE("File Write Failed"); - } -EXIT: - if (localbuffer) - { - free(localbuffer); - localbuffer = NULL; - } - if (filedes > 0) - { - close(filedes); - } -} - -#endif diff --git a/domx/test/Makefile b/domx/test/Makefile deleted file mode 100644 index 78c6f31..0000000 --- a/domx/test/Makefile +++ /dev/null @@ -1,95 +0,0 @@ -# -# Copyright (C) Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ---------------------------------------------------------------------------- -# Revision History -# -# -# REF=ORG -# Original version. -# ---------------------------------------------------------------------------- - - - -include $(PROJROOT)/make/start.mk - -# Do not change above "include" line(s) - -# Arguments to tools, will move to make system once finalized. - -CFLAGS = -CDEFS = -ifeq ($(BUILD),udeb) -CDEFS += DEBUG -endif -CDEFS += - -EXEC_ARGS = -ST_LIB_ARGS = -SH_LIB_ARGS = - -# Define this macro if target runs in kernel mode -#__KERNEL__ = 1 - -# Target name and extension -# static library (ST_LIB): filename.a -# shared library soname (SH_LIB): filename.so.maj_ver.min_ver -# executable (EXEC) : filename.out - -TARGETNAME = - - -# TARGETTYPE must be EXEC, ST_LIB or SH_LIB in upper case. - -TARGETTYPE = - -# install directory relative to the HOSTTARGET directory -HOSTRELEASE = - -# install directory relative to the root filesystem -ROOTFSRELEASE = - -# Folders in which gmake will run before building current target - -SUBMODULES = sample_proxy \ - -# Filename must not begin with '.', '/' or '\' - -SOURCES = \ - - - - -# Search path for include files - -INCLUDES = - -# Libraries needed for linking. - -#ST_LIBS = omx_core omx_proxy_component mmplatform mm_osal domx -#SH_LIBS = pthread rt utils procmgr ipc rcm notify -#SH_LIBS += sysmgr sysmemmgr - - -# Search path for library (and linker command) files. -# Current folder and target folder are included by default. - -LIBINCLUDES = $(PROJROOT)/target/lib - - -# Do not change below "include" line(s) - -include $(PROJROOT)/make/build.mk - diff --git a/domx/test/sample_proxy/Makefile b/domx/test/sample_proxy/Makefile deleted file mode 100644 index 02a3619..0000000 --- a/domx/test/sample_proxy/Makefile +++ /dev/null @@ -1,98 +0,0 @@ -# -# Copyright (C) Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ---------------------------------------------------------------------------- -# Revision History -# -# -# REF=ORG -# Original version. -# ---------------------------------------------------------------------------- - - - -include $(PROJROOT)/make/start.mk - -# Do not change above "include" line(s) - -# Arguments to tools, will move to make system once finalized. - -CFLAGS = -CDEFS = -ifeq ($(BUILD),udeb) -CDEFS += DEBUG -endif -CDEFS += - -EXEC_ARGS = -ST_LIB_ARGS = -SH_LIB_ARGS = - -# Define this macro if target runs in kernel mode -#__KERNEL__ = 1 - -# Target name and extension -# static library (ST_LIB): filename.a -# shared library soname (SH_LIB): filename.so.maj_ver.min_ver -# executable (EXEC) : filename.out - -TARGETNAME = sampletest - - -# TARGETTYPE must be EXEC, ST_LIB or SH_LIB in upper case. - -TARGETTYPE = EXEC - -# install directory relative to the HOSTTARGET directory -HOSTRELEASE = binaries - -# install directory relative to the root filesystem -ROOTFSRELEASE = binaries - -# Folders in which gmake will run before building current target - -SUBMODULES = \ - -# Filename must not begin with '.', '/' or '\' - -SOURCES = \ -test_sample_proxy.c - - - -# Search path for include files - -INCLUDES = \ - $(PROJROOT)/omx_core/inc \ - $(PROJROOT)/mm_osal/inc \ - $(MEMMGRROOT) - -# Libraries needed for linking. - -ST_LIBS = -#omx_core omx_proxy_component domx mm_osal -SH_LIBS = pthread dl omx_core OMX.TI.DUCATI1.MISC.SAMPLE domx mm_osal timemmgr - - -# Search path for library (and linker command) files. -# Current folder and target folder are included by default. - -LIBINCLUDES = $(PROJROOT)/target/lib - - -# Do not change below "include" line(s) - -include $(PROJROOT)/make/build.mk - diff --git a/domx/test/sample_proxy/test_sample_proxy.c b/domx/test/sample_proxy/test_sample_proxy.c deleted file mode 100755 index 59830a9..0000000 --- a/domx/test/sample_proxy/test_sample_proxy.c +++ /dev/null @@ -1,1222 +0,0 @@ -/* - * Copyright (c) 2010, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define COMPONENT_NAME "OMX.TI.DUCATI1.MISC.SAMPLE" // needs to be specific for every configuration wrapper -#define OMX_SAMPLE_USEBUF OMX_TRUE - -/**************************************************************** -* INCLUDE FILES -****************************************************************/ -/* ----- system and platform files ----------------------------*/ -#include -#include -#include -#include - - -/*-------program files ----------------------------------------*/ -#include -#include -#include "timm_osal_interfaces.h" - - -#define OMX_SAMPLE_TILER_TEST - -#ifdef OMX_SAMPLE_TILER_TEST - -#include "memmgr.h" - -#endif - - -#define OMX_SAMPLE_INPUT_PORT 0 -#define OMX_SAMPLE_OUTPUT_PORT 1 - -#ifdef OMX_SAMPLE_TILER_TEST - - -#define OMX_SAMPLE_IN_2DYHEIGHT 4 -#define OMX_SAMPLE_IN_2DYWIDTH 8 -#define OMX_SAMPLE_IN_2DUVHEIGHT 2 -#define OMX_SAMPLE_IN_2DUVWIDTH 4 -/* - #define STRIDE_8BIT (16 * 1024) - #define STRIDE_16BIT (32 * 1024) -*/ -#define OMX_SAMPLE_IN_HEIGHT 6 -#define OMX_SAMPLE_IN_WIDTH 8 - -#define STRIDE_LINUX (4 * 1024) - -#define OMX_SAMPLE_BUFFER_SIZE 48 - - -void Test_Util_Memcpy_1Dto2D(TIMM_OSAL_PTR pDst2D, TIMM_OSAL_PTR pSrc1D, - TIMM_OSAL_U32 nSize1D, TIMM_OSAL_U32 nHeight2D, TIMM_OSAL_U32 nWidth2D, - TIMM_OSAL_U32 nStride2D) -{ - TIMM_OSAL_U8 *pInBuffer; - TIMM_OSAL_U8 *pOutBuffer; - TIMM_OSAL_U32 nSizeLeft, i; - - nSizeLeft = nSize1D; - pInBuffer = (TIMM_OSAL_U8 *) pSrc1D; - pOutBuffer = (TIMM_OSAL_U8 *) pDst2D; - //The lower limit is copied. If nSize1D < H*W then 1Dsize is copied else H*W is copied - for (i = 0; i < nHeight2D; i++) - { - if (nSizeLeft >= nWidth2D) - { - TIMM_OSAL_Memcpy(pOutBuffer, pInBuffer, nWidth2D); - } else - { - TIMM_OSAL_Memcpy(pOutBuffer, pInBuffer, nSizeLeft); - break; - } - nSizeLeft -= nWidth2D; - pInBuffer = - (TIMM_OSAL_U8 *) ((TIMM_OSAL_U32) pInBuffer + nWidth2D); - pOutBuffer = - (TIMM_OSAL_U8 *) ((TIMM_OSAL_U32) pOutBuffer + nStride2D); - } -} - -#endif - - -/**************************************************************** -* EXTERNAL REFERENCES NOTE : only use if not found in header file -****************************************************************/ -/*--------data declarations -----------------------------------*/ -/*--------function prototypes ---------------------------------*/ - -/**************************************************************** -* PRIVATE DECLARATIONS Defined and used only here -****************************************************************/ -/*--------function declarations -------------------------------*/ - -/*--------data declarations -----------------------------------*/ -#define NUM_DOMAINS 0x4 -#define OMX_NOPORT 0xfffffffe - -//#define INPUT_FILE "../../omx/omx_il_1_x/omx_base/test/patterns/chikita.mp3" -#define INPUT_FILE "sample_input.mp3" -#define NON_TUN_OUTPUT_FILE "nt_output.mp3" - -static int gTest = 1; - -#define TIMM_OSAL_MallocaBuffer(_size, bContigous, nBlockAlignment) \ - TIMM_OSAL_Malloc (_size, TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_EXT) - -#define OMX_TEST_BUFFERS_OF_TRAFFIC 20 - -#define OMX_TEST_BAIL_IF_ERROR(_eError) \ - if(OMX_ErrorNone != (eError = _eError)){ \ - goto OMX_TEST_BAIL; \ - } - -#define OMX_TEST_SET_ERROR_BAIL(_eCode, _desc) \ -{ \ - eError = _eCode; \ - printf(_desc);\ - goto OMX_TEST_BAIL; \ -} - -#define OMX_TEST_INIT_STRUCT(_s_, _name_) \ - memset(&(_s_), 0x0, sizeof(_name_)); \ - (_s_).nSize = sizeof(_name_); \ - (_s_).nVersion.s.nVersionMajor = 0x1; \ - (_s_).nVersion.s.nVersionMinor = 0x1; \ - (_s_).nVersion.s.nRevision = 0x0; \ - (_s_).nVersion.s.nStep = 0x0 - -#define BUFFER_LIST_CLEAR_ENTRY(_pL, _pB)\ - _pB = _pL->pBufHdr; \ - _pL->pBufHdr = NULL; \ - _pL = _pL->pNextBuf; - -#define BUFFER_LIST_SET_ENTRY(_pL, _pB) \ -{ \ - BufferList *_pT = _pL; \ - while(_pT && _pT->pBufHdr){ \ - _pT = _pT->pNextBuf; \ - } \ - if(_pT) \ - _pT->pBufHdr = _pB; \ -} - -#define BUFFERLIST_CLEAR_ENTRY(_pL, _pB)\ - _pB = _pL->pBufHdr; \ - _pL->pBufHdr = NULL; \ - _pL = _pL->pNextBuf; - -typedef struct _BufferList BufferList; - -struct _BufferList -{ - OMX_BUFFERHEADERTYPE *pBufHdr; - OMX_BUFFERHEADERTYPE *pOrigBufHdr; - BufferList *pNextBuf; -}; - -typedef struct SampleCompTestCtxt -{ - OMX_HANDLETYPE hComp; - OMX_STATETYPE eState; - OMX_U32 nPorts; - OMX_HANDLETYPE hStateSetEvent; - OMX_HANDLETYPE hPortDisableEvent; - OMX_HANDLETYPE hPortEnableEvent; - OMX_STRING inFilePath; - OMX_STRING outFilePath; - FILE *pOutputFile; - FILE *pInputfile; - OMX_BOOL bEOS; - BufferList *pInBufferList; - BufferList *pOutBufferList; - OMX_BOOL bClientAllocBuf; - OMX_U32 nBufDoneCalls; - OMX_PORT_PARAM_TYPE sPortParam[NUM_DOMAINS]; -} SampleCompTestCtxt; - -//this test compiles only for ducati SYS -typedef struct TestCtxt -{ - OMX_HANDLETYPE hComp; - OMX_STATETYPE eState; - OMX_U32 nPorts; - OMX_HANDLETYPE hStateSetEvent; - OMX_HANDLETYPE hPortDisableEvent; - OMX_HANDLETYPE hPortEnableEvent; - OMX_STRING inFilePath; - OMX_STRING outFilePath; - FILE *pOutputFile; - FILE *pInputfile; - OMX_BOOL bEOS; - BufferList *pInBufferList; - BufferList *pOutBufferList; - OMX_BOOL bClientAllocBuf; - OMX_U32 nBufDoneCalls; - //OMX_PORT_PARAM_TYPE sPortParam[NUM_DOMAINS]; -} TestCtxt; - - -static OMX_U32 nInBufCount = 0; -static OMX_U32 nOutBufCount = 0; - - -//Semaphore_Handle EBDSem; -//Semaphore_Params EBDsemParams; - -//Semaphore_Handle FBDSem; -//Semaphore_Params FBDsemParams; -/*========================================================*/ -/* @ fn OMX_TEST_ErrorToString :: ERROR to STRING */ -/*========================================================*/ -OMX_STRING OMX_TEST_ErrorToString(OMX_ERRORTYPE eError) -{ - - OMX_STRING errorString; - - switch (eError) - { - - case OMX_ErrorNone: - errorString = "ErrorNone"; - break; - case OMX_ErrorInsufficientResources: - errorString = "ErrorInsufficientResources"; - break; - case OMX_ErrorUndefined: - errorString = "ErrorUndefined"; - break; - case OMX_ErrorInvalidComponentName: - errorString = "ErrorInvalidComponentName"; - break; - case OMX_ErrorComponentNotFound: - errorString = "ErrorComponentNotFound"; - break; - case OMX_ErrorInvalidComponent: - errorString = "ErrorInvalidComponent"; - break; - case OMX_ErrorBadParameter: - errorString = "ErrorBadParameter"; - break; - case OMX_ErrorNotImplemented: - errorString = "ErrorNotImplemented"; - break; - case OMX_ErrorUnderflow: - errorString = "ErrorUnderflow"; - break; - case OMX_ErrorOverflow: - errorString = "ErrorOverflow"; - break; - case OMX_ErrorHardware: - errorString = "ErrorHardware"; - break; - case OMX_ErrorInvalidState: - errorString = "ErrorInvalidState"; - break; - case OMX_ErrorStreamCorrupt: - errorString = "ErrorStreamCorrupt"; - break; - case OMX_ErrorPortsNotCompatible: - errorString = "ErrorPortsNotCompatible"; - break; - case OMX_ErrorResourcesLost: - errorString = "ErrorResourcesLost"; - break; - case OMX_ErrorNoMore: - errorString = "ErrorNoMore"; - break; - case OMX_ErrorVersionMismatch: - errorString = "ErrorVersionMismatch"; - break; - case OMX_ErrorNotReady: - errorString = "ErrorNotReady"; - break; - case OMX_ErrorTimeout: - errorString = "ErrorTimeout"; - break; - case OMX_ErrorSameState: - errorString = "ErrorSameState"; - break; - case OMX_ErrorResourcesPreempted: - errorString = "ErrorResourcesPreempted"; - break; - case OMX_ErrorPortUnresponsiveDuringAllocation: - errorString = "ErrorPortUnresponsiveDuringAllocation"; - break; - case OMX_ErrorPortUnresponsiveDuringDeallocation: - errorString = "ErrorPortUnresponsiveDuringDeallocation"; - break; - case OMX_ErrorPortUnresponsiveDuringStop: - errorString = "ErrorPortUnresponsiveDuringStop"; - break; - case OMX_ErrorIncorrectStateTransition: - errorString = "ErrorIncorrectStateTransition"; - break; - case OMX_ErrorIncorrectStateOperation: - errorString = "ErrorIncorrectStateOperation"; - break; - case OMX_ErrorUnsupportedSetting: - errorString = "ErrorUnsupportedSetting"; - break; - case OMX_ErrorUnsupportedIndex: - errorString = "ErrorUnsupportedIndex"; - break; - case OMX_ErrorBadPortIndex: - errorString = "ErrorBadPortIndex"; - break; - case OMX_ErrorPortUnpopulated: - errorString = "ErrorPortUnpopulated"; - break; - case OMX_ErrorComponentSuspended: - errorString = "ErrorComponentSuspended"; - break; - case OMX_ErrorDynamicResourcesUnavailable: - errorString = "ErrorDynamicResourcesUnavailable"; - break; - case OMX_ErrorMbErrorsInFrame: - errorString = "ErrorMbErrorsInFrame"; - break; - case OMX_ErrorFormatNotDetected: - errorString = "ErrorFormatNotDetected"; - break; - case OMX_ErrorContentPipeOpenFailed: - errorString = "ErrorContentPipeOpenFailed"; - break; - case OMX_ErrorContentPipeCreationFailed: - errorString = "ErrorContentPipeCreationFailed"; - break; - case OMX_ErrorSeperateTablesUsed: - errorString = "ErrorSeperateTablesUsed"; - break; - case OMX_ErrorTunnelingUnsupported: - errorString = "ErrorTunnelingUnsupported"; - break; - default: - errorString = ""; - break; - } - return errorString; -} - -/*========================================================*/ -/* @ fn OMX_TEST_StateToString :: STATE to STRING */ -/*========================================================*/ -OMX_STRING OMX_TEST_StateToString(OMX_STATETYPE eState) -{ - OMX_STRING StateString; - - switch (eState) - { - case OMX_StateInvalid: - StateString = "Invalid"; - break; - case OMX_StateLoaded: - StateString = "Loaded"; - break; - case OMX_StateIdle: - StateString = "Idle"; - break; - case OMX_StateExecuting: - StateString = "Executing"; - break; - case OMX_StatePause: - StateString = "Pause"; - break; - case OMX_StateWaitForResources: - StateString = "WaitForResources "; - break; - default: - StateString = ""; - break; - } - - return StateString; -} - -/* Application callback Functions */ -/*========================================================*/ -/* @ fn SampleTest_EventHandler :: Application callback */ -/*========================================================*/ -OMX_ERRORTYPE SampleTest_EventHandler(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData) -{ - SampleCompTestCtxt *pContext; - - printf("\n___________ ENTERED CLIENT CALLBACK:%s", __FUNCTION__); - - if (pAppData == NULL) - return OMX_ErrorNone; - - pContext = (SampleCompTestCtxt *) pAppData; - - switch (eEvent) - { - case OMX_EventCmdComplete: - printf("\n OMX_EventCmdComplete case: \n"); - if (OMX_CommandStateSet == nData1) - { - printf(" Component Transitioned to %s state \n", - OMX_TEST_StateToString((OMX_STATETYPE) nData2)); - pContext->eState = (OMX_STATETYPE) nData2; - TIMM_OSAL_SemaphoreRelease(pContext->hStateSetEvent); - } else if (OMX_CommandFlush == nData1) - { - /* Nothing to do over here */ - } else if (OMX_CommandPortDisable == nData1) - { - /* Nothing to do over here */ - TIMM_OSAL_SemaphoreRelease(pContext-> - hPortDisableEvent); - } else if (OMX_CommandPortEnable == nData1) - { - /* Nothing to do over here */ - } else if (OMX_CommandMarkBuffer == nData1) - { - /* Nothing to do over here */ - } - break; - - case OMX_EventError: - printf("\nOMX EVENT ERROR!!!!!! \n"); - break; - - case OMX_EventMark: - break; - - case OMX_EventPortSettingsChanged: - break; - - case OMX_EventBufferFlag: - break; - - case OMX_EventResourcesAcquired: - break; - - case OMX_EventComponentResumed: - break; - - case OMX_EventDynamicResourcesAvailable: - break; - - case OMX_EventPortFormatDetected: - break; - - default: - break; - } - - goto OMX_TEST_BAIL; - OMX_TEST_BAIL: - return OMX_ErrorNone; -} - -/*========================================================*/ -/* @ fn SampleTest_EmptyBufferDone :: Application callback */ -/*========================================================*/ -OMX_ERRORTYPE SampleTest_EmptyBufferDone(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, OMX_IN OMX_BUFFERHEADERTYPE * pBuffer) -{ - SampleCompTestCtxt *pContext; - - printf("\n___________ ENTERED CLIENT CALLBACK:%s", __FUNCTION__); - - if (pAppData == NULL) - return OMX_ErrorNone; - - pContext = (SampleCompTestCtxt *) pAppData; - pContext->nBufDoneCalls++; - - BUFFER_LIST_SET_ENTRY(pContext->pInBufferList, pBuffer); - //Semaphore_post(EBDSem); - - goto OMX_TEST_BAIL; - OMX_TEST_BAIL: - printf("\nEBD done\n"); - return OMX_ErrorNone; -} - -/*========================================================*/ -/* @ fn SampleTest_FillBufferDone :: Application callback */ -/*========================================================*/ -OMX_ERRORTYPE SampleTest_FillBufferDone(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, OMX_IN OMX_BUFFERHEADERTYPE * pBuffHeader) -{ - SampleCompTestCtxt *pContext; - - printf("\n___________ ENTERED CLIENT CALLBACK:%s", __FUNCTION__); - - if (pAppData == NULL) - return OMX_ErrorNone; - - pContext = (SampleCompTestCtxt *) pAppData; - pContext->nBufDoneCalls++; - - if (pContext->pOutputFile && gTest) - { - printf(" writing to output file :: buffer cnt : %d\n", - nOutBufCount); - nOutBufCount++; - fwrite(pBuffHeader->pBuffer, 1, pBuffHeader->nFilledLen, - pContext->pOutputFile); - } - - BUFFER_LIST_SET_ENTRY(pContext->pOutBufferList, pBuffHeader); - //Semaphore_post(FBDSem); - - goto OMX_TEST_BAIL; - OMX_TEST_BAIL: - printf("\nFBD done\n"); - return OMX_ErrorNone; -} - - -static void SampleTest_ReadInputFile(SampleCompTestCtxt * pContext, - OMX_PTR pData, OMX_U32 nBytes, FILE * fp) -{ - OMX_U32 nReadSize = 0; - - printf("\nIn read i/p file\n"); - if (pData == NULL) - printf("\npData is NULL\n"); - else - printf("\npData = %x\n", pData); - printf("\nnBytes = %d\n", nBytes); - if (fp == NULL) - printf("\nfp is NULL\n"); - else - printf("\nfp = %x\n", fp); - nReadSize = fread(pData, 1, nBytes, fp); - if (nReadSize != nBytes) - { - pContext->bEOS = OMX_TRUE; - } - - printf(" Reading from file :: Buffer cont : %d \n", nInBufCount); - nInBufCount++; -} - -/*========================================================*/ -/* @ fn SampleTest_WriteInBuffers :: Reads a buffer from a file and send to Comp */ -/*========================================================*/ -OMX_ERRORTYPE SampleTest_WriteInBuffers(SampleCompTestCtxt * pContext) -{ - - OMX_ERRORTYPE eError = OMX_ErrorNone; - BufferList *pList; - OMX_BUFFERHEADERTYPE *pBufHeader; -#ifdef OMX_SAMPLE_TILER_TEST - OMX_U8 *pTmpBuffer = NULL, *pOrigTmpBuffer = NULL; -#endif - pList = pContext->pInBufferList; - while (pList && pList->pBufHdr) - { - BUFFERLIST_CLEAR_ENTRY(pList, pBufHeader); - printf("\nAbout to read from input file\n"); -#if defined(OMX_SAMPLE_TILER_TEST) - - //OMX_SAMPLE_BUFFER_SIZE is the total amt of data to be sent in the buffer - pTmpBuffer = - TIMM_OSAL_Malloc(OMX_SAMPLE_BUFFER_SIZE, 0, 0, 0); - if (pTmpBuffer == NULL) - OMX_TEST_SET_ERROR_BAIL - (OMX_ErrorInsufficientResources, - "malloc failed \n"); - pOrigTmpBuffer = pTmpBuffer; - - SampleTest_ReadInputFile(pContext, pTmpBuffer, - OMX_SAMPLE_BUFFER_SIZE, pContext->pInputfile); - - Test_Util_Memcpy_1Dto2D(pBufHeader->pBuffer, pTmpBuffer, - OMX_SAMPLE_BUFFER_SIZE, OMX_SAMPLE_IN_HEIGHT, - OMX_SAMPLE_IN_WIDTH, STRIDE_LINUX); - pBufHeader->nFilledLen = OMX_SAMPLE_BUFFER_SIZE; - - printf("\nBefore ETB pBufHeader->nInputPortIndex = %d\n", - pBufHeader->nInputPortIndex); - - TIMM_OSAL_Free(pOrigTmpBuffer); - -#else - SampleTest_ReadInputFile(pContext, pBufHeader->pBuffer, - pBufHeader->nAllocLen, pContext->pInputfile); - pBufHeader->nFilledLen = pBufHeader->nAllocLen; - -#endif - if (pContext->bEOS == OMX_TRUE) - { - pBufHeader->nFlags |= OMX_BUFFERFLAG_EOS; - } - - eError = OMX_EmptyThisBuffer(pContext->hComp, pBufHeader); - - OMX_TEST_BAIL_IF_ERROR(eError); - } - - OMX_TEST_BAIL: - return eError; - -} - -/*========================================================*/ -/* @ fn SampleTest_ReadOutBuffers :: Send out buffers */ -/*========================================================*/ - -OMX_ERRORTYPE SampleTest_ReadOutBuffers(SampleCompTestCtxt * pContext) -{ - - OMX_ERRORTYPE eError = OMX_ErrorNone; - BufferList *pList; - OMX_BUFFERHEADERTYPE *pBufHeader; - - pList = pContext->pOutBufferList; - while (pList && pList->pBufHdr) - { - printf("\nAbout to do FTB\n"); - - BUFFERLIST_CLEAR_ENTRY(pList, pBufHeader); - - eError = OMX_FillThisBuffer(pContext->hComp, pBufHeader); - - OMX_TEST_BAIL_IF_ERROR(eError); - if (pBufHeader->nFlags == OMX_BUFFERFLAG_EOS) - { - pContext->nBufDoneCalls = OMX_TEST_BUFFERS_OF_TRAFFIC; - } - } - - OMX_TEST_BAIL: - return eError; - -} - - - -/*========================================================*/ -/* @ fn SampleTest_AllocateBuffers :: Allocates the Resources on the available ports */ -/*========================================================*/ -OMX_ERRORTYPE SampleTest_AllocateBuffers(SampleCompTestCtxt * pContext, - OMX_PARAM_PORTDEFINITIONTYPE * pPortDef) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_U8 *pBuffer = NULL; - BufferList *pBufferList; - BufferList *pTemp; - OMX_BUFFERHEADERTYPE *pBufferHdr; - OMX_U32 i = 100; - OMX_COMPONENTTYPE *pComp; - -#ifdef OMX_SAMPLE_TILER_TEST - MemAllocBlock *pBlock = NULL; - OMX_U32 nNumBlocks = 1; - -/*For i/p port allocate 2D packed buffer, for o/p port allocate 1D buffer. -Ideally client should get this from GetParams but this is just a sample test so -values are hardcoded*/ - - if (pPortDef->nPortIndex == OMX_SAMPLE_INPUT_PORT) - { - nNumBlocks = 2; - pBlock = - TIMM_OSAL_Malloc(sizeof(MemAllocBlock) * nNumBlocks, 0, 0, - 0); - TIMM_OSAL_Memset(pBlock, 0, sizeof(MemAllocBlock) * nNumBlocks); - pBlock[0].dim.area.width = OMX_SAMPLE_IN_2DYWIDTH; - pBlock[0].dim.area.height = OMX_SAMPLE_IN_2DYHEIGHT; - pBlock[0].pixelFormat = PIXEL_FMT_8BIT; - pBlock[1].dim.area.width = OMX_SAMPLE_IN_2DUVWIDTH; - pBlock[1].dim.area.height = OMX_SAMPLE_IN_2DUVHEIGHT; - pBlock[1].pixelFormat = PIXEL_FMT_16BIT; - } else - { - nNumBlocks = 1; - pBlock = - TIMM_OSAL_Malloc(sizeof(MemAllocBlock) * nNumBlocks, 0, 0, - 0); - TIMM_OSAL_Memset(pBlock, 0, sizeof(MemAllocBlock) * nNumBlocks); - pBlock[0].dim.len = OMX_SAMPLE_BUFFER_SIZE; - pBlock[0].pixelFormat = PIXEL_FMT_PAGE; - } -#endif - - for (i = 0; i < pPortDef->nBufferCountActual; i++) - { - pBufferList = - (BufferList *) TIMM_OSAL_Malloc(sizeof(BufferList), - TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT); - if (!pBufferList) - { - OMX_TEST_SET_ERROR_BAIL - (OMX_ErrorInsufficientResources, - "malloc failed \n"); - } - - if (pContext->bClientAllocBuf) - { - -#ifdef OMX_SAMPLE_TILER_TEST -/*For i/p port allocate 2D packed buffer, for o/p port allocate 1D buffer. -Ideally client should get this from GetParams but this is just a sample test so -values are hardcoded*/ - pBuffer = MemMgr_Alloc(pBlock, nNumBlocks); - printf("\nMemMgr allocated buffer = 0x%x\n", pBuffer); -#else - pBuffer = - (OMX_U8 *) TIMM_OSAL_MallocaBuffer(pPortDef-> - nBufferSize, pPortDef->bBuffersContiguous, - pPortDef->nBufferAlignment); - -#endif - - if (!pBufferList) - { - OMX_TEST_SET_ERROR_BAIL - (OMX_ErrorInsufficientResources, - "malloc failed \n"); - } - - printf("\nCalling UseBuf on port %d\n", - pPortDef->nPortIndex); - eError = - OMX_UseBuffer(pContext->hComp, &pBufferHdr, - pPortDef->nPortIndex, 0, pPortDef->nBufferSize, - pBuffer); - - OMX_TEST_BAIL_IF_ERROR(eError); - - } else - { - - pComp = (OMX_COMPONENTTYPE *) pContext->hComp; - printf("\nCalling allocate buffer\n"); - eError = - OMX_AllocateBuffer(pContext->hComp, &pBufferHdr, - pPortDef->nPortIndex, 0, pPortDef->nBufferSize); - - OMX_TEST_BAIL_IF_ERROR(eError); - } - printf("\npBufferHdr->nOutputPortIndex = %d\n", - pBufferHdr->nOutputPortIndex); - printf("\npBufferHdr->nInputPortIndex = %d\n", - pBufferHdr->nInputPortIndex); - pBufferList->pNextBuf = NULL; - pBufferList->pBufHdr = pBufferHdr; - pBufferList->pOrigBufHdr = pBufferHdr; - - if (pPortDef->eDir == OMX_DirInput) - { - printf("\npBufferHdr->nOutputPortIndex = %d\n", - pBufferHdr->nOutputPortIndex); - printf("\npBufferHdr->nInputPortIndex = %d\n", - pBufferHdr->nInputPortIndex); - pBufferHdr->nOutputPortIndex = OMX_NOPORT; - if (pContext->pInBufferList == NULL) - { - pContext->pInBufferList = pBufferList; - } else - { - pTemp = pContext->pInBufferList; - while (pTemp->pNextBuf) - pTemp = pTemp->pNextBuf; - pTemp->pNextBuf = pBufferList; - } - } else - { - pBufferHdr->nInputPortIndex = OMX_NOPORT; - printf("\npBufferHdr->nOutputPortIndex = %d\n", - pBufferHdr->nOutputPortIndex); - printf("\npBufferHdr->nInputPortIndex = %d\n", - pBufferHdr->nInputPortIndex); - if (pContext->pOutBufferList == NULL) - { - pContext->pOutBufferList = pBufferList; - } else - { - pTemp = pContext->pOutBufferList; - while (pTemp->pNextBuf) - pTemp = pTemp->pNextBuf; - pTemp->pNextBuf = pBufferList; - } - } - } - - OMX_TEST_BAIL: -#ifdef OMX_SAMPLE_TILER_TEST - if (pBlock != NULL) - TIMM_OSAL_Free(pBlock); -#endif - if (eError != OMX_ErrorNone) - { - if (pBufferList) - { - TIMM_OSAL_Free(pBufferList); - } - } - - return eError; -} - -/*========================================================*/ -/* @ fn SampleTest_DeInitBuffers :: Destroy the resources */ -/*========================================================*/ -OMX_ERRORTYPE SampleTest_DeInitBuffers(SampleCompTestCtxt * pContext) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_U8 *pBuffer; - BufferList *pBufferList; - BufferList *pTemp; - - OMX_U32 nRetVal = 0; - - pTemp = pContext->pInBufferList; - - while (pTemp) - { - pBufferList = (BufferList *) pTemp; - pBuffer = (OMX_U8 *) pTemp->pOrigBufHdr->pBuffer; - - printf("\nCalling Free Buffer on port no. %d\n", - pTemp->pOrigBufHdr->nInputPortIndex); - - eError = - OMX_FreeBuffer(pContext->hComp, - pTemp->pOrigBufHdr->nInputPortIndex, pTemp->pOrigBufHdr); - OMX_TEST_BAIL_IF_ERROR(eError); - - if (pContext->bClientAllocBuf) - { - -#ifdef OMX_SAMPLE_TILER_TEST - nRetVal = MemMgr_Free(pBuffer); - if (nRetVal) - { - printf("\nError in MemMgr free\n"); - } -#else - TIMM_OSAL_Free(pBuffer); -#endif - } - - pTemp = pTemp->pNextBuf; - if (pBufferList) - TIMM_OSAL_Free(pBufferList); - } - - pContext->pInBufferList = NULL; - - pTemp = pContext->pOutBufferList; - while (pTemp) - { - pBufferList = (BufferList *) pTemp; - pBuffer = (OMX_U8 *) pTemp->pOrigBufHdr->pBuffer; - printf("\nCalling Free Buffer on port no. %d\n", - pTemp->pOrigBufHdr->nOutputPortIndex); - - eError = - OMX_FreeBuffer(pContext->hComp, - pTemp->pOrigBufHdr->nOutputPortIndex, pTemp->pOrigBufHdr); - OMX_TEST_BAIL_IF_ERROR(eError); - if (pContext->bClientAllocBuf) - { -#ifdef OMX_SAMPLE_TILER_TEST - nRetVal = MemMgr_Free(pBuffer); - if (nRetVal) - { - printf("\nError in MemMgr free\n"); - } -#else - TIMM_OSAL_Free(pBuffer); -#endif - } - - pTemp = pTemp->pNextBuf; - if (pBufferList) - TIMM_OSAL_Free(pBufferList); - - } - - pContext->pOutBufferList = NULL; - - OMX_TEST_BAIL: - return eError; -} - -/*========================================================*/ -/* @ fn SampleTest_TransitionWait :: Waits for the transition to be completed , - * incase of loaded to idle Allocates the Resources and while idle to loaded - * destroys the resources */ -/*========================================================*/ -OMX_ERRORTYPE SampleTest_TransitionWait(OMX_STATETYPE eToState, - SampleCompTestCtxt * pContext) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_PARAM_PORTDEFINITIONTYPE tPortDef; - OMX_U32 i, j; - - eError = OMX_SendCommand(pContext->hComp, OMX_CommandStateSet, - eToState, NULL); - OMX_TEST_BAIL_IF_ERROR(eError); - - if ((eToState == OMX_StateIdle) && - (pContext->eState == OMX_StateLoaded)) - { - for (i = 0; i < NUM_DOMAINS; i++) - { - for (j = pContext->sPortParam[i].nStartPortNumber; - j < pContext->sPortParam[i].nStartPortNumber - + pContext->sPortParam[i].nPorts; j++) - { - - OMX_TEST_INIT_STRUCT(tPortDef, - OMX_PARAM_PORTDEFINITIONTYPE); - tPortDef.nPortIndex = j; -//printf("\nCalling GetParam before UseBuf on port %d\n",j); - eError = OMX_GetParameter(pContext->hComp, - OMX_IndexParamPortDefinition, - (OMX_PTR) & tPortDef); - OMX_TEST_BAIL_IF_ERROR(eError); - -// if(tPortDef.bEnabled)//AD - eError = - SampleTest_AllocateBuffers(pContext, - &tPortDef); - - OMX_TEST_BAIL_IF_ERROR(eError); - } - } - } else if ((eToState == OMX_StateLoaded) && - (pContext->eState == OMX_StateIdle)) - { - - eError = SampleTest_DeInitBuffers(pContext); - OMX_TEST_BAIL_IF_ERROR(eError); - - } - printf("\nWaiting for state set event\n"); - TIMM_OSAL_SemaphoreObtain(pContext->hStateSetEvent, - TIMM_OSAL_SUSPEND); - printf("\nState set event recd.\n"); - - if (pContext->eState != eToState) - OMX_TEST_SET_ERROR_BAIL(OMX_ErrorUndefined, - " InComplete Transition \n"); - - OMX_TEST_BAIL: - return eError; -} - - -/*========================================================*/ -/* @ fn OMX_Sample_UT0001 :: Initializes, move to Idle and then to executing, process -* buffers and then destroy the component by moving back to idle, loaded, invalid */ -/*========================================================*/ -void main(void) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_HANDLETYPE hComp = NULL; - OMX_CALLBACKTYPE oCallbacks; - SampleCompTestCtxt *pContext; - SampleCompTestCtxt oAppData; - - int ch1, ch2; - int pass; - int while_pass = 0, loc_diff = 0; - - - pContext = &oAppData; - printf(" Entering : %s \n", __FUNCTION__); - memset(pContext, 0x0, sizeof(SampleCompTestCtxt)); - - oCallbacks.EventHandler = SampleTest_EventHandler; - oCallbacks.EmptyBufferDone = SampleTest_EmptyBufferDone; - oCallbacks.FillBufferDone = SampleTest_FillBufferDone; - printf("\nCalling sem create\n"); - /* Initialize Events to Track callbacks */ - TIMM_OSAL_SemaphoreCreate(&pContext->hStateSetEvent, 0); - TIMM_OSAL_SemaphoreCreate(&pContext->hPortDisableEvent, 0); - //TIMM_OSAL_MutexObtain(pContext->hStateSetEvent, TIMM_OSAL_SUSPEND); - printf("\nSem created\n"); - - - pContext->pInputfile = fopen(INPUT_FILE, "rb"); - if (NULL == pContext->pInputfile) - { - eError = OMX_ErrorInsufficientResources; - //goto OMX_TEST_BAIL; - } - printf("\nInput file opened\n"); - pContext->pOutputFile = fopen(NON_TUN_OUTPUT_FILE, "wb"); - if (NULL == pContext->pOutputFile) - { - eError = OMX_ErrorInsufficientResources; - //goto OMX_TEST_BAIL; - } - - - /* Initialize OpenMAX */ - printf("\nInitialize OpenMAX\n"); - eError = OMX_Init(); - OMX_TEST_BAIL_IF_ERROR(eError); - /* Load a component */ - printf("\nLoad a component\n"); - eError = - OMX_GetHandle(&hComp, (OMX_STRING) "OMX.TI.DUCATI1.MISC.SAMPLE", - pContext, &oCallbacks); - OMX_TEST_BAIL_IF_ERROR(eError); - pContext->hComp = hComp; -printf ("\neError = 0x%x\n", eError); -if(hComp) - printf("\nhComp = 0x%x\n", hComp); - /* Verify that the component is in Loaded state */ - printf("\nVerify that the component is in Loaded state\n"); - - eError = OMX_GetState(pContext->hComp, &pContext->eState); - OMX_TEST_BAIL_IF_ERROR(eError); - if (OMX_StateLoaded != pContext->eState) - { - OMX_TEST_SET_ERROR_BAIL(OMX_ErrorUndefined, - "not in loaded state \n"); - } - - /* detect all Audio ports on the component */ - OMX_TEST_INIT_STRUCT(pContext->sPortParam[0], OMX_PORT_PARAM_TYPE); - eError = OMX_GetParameter(hComp, OMX_IndexParamAudioInit, - (OMX_PTR) & pContext->sPortParam[0]); - OMX_TEST_BAIL_IF_ERROR(eError); - - /* detect all video ports on the component */ - OMX_TEST_INIT_STRUCT(pContext->sPortParam[1], OMX_PORT_PARAM_TYPE); - eError = OMX_GetParameter(hComp, OMX_IndexParamVideoInit, - (OMX_PTR) & pContext->sPortParam[1]); - OMX_TEST_BAIL_IF_ERROR(eError); - - /* detect all image ports on the component */ - OMX_TEST_INIT_STRUCT(pContext->sPortParam[2], OMX_PORT_PARAM_TYPE); - eError = OMX_GetParameter(hComp, OMX_IndexParamImageInit, - (OMX_PTR) & pContext->sPortParam[2]); - OMX_TEST_BAIL_IF_ERROR(eError); - - /* detect all other ports on the component */ - OMX_TEST_INIT_STRUCT(pContext->sPortParam[3], OMX_PORT_PARAM_TYPE); - eError = OMX_GetParameter(hComp, OMX_IndexParamOtherInit, - (OMX_PTR) & pContext->sPortParam[3]); - OMX_TEST_BAIL_IF_ERROR(eError); - - pContext->nPorts = pContext->sPortParam[0].nPorts + - pContext->sPortParam[1].nPorts + - pContext->sPortParam[2].nPorts + pContext->sPortParam[3].nPorts; - - - pContext->bClientAllocBuf = OMX_SAMPLE_USEBUF; - if (pContext->bClientAllocBuf == OMX_TRUE) - { - printf(" Client does Allocation of buffers \n"); - } else - { - printf(" Component does Allocation of buffers \n"); - } - - /* Transition to Idle state */ - - eError = SampleTest_TransitionWait(OMX_StateIdle, pContext); - OMX_TEST_BAIL_IF_ERROR(eError); - /* Transition to Executing state */ - eError = SampleTest_TransitionWait(OMX_StateExecuting, pContext); - OMX_TEST_BAIL_IF_ERROR(eError); - printf("\nAbout to start processing buffers\n"); - - - /* process buffers */ - - while (pContext->nBufDoneCalls < OMX_TEST_BUFFERS_OF_TRAFFIC) - { - - eError = SampleTest_WriteInBuffers(pContext); - OMX_TEST_BAIL_IF_ERROR(eError); - - eError = SampleTest_ReadOutBuffers(pContext); - OMX_TEST_BAIL_IF_ERROR(eError); - while_pass++; - //printf("\n WHILE PROCESS LOOP COUNT: BufDoneCount = %d %d", - // while_pass, pContext->nBufDoneCalls); - - //printf("\n Waiting on Sample component to respond"); - - } - - - gTest = 0; - - /* Transition back to Idle state */ - eError = SampleTest_TransitionWait(OMX_StateIdle, pContext); - OMX_TEST_BAIL_IF_ERROR(eError); - - /* Trasnition back to Loaded state */ - eError = SampleTest_TransitionWait(OMX_StateLoaded, pContext); - OMX_TEST_BAIL_IF_ERROR(eError); - - - OMX_TEST_BAIL: - - fclose(pContext->pInputfile); - fclose(pContext->pOutputFile); - - if (eError == OMX_ErrorNone) - { - eError = OMX_FreeHandle(pContext->hComp); - eError = OMX_Deinit(); - } else - { - SampleTest_TransitionWait(OMX_StateInvalid, pContext); - SampleTest_DeInitBuffers(pContext); - - OMX_FreeHandle(pContext->hComp); - OMX_Deinit(); - } - - TIMM_OSAL_SemaphoreDelete(pContext->hStateSetEvent); - TIMM_OSAL_SemaphoreDelete(pContext->hPortDisableEvent); - - /* emit the Test Result */ - if (OMX_ErrorNone != eError) - { - printf(" TestCase Failed and returned an error:: %s \n", - OMX_TEST_ErrorToString(eError)); - } else - { - printf - ("\nTest case has ended, now comparing input and output files\n"); - pContext->pInputfile = fopen(INPUT_FILE, "rb"); - if (NULL == pContext->pInputfile) - { - printf("\n Error in opening INPUT_FILE"); - eError = OMX_ErrorInsufficientResources; - } - - pContext->pOutputFile = fopen(NON_TUN_OUTPUT_FILE, "rb"); - if (NULL == pContext->pOutputFile) - { - printf("\n Error in opening NON_TUN_OUTPUT_FILE"); - eError = OMX_ErrorInsufficientResources; - } - pass = 1; - while (1) - { - if (eError != OMX_ErrorNone) - { - pass = 0; - break; - } - ch1 = fgetc(pContext->pInputfile); - ch2 = fgetc(pContext->pOutputFile); - loc_diff++; - if (ch1 == EOF || ch2 == EOF) - { - break; - } - if (ch1 != ch2) - { - pass = 0; - printf("\n \n"); - printf - ("\n FILE SIZE = 320 KB - NUMBER OF ITERATIONS = 20 (10 for INPUT AND 10 FOR OUTPUT buffers\n"); - printf - ("\n ################### LOCATION OF DIFFERENCE: %d ################### \n", - loc_diff); - break; - } - } - fclose(pContext->pInputfile); - fclose(pContext->pOutputFile); - if (pass == 1) - printf(" Test Case has Passed\n"); - else - { - printf("\nTest case has failed. (EOF not reached)\n"); - eError = OMX_ErrorUndefined; - } - } - - if (eError == OMX_ErrorNone) - { - printf(" Test Case has Passed :) \n"); - } else - { - printf("\nTest case has failed.(OMX Error)\n"); - } -} - diff --git a/edid/Android.mk b/edid/Android.mk deleted file mode 100755 index d8b8dca..0000000 --- a/edid/Android.mk +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - lib/edid_parser.c - -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := libedid - -include $(BUILD_SHARED_LIBRARY) - -# ==================== -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - cmd/parse_hdmi_edid.c - -LOCAL_SHARED_LIBRARIES:= \ - libutils \ - libedid - -LOCAL_MODULE:= parse_hdmi_edid -LOCAL_MODULE_TAGS:= optional - -include $(BUILD_EXECUTABLE) - diff --git a/edid/cmd/parse_hdmi_edid.c b/edid/cmd/parse_hdmi_edid.c deleted file mode 100755 index 9f84505..0000000 --- a/edid/cmd/parse_hdmi_edid.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#define LOG_TAG "EDID" -#include - -#include - -static const char kHdmiEdidPathName[] = "/sys/devices/platform/omapdss/display1/edid"; - -static void print_s3d_format_info(struct edid_t *edid, const struct hdmi_s3d_format_info_t *info) -{ - unsigned int i; - if(info == NULL) { - return; - } - - switch(info->format) { - case HDMI_FRAME_PACKING: - fprintf(stdout, "--Frame Packing"); - break; - case HDMI_FIELD_ALTERNATIVE: - fprintf(stdout, "--Filed Alternative"); - break; - case HDMI_LINE_ALTERNATIVE: - fprintf(stdout, "--Line Alternative"); - break; - case HDMI_SIDE_BY_SIDE_FULL: - fprintf(stdout, "--Side by Side FULL"); - break; - case HDMI_L_DEPTH: - fprintf(stdout, "--L + Depth"); - break; - case HDMI_L_DEPTH_GFX_GFX_DEPTH: - fprintf(stdout, "--L + Depth + Graphics + Graphics + Depth"); - break; - case HDMI_TOPBOTTOM: - fprintf(stdout, "--Top Bottom"); - break; - case HDMI_SIDE_BY_SIDE_HALF: - fprintf(stdout, "--Side by Side HALF"); - break; - default: - fprintf(stdout, "--Unkown format"); - break; - } - fprintf(stdout, "\n"); - - for (i = 0; i < info->num_valid_vic; i++) { - const struct svd_t * svd = edid_get_svd_descriptor(edid, info->vic_info[i].vic_pos); - fprintf(stdout, "----Mode:%s sub-sampling: ", svd->info.name); - switch(info->vic_info[i].subsampling) { - case HDMI_SS_HORZANDQUINCUNX: - fprintf(stdout, "Horizontal and Quincunx"); - break; - case HDMI_SS_HORIZONTAL: - fprintf(stdout, "Horizontal"); - break; - case HDMI_SS_QUINCUNX_ALL: - fprintf(stdout, "Quincunx"); - break; - case HDMI_SS_QUINCUNX_OLOR: - fprintf(stdout, "Quincunx Odd-Left/Odd-Right"); - break; - case HDMI_SS_QUINCUNX_OLER: - fprintf(stdout, "Quincunx Odd-Left/Even-Right"); - break; - case HDMI_SS_QUINCUNX_ELOR: - fprintf(stdout, "Quincunx Even-Left/Odd-Right"); - break; - case HDMI_SS_QUINCUNX_ELER: - fprintf(stdout, "Quincunx Even-Left/Even-Right"); - break; - case HDMI_SS_VERTICAL: - fprintf(stdout, "Vertical"); - break; - case HDMI_SS_NONE: - fprintf(stdout, "None"); - break; - default: - break; - } - fprintf(stdout, "\n"); - } - -} -int main() -{ - unsigned int i; - struct svd_t *svd_list; - unsigned int num_svds; - - int fd = open(kHdmiEdidPathName, O_RDONLY); - - if (!fd) { - return 1; - } - - uint8_t edid_data[EDID_SIZE]; - size_t bytes_read = read(fd, edid_data, EDID_SIZE); - close(fd); - - if (bytes_read < EDID_SIZE) { - fprintf(stderr, "Could not read EDID data\n"); - return 1; - } - - struct edid_t *edid = NULL; - if(edid_parser_init(&edid, edid_data)) { - fprintf(stderr, "Could not init parser\n"); - return 1; - } - - edid_get_svd_list(edid, &svd_list, &num_svds); - - fprintf(stdout, "EDID Info\n"); - fprintf(stdout, "[Short Video Descriptors]\n"); - for (i = 0; i < num_svds; i++) { - fprintf(stdout, "----%d: %s [code:%d, native:%d] [xres:%d, yres:%d Hz:%d]\n", - i, svd_list[i].info.name, svd_list[i].code, svd_list[i].native, - svd_list[i].info.xres, svd_list[i].info.yres, svd_list[i].info.hz); - } - - fprintf(stdout, "\n[S3D Optional Formats]\n"); - print_s3d_format_info(edid, edid_get_s3d_format_info(edid, HDMI_FRAME_PACKING)); - print_s3d_format_info(edid, edid_get_s3d_format_info(edid, HDMI_FIELD_ALTERNATIVE)); - print_s3d_format_info(edid, edid_get_s3d_format_info(edid, HDMI_LINE_ALTERNATIVE)); - print_s3d_format_info(edid, edid_get_s3d_format_info(edid, HDMI_SIDE_BY_SIDE_FULL)); - print_s3d_format_info(edid, edid_get_s3d_format_info(edid, HDMI_L_DEPTH)); - print_s3d_format_info(edid, edid_get_s3d_format_info(edid, HDMI_L_DEPTH_GFX_GFX_DEPTH)); - print_s3d_format_info(edid, edid_get_s3d_format_info(edid, HDMI_TOPBOTTOM)); - print_s3d_format_info(edid, edid_get_s3d_format_info(edid, HDMI_SIDE_BY_SIDE_HALF)); - - edid_parser_deinit(edid); - - return 0; -} diff --git a/edid/inc/edid_parser.h b/edid/inc/edid_parser.h deleted file mode 100755 index 9dba5f4..0000000 --- a/edid/inc/edid_parser.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _EDID_PARSER_ -#define _EDID_PARSER_ - -#define EDID_SIZE 256 -#define MAX_VIC_CODES_PER_3D_FORMAT 16 - -struct edid_t; - -enum datablock_id { - DATABLOCK_AUDIO = 1, - DATABLOCK_VIDEO = 2, - DATABLOCK_VENDOR = 3, - DATABLOCK_SPEAKERS = 4, -}; - -enum hdmi_3d_format { - HDMI_FRAME_PACKING = 0, - HDMI_FIELD_ALTERNATIVE = 1, - HDMI_LINE_ALTERNATIVE = 2, - HDMI_SIDE_BY_SIDE_FULL = 3, - HDMI_L_DEPTH = 4, - HDMI_L_DEPTH_GFX_GFX_DEPTH = 5, - HDMI_TOPBOTTOM = 6, - HDMI_SIDE_BY_SIDE_HALF = 8, -}; - -enum hdmi_3d_format_bits { - HDMI_FRAME_PACKING_BIT = 1 << HDMI_FRAME_PACKING, - HDMI_FIELD_ALTERNATIVE_BIT = 1 << HDMI_FIELD_ALTERNATIVE, - HDMI_LINE_ALTERNATIVE_BIT = 1 << HDMI_LINE_ALTERNATIVE, - HDMI_SIDE_BY_SIDE_FULL_BIT = 1 << HDMI_SIDE_BY_SIDE_FULL, - HDMI_L_DEPTH_BIT = 1 << HDMI_L_DEPTH , - HDMI_L_DEPTH_GFX_GFX_DEPTH_BIT = 1 << HDMI_L_DEPTH_GFX_GFX_DEPTH, - HDMI_TOPBOTTOM_BIT = 1 << HDMI_TOPBOTTOM, - HDMI_SIDE_BY_SIDE_HALF_BIT = 1 << HDMI_SIDE_BY_SIDE_HALF, - HDMI_SIDE_BY_SIDE_HALF_QUINCUNX_BIT = 1 << 15, -}; - -//ALL = both horizontal and quincunx modes are supported -//HDMI_SS_QUINCUNX_ALL = all quincunx subsampling modes are supported -//OL = Odd left viewHorizontal sub -//OR = Odd right view -//ER = Even left view -//EL = Even right view -enum hdmi_3d_subsampling { - HDMI_SS_HORZANDQUINCUNX = 0, - HDMI_SS_HORIZONTAL = 1, - HDMI_SS_QUINCUNX_ALL = 6, - HDMI_SS_QUINCUNX_OLOR = 7, - HDMI_SS_QUINCUNX_OLER = 8, - HDMI_SS_QUINCUNX_ELOR = 9, - HDMI_SS_QUINCUNX_ELER = 10, - HDMI_SS_VERTICAL = 0xF0000, - HDMI_SS_NONE = 0xF0001, -}; - -enum hdmi_scan_type { - HDMI_SCAN_PROGRESSIVE, - HDMI_SCAN_INTERLACED, -}; - -struct svd_info_t { - uint32_t xres; - uint32_t yres; - uint32_t hz; - enum hdmi_scan_type scan_type; - char name[9]; -}; - -struct svd_t { - uint8_t code; - bool native; - struct svd_info_t info; -}; - -struct hdmi_s3d_format_vic_info_t { - uint8_t vic_pos; - enum hdmi_3d_subsampling subsampling; -}; - -struct hdmi_s3d_format_info_t { - enum hdmi_3d_format format; - unsigned int num_valid_vic; - struct hdmi_s3d_format_vic_info_t vic_info[MAX_VIC_CODES_PER_3D_FORMAT]; -}; - -int edid_parser_init(struct edid_t **edid, const uint8_t *raw_edid_data); -void edid_parser_deinit(struct edid_t *edid); - -bool edid_s3d_capable(struct edid_t *edid); -bool edid_supports_s3d_format(struct edid_t *edid, enum hdmi_3d_format format); -const struct hdmi_s3d_format_info_t * edid_get_s3d_format_info(struct edid_t *edid, enum hdmi_3d_format format); - -void edid_get_svd_list(struct edid_t *edid, struct svd_t **list, unsigned int *num_elements); -const struct svd_t *edid_get_svd_descriptor(struct edid_t *edid, uint8_t vic_pos); - -#endif //_EDID_PARSER_ \ No newline at end of file diff --git a/edid/lib/edid_parser.c b/edid/lib/edid_parser.c deleted file mode 100755 index e08822c..0000000 --- a/edid/lib/edid_parser.c +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include -#include - -#include -#include "edid_parser_priv.h" - -const struct svd_info_t svd_table[] = -{ - {0, 0, 0, HDMI_SCAN_PROGRESSIVE, "reserved"}, - {640, 480, 60, HDMI_SCAN_PROGRESSIVE, "DMT0659"}, - {720, 480, 60, HDMI_SCAN_PROGRESSIVE, "480p"}, - {720, 480, 60, HDMI_SCAN_PROGRESSIVE, "480pH"}, - {1280, 720, 60, HDMI_SCAN_PROGRESSIVE, "720p"}, - {1920, 1080, 60, HDMI_SCAN_INTERLACED, "1080i"}, - {720, 480, 60, HDMI_SCAN_INTERLACED, "480i"}, - {720, 480, 60, HDMI_SCAN_INTERLACED, "480iH"}, - {720, 240, 60, HDMI_SCAN_PROGRESSIVE, "240p"}, - {1280, 720, 60, HDMI_SCAN_PROGRESSIVE, "240pH"}, - {720, 480, 60, HDMI_SCAN_INTERLACED, "480i4x"}, - {720, 480, 60, HDMI_SCAN_INTERLACED, "480i4xH"}, - {720, 240, 60, HDMI_SCAN_PROGRESSIVE, "240p4x"}, - {720, 240, 60, HDMI_SCAN_PROGRESSIVE, "240p4xH"}, - {720, 480, 60, HDMI_SCAN_PROGRESSIVE, "480p2x"}, - {720, 480, 60, HDMI_SCAN_PROGRESSIVE, "480p2xH"}, - {1920, 1080, 60, HDMI_SCAN_PROGRESSIVE, "1080p"}, - {720, 576, 50, HDMI_SCAN_PROGRESSIVE, "576p"}, - {720, 576, 50, HDMI_SCAN_PROGRESSIVE, "576pH"}, - {1280, 720, 50, HDMI_SCAN_PROGRESSIVE, "720p50"}, - {1920, 1080, 50, HDMI_SCAN_INTERLACED, "1080i25"}, - {720, 576, 50, HDMI_SCAN_INTERLACED, "576i"}, - {720, 576, 50, HDMI_SCAN_INTERLACED, "576iH"}, - {720, 288, 50, HDMI_SCAN_PROGRESSIVE, "288p"}, - {720, 288, 50, HDMI_SCAN_PROGRESSIVE, "288pH"}, - {720, 576, 50, HDMI_SCAN_INTERLACED, "576i4x"}, - {720, 576, 50, HDMI_SCAN_INTERLACED, "576i4xH"}, - {720, 288, 50, HDMI_SCAN_PROGRESSIVE, "288p4x"}, - {720, 288, 50, HDMI_SCAN_PROGRESSIVE, "288p4xH"}, - {720, 576, 50, HDMI_SCAN_PROGRESSIVE, "576p2x"}, - {720, 576, 50, HDMI_SCAN_PROGRESSIVE, "576p2xH"}, - {1920, 1080, 50, HDMI_SCAN_PROGRESSIVE, "1080p50"}, - {1920, 1080, 24, HDMI_SCAN_PROGRESSIVE, "1080p24"}, - {1920, 1080, 25, HDMI_SCAN_PROGRESSIVE, "1080p25"}, - {1920, 1080, 30, HDMI_SCAN_PROGRESSIVE, "1080p30"}, - {720, 480, 60, HDMI_SCAN_PROGRESSIVE, "480p4x"}, - {720, 480, 60, HDMI_SCAN_PROGRESSIVE, "480p4xH"}, - {720, 576, 50, HDMI_SCAN_PROGRESSIVE, "576p4x"}, - {720, 576, 50, HDMI_SCAN_PROGRESSIVE, "576p4xH"}, - {1920, 1080, 50, HDMI_SCAN_INTERLACED, "1080i25"}, - {1920, 1080, 100, HDMI_SCAN_INTERLACED, "1080i50"}, - {1280, 720, 100, HDMI_SCAN_PROGRESSIVE, "720p100"}, - {720, 576, 100, HDMI_SCAN_PROGRESSIVE, "576p100"}, - {720, 576, 100, HDMI_SCAN_PROGRESSIVE, "576p100H"}, - {720, 576, 100, HDMI_SCAN_INTERLACED, "576i50"}, - {720, 576, 100, HDMI_SCAN_INTERLACED, "576i50H"}, - {1920, 1080, 120, HDMI_SCAN_INTERLACED, "1080i60"}, - {1280, 720, 120, HDMI_SCAN_PROGRESSIVE, "720p120"}, - {720, 480, 120, HDMI_SCAN_PROGRESSIVE, "480p120"}, - {720, 480, 120, HDMI_SCAN_PROGRESSIVE, "480p120H"}, - {720, 480, 120, HDMI_SCAN_INTERLACED, "480i60"}, - {720, 480, 120, HDMI_SCAN_INTERLACED, "480i60H"}, - {720, 576, 200, HDMI_SCAN_PROGRESSIVE, "576p200"}, - {720, 576, 200, HDMI_SCAN_PROGRESSIVE, "576p200H"}, - {720, 576, 200, HDMI_SCAN_INTERLACED, "576i100"}, - {720, 576, 200, HDMI_SCAN_INTERLACED, "576i100H"}, - {720, 480, 240, HDMI_SCAN_PROGRESSIVE, "480p240"}, - {720, 480, 240, HDMI_SCAN_PROGRESSIVE, "480p240H"}, - {720, 480, 240, HDMI_SCAN_INTERLACED, "480i120"}, - {720, 480, 240, HDMI_SCAN_INTERLACED, "480i120H"}, - {1280, 720, 24, HDMI_SCAN_PROGRESSIVE, "720p24"}, - {1280, 720, 25, HDMI_SCAN_PROGRESSIVE, "720p25"}, - {1280, 720, 30, HDMI_SCAN_PROGRESSIVE, "720p30"}, - {1920, 1080, 120, HDMI_SCAN_PROGRESSIVE, "1080p120"} -}; - -const int NUM_SVD_ENTRIES = sizeof(svd_table)/sizeof(svd_table[0]); - -static unsigned int count_set_bits(uint16_t value) -{ - unsigned int count; - for (count = 0; value; count++) - value &= value - 1; - return count; -} - -static void set_s3d_format_bits(const uint8_t *edid_data, int off, int hdmi_3d_len, uint16_t *s3d_struct_bits) -{ - //These are 3D formats signaled through 2D VIC order and 3D_structure-3D_Detail - while (hdmi_3d_len > 0) { - unsigned int val = edid_data[off++] & 0x0F; - *s3d_struct_bits |= 1 << val; - //3D Detail_x is included for 3D_Structure_x range 0x8-0xF - if ( val >= HDMI_SIDE_BY_SIDE_HALF) { - hdmi_3d_len--; - off++; - } - hdmi_3d_len--; - } -} - -static void update_s3d_format(struct edid_t *edid, enum hdmi_3d_format format, - uint8_t vic_pos, enum hdmi_3d_subsampling subsamp) -{ - unsigned int format_ix, vic_pos_ix; - if (vic_pos > edid->num_svds) { - return; - } - - for (format_ix = 0; format_ix < edid->num_s3d_formats; format_ix++) { - if (edid->s3d_format_list[format_ix].format == format) { - break; - } - } - - if (format_ix >= edid->num_s3d_formats) { - return; - } - - //In case this has already been signaled, we'll update the subsampling mode - for (vic_pos_ix = 0; vic_pos_ix < edid->s3d_format_list[format_ix].num_valid_vic; vic_pos_ix++) { - if (edid->s3d_format_list[format_ix].vic_info[vic_pos_ix].vic_pos == vic_pos) { - break; - } - } - - if (vic_pos_ix >= edid->s3d_format_list[format_ix].num_valid_vic) { - vic_pos_ix = edid->s3d_format_list[format_ix].num_valid_vic; - edid->s3d_format_list[format_ix].num_valid_vic += 1; - } - - edid->s3d_format_list[format_ix].vic_info[vic_pos_ix].vic_pos = vic_pos; - edid->s3d_format_list[format_ix].vic_info[vic_pos_ix].subsampling = subsamp; -} - -/* This function was originally written by Mythri pk */ -static int edid_get_datablock_offset(const uint8_t *edid_data, enum datablock_id type, unsigned int *off) -{ - uint8_t val; - uint8_t ext_length; - uint8_t offset; - - //CEA extension signaled? If not, then no datablocks are contained - if (edid_data[0x7e] == 0x00) { - return 1; - } - - //18-byte descriptors only? Otherwise, there are datablocks present - ext_length = edid_data[0x82]; - if (ext_length == 0x4) { - return 1; - } - - //Start of first extended data block - offset = 0x84; - while (offset < (0x80 + ext_length)) { - val = edid_data[offset]; - //Upper 3 bits indicate block type - if ((val >> 5) == type) { - *off = offset; - return 0; - } else { - //lower 5 bits indicate block length - offset += (val & 0x1F) + 1; - } - } - return 1; -} - -static void edid_parse_s3d_support(struct edid_t *edid, const uint8_t *edid_data) -{ - unsigned int off; - unsigned int i, count; - uint8_t val; - uint8_t s3d_multi_present; - uint8_t hdmi_3d_len; - uint16_t s3d_struct_all = 0; - uint16_t s3d_struct_bits = 0; - uint16_t hdmi_vic_pos_bits = 0; - - //memset(edid->s3d_formats, 0, sizeof(edid->s3d_formats)); - - //S3D HDMI information is signaled in the Vendor Specific datablock - if(edid_get_datablock_offset(edid_data, DATABLOCK_VENDOR, &off)) - return; - - //Skip header and other non-S3D related fields - off += 8; - val = edid_data[off++]; - - //HDMI_Video_present? - if (!(val & 0x20)) { - return; - } - - //Latency_Fields_Present? Skip - if (val & 0x80) { - off += 2; - } - - //I_Latency_Fields_Present? Skip - if (val & 0x40) { - off += 2; - } - - val = edid_data[off++]; - //3D_Present? - if (!(val & 0x80)) { - return; - } - - edid->s3d_capable = true; - - s3d_multi_present = (val & 0x60) >> 5; - - //Skip HDMI_XX_LEN - val = edid_data[off++]; - off += (val & 0xE0) >> 5; - hdmi_3d_len = (val & 0x1F); - - //3D capabilities signaled through bitmasks - //s3d_struct_all has all the 3D formats supported (per bit) - //hdmi_vic_mask has which of the corresponding VIC codes the 3D formats apply to - //if s3d_multi_present = 1, then the 3D formats apply to all the first 16 VIC codes - if (s3d_multi_present == 1 || s3d_multi_present == 2) { - s3d_struct_all = (edid_data[off] << 8) | edid_data[off+1]; - hdmi_vic_pos_bits = 0xFFFF; - hdmi_3d_len -= 2; - off += 2; - } - - if (s3d_multi_present == 2) { - hdmi_vic_pos_bits = (edid_data[off] << 8) | edid_data[off+1]; - hdmi_3d_len -= 2; - off += 2; - } - - //Bit 15 signals same format as Bit 8 - HDMI_SIDE_BY_SIDE_HALF, they only differ in subsampling options - s3d_struct_bits = s3d_struct_all & 0x7FFF; - set_s3d_format_bits(edid_data, off, hdmi_3d_len, &s3d_struct_bits); - - edid->num_s3d_formats = count_set_bits(s3d_struct_bits); - edid->s3d_format_list = (struct hdmi_s3d_format_info_t *) malloc(edid->num_s3d_formats * sizeof(struct hdmi_s3d_format_info_t)); - - count = 0; - for (i = 0; i <= HDMI_SIDE_BY_SIDE_HALF; i++) { - if (s3d_struct_bits & (1 << i)) { - edid->s3d_format_list[count++].format = (enum hdmi_3d_format)i; - } - } - - for (i = 0; i < edid->num_s3d_formats; i++) { - unsigned int j; - enum hdmi_3d_subsampling subsampling; - if (edid->s3d_format_list[i].format == HDMI_SIDE_BY_SIDE_HALF) { - uint16_t bitmask = HDMI_SIDE_BY_SIDE_HALF_QUINCUNX_BIT | HDMI_SIDE_BY_SIDE_HALF_BIT; - if ( (s3d_struct_all & bitmask) == bitmask) { - subsampling = HDMI_SS_HORZANDQUINCUNX; - } else if ((s3d_struct_all & bitmask) == HDMI_SIDE_BY_SIDE_HALF_QUINCUNX_BIT) { - subsampling = HDMI_SS_QUINCUNX_ALL; - } else if ((s3d_struct_all & bitmask) == HDMI_SIDE_BY_SIDE_HALF_BIT) { - subsampling = HDMI_SS_HORIZONTAL; - } - } else if (edid->s3d_format_list[i].format == HDMI_TOPBOTTOM) { - subsampling = HDMI_SS_VERTICAL; - } else { - subsampling = HDMI_SS_NONE; - } - count = 0; - for (j = 0; j < 16; j++) { - if ((s3d_struct_all & (1 << edid->s3d_format_list[i].format)) && - (hdmi_vic_pos_bits & (1 << j))) { - edid->s3d_format_list[i].vic_info[count].subsampling = subsampling; - edid->s3d_format_list[i].vic_info[count++].vic_pos = j; - } - } - edid->s3d_format_list[i].num_valid_vic = count; - } - - //In this case, the 3D formats signaled only apply to the VIC codes signaled per bit - //i.e. bit0 = VIC code 0 from the Short video descriptors list - while (hdmi_3d_len > 0) { - //Upper 4 bits indicate vic position, lower 4 bits are the 3D structure value - enum hdmi_3d_subsampling subsampling = HDMI_SS_NONE; - uint8_t vic_pos = (edid_data[off] & 0xF0) >> 4; - enum hdmi_3d_format format = (enum hdmi_3d_format) (edid_data[off++] & 0x0F); - if (format >= HDMI_SIDE_BY_SIDE_HALF) { - subsampling = (enum hdmi_3d_subsampling)((edid_data[off++] & 0xF0) >> 4); - hdmi_3d_len--; - } - if (format == HDMI_TOPBOTTOM) { - subsampling = HDMI_SS_VERTICAL; - } - update_s3d_format(edid, format, vic_pos, subsampling); - hdmi_3d_len--; - } -} - -static void edid_fill_svd_info(uint8_t code, struct svd_info_t *info) -{ - if(code > NUM_SVD_ENTRIES) - code = 0; - memcpy(info, &svd_table[code], sizeof(struct svd_info_t)); -} - -static void edid_parse_svds(struct edid_t *edid, const uint8_t *raw_edid_data) -{ - unsigned int offset; - unsigned int i; - if (edid_get_datablock_offset(raw_edid_data, DATABLOCK_VIDEO, &offset)) { - edid->num_svds = 0; - edid->svd_list = NULL; - return ; - } - - edid->num_svds = raw_edid_data[offset] & 0x1F; - edid->svd_list = (struct svd_t *) malloc(edid->num_svds * sizeof(struct svd_t)); - for (i = 0; i < edid->num_svds; i++) { - struct svd_t *svd = &edid->svd_list[i]; - svd->code = raw_edid_data[offset + i] & 0x7F; - svd->native = (raw_edid_data[offset + i] & 0x80) == 0x80; - edid_fill_svd_info(svd->code, &svd->info); - } -} - -/*=======================================================*/ -int edid_parser_init(struct edid_t **edid_handle, const uint8_t *raw_edid_data) -{ - if(edid_handle == NULL) { - return -1; - } - - struct edid_t *edid = (struct edid_t *) malloc(sizeof(struct edid_t)); - if (edid == NULL) { - return -1; - } - - memset(edid, 0, sizeof(struct edid_t)); - edid_parse_svds(edid, raw_edid_data); - edid_parse_s3d_support(edid, raw_edid_data); - - *edid_handle = edid; - return 0; -} - -void edid_parser_deinit(struct edid_t *edid) -{ - free(edid->s3d_format_list); - free(edid->svd_list); - free(edid); -} - -bool edid_s3d_capable(struct edid_t *edid) -{ - return edid->s3d_capable; -} - -bool edid_supports_s3d_format(struct edid_t *edid, enum hdmi_3d_format format) -{ - unsigned int i; - for (i = 0; i < edid->num_s3d_formats; i++) { - if (edid->s3d_format_list[i].format == format) { - return true; - } - } - return false; -} - -const struct hdmi_s3d_format_info_t * edid_get_s3d_format_info(struct edid_t *edid, enum hdmi_3d_format format) -{ - unsigned int i; - for (i = 0; i < edid->num_s3d_formats; i++) { - if (edid->s3d_format_list[i].format == format) { - return &edid->s3d_format_list[i]; - } - } - return NULL; -} - -void edid_get_svd_list(struct edid_t *edid, struct svd_t **list, unsigned int *num_elements) -{ - if(list == NULL || num_elements == NULL) - return; - - *list = edid->svd_list; - *num_elements = edid->num_svds; -} - -const struct svd_t *edid_get_svd_descriptor(struct edid_t *edid, uint8_t vic_pos) -{ - if(vic_pos > edid->num_svds) - return NULL; - return &edid->svd_list[vic_pos]; -} diff --git a/edid/lib/edid_parser_priv.h b/edid/lib/edid_parser_priv.h deleted file mode 100755 index 69ba513..0000000 --- a/edid/lib/edid_parser_priv.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -struct hdmi_s3d_format_t { - bool supported; - struct hdmi_s3d_format_info_t f; -}; - -struct edid_t { - bool s3d_capable; - - unsigned int num_s3d_formats; - struct hdmi_s3d_format_info_t *s3d_format_list; - - unsigned int num_svds; - struct svd_t *svd_list; -}; diff --git a/hwc/Android.mk b/hwc/Android.mk deleted file mode 100755 index 3761813..0000000 --- a/hwc/Android.mk +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (C) Texas Instruments - http://www.ti.com/ -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -LOCAL_PATH := $(call my-dir) - -# HAL module implementation, not prelinked and stored in -# hw/..so -include $(CLEAR_VARS) -LOCAL_PRELINK_MODULE := false -LOCAL_ARM_MODE := arm -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/../vendor/lib/hw -LOCAL_SHARED_LIBRARIES := liblog libEGL libcutils libutils libhardware libhardware_legacy libz \ - libion_ti -LOCAL_SRC_FILES := hwc.c rgz_2d.c dock_image.c sw_vsync.c -LOCAL_STATIC_LIBRARIES := libpng - -LOCAL_MODULE_TAGS := optional - -LOCAL_MODULE := hwcomposer.$(TARGET_BOOTLOADER_BOARD_NAME) -LOCAL_CFLAGS := -DLOG_TAG=\"ti_hwc\" -LOCAL_C_INCLUDES += external/libpng external/zlib - -ifeq ($(TARGET_TI_HWC_HDMI_DISABLED),true) - LOCAL_CFLAGS += -DHDMI_DISABLED -endif - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/../edid/inc \ - $(LOCAL_PATH)/../include -LOCAL_SHARED_LIBRARIES += libedid - -# LOG_NDEBUG=0 means verbose logging enabled -# LOCAL_CFLAGS += -DLOG_NDEBUG=0 -include $(BUILD_SHARED_LIBRARY) diff --git a/hwc/dock_image.c b/hwc/dock_image.c deleted file mode 100755 index b74a17e..0000000 --- a/hwc/dock_image.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "hwc_dev.h" -#include "dock_image.h" - -static struct dock_image_state { - void *buffer; /* start of fb for hdmi */ - uint32_t buffer_size; /* size of fb for hdmi */ - - uint32_t max_width; - uint32_t max_height; - - image_info_t image; -} dock_image; - -static void free_png_image(image_info_t *img) -{ - memset(img, 0, sizeof(*img)); -} - -static int load_png_image(char *path, image_info_t *img) -{ - void *ptr = NULL; - png_bytepp row_pointers = NULL; - - FILE *fd = fopen(path, "rb"); - if (!fd) { - ALOGE("failed to open PNG file %s: (%d)", path, errno); - return -EINVAL; - } - - const int SIZE_PNG_HEADER = 8; - uint8_t header[SIZE_PNG_HEADER]; - fread(header, 1, SIZE_PNG_HEADER, fd); - if (png_sig_cmp(header, 0, SIZE_PNG_HEADER)) { - ALOGE("%s is not a PNG file", path); - goto fail; - } - - png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) - goto fail_alloc; - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - goto fail_alloc; - - if (setjmp(png_jmpbuf(png_ptr))) - goto fail_alloc; - - png_init_io(png_ptr, fd); - png_set_sig_bytes(png_ptr, SIZE_PNG_HEADER); - png_set_user_limits(png_ptr, dock_image.max_width, dock_image.max_height); - png_read_info(png_ptr, info_ptr); - - uint8_t bit_depth = png_get_bit_depth(png_ptr, info_ptr); - uint32_t width = png_get_image_width(png_ptr, info_ptr); - uint32_t height = png_get_image_height(png_ptr, info_ptr); - uint8_t color_type = png_get_color_type(png_ptr, info_ptr); - - switch (color_type) { - case PNG_COLOR_TYPE_PALETTE: - png_set_palette_to_rgb(png_ptr); - png_set_filler(png_ptr, 128, PNG_FILLER_AFTER); - break; - case PNG_COLOR_TYPE_GRAY: - if (bit_depth < 8) { - png_set_expand_gray_1_2_4_to_8(png_ptr); - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - png_set_tRNS_to_alpha(png_ptr); - } else { - png_set_filler(png_ptr, 128, PNG_FILLER_AFTER); - } - /* fall through */ - case PNG_COLOR_TYPE_GRAY_ALPHA: - png_set_gray_to_rgb(png_ptr); - break; - case PNG_COLOR_TYPE_RGB: - png_set_filler(png_ptr, 128, PNG_FILLER_AFTER); - /* fall through */ - case PNG_COLOR_TYPE_RGB_ALPHA: - png_set_bgr(png_ptr); - break; - default: - ALOGE("unsupported PNG color: %x", color_type); - goto fail_alloc; - } - - if (bit_depth == 16) - png_set_strip_16(png_ptr); - - const uint32_t bpp = 4; - img->size = ALIGN(width * height * bpp, 4096); - if ((uint32_t)img->size > dock_image.buffer_size) { - ALOGE("image does not fit into framebuffer area (%d > %d)", img->size, dock_image.buffer_size); - goto fail_alloc; - } - img->ptr = dock_image.buffer; - - row_pointers = calloc(height, sizeof(*row_pointers)); - if (!row_pointers) { - ALOGE("failed to allocate row pointers"); - goto fail_alloc; - } - uint32_t i; - for (i = 0; i < height; i++) - row_pointers[i] = img->ptr + i * width * bpp; - png_set_rows(png_ptr, info_ptr, row_pointers); - png_read_update_info(png_ptr, info_ptr); - img->rowbytes = png_get_rowbytes(png_ptr, info_ptr); - - png_read_image(png_ptr, row_pointers); - png_read_end(png_ptr, NULL); - free(row_pointers); - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - fclose(fd); - img->width = width; - img->height = height; - return 0; - -fail_alloc: - free_png_image(img); - free(row_pointers); - if (!png_ptr || !info_ptr) - ALOGE("failed to allocate PNG structures"); - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); -fail: - fclose(fd); - return -EINVAL; -} - -int init_dock_image(omap_hwc_device_t *hwc_dev, uint32_t max_width, uint32_t max_height) -{ - int err = 0; - - struct fb_fix_screeninfo fix; - if (ioctl(hwc_dev->fb_fd, FBIOGET_FSCREENINFO, &fix)) { - ALOGE("failed to get fb info (%d)", errno); - err = -errno; - goto done; - } - - dock_image.buffer_size = fix.smem_len; - dock_image.buffer = mmap(NULL, fix.smem_len, PROT_WRITE, MAP_SHARED, hwc_dev->fb_fd, 0); - if (dock_image.buffer == MAP_FAILED) { - ALOGE("failed to map fb memory"); - err = -errno; - goto done; - } - - dock_image.max_width = max_width; - dock_image.max_height = max_height; - - done: - return err; -} - -void load_dock_image() -{ - if (!dock_image.image.rowbytes) { - char value[PROPERTY_VALUE_MAX]; - property_get("persist.hwc.dock_image", value, "/vendor/res/images/dock/dock.png"); - load_png_image(value, &dock_image.image); - } -} - -image_info_t *get_dock_image() -{ - return &dock_image.image; -} - diff --git a/hwc/dock_image.h b/hwc/dock_image.h deleted file mode 100755 index 44a3271..0000000 --- a/hwc/dock_image.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DOCK_IMAGE__ -#define __DOCK_IMAGE__ - -#include - -/* ARGB image */ -struct image_info { - int width; - int height; - int rowbytes; - int size; - uint8_t *ptr; -}; -typedef struct image_info image_info_t; - -typedef struct omap_hwc_device omap_hwc_device_t; - -int init_dock_image(omap_hwc_device_t *hwc_dev, uint32_t max_width, uint32_t max_height); -void load_dock_image(); -image_info_t *get_dock_image(); - -#endif diff --git a/hwc/hal_public.h b/hwc/hal_public.h deleted file mode 100755 index a7dfb08..0000000 --- a/hwc/hal_public.h +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (c) Imagination Technologies Ltd. - * - * The contents of this file are subject to the MIT license as set out below. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef HAL_PUBLIC_H -#define HAL_PUBLIC_H - -/* Authors of third party hardware composer (HWC) modules will need to include - * this header to access functionality in the gralloc and framebuffer HALs. - */ - -#include - -#define ALIGN(x,a) (((x) + (a) - 1L) & ~((a) - 1L)) -#define HW_ALIGN 32 - -/* This can be tuned down as appropriate for the SOC. - * - * IMG formats are usually a single sub-alloc. - * Some OEM video formats are two sub-allocs (Y, UV planes). - * Future OEM video formats might be three sub-allocs (Y, U, V planes). - */ -#define MAX_SUB_ALLOCS 3 - -typedef struct -{ - native_handle_t base; - - /* These fields can be sent cross process. They are also valid - * to duplicate within the same process. - * - * A table is stored within psPrivateData on gralloc_module_t (this - * is obviously per-process) which maps stamps to a mapped - * PVRSRV_CLIENT_MEM_INFO in that process. Each map entry has a lock - * count associated with it, satisfying the requirements of the - * Android API. This also prevents us from leaking maps/allocations. - * - * This table has entries inserted either by alloc() - * (alloc_device_t) or map() (gralloc_module_t). Entries are removed - * by free() (alloc_device_t) and unmap() (gralloc_module_t). - * - * As a special case for framebuffer_device_t, framebuffer_open() - * will add and framebuffer_close() will remove from this table. - */ - -#define IMG_NATIVE_HANDLE_NUMFDS MAX_SUB_ALLOCS - /* The `fd' field is used to "export" a meminfo to another process. - * Therefore, it is allocated by alloc_device_t, and consumed by - * gralloc_module_t. The framebuffer_device_t does not need a handle, - * and the special value IMG_FRAMEBUFFER_FD is used instead. - */ - int fd[MAX_SUB_ALLOCS]; - -#define IMG_NATIVE_HANDLE_NUMINTS ((sizeof(unsigned long long) / sizeof(int)) + 5) - /* A KERNEL unique identifier for any exported kernel meminfo. Each - * exported kernel meminfo will have a unique stamp, but note that in - * userspace, several meminfos across multiple processes could have - * the same stamp. As the native_handle can be dup(2)'d, there could be - * multiple handles with the same stamp but different file descriptors. - */ - unsigned long long ui64Stamp; - - /* This is used for buffer usage validation when locking a buffer, - * and also in WSEGL (for the composition bypass feature). - */ - int usage; - - /* In order to do efficient cache flushes we need the buffer dimensions - * and format. These are available on the ANativeWindowBuffer, - * but the platform doesn't pass them down to the graphics HAL. - * - * These fields are also used in the composition bypass. In this - * capacity, these are the "real" values for the backing allocation. - */ - int iWidth; - int iHeight; - int iFormat; - unsigned int uiBpp; -} -__attribute__((aligned(sizeof(int)),packed)) IMG_native_handle_t; - -typedef struct -{ - framebuffer_device_t base; - - /* The HWC was loaded. post() is no longer responsible for presents */ - int bBypassPost; - - /* HWC path for present posts */ - int (*Post2)(framebuffer_device_t *fb, buffer_handle_t *buffers, - int num_buffers, void *data, int data_length); -} -IMG_framebuffer_device_public_t; - -typedef struct IMG_gralloc_module_public_t -{ - gralloc_module_t base; - - /* If the framebuffer has been opened, this will point to the - * framebuffer device data required by the allocator, WSEGL - * modules and composerhal. - */ - IMG_framebuffer_device_public_t *psFrameBufferDevice; - - int (*GetPhyAddrs)(struct IMG_gralloc_module_public_t const* module, - buffer_handle_t handle, - unsigned int auiPhyAddr[MAX_SUB_ALLOCS]); - - /* Custom-blit components in lieu of overlay hardware */ - int (*Blit)(struct IMG_gralloc_module_public_t const *module, - buffer_handle_t src, - void *dest[MAX_SUB_ALLOCS], int format); - - int (*Blit2)(struct IMG_gralloc_module_public_t const *module, - buffer_handle_t src, buffer_handle_t dest, - int w, int h, int x, int y); -} -IMG_gralloc_module_public_t; - -typedef struct -{ - int l, t, w, h; -} -IMG_write_lock_rect_t; - -typedef struct IMG_buffer_format_public_t -{ - /* Buffer formats are returned as a linked list */ - struct IMG_buffer_format_public_t *psNext; - - /* HAL_PIXEL_FORMAT_... enumerant */ - int iHalPixelFormat; - - /* WSEGL_PIXELFORMAT_... enumerant */ - int iWSEGLPixelFormat; - - /* Friendly name for format */ - const char *const szName; - - /* Bits (not bytes) per pixel */ - unsigned int uiBpp; - - /* GPU output format (creates EGLConfig for format) */ - int bGPURenderable; -} -IMG_buffer_format_public_t; - -/* - * These are vendor specific pixel formats, by (informal) convention IMGTec - * formats start from the top of the range, TI formats start from the bottom - */ -#define HAL_PIXEL_FORMAT_BGRX_8888 0x1FF -#define HAL_PIXEL_FORMAT_TI_NV12 0x100 -#define HAL_PIXEL_FORMAT_TI_UNUSED 0x101 /* Free for use */ -#define HAL_PIXEL_FORMAT_TI_NV12_1D 0x102 - -#ifndef GRALLOC_USAGE_SYSTEM_HEAP -#define GRALLOC_USAGE_SYSTEM_HEAP GRALLOC_USAGE_PRIVATE_0 -#else -#error GRALLOC_USAGE_SYSTEM_HEAP should only be defined by hal_public.h -#endif - -#ifndef GRALLOC_USAGE_PHYS_CONTIG -#define GRALLOC_USAGE_PHYS_CONTIG GRALLOC_USAGE_PRIVATE_1 -#else -#error GRALLOC_USAGE_PHYS_CONTIG should only be defined by hal_public.h -#endif -#endif /* HAL_PUBLIC_H */ - diff --git a/hwc/hwc.c b/hwc/hwc.c deleted file mode 100755 index 7cd1e3a..0000000 --- a/hwc/hwc.c +++ /dev/null @@ -1,2703 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#define HWC_REMOVE_DEPRECATED_VERSIONS 1 -#include -#include -#include -#include -#include -#include -#include -#ifdef OMAP_ENHANCEMENT_S3D -#include -#endif - -#include -#include -#include - -#include "hwc_dev.h" -#include "dock_image.h" -#include "sw_vsync.h" - -#define min(a, b) ( { typeof(a) __a = (a), __b = (b); __a < __b ? __a : __b; } ) -#define max(a, b) ( { typeof(a) __a = (a), __b = (b); __a > __b ? __a : __b; } ) -#define swap(a, b) do { typeof(a) __a = (a); (a) = (b); (b) = __a; } while (0) - -#define WIDTH(rect) ((rect).right - (rect).left) -#define HEIGHT(rect) ((rect).bottom - (rect).top) - -#define DIV_ROUND_UP(a, b) (((a) + (b) - 1) / (b)) - -#define MAX_HWC_LAYERS 32 -#define MAX_HW_OVERLAYS 4 -#define NUM_NONSCALING_OVERLAYS 1 -#define NUM_EXT_DISPLAY_BACK_BUFFERS 2 -#define ASPECT_RATIO_TOLERANCE 0.02f - -/* used by property settings */ -enum { - EXT_ROTATION = 3, /* rotation while mirroring */ - EXT_HFLIP = (1 << 2), /* flip l-r on output (after rotation) */ -}; - -#define HAL_FMT(f) ((f) == HAL_PIXEL_FORMAT_TI_NV12 ? "NV12" : \ - (f) == HAL_PIXEL_FORMAT_TI_NV12_1D ? "NV12" : \ - (f) == HAL_PIXEL_FORMAT_YV12 ? "YV12" : \ - (f) == HAL_PIXEL_FORMAT_BGRX_8888 ? "xRGB32" : \ - (f) == HAL_PIXEL_FORMAT_RGBX_8888 ? "xBGR32" : \ - (f) == HAL_PIXEL_FORMAT_BGRA_8888 ? "ARGB32" : \ - (f) == HAL_PIXEL_FORMAT_RGBA_8888 ? "ABGR32" : \ - (f) == HAL_PIXEL_FORMAT_RGB_565 ? "RGB565" : "??") - -#define DSS_FMT(f) ((f) == OMAP_DSS_COLOR_NV12 ? "NV12" : \ - (f) == OMAP_DSS_COLOR_RGB24U ? "xRGB32" : \ - (f) == OMAP_DSS_COLOR_ARGB32 ? "ARGB32" : \ - (f) == OMAP_DSS_COLOR_RGB16 ? "RGB565" : "??") - -static bool debug = false; -static bool debugpost2 = false; -static bool debugblt = false; -static rgz_t grgz; -static rgz_ext_layer_list_t grgz_ext_layer_list; -static struct bvsurfgeom gscrngeom; - -static void showfps(void) -{ - static int framecount = 0; - static int lastframecount = 0; - static nsecs_t lastfpstime = 0; - static float fps = 0; - char value[PROPERTY_VALUE_MAX]; - - property_get("debug.hwc.showfps", value, "0"); - if (!atoi(value)) { - return; - } - - framecount++; - if (!(framecount & 0x7)) { - nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC); - nsecs_t diff = now - lastfpstime; - fps = ((framecount - lastframecount) * (float)(s2ns(1))) / diff; - lastfpstime = now; - lastframecount = framecount; - ALOGI("%d Frames, %f FPS", framecount, fps); - } -} - -static void dump_layer(hwc_layer_1_t const* l) -{ - ALOGD("\ttype=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, {%d,%d,%d,%d}, {%d,%d,%d,%d}", - l->compositionType, l->flags, l->handle, l->transform, l->blending, - l->sourceCrop.left, - l->sourceCrop.top, - l->sourceCrop.right, - l->sourceCrop.bottom, - l->displayFrame.left, - l->displayFrame.top, - l->displayFrame.right, - l->displayFrame.bottom); -} - -static void dump_dsscomp(struct dsscomp_setup_dispc_data *d) -{ - uint32_t i; - - ALOGD("[%08x] set: %c%c%c %d ovls\n", - d->sync_id, - (d->mode & DSSCOMP_SETUP_MODE_APPLY) ? 'A' : '-', - (d->mode & DSSCOMP_SETUP_MODE_DISPLAY) ? 'D' : '-', - (d->mode & DSSCOMP_SETUP_MODE_CAPTURE) ? 'C' : '-', - d->num_ovls); - - for (i = 0; i < d->num_mgrs; i++) { - struct dss2_mgr_info *mi = &d->mgrs[i]; - ALOGD(" (dis%d alpha=%d col=%08x ilace=%d)\n", - mi->ix, - mi->alpha_blending, mi->default_color, - mi->interlaced); - } - - for (i = 0; i < d->num_ovls; i++) { - struct dss2_ovl_info *oi = &d->ovls[i]; - struct dss2_ovl_cfg *c = &oi->cfg; - if (c->zonly) - ALOGD("ovl%d(%s z%d)\n", - c->ix, c->enabled ? "ON" : "off", c->zorder); - else - ALOGD("ovl%d(%s z%d %s%s *%d%% %d*%d:%d,%d+%d,%d rot%d%s => %d,%d+%d,%d %p/%p|%d)\n", - c->ix, c->enabled ? "ON" : "off", c->zorder, DSS_FMT(c->color_mode), - c->pre_mult_alpha ? " premult" : "", - (c->global_alpha * 100 + 128) / 255, - c->width, c->height, c->crop.x, c->crop.y, - c->crop.w, c->crop.h, - c->rotation, c->mirror ? "+mir" : "", - c->win.x, c->win.y, c->win.w, c->win.h, - (void *) oi->ba, (void *) oi->uv, c->stride); - } -} - -struct dump_buf { - char *buf; - int buf_len; - int len; -}; - -static void dump_printf(struct dump_buf *buf, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - buf->len += vsnprintf(buf->buf + buf->len, buf->buf_len - buf->len, fmt, ap); - va_end(ap); -} - -static void dump_set_info(omap_hwc_device_t *hwc_dev, hwc_display_contents_1_t* list) -{ - struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; - char logbuf[1024]; - struct dump_buf log = { - .buf = logbuf, - .buf_len = sizeof(logbuf), - }; - uint32_t i; - - dump_printf(&log, "set H{"); - for (i = 0; list && i < list->numHwLayers; i++) { - if (i) - dump_printf(&log, " "); - hwc_layer_1_t *layer = &list->hwLayers[i]; - IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; - if (hwc_dev->post2_blit_buffers) { - if ((i + 1) < hwc_dev->post2_layers) - dump_printf(&log, "%p:%s,", handle, "DSS"); - else - dump_printf(&log, "%p:%s,", handle, "BV2D"); - } - else - dump_printf(&log, "%p:%s,", handle, layer->compositionType == HWC_OVERLAY ? "DSS" : "SGX"); - if ((layer->flags & HWC_SKIP_LAYER) || !handle) { - dump_printf(&log, "SKIP"); - continue; - } - if (layer->flags & HWC_HINT_CLEAR_FB) - dump_printf(&log, "CLR,"); - dump_printf(&log, "%d*%d(%s)", handle->iWidth, handle->iHeight, HAL_FMT(handle->iFormat)); - if (layer->transform) - dump_printf(&log, "~%d", layer->transform); - } - dump_printf(&log, "} D{"); - for (i = 0; i < dsscomp->num_ovls; i++) { - if (i) - dump_printf(&log, " "); - dump_printf(&log, "%d=", dsscomp->ovls[i].cfg.ix); - if (dsscomp->ovls[i].cfg.enabled) - dump_printf(&log, "%08x:%d*%d,%s", - dsscomp->ovls[i].ba, - dsscomp->ovls[i].cfg.width, - dsscomp->ovls[i].cfg.height, - DSS_FMT(dsscomp->ovls[i].cfg.color_mode)); - else - dump_printf(&log, "-"); - } - dump_printf(&log, "} L{"); - for (i = 0; i < hwc_dev->post2_layers; i++) { - if (i) - dump_printf(&log, " "); - dump_printf(&log, "%p", hwc_dev->buffers[i]); - } - if (hwc_dev->post2_blit_buffers) { - dump_printf(&log, "} B{"); - for (i = hwc_dev->post2_layers; - i < hwc_dev->post2_blit_buffers + hwc_dev->post2_layers; i++) { - dump_printf(&log, "%p ", hwc_dev->buffers[i]); - } - } - dump_printf(&log, "}%s\n", hwc_dev->use_sgx ? " swap" : ""); - - ALOGD("%s", log.buf); -} - -static int sync_id = 0; - -static bool is_valid_format(uint32_t format) -{ - switch(format) { - case HAL_PIXEL_FORMAT_RGB_565: - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_BGRA_8888: - case HAL_PIXEL_FORMAT_BGRX_8888: - case HAL_PIXEL_FORMAT_TI_NV12: - case HAL_PIXEL_FORMAT_TI_NV12_1D: - return true; - - default: - return false; - } -} -#ifdef OMAP_ENHANCEMENT_S3D -static uint32_t get_s3d_layout_type(hwc_layer_1_t *layer) -{ - return (layer->flags & S3DLayoutTypeMask) >> S3DLayoutTypeShift; -} - -static uint32_t get_s3d_layout_order(hwc_layer_1_t *layer) -{ - return (layer->flags & S3DLayoutOrderMask) >> S3DLayoutOrderShift; -} -#endif - -static bool scaled(hwc_layer_1_t *layer) -{ - int w = WIDTH(layer->sourceCrop); - int h = HEIGHT(layer->sourceCrop); - - if (layer->transform & HWC_TRANSFORM_ROT_90) - swap(w, h); - - bool res = WIDTH(layer->displayFrame) != w || HEIGHT(layer->displayFrame) != h; -#ifdef OMAP_ENHANCEMENT_S3D - /* An S3D layer also needs scaling due to subsampling */ - res = res || (get_s3d_layout_type(layer) != eMono); -#endif - - return res; -} - -static bool is_protected(hwc_layer_1_t *layer) -{ - IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; - - return (handle->usage & GRALLOC_USAGE_PROTECTED) != 0; -} - -#define is_BLENDED(layer) ((layer)->blending != HWC_BLENDING_NONE) - -static bool is_RGB(IMG_native_handle_t *handle) -{ - switch(handle->iFormat) - { - case HAL_PIXEL_FORMAT_BGRA_8888: - case HAL_PIXEL_FORMAT_BGRX_8888: - case HAL_PIXEL_FORMAT_RGB_565: - return true; - default: - return false; - } -} -static uint32_t get_format_bpp(uint32_t format) -{ - switch(format) { - case HAL_PIXEL_FORMAT_BGRA_8888: - case HAL_PIXEL_FORMAT_BGRX_8888: - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_RGBA_8888: - return 32; - case HAL_PIXEL_FORMAT_RGB_565: - return 16; - case HAL_PIXEL_FORMAT_TI_NV12: - case HAL_PIXEL_FORMAT_TI_NV12_1D: - return 8; - default: - return 0; - } -} - -static bool is_BGR_format(uint32_t format) -{ - switch (format) { - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_RGBA_8888: - return true; - default: - return false; - } -} - -static bool is_BGR(IMG_native_handle_t *handle) -{ - return is_BGR_format(handle->iFormat); -} - -static bool is_NV12(IMG_native_handle_t *handle) -{ - switch(handle->iFormat) - { - case HAL_PIXEL_FORMAT_TI_NV12: - case HAL_PIXEL_FORMAT_TI_NV12_1D: - return true; - default: - return false; - } -} - -static bool is_upscaled_NV12(omap_hwc_device_t *hwc_dev, hwc_layer_1_t *layer) -{ - if (!layer) - return false; - - IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; - if (!is_NV12(handle)) - return false; - - int w = WIDTH(layer->sourceCrop); - int h = HEIGHT(layer->sourceCrop); - - if (layer->transform & HWC_TRANSFORM_ROT_90) - swap(w, h); - - return (WIDTH(layer->displayFrame) >= w * hwc_dev->upscaled_nv12_limit || - HEIGHT(layer->displayFrame) >= h * hwc_dev->upscaled_nv12_limit); -} - -static bool dockable(hwc_layer_1_t *layer) -{ - IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; - - return (handle->usage & GRALLOC_USAGE_EXTERNAL_DISP) != 0; -} - -static uint32_t mem1d(IMG_native_handle_t *handle) -{ - if (handle == NULL || is_NV12(handle)) - return 0; - - int bpp = handle->iFormat == HAL_PIXEL_FORMAT_RGB_565 ? 2 : 4; - int stride = ALIGN(handle->iWidth, HW_ALIGN) * bpp; - return stride * handle->iHeight; -} - -static void setup_layer_base(struct dss2_ovl_cfg *oc, int index, uint32_t format, - bool blended, int width, int height) -{ - /* YUV2RGB conversion */ - const struct omap_dss_cconv_coefs ctbl_bt601_5 = { - 298, 409, 0, 298, -208, -100, 298, 0, 517, 0, - }; - - /* convert color format */ - switch (format) { - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_BGRA_8888: - oc->color_mode = OMAP_DSS_COLOR_ARGB32; - if (blended) - break; - - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_BGRX_8888: - oc->color_mode = OMAP_DSS_COLOR_RGB24U; - break; - - case HAL_PIXEL_FORMAT_RGB_565: - oc->color_mode = OMAP_DSS_COLOR_RGB16; - break; - - case HAL_PIXEL_FORMAT_TI_NV12: - case HAL_PIXEL_FORMAT_TI_NV12_1D: - oc->color_mode = OMAP_DSS_COLOR_NV12; - oc->cconv = ctbl_bt601_5; - break; - - default: - /* Should have been filtered out */ - ALOGV("Unsupported pixel format"); - return; - } - - oc->width = width; - oc->height = height; - oc->stride = ALIGN(width, HW_ALIGN) * get_format_bpp(format) / 8; - - oc->enabled = 1; - oc->global_alpha = 255; - oc->zorder = index; - oc->ix = 0; - - /* defaults for SGX framebuffer renders */ - oc->crop.w = oc->win.w = width; - oc->crop.h = oc->win.h = height; - - /* for now interlacing and vc1 info is not supplied */ - oc->ilace = OMAP_DSS_ILACE_NONE; - oc->vc1.enable = 0; -} - -static void setup_layer(omap_hwc_device_t *hwc_dev, struct dss2_ovl_info *ovl, - hwc_layer_1_t *layer, int index, uint32_t format, int width, int height) -{ - struct dss2_ovl_cfg *oc = &ovl->cfg; - - //dump_layer(layer); - - setup_layer_base(oc, index, format, is_BLENDED(layer), width, height); - - /* convert transformation - assuming 0-set config */ - if (layer->transform & HWC_TRANSFORM_FLIP_H) - oc->mirror = 1; - if (layer->transform & HWC_TRANSFORM_FLIP_V) { - oc->rotation = 2; - oc->mirror = !oc->mirror; - } - if (layer->transform & HWC_TRANSFORM_ROT_90) { - oc->rotation += oc->mirror ? -1 : 1; - oc->rotation &= 3; - } - - oc->pre_mult_alpha = layer->blending == HWC_BLENDING_PREMULT; - - /* display position */ - oc->win.x = layer->displayFrame.left; - oc->win.y = layer->displayFrame.top; - oc->win.w = WIDTH(layer->displayFrame); - oc->win.h = HEIGHT(layer->displayFrame); - - /* crop */ - oc->crop.x = layer->sourceCrop.left; - oc->crop.y = layer->sourceCrop.top; - oc->crop.w = WIDTH(layer->sourceCrop); - oc->crop.h = HEIGHT(layer->sourceCrop); -} - -const float m_unit[2][3] = { { 1., 0., 0. }, { 0., 1., 0. } }; - -static inline void m_translate(float m[2][3], float dx, float dy) -{ - m[0][2] += dx; - m[1][2] += dy; -} - -static inline void m_scale1(float m[3], int from, int to) -{ - m[0] = m[0] * to / from; - m[1] = m[1] * to / from; - m[2] = m[2] * to / from; -} - -static inline void m_scale(float m[2][3], int x_from, int x_to, int y_from, int y_to) -{ - m_scale1(m[0], x_from, x_to); - m_scale1(m[1], y_from, y_to); -} - -static void m_rotate(float m[2][3], int quarter_turns) -{ - if (quarter_turns & 2) - m_scale(m, 1, -1, 1, -1); - if (quarter_turns & 1) { - float q; - q = m[0][0]; m[0][0] = -m[1][0]; m[1][0] = q; - q = m[0][1]; m[0][1] = -m[1][1]; m[1][1] = q; - q = m[0][2]; m[0][2] = -m[1][2]; m[1][2] = q; - } -} - -static inline int m_round(float x) -{ - /* int truncates towards 0 */ - return (int) (x < 0 ? x - 0.5 : x + 0.5); -} - -/* - * assuming xpy (xratio:yratio) original pixel ratio, calculate the adjusted width - * and height for a screen of xres/yres and physical size of width/height. - * The adjusted size is the largest that fits into the screen. - */ -static void get_max_dimensions(uint32_t orig_xres, uint32_t orig_yres, - float xpy, - uint32_t scr_xres, uint32_t scr_yres, - uint32_t scr_width, uint32_t scr_height, - uint32_t *adj_xres, uint32_t *adj_yres) -{ - /* assume full screen (largest size)*/ - *adj_xres = scr_xres; - *adj_yres = scr_yres; - - /* assume 1:1 pixel ratios if none supplied */ - if (!scr_width || !scr_height) { - scr_width = scr_xres; - scr_height = scr_yres; - } - - /* trim to keep aspect ratio */ - float x_factor = orig_xres * xpy * scr_height; - float y_factor = orig_yres * scr_width; - - /* allow for tolerance so we avoid scaling if framebuffer is standard size */ - if (x_factor < y_factor * (1.f - ASPECT_RATIO_TOLERANCE)) - *adj_xres = (uint32_t) (x_factor * *adj_xres / y_factor + 0.5); - else if (x_factor * (1.f - ASPECT_RATIO_TOLERANCE) > y_factor) - *adj_yres = (uint32_t) (y_factor * *adj_yres / x_factor + 0.5); -} - -static void set_ext_matrix(omap_hwc_ext_t *ext, struct hwc_rect region) -{ - int orig_w = WIDTH(region); - int orig_h = HEIGHT(region); - float xpy = ext->lcd_xpy; - - /* reorientation matrix is: - m = (center-from-target-center) * (scale-to-target) * (mirror) * (rotate) * (center-to-original-center) */ - - memcpy(ext->m, m_unit, sizeof(m_unit)); - m_translate(ext->m, -(orig_w / 2.0f) - region.left, -(orig_h / 2.0f) - region.top); - m_rotate(ext->m, ext->current.rotation); - if (ext->current.hflip) - m_scale(ext->m, 1, -1, 1, 1); - - if (ext->current.rotation & 1) { - swap(orig_w, orig_h); - xpy = 1. / xpy; - } - - /* get target size */ - uint32_t adj_xres, adj_yres; - get_max_dimensions(orig_w, orig_h, xpy, - ext->xres, ext->yres, ext->width, ext->height, - &adj_xres, &adj_yres); - - m_scale(ext->m, orig_w, adj_xres, orig_h, adj_yres); - m_translate(ext->m, ext->xres >> 1, ext->yres >> 1); -} - -static int -crop_to_rect(struct dss2_ovl_cfg *cfg, struct hwc_rect vis_rect) -{ - struct { - int xy[2]; - int wh[2]; - } crop, win; - struct { - int lt[2]; - int rb[2]; - } vis; - win.xy[0] = cfg->win.x; win.xy[1] = cfg->win.y; - win.wh[0] = cfg->win.w; win.wh[1] = cfg->win.h; - crop.xy[0] = cfg->crop.x; crop.xy[1] = cfg->crop.y; - crop.wh[0] = cfg->crop.w; crop.wh[1] = cfg->crop.h; - vis.lt[0] = vis_rect.left; vis.lt[1] = vis_rect.top; - vis.rb[0] = vis_rect.right; vis.rb[1] = vis_rect.bottom; - - int c; - bool swap = cfg->rotation & 1; - - /* align crop window with display coordinates */ - if (swap) - crop.xy[1] -= (crop.wh[1] = -crop.wh[1]); - if (cfg->rotation & 2) - crop.xy[!swap] -= (crop.wh[!swap] = -crop.wh[!swap]); - if ((!cfg->mirror) ^ !(cfg->rotation & 2)) - crop.xy[swap] -= (crop.wh[swap] = -crop.wh[swap]); - - for (c = 0; c < 2; c++) { - /* see if complete buffer is outside the vis or it is - fully cropped or scaled to 0 */ - if (win.wh[c] <= 0 || vis.rb[c] <= vis.lt[c] || - win.xy[c] + win.wh[c] <= vis.lt[c] || - win.xy[c] >= vis.rb[c] || - !crop.wh[c ^ swap]) - return -ENOENT; - - /* crop left/top */ - if (win.xy[c] < vis.lt[c]) { - /* correction term */ - int a = (vis.lt[c] - win.xy[c]) * crop.wh[c ^ swap] / win.wh[c]; - crop.xy[c ^ swap] += a; - crop.wh[c ^ swap] -= a; - win.wh[c] -= vis.lt[c] - win.xy[c]; - win.xy[c] = vis.lt[c]; - } - /* crop right/bottom */ - if (win.xy[c] + win.wh[c] > vis.rb[c]) { - crop.wh[c ^ swap] = crop.wh[c ^ swap] * (vis.rb[c] - win.xy[c]) / win.wh[c]; - win.wh[c] = vis.rb[c] - win.xy[c]; - } - - if (!crop.wh[c ^ swap] || !win.wh[c]) - return -ENOENT; - } - - /* realign crop window to buffer coordinates */ - if (cfg->rotation & 2) - crop.xy[!swap] -= (crop.wh[!swap] = -crop.wh[!swap]); - if ((!cfg->mirror) ^ !(cfg->rotation & 2)) - crop.xy[swap] -= (crop.wh[swap] = -crop.wh[swap]); - if (swap) - crop.xy[1] -= (crop.wh[1] = -crop.wh[1]); - - cfg->win.x = win.xy[0]; cfg->win.y = win.xy[1]; - cfg->win.w = win.wh[0]; cfg->win.h = win.wh[1]; - cfg->crop.x = crop.xy[0]; cfg->crop.y = crop.xy[1]; - cfg->crop.w = crop.wh[0]; cfg->crop.h = crop.wh[1]; - - return 0; -} - -static void apply_transform(float transform[2][3],struct dss2_ovl_cfg *oc) -{ - float x, y, w, h; - - /* display position */ - x = transform[0][0] * oc->win.x + transform[0][1] * oc->win.y + transform[0][2]; - y = transform[1][0] * oc->win.x + transform[1][1] * oc->win.y + transform[1][2]; - w = transform[0][0] * oc->win.w + transform[0][1] * oc->win.h; - h = transform[1][0] * oc->win.w + transform[1][1] * oc->win.h; - oc->win.x = m_round(w > 0 ? x : x + w); - oc->win.y = m_round(h > 0 ? y : y + h); - oc->win.w = m_round(w > 0 ? w : -w); - oc->win.h = m_round(h > 0 ? h : -h); -} - -static void adjust_ext_layer(omap_hwc_ext_t *ext, struct dss2_ovl_info *ovl) -{ - struct dss2_ovl_cfg *oc = &ovl->cfg; - - /* crop to clone region if mirroring */ - if (!ext->current.docking && - crop_to_rect(&ovl->cfg, ext->mirror_region) != 0) { - ovl->cfg.enabled = 0; - return; - } - - apply_transform(ext->m, oc); - - /* combining transformations: F^a*R^b*F^i*R^j = F^(a+b)*R^(j+b*(-1)^i), because F*R = R^(-1)*F */ - oc->rotation += (oc->mirror ? -1 : 1) * ext->current.rotation; - oc->rotation &= 3; - if (ext->current.hflip) - oc->mirror = !oc->mirror; -} - -static struct dsscomp_platform_info limits; - -static void adjust_primary_display_layer(omap_hwc_device_t *hwc_dev, struct dss2_ovl_info *ovl) -{ - struct dss2_ovl_cfg *oc = &ovl->cfg; - - if (crop_to_rect(&ovl->cfg, hwc_dev->primary_region) != 0) { - ovl->cfg.enabled = 0; - return; - } - - apply_transform(hwc_dev->primary_m, oc); - - /* combining transformations: F^a*R^b*F^i*R^j = F^(a+b)*R^(j+b*(-1)^i), because F*R = R^(-1)*F */ - oc->rotation += (oc->mirror ? -1 : 1) * hwc_dev->primary_rotation; - oc->rotation &= 3; -} - -static bool can_scale(uint32_t src_w, uint32_t src_h, uint32_t dst_w, uint32_t dst_h, bool is_2d, - struct dsscomp_display_info *dis, struct dsscomp_platform_info *limits, - uint32_t pclk, IMG_native_handle_t *handle) -{ - uint32_t fclk = limits->fclk / 1000; - uint32_t min_src_w = DIV_ROUND_UP(src_w, is_2d ? limits->max_xdecim_2d : limits->max_xdecim_1d); - uint32_t min_src_h = DIV_ROUND_UP(src_h, is_2d ? limits->max_ydecim_2d : limits->max_ydecim_1d); - - /* ERRATAs */ - /* cannot render 1-width layers on DSI video mode panels - we just disallow all 1-width LCD layers */ - if (dis->channel != OMAP_DSS_CHANNEL_DIGIT && dst_w < limits->min_width) - return false; - - /* NOTE: no support for checking YUV422 layers that are tricky to scale */ - - /* FIXME: limit vertical downscale well below theoretical limit as we saw display artifacts */ - if (dst_h < src_h / 4) - return false; - - /* max downscale */ - if (dst_h * limits->max_downscale < min_src_h) - return false; - - /* for manual panels pclk is 0, and there are no pclk based scaling limits */ - if (!pclk) - return !(dst_w < src_w / limits->max_downscale / (is_2d ? limits->max_xdecim_2d : limits->max_xdecim_1d)); - - /* :HACK: limit horizontal downscale well below theoretical limit as we saw display artifacts */ - if (dst_w * 4 < src_w) - return false; - - if (handle) - if (get_format_bpp(handle->iFormat) == 32 && src_w > 1280 && dst_w * 3 < src_w) - return false; - - /* max horizontal downscale is 4, or the fclk/pixclk */ - if (fclk > pclk * limits->max_downscale) - fclk = pclk * limits->max_downscale; - /* for small parts, we need to use integer fclk/pixclk */ - if (src_w < limits->integer_scale_ratio_limit) - fclk = fclk / pclk * pclk; - if ((uint32_t) dst_w * fclk < min_src_w * pclk) - return false; - - return true; -} - -static bool can_scale_layer(omap_hwc_device_t *hwc_dev, hwc_layer_1_t *layer, IMG_native_handle_t *handle) -{ - int src_w = WIDTH(layer->sourceCrop); - int src_h = HEIGHT(layer->sourceCrop); - int dst_w = WIDTH(layer->displayFrame); - int dst_h = HEIGHT(layer->displayFrame); - - /* account for 90-degree rotation */ - if (layer->transform & HWC_TRANSFORM_ROT_90) - swap(src_w, src_h); - - /* NOTE: layers should be able to be scaled externally since - framebuffer is able to be scaled on selected external resolution */ - return can_scale(src_w, src_h, dst_w, dst_h, is_NV12(handle), &hwc_dev->fb_dis, &limits, - hwc_dev->fb_dis.timings.pixel_clock, handle); -} - -static bool is_valid_layer(omap_hwc_device_t *hwc_dev, hwc_layer_1_t *layer, IMG_native_handle_t *handle) -{ - /* Skip layers are handled by SF */ - if ((layer->flags & HWC_SKIP_LAYER) || !handle) - return false; - - if (!is_valid_format(handle->iFormat)) - return false; - - /* 1D buffers: no transform, must fit in TILER slot */ - if (!is_NV12(handle)) { - if (layer->transform) - return false; - if (mem1d(handle) > limits.tiler1d_slot_size) - return false; - } - - return can_scale_layer(hwc_dev, layer, handle); -} - -static uint32_t add_scaling_score(uint32_t score, - uint32_t xres, uint32_t yres, uint32_t refresh, - uint32_t ext_xres, uint32_t ext_yres, - uint32_t mode_xres, uint32_t mode_yres, uint32_t mode_refresh) -{ - uint32_t area = xres * yres; - uint32_t ext_area = ext_xres * ext_yres; - uint32_t mode_area = mode_xres * mode_yres; - - /* prefer to upscale (1% tolerance) [0..1] (insert after 1st bit) */ - int upscale = (ext_xres >= xres * 99 / 100 && ext_yres >= yres * 99 / 100); - score = (((score & ~1) | upscale) << 1) | (score & 1); - - /* pick minimum scaling [0..16] */ - if (ext_area > area) - score = (score << 5) | (16 * area / ext_area); - else - score = (score << 5) | (16 * ext_area / area); - - /* pick smallest leftover area [0..16] */ - score = (score << 5) | ((16 * ext_area + (mode_area >> 1)) / mode_area); - - /* adjust mode refresh rate */ - mode_refresh += mode_refresh % 6 == 5; - - /* prefer same or higher frame rate */ - upscale = (mode_refresh >= refresh); - score = (score << 1) | upscale; - - /* pick closest frame rate */ - if (mode_refresh > refresh) - score = (score << 8) | (240 * refresh / mode_refresh); - else - score = (score << 8) | (240 * mode_refresh / refresh); - - return score; -} - -static int set_best_hdmi_mode(omap_hwc_device_t *hwc_dev, uint32_t xres, uint32_t yres, float xpy) -{ - int dis_ix = hwc_dev->on_tv ? 0 : 1; - struct _qdis { - struct dsscomp_display_info dis; - struct dsscomp_videomode modedb[32]; - } d = { .dis = { .ix = dis_ix } }; - omap_hwc_ext_t *ext = &hwc_dev->ext; - - d.dis.modedb_len = sizeof(d.modedb) / sizeof(*d.modedb); - int ret = ioctl(hwc_dev->dsscomp_fd, DSSCIOC_QUERY_DISPLAY, &d); - if (ret) - return ret; - - if (d.dis.timings.x_res * d.dis.timings.y_res == 0 || - xres * yres == 0) - return -EINVAL; - - uint32_t i, best = ~0, best_score = 0; - ext->width = d.dis.width_in_mm; - ext->height = d.dis.height_in_mm; - ext->xres = d.dis.timings.x_res; - ext->yres = d.dis.timings.y_res; - - /* use VGA external resolution as default */ - if (!ext->xres || !ext->yres) { - ext->xres = 640; - ext->yres = 480; - } - - uint32_t ext_fb_xres, ext_fb_yres; - for (i = 0; i < d.dis.modedb_len; i++) { - uint32_t score = 0; - uint32_t mode_xres = d.modedb[i].xres; - uint32_t mode_yres = d.modedb[i].yres; - uint32_t ext_width = d.dis.width_in_mm; - uint32_t ext_height = d.dis.height_in_mm; - - if (d.modedb[i].vmode & FB_VMODE_INTERLACED) - mode_yres /= 2; - - if (d.modedb[i].flag & FB_FLAG_RATIO_4_3) { - ext_width = 4; - ext_height = 3; - } else if (d.modedb[i].flag & FB_FLAG_RATIO_16_9) { - ext_width = 16; - ext_height = 9; - } - - if (!mode_xres || !mode_yres) - continue; - - get_max_dimensions(xres, yres, xpy, mode_xres, mode_yres, - ext_width, ext_height, &ext_fb_xres, &ext_fb_yres); - - /* we need to ensure that even TILER2D buffers can be scaled */ - if (!d.modedb[i].pixclock || - (d.modedb[i].vmode & ~FB_VMODE_INTERLACED) || - !can_scale(xres, yres, ext_fb_xres, ext_fb_yres, - 1, &d.dis, &limits, - 1000000000 / d.modedb[i].pixclock, NULL)) - continue; - - /* prefer CEA modes */ - if (d.modedb[i].flag & (FB_FLAG_RATIO_4_3 | FB_FLAG_RATIO_16_9)) - score = 1; - - /* prefer the same mode as we use for mirroring to avoid mode change */ - score = (score << 1) | (i == ~ext->mirror_mode && ext->avoid_mode_change); - - score = add_scaling_score(score, xres, yres, 60, ext_fb_xres, ext_fb_yres, - mode_xres, mode_yres, d.modedb[i].refresh ? : 1); - - ALOGD("#%d: %dx%d %dHz", i, mode_xres, mode_yres, d.modedb[i].refresh); - if (debug) - ALOGD(" score=0x%x adj.res=%dx%d", score, ext_fb_xres, ext_fb_yres); - if (best_score < score) { - ext->width = ext_width; - ext->height = ext_height; - ext->xres = mode_xres; - ext->yres = mode_yres; - best = i; - best_score = score; - } - } - if (~best) { - struct dsscomp_setup_display_data sdis = { .ix = dis_ix }; - sdis.mode = d.dis.modedb[best]; - ALOGD("picking #%d", best); - /* only reconfigure on change */ - if (ext->last_mode != ~best) - ioctl(hwc_dev->dsscomp_fd, DSSCIOC_SETUP_DISPLAY, &sdis); - ext->last_mode = ~best; - } else { - uint32_t ext_width = d.dis.width_in_mm; - uint32_t ext_height = d.dis.height_in_mm; - uint32_t ext_fb_xres, ext_fb_yres; - - get_max_dimensions(xres, yres, xpy, d.dis.timings.x_res, d.dis.timings.y_res, - ext_width, ext_height, &ext_fb_xres, &ext_fb_yres); - if (!d.dis.timings.pixel_clock || - !can_scale(xres, yres, ext_fb_xres, ext_fb_yres, - 1, &d.dis, &limits, - d.dis.timings.pixel_clock, NULL)) { - ALOGW("DSS scaler cannot support HDMI cloning"); - return -1; - } - } - ext->last_xres_used = xres; - ext->last_yres_used = yres; - ext->last_xpy = xpy; - if (d.dis.channel == OMAP_DSS_CHANNEL_DIGIT) - ext->on_tv = 1; - return 0; -} - -static void gather_layer_statistics(omap_hwc_device_t *hwc_dev, hwc_display_contents_1_t *list) -{ - uint32_t i; - counts_t *num = &hwc_dev->counts; - - memset(num, 0, sizeof(*num)); - - num->composited_layers = list ? list->numHwLayers : 0; - - /* Figure out how many layers we can support via DSS */ - for (i = 0; list && i < list->numHwLayers; i++) { - hwc_layer_1_t *layer = &list->hwLayers[i]; - IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; -#ifdef OMAP_ENHANCEMENT_S3D - uint32_t s3d_layout_type = get_s3d_layout_type(layer); -#endif - - layer->compositionType = HWC_FRAMEBUFFER; - - if (is_valid_layer(hwc_dev, layer, handle)) { -#ifdef OMAP_ENHANCEMENT_S3D - if (s3d_layout_type != eMono) { - /* For now we can only handle 1 S3D layer, skip any additional ones */ - if (num->s3d > 0 || !hwc_dev->ext.dock.enabled || !hwc_dev->ext.s3d_capable) { - layer->flags |= HWC_SKIP_LAYER; - continue; - } else if (num->s3d == 0) { - /* For now, S3D layer is made a dockable layer to trigger docking logic. */ - if (!dockable(layer)) { - num->dockable++; - } - num->s3d++; - hwc_dev->s3d_input_type = s3d_layout_type; - hwc_dev->s3d_input_order = get_s3d_layout_order(layer); - } - } -#endif - num->possible_overlay_layers++; - - /* NV12 layers can only be rendered on scaling overlays */ - if (scaled(layer) || is_NV12(handle) || hwc_dev->primary_transform) - num->scaled_layers++; - - if (is_BGR(handle)) - num->BGR++; - else if (is_RGB(handle)) - num->RGB++; - else if (is_NV12(handle)) - num->NV12++; - - if (dockable(layer)) - num->dockable++; - - if (is_protected(layer)) - num->protected++; - - num->mem += mem1d(handle); - } - } -} - -static void decide_supported_cloning(omap_hwc_device_t *hwc_dev) -{ - omap_hwc_ext_t *ext = &hwc_dev->ext; - counts_t *num = &hwc_dev->counts; - int nonscaling_ovls = NUM_NONSCALING_OVERLAYS; - num->max_hw_overlays = MAX_HW_OVERLAYS; - - /* - * We cannot atomically switch overlays from one display to another. First, they - * have to be disabled, and the disabling has to take effect on the current display. - * We keep track of the available number of overlays here. - */ - if (ext->dock.enabled && !(ext->mirror.enabled && !(num->dockable || ext->force_dock))) { - /* some overlays may already be used by the external display, so we account for this */ - - /* reserve just a video pipeline for HDMI if docking */ - hwc_dev->ext_ovls = (num->dockable || ext->force_dock) ? 1 : 0; -#ifdef OMAP_ENHANCEMENT_S3D - if (num->s3d && (hwc_dev->ext.s3d_type != hwc_dev->s3d_input_type)) { - /* S3D layers are dockable, and they need two overlays */ - hwc_dev->ext_ovls += 1; - } -#endif - num->max_hw_overlays -= max(hwc_dev->ext_ovls, hwc_dev->last_ext_ovls); - - /* use mirroring transform if we are auto-switching to docking mode while mirroring*/ - if (ext->mirror.enabled) { - ext->current = ext->mirror; - ext->current.docking = 1; - } else { - ext->current = ext->dock; - } - } else if (ext->mirror.enabled) { - /* - * otherwise, manage just from half the pipelines. NOTE: there is - * no danger of having used too many overlays for external display here. - */ - num->max_hw_overlays >>= 1; - nonscaling_ovls >>= 1; - hwc_dev->ext_ovls = MAX_HW_OVERLAYS - num->max_hw_overlays; - ext->current = ext->mirror; - } else { - num->max_hw_overlays -= hwc_dev->last_ext_ovls; - hwc_dev->ext_ovls = 0; - ext->current.enabled = 0; - } - - /* - * :TRICKY: We may not have enough overlays on the external display. We "reserve" them - * here to figure out if mirroring is supported, but may not do mirroring for the first - * frame while the overlays required for it are cleared. - */ - hwc_dev->ext_ovls_wanted = hwc_dev->ext_ovls; - hwc_dev->ext_ovls = min(MAX_HW_OVERLAYS - hwc_dev->last_int_ovls, hwc_dev->ext_ovls); - - /* if mirroring, we are limited by both internal and external overlays. However, - ext_ovls is always <= MAX_HW_OVERLAYS / 2 <= max_hw_overlays */ - if (!num->protected && hwc_dev->ext_ovls && ext->current.enabled && !ext->current.docking) - num->max_hw_overlays = hwc_dev->ext_ovls; - - /* If FB is not same resolution as LCD don't use GFX pipe line*/ - if (hwc_dev->primary_transform) { - num->max_hw_overlays -= NUM_NONSCALING_OVERLAYS; - num->max_scaling_overlays = num->max_hw_overlays; - } else - num->max_scaling_overlays = num->max_hw_overlays - nonscaling_ovls; -} - -static bool can_dss_render_all(omap_hwc_device_t *hwc_dev) -{ - omap_hwc_ext_t *ext = &hwc_dev->ext; - counts_t *num = &hwc_dev->counts; - bool on_tv = hwc_dev->on_tv || (ext->on_tv && ext->current.enabled); - bool tform = ext->current.enabled && (ext->current.rotation || ext->current.hflip); - - return !hwc_dev->force_sgx && - /* must have at least one layer if using composition bypass to get sync object */ - num->possible_overlay_layers && - num->possible_overlay_layers <= num->max_hw_overlays && - num->possible_overlay_layers == num->composited_layers && - num->scaled_layers <= num->max_scaling_overlays && - num->NV12 <= num->max_scaling_overlays && - /* fits into TILER slot */ - num->mem <= limits.tiler1d_slot_size && - /* we cannot clone non-NV12 transformed layers */ - (!tform || (num->NV12 == num->possible_overlay_layers) || - (num->NV12 && ext->current.docking)) && - /* HDMI cannot display BGR */ - (num->BGR == 0 || (num->RGB == 0 && !on_tv) || !hwc_dev->flags_rgb_order) && - /* If nv12_only flag is set DSS should only render NV12 */ - (!hwc_dev->flags_nv12_only || (num->BGR == 0 && num->RGB == 0)); -} - -static inline bool can_dss_render_layer(omap_hwc_device_t *hwc_dev, hwc_layer_1_t *layer) -{ - IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; - - omap_hwc_ext_t *ext = &hwc_dev->ext; - bool cloning = ext->current.enabled && (!ext->current.docking || (handle!=NULL ? dockable(layer) : 0)); - bool on_tv = hwc_dev->on_tv || (ext->on_tv && cloning); - bool tform = cloning && (ext->current.rotation || ext->current.hflip); - - return is_valid_layer(hwc_dev, layer, handle) && - /* cannot rotate non-NV12 layers on external display */ - (!tform || is_NV12(handle)) && - /* skip non-NV12 layers if also using SGX (if nv12_only flag is set) */ - (!hwc_dev->flags_nv12_only || (!hwc_dev->use_sgx || is_NV12(handle))) && - /* make sure RGB ordering is consistent (if rgb_order flag is set) */ - (!(hwc_dev->swap_rb ? is_RGB(handle) : is_BGR(handle)) || - !hwc_dev->flags_rgb_order) && - /* TV can only render RGB */ - !(on_tv && is_BGR(handle)); -} - -static inline int display_area(struct dss2_ovl_info *o) -{ - return o->cfg.win.w * o->cfg.win.h; -} - -static int clone_layer(omap_hwc_device_t *hwc_dev, int ix) { - struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; - omap_hwc_ext_t *ext = &hwc_dev->ext; - int ext_ovl_ix = dsscomp->num_ovls - hwc_dev->post2_layers; - struct dss2_ovl_info *o = &dsscomp->ovls[dsscomp->num_ovls]; - - if (dsscomp->num_ovls >= MAX_HW_OVERLAYS) { - ALOGE("**** cannot clone layer #%d. using all %d overlays.", ix, dsscomp->num_ovls); - return -EBUSY; - } - - memcpy(o, dsscomp->ovls + ix, sizeof(*o)); - - /* reserve overlays at end for other display */ - o->cfg.ix = MAX_HW_OVERLAYS - 1 - ext_ovl_ix; - o->cfg.mgr_ix = 1; - /* - * Here the assumption is that overlay0 is the one attached to FB. - * Hence this clone_layer call is for FB cloning (provided use_sgx is true). - */ - /* For the external displays whose transform is the same as - * that of primary display, ion_handles would be NULL hence - * the below logic doesn't execute. - */ - if (ix == 0 && hwc_dev->ion_handles[sync_id%2] && hwc_dev->use_sgx) { - o->addressing = OMAP_DSS_BUFADDR_ION; - o->ba = (int)hwc_dev->ion_handles[sync_id%2]; - } else { - o->addressing = OMAP_DSS_BUFADDR_OVL_IX; - o->ba = ix; - } - - /* use distinct z values (to simplify z-order checking) */ - o->cfg.zorder += hwc_dev->post2_layers; - - adjust_ext_layer(&hwc_dev->ext, o); - dsscomp->num_ovls++; - return 0; -} - -static int clone_external_layer(omap_hwc_device_t *hwc_dev, int ix) { - struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; - omap_hwc_ext_t *ext = &hwc_dev->ext; - - /* mirror only 1 external layer */ - struct dss2_ovl_info *o = &dsscomp->ovls[ix]; - - /* full screen video after transformation */ - uint32_t xres = o->cfg.crop.w, yres = o->cfg.crop.h; - if ((ext->current.rotation + o->cfg.rotation) & 1) - swap(xres, yres); - float xpy = ext->lcd_xpy * o->cfg.win.w / o->cfg.win.h; - if (o->cfg.rotation & 1) - xpy = o->cfg.crop.h / xpy / o->cfg.crop.w; - else - xpy = o->cfg.crop.h * xpy / o->cfg.crop.w; - if (ext->current.rotation & 1) - xpy = 1. / xpy; - - /* adjust hdmi mode based on resolution */ - if (xres != ext->last_xres_used || - yres != ext->last_yres_used || - xpy < ext->last_xpy * (1.f - ASPECT_RATIO_TOLERANCE) || - xpy * (1.f - ASPECT_RATIO_TOLERANCE) > ext->last_xpy) { - ALOGD("set up HDMI for %d*%d\n", xres, yres); - if (set_best_hdmi_mode(hwc_dev, xres, yres, xpy)) { - ext->current.enabled = 0; - return -ENODEV; - } - } - - struct hwc_rect region = { - .left = o->cfg.win.x, .top = o->cfg.win.y, - .right = o->cfg.win.x + o->cfg.win.w, - .bottom = o->cfg.win.y + o->cfg.win.h - }; - set_ext_matrix(&hwc_dev->ext, region); - - return clone_layer(hwc_dev, ix); -} - -#ifdef OMAP_ENHANCEMENT_S3D -const char hdmiS3DTypePath[] = "/sys/devices/platform/omapdss/display1/s3d_type"; -const char hdmiS3DEnablePath[] = "/sys/devices/platform/omapdss/display1/s3d_enable"; - -static void enable_s3d_hdmi(omap_hwc_device_t *hwc_dev, bool enable) -{ - size_t bytesWritten; - char data; - int fd; - - if (hwc_dev->ext.s3d_enabled == enable) { - return; - } - - if (enable) { - char type[2]; - - switch(hwc_dev->ext.s3d_type) { - case eSideBySide: - snprintf(type, sizeof(type), "%d", HDMI_SIDE_BY_SIDE_HALF); - break; - case eTopBottom: - snprintf(type, sizeof(type), "%d", HDMI_TOPBOTTOM); - break; - default: - return; - } - - fd = open(hdmiS3DTypePath, O_WRONLY); - if (fd < 0) { - ALOGE("Failed to open sysfs %s", hdmiS3DTypePath); - return; - } - bytesWritten = write(fd, type, sizeof(type)); - close(fd); - - if (bytesWritten != sizeof(type)) { - ALOGE("Failed to write (%s) to sysfs %s", type, hdmiS3DTypePath); - return; - } - } - data = enable ? '1' : '0'; - - fd = open(hdmiS3DEnablePath, O_WRONLY); - if (fd < 0) { - ALOGE("Failed to open sysfs %s", hdmiS3DEnablePath); - return; - } - bytesWritten = write(fd, &data, 1); - close(fd); - - if (bytesWritten != 1) { - ALOGE("Failed to write(%d) to sysfs %s", enable, hdmiS3DEnablePath); - return; - } - - hwc_dev->ext.s3d_enabled = enable; -} - -static void adjust_ext_s3d_layer(omap_hwc_device_t *hwc_dev, - struct dss2_ovl_info *ovl, bool left_view) -{ - struct dss2_ovl_cfg *oc = &ovl->cfg; - float x, y, w, h; - - switch (hwc_dev->s3d_input_type) { - case eSideBySide: - oc->crop.w = oc->crop.w/2; - if ((left_view && hwc_dev->s3d_input_order == eRightViewFirst) || - (!left_view && hwc_dev->s3d_input_order == eLeftViewFirst)) { - oc->crop.x = oc->crop.x + oc->crop.w; - } - break; - case eTopBottom: - oc->crop.h = oc->crop.h/2; - if ((left_view && hwc_dev->s3d_input_order == eRightViewFirst) || - (!left_view && hwc_dev->s3d_input_order == eLeftViewFirst)) { - oc->crop.y = oc->crop.y + oc->crop.h; - } - break; - default: - /* Should never fall here! */ - ALOGE("Unsupported S3D layer type!"); - break; - } - - switch (hwc_dev->ext.s3d_type) { - case eSideBySide: - oc->win.w = oc->win.w/2; - if ((left_view && hwc_dev->ext.s3d_order == eRightViewFirst) || - (!left_view && hwc_dev->ext.s3d_order == eLeftViewFirst)) { - oc->win.x = oc->win.x/2 + hwc_dev->ext.xres/2; - } else { - oc->win.x = oc->win.x/2; - } - break; - case eTopBottom: - oc->win.h = oc->win.h/2; - if ((left_view && hwc_dev->ext.s3d_order == eRightViewFirst) || - (!left_view && hwc_dev->ext.s3d_order == eLeftViewFirst)) { - oc->win.y = oc->win.y/2 + hwc_dev->ext.yres/2; - } else { - oc->win.y = oc->win.y/2; - } - break; - default: - /* Currently unhandled!!! */ - ALOGE("Unsupported S3D display type!"); - break; - } -} - -static int clone_s3d_external_layer(omap_hwc_device_t *hwc_dev, int ix_s3d) -{ - struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; - int r; - - /* S3D layers are forced into docking layers. If the display layout and - * the layer layout don't match, we have to use 2 overlay pipelines */ - r = clone_external_layer(hwc_dev, ix_s3d); - if (r) { - ALOGE("Failed to clone s3d layer (%d)", r); - return r; - } - - r = clone_layer(hwc_dev, ix_s3d); - if (r) { - ALOGE("Failed to clone s3d layer (%d)", r); - return r; - } - - if (dsscomp->num_ovls < 2) { - ALOGE("Number of overlays is inconsistent (%d)", dsscomp->num_ovls); - return -EINVAL; - } - - adjust_ext_s3d_layer(hwc_dev, &dsscomp->ovls[dsscomp->num_ovls - 1], true); - adjust_ext_s3d_layer(hwc_dev, &dsscomp->ovls[dsscomp->num_ovls - 2], false); - - return 0; -} -#endif -static int setup_mirroring(omap_hwc_device_t *hwc_dev) -{ - omap_hwc_ext_t *ext = &hwc_dev->ext; - - uint32_t xres = WIDTH(ext->mirror_region); - uint32_t yres = HEIGHT(ext->mirror_region); - if (ext->current.rotation & 1) - swap(xres, yres); - if (set_best_hdmi_mode(hwc_dev, xres, yres, ext->lcd_xpy)) - return -ENODEV; - set_ext_matrix(ext, ext->mirror_region); - return 0; -} - -/* - * We're using "implicit" synchronization, so make sure we aren't passing any - * sync object descriptors around. - */ -static void check_sync_fds(size_t numDisplays, hwc_display_contents_1_t** displays) -{ - //ALOGD("checking sync FDs"); - unsigned int i, j; - for (i = 0; i < numDisplays; i++) { - hwc_display_contents_1_t* list = displays[i]; - if (list->retireFenceFd >= 0) { - ALOGW("retireFenceFd[%u] was %d", i, list->retireFenceFd); - list->retireFenceFd = -1; - } - - for (j = 0; j < list->numHwLayers; j++) { - hwc_layer_1_t* layer = &list->hwLayers[j]; - if (layer->acquireFenceFd >= 0) { - ALOGW("acquireFenceFd[%u][%u] was %d, closing", i, j, layer->acquireFenceFd); - close(layer->acquireFenceFd); - layer->acquireFenceFd = -1; - } - if (layer->releaseFenceFd >= 0) { - ALOGW("releaseFenceFd[%u][%u] was %d", i, j, layer->releaseFenceFd); - layer->releaseFenceFd = -1; - } - } - } -} - -static void blit_reset(omap_hwc_device_t *hwc_dev) -{ - hwc_dev->blit_flags = 0; - hwc_dev->blit_num = 0; - hwc_dev->post2_blit_buffers = 0; - hwc_dev->comp_data.blit_data.rgz_items = 0; -} - -static bool blit_layers(omap_hwc_device_t *hwc_dev, hwc_display_contents_1_t *list, int bufoff) -{ - if (!list || hwc_dev->ext.mirror.enabled) - goto err_out; - - int rgz_in_op; - int rgz_out_op; - - switch (hwc_dev->blt_mode) { - case BLTMODE_PAINT: - rgz_in_op = RGZ_IN_HWCCHK; - rgz_out_op = RGZ_OUT_BVCMD_PAINT; - break; - case BLTMODE_REGION: - default: - rgz_in_op = RGZ_IN_HWC; - rgz_out_op = RGZ_OUT_BVCMD_REGION; - break; - } - - /* - * Request the layer identities to SurfaceFlinger, first figure out if the - * operation is supported - */ - if (!(list->flags & HWC_EXTENDED_API) || !hwc_dev->procs || - hwc_dev->procs->extension_cb(hwc_dev->procs, HWC_EXTENDED_OP_LAYERDATA, NULL, -1) != 0) - goto err_out; - - /* Check if we have enough space in the extended layer list */ - if ((sizeof(hwc_layer_extended_t) * list->numHwLayers) > sizeof(grgz_ext_layer_list)) - goto err_out; - - uint32_t i; - for (i = 0; i < list->numHwLayers; i++) { - hwc_layer_extended_t *ext_layer = &grgz_ext_layer_list.layers[i]; - ext_layer->idx = i; - if (hwc_dev->procs->extension_cb(hwc_dev->procs, HWC_EXTENDED_OP_LAYERDATA, - (void **) &ext_layer, sizeof(hwc_layer_extended_t)) != 0) - goto err_out; - } - - rgz_in_params_t in = { - .op = rgz_in_op, - .data = { - .hwc = { - .dstgeom = &gscrngeom, - .layers = list->hwLayers, - .extlayers = grgz_ext_layer_list.layers, - .layerno = list->numHwLayers - } - } - }; - - /* - * This means if all the layers marked for the FRAMEBUFFER cannot be - * blitted, do not blit, for e.g. SKIP layers - */ - if (rgz_in(&in, &grgz) != RGZ_ALL) - goto err_out; - - uint32_t count = 0; - for (i = 0; i < list->numHwLayers; i++) { - if (list->hwLayers[i].compositionType != HWC_OVERLAY) { - count++; - } - } - - rgz_out_params_t out = { - .op = rgz_out_op, - .data = { - .bvc = { - .dstgeom = &gscrngeom, - .noblend = 0, - } - } - }; - - if (rgz_out(&grgz, &out) != 0) { - ALOGE("Failed generating blits"); - goto err_out; - } - - /* This is a special situation where the regionizer decided no blits are - * needed for this frame but there are blit buffers to synchronize with. Can - * happen only if the regionizer is enabled otherwise it's likely a bug - */ - if (rgz_out_op != RGZ_OUT_BVCMD_REGION && out.data.bvc.out_blits == 0 && out.data.bvc.out_nhndls > 0) { - ALOGE("Regionizer invalid output blit_num %d, post2_blit_buffers %d", out.data.bvc.out_blits, out.data.bvc.out_nhndls); - goto err_out; - } - - hwc_dev->blit_flags |= HWC_BLT_FLAG_USE_FB; - hwc_dev->blit_num = out.data.bvc.out_blits; - hwc_dev->post2_blit_buffers = out.data.bvc.out_nhndls; - for (i = 0; i < hwc_dev->post2_blit_buffers; i++) { - //ALOGI("blit buffers[%d] = %p", bufoff, out.data.bvc.out_hndls[i]); - hwc_dev->buffers[bufoff++] = out.data.bvc.out_hndls[i]; - } - - struct rgz_blt_entry *res_blit_ops = (struct rgz_blt_entry *) out.data.bvc.cmdp; - memcpy(hwc_dev->comp_data.blit_data.rgz_blts, res_blit_ops, sizeof(*res_blit_ops) * out.data.bvc.cmdlen); - ALOGI_IF(debugblt, "blt struct sz %d", sizeof(*res_blit_ops) * out.data.bvc.cmdlen); - ALOGE_IF(hwc_dev->blit_num != out.data.bvc.cmdlen,"blit_num != out.data.bvc.cmdlen, %d != %d", hwc_dev->blit_num, out.data.bvc.cmdlen); - - /* all layers will be rendered without SGX help either via DSS or blitter */ - for (i = 0; i < list->numHwLayers; i++) { - if (list->hwLayers[i].compositionType != HWC_OVERLAY) { - list->hwLayers[i].compositionType = HWC_OVERLAY; - //ALOGI("blitting layer %d", i); - list->hwLayers[i].hints &= ~HWC_HINT_TRIPLE_BUFFER; - } - list->hwLayers[i].hints &= ~HWC_HINT_CLEAR_FB; - } - return true; - -err_out: - rgz_release(&grgz); - return false; -} - -void debug_post2(omap_hwc_device_t *hwc_dev, int nbufs) -{ - if (!debugpost2) - return; - struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; - int i; - for (i=0; ibuffers[i]); - } - for (i=0; i < dsscomp->num_ovls; i++) { - ALOGI("ovl[%d] ba %d", i, dsscomp->ovls[i].ba); - } -} - -static int free_tiler2d_buffers(omap_hwc_device_t *hwc_dev) -{ - int i; - - for (i = 0 ; i < NUM_EXT_DISPLAY_BACK_BUFFERS; i++) { - ion_free(hwc_dev->ion_fd, hwc_dev->ion_handles[i]); - hwc_dev->ion_handles[i] = NULL; - } - return 0; -} - -static int allocate_tiler2d_buffers(omap_hwc_device_t *hwc_dev) -{ - int ret, i; - size_t stride; - - if (hwc_dev->ion_fd < 0) { - ALOGE("No ion fd, hence can't allocate tiler2d buffers"); - return -1; - } - - for (i = 0; i < NUM_EXT_DISPLAY_BACK_BUFFERS; i++) { - if (hwc_dev->ion_handles[i]) - return 0; - } - - for (i = 0 ; i < NUM_EXT_DISPLAY_BACK_BUFFERS; i++) { - ret = ion_alloc_tiler(hwc_dev->ion_fd, hwc_dev->fb_dev->base.width, hwc_dev->fb_dev->base.height, - TILER_PIXEL_FMT_32BIT, 0, &hwc_dev->ion_handles[i], &stride); - if (ret) - goto handle_error; - - ALOGI("ion handle[%d][%p]", i, hwc_dev->ion_handles[i]); - } - return 0; - -handle_error: - free_tiler2d_buffers(hwc_dev); - return -1; -} - -static int hwc_prepare(struct hwc_composer_device_1 *dev, size_t numDisplays, - hwc_display_contents_1_t** displays) -{ - if (!numDisplays || displays == NULL) { - return 0; - } - - hwc_display_contents_1_t* list = displays[0]; // ignore displays beyond the first - omap_hwc_device_t *hwc_dev = (omap_hwc_device_t *)dev; - struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; - counts_t *num = &hwc_dev->counts; - uint32_t i, ix; - - pthread_mutex_lock(&hwc_dev->lock); - memset(dsscomp, 0x0, sizeof(*dsscomp)); - dsscomp->sync_id = sync_id++; - - gather_layer_statistics(hwc_dev, list); - - decide_supported_cloning(hwc_dev); - - /* phase 3 logic */ - if (can_dss_render_all(hwc_dev)) { - /* All layers can be handled by the DSS -- don't use SGX for composition */ - hwc_dev->use_sgx = 0; - hwc_dev->swap_rb = num->BGR != 0; - } else { - /* Use SGX for composition plus first 3 layers that are DSS renderable */ - hwc_dev->use_sgx = 1; - hwc_dev->swap_rb = is_BGR_format(hwc_dev->fb_dev->base.format); - } - - /* setup pipes */ - int z = 0; - int fb_z = -1; - int ix_docking = -1; -#ifdef OMAP_ENHANCEMENT_S3D - int ix_s3d = -1; -#endif - bool scaled_gfx = false; - bool blit_all = false; - blit_reset(hwc_dev); - - /* If the SGX is used or we are going to blit something we need a framebuffer - * and a DSS pipe - */ - bool needs_fb = hwc_dev->use_sgx; - - if (hwc_dev->blt_policy == BLTPOLICY_ALL) { - /* Check if we can blit everything */ - blit_all = blit_layers(hwc_dev, list, 0); - if (blit_all) { - needs_fb = 1; - hwc_dev->use_sgx = 0; - /* No need to swap red and blue channels */ - hwc_dev->swap_rb = 0; - } - } - - /* If a framebuffer is needed, begin using VID1 for DSS overlay layers, - * we need GFX for FB - */ - dsscomp->num_ovls = needs_fb ? 1 /*VID1*/ : 0 /*GFX*/; - - /* set up if DSS layers */ - uint32_t mem_used = 0; - for (i = 0; list && i < list->numHwLayers && !blit_all; i++) { - hwc_layer_1_t *layer = &list->hwLayers[i]; - IMG_native_handle_t *handle = (IMG_native_handle_t *)layer->handle; - - if (dsscomp->num_ovls < num->max_hw_overlays && - can_dss_render_layer(hwc_dev, layer) && - (!hwc_dev->force_sgx || - /* render protected and dockable layers via DSS */ - is_protected(layer) || - is_upscaled_NV12(hwc_dev, layer) || - (hwc_dev->ext.current.docking && hwc_dev->ext.current.enabled && dockable(layer))) && - mem_used + mem1d(handle) <= limits.tiler1d_slot_size && - /* can't have a transparent overlay in the middle of the framebuffer stack */ - !(is_BLENDED(layer) && fb_z >= 0)) { - - /* render via DSS overlay */ - mem_used += mem1d(handle); - layer->compositionType = HWC_OVERLAY; - /* - * This hint will not be used in vanilla ICS, but maybe in - * JellyBean, it is useful to distinguish between blts and true - * overlays - */ - layer->hints |= HWC_HINT_TRIPLE_BUFFER; - - /* clear FB above all opaque layers if rendering via SGX */ - if (hwc_dev->use_sgx && !is_BLENDED(layer)) - layer->hints |= HWC_HINT_CLEAR_FB; - - hwc_dev->buffers[dsscomp->num_ovls] = layer->handle; - //ALOGI("dss buffers[%d] = %p", dsscomp->num_ovls, hwc_dev->buffers[dsscomp->num_ovls]); - - setup_layer(hwc_dev, - &dsscomp->ovls[dsscomp->num_ovls], - layer, - z, - handle->iFormat, - handle->iWidth, - handle->iHeight); - - dsscomp->ovls[dsscomp->num_ovls].cfg.ix = dsscomp->num_ovls + hwc_dev->primary_transform; - dsscomp->ovls[dsscomp->num_ovls].addressing = OMAP_DSS_BUFADDR_LAYER_IX; - dsscomp->ovls[dsscomp->num_ovls].ba = dsscomp->num_ovls; - - /* ensure GFX layer is never scaled */ - if ((dsscomp->num_ovls == 0) && (!hwc_dev->primary_transform)) { - scaled_gfx = scaled(layer) || is_NV12(handle); - } else if (scaled_gfx && !scaled(layer) && !is_NV12(handle)) { - /* swap GFX layer with this one */ - dsscomp->ovls[dsscomp->num_ovls].cfg.ix = 0; - dsscomp->ovls[0].cfg.ix = dsscomp->num_ovls; - scaled_gfx = 0; - } - - /* remember largest dockable layer */ - if (dockable(layer) && - (ix_docking < 0 || - display_area(&dsscomp->ovls[dsscomp->num_ovls]) > display_area(&dsscomp->ovls[ix_docking]))) - ix_docking = dsscomp->num_ovls; -#ifdef OMAP_ENHANCEMENT_S3D - /* remember the ix for s3d layer */ - if (get_s3d_layout_type(layer) != eMono) { - ix_s3d = dsscomp->num_ovls; - } -#endif - dsscomp->num_ovls++; - z++; - } else if (hwc_dev->use_sgx) { - if (fb_z < 0) { - /* NOTE: we are not handling transparent cutout for now */ - fb_z = z; - z++; - } else { - /* move fb z-order up (by lowering dss layers) */ - while (fb_z < z - 1) - dsscomp->ovls[1 + fb_z++].cfg.zorder--; - } - } - } - - /* if scaling GFX (e.g. only 1 scaled surface) use a VID pipe */ - if (scaled_gfx) - dsscomp->ovls[0].cfg.ix = dsscomp->num_ovls; - - if (hwc_dev->blt_policy == BLTPOLICY_DEFAULT) { - /* - * As long as we keep blitting on consecutive frames keep the regionizer - * state, if this is not possible the regionizer state is unreliable and - * we need to reset its state. - */ - if (hwc_dev->use_sgx) { - if (blit_layers(hwc_dev, list, dsscomp->num_ovls == 1 ? 0 : dsscomp->num_ovls)) { - hwc_dev->use_sgx = 0; - } - } else - rgz_release(&grgz); - } - - /* If the SGX is not used and there is blit data we need a framebuffer and - * a DSS pipe well configured for it - */ - if (needs_fb) { - /* assign a z-layer for fb */ - if (fb_z < 0) { - if (!hwc_dev->blt_policy != BLTPOLICY_DISABLED && num->composited_layers) - ALOGE("**** should have assigned z-layer for fb"); - fb_z = z++; - } - /* - * This is needed because if we blit all we would lose the handle of - * the first layer - */ - if (hwc_dev->use_sgx) { - hwc_dev->buffers[0] = NULL; - } - setup_layer_base(&dsscomp->ovls[0].cfg, fb_z, - hwc_dev->fb_dev->base.format, - 1, /* FB is always premultiplied */ - hwc_dev->fb_dev->base.width, - hwc_dev->fb_dev->base.height); - dsscomp->ovls[0].cfg.pre_mult_alpha = 1; - dsscomp->ovls[0].addressing = OMAP_DSS_BUFADDR_LAYER_IX; - dsscomp->ovls[0].ba = 0; - dsscomp->ovls[0].cfg.ix = hwc_dev->primary_transform; - } - - /* mirror layers */ - hwc_dev->post2_layers = dsscomp->num_ovls; - - omap_hwc_ext_t *ext = &hwc_dev->ext; - if (ext->current.enabled && ((!num->protected && hwc_dev->ext_ovls) || - (hwc_dev->ext_ovls_wanted && hwc_dev->ext_ovls >= hwc_dev->ext_ovls_wanted))) { -#ifdef OMAP_ENHANCEMENT_S3D - if (ext->current.docking && ix_s3d >= 0) { - if (clone_s3d_external_layer(hwc_dev, ix_s3d) == 0) { - dsscomp->ovls[dsscomp->num_ovls - 2].cfg.zorder = z++; - dsscomp->ovls[dsscomp->num_ovls - 1].cfg.zorder = z++; - /* For now, show only the left view of an S3D layer - * in the local display while we have hdmi attached */ - switch (hwc_dev->s3d_input_type) { - case eSideBySide: - dsscomp->ovls[ix_s3d].cfg.crop.w = dsscomp->ovls[ix_s3d].cfg.crop.w/2; - break; - case eTopBottom: - dsscomp->ovls[ix_s3d].cfg.crop.h = dsscomp->ovls[ix_s3d].cfg.crop.h/2; - break; - default: - ALOGE("Unsupported S3D input type"); - break; - } - } - } else if (ext->current.docking && ix_docking >= 0) { -#else - if (ext->current.docking && ix_docking >= 0) { -#endif - if (clone_external_layer(hwc_dev, ix_docking) == 0) - dsscomp->ovls[dsscomp->num_ovls - 1].cfg.zorder = z++; - } else if (ext->current.docking && ix_docking < 0 && ext->force_dock) { - ix_docking = dsscomp->num_ovls; - struct dss2_ovl_info *oi = &dsscomp->ovls[ix_docking]; - image_info_t *dock_image = get_dock_image(); - setup_layer_base(&oi->cfg, 0, HAL_PIXEL_FORMAT_BGRA_8888, 1, - dock_image->width, dock_image->height); - oi->cfg.stride = dock_image->rowbytes; - if (clone_external_layer(hwc_dev, ix_docking) == 0) { - oi->addressing = OMAP_DSS_BUFADDR_FB; - oi->ba = 0; - z++; - } - } else if (!ext->current.docking) { - int res = 0; - - /* reset mode if we are coming from docking */ - if (ext->last.docking) - res = setup_mirroring(hwc_dev); - - /* mirror all layers */ - for (ix = 0; res == 0 && ix < hwc_dev->post2_layers; ix++) { - if (clone_layer(hwc_dev, ix)) - break; - z++; - } - } - } - - /* Apply transform for primary display */ - if (hwc_dev->primary_transform) - for (i = 0; i < dsscomp->num_ovls; i++) { - if(dsscomp->ovls[i].cfg.mgr_ix == 0) - adjust_primary_display_layer(hwc_dev, &dsscomp->ovls[i]); - } - -#ifdef OMAP_ENHANCEMENT_S3D - enable_s3d_hdmi(hwc_dev, ix_s3d >= 0); -#endif - ext->last = ext->current; - - if (z != dsscomp->num_ovls || dsscomp->num_ovls > MAX_HW_OVERLAYS) - ALOGE("**** used %d z-layers for %d overlays\n", z, dsscomp->num_ovls); - - /* verify all z-orders and overlay indices are distinct */ - for (i = z = ix = 0; i < dsscomp->num_ovls; i++) { - struct dss2_ovl_cfg *c = &dsscomp->ovls[i].cfg; - - if (z & (1 << c->zorder)) - ALOGE("**** used z-order #%d multiple times", c->zorder); - if (ix & (1 << c->ix)) - ALOGE("**** used ovl index #%d multiple times", c->ix); - z |= 1 << c->zorder; - ix |= 1 << c->ix; - } - dsscomp->mode = DSSCOMP_SETUP_DISPLAY; - dsscomp->mgrs[0].ix = 0; - dsscomp->mgrs[0].alpha_blending = 1; - dsscomp->mgrs[0].swap_rb = hwc_dev->swap_rb; - dsscomp->num_mgrs = 1; - - if (ext->current.enabled || hwc_dev->last_ext_ovls) { - dsscomp->mgrs[1] = dsscomp->mgrs[0]; - dsscomp->mgrs[1].ix = 1; - dsscomp->num_mgrs++; - hwc_dev->ext_ovls = dsscomp->num_ovls - hwc_dev->post2_layers; - } - - /* - * Whilst the mode of the display is being changed drop compositions to the - * display - */ - if (ext->last_mode == 0 && hwc_dev->on_tv) { - dsscomp->num_ovls = 0; - } - - if (debug) { - ALOGD("prepare (%d) - %s (comp=%d, poss=%d/%d scaled, RGB=%d,BGR=%d,NV12=%d) (ext=%s%s%ddeg%s %dex/%dmx (last %dex,%din)\n", - dsscomp->sync_id, - hwc_dev->use_sgx ? "SGX+OVL" : "all-OVL", - num->composited_layers, - num->possible_overlay_layers, num->scaled_layers, - num->RGB, num->BGR, num->NV12, - ext->on_tv ? "tv+" : "", - ext->current.enabled ? ext->current.docking ? "dock+" : "mirror+" : "OFF+", - ext->current.rotation * 90, - ext->current.hflip ? "+hflip" : "", - hwc_dev->ext_ovls, num->max_hw_overlays, hwc_dev->last_ext_ovls, hwc_dev->last_int_ovls); - } - - pthread_mutex_unlock(&hwc_dev->lock); - return 0; -} - -static void reset_screen(omap_hwc_device_t *hwc_dev) -{ - static int first_set = 1; - int ret; - - if (first_set) { - first_set = 0; - struct dsscomp_setup_dispc_data d = { - .num_mgrs = 1, - }; - /* remove bootloader image from the screen as blank/unblank does not change the composition */ - ret = ioctl(hwc_dev->dsscomp_fd, DSSCIOC_SETUP_DISPC, &d); - if (ret) - ALOGW("failed to remove bootloader image"); - - /* blank and unblank fd to make sure display is properly programmed on boot. - * This is needed because the bootloader can not be trusted. - */ - ret = ioctl(hwc_dev->fb_fd, FBIOBLANK, FB_BLANK_POWERDOWN); - if (ret) - ALOGW("failed to blank display"); - - ret = ioctl(hwc_dev->fb_fd, FBIOBLANK, FB_BLANK_UNBLANK); - if (ret) - ALOGW("failed to blank display"); - } -} - -static int hwc_set(struct hwc_composer_device_1 *dev, - size_t numDisplays, hwc_display_contents_1_t** displays) -{ - if (!numDisplays || displays == NULL) { - ALOGD("set: empty display list"); - return 0; - } - hwc_display_t dpy = NULL; - hwc_surface_t sur = NULL; - hwc_display_contents_1_t* list = displays[0]; // ignore displays beyond the first - if (list != NULL) { - dpy = list->dpy; - sur = list->sur; - } - omap_hwc_device_t *hwc_dev = (omap_hwc_device_t *)dev; - struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; - int err = 0; - bool invalidate; - - pthread_mutex_lock(&hwc_dev->lock); - - reset_screen(hwc_dev); - - invalidate = hwc_dev->ext_ovls_wanted && (hwc_dev->ext_ovls < hwc_dev->ext_ovls_wanted) && - (hwc_dev->counts.protected || !hwc_dev->ext_ovls); - - if (debug) - dump_set_info(hwc_dev, list); - - if (dpy && sur) { - // list can be NULL which means hwc is temporarily disabled. - // however, if dpy and sur are null it means we're turning the - // screen off. no shall not call eglSwapBuffers() in that case. - - if (hwc_dev->use_sgx) { - if (!eglSwapBuffers((EGLDisplay)dpy, (EGLSurface)sur)) { - ALOGE("eglSwapBuffers error"); - err = HWC_EGL_ERROR; - goto err_out; - } - } - - //dump_dsscomp(dsscomp); - - // signal the event thread that a post has happened - write(hwc_dev->pipe_fds[1], "s", 1); - if (hwc_dev->force_sgx > 0) - hwc_dev->force_sgx--; - - hwc_dev->comp_data.blit_data.rgz_flags = hwc_dev->blit_flags; - hwc_dev->comp_data.blit_data.rgz_items = hwc_dev->blit_num; - int omaplfb_comp_data_sz = sizeof(hwc_dev->comp_data) + - (hwc_dev->comp_data.blit_data.rgz_items * sizeof(struct rgz_blt_entry)); - - - uint32_t nbufs = hwc_dev->post2_layers; - if (hwc_dev->post2_blit_buffers) { - /* - * We don't want to pass a NULL entry in the Post2, but we need to - * fix up buffer handle array and overlay indexes to account for - * this - */ - nbufs += hwc_dev->post2_blit_buffers - 1; - - if (hwc_dev->post2_layers > 1) { - uint32_t i, j; - for (i = 0; i < nbufs; i++) { - hwc_dev->buffers[i] = hwc_dev->buffers[i+1]; - } - for (i = 1, j= 1; j < hwc_dev->post2_layers; i++, j++) { - dsscomp->ovls[j].ba = i; - } - } - } - ALOGI_IF(debugblt && hwc_dev->blt_policy != BLTPOLICY_DISABLED, - "Post2, blits %d, ovl_buffers %d, blit_buffers %d sgx %d", - hwc_dev->blit_num, hwc_dev->post2_layers, hwc_dev->post2_blit_buffers, - hwc_dev->use_sgx); - - debug_post2(hwc_dev, nbufs); - err = hwc_dev->fb_dev->Post2((framebuffer_device_t *)hwc_dev->fb_dev, - hwc_dev->buffers, - nbufs, - dsscomp, omaplfb_comp_data_sz); - showfps(); - } - hwc_dev->last_ext_ovls = hwc_dev->ext_ovls; - hwc_dev->last_int_ovls = hwc_dev->post2_layers; - if (err) - ALOGE("Post2 error"); - - check_sync_fds(numDisplays, displays); - -err_out: - pthread_mutex_unlock(&hwc_dev->lock); - - if (invalidate) - hwc_dev->procs->invalidate(hwc_dev->procs); - - return err; -} - -static void hwc_dump(struct hwc_composer_device_1 *dev, char *buff, int buff_len) -{ - omap_hwc_device_t *hwc_dev = (omap_hwc_device_t *)dev; - struct dsscomp_setup_dispc_data *dsscomp = &hwc_dev->comp_data.dsscomp_data; - struct dump_buf log = { - .buf = buff, - .buf_len = buff_len, - }; - int i; - - dump_printf(&log, "omap_hwc %d:\n", dsscomp->num_ovls); - dump_printf(&log, " idle timeout: %dms\n", hwc_dev->idle); - - for (i = 0; i < dsscomp->num_ovls; i++) { - struct dss2_ovl_cfg *cfg = &dsscomp->ovls[i].cfg; - - dump_printf(&log, " layer %d:\n", i); - dump_printf(&log, " enabled:%s buff:%p %dx%d stride:%d\n", - cfg->enabled ? "true" : "false", hwc_dev->buffers[i], - cfg->width, cfg->height, cfg->stride); - dump_printf(&log, " src:(%d,%d) %dx%d dst:(%d,%d) %dx%d ix:%d zorder:%d\n", - cfg->crop.x, cfg->crop.y, cfg->crop.w, cfg->crop.h, - cfg->win.x, cfg->win.y, cfg->win.w, cfg->win.h, - cfg->ix, cfg->zorder); - } - - if (hwc_dev->blt_policy != BLTPOLICY_DISABLED) { - dump_printf(&log, " bltpolicy: %s, bltmode: %s\n", - hwc_dev->blt_policy == BLTPOLICY_DEFAULT ? "default" : - hwc_dev->blt_policy == BLTPOLICY_ALL ? "all" : "unknown", - hwc_dev->blt_mode == BLTMODE_PAINT ? "paint" : "regionize"); - } - dump_printf(&log, "\n"); -} - -static int hwc_device_close(hw_device_t* device) -{ - omap_hwc_device_t *hwc_dev = (omap_hwc_device_t *) device;; - - if (hwc_dev) { - if (hwc_dev->dsscomp_fd >= 0) - close(hwc_dev->dsscomp_fd); - if (hwc_dev->hdmi_fb_fd >= 0) - close(hwc_dev->hdmi_fb_fd); - if (hwc_dev->fb_fd >= 0) - close(hwc_dev->fb_fd); - if (hwc_dev->ion_fd >= 0) - ion_close(hwc_dev->ion_fd); - - /* pthread will get killed when parent process exits */ - pthread_mutex_destroy(&hwc_dev->lock); - free(hwc_dev); - } - - return 0; -} - -static int open_fb_hal(IMG_framebuffer_device_public_t **fb_dev) -{ - const struct hw_module_t *psModule; - IMG_gralloc_module_public_t *psGrallocModule; - int err; - - err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &psModule); - psGrallocModule = (IMG_gralloc_module_public_t *) psModule; - - if(err) - goto err_out; - - if (strcmp(psGrallocModule->base.common.author, "Imagination Technologies")) { - err = -EINVAL; - goto err_out; - } - - *fb_dev = psGrallocModule->psFrameBufferDevice; - - return 0; - -err_out: - ALOGE("Composer HAL failed to load compatible Graphics HAL"); - return err; -} - -static void set_primary_display_transform_matrix(omap_hwc_device_t *hwc_dev) -{ - /* create primary display translation matrix */ - hwc_dev->fb_dis.ix = 0;/*Default display*/ - - int ret = ioctl(hwc_dev->dsscomp_fd, DSSCIOC_QUERY_DISPLAY, &hwc_dev->fb_dis); - if (ret) - ALOGE("failed to get display info (%d): %m", errno); - - int lcd_w = hwc_dev->fb_dis.timings.x_res; - int lcd_h = hwc_dev->fb_dis.timings.y_res; - int orig_w = hwc_dev->fb_dev->base.width; - int orig_h = hwc_dev->fb_dev->base.height; - hwc_rect_t region = {.left = 0, .top = 0, .right = orig_w, .bottom = orig_h}; - hwc_dev->primary_region = region; - hwc_dev->primary_rotation = ((lcd_w > lcd_h) ^ (orig_w > orig_h)) ? 1 : 0; - hwc_dev->primary_transform = ((lcd_w != orig_w)||(lcd_h != orig_h)) ? 1 : 0; - - ALOGI("transforming FB (%dx%d) => (%dx%d) rot%d", orig_w, orig_h, lcd_w, lcd_h, hwc_dev->primary_rotation); - - /* reorientation matrix is: - m = (center-from-target-center) * (scale-to-target) * (mirror) * (rotate) * (center-to-original-center) */ - - memcpy(hwc_dev->primary_m, m_unit, sizeof(m_unit)); - m_translate(hwc_dev->primary_m, -(orig_w >> 1), -(orig_h >> 1)); - m_rotate(hwc_dev->primary_m, hwc_dev->primary_rotation); - if (hwc_dev->primary_rotation & 1) - swap(orig_w, orig_h); - m_scale(hwc_dev->primary_m, orig_w, lcd_w, orig_h, lcd_h); - m_translate(hwc_dev->primary_m, lcd_w >> 1, lcd_h >> 1); -} - -#ifdef OMAP_ENHANCEMENT_S3D -static void handle_s3d_hotplug(omap_hwc_ext_t *ext, bool state) -{ - struct edid_t *edid = NULL; - if (state) { - int fd = open("/sys/devices/platform/omapdss/display1/edid", O_RDONLY); - if (!fd) - return; - uint8_t edid_data[EDID_SIZE]; - size_t bytes_read = read(fd, edid_data, EDID_SIZE); - close(fd); - if (bytes_read < EDID_SIZE) - return; - if (edid_parser_init(&edid, edid_data)) - return; - } - - ext->s3d_enabled = false; - ext->s3d_capable = false; - ext->s3d_type = eMono; - ext->s3d_order = eLeftViewFirst; - - if (edid) { - ext->s3d_capable = edid_s3d_capable(edid); - /* For now assume Side-by-Side half support applies to all modes */ - ext->s3d_type = eSideBySide; - ext->s3d_order = eLeftViewFirst; - edid_parser_deinit(edid); - } -} -#endif -static void handle_hotplug(omap_hwc_device_t *hwc_dev) -{ - omap_hwc_ext_t *ext = &hwc_dev->ext; - bool state = ext->hdmi_state; - - /* Ignore external HDMI logic if the primary display is HDMI */ - if (hwc_dev->on_tv) { - ALOGI("Primary display is HDMI - skip clone/dock logic"); - - if (state) { - uint32_t xres = hwc_dev->fb_dev->base.width; - uint32_t yres = hwc_dev->fb_dev->base.height; - if (set_best_hdmi_mode(hwc_dev, xres, yres, ext->lcd_xpy)) { - ALOGE("Failed to set HDMI mode"); - } - set_primary_display_transform_matrix(hwc_dev); - - ioctl(hwc_dev->fb_fd, FBIOBLANK, FB_BLANK_UNBLANK); - - if (hwc_dev->procs && hwc_dev->procs->invalidate) { - hwc_dev->procs->invalidate(hwc_dev->procs); - } - } else - ext->last_mode = 0; - - return; - } - - pthread_mutex_lock(&hwc_dev->lock); -#ifdef OMAP_ENHANCEMENT_S3D - handle_s3d_hotplug(ext, state); -#endif - ext->dock.enabled = ext->mirror.enabled = 0; - if (state) { - /* check whether we can clone and/or dock */ - char value[PROPERTY_VALUE_MAX]; - property_get("persist.hwc.docking.enabled", value, "1"); - ext->dock.enabled = atoi(value) > 0; - property_get("persist.hwc.mirroring.enabled", value, "1"); - ext->mirror.enabled = atoi(value) > 0; - property_get("persist.hwc.avoid_mode_change", value, "1"); - ext->avoid_mode_change = atoi(value) > 0; - - /* get cloning transformation */ - property_get("persist.hwc.docking.transform", value, "0"); - ext->dock.rotation = atoi(value) & EXT_ROTATION; - ext->dock.hflip = (atoi(value) & EXT_HFLIP) > 0; - ext->dock.docking = 1; - property_get("persist.hwc.mirroring.transform", value, hwc_dev->fb_dis.timings.y_res > hwc_dev->fb_dis.timings.x_res ? "3" : "0"); - ext->mirror.rotation = atoi(value) & EXT_ROTATION; - ext->mirror.hflip = (atoi(value) & EXT_HFLIP) > 0; - ext->mirror.docking = 0; - - if (ext->force_dock) { - /* restrict to docking with no transform */ - ext->mirror.enabled = 0; - ext->dock.rotation = 0; - ext->dock.hflip = 0; - - load_dock_image(); - } - - /* select best mode for mirroring */ - if (ext->mirror.enabled) { - ext->current = ext->mirror; - ext->mirror_mode = 0; - if (setup_mirroring(hwc_dev) == 0) { - ext->mirror_mode = ext->last_mode; - ioctl(hwc_dev->hdmi_fb_fd, FBIOBLANK, FB_BLANK_UNBLANK); - } else - ext->mirror.enabled = 0; - } - /* Allocate backup buffers for FB rotation - * This is required only if the FB tranform is different from that - * of the external display and the FB is not in TILER2D space - */ - if (ext->mirror.rotation && (limits.fbmem_type != DSSCOMP_FBMEM_TILER2D)) - allocate_tiler2d_buffers(hwc_dev); - - } else { - ext->last_mode = 0; - if (ext->mirror.rotation && (limits.fbmem_type != DSSCOMP_FBMEM_TILER2D)) { - /* free tiler 2D buffer on detach */ - free_tiler2d_buffers(hwc_dev); - } - } - ALOGI("external display changed (state=%d, mirror={%s tform=%ddeg%s}, dock={%s tform=%ddeg%s%s}, tv=%d", state, - ext->mirror.enabled ? "enabled" : "disabled", - ext->mirror.rotation * 90, - ext->mirror.hflip ? "+hflip" : "", - ext->dock.enabled ? "enabled" : "disabled", - ext->dock.rotation * 90, - ext->dock.hflip ? "+hflip" : "", - ext->force_dock ? " forced" : "", - ext->on_tv); - - pthread_mutex_unlock(&hwc_dev->lock); - - /* hwc_dev->procs is set right after the device is opened, but there is - * still a race condition where a hotplug event might occur after the open - * but before the procs are registered. */ - if (hwc_dev->procs) - hwc_dev->procs->invalidate(hwc_dev->procs); -} - -static void handle_uevents(omap_hwc_device_t *hwc_dev, const char *buff, int len) -{ - int dock; - int hdmi; - int vsync; - int state = 0; - uint64_t timestamp = 0; - const char *s = buff; - - dock = !strcmp(s, "change@/devices/virtual/switch/dock"); - hdmi = !strcmp(s, "change@/devices/virtual/switch/hdmi"); - vsync = !strcmp(s, "change@/devices/platform/omapfb") || - !strcmp(s, "change@/devices/virtual/switch/omapfb-vsync"); - - if (!dock && !vsync && !hdmi) - return; - - s += strlen(s) + 1; - - while(*s) { - if (!strncmp(s, "SWITCH_STATE=", strlen("SWITCH_STATE="))) - state = atoi(s + strlen("SWITCH_STATE=")); - else if (!strncmp(s, "SWITCH_TIME=", strlen("SWITCH_TIME="))) - timestamp = strtoull(s + strlen("SWITCH_TIME="), NULL, 0); - else if (!strncmp(s, "VSYNC=", strlen("VSYNC="))) - timestamp = strtoull(s + strlen("VSYNC="), NULL, 0); - - s += strlen(s) + 1; - if (s - buff >= len) - break; - } - - if (vsync) { - if (hwc_dev->procs) - hwc_dev->procs->vsync(hwc_dev->procs, 0, timestamp); - } else { - if (dock) - hwc_dev->ext.force_dock = state == 1; - else - hwc_dev->ext.hdmi_state = state == 1; - handle_hotplug(hwc_dev); - } -} - -static void *hdmi_thread(void *data) -{ - omap_hwc_device_t *hwc_dev = data; - static char uevent_desc[4096]; - struct pollfd fds[2]; - bool invalidate = false; - int timeout; - int err; - - setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); - - uevent_init(); - - fds[0].fd = uevent_get_fd(); - fds[0].events = POLLIN; - fds[1].fd = hwc_dev->pipe_fds[0]; - fds[1].events = POLLIN; - - timeout = hwc_dev->idle ? hwc_dev->idle : -1; - - memset(uevent_desc, 0, sizeof(uevent_desc)); - - do { - err = poll(fds, hwc_dev->idle ? 2 : 1, timeout); - - if (err == 0) { - if (hwc_dev->idle) { - if (hwc_dev->procs) { - pthread_mutex_lock(&hwc_dev->lock); - invalidate = hwc_dev->last_int_ovls > 1 && !hwc_dev->force_sgx; - if (invalidate) { - hwc_dev->force_sgx = 2; - } - pthread_mutex_unlock(&hwc_dev->lock); - - if (invalidate) { - hwc_dev->procs->invalidate(hwc_dev->procs); - timeout = -1; - } - } - - continue; - } - } - - if (err == -1) { - if (errno != EINTR) - ALOGE("event error: %m"); - continue; - } - - if (hwc_dev->idle && fds[1].revents & POLLIN) { - char c; - read(hwc_dev->pipe_fds[0], &c, 1); - if (!hwc_dev->force_sgx) - timeout = hwc_dev->idle ? hwc_dev->idle : -1; - } - - if (fds[0].revents & POLLIN) { - /* keep last 2 zeroes to ensure double 0 termination */ - int len = uevent_next_event(uevent_desc, sizeof(uevent_desc) - 2); - handle_uevents(hwc_dev, uevent_desc, len); - } - } while (1); - - return NULL; -} - -static void hwc_registerProcs(struct hwc_composer_device_1* dev, - hwc_procs_t const* procs) -{ - omap_hwc_device_t *hwc_dev = (omap_hwc_device_t *) dev; - - hwc_dev->procs = (typeof(hwc_dev->procs)) procs; -} - -static int hwc_query(struct hwc_composer_device_1* dev, int what, int* value) -{ - omap_hwc_device_t *hwc_dev = (omap_hwc_device_t *) dev; - - switch (what) { - case HWC_BACKGROUND_LAYER_SUPPORTED: - // we don't support the background layer yet - value[0] = 0; - break; - case HWC_VSYNC_PERIOD: - // vsync period in nanosecond - value[0] = 1000000000.0 / hwc_dev->fb_dev->base.fps; - break; - default: - // unsupported query - return -EINVAL; - } - return 0; -} - -static int hwc_eventControl(struct hwc_composer_device_1* dev, - int dpy, int event, int enabled) -{ - omap_hwc_device_t *hwc_dev = (omap_hwc_device_t *) dev; - - switch (event) { - case HWC_EVENT_VSYNC: - { - int val = !!enabled; - int err; - - if (hwc_dev->use_sw_vsync) { - if (enabled) - start_sw_vsync(hwc_dev); - else - stop_sw_vsync(); - return 0; - } - - err = ioctl(hwc_dev->fb_fd, OMAPFB_ENABLEVSYNC, &val); - if (err < 0) - return -errno; - - return 0; - } - default: - return -EINVAL; - } -} - -static int hwc_blank(struct hwc_composer_device_1 *dev, int dpy, int blank) -{ - // We're using an older method of screen blanking based on - // early_suspend in the kernel. No need to do anything here. - return 0; -} - -static int hwc_device_open(const hw_module_t* module, const char* name, hw_device_t** device) -{ - omap_hwc_module_t *hwc_mod = (omap_hwc_module_t *)module; - omap_hwc_device_t *hwc_dev; - int err = 0; - - if (strcmp(name, HWC_HARDWARE_COMPOSER)) { - return -EINVAL; - } - - if (!hwc_mod->fb_dev) { - err = open_fb_hal(&hwc_mod->fb_dev); - if (err) - return err; - - if (!hwc_mod->fb_dev) { - ALOGE("Framebuffer HAL not opened before HWC"); - return -EFAULT; - } - hwc_mod->fb_dev->bBypassPost = 1; - } - - hwc_dev = (omap_hwc_device_t *)malloc(sizeof(*hwc_dev)); - if (hwc_dev == NULL) - return -ENOMEM; - - memset(hwc_dev, 0, sizeof(*hwc_dev)); - - hwc_dev->base.common.tag = HARDWARE_DEVICE_TAG; - hwc_dev->base.common.version = HWC_DEVICE_API_VERSION_1_0; - - if (use_sw_vsync()) { - hwc_dev->use_sw_vsync = true; - init_sw_vsync(hwc_dev); - } - - hwc_dev->base.common.module = (hw_module_t *)module; - hwc_dev->base.common.close = hwc_device_close; - hwc_dev->base.prepare = hwc_prepare; - hwc_dev->base.set = hwc_set; - hwc_dev->base.eventControl = hwc_eventControl; - hwc_dev->base.blank = hwc_blank; - hwc_dev->base.dump = hwc_dump; - hwc_dev->base.registerProcs = hwc_registerProcs; - hwc_dev->base.query = hwc_query; - - hwc_dev->fb_dev = hwc_mod->fb_dev; - *device = &hwc_dev->base.common; - - hwc_dev->dsscomp_fd = open("/dev/dsscomp", O_RDWR); - if (hwc_dev->dsscomp_fd < 0) { - ALOGE("failed to open dsscomp (%d)", errno); - err = -errno; - goto done; - } - - int ret = ioctl(hwc_dev->dsscomp_fd, DSSCIOC_QUERY_PLATFORM, &limits); - if (ret) { - ALOGE("failed to get platform limits (%d): %m", errno); - err = -errno; - goto done; - } - - hwc_dev->fb_fd = open("/dev/graphics/fb0", O_RDWR); - if (hwc_dev->fb_fd < 0) { - ALOGE("failed to open fb (%d)", errno); - err = -errno; - goto done; - } - - err = init_dock_image(hwc_dev, limits.max_width, limits.max_height); - if (err) - goto done; - - /* Allocate the maximum buffers that we can receive from HWC */ - hwc_dev->buffers = malloc(sizeof(buffer_handle_t) * MAX_HWC_LAYERS); - if (!hwc_dev->buffers) { - err = -ENOMEM; - goto done; - } - - ret = ioctl(hwc_dev->dsscomp_fd, DSSCIOC_QUERY_DISPLAY, &hwc_dev->fb_dis); - if (ret) { - ALOGE("failed to get display info (%d): %m", errno); - err = -errno; - goto done; - } - - hwc_dev->ion_fd = ion_open(); - if (hwc_dev->ion_fd < 0) { - ALOGE("failed to open ion driver (%d)", errno); - } - - int i; - for (i = 0; i < NUM_EXT_DISPLAY_BACK_BUFFERS; i++) { - hwc_dev->ion_handles[i] = NULL; - } - - /* use default value in case some of requested display parameters missing */ - hwc_dev->ext.lcd_xpy = 1.0; - if (hwc_dev->fb_dis.timings.x_res && hwc_dev->fb_dis.height_in_mm) { - hwc_dev->ext.lcd_xpy = (float) - hwc_dev->fb_dis.width_in_mm / hwc_dev->fb_dis.timings.x_res / - hwc_dev->fb_dis.height_in_mm * hwc_dev->fb_dis.timings.y_res; - } - - if (hwc_dev->fb_dis.channel == OMAP_DSS_CHANNEL_DIGIT) { - ALOGI("Primary display is HDMI"); - hwc_dev->on_tv = 1; - } else { -#ifndef HDMI_DISABLED - hwc_dev->hdmi_fb_fd = open("/dev/graphics/fb1", O_RDWR); - if (hwc_dev->hdmi_fb_fd < 0) { - ALOGE("failed to open hdmi fb (%d)", errno); - err = -errno; - goto done; - } -#endif - } - - set_primary_display_transform_matrix(hwc_dev); - - if (pipe(hwc_dev->pipe_fds) == -1) { - ALOGE("failed to event pipe (%d): %m", errno); - err = -errno; - goto done; - } - - if (pthread_mutex_init(&hwc_dev->lock, NULL)) { - ALOGE("failed to create mutex (%d): %m", errno); - err = -errno; - goto done; - } - if (pthread_create(&hwc_dev->hdmi_thread, NULL, hdmi_thread, hwc_dev)) - { - ALOGE("failed to create HDMI listening thread (%d): %m", errno); - err = -errno; - goto done; - } - - /* get debug properties */ - - /* see if hwc is enabled at all */ - char value[PROPERTY_VALUE_MAX]; - property_get("debug.hwc.rgb_order", value, "1"); - hwc_dev->flags_rgb_order = atoi(value); - property_get("debug.hwc.nv12_only", value, "0"); - hwc_dev->flags_nv12_only = atoi(value); - property_get("debug.hwc.idle", value, "250"); - hwc_dev->idle = atoi(value); - - /* get the board specific clone properties */ - /* 0:0:1280:720 */ - if (property_get("persist.hwc.mirroring.region", value, "") <= 0 || - sscanf(value, "%d:%d:%d:%d", - &hwc_dev->ext.mirror_region.left, &hwc_dev->ext.mirror_region.top, - &hwc_dev->ext.mirror_region.right, &hwc_dev->ext.mirror_region.bottom) != 4 || - hwc_dev->ext.mirror_region.left >= hwc_dev->ext.mirror_region.right || - hwc_dev->ext.mirror_region.top >= hwc_dev->ext.mirror_region.bottom) { - struct hwc_rect fb_region = { .right = hwc_dev->fb_dev->base.width, .bottom = hwc_dev->fb_dev->base.height }; - hwc_dev->ext.mirror_region = fb_region; - } - ALOGI("clone region is set to (%d,%d) to (%d,%d)", - hwc_dev->ext.mirror_region.left, hwc_dev->ext.mirror_region.top, - hwc_dev->ext.mirror_region.right, hwc_dev->ext.mirror_region.bottom); - - /* read switch state */ - int sw_fd = open("/sys/class/switch/hdmi/state", O_RDONLY); - if (sw_fd >= 0) { - char value; - if (read(sw_fd, &value, 1) == 1) - hwc_dev->ext.hdmi_state = value == '1'; - close(sw_fd); - } - sw_fd = open("/sys/class/switch/dock/state", O_RDONLY); - if (sw_fd >= 0) { - char value; - if (read(sw_fd, &value, 1) == 1) - hwc_dev->ext.force_dock = value == '1'; - close(sw_fd); - } - handle_hotplug(hwc_dev); - - ALOGI("open_device(rgb_order=%d nv12_only=%d)", - hwc_dev->flags_rgb_order, hwc_dev->flags_nv12_only); - - int gc2d_fd = open("/dev/gcioctl", O_RDWR); - if (gc2d_fd < 0) { - ALOGI("Unable to open gc-core device (%d), blits disabled", errno); - hwc_dev->blt_policy = BLTPOLICY_DISABLED; - } else { - property_get("persist.hwc.bltmode", value, "1"); - hwc_dev->blt_mode = atoi(value); - property_get("persist.hwc.bltpolicy", value, "1"); - hwc_dev->blt_policy = atoi(value); - ALOGI("blitter present, blits mode %d, blits policy %d", hwc_dev->blt_mode, hwc_dev->blt_policy); - close(gc2d_fd); - - if (rgz_get_screengeometry(hwc_dev->fb_fd, &gscrngeom, - hwc_dev->fb_dev->base.format) != 0) { - err = -EINVAL; - goto done; - } - } - - property_get("persist.hwc.upscaled_nv12_limit", value, "2."); - sscanf(value, "%f", &hwc_dev->upscaled_nv12_limit); - if (hwc_dev->upscaled_nv12_limit < 0. || hwc_dev->upscaled_nv12_limit > 2048.) { - ALOGW("Invalid upscaled_nv12_limit (%s), setting to 2.", value); - hwc_dev->upscaled_nv12_limit = 2.; - } - -done: - if (err && hwc_dev) { - if (hwc_dev->dsscomp_fd >= 0) - close(hwc_dev->dsscomp_fd); - if (hwc_dev->hdmi_fb_fd >= 0) - close(hwc_dev->hdmi_fb_fd); - if (hwc_dev->fb_fd >= 0) - close(hwc_dev->fb_fd); - pthread_mutex_destroy(&hwc_dev->lock); - free(hwc_dev->buffers); - free(hwc_dev); - } - - return err; -} - -static struct hw_module_methods_t module_methods = { - .open = hwc_device_open, -}; - -omap_hwc_module_t HAL_MODULE_INFO_SYM = { - .base = { - .common = { - .tag = HARDWARE_MODULE_TAG, - .module_api_version = HWC_MODULE_API_VERSION_0_1, - .hal_api_version = HARDWARE_HAL_API_VERSION, - .id = HWC_HARDWARE_MODULE_ID, - .name = "OMAP 44xx Hardware Composer HAL", - .author = "Texas Instruments", - .methods = &module_methods, - }, - }, -}; diff --git a/hwc/hwc_dev.h b/hwc/hwc_dev.h deleted file mode 100755 index d1d0fa3..0000000 --- a/hwc/hwc_dev.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __HWC_DEV__ -#define __HWC_DEV__ - -#include -#include - -#include -#ifdef OMAP_ENHANCEMENT_S3D -#include -#endif - -#include -#include