From 93a7e5951c8dfcdf609161875493ef6925f68ca7 Mon Sep 17 00:00:00 2001 From: atinm Date: Tue, 17 May 2011 11:12:26 -0400 Subject: moved to device/samsung/aries-common --- Android.mk | 5 + aries.mk | 3 - aries/Android.mk | 3 - aries/bmlutils/Android.mk | 11 - aries/bmlutils/bmlwrite.c | 35 - aries/include/s3c_bc.h | 63 - aries/include/s3c_mem.h | 56 - aries/include/s5p_fimc.h | 153 - aries/include/videodev2_samsung.h | 633 ---- aries/libaudio/Android.mk | 49 - aries/libaudio/AudioHardware.cpp | 2127 ------------- aries/libaudio/AudioHardware.h | 367 --- aries/libaudio/AudioPolicyManager.cpp | 46 - aries/libaudio/AudioPolicyManager.h | 46 - aries/libaudio/alsa_audio.h | 77 - aries/libaudio/alsa_mixer.c | 371 --- aries/libaudio/alsa_pcm.c | 405 --- aries/libaudio/amix.c | 78 - aries/libaudio/aplay.c | 140 - aries/libaudio/arec.c | 128 - aries/libaudio/asound.h | 814 ----- aries/libaudio/secril-client.h | 175 -- aries/libcamera/Android.mk | 51 - aries/libcamera/NOTICE | 190 -- aries/libcamera/SecCamera.cpp | 3142 -------------------- aries/libcamera/SecCamera.h | 538 ---- aries/libcamera/SecCameraHWInterface.cpp | 2142 ------------- aries/libcamera/SecCameraHWInterface.h | 212 -- aries/liblight/Android.mk | 32 - aries/liblight/NOTICE | 190 -- aries/liblight/lights.c | 153 - aries/liboverlay/Android.mk | 35 - aries/liboverlay/overlay.cpp | 1490 ---------- aries/liboverlay/v4l2_utils.c | 788 ----- aries/liboverlay/v4l2_utils.h | 75 - aries/libs3cjpeg/Android.mk | 36 - aries/libs3cjpeg/Exif.h | 233 -- aries/libs3cjpeg/JpegEncoder.cpp | 796 ----- aries/libs3cjpeg/JpegEncoder.h | 240 -- aries/libsensors/Android.mk | 50 - aries/libsensors/BoschYamaha.cpp | 500 ---- aries/libsensors/BoschYamaha.h | 83 - aries/libsensors/CompassSensor.cpp | 166 -- aries/libsensors/CompassSensor.h | 54 - aries/libsensors/GyroSensor.cpp | 181 -- aries/libsensors/GyroSensor.h | 54 - aries/libsensors/InputEventReader.cpp | 88 - aries/libsensors/InputEventReader.h | 47 - aries/libsensors/LightSensor.cpp | 180 -- aries/libsensors/LightSensor.h | 57 - aries/libsensors/OrientationSensor.cpp | 163 - aries/libsensors/OrientationSensor.h | 54 - aries/libsensors/ProximitySensor.cpp | 144 - aries/libsensors/ProximitySensor.h | 54 - aries/libsensors/SensorBase.cpp | 128 - aries/libsensors/SensorBase.h | 65 - aries/libsensors/Smb380Sensor.cpp | 165 - aries/libsensors/Smb380Sensor.h | 69 - aries/libsensors/sensors.cpp | 335 --- aries/libsensors/sensors.h | 117 - aries/libstagefrighthw/Android.mk | 27 - aries/libstagefrighthw/SEC_OMX_Plugin.cpp | 147 - aries/libstagefrighthw/SEC_OMX_Plugin.h | 76 - aries/libstagefrighthw/SecHardwareRenderer.cpp | 228 -- aries/libstagefrighthw/SecHardwareRenderer.h | 78 - .../stagefright_overlay_output.cpp | 51 - aries/mkshbootimg.py | 47 - aries/sec_mm/Android.mk | 1 - aries/sec_mm/sec_omx/Android.mk | 22 - aries/sec_mm/sec_omx/sec_codecs/Android.mk | 7 - .../sec_codecs/video/mfc_c110/dec/Android.mk | 26 - .../video/mfc_c110/dec/src/SsbSipMfcDecAPI.c | 675 ----- .../sec_codecs/video/mfc_c110/enc/Android.mk | 26 - .../video/mfc_c110/enc/src/SsbSipMfcEncAPI.c | 630 ---- .../video/mfc_c110/include/SsbSipMfcApi.h | 330 -- .../video/mfc_c110/include/mfc_interface.h | 333 --- .../sec_omx/sec_omx_component/common/Android.mk | 24 - .../common/SEC_OMX_Basecomponent.c | 1486 --------- .../common/SEC_OMX_Basecomponent.h | 174 -- .../sec_omx_component/common/SEC_OMX_Baseport.c | 1005 ------- .../sec_omx_component/common/SEC_OMX_Baseport.h | 90 - .../common/SEC_OMX_Resourcemanager.c | 383 --- .../common/SEC_OMX_Resourcemanager.h | 59 - .../sec_omx/sec_omx_component/video/dec/Android.mk | 20 - .../sec_omx_component/video/dec/SEC_OMX_Vdec.c | 1355 --------- .../sec_omx_component/video/dec/SEC_OMX_Vdec.h | 107 - .../sec_omx_component/video/dec/h264dec/Android.mk | 29 - .../video/dec/h264dec/SEC_OMX_H264dec.c | 1191 -------- .../video/dec/h264dec/SEC_OMX_H264dec.h | 66 - .../video/dec/h264dec/library_register.c | 55 - .../video/dec/h264dec/library_register.h | 55 - .../video/dec/mpeg4dec/Android.mk | 29 - .../video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c | 1399 --------- .../video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h | 91 - .../video/dec/mpeg4dec/library_register.c | 63 - .../video/dec/mpeg4dec/library_register.h | 59 - .../sec_omx/sec_omx_component/video/enc/Android.mk | 20 - .../sec_omx_component/video/enc/SEC_OMX_Venc.c | 1411 --------- .../sec_omx_component/video/enc/SEC_OMX_Venc.h | 106 - .../sec_omx_component/video/enc/h264enc/Android.mk | 29 - .../video/enc/h264enc/SEC_OMX_H264enc.c | 1029 ------- .../video/enc/h264enc/SEC_OMX_H264enc.h | 76 - .../video/enc/h264enc/library_register.c | 55 - .../video/enc/h264enc/library_register.h | 55 - .../video/enc/mpeg4enc/Android.mk | 29 - .../video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c | 1205 -------- .../video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.h | 76 - .../video/enc/mpeg4enc/library_register.c | 64 - .../video/enc/mpeg4enc/library_register.h | 59 - aries/sec_mm/sec_omx/sec_omx_core/Android.mk | 25 - .../sec_omx_core/SEC_OMX_Component_Register.c | 269 -- .../sec_omx_core/SEC_OMX_Component_Register.h | 75 - aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.c | 354 --- aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.h | 78 - aries/sec_mm/sec_omx/sec_omx_core/secomxregistry | 4 - .../sec_omx/sec_omx_include/khronos/OMX_Audio.h | 1311 -------- .../sec_omx_include/khronos/OMX_Component.h | 579 ---- .../sec_omx_include/khronos/OMX_ContentPipe.h | 195 -- .../sec_omx/sec_omx_include/khronos/OMX_Core.h | 1431 --------- .../sec_omx/sec_omx_include/khronos/OMX_IVCommon.h | 920 ------ .../sec_omx/sec_omx_include/khronos/OMX_Image.h | 328 -- .../sec_omx/sec_omx_include/khronos/OMX_Index.h | 258 -- .../sec_omx/sec_omx_include/khronos/OMX_Other.h | 337 --- .../sec_omx/sec_omx_include/khronos/OMX_Types.h | 347 --- .../sec_omx/sec_omx_include/khronos/OMX_Video.h | 1060 ------- .../sec_omx/sec_omx_include/sec/SEC_OMX_Def.h | 138 - .../sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h | 64 - aries/sec_mm/sec_omx/sec_osal/Android.mk | 29 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.c | 144 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.h | 48 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.c | 217 -- aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.h | 61 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.c | 54 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.h | 46 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.c | 53 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.h | 78 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.c | 71 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.h | 47 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.c | 91 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.h | 47 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.c | 174 -- aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h | 67 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c | 132 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.h | 49 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c | 153 - aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h | 48 - aries/shbootimg.mk | 8 - bmlutils/Android.mk | 11 + bmlutils/bmlwrite.c | 35 + include/s3c_bc.h | 63 + include/s3c_mem.h | 56 + include/s5p_fimc.h | 153 + include/videodev2_samsung.h | 633 ++++ libaudio/Android.mk | 49 + libaudio/AudioHardware.cpp | 2127 +++++++++++++ libaudio/AudioHardware.h | 367 +++ libaudio/AudioPolicyManager.cpp | 46 + libaudio/AudioPolicyManager.h | 46 + libaudio/alsa_audio.h | 77 + libaudio/alsa_mixer.c | 371 +++ libaudio/alsa_pcm.c | 405 +++ libaudio/amix.c | 78 + libaudio/aplay.c | 140 + libaudio/arec.c | 128 + libaudio/asound.h | 814 +++++ libaudio/secril-client.h | 175 ++ libcamera/Android.mk | 51 + libcamera/NOTICE | 190 ++ libcamera/SecCamera.cpp | 3142 ++++++++++++++++++++ libcamera/SecCamera.h | 538 ++++ libcamera/SecCameraHWInterface.cpp | 2142 +++++++++++++ libcamera/SecCameraHWInterface.h | 212 ++ liblight/Android.mk | 32 + liblight/NOTICE | 190 ++ liblight/lights.c | 153 + liboverlay/Android.mk | 35 + liboverlay/overlay.cpp | 1490 ++++++++++ liboverlay/v4l2_utils.c | 788 +++++ liboverlay/v4l2_utils.h | 75 + libs3cjpeg/Android.mk | 36 + libs3cjpeg/Exif.h | 233 ++ libs3cjpeg/JpegEncoder.cpp | 796 +++++ libs3cjpeg/JpegEncoder.h | 240 ++ libsensors/Android.mk | 50 + libsensors/BoschYamaha.cpp | 500 ++++ libsensors/BoschYamaha.h | 83 + libsensors/CompassSensor.cpp | 166 ++ libsensors/CompassSensor.h | 54 + libsensors/GyroSensor.cpp | 181 ++ libsensors/GyroSensor.h | 54 + libsensors/InputEventReader.cpp | 88 + libsensors/InputEventReader.h | 47 + libsensors/LightSensor.cpp | 180 ++ libsensors/LightSensor.h | 57 + libsensors/OrientationSensor.cpp | 163 + libsensors/OrientationSensor.h | 54 + libsensors/ProximitySensor.cpp | 144 + libsensors/ProximitySensor.h | 54 + libsensors/SensorBase.cpp | 128 + libsensors/SensorBase.h | 65 + libsensors/Smb380Sensor.cpp | 165 + libsensors/Smb380Sensor.h | 69 + libsensors/sensors.cpp | 335 +++ libsensors/sensors.h | 117 + libstagefrighthw/Android.mk | 27 + libstagefrighthw/SEC_OMX_Plugin.cpp | 147 + libstagefrighthw/SEC_OMX_Plugin.h | 76 + libstagefrighthw/SecHardwareRenderer.cpp | 228 ++ libstagefrighthw/SecHardwareRenderer.h | 78 + libstagefrighthw/stagefright_overlay_output.cpp | 51 + mkshbootimg.py | 47 + sec_mm/Android.mk | 1 + sec_mm/sec_omx/Android.mk | 22 + sec_mm/sec_omx/sec_codecs/Android.mk | 7 + .../sec_codecs/video/mfc_c110/dec/Android.mk | 26 + .../video/mfc_c110/dec/src/SsbSipMfcDecAPI.c | 675 +++++ .../sec_codecs/video/mfc_c110/enc/Android.mk | 26 + .../video/mfc_c110/enc/src/SsbSipMfcEncAPI.c | 630 ++++ .../video/mfc_c110/include/SsbSipMfcApi.h | 330 ++ .../video/mfc_c110/include/mfc_interface.h | 333 +++ sec_mm/sec_omx/sec_omx_component/common/Android.mk | 24 + .../common/SEC_OMX_Basecomponent.c | 1486 +++++++++ .../common/SEC_OMX_Basecomponent.h | 174 ++ .../sec_omx_component/common/SEC_OMX_Baseport.c | 1005 +++++++ .../sec_omx_component/common/SEC_OMX_Baseport.h | 90 + .../common/SEC_OMX_Resourcemanager.c | 383 +++ .../common/SEC_OMX_Resourcemanager.h | 59 + .../sec_omx/sec_omx_component/video/dec/Android.mk | 20 + .../sec_omx_component/video/dec/SEC_OMX_Vdec.c | 1355 +++++++++ .../sec_omx_component/video/dec/SEC_OMX_Vdec.h | 107 + .../sec_omx_component/video/dec/h264dec/Android.mk | 29 + .../video/dec/h264dec/SEC_OMX_H264dec.c | 1191 ++++++++ .../video/dec/h264dec/SEC_OMX_H264dec.h | 66 + .../video/dec/h264dec/library_register.c | 55 + .../video/dec/h264dec/library_register.h | 55 + .../video/dec/mpeg4dec/Android.mk | 29 + .../video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c | 1399 +++++++++ .../video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h | 91 + .../video/dec/mpeg4dec/library_register.c | 63 + .../video/dec/mpeg4dec/library_register.h | 59 + .../sec_omx/sec_omx_component/video/enc/Android.mk | 20 + .../sec_omx_component/video/enc/SEC_OMX_Venc.c | 1411 +++++++++ .../sec_omx_component/video/enc/SEC_OMX_Venc.h | 106 + .../sec_omx_component/video/enc/h264enc/Android.mk | 29 + .../video/enc/h264enc/SEC_OMX_H264enc.c | 1029 +++++++ .../video/enc/h264enc/SEC_OMX_H264enc.h | 76 + .../video/enc/h264enc/library_register.c | 55 + .../video/enc/h264enc/library_register.h | 55 + .../video/enc/mpeg4enc/Android.mk | 29 + .../video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c | 1205 ++++++++ .../video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.h | 76 + .../video/enc/mpeg4enc/library_register.c | 64 + .../video/enc/mpeg4enc/library_register.h | 59 + sec_mm/sec_omx/sec_omx_core/Android.mk | 25 + .../sec_omx_core/SEC_OMX_Component_Register.c | 269 ++ .../sec_omx_core/SEC_OMX_Component_Register.h | 75 + sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.c | 354 +++ sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.h | 78 + sec_mm/sec_omx/sec_omx_core/secomxregistry | 4 + sec_mm/sec_omx/sec_omx_include/khronos/OMX_Audio.h | 1311 ++++++++ .../sec_omx_include/khronos/OMX_Component.h | 579 ++++ .../sec_omx_include/khronos/OMX_ContentPipe.h | 195 ++ sec_mm/sec_omx/sec_omx_include/khronos/OMX_Core.h | 1431 +++++++++ .../sec_omx/sec_omx_include/khronos/OMX_IVCommon.h | 920 ++++++ sec_mm/sec_omx/sec_omx_include/khronos/OMX_Image.h | 328 ++ sec_mm/sec_omx/sec_omx_include/khronos/OMX_Index.h | 258 ++ sec_mm/sec_omx/sec_omx_include/khronos/OMX_Other.h | 337 +++ sec_mm/sec_omx/sec_omx_include/khronos/OMX_Types.h | 347 +++ sec_mm/sec_omx/sec_omx_include/khronos/OMX_Video.h | 1060 +++++++ sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h | 138 + .../sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h | 64 + sec_mm/sec_omx/sec_osal/Android.mk | 29 + sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.c | 144 + sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.h | 48 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.c | 217 ++ sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.h | 61 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.c | 54 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.h | 46 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.c | 53 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.h | 78 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.c | 71 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.h | 47 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.c | 91 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.h | 47 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.c | 174 ++ sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h | 67 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c | 132 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.h | 49 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c | 153 + sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h | 48 + shbootimg.mk | 7 + 291 files changed, 42923 insertions(+), 42925 deletions(-) create mode 100644 Android.mk delete mode 100644 aries.mk delete mode 100644 aries/Android.mk delete mode 100644 aries/bmlutils/Android.mk delete mode 100644 aries/bmlutils/bmlwrite.c delete mode 100755 aries/include/s3c_bc.h delete mode 100755 aries/include/s3c_mem.h delete mode 100755 aries/include/s5p_fimc.h delete mode 100755 aries/include/videodev2_samsung.h delete mode 100644 aries/libaudio/Android.mk delete mode 100644 aries/libaudio/AudioHardware.cpp delete mode 100644 aries/libaudio/AudioHardware.h delete mode 100644 aries/libaudio/AudioPolicyManager.cpp delete mode 100644 aries/libaudio/AudioPolicyManager.h delete mode 100644 aries/libaudio/alsa_audio.h delete mode 100644 aries/libaudio/alsa_mixer.c delete mode 100644 aries/libaudio/alsa_pcm.c delete mode 100644 aries/libaudio/amix.c delete mode 100644 aries/libaudio/aplay.c delete mode 100644 aries/libaudio/arec.c delete mode 100644 aries/libaudio/asound.h delete mode 100644 aries/libaudio/secril-client.h delete mode 100644 aries/libcamera/Android.mk delete mode 100644 aries/libcamera/NOTICE delete mode 100644 aries/libcamera/SecCamera.cpp delete mode 100644 aries/libcamera/SecCamera.h delete mode 100644 aries/libcamera/SecCameraHWInterface.cpp delete mode 100644 aries/libcamera/SecCameraHWInterface.h delete mode 100644 aries/liblight/Android.mk delete mode 100644 aries/liblight/NOTICE delete mode 100644 aries/liblight/lights.c delete mode 100644 aries/liboverlay/Android.mk delete mode 100644 aries/liboverlay/overlay.cpp delete mode 100644 aries/liboverlay/v4l2_utils.c delete mode 100644 aries/liboverlay/v4l2_utils.h delete mode 100644 aries/libs3cjpeg/Android.mk delete mode 100644 aries/libs3cjpeg/Exif.h delete mode 100644 aries/libs3cjpeg/JpegEncoder.cpp delete mode 100644 aries/libs3cjpeg/JpegEncoder.h delete mode 100644 aries/libsensors/Android.mk delete mode 100644 aries/libsensors/BoschYamaha.cpp delete mode 100644 aries/libsensors/BoschYamaha.h delete mode 100644 aries/libsensors/CompassSensor.cpp delete mode 100644 aries/libsensors/CompassSensor.h delete mode 100644 aries/libsensors/GyroSensor.cpp delete mode 100644 aries/libsensors/GyroSensor.h delete mode 100644 aries/libsensors/InputEventReader.cpp delete mode 100644 aries/libsensors/InputEventReader.h delete mode 100644 aries/libsensors/LightSensor.cpp delete mode 100644 aries/libsensors/LightSensor.h delete mode 100644 aries/libsensors/OrientationSensor.cpp delete mode 100644 aries/libsensors/OrientationSensor.h delete mode 100644 aries/libsensors/ProximitySensor.cpp delete mode 100644 aries/libsensors/ProximitySensor.h delete mode 100644 aries/libsensors/SensorBase.cpp delete mode 100644 aries/libsensors/SensorBase.h delete mode 100644 aries/libsensors/Smb380Sensor.cpp delete mode 100644 aries/libsensors/Smb380Sensor.h delete mode 100644 aries/libsensors/sensors.cpp delete mode 100644 aries/libsensors/sensors.h delete mode 100644 aries/libstagefrighthw/Android.mk delete mode 100644 aries/libstagefrighthw/SEC_OMX_Plugin.cpp delete mode 100644 aries/libstagefrighthw/SEC_OMX_Plugin.h delete mode 100644 aries/libstagefrighthw/SecHardwareRenderer.cpp delete mode 100644 aries/libstagefrighthw/SecHardwareRenderer.h delete mode 100644 aries/libstagefrighthw/stagefright_overlay_output.cpp delete mode 100755 aries/mkshbootimg.py delete mode 100644 aries/sec_mm/Android.mk delete mode 100644 aries/sec_mm/sec_omx/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_codecs/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/src/SsbSipMfcDecAPI.c delete mode 100644 aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/src/SsbSipMfcEncAPI.c delete mode 100644 aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/SsbSipMfcApi.h delete mode 100644 aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/mfc_interface.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/common/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_core/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.c delete mode 100644 aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_core/secomxregistry delete mode 100644 aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Audio.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Component.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_ContentPipe.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Core.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_IVCommon.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Image.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Index.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Other.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Types.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Video.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h delete mode 100644 aries/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h delete mode 100644 aries/sec_mm/sec_omx/sec_osal/Android.mk delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.c delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.h delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.c delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.h delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.c delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.h delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.c delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.h delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.c delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.h delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.c delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.h delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.c delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.h delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c delete mode 100644 aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h delete mode 100644 aries/shbootimg.mk create mode 100644 bmlutils/Android.mk create mode 100644 bmlutils/bmlwrite.c create mode 100755 include/s3c_bc.h create mode 100755 include/s3c_mem.h create mode 100755 include/s5p_fimc.h create mode 100755 include/videodev2_samsung.h create mode 100644 libaudio/Android.mk create mode 100644 libaudio/AudioHardware.cpp create mode 100644 libaudio/AudioHardware.h create mode 100644 libaudio/AudioPolicyManager.cpp create mode 100644 libaudio/AudioPolicyManager.h create mode 100644 libaudio/alsa_audio.h create mode 100644 libaudio/alsa_mixer.c create mode 100644 libaudio/alsa_pcm.c create mode 100644 libaudio/amix.c create mode 100644 libaudio/aplay.c create mode 100644 libaudio/arec.c create mode 100644 libaudio/asound.h create mode 100644 libaudio/secril-client.h create mode 100644 libcamera/Android.mk create mode 100644 libcamera/NOTICE create mode 100644 libcamera/SecCamera.cpp create mode 100644 libcamera/SecCamera.h create mode 100644 libcamera/SecCameraHWInterface.cpp create mode 100644 libcamera/SecCameraHWInterface.h create mode 100644 liblight/Android.mk create mode 100644 liblight/NOTICE create mode 100644 liblight/lights.c create mode 100644 liboverlay/Android.mk create mode 100644 liboverlay/overlay.cpp create mode 100644 liboverlay/v4l2_utils.c create mode 100644 liboverlay/v4l2_utils.h create mode 100644 libs3cjpeg/Android.mk create mode 100644 libs3cjpeg/Exif.h create mode 100644 libs3cjpeg/JpegEncoder.cpp create mode 100644 libs3cjpeg/JpegEncoder.h create mode 100644 libsensors/Android.mk create mode 100644 libsensors/BoschYamaha.cpp create mode 100644 libsensors/BoschYamaha.h create mode 100644 libsensors/CompassSensor.cpp create mode 100644 libsensors/CompassSensor.h create mode 100644 libsensors/GyroSensor.cpp create mode 100644 libsensors/GyroSensor.h create mode 100644 libsensors/InputEventReader.cpp create mode 100644 libsensors/InputEventReader.h create mode 100644 libsensors/LightSensor.cpp create mode 100644 libsensors/LightSensor.h create mode 100644 libsensors/OrientationSensor.cpp create mode 100644 libsensors/OrientationSensor.h create mode 100644 libsensors/ProximitySensor.cpp create mode 100644 libsensors/ProximitySensor.h create mode 100644 libsensors/SensorBase.cpp create mode 100644 libsensors/SensorBase.h create mode 100644 libsensors/Smb380Sensor.cpp create mode 100644 libsensors/Smb380Sensor.h create mode 100644 libsensors/sensors.cpp create mode 100644 libsensors/sensors.h create mode 100644 libstagefrighthw/Android.mk create mode 100644 libstagefrighthw/SEC_OMX_Plugin.cpp create mode 100644 libstagefrighthw/SEC_OMX_Plugin.h create mode 100644 libstagefrighthw/SecHardwareRenderer.cpp create mode 100644 libstagefrighthw/SecHardwareRenderer.h create mode 100644 libstagefrighthw/stagefright_overlay_output.cpp create mode 100755 mkshbootimg.py create mode 100644 sec_mm/Android.mk create mode 100644 sec_mm/sec_omx/Android.mk create mode 100644 sec_mm/sec_omx/sec_codecs/Android.mk create mode 100644 sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/Android.mk create mode 100644 sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/src/SsbSipMfcDecAPI.c create mode 100644 sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/Android.mk create mode 100644 sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/src/SsbSipMfcEncAPI.c create mode 100644 sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/SsbSipMfcApi.h create mode 100644 sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/mfc_interface.h create mode 100644 sec_mm/sec_omx/sec_omx_component/common/Android.mk create mode 100644 sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c create mode 100644 sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.h create mode 100644 sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c create mode 100644 sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h create mode 100644 sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.c create mode 100644 sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.h create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/Android.mk create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.h create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c create mode 100644 sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/Android.mk create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.h create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.h create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.h create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.h create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c create mode 100644 sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.h create mode 100644 sec_mm/sec_omx/sec_omx_core/Android.mk create mode 100644 sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.c create mode 100644 sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.h create mode 100644 sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.c create mode 100644 sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.h create mode 100644 sec_mm/sec_omx/sec_omx_core/secomxregistry create mode 100644 sec_mm/sec_omx/sec_omx_include/khronos/OMX_Audio.h create mode 100644 sec_mm/sec_omx/sec_omx_include/khronos/OMX_Component.h create mode 100644 sec_mm/sec_omx/sec_omx_include/khronos/OMX_ContentPipe.h create mode 100644 sec_mm/sec_omx/sec_omx_include/khronos/OMX_Core.h create mode 100644 sec_mm/sec_omx/sec_omx_include/khronos/OMX_IVCommon.h create mode 100644 sec_mm/sec_omx/sec_omx_include/khronos/OMX_Image.h create mode 100644 sec_mm/sec_omx/sec_omx_include/khronos/OMX_Index.h create mode 100644 sec_mm/sec_omx/sec_omx_include/khronos/OMX_Other.h create mode 100644 sec_mm/sec_omx/sec_omx_include/khronos/OMX_Types.h create mode 100644 sec_mm/sec_omx/sec_omx_include/khronos/OMX_Video.h create mode 100644 sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h create mode 100644 sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h create mode 100644 sec_mm/sec_omx/sec_osal/Android.mk create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.c create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.h create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.c create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.h create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.c create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.h create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.c create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.h create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.c create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.h create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.c create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.h create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.c create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.h create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c create mode 100644 sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h create mode 100644 shbootimg.mk diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..9f8167c --- /dev/null +++ b/Android.mk @@ -0,0 +1,5 @@ +ifeq ($(filter-out aries,$(TARGET_BOOTLOADER_BOARD_NAME)),) +ifeq ($(filter-out s5pv210,$(TARGET_BOARD_PLATFORM)),) + include $(all-subdir-makefiles) +endif +endif diff --git a/aries.mk b/aries.mk deleted file mode 100644 index f1fe55b..0000000 --- a/aries.mk +++ /dev/null @@ -1,3 +0,0 @@ -ifeq ($(filter-out aries,$(TARGET_BOOTLOADER_BOARD_NAME)),) - include device/samsung/common/aries/Android.mk -endif diff --git a/aries/Android.mk b/aries/Android.mk deleted file mode 100644 index c32db09..0000000 --- a/aries/Android.mk +++ /dev/null @@ -1,3 +0,0 @@ -ifeq ($(filter-out s5pv210,$(TARGET_BOARD_PLATFORM)),) - include $(all-subdir-makefiles) -endif diff --git a/aries/bmlutils/Android.mk b/aries/bmlutils/Android.mk deleted file mode 100644 index cb7ec37..0000000 --- a/aries/bmlutils/Android.mk +++ /dev/null @@ -1,11 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := bmlwrite -LOCAL_MODULE_TAGS := eng -LOCAL_MODULE_PATH := releasetools/kernel-tools -LOCAL_SRC_FILES := bmlwrite.c -LOCAL_FORCE_STATIC_EXECUTABLE := true -LOCAL_STATIC_LIBRARIES += libstdc++ libc -include $(BUILD_EXECUTABLE) - diff --git a/aries/bmlutils/bmlwrite.c b/aries/bmlutils/bmlwrite.c deleted file mode 100644 index 74860c6..0000000 --- a/aries/bmlutils/bmlwrite.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include -#include - -#define BML_UNLOCK_ALL 0x8A29 ///< unlock all partition RO -> RW - -int main(int argc, char** argv) { - char buf[4096]; - int dstfd, srcfd, bytes_read, bytes_written, total_read = 0; - if (argc != 3) - return 1; - if (argv[1][0] == '-' && argv[1][1] == 0) - srcfd = 0; - else { - srcfd = open(argv[1], O_RDONLY | O_LARGEFILE); - if (srcfd < 0) - return 2; - } - dstfd = open(argv[2], O_RDWR | O_LARGEFILE); - if (dstfd < 0) - return 3; - if (ioctl(dstfd, BML_UNLOCK_ALL, 0)) - return 4; - do { - total_read += bytes_read = read(srcfd, buf, 4096); - if (!bytes_read) - break; - if (bytes_read < 4096) - memset(&buf[bytes_read], 0, 4096 - bytes_read); - if (write(dstfd, buf, 4096) < 4096) - return 5; - } while(bytes_read == 4096); - return 0; -} diff --git a/aries/include/s3c_bc.h b/aries/include/s3c_bc.h deleted file mode 100755 index e8ea490..0000000 --- a/aries/include/s3c_bc.h +++ /dev/null @@ -1,63 +0,0 @@ -/*!**************************************************************************** -@File s3c_bc.h - -@Title s3c_bc kernel driver parameters - -@Author Imagination Technologies - Samsung Electronics Co. LTD - -@Date 03/03/2010 - -@Copyright 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. - -@Platform Generic - -@Description s3c_bc kernel driver parameters - -@DoxygenVer - -******************************************************************************/ - -/****************************************************************************** -Modifications :- -$Log: s3c_bc.h $ -******************************************************************************/ -#ifndef __S3C_BC_H__ -#define __S3C_BC_H__ - -#include - -#define S3C_BC_DEVICE_NAME "s3c_bc" - -#define S3C_BC_DEVICE_ID 0 -#define S3C_BC_DEVICE_BUFFER_COUNT 4 /* TODO: Modify this accordingly. */ - -#define S3C_BC_DEVICE_PHYS_PAGE_SIZE 0x1000 /* 4KB */ - -typedef struct S3C_BC_ioctl_package_TAG -{ - int inputparam; - int outputparam; -} S3C_BC_ioctl_package, *PS3C_BC_ioctl_package; - -/*!< Nov 2006: according to ioctl-number.txt 'g' wasn't in use. */ -#define S3C_BC_IOC_GID 'g' - -#define S3C_BC_IOWR(INDEX) _IOWR(S3C_BC_IOC_GID, INDEX, S3C_BC_ioctl_package) - -#define S3C_BC_ioctl_get_physical_base_address S3C_BC_IOWR(0) - -#endif /* __S3C_BC__H__ */ -/****************************************************************************** - End of file (s3c_bc.h) -******************************************************************************/ diff --git a/aries/include/s3c_mem.h b/aries/include/s3c_mem.h deleted file mode 100755 index d51398a..0000000 --- a/aries/include/s3c_mem.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright@ Samsung Electronics Co. LTD - * - * 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 _S3C_MEM_COMMON_H_ -#define _S3C_MEM_COMMON_H_ - -#define MEM_IOCTL_MAGIC 'M' - -#define S3C_MEM_ALLOC _IOWR(MEM_IOCTL_MAGIC, 310, struct s3c_mem_alloc) -#define S3C_MEM_FREE _IOWR(MEM_IOCTL_MAGIC, 311, struct s3c_mem_alloc) - -#define S3C_MEM_SHARE_ALLOC _IOWR(MEM_IOCTL_MAGIC, 314, struct s3c_mem_alloc) -#define S3C_MEM_SHARE_FREE _IOWR(MEM_IOCTL_MAGIC, 315, struct s3c_mem_alloc) - -#define S3C_MEM_CACHEABLE_ALLOC _IOWR(MEM_IOCTL_MAGIC, 316, struct s3c_mem_alloc) -#define S3C_MEM_CACHEABLE_SHARE_ALLOC _IOWR(MEM_IOCTL_MAGIC, 317, struct s3c_mem_alloc) - -#define S3C_MEM_DMA_COPY _IOWR(MEM_IOCTL_MAGIC, 318, struct s3c_mem_dma_param) -#define S3C_MEM_DMA_SET _IOWR(MEM_IOCTL_MAGIC, 319, struct s3c_mem_dma_param) - -#define S3C_MEM_CACHE_INV _IOWR(MEM_IOCTL_MAGIC, 330, struct s3c_mem_dma_param) - - -struct s3c_mem_alloc { - int size; - unsigned int vir_addr; - unsigned int phy_addr; -}; - -struct s3c_mem_dma_param { - int size; - unsigned int src_addr; - unsigned int dst_addr; - int cfg; -}; - -#if 0 -typedef struct _s3c_mem_t{ - int dev_fd; - struct s3c_mem_alloc mem_alloc_info; -}s3c_mem_t; -#endif -#endif // _S3C_MEM_COMMON_H_ diff --git a/aries/include/s5p_fimc.h b/aries/include/s5p_fimc.h deleted file mode 100755 index d2c760c..0000000 --- a/aries/include/s5p_fimc.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright@ Samsung Electronics Co. LTD - * - * 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 _S5P_FIMC_H_ -#define _S5P_FIMC_H_ - -#include - -/* - * G E N E R A L S - * -*/ -#define MIN(x, y) ((x < y) ? x : y) - -/* - * P I X E L F O R M A T G U I D E - * - * The 'x' means 'DO NOT CARE' - * The '*' means 'FIMC SPECIFIC' - * For some fimc formats, we couldn't find equivalent format in the V4L2 FOURCC. - * - * FIMC TYPE PLANES ORDER V4L2_PIX_FMT - * --------------------------------------------------------- - * RGB565 x x V4L2_PIX_FMT_RGB565 - * RGB888 x x V4L2_PIX_FMT_RGB24 - * YUV420 2 LSB_CBCR V4L2_PIX_FMT_NV12 - * YUV420 2 LSB_CRCB V4L2_PIX_FMT_NV21 - * YUV420 2 MSB_CBCR V4L2_PIX_FMT_NV21X* - * YUV420 2 MSB_CRCB V4L2_PIX_FMT_NV12X* - * YUV420 3 x V4L2_PIX_FMT_YUV420 - * YUV422 1 YCBYCR V4L2_PIX_FMT_YUYV - * YUV422 1 YCRYCB V4L2_PIX_FMT_YVYU - * YUV422 1 CBYCRY V4L2_PIX_FMT_UYVY - * YUV422 1 CRYCBY V4L2_PIX_FMT_VYUY* - * YUV422 2 LSB_CBCR V4L2_PIX_FMT_NV16* - * YUV422 2 LSB_CRCB V4L2_PIX_FMT_NV61* - * YUV422 2 MSB_CBCR V4L2_PIX_FMT_NV16X* - * YUV422 2 MSB_CRCB V4L2_PIX_FMT_NV61X* - * YUV422 3 x V4L2_PIX_FMT_YUV422P - * -*/ - -/* - * V 4 L 2 F I M C E X T E N S I O N S - * -*/ -#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') - -/* FOURCC for FIMC specific */ -#define V4L2_PIX_FMT_NV12X v4l2_fourcc('N', '1', '2', 'X') -#define V4L2_PIX_FMT_NV21X v4l2_fourcc('N', '2', '1', 'X') -#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') -#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') -#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') -#define V4L2_PIX_FMT_NV16X v4l2_fourcc('N', '1', '6', 'X') -#define V4L2_PIX_FMT_NV61X v4l2_fourcc('N', '6', '1', 'X') - -#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */ - -/* CID extensions */ -#define V4L2_CID_ROTATION (V4L2_CID_PRIVATE_BASE + 0) -#define V4L2_CID_RESERVED_MEM_BASE_ADDR (V4L2_CID_PRIVATE_BASE + 20) -#define V4L2_CID_FIMC_VERSION (V4L2_CID_PRIVATE_BASE + 21) -/* - * U S E R D E F I N E D T Y P E S - * -*/ - -typedef unsigned int dma_addr_t; - -struct fimc_buf { - dma_addr_t base[3]; - size_t length[3]; -}; - -struct fimc_buffer { - void *virt_addr; - void *phys_addr; - size_t length; -}; - -struct yuv_fmt_list { - const char *name; - const char *desc; - unsigned int fmt; - int bpp; - int planes; -}; - -struct img_offset { - int y_h; - int y_v; - int cb_h; - int cb_v; - int cr_h; - int cr_v; -}; - -//------------ STRUCT ---------------------------------------------------------// - -typedef struct -{ - unsigned int full_width; // Source Image Full Width (Virtual screen size) - unsigned int full_height; // Source Image Full Height (Virtual screen size) - unsigned int start_x; // Source Image Start width offset - unsigned int start_y; // Source Image Start height offset - unsigned int width; // Source Image Width - unsigned int height; // Source Image Height - unsigned int buf_addr_phy_rgb_y; // Base Address of the Source Image (RGB or Y): Physical Address - unsigned int buf_addr_phy_cb; // Base Address of the Source Image (CB Component) : Physical Address - unsigned int buf_addr_phy_cr; // Base Address of the Source Image (CR Component) : Physical Address - unsigned int color_space; // Color Space of the Source Image -} s5p_fimc_img_info; - -typedef struct -{ - s5p_fimc_img_info src; - s5p_fimc_img_info dst; -} s5p_fimc_params_t; - -typedef struct _s5p_fimc_t { - int dev_fd; - struct fimc_buffer out_buf; - - s5p_fimc_params_t params; - - int use_ext_out_mem; - unsigned int hw_ver; -}s5p_fimc_t; - -//------------------------ functions for v4l2 ------------------------------// -int fimc_v4l2_set_src(int fd, unsigned int hw_ver, s5p_fimc_img_info *src); -int fimc_v4l2_set_dst(int fd, s5p_fimc_img_info *dst, int rotation, unsigned int addr); -int fimc_v4l2_stream_on(int fd, enum v4l2_buf_type type); -int fimc_v4l2_queue(int fd, struct fimc_buf *fimc_buf); -int fimc_v4l2_dequeue(int fd); -int fimc_v4l2_stream_off(int fd); -int fimc_v4l2_clr_buf(int fd); -int fimc_handle_oneshot(int fd, struct fimc_buf *fimc_buf); -#endif diff --git a/aries/include/videodev2_samsung.h b/aries/include/videodev2_samsung.h deleted file mode 100755 index 0a7d7c3..0000000 --- a/aries/include/videodev2_samsung.h +++ /dev/null @@ -1,633 +0,0 @@ -/* - * Video for Linux Two header file for samsung - * - * Copyright (C) 2009, Samsung Electronics - * - * This header file contains several v4l2 APIs to be proposed to v4l2 - * community and until bein accepted, will be used restrictly in Samsung's - * camera interface driver FIMC. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Alternatively, 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 __LINUX_VIDEODEV2_SAMSUNG_H -#define __LINUX_VIDEODEV2_SAMSUNG_H - -/* Values for 'capabilities' field */ -/* Object detection device */ -#define V4L2_CAP_OBJ_RECOGNITION 0x10000000 -/* strobe control */ -#define V4L2_CAP_STROBE 0x20000000 - -#define V4L2_CID_FOCUS_MODE (V4L2_CID_CAMERA_CLASS_BASE + 17) -/* Focus Methods */ -enum v4l2_focus_mode { - V4L2_FOCUS_MODE_AUTO = 0, - V4L2_FOCUS_MODE_MACRO = 1, - V4L2_FOCUS_MODE_MANUAL = 2, - V4L2_FOCUS_MODE_LASTP = 2, -}; - -#define V4L2_CID_ZOOM_MODE (V4L2_CID_CAMERA_CLASS_BASE + 18) -/* Zoom Methods */ -enum v4l2_zoom_mode { - V4L2_ZOOM_MODE_CONTINUOUS = 0, - V4L2_ZOOM_MODE_OPTICAL = 1, - V4L2_ZOOM_MODE_DIGITAL = 2, - V4L2_ZOOM_MODE_LASTP = 2, -}; - -/* Exposure Methods */ -#define V4L2_CID_PHOTOMETRY (V4L2_CID_CAMERA_CLASS_BASE + 19) -enum v4l2_photometry_mode { - V4L2_PHOTOMETRY_MULTISEG = 0, /*Multi Segment */ - V4L2_PHOTOMETRY_CWA = 1, /*Centre Weighted Average */ - V4L2_PHOTOMETRY_SPOT = 2, - V4L2_PHOTOMETRY_AFSPOT = 3, /*Spot metering on focused point */ - V4L2_PHOTOMETRY_LASTP = V4L2_PHOTOMETRY_AFSPOT, -}; - -/* Manual exposure control items menu type: iris, shutter, iso */ -#define V4L2_CID_CAM_APERTURE (V4L2_CID_CAMERA_CLASS_BASE + 20) -#define V4L2_CID_CAM_SHUTTER (V4L2_CID_CAMERA_CLASS_BASE + 21) -#define V4L2_CID_CAM_ISO (V4L2_CID_CAMERA_CLASS_BASE + 22) - -/* Following CIDs are menu type */ -#define V4L2_CID_SCENEMODE (V4L2_CID_CAMERA_CLASS_BASE + 23) -#define V4L2_CID_CAM_STABILIZE (V4L2_CID_CAMERA_CLASS_BASE + 24) -#define V4L2_CID_CAM_MULTISHOT (V4L2_CID_CAMERA_CLASS_BASE + 25) - -/* Control dynamic range */ -#define V4L2_CID_CAM_DR (V4L2_CID_CAMERA_CLASS_BASE + 26) - -/* White balance preset control */ -#define V4L2_CID_WHITE_BALANCE_PRESET (V4L2_CID_CAMERA_CLASS_BASE + 27) - -/* CID extensions */ -#define V4L2_CID_ROTATION (V4L2_CID_PRIVATE_BASE + 0) -#define V4L2_CID_PADDR_Y (V4L2_CID_PRIVATE_BASE + 1) -#define V4L2_CID_PADDR_CB (V4L2_CID_PRIVATE_BASE + 2) -#define V4L2_CID_PADDR_CR (V4L2_CID_PRIVATE_BASE + 3) -#define V4L2_CID_PADDR_CBCR (V4L2_CID_PRIVATE_BASE + 4) -#define V4L2_CID_OVERLAY_AUTO (V4L2_CID_PRIVATE_BASE + 5) -#define V4L2_CID_OVERLAY_VADDR0 (V4L2_CID_PRIVATE_BASE + 6) -#define V4L2_CID_OVERLAY_VADDR1 (V4L2_CID_PRIVATE_BASE + 7) -#define V4L2_CID_OVERLAY_VADDR2 (V4L2_CID_PRIVATE_BASE + 8) -#define V4L2_CID_OVLY_MODE (V4L2_CID_PRIVATE_BASE + 9) -#define V4L2_CID_DST_INFO (V4L2_CID_PRIVATE_BASE + 10) -#define V4L2_CID_IMAGE_EFFECT_FN (V4L2_CID_PRIVATE_BASE + 16) -#define V4L2_CID_IMAGE_EFFECT_APPLY (V4L2_CID_PRIVATE_BASE + 17) -#define V4L2_CID_IMAGE_EFFECT_CB (V4L2_CID_PRIVATE_BASE + 18) -#define V4L2_CID_IMAGE_EFFECT_CR (V4L2_CID_PRIVATE_BASE + 19) -#define V4L2_CID_RESERVED_MEM_BASE_ADDR (V4L2_CID_PRIVATE_BASE + 20) -#define V4L2_CID_FIMC_VERSION (V4L2_CID_PRIVATE_BASE + 21) - -#define V4L2_CID_STREAM_PAUSE (V4L2_CID_PRIVATE_BASE + 53) - -/* CID Extensions for camera sensor operations */ -#define V4L2_CID_CAM_PREVIEW_ONOFF (V4L2_CID_PRIVATE_BASE + 64) -#define V4L2_CID_CAM_CAPTURE (V4L2_CID_PRIVATE_BASE + 65) -#define V4L2_CID_CAM_JPEG_MEMSIZE (V4L2_CID_PRIVATE_BASE + 66) - -#define V4L2_CID_CAM_DATE_INFO_YEAR (V4L2_CID_PRIVATE_BASE + 14) -#define V4L2_CID_CAM_DATE_INFO_MONTH (V4L2_CID_PRIVATE_BASE + 15) -#define V4L2_CID_CAM_DATE_INFO_DATE (V4L2_CID_PRIVATE_BASE + 22) -#define V4L2_CID_CAM_SENSOR_VER (V4L2_CID_PRIVATE_BASE + 23) -#define V4L2_CID_CAM_FW_MINOR_VER (V4L2_CID_PRIVATE_BASE + 24) -#define V4L2_CID_CAM_FW_MAJOR_VER (V4L2_CID_PRIVATE_BASE + 25) -#define V4L2_CID_CAM_PRM_MINOR_VER (V4L2_CID_PRIVATE_BASE + 26) -#define V4L2_CID_CAM_PRM_MAJOR_VER (V4L2_CID_PRIVATE_BASE + 27) -#define V4L2_CID_CAM_FW_VER (V4L2_CID_PRIVATE_BASE + 28) -#define V4L2_CID_CAM_SET_FW_ADDR (V4L2_CID_PRIVATE_BASE + 29) -#define V4L2_CID_CAM_SET_FW_SIZE (V4L2_CID_PRIVATE_BASE + 30) -#define V4L2_CID_CAM_UPDATE_FW (V4L2_CID_PRIVATE_BASE + 31) -#define V4L2_CID_CAM_JPEG_MAIN_SIZE (V4L2_CID_PRIVATE_BASE + 32) -#define V4L2_CID_CAM_JPEG_MAIN_OFFSET (V4L2_CID_PRIVATE_BASE + 33) -#define V4L2_CID_CAM_JPEG_THUMB_SIZE (V4L2_CID_PRIVATE_BASE + 34) -#define V4L2_CID_CAM_JPEG_THUMB_OFFSET (V4L2_CID_PRIVATE_BASE + 35) -#define V4L2_CID_CAM_JPEG_POSTVIEW_OFFSET (V4L2_CID_PRIVATE_BASE + 36) -#define V4L2_CID_CAM_JPEG_QUALITY (V4L2_CID_PRIVATE_BASE + 37) -#define V4L2_CID_CAM_SENSOR_MAKER (V4L2_CID_PRIVATE_BASE + 38) -#define V4L2_CID_CAM_SENSOR_OPTICAL (V4L2_CID_PRIVATE_BASE + 39) -#define V4L2_CID_CAM_AF_VER_LOW (V4L2_CID_PRIVATE_BASE + 40) -#define V4L2_CID_CAM_AF_VER_HIGH (V4L2_CID_PRIVATE_BASE + 41) -#define V4L2_CID_CAM_GAMMA_RG_LOW (V4L2_CID_PRIVATE_BASE + 42) -#define V4L2_CID_CAM_GAMMA_RG_HIGH (V4L2_CID_PRIVATE_BASE + 43) -#define V4L2_CID_CAM_GAMMA_BG_LOW (V4L2_CID_PRIVATE_BASE + 44) -#define V4L2_CID_CAM_GAMMA_BG_HIGH (V4L2_CID_PRIVATE_BASE + 45) -#define V4L2_CID_CAM_DUMP_FW (V4L2_CID_PRIVATE_BASE + 46) -#define V4L2_CID_CAM_GET_DUMP_SIZE (V4L2_CID_PRIVATE_BASE + 47) -#define V4L2_CID_CAMERA_VT_MODE (V4L2_CID_PRIVATE_BASE + 48) -#define V4L2_CID_CAMERA_VGA_BLUR (V4L2_CID_PRIVATE_BASE + 49) -#define V4L2_CID_CAMERA_CAPTURE (V4L2_CID_PRIVATE_BASE + 50) - -#define V4L2_CID_MAIN_SW_DATE_INFO_YEAR (V4L2_CID_PRIVATE_BASE + 54) -#define V4L2_CID_MAIN_SW_DATE_INFO_MONTH (V4L2_CID_PRIVATE_BASE + 55) -#define V4L2_CID_MAIN_SW_DATE_INFO_DATE (V4L2_CID_PRIVATE_BASE + 56) -#define V4L2_CID_MAIN_SW_FW_MINOR_VER (V4L2_CID_PRIVATE_BASE + 57) -#define V4L2_CID_MAIN_SW_FW_MAJOR_VER (V4L2_CID_PRIVATE_BASE + 58) -#define V4L2_CID_MAIN_SW_PRM_MINOR_VER (V4L2_CID_PRIVATE_BASE + 59) -#define V4L2_CID_MAIN_SW_PRM_MAJOR_VER (V4L2_CID_PRIVATE_BASE + 60) - -enum v4l2_blur { - BLUR_LEVEL_0 = 0, - BLUR_LEVEL_1, - BLUR_LEVEL_2, - BLUR_LEVEL_3, - BLUR_LEVEL_MAX, -}; - -#define V4L2_CID_CAMERA_SCENE_MODE (V4L2_CID_PRIVATE_BASE + 70) -enum v4l2_scene_mode { - SCENE_MODE_BASE, - SCENE_MODE_NONE, - SCENE_MODE_PORTRAIT, - SCENE_MODE_NIGHTSHOT, - SCENE_MODE_BACK_LIGHT, - SCENE_MODE_LANDSCAPE, - SCENE_MODE_SPORTS, - SCENE_MODE_PARTY_INDOOR, - SCENE_MODE_BEACH_SNOW, - SCENE_MODE_SUNSET, - SCENE_MODE_DUST_DAWN, - SCENE_MODE_FALL_COLOR, - SCENE_MODE_FIREWORKS, - SCENE_MODE_TEXT, - SCENE_MODE_CANDLE_LIGHT, - SCENE_MODE_MAX, -}; - -#define V4L2_CID_CAMERA_FLASH_MODE (V4L2_CID_PRIVATE_BASE + 71) -enum v4l2_flash_mode { - FLASH_MODE_BASE, - FLASH_MODE_OFF, - FLASH_MODE_AUTO, - FLASH_MODE_ON, - FLASH_MODE_TORCH, - FLASH_MODE_MAX, -}; - -#define V4L2_CID_CAMERA_BRIGHTNESS (V4L2_CID_PRIVATE_BASE + 72) -enum v4l2_ev_mode { - EV_MINUS_4 = 0, - EV_MINUS_3, - EV_MINUS_2, - EV_MINUS_1, - EV_DEFAULT, - EV_PLUS_1, - EV_PLUS_2, - EV_PLUS_3, - EV_PLUS_4, - EV_MAX, -}; - -#define V4L2_CID_CAMERA_WHITE_BALANCE (V4L2_CID_PRIVATE_BASE + 73) -enum v4l2_wb_mode { - WHITE_BALANCE_BASE = 0, - WHITE_BALANCE_AUTO, - WHITE_BALANCE_SUNNY, - WHITE_BALANCE_CLOUDY, - WHITE_BALANCE_TUNGSTEN, - WHITE_BALANCE_FLUORESCENT, - WHITE_BALANCE_MAX, -}; - -#define V4L2_CID_CAMERA_EFFECT (V4L2_CID_PRIVATE_BASE + 74) -enum v4l2_effect_mode { - IMAGE_EFFECT_BASE = 0, - IMAGE_EFFECT_NONE, - IMAGE_EFFECT_BNW, - IMAGE_EFFECT_SEPIA, - IMAGE_EFFECT_AQUA, - IMAGE_EFFECT_ANTIQUE, - IMAGE_EFFECT_NEGATIVE, - IMAGE_EFFECT_SHARPEN, - IMAGE_EFFECT_MAX, -}; - -#define V4L2_CID_CAMERA_ISO (V4L2_CID_PRIVATE_BASE + 75) -enum v4l2_iso_mode { - ISO_AUTO = 0, - ISO_50, - ISO_100, - ISO_200, - ISO_400, - ISO_800, - ISO_1600, - ISO_SPORTS, - ISO_NIGHT, - ISO_MOVIE, - ISO_MAX, -}; - -#define V4L2_CID_CAMERA_METERING (V4L2_CID_PRIVATE_BASE + 76) -enum v4l2_metering_mode { - METERING_BASE = 0, - METERING_MATRIX, - METERING_CENTER, - METERING_SPOT, - METERING_MAX, -}; - -#define V4L2_CID_CAMERA_CONTRAST (V4L2_CID_PRIVATE_BASE + 77) -enum v4l2_contrast_mode { - CONTRAST_MINUS_2 = 0, - CONTRAST_MINUS_1, - CONTRAST_DEFAULT, - CONTRAST_PLUS_1, - CONTRAST_PLUS_2, - CONTRAST_MAX, -}; - -#define V4L2_CID_CAMERA_SATURATION (V4L2_CID_PRIVATE_BASE + 78) -enum v4l2_saturation_mode { - SATURATION_MINUS_2 = 0, - SATURATION_MINUS_1, - SATURATION_DEFAULT, - SATURATION_PLUS_1, - SATURATION_PLUS_2, - SATURATION_MAX, -}; - -#define V4L2_CID_CAMERA_SHARPNESS (V4L2_CID_PRIVATE_BASE + 79) -enum v4l2_sharpness_mode { - SHARPNESS_MINUS_2 = 0, - SHARPNESS_MINUS_1, - SHARPNESS_DEFAULT, - SHARPNESS_PLUS_1, - SHARPNESS_PLUS_2, - SHARPNESS_MAX, -}; - -#define V4L2_CID_CAMERA_WDR (V4L2_CID_PRIVATE_BASE + 80) -enum v4l2_wdr_mode { - WDR_OFF, - WDR_ON, - WDR_MAX, -}; - -#define V4L2_CID_CAMERA_ANTI_SHAKE (V4L2_CID_PRIVATE_BASE + 81) -enum v4l2_anti_shake_mode { - ANTI_SHAKE_OFF, - ANTI_SHAKE_STILL_ON, - ANTI_SHAKE_MOVIE_ON, - ANTI_SHAKE_MAX, -}; - -#define V4L2_CID_CAMERA_TOUCH_AF_START_STOP (V4L2_CID_PRIVATE_BASE + 82) -enum v4l2_touch_af { - TOUCH_AF_STOP = 0, - TOUCH_AF_START, - TOUCH_AF_MAX, -}; - -#define V4L2_CID_CAMERA_SMART_AUTO (V4L2_CID_PRIVATE_BASE + 83) -enum v4l2_smart_auto { - SMART_AUTO_OFF = 0, - SMART_AUTO_ON, - SMART_AUTO_MAX, -}; - -#define V4L2_CID_CAMERA_VINTAGE_MODE (V4L2_CID_PRIVATE_BASE + 84) -enum v4l2_vintage_mode { - VINTAGE_MODE_BASE, - VINTAGE_MODE_OFF, - VINTAGE_MODE_NORMAL, - VINTAGE_MODE_WARM, - VINTAGE_MODE_COOL, - VINTAGE_MODE_BNW, - VINTAGE_MODE_MAX, -}; - -#define V4L2_CID_CAMERA_JPEG_QUALITY (V4L2_CID_PRIVATE_BASE + 85) -#define V4L2_CID_CAMERA_GPS_LATITUDE (V4L2_CID_CAMERA_CLASS_BASE + 30) -#define V4L2_CID_CAMERA_GPS_LONGITUDE (V4L2_CID_CAMERA_CLASS_BASE + 31) -#define V4L2_CID_CAMERA_GPS_TIMESTAMP (V4L2_CID_CAMERA_CLASS_BASE + 32) -#define V4L2_CID_CAMERA_GPS_ALTITUDE (V4L2_CID_CAMERA_CLASS_BASE + 33) -#define V4L2_CID_CAMERA_EXIF_TIME_INFO (V4L2_CID_CAMERA_CLASS_BASE + 34) -#define V4L2_CID_CAMERA_ZOOM (V4L2_CID_PRIVATE_BASE + 90) -enum v4l2_zoom_level { - ZOOM_LEVEL_0 = 0, - ZOOM_LEVEL_1, - ZOOM_LEVEL_2, - ZOOM_LEVEL_3, - ZOOM_LEVEL_4, - ZOOM_LEVEL_5, - ZOOM_LEVEL_6, - ZOOM_LEVEL_7, - ZOOM_LEVEL_8, - ZOOM_LEVEL_9, - ZOOM_LEVEL_10, - ZOOM_LEVEL_11, - ZOOM_LEVEL_12, - ZOOM_LEVEL_MAX, -}; - -#define V4L2_CID_CAMERA_FACE_DETECTION (V4L2_CID_PRIVATE_BASE + 91) -enum v4l2_face_detection { - FACE_DETECTION_OFF = 0, - FACE_DETECTION_ON, - FACE_DETECTION_NOLINE, - FACE_DETECTION_ON_BEAUTY, - FACE_DETECTION_MAX, -}; - -#define V4L2_CID_CAMERA_SMART_AUTO_STATUS (V4L2_CID_PRIVATE_BASE + 92) -enum v4l2_smart_auto_status { - SMART_AUTO_STATUS_AUTO = 0, - SMART_AUTO_STATUS_LANDSCAPE, - SMART_AUTO_STATUS_PORTRAIT, - SMART_AUTO_STATUS_MACRO, - SMART_AUTO_STATUS_NIGHT, - SMART_AUTO_STATUS_PORTRAIT_NIGHT, - SMART_AUTO_STATUS_BACKLIT, - SMART_AUTO_STATUS_PORTRAIT_BACKLIT, - SMART_AUTO_STATUS_ANTISHAKE, - SMART_AUTO_STATUS_PORTRAIT_ANTISHAKE, - SMART_AUTO_STATUS_MAX, -}; - -#define V4L2_CID_CAMERA_SET_AUTO_FOCUS (V4L2_CID_PRIVATE_BASE + 93) -enum v4l2_auto_focus { - AUTO_FOCUS_OFF = 0, - AUTO_FOCUS_ON, - AUTO_FOCUS_MAX, -}; - -#define V4L2_CID_CAMERA_BEAUTY_SHOT (V4L2_CID_PRIVATE_BASE + 94) -enum v4l2_beauty_shot { - BEAUTY_SHOT_OFF = 0, - BEAUTY_SHOT_ON, - BEAUTY_SHOT_MAX, -}; - -#define V4L2_CID_CAMERA_AEAWB_LOCK_UNLOCK (V4L2_CID_PRIVATE_BASE + 95) -enum v4l2_ae_awb_lockunlock { - AE_UNLOCK_AWB_UNLOCK = 0, - AE_LOCK_AWB_UNLOCK, - AE_UNLOCK_AWB_LOCK, - AE_LOCK_AWB_LOCK, - AE_AWB_MAX -}; - -#define V4L2_CID_CAMERA_FACEDETECT_LOCKUNLOCK (V4L2_CID_PRIVATE_BASE + 96) -enum v4l2_face_lock { - FACE_LOCK_OFF = 0, - FACE_LOCK_ON, - FIRST_FACE_TRACKING, - FACE_LOCK_MAX, -}; - -#define V4L2_CID_CAMERA_OBJECT_POSITION_X (V4L2_CID_PRIVATE_BASE + 97) -#define V4L2_CID_CAMERA_OBJECT_POSITION_Y (V4L2_CID_PRIVATE_BASE + 98) -#define V4L2_CID_CAMERA_FOCUS_MODE (V4L2_CID_PRIVATE_BASE + 99) -enum v4l2_focusmode { - FOCUS_MODE_AUTO = 0, - FOCUS_MODE_MACRO, - FOCUS_MODE_FACEDETECT, - FOCUS_MODE_AUTO_DEFAULT, - FOCUS_MODE_MACRO_DEFAULT, - FOCUS_MODE_FACEDETECT_DEFAULT, - FOCUS_MODE_INFINITY, - FOCUS_MODE_MAX, -}; - -#define V4L2_CID_CAMERA_OBJ_TRACKING_STATUS (V4L2_CID_PRIVATE_BASE + 100) -enum v4l2_obj_tracking_status { - OBJECT_TRACKING_STATUS_BASE, - OBJECT_TRACKING_STATUS_PROGRESSING, - OBJECT_TRACKING_STATUS_SUCCESS, - OBJECT_TRACKING_STATUS_FAIL, - OBJECT_TRACKING_STATUS_MISSING, - OBJECT_TRACKING_STATUS_MAX, -}; - -#define V4L2_CID_CAMERA_OBJ_TRACKING_START_STOP (V4L2_CID_PRIVATE_BASE + 101) -enum v4l2_ot_start_stop { - OT_STOP = 0, - OT_START, - OT_MAX, -}; - -#define V4L2_CID_CAMERA_CAF_START_STOP (V4L2_CID_PRIVATE_BASE + 102) -enum v4l2_caf_start_stop { - CAF_STOP = 0, - CAF_START, - CAF_MAX, -}; - -#define V4L2_CID_CAMERA_AUTO_FOCUS_RESULT (V4L2_CID_PRIVATE_BASE + 103) -#define V4L2_CID_CAMERA_FRAME_RATE (V4L2_CID_PRIVATE_BASE + 104) -enum v4l2_frame_rate { - FRAME_RATE_AUTO = 0, - FRAME_RATE_7 = 7, - FRAME_RATE_15 = 15, - FRAME_RATE_30 = 30, - FRAME_RATE_60 = 60, - FRAME_RATE_120 = 120, - FRAME_RATE_MAX -}; - -#define V4L2_CID_CAMERA_ANTI_BANDING (V4L2_CID_PRIVATE_BASE + 105) -enum v4l2_anti_banding { - ANTI_BANDING_AUTO = 0, - ANTI_BANDING_50HZ = 1, - ANTI_BANDING_60HZ = 2, - ANTI_BANDING_OFF = 3, -}; - -#define V4L2_CID_CAMERA_SET_GAMMA (V4L2_CID_PRIVATE_BASE + 106) -enum v4l2_gamma_mode { - GAMMA_OFF = 0, - GAMMA_ON = 1, - GAMMA_MAX, -}; - -#define V4L2_CID_CAMERA_SET_SLOW_AE (V4L2_CID_PRIVATE_BASE + 107) -enum v4l2_slow_ae_mode { - SLOW_AE_OFF, - SLOW_AE_ON, - SLOW_AE_MAX, -}; - -#define V4L2_CID_CAMERA_BATCH_REFLECTION (V4L2_CID_PRIVATE_BASE + 108) -#define V4L2_CID_CAMERA_EXIF_ORIENTATION (V4L2_CID_PRIVATE_BASE + 109) - -#define V4L2_CID_CAMERA_RESET (V4L2_CID_PRIVATE_BASE + 111) -#define V4L2_CID_CAMERA_CHECK_DATALINE (V4L2_CID_PRIVATE_BASE + 112) -#define V4L2_CID_CAMERA_CHECK_DATALINE_STOP (V4L2_CID_PRIVATE_BASE + 113) -#define V4L2_CID_CAMERA_GET_ISO (V4L2_CID_PRIVATE_BASE + 114) -#define V4L2_CID_CAMERA_GET_SHT_TIME (V4L2_CID_PRIVATE_BASE + 115) -#define V4L2_CID_CAMERA_SENSOR_MODE (V4L2_CID_PRIVATE_BASE + 116) -#define V4L2_CID_ESD_INT (V4L2_CID_PRIVATE_BASE + 117) -#define V4L2_CID_CAMERA_GET_FLASH_ONOFF (V4L2_CID_PRIVATE_BASE + 118) -#define V4L2_CID_CAMERA_RETURN_FOCUS (V4L2_CID_PRIVATE_BASE + 119) - -/* Pixel format FOURCC depth Description */ -/* 12 Y/CbCr 4:2:0 64x32 macroblocks */ -#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2') - -/* - * * V4L2 extention for digital camera - * */ -/* Strobe flash light */ -enum v4l2_strobe_control { - /* turn off the flash light */ - V4L2_STROBE_CONTROL_OFF = 0, - /* turn on the flash light */ - V4L2_STROBE_CONTROL_ON = 1, - /* act guide light before splash */ - V4L2_STROBE_CONTROL_AFGUIDE = 2, - /* charge the flash light */ - V4L2_STROBE_CONTROL_CHARGE = 3, -}; - -enum v4l2_strobe_conf { - V4L2_STROBE_OFF = 0, /* Always off */ - V4L2_STROBE_ON = 1, /* Always splashes */ - /* Auto control presets */ - V4L2_STROBE_AUTO = 2, - V4L2_STROBE_REDEYE_REDUCTION = 3, - V4L2_STROBE_SLOW_SYNC = 4, - V4L2_STROBE_FRONT_CURTAIN = 5, - V4L2_STROBE_REAR_CURTAIN = 6, - /* Extra manual control presets */ - /* keep turned on until turning off */ - V4L2_STROBE_PERMANENT = 7, - V4L2_STROBE_EXTERNAL = 8, -}; - -enum v4l2_strobe_status { - V4L2_STROBE_STATUS_OFF = 0, - /* while processing configurations */ - V4L2_STROBE_STATUS_BUSY = 1, - V4L2_STROBE_STATUS_ERR = 2, - V4L2_STROBE_STATUS_CHARGING = 3, - V4L2_STROBE_STATUS_CHARGED = 4, -}; - -/* capabilities field */ -/* No strobe supported */ -#define V4L2_STROBE_CAP_NONE 0x0000 -/* Always flash off mode */ -#define V4L2_STROBE_CAP_OFF 0x0001 -/* Always use flash light mode */ -#define V4L2_STROBE_CAP_ON 0x0002 -/* Flashlight works automatic */ -#define V4L2_STROBE_CAP_AUTO 0x0004 -/* Red-eye reduction */ -#define V4L2_STROBE_CAP_REDEYE 0x0008 -/* Slow sync */ -#define V4L2_STROBE_CAP_SLOWSYNC 0x0010 -/* Front curtain */ -#define V4L2_STROBE_CAP_FRONT_CURTAIN 0x0020 -/* Rear curtain */ -#define V4L2_STROBE_CAP_REAR_CURTAIN 0x0040 -/* keep turned on until turning off */ -#define V4L2_STROBE_CAP_PERMANENT 0x0080 -/* use external strobe */ -#define V4L2_STROBE_CAP_EXTERNAL 0x0100 - -/* Set mode and Get status */ -struct v4l2_strobe { - /* off/on/charge:0/1/2 */ - enum v4l2_strobe_control control; - /* supported strobe capabilities */ - __u32 capabilities; - enum v4l2_strobe_conf mode; - enum v4l2_strobe_status status; /* read only */ - /* default is 0 and range of value varies from each models */ - __u32 flash_ev; - __u32 reserved[4]; -}; - -#define VIDIOC_S_STROBE _IOWR('V', 83, struct v4l2_strobe) -#define VIDIOC_G_STROBE _IOR('V', 84, struct v4l2_strobe) - -/* Object recognition and collateral actions */ -enum v4l2_recog_mode { - V4L2_RECOGNITION_MODE_OFF = 0, - V4L2_RECOGNITION_MODE_ON = 1, - V4L2_RECOGNITION_MODE_LOCK = 2, -}; - -enum v4l2_recog_action { - V4L2_RECOGNITION_ACTION_NONE = 0, /* only recognition */ - V4L2_RECOGNITION_ACTION_BLINK = 1, /* Capture on blinking */ - V4L2_RECOGNITION_ACTION_SMILE = 2, /* Capture on smiling */ -}; - -enum v4l2_recog_pattern { - V4L2_RECOG_PATTERN_FACE = 0, /* Face */ - V4L2_RECOG_PATTERN_HUMAN = 1, /* Human */ - V4L2_RECOG_PATTERN_CHAR = 2, /* Character */ -}; - -struct v4l2_recog_rect { - enum v4l2_recog_pattern p; /* detected pattern */ - struct v4l2_rect o; /* detected area */ - __u32 reserved[4]; -}; - -struct v4l2_recog_data { - __u8 detect_cnt; /* detected object counter */ - struct v4l2_rect o; /* detected area */ - __u32 reserved[4]; -}; - -struct v4l2_recognition { - enum v4l2_recog_mode mode; - - /* Which pattern to detect */ - enum v4l2_recog_pattern pattern; - - /* How many object to detect */ - __u8 obj_num; - - /* select detected object */ - __u32 detect_idx; - - /* read only :Get object coordination */ - struct v4l2_recog_data data; - - enum v4l2_recog_action action; - __u32 reserved[4]; -}; - -#define VIDIOC_S_RECOGNITION _IOWR('V', 85, struct v4l2_recognition) -#define VIDIOC_G_RECOGNITION _IOR('V', 86, struct v4l2_recognition) - -/* We use this struct as the v4l2_streamparm raw_data for - * VIDIOC_G_PARM and VIDIOC_S_PARM - */ -struct sec_cam_parm { - struct v4l2_captureparm capture; - int contrast; - int effects; - int brightness; - int flash_mode; - int focus_mode; - int iso; - int metering; - int saturation; - int scene_mode; - int sharpness; - int white_balance; -}; - -#endif /* __LINUX_VIDEODEV2_SAMSUNG_H */ diff --git a/aries/libaudio/Android.mk b/aries/libaudio/Android.mk deleted file mode 100644 index 43f2ad8..0000000 --- a/aries/libaudio/Android.mk +++ /dev/null @@ -1,49 +0,0 @@ -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_SRC_FILES:= aplay.c alsa_pcm.c alsa_mixer.c -LOCAL_MODULE:= aplay -LOCAL_SHARED_LIBRARIES:= libc libcutils -LOCAL_MODULE_TAGS:= debug -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_SRC_FILES:= arec.c alsa_pcm.c -LOCAL_MODULE:= arec -LOCAL_SHARED_LIBRARIES:= libc libcutils -LOCAL_MODULE_TAGS:= debug -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_SRC_FILES:= amix.c alsa_mixer.c -LOCAL_MODULE:= amix -LOCAL_SHARED_LIBRARIES := libc libcutils -LOCAL_MODULE_TAGS:= debug -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_SRC_FILES:= AudioHardware.cpp alsa_mixer.c alsa_pcm.c -LOCAL_MODULE:= libaudio -LOCAL_STATIC_LIBRARIES:= libaudiointerface -LOCAL_SHARED_LIBRARIES:= libc libcutils libutils libmedia libhardware_legacy -ifeq ($(BOARD_HAVE_BLUETOOTH),true) - LOCAL_SHARED_LIBRARIES += liba2dp -endif - -ifeq ($(TARGET_SIMULATOR),true) - LOCAL_LDLIBS += -ldl -else - LOCAL_SHARED_LIBRARIES += libdl -endif - -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_SRC_FILES:= AudioPolicyManager.cpp -LOCAL_MODULE:= libaudiopolicy -LOCAL_STATIC_LIBRARIES:= libaudiopolicybase -LOCAL_SHARED_LIBRARIES:= libc libcutils libutils libmedia -ifeq ($(BOARD_HAVE_BLUETOOTH),true) - LOCAL_CFLAGS += -DWITH_A2DP -endif -include $(BUILD_SHARED_LIBRARY) diff --git a/aries/libaudio/AudioHardware.cpp b/aries/libaudio/AudioHardware.cpp deleted file mode 100644 index 45f0a2d..0000000 --- a/aries/libaudio/AudioHardware.cpp +++ /dev/null @@ -1,2127 +0,0 @@ -/* -** Copyright 2010, The Android Open-Source Project -** -** 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 - -//#define LOG_NDEBUG 0 - -#define LOG_TAG "AudioHardware" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "AudioHardware.h" -#include -#include - -extern "C" { -#include "alsa_audio.h" -} - - -namespace android { - -const uint32_t AudioHardware::inputSamplingRates[] = { - 8000, 11025, 16000, 22050, 44100 -}; - -// trace driver operations for dump -// -#define DRIVER_TRACE - -enum { - DRV_NONE, - DRV_PCM_OPEN, - DRV_PCM_CLOSE, - DRV_PCM_WRITE, - DRV_PCM_READ, - DRV_MIXER_OPEN, - DRV_MIXER_CLOSE, - DRV_MIXER_GET, - DRV_MIXER_SEL -}; - -#ifdef DRIVER_TRACE -#define TRACE_DRIVER_IN(op) mDriverOp = op; -#define TRACE_DRIVER_OUT mDriverOp = DRV_NONE; -#else -#define TRACE_DRIVER_IN(op) -#define TRACE_DRIVER_OUT -#endif - -// ---------------------------------------------------------------------------- - -const char *AudioHardware::inputPathNameDefault = "Default"; -const char *AudioHardware::inputPathNameCamcorder = "Camcorder"; -const char *AudioHardware::inputPathNameVoiceRecognition = "Voice Recognition"; -const char *AudioHardware::inputPathNameVoiceCommunication = "Voice Communication"; - -AudioHardware::AudioHardware() : - mInit(false), - mMicMute(false), - mPcm(NULL), - mMixer(NULL), - mPcmOpenCnt(0), - mMixerOpenCnt(0), - mInCallAudioMode(false), - mInputSource(AUDIO_SOURCE_DEFAULT), - mBluetoothNrec(true), - mTTYMode(TTY_MODE_OFF), - mSecRilLibHandle(NULL), - mRilClient(0), - mActivatedCP(false), - mDriverOp(DRV_NONE) -{ - loadRILD(); - mInit = true; -} - -AudioHardware::~AudioHardware() -{ - for (size_t index = 0; index < mInputs.size(); index++) { - closeInputStream(mInputs[index].get()); - } - mInputs.clear(); - closeOutputStream((AudioStreamOut*)mOutput.get()); - - if (mMixer) { - TRACE_DRIVER_IN(DRV_MIXER_CLOSE) - mixer_close(mMixer); - TRACE_DRIVER_OUT - } - if (mPcm) { - TRACE_DRIVER_IN(DRV_PCM_CLOSE) - pcm_close(mPcm); - TRACE_DRIVER_OUT - } - - if (mSecRilLibHandle) { - if (disconnectRILD(mRilClient) != RIL_CLIENT_ERR_SUCCESS) - LOGE("Disconnect_RILD() error"); - - if (closeClientRILD(mRilClient) != RIL_CLIENT_ERR_SUCCESS) - LOGE("CloseClient_RILD() error"); - - mRilClient = 0; - - dlclose(mSecRilLibHandle); - mSecRilLibHandle = NULL; - } - - mInit = false; -} - -status_t AudioHardware::initCheck() -{ - return mInit ? NO_ERROR : NO_INIT; -} - -void AudioHardware::loadRILD(void) -{ - mSecRilLibHandle = dlopen("libsecril-client.so", RTLD_NOW); - - if (mSecRilLibHandle) { - LOGV("libsecril-client.so is loaded"); - - openClientRILD = (HRilClient (*)(void)) - dlsym(mSecRilLibHandle, "OpenClient_RILD"); - disconnectRILD = (int (*)(HRilClient)) - dlsym(mSecRilLibHandle, "Disconnect_RILD"); - closeClientRILD = (int (*)(HRilClient)) - dlsym(mSecRilLibHandle, "CloseClient_RILD"); - isConnectedRILD = (int (*)(HRilClient)) - dlsym(mSecRilLibHandle, "isConnected_RILD"); - connectRILD = (int (*)(HRilClient)) - dlsym(mSecRilLibHandle, "Connect_RILD"); - setCallVolume = (int (*)(HRilClient, SoundType, int)) - dlsym(mSecRilLibHandle, "SetCallVolume"); - setCallAudioPath = (int (*)(HRilClient, AudioPath)) - dlsym(mSecRilLibHandle, "SetCallAudioPath"); - setCallClockSync = (int (*)(HRilClient, SoundClockCondition)) - dlsym(mSecRilLibHandle, "SetCallClockSync"); - - if (!openClientRILD || !disconnectRILD || !closeClientRILD || - !isConnectedRILD || !connectRILD || - !setCallVolume || !setCallAudioPath || !setCallClockSync) { - LOGE("Can't load all functions from libsecril-client.so"); - - dlclose(mSecRilLibHandle); - mSecRilLibHandle = NULL; - } else { - mRilClient = openClientRILD(); - if (!mRilClient) { - LOGE("OpenClient_RILD() error"); - - dlclose(mSecRilLibHandle); - mSecRilLibHandle = NULL; - } - } - } else { - LOGE("Can't load libsecril-client.so"); - } -} - -status_t AudioHardware::connectRILDIfRequired(void) -{ - if (!mSecRilLibHandle) { - LOGE("connectIfRequired() lib is not loaded"); - return INVALID_OPERATION; - } - - if (isConnectedRILD(mRilClient)) { - return OK; - } - - if (connectRILD(mRilClient) != RIL_CLIENT_ERR_SUCCESS) { - LOGE("Connect_RILD() error"); - return INVALID_OPERATION; - } - - return OK; -} - -AudioStreamOut* AudioHardware::openOutputStream( - uint32_t devices, int *format, uint32_t *channels, - uint32_t *sampleRate, status_t *status) -{ - sp out; - status_t rc; - - { // scope for the lock - Mutex::Autolock lock(mLock); - - // only one output stream allowed - if (mOutput != 0) { - if (status) { - *status = INVALID_OPERATION; - } - return NULL; - } - - out = new AudioStreamOutALSA(); - - rc = out->set(this, devices, format, channels, sampleRate); - if (rc == NO_ERROR) { - mOutput = out; - } - } - - if (rc != NO_ERROR) { - if (out != 0) { - out.clear(); - } - } - if (status) { - *status = rc; - } - - return out.get(); -} - -void AudioHardware::closeOutputStream(AudioStreamOut* out) { - sp spOut; - { - Mutex::Autolock lock(mLock); - if (mOutput == 0 || mOutput.get() != out) { - LOGW("Attempt to close invalid output stream"); - return; - } - spOut = mOutput; - mOutput.clear(); - } - spOut.clear(); -} - -AudioStreamIn* AudioHardware::openInputStream( - uint32_t devices, int *format, uint32_t *channels, - uint32_t *sampleRate, status_t *status, - AudioSystem::audio_in_acoustics acoustic_flags) -{ - // check for valid input source - if (!AudioSystem::isInputDevice((AudioSystem::audio_devices)devices)) { - if (status) { - *status = BAD_VALUE; - } - return NULL; - } - - status_t rc = NO_ERROR; - sp in; - - { // scope for the lock - Mutex::Autolock lock(mLock); - - in = new AudioStreamInALSA(); - rc = in->set(this, devices, format, channels, sampleRate, acoustic_flags); - if (rc == NO_ERROR) { - mInputs.add(in); - } - } - - if (rc != NO_ERROR) { - if (in != 0) { - in.clear(); - } - } - if (status) { - *status = rc; - } - - LOGV("AudioHardware::openInputStream()%p", in.get()); - return in.get(); -} - -void AudioHardware::closeInputStream(AudioStreamIn* in) { - - sp spIn; - { - Mutex::Autolock lock(mLock); - - ssize_t index = mInputs.indexOf((AudioStreamInALSA *)in); - if (index < 0) { - LOGW("Attempt to close invalid input stream"); - return; - } - spIn = mInputs[index]; - mInputs.removeAt(index); - } - LOGV("AudioHardware::closeInputStream()%p", in); - spIn.clear(); -} - - -status_t AudioHardware::setMode(int mode) -{ - sp spOut; - sp spIn; - status_t status; - - // Mutex acquisition order is always out -> in -> hw - AutoMutex lock(mLock); - - spOut = mOutput; - while (spOut != 0) { - if (!spOut->checkStandby()) { - int cnt = spOut->prepareLock(); - mLock.unlock(); - spOut->lock(); - mLock.lock(); - // make sure that another thread did not change output state while the - // mutex is released - if ((spOut == mOutput) && (cnt == spOut->standbyCnt())) { - break; - } - spOut->unlock(); - spOut = mOutput; - } else { - spOut.clear(); - } - } - // spOut is not 0 here only if the output is active - - spIn = getActiveInput_l(); - while (spIn != 0) { - int cnt = spIn->prepareLock(); - mLock.unlock(); - spIn->lock(); - mLock.lock(); - // make sure that another thread did not change input state while the - // mutex is released - if ((spIn == getActiveInput_l()) && (cnt == spIn->standbyCnt())) { - break; - } - spIn->unlock(); - spIn = getActiveInput_l(); - } - // spIn is not 0 here only if the input is active - - int prevMode = mMode; - status = AudioHardwareBase::setMode(mode); - LOGV("setMode() : new %d, old %d", mMode, prevMode); - if (status == NO_ERROR) { - // activate call clock in radio when entering in call or ringtone mode - if (prevMode == AudioSystem::MODE_NORMAL) - { - if ((!mActivatedCP) && (mSecRilLibHandle) && (connectRILDIfRequired() == OK)) { - setCallClockSync(mRilClient, SOUND_CLOCK_START); - mActivatedCP = true; - } - } - - if (mMode == AudioSystem::MODE_IN_CALL && !mInCallAudioMode) { - if (spOut != 0) { - LOGV("setMode() in call force output standby"); - spOut->doStandby_l(); - } - if (spIn != 0) { - LOGV("setMode() in call force input standby"); - spIn->doStandby_l(); - } - - LOGV("setMode() openPcmOut_l()"); - openPcmOut_l(); - openMixer_l(); - setInputSource_l(AUDIO_SOURCE_DEFAULT); - mInCallAudioMode = true; - } - if (mMode == AudioSystem::MODE_NORMAL && mInCallAudioMode) { - setInputSource_l(mInputSource); - if (mMixer != NULL) { - TRACE_DRIVER_IN(DRV_MIXER_GET) - struct mixer_ctl *ctl= mixer_get_control(mMixer, "Playback Path", 0); - TRACE_DRIVER_OUT - if (ctl != NULL) { - LOGV("setMode() reset Playback Path to RCV"); - TRACE_DRIVER_IN(DRV_MIXER_SEL) - mixer_ctl_select(ctl, "RCV"); - TRACE_DRIVER_OUT - } - } - LOGV("setMode() closePcmOut_l()"); - closeMixer_l(); - closePcmOut_l(); - - if (spOut != 0) { - LOGV("setMode() off call force output standby"); - spOut->doStandby_l(); - } - if (spIn != 0) { - LOGV("setMode() off call force input standby"); - spIn->doStandby_l(); - } - - mInCallAudioMode = false; - } - - if (mMode == AudioSystem::MODE_NORMAL) { - if(mActivatedCP) - mActivatedCP = false; - } - } - - if (spIn != 0) { - spIn->unlock(); - } - if (spOut != 0) { - spOut->unlock(); - } - - return status; -} - -status_t AudioHardware::setMicMute(bool state) -{ - LOGV("setMicMute(%d) mMicMute %d", state, mMicMute); - sp spIn; - { - AutoMutex lock(mLock); - if (mMicMute != state) { - mMicMute = state; - // in call mute is handled by RIL - if (mMode != AudioSystem::MODE_IN_CALL) { - spIn = getActiveInput_l(); - } - } - } - - if (spIn != 0) { - spIn->standby(); - } - - return NO_ERROR; -} - -status_t AudioHardware::getMicMute(bool* state) -{ - *state = mMicMute; - return NO_ERROR; -} - -status_t AudioHardware::setParameters(const String8& keyValuePairs) -{ - AudioParameter param = AudioParameter(keyValuePairs); - String8 value; - String8 key; - const char BT_NREC_KEY[] = "bt_headset_nrec"; - const char BT_NREC_VALUE_ON[] = "on"; - const char TTY_MODE_KEY[] = "tty_mode"; - const char TTY_MODE_VALUE_OFF[] = "tty_off"; - const char TTY_MODE_VALUE_VCO[] = "tty_vco"; - const char TTY_MODE_VALUE_HCO[] = "tty_hco"; - const char TTY_MODE_VALUE_FULL[] = "tty_full"; - - key = String8(BT_NREC_KEY); - if (param.get(key, value) == NO_ERROR) { - if (value == BT_NREC_VALUE_ON) { - mBluetoothNrec = true; - } else { - mBluetoothNrec = false; - LOGD("Turning noise reduction and echo cancellation off for BT " - "headset"); - } - param.remove(String8(BT_NREC_KEY)); - } - - key = String8(TTY_MODE_KEY); - if (param.get(key, value) == NO_ERROR) { - int ttyMode; - if (value == TTY_MODE_VALUE_OFF) { - ttyMode = TTY_MODE_OFF; - } else if (value == TTY_MODE_VALUE_VCO) { - ttyMode = TTY_MODE_VCO; - } else if (value == TTY_MODE_VALUE_HCO) { - ttyMode = TTY_MODE_HCO; - } else if (value == TTY_MODE_VALUE_FULL) { - ttyMode = TTY_MODE_FULL; - } else { - return BAD_VALUE; - } - - if (ttyMode != mTTYMode) { - LOGV("new tty mode %d", ttyMode); - mTTYMode = ttyMode; - if (mOutput != 0 && mMode == AudioSystem::MODE_IN_CALL) { - setIncallPath_l(mOutput->device()); - } - } - param.remove(String8(TTY_MODE_KEY)); - } - - return NO_ERROR; -} - -String8 AudioHardware::getParameters(const String8& keys) -{ - AudioParameter request = AudioParameter(keys); - AudioParameter reply = AudioParameter(); - - LOGV("getParameters() %s", keys.string()); - - return reply.toString(); -} - -size_t AudioHardware::getInputBufferSize(uint32_t sampleRate, int format, int channelCount) -{ - if (format != AudioSystem::PCM_16_BIT) { - LOGW("getInputBufferSize bad format: %d", format); - return 0; - } - if (channelCount < 1 || channelCount > 2) { - LOGW("getInputBufferSize bad channel count: %d", channelCount); - return 0; - } - if (sampleRate != 8000 && sampleRate != 11025 && sampleRate != 16000 && - sampleRate != 22050 && sampleRate != 44100) { - LOGW("getInputBufferSize bad sample rate: %d", sampleRate); - return 0; - } - - return AudioStreamInALSA::getBufferSize(sampleRate, channelCount); -} - - -status_t AudioHardware::setVoiceVolume(float volume) -{ - LOGD("### setVoiceVolume"); - - AutoMutex lock(mLock); - if ( (AudioSystem::MODE_IN_CALL == mMode) && (mSecRilLibHandle) && - (connectRILDIfRequired() == OK) ) { - - uint32_t device = AudioSystem::DEVICE_OUT_EARPIECE; - if (mOutput != 0) { - device = mOutput->device(); - } - int int_volume = (int)(volume * 5); - SoundType type; - - LOGD("### route(%d) call volume(%f)", device, volume); - switch (device) { - case AudioSystem::DEVICE_OUT_EARPIECE: - LOGD("### earpiece call volume"); - type = SOUND_TYPE_VOICE; - break; - - case AudioSystem::DEVICE_OUT_SPEAKER: - LOGD("### speaker call volume"); - type = SOUND_TYPE_SPEAKER; - break; - - case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO: - case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET: - case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT: - LOGD("### bluetooth call volume"); - type = SOUND_TYPE_BTVOICE; - break; - - case AudioSystem::DEVICE_OUT_WIRED_HEADSET: - case AudioSystem::DEVICE_OUT_WIRED_HEADPHONE: // Use receive path with 3 pole headset. - LOGD("### headset call volume"); - type = SOUND_TYPE_HEADSET; - break; - - default: - LOGW("### Call volume setting error!!!0x%08x \n", device); - type = SOUND_TYPE_VOICE; - break; - } - setCallVolume(mRilClient, type, int_volume); - } - - return NO_ERROR; -} - -status_t AudioHardware::setMasterVolume(float volume) -{ - LOGV("Set master volume to %f.\n", volume); - // We return an error code here to let the audioflinger do in-software - // volume on top of the maximum volume that we set through the SND API. - // return error - software mixer will handle it - return -1; -} - -static const int kDumpLockRetries = 50; -static const int kDumpLockSleep = 20000; - -static bool tryLock(Mutex& mutex) -{ - bool locked = false; - for (int i = 0; i < kDumpLockRetries; ++i) { - if (mutex.tryLock() == NO_ERROR) { - locked = true; - break; - } - usleep(kDumpLockSleep); - } - return locked; -} - -status_t AudioHardware::dump(int fd, const Vector& args) -{ - const size_t SIZE = 256; - char buffer[SIZE]; - String8 result; - - bool locked = tryLock(mLock); - if (!locked) { - snprintf(buffer, SIZE, "\n\tAudioHardware maybe deadlocked\n"); - } else { - mLock.unlock(); - } - - snprintf(buffer, SIZE, "\tInit %s\n", (mInit) ? "OK" : "Failed"); - result.append(buffer); - snprintf(buffer, SIZE, "\tMic Mute %s\n", (mMicMute) ? "ON" : "OFF"); - result.append(buffer); - snprintf(buffer, SIZE, "\tmPcm: %p\n", mPcm); - result.append(buffer); - snprintf(buffer, SIZE, "\tmPcmOpenCnt: %d\n", mPcmOpenCnt); - result.append(buffer); - snprintf(buffer, SIZE, "\tmMixer: %p\n", mMixer); - result.append(buffer); - snprintf(buffer, SIZE, "\tmMixerOpenCnt: %d\n", mMixerOpenCnt); - result.append(buffer); - snprintf(buffer, SIZE, "\tIn Call Audio Mode %s\n", - (mInCallAudioMode) ? "ON" : "OFF"); - result.append(buffer); - snprintf(buffer, SIZE, "\tInput source %d\n", mInputSource); - result.append(buffer); - snprintf(buffer, SIZE, "\tmSecRilLibHandle: %p\n", mSecRilLibHandle); - result.append(buffer); - snprintf(buffer, SIZE, "\tmRilClient: %p\n", mRilClient); - result.append(buffer); - snprintf(buffer, SIZE, "\tCP %s\n", - (mActivatedCP) ? "Activated" : "Deactivated"); - result.append(buffer); - snprintf(buffer, SIZE, "\tmDriverOp: %d\n", mDriverOp); - result.append(buffer); - - snprintf(buffer, SIZE, "\n\tmOutput %p dump:\n", mOutput.get()); - result.append(buffer); - write(fd, result.string(), result.size()); - if (mOutput != 0) { - mOutput->dump(fd, args); - } - - snprintf(buffer, SIZE, "\n\t%d inputs opened:\n", mInputs.size()); - write(fd, buffer, strlen(buffer)); - for (size_t i = 0; i < mInputs.size(); i++) { - snprintf(buffer, SIZE, "\t- input %d dump:\n", i); - write(fd, buffer, strlen(buffer)); - mInputs[i]->dump(fd, args); - } - - return NO_ERROR; -} - -status_t AudioHardware::setIncallPath_l(uint32_t device) -{ - LOGV("setIncallPath_l: device %x", device); - - // Setup sound path for CP clocking - if ((mSecRilLibHandle) && - (connectRILDIfRequired() == OK)) { - - if (mMode == AudioSystem::MODE_IN_CALL) { - LOGD("### incall mode route (%d)", device); - AudioPath path; - switch(device){ - case AudioSystem::DEVICE_OUT_EARPIECE: - LOGD("### incall mode earpiece route"); - path = SOUND_AUDIO_PATH_HANDSET; - break; - - case AudioSystem::DEVICE_OUT_SPEAKER: - LOGD("### incall mode speaker route"); - path = SOUND_AUDIO_PATH_SPEAKER; - break; - - case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO: - case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET: - case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT: - LOGD("### incall mode bluetooth route %s NR", mBluetoothNrec ? "" : "NO"); - if (mBluetoothNrec) { - path = SOUND_AUDIO_PATH_BLUETOOTH; - } else { - path = SOUND_AUDIO_PATH_BLUETOOTH_NO_NR; - } - break; - - case AudioSystem::DEVICE_OUT_WIRED_HEADPHONE : - LOGD("### incall mode headphone route"); - path = SOUND_AUDIO_PATH_HEADPHONE; - break; - case AudioSystem::DEVICE_OUT_WIRED_HEADSET : - LOGD("### incall mode headset route"); - path = SOUND_AUDIO_PATH_HEADSET; - break; - default: - LOGW("### incall mode Error!! route = [%d]", device); - path = SOUND_AUDIO_PATH_HANDSET; - break; - } - - setCallAudioPath(mRilClient, path); - - if (mMixer != NULL) { - TRACE_DRIVER_IN(DRV_MIXER_GET) - struct mixer_ctl *ctl= mixer_get_control(mMixer, "Voice Call Path", 0); - TRACE_DRIVER_OUT - LOGE_IF(ctl == NULL, "setIncallPath_l() could not get mixer ctl"); - if (ctl != NULL) { - LOGV("setIncallPath_l() Voice Call Path, (%x)", device); - TRACE_DRIVER_IN(DRV_MIXER_SEL) - mixer_ctl_select(ctl, getVoiceRouteFromDevice(device)); - TRACE_DRIVER_OUT - } - } - } - } - return NO_ERROR; -} - -struct pcm *AudioHardware::openPcmOut_l() -{ - LOGD("openPcmOut_l() mPcmOpenCnt: %d", mPcmOpenCnt); - if (mPcmOpenCnt++ == 0) { - if (mPcm != NULL) { - LOGE("openPcmOut_l() mPcmOpenCnt == 0 and mPcm == %p\n", mPcm); - mPcmOpenCnt--; - return NULL; - } - unsigned flags = PCM_OUT; - - flags |= (AUDIO_HW_OUT_PERIOD_MULT - 1) << PCM_PERIOD_SZ_SHIFT; - flags |= (AUDIO_HW_OUT_PERIOD_CNT - PCM_PERIOD_CNT_MIN) << PCM_PERIOD_CNT_SHIFT; - - TRACE_DRIVER_IN(DRV_PCM_OPEN) - mPcm = pcm_open(flags); - TRACE_DRIVER_OUT - if (!pcm_ready(mPcm)) { - LOGE("openPcmOut_l() cannot open pcm_out driver: %s\n", pcm_error(mPcm)); - TRACE_DRIVER_IN(DRV_PCM_CLOSE) - pcm_close(mPcm); - TRACE_DRIVER_OUT - mPcmOpenCnt--; - mPcm = NULL; - } - } - return mPcm; -} - -void AudioHardware::closePcmOut_l() -{ - LOGD("closePcmOut_l() mPcmOpenCnt: %d", mPcmOpenCnt); - if (mPcmOpenCnt == 0) { - LOGE("closePcmOut_l() mPcmOpenCnt == 0"); - return; - } - - if (--mPcmOpenCnt == 0) { - TRACE_DRIVER_IN(DRV_PCM_CLOSE) - pcm_close(mPcm); - TRACE_DRIVER_OUT - mPcm = NULL; - } -} - -struct mixer *AudioHardware::openMixer_l() -{ - LOGV("openMixer_l() mMixerOpenCnt: %d", mMixerOpenCnt); - if (mMixerOpenCnt++ == 0) { - if (mMixer != NULL) { - LOGE("openMixer_l() mMixerOpenCnt == 0 and mMixer == %p\n", mMixer); - mMixerOpenCnt--; - return NULL; - } - TRACE_DRIVER_IN(DRV_MIXER_OPEN) - mMixer = mixer_open(); - TRACE_DRIVER_OUT - if (mMixer == NULL) { - LOGE("openMixer_l() cannot open mixer"); - mMixerOpenCnt--; - return NULL; - } - } - return mMixer; -} - -void AudioHardware::closeMixer_l() -{ - LOGV("closeMixer_l() mMixerOpenCnt: %d", mMixerOpenCnt); - if (mMixerOpenCnt == 0) { - LOGE("closeMixer_l() mMixerOpenCnt == 0"); - return; - } - - if (--mMixerOpenCnt == 0) { - TRACE_DRIVER_IN(DRV_MIXER_CLOSE) - mixer_close(mMixer); - TRACE_DRIVER_OUT - mMixer = NULL; - } -} - -const char *AudioHardware::getOutputRouteFromDevice(uint32_t device) -{ - switch (device) { - case AudioSystem::DEVICE_OUT_EARPIECE: - return "RCV"; - case AudioSystem::DEVICE_OUT_SPEAKER: - if (mMode == AudioSystem::MODE_RINGTONE) return "RING_SPK"; - else return "SPK"; - case AudioSystem::DEVICE_OUT_WIRED_HEADPHONE: - if (mMode == AudioSystem::MODE_RINGTONE) return "RING_NO_MIC"; - else return "HP_NO_MIC"; - case AudioSystem::DEVICE_OUT_WIRED_HEADSET: - if (mMode == AudioSystem::MODE_RINGTONE) return "RING_HP"; - else return "HP"; - case (AudioSystem::DEVICE_OUT_SPEAKER|AudioSystem::DEVICE_OUT_WIRED_HEADPHONE): - case (AudioSystem::DEVICE_OUT_SPEAKER|AudioSystem::DEVICE_OUT_WIRED_HEADSET): - if (mMode == AudioSystem::MODE_RINGTONE) return "RING_SPK_HP"; - else return "SPK_HP"; - case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO: - case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET: - case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT: - return "BT"; - default: - return "OFF"; - } -} - -const char *AudioHardware::getVoiceRouteFromDevice(uint32_t device) -{ - switch (device) { - case AudioSystem::DEVICE_OUT_EARPIECE: - return "RCV"; - case AudioSystem::DEVICE_OUT_SPEAKER: - return "SPK"; - case AudioSystem::DEVICE_OUT_WIRED_HEADPHONE: - case AudioSystem::DEVICE_OUT_WIRED_HEADSET: - switch (mTTYMode) { - case TTY_MODE_VCO: - return "TTY_VCO"; - case TTY_MODE_HCO: - return "TTY_HCO"; - case TTY_MODE_FULL: - return "TTY_FULL"; - case TTY_MODE_OFF: - default: - if (device == AudioSystem::DEVICE_OUT_WIRED_HEADPHONE) { - return "HP_NO_MIC"; - } else { - return "HP"; - } - } - case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO: - case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET: - case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT: - return "BT"; - default: - return "OFF"; - } -} - -const char *AudioHardware::getInputRouteFromDevice(uint32_t device) -{ - if (mMicMute) { - return "MIC OFF"; - } - - switch (device) { - case AudioSystem::DEVICE_IN_BUILTIN_MIC: - return "Main Mic"; - case AudioSystem::DEVICE_IN_WIRED_HEADSET: - return "Hands Free Mic"; - case AudioSystem::DEVICE_IN_BLUETOOTH_SCO_HEADSET: - return "BT Sco Mic"; - default: - return "MIC OFF"; - } -} - -uint32_t AudioHardware::getInputSampleRate(uint32_t sampleRate) -{ - uint32_t i; - uint32_t prevDelta; - uint32_t delta; - - for (i = 0, prevDelta = 0xFFFFFFFF; i < sizeof(inputSamplingRates)/sizeof(uint32_t); i++, prevDelta = delta) { - delta = abs(sampleRate - inputSamplingRates[i]); - if (delta > prevDelta) break; - } - // i is always > 0 here - return inputSamplingRates[i-1]; -} - -// getActiveInput_l() must be called with mLock held -sp AudioHardware::getActiveInput_l() -{ - sp< AudioHardware::AudioStreamInALSA> spIn; - - for (size_t i = 0; i < mInputs.size(); i++) { - // return first input found not being in standby mode - // as only one input can be in this state - if (!mInputs[i]->checkStandby()) { - spIn = mInputs[i]; - break; - } - } - - return spIn; -} - -status_t AudioHardware::setInputSource_l(audio_source source) -{ - LOGV("setInputSource_l(%d)", source); - if (source != mInputSource) { - if ((source == AUDIO_SOURCE_DEFAULT) || (mMode != AudioSystem::MODE_IN_CALL)) { - if (mMixer) { - TRACE_DRIVER_IN(DRV_MIXER_GET) - struct mixer_ctl *ctl= mixer_get_control(mMixer, "Input Source", 0); - TRACE_DRIVER_OUT - if (ctl == NULL) { - return NO_INIT; - } - const char* sourceName; - switch (source) { - case AUDIO_SOURCE_DEFAULT: // intended fall-through - case AUDIO_SOURCE_MIC: - sourceName = inputPathNameDefault; - break; - case AUDIO_SOURCE_VOICE_COMMUNICATION: - sourceName = inputPathNameVoiceCommunication; - break; - case AUDIO_SOURCE_CAMCORDER: - sourceName = inputPathNameCamcorder; - break; - case AUDIO_SOURCE_VOICE_RECOGNITION: - sourceName = inputPathNameVoiceRecognition; - break; - case AUDIO_SOURCE_VOICE_UPLINK: // intended fall-through - case AUDIO_SOURCE_VOICE_DOWNLINK: // intended fall-through - case AUDIO_SOURCE_VOICE_CALL: // intended fall-through - default: - return NO_INIT; - } - LOGV("mixer_ctl_select, Input Source, (%s)", sourceName); - TRACE_DRIVER_IN(DRV_MIXER_SEL) - mixer_ctl_select(ctl, sourceName); - TRACE_DRIVER_OUT - } - } - mInputSource = source; - } - - return NO_ERROR; -} - - -//------------------------------------------------------------------------------ -// AudioStreamOutALSA -//------------------------------------------------------------------------------ - -AudioHardware::AudioStreamOutALSA::AudioStreamOutALSA() : - mHardware(0), mPcm(0), mMixer(0), mRouteCtl(0), - mStandby(true), mDevices(0), mChannels(AUDIO_HW_OUT_CHANNELS), - mSampleRate(AUDIO_HW_OUT_SAMPLERATE), mBufferSize(AUDIO_HW_OUT_PERIOD_BYTES), - mDriverOp(DRV_NONE), mStandbyCnt(0), mSleepReq(false) -{ -} - -status_t AudioHardware::AudioStreamOutALSA::set( - AudioHardware* hw, uint32_t devices, int *pFormat, - uint32_t *pChannels, uint32_t *pRate) -{ - int lFormat = pFormat ? *pFormat : 0; - uint32_t lChannels = pChannels ? *pChannels : 0; - uint32_t lRate = pRate ? *pRate : 0; - - mHardware = hw; - mDevices = devices; - - // fix up defaults - if (lFormat == 0) lFormat = format(); - if (lChannels == 0) lChannels = channels(); - if (lRate == 0) lRate = sampleRate(); - - // check values - if ((lFormat != format()) || - (lChannels != channels()) || - (lRate != sampleRate())) { - if (pFormat) *pFormat = format(); - if (pChannels) *pChannels = channels(); - if (pRate) *pRate = sampleRate(); - return BAD_VALUE; - } - - if (pFormat) *pFormat = lFormat; - if (pChannels) *pChannels = lChannels; - if (pRate) *pRate = lRate; - - mChannels = lChannels; - mSampleRate = lRate; - mBufferSize = AUDIO_HW_OUT_PERIOD_BYTES; - - return NO_ERROR; -} - -AudioHardware::AudioStreamOutALSA::~AudioStreamOutALSA() -{ - standby(); -} - -ssize_t AudioHardware::AudioStreamOutALSA::write(const void* buffer, size_t bytes) -{ - // LOGV("AudioStreamOutALSA::write(%p, %u)", buffer, bytes); - status_t status = NO_INIT; - const uint8_t* p = static_cast(buffer); - int ret; - - if (mHardware == NULL) return NO_INIT; - - if (mSleepReq) { - // 10ms are always shorter than the time to reconfigure the audio path - // which is the only condition when mSleepReq would be true. - usleep(10000); - } - - { // scope for the lock - - AutoMutex lock(mLock); - - if (mStandby) { - AutoMutex hwLock(mHardware->lock()); - - LOGD("AudioHardware pcm playback is exiting standby."); - acquire_wake_lock (PARTIAL_WAKE_LOCK, "AudioOutLock"); - - sp spIn = mHardware->getActiveInput_l(); - while (spIn != 0) { - int cnt = spIn->prepareLock(); - mHardware->lock().unlock(); - // Mutex acquisition order is always out -> in -> hw - spIn->lock(); - mHardware->lock().lock(); - // make sure that another thread did not change input state - // while the mutex is released - if ((spIn == mHardware->getActiveInput_l()) && - (cnt == spIn->standbyCnt())) { - LOGV("AudioStreamOutALSA::write() force input standby"); - spIn->close_l(); - break; - } - spIn->unlock(); - spIn = mHardware->getActiveInput_l(); - } - // spIn is not 0 here only if the input was active and has been - // closed above - - // open output before input - open_l(); - - if (spIn != 0) { - if (spIn->open_l() != NO_ERROR) { - spIn->doStandby_l(); - } - spIn->unlock(); - } - if (mPcm == NULL) { - release_wake_lock("AudioOutLock"); - goto Error; - } - mStandby = false; - } - - TRACE_DRIVER_IN(DRV_PCM_WRITE) - ret = pcm_write(mPcm,(void*) p, bytes); - TRACE_DRIVER_OUT - - if (ret == 0) { - return bytes; - } - LOGW("write error: %d", errno); - status = -errno; - } -Error: - - standby(); - - // Simulate audio output timing in case of error - usleep((((bytes * 1000) / frameSize()) * 1000) / sampleRate()); - - return status; -} - -status_t AudioHardware::AudioStreamOutALSA::standby() -{ - if (mHardware == NULL) return NO_INIT; - - AutoMutex lock(mLock); - - { // scope for the AudioHardware lock - AutoMutex hwLock(mHardware->lock()); - - doStandby_l(); - } - - return NO_ERROR; -} - -void AudioHardware::AudioStreamOutALSA::doStandby_l() -{ - mStandbyCnt++; - - if (!mStandby) { - LOGD("AudioHardware pcm playback is going to standby."); - release_wake_lock("AudioOutLock"); - mStandby = true; - } - - close_l(); -} - -void AudioHardware::AudioStreamOutALSA::close_l() -{ - if (mMixer) { - mHardware->closeMixer_l(); - mMixer = NULL; - mRouteCtl = NULL; - } - if (mPcm) { - mHardware->closePcmOut_l(); - mPcm = NULL; - } -} - -status_t AudioHardware::AudioStreamOutALSA::open_l() -{ - LOGV("open pcm_out driver"); - mPcm = mHardware->openPcmOut_l(); - if (mPcm == NULL) { - return NO_INIT; - } - - mMixer = mHardware->openMixer_l(); - if (mMixer) { - LOGV("open playback normal"); - TRACE_DRIVER_IN(DRV_MIXER_GET) - mRouteCtl = mixer_get_control(mMixer, "Playback Path", 0); - TRACE_DRIVER_OUT - } - if (mHardware->mode() != AudioSystem::MODE_IN_CALL) { - const char *route = mHardware->getOutputRouteFromDevice(mDevices); - LOGV("write() wakeup setting route %s", route); - if (mRouteCtl) { - TRACE_DRIVER_IN(DRV_MIXER_SEL) - mixer_ctl_select(mRouteCtl, route); - TRACE_DRIVER_OUT - } - } - return NO_ERROR; -} - -status_t AudioHardware::AudioStreamOutALSA::dump(int fd, const Vector& args) -{ - const size_t SIZE = 256; - char buffer[SIZE]; - String8 result; - - bool locked = tryLock(mLock); - if (!locked) { - snprintf(buffer, SIZE, "\n\t\tAudioStreamOutALSA maybe deadlocked\n"); - } else { - mLock.unlock(); - } - - snprintf(buffer, SIZE, "\t\tmHardware: %p\n", mHardware); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmPcm: %p\n", mPcm); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmMixer: %p\n", mMixer); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmRouteCtl: %p\n", mRouteCtl); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tStandby %s\n", (mStandby) ? "ON" : "OFF"); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmDevices: 0x%08x\n", mDevices); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmChannels: 0x%08x\n", mChannels); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmSampleRate: %d\n", mSampleRate); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmBufferSize: %d\n", mBufferSize); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmDriverOp: %d\n", mDriverOp); - result.append(buffer); - - ::write(fd, result.string(), result.size()); - - return NO_ERROR; -} - -bool AudioHardware::AudioStreamOutALSA::checkStandby() -{ - return mStandby; -} - -status_t AudioHardware::AudioStreamOutALSA::setParameters(const String8& keyValuePairs) -{ - AudioParameter param = AudioParameter(keyValuePairs); - status_t status = NO_ERROR; - int device; - LOGD("AudioStreamOutALSA::setParameters() %s", keyValuePairs.string()); - - if (mHardware == NULL) return NO_INIT; - - { - AutoMutex lock(mLock); - - if (param.getInt(String8(AudioParameter::keyRouting), device) == NO_ERROR) - { - if (device != 0) { - AutoMutex hwLock(mHardware->lock()); - - if (mDevices != (uint32_t)device) { - mDevices = (uint32_t)device; - if (mHardware->mode() != AudioSystem::MODE_IN_CALL) { - doStandby_l(); - } - } - if (mHardware->mode() == AudioSystem::MODE_IN_CALL) { - mHardware->setIncallPath_l(device); - } - } - param.remove(String8(AudioParameter::keyRouting)); - } - } - - if (param.size()) { - status = BAD_VALUE; - } - - - return status; - -} - -String8 AudioHardware::AudioStreamOutALSA::getParameters(const String8& keys) -{ - AudioParameter param = AudioParameter(keys); - String8 value; - String8 key = String8(AudioParameter::keyRouting); - - if (param.get(key, value) == NO_ERROR) { - param.addInt(key, (int)mDevices); - } - - LOGV("AudioStreamOutALSA::getParameters() %s", param.toString().string()); - return param.toString(); -} - -status_t AudioHardware::AudioStreamOutALSA::getRenderPosition(uint32_t *dspFrames) -{ - //TODO - return INVALID_OPERATION; -} - -int AudioHardware::AudioStreamOutALSA::prepareLock() -{ - // request sleep next time write() is called so that caller can acquire - // mLock - mSleepReq = true; - return mStandbyCnt; -} - -void AudioHardware::AudioStreamOutALSA::lock() -{ - mLock.lock(); - mSleepReq = false; -} - -void AudioHardware::AudioStreamOutALSA::unlock() { - mLock.unlock(); -} - -//------------------------------------------------------------------------------ -// AudioStreamInALSA -//------------------------------------------------------------------------------ - -AudioHardware::AudioStreamInALSA::AudioStreamInALSA() : - mHardware(0), mPcm(0), mMixer(0), mRouteCtl(0), - mStandby(true), mDevices(0), mChannels(AUDIO_HW_IN_CHANNELS), mChannelCount(1), - mSampleRate(AUDIO_HW_IN_SAMPLERATE), mBufferSize(AUDIO_HW_IN_PERIOD_BYTES), - mDownSampler(NULL), mReadStatus(NO_ERROR), mDriverOp(DRV_NONE), - mStandbyCnt(0), mSleepReq(false) -{ -} - -status_t AudioHardware::AudioStreamInALSA::set( - AudioHardware* hw, uint32_t devices, int *pFormat, - uint32_t *pChannels, uint32_t *pRate, AudioSystem::audio_in_acoustics acoustics) -{ - if (pFormat == 0 || *pFormat != AUDIO_HW_IN_FORMAT) { - *pFormat = AUDIO_HW_IN_FORMAT; - return BAD_VALUE; - } - if (pRate == 0) { - return BAD_VALUE; - } - uint32_t rate = AudioHardware::getInputSampleRate(*pRate); - if (rate != *pRate) { - *pRate = rate; - return BAD_VALUE; - } - - if (pChannels == 0 || (*pChannels != AudioSystem::CHANNEL_IN_MONO && - *pChannels != AudioSystem::CHANNEL_IN_STEREO)) { - *pChannels = AUDIO_HW_IN_CHANNELS; - return BAD_VALUE; - } - - mHardware = hw; - - LOGV("AudioStreamInALSA::set(%d, %d, %u)", *pFormat, *pChannels, *pRate); - - mBufferSize = getBufferSize(*pRate, AudioSystem::popCount(*pChannels)); - mDevices = devices; - mChannels = *pChannels; - mChannelCount = AudioSystem::popCount(mChannels); - mSampleRate = rate; - if (mSampleRate != AUDIO_HW_OUT_SAMPLERATE) { - mDownSampler = new AudioHardware::DownSampler(mSampleRate, - mChannelCount, - AUDIO_HW_IN_PERIOD_SZ, - this); - status_t status = mDownSampler->initCheck(); - if (status != NO_ERROR) { - delete mDownSampler; - LOGW("AudioStreamInALSA::set() downsampler init failed: %d", status); - return status; - } - - mPcmIn = new int16_t[AUDIO_HW_IN_PERIOD_SZ * mChannelCount]; - } - return NO_ERROR; -} - -AudioHardware::AudioStreamInALSA::~AudioStreamInALSA() -{ - standby(); - if (mDownSampler != NULL) { - delete mDownSampler; - if (mPcmIn != NULL) { - delete[] mPcmIn; - } - } -} - -ssize_t AudioHardware::AudioStreamInALSA::read(void* buffer, ssize_t bytes) -{ - // LOGV("AudioStreamInALSA::read(%p, %u)", buffer, bytes); - status_t status = NO_INIT; - int ret; - - if (mHardware == NULL) return NO_INIT; - - if (mSleepReq) { - // 10ms are always shorter than the time to reconfigure the audio path - // which is the only condition when mSleepReq would be true. - usleep(10000); - } - - { // scope for the lock - AutoMutex lock(mLock); - - if (mStandby) { - AutoMutex hwLock(mHardware->lock()); - - LOGD("AudioHardware pcm capture is exiting standby."); - acquire_wake_lock (PARTIAL_WAKE_LOCK, "AudioInLock"); - - sp spOut = mHardware->output(); - while (spOut != 0) { - if (!spOut->checkStandby()) { - int cnt = spOut->prepareLock(); - mHardware->lock().unlock(); - mLock.unlock(); - // Mutex acquisition order is always out -> in -> hw - spOut->lock(); - mLock.lock(); - mHardware->lock().lock(); - // make sure that another thread did not change output state - // while the mutex is released - if ((spOut == mHardware->output()) && (cnt == spOut->standbyCnt())) { - LOGV("AudioStreamInALSA::read() force output standby"); - spOut->close_l(); - break; - } - spOut->unlock(); - spOut = mHardware->output(); - } else { - spOut.clear(); - } - } - // spOut is not 0 here only if the output was active and has been - // closed above - - // open output before input - if (spOut != 0) { - if (spOut->open_l() != NO_ERROR) { - spOut->doStandby_l(); - } - spOut->unlock(); - } - - open_l(); - - if (mPcm == NULL) { - release_wake_lock("AudioInLock"); - goto Error; - } - mStandby = false; - } - - - if (mDownSampler != NULL) { - size_t frames = bytes / frameSize(); - size_t framesIn = 0; - mReadStatus = 0; - do { - size_t outframes = frames - framesIn; - mDownSampler->resample( - (int16_t *)buffer + (framesIn * mChannelCount), - &outframes); - framesIn += outframes; - } while ((framesIn < frames) && mReadStatus == 0); - ret = mReadStatus; - bytes = framesIn * frameSize(); - } else { - TRACE_DRIVER_IN(DRV_PCM_READ) - ret = pcm_read(mPcm, buffer, bytes); - TRACE_DRIVER_OUT - } - - if (ret == 0) { - return bytes; - } - - LOGW("read error: %d", ret); - status = ret; - } - -Error: - - standby(); - - // Simulate audio output timing in case of error - usleep((((bytes * 1000) / frameSize()) * 1000) / sampleRate()); - - return status; -} - -status_t AudioHardware::AudioStreamInALSA::standby() -{ - if (mHardware == NULL) return NO_INIT; - - AutoMutex lock(mLock); - - { // scope for AudioHardware lock - AutoMutex hwLock(mHardware->lock()); - - doStandby_l(); - } - return NO_ERROR; -} - -void AudioHardware::AudioStreamInALSA::doStandby_l() -{ - mStandbyCnt++; - - if (!mStandby) { - LOGD("AudioHardware pcm capture is going to standby."); - release_wake_lock("AudioInLock"); - mStandby = true; - } - close_l(); -} - -void AudioHardware::AudioStreamInALSA::close_l() -{ - if (mMixer) { - mHardware->closeMixer_l(); - mMixer = NULL; - mRouteCtl = NULL; - } - - if (mPcm) { - TRACE_DRIVER_IN(DRV_PCM_CLOSE) - pcm_close(mPcm); - TRACE_DRIVER_OUT - mPcm = NULL; - } -} - -status_t AudioHardware::AudioStreamInALSA::open_l() -{ - unsigned flags = PCM_IN; - if (mChannels == AudioSystem::CHANNEL_IN_MONO) { - flags |= PCM_MONO; - } - flags |= (AUDIO_HW_IN_PERIOD_MULT - 1) << PCM_PERIOD_SZ_SHIFT; - flags |= (AUDIO_HW_IN_PERIOD_CNT - PCM_PERIOD_CNT_MIN) - << PCM_PERIOD_CNT_SHIFT; - - LOGV("open pcm_in driver"); - TRACE_DRIVER_IN(DRV_PCM_OPEN) - mPcm = pcm_open(flags); - TRACE_DRIVER_OUT - if (!pcm_ready(mPcm)) { - LOGE("cannot open pcm_in driver: %s\n", pcm_error(mPcm)); - TRACE_DRIVER_IN(DRV_PCM_CLOSE) - pcm_close(mPcm); - TRACE_DRIVER_OUT - mPcm = NULL; - return NO_INIT; - } - - if (mDownSampler != NULL) { - mInPcmInBuf = 0; - mDownSampler->reset(); - } - - mMixer = mHardware->openMixer_l(); - if (mMixer) { - TRACE_DRIVER_IN(DRV_MIXER_GET) - mRouteCtl = mixer_get_control(mMixer, "Capture MIC Path", 0); - TRACE_DRIVER_OUT - } - - if (mHardware->mode() != AudioSystem::MODE_IN_CALL) { - const char *route = mHardware->getInputRouteFromDevice(mDevices); - LOGV("read() wakeup setting route %s", route); - if (mRouteCtl) { - TRACE_DRIVER_IN(DRV_MIXER_SEL) - mixer_ctl_select(mRouteCtl, route); - TRACE_DRIVER_OUT - } - } - - return NO_ERROR; -} - -status_t AudioHardware::AudioStreamInALSA::dump(int fd, const Vector& args) -{ - const size_t SIZE = 256; - char buffer[SIZE]; - String8 result; - - bool locked = tryLock(mLock); - if (!locked) { - snprintf(buffer, SIZE, "\n\t\tAudioStreamInALSA maybe deadlocked\n"); - } else { - mLock.unlock(); - } - - snprintf(buffer, SIZE, "\t\tmHardware: %p\n", mHardware); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmPcm: %p\n", mPcm); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmMixer: %p\n", mMixer); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tStandby %s\n", (mStandby) ? "ON" : "OFF"); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmDevices: 0x%08x\n", mDevices); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmChannels: 0x%08x\n", mChannels); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmSampleRate: %d\n", mSampleRate); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmBufferSize: %d\n", mBufferSize); - result.append(buffer); - snprintf(buffer, SIZE, "\t\tmDriverOp: %d\n", mDriverOp); - result.append(buffer); - write(fd, result.string(), result.size()); - - return NO_ERROR; -} - -bool AudioHardware::AudioStreamInALSA::checkStandby() -{ - return mStandby; -} - -status_t AudioHardware::AudioStreamInALSA::setParameters(const String8& keyValuePairs) -{ - AudioParameter param = AudioParameter(keyValuePairs); - status_t status = NO_ERROR; - int value; - - LOGD("AudioStreamInALSA::setParameters() %s", keyValuePairs.string()); - - if (mHardware == NULL) return NO_INIT; - - { - AutoMutex lock(mLock); - - if (param.getInt(String8(AudioParameter::keyInputSource), value) == NO_ERROR) { - AutoMutex hwLock(mHardware->lock()); - - mHardware->openMixer_l(); - mHardware->setInputSource_l((audio_source)value); - mHardware->closeMixer_l(); - - param.remove(String8(AudioParameter::keyInputSource)); - } - - if (param.getInt(String8(AudioParameter::keyRouting), value) == NO_ERROR) - { - if (value != 0) { - AutoMutex hwLock(mHardware->lock()); - - if (mDevices != (uint32_t)value) { - mDevices = (uint32_t)value; - if (mHardware->mode() != AudioSystem::MODE_IN_CALL) { - doStandby_l(); - } - } - } - param.remove(String8(AudioParameter::keyRouting)); - } - } - - - if (param.size()) { - status = BAD_VALUE; - } - - return status; - -} - -String8 AudioHardware::AudioStreamInALSA::getParameters(const String8& keys) -{ - AudioParameter param = AudioParameter(keys); - String8 value; - String8 key = String8(AudioParameter::keyRouting); - - if (param.get(key, value) == NO_ERROR) { - param.addInt(key, (int)mDevices); - } - - LOGV("AudioStreamInALSA::getParameters() %s", param.toString().string()); - return param.toString(); -} - -status_t AudioHardware::AudioStreamInALSA::getNextBuffer(AudioHardware::BufferProvider::Buffer* buffer) -{ - if (mPcm == NULL) { - buffer->raw = NULL; - buffer->frameCount = 0; - mReadStatus = NO_INIT; - return NO_INIT; - } - - if (mInPcmInBuf == 0) { - TRACE_DRIVER_IN(DRV_PCM_READ) - mReadStatus = pcm_read(mPcm,(void*) mPcmIn, AUDIO_HW_IN_PERIOD_SZ * frameSize()); - TRACE_DRIVER_OUT - if (mReadStatus != 0) { - buffer->raw = NULL; - buffer->frameCount = 0; - return mReadStatus; - } - mInPcmInBuf = AUDIO_HW_IN_PERIOD_SZ; - } - - buffer->frameCount = (buffer->frameCount > mInPcmInBuf) ? mInPcmInBuf : buffer->frameCount; - buffer->i16 = mPcmIn + (AUDIO_HW_IN_PERIOD_SZ - mInPcmInBuf) * mChannelCount; - - return mReadStatus; -} - -void AudioHardware::AudioStreamInALSA::releaseBuffer(Buffer* buffer) -{ - mInPcmInBuf -= buffer->frameCount; -} - -size_t AudioHardware::AudioStreamInALSA::getBufferSize(uint32_t sampleRate, int channelCount) -{ - size_t ratio; - - switch (sampleRate) { - case 8000: - case 11025: - ratio = 4; - break; - case 16000: - case 22050: - ratio = 2; - break; - case 44100: - default: - ratio = 1; - break; - } - - return (AUDIO_HW_IN_PERIOD_SZ*channelCount*sizeof(int16_t)) / ratio ; -} - -int AudioHardware::AudioStreamInALSA::prepareLock() -{ - // request sleep next time read() is called so that caller can acquire - // mLock - mSleepReq = true; - return mStandbyCnt; -} - -void AudioHardware::AudioStreamInALSA::lock() -{ - mLock.lock(); - mSleepReq = false; -} - -void AudioHardware::AudioStreamInALSA::unlock() { - mLock.unlock(); -} - -//------------------------------------------------------------------------------ -// DownSampler -//------------------------------------------------------------------------------ - -/* - * 2.30 fixed point FIR filter coefficients for conversion 44100 -> 22050. - * (Works equivalently for 22010 -> 11025 or any other halving, of course.) - * - * Transition band from about 18 kHz, passband ripple < 0.1 dB, - * stopband ripple at about -55 dB, linear phase. - * - * Design and display in MATLAB or Octave using: - * - * filter = fir1(19, 0.5); filter = round(filter * 2**30); freqz(filter * 2**-30); - */ -static const int32_t filter_22khz_coeff[] = { - 2089257, 2898328, -5820678, -10484531, - 19038724, 30542725, -50469415, -81505260, - 152544464, 478517512, 478517512, 152544464, - -81505260, -50469415, 30542725, 19038724, - -10484531, -5820678, 2898328, 2089257, -}; -#define NUM_COEFF_22KHZ (sizeof(filter_22khz_coeff) / sizeof(filter_22khz_coeff[0])) -#define OVERLAP_22KHZ (NUM_COEFF_22KHZ - 2) - -/* - * Convolution of signals A and reverse(B). (In our case, the filter response - * is symmetric, so the reversing doesn't matter.) - * A is taken to be in 0.16 fixed-point, and B is taken to be in 2.30 fixed-point. - * The answer will be in 16.16 fixed-point, unclipped. - * - * This function would probably be the prime candidate for SIMD conversion if - * you want more speed. - */ -int32_t fir_convolve(const int16_t* a, const int32_t* b, int num_samples) -{ - int32_t sum = 1 << 13; - for (int i = 0; i < num_samples; ++i) { - sum += a[i] * (b[i] >> 16); - } - return sum >> 14; -} - -/* Clip from 16.16 fixed-point to 0.16 fixed-point. */ -int16_t clip(int32_t x) -{ - if (x < -32768) { - return -32768; - } else if (x > 32767) { - return 32767; - } else { - return x; - } -} - -/* - * Convert a chunk from 44 kHz to 22 kHz. Will update num_samples_in and num_samples_out - * accordingly, since it may leave input samples in the buffer due to overlap. - * - * Input and output are taken to be in 0.16 fixed-point. - */ -void resample_2_1(int16_t* input, int16_t* output, int* num_samples_in, int* num_samples_out) -{ - if (*num_samples_in < (int)NUM_COEFF_22KHZ) { - *num_samples_out = 0; - return; - } - - int odd_smp = *num_samples_in & 0x1; - int num_samples = *num_samples_in - odd_smp - OVERLAP_22KHZ; - - for (int i = 0; i < num_samples; i += 2) { - output[i / 2] = clip(fir_convolve(input + i, filter_22khz_coeff, NUM_COEFF_22KHZ)); - } - - memmove(input, input + num_samples, (OVERLAP_22KHZ + odd_smp) * sizeof(*input)); - *num_samples_out = num_samples / 2; - *num_samples_in = OVERLAP_22KHZ + odd_smp; -} - -/* - * 2.30 fixed point FIR filter coefficients for conversion 22050 -> 16000, - * or 11025 -> 8000. - * - * Transition band from about 14 kHz, passband ripple < 0.1 dB, - * stopband ripple at about -50 dB, linear phase. - * - * Design and display in MATLAB or Octave using: - * - * filter = fir1(23, 16000 / 22050); filter = round(filter * 2**30); freqz(filter * 2**-30); - */ -static const int32_t filter_16khz_coeff[] = { - 2057290, -2973608, 1880478, 4362037, - -14639744, 18523609, -1609189, -38502470, - 78073125, -68353935, -59103896, 617555440, - 617555440, -59103896, -68353935, 78073125, - -38502470, -1609189, 18523609, -14639744, - 4362037, 1880478, -2973608, 2057290, -}; -#define NUM_COEFF_16KHZ (sizeof(filter_16khz_coeff) / sizeof(filter_16khz_coeff[0])) -#define OVERLAP_16KHZ (NUM_COEFF_16KHZ - 1) - -/* - * Convert a chunk from 22 kHz to 16 kHz. Will update num_samples_in and - * num_samples_out accordingly, since it may leave input samples in the buffer - * due to overlap. - * - * This implementation is rather ad-hoc; it first low-pass filters the data - * into a temporary buffer, and then converts chunks of 441 input samples at a - * time into 320 output samples by simple linear interpolation. A better - * implementation would use a polyphase filter bank to do these two operations - * in one step. - * - * Input and output are taken to be in 0.16 fixed-point. - */ - -#define RESAMPLE_16KHZ_SAMPLES_IN 441 -#define RESAMPLE_16KHZ_SAMPLES_OUT 320 - -void resample_441_320(int16_t* input, int16_t* output, int* num_samples_in, int* num_samples_out) -{ - const int num_blocks = (*num_samples_in - OVERLAP_16KHZ) / RESAMPLE_16KHZ_SAMPLES_IN; - if (num_blocks < 1) { - *num_samples_out = 0; - return; - } - - for (int i = 0; i < num_blocks; ++i) { - uint32_t tmp[RESAMPLE_16KHZ_SAMPLES_IN]; - for (int j = 0; j < RESAMPLE_16KHZ_SAMPLES_IN; ++j) { - tmp[j] = fir_convolve(input + i * RESAMPLE_16KHZ_SAMPLES_IN + j, - filter_16khz_coeff, - NUM_COEFF_16KHZ); - } - - const float step_float = (float)RESAMPLE_16KHZ_SAMPLES_IN / (float)RESAMPLE_16KHZ_SAMPLES_OUT; - const uint32_t step = (uint32_t)(step_float * 32768.0f + 0.5f); // 17.15 fixed point - - uint32_t in_sample_num = 0; // 17.15 fixed point - for (int j = 0; j < RESAMPLE_16KHZ_SAMPLES_OUT; ++j, in_sample_num += step) { - const uint32_t whole = in_sample_num >> 15; - const uint32_t frac = (in_sample_num & 0x7fff); // 0.15 fixed point - const int32_t s1 = tmp[whole]; - const int32_t s2 = tmp[whole + 1]; - *output++ = clip(s1 + (((s2 - s1) * (int32_t)frac) >> 15)); - } - - } - - const int samples_consumed = num_blocks * RESAMPLE_16KHZ_SAMPLES_IN; - memmove(input, input + samples_consumed, (*num_samples_in - samples_consumed) * sizeof(*input)); - *num_samples_in -= samples_consumed; - *num_samples_out = RESAMPLE_16KHZ_SAMPLES_OUT * num_blocks; -} - - -AudioHardware::DownSampler::DownSampler(uint32_t outSampleRate, - uint32_t channelCount, - uint32_t frameCount, - AudioHardware::BufferProvider* provider) - : mStatus(NO_INIT), mProvider(provider), mSampleRate(outSampleRate), - mChannelCount(channelCount), mFrameCount(frameCount), - mInLeft(NULL), mInRight(NULL), mTmpLeft(NULL), mTmpRight(NULL), - mTmp2Left(NULL), mTmp2Right(NULL), mOutLeft(NULL), mOutRight(NULL) - -{ - LOGV("AudioHardware::DownSampler() cstor %p SR %d channels %d frames %d", - this, mSampleRate, mChannelCount, mFrameCount); - - if (mSampleRate != 8000 && mSampleRate != 11025 && mSampleRate != 16000 && - mSampleRate != 22050) { - LOGW("AudioHardware::DownSampler cstor: bad sampling rate: %d", mSampleRate); - return; - } - - mInLeft = new int16_t[mFrameCount]; - mInRight = new int16_t[mFrameCount]; - mTmpLeft = new int16_t[mFrameCount]; - mTmpRight = new int16_t[mFrameCount]; - mTmp2Left = new int16_t[mFrameCount]; - mTmp2Right = new int16_t[mFrameCount]; - mOutLeft = new int16_t[mFrameCount]; - mOutRight = new int16_t[mFrameCount]; - - mStatus = NO_ERROR; -} - -AudioHardware::DownSampler::~DownSampler() -{ - if (mInLeft) delete[] mInLeft; - if (mInRight) delete[] mInRight; - if (mTmpLeft) delete[] mTmpLeft; - if (mTmpRight) delete[] mTmpRight; - if (mTmp2Left) delete[] mTmp2Left; - if (mTmp2Right) delete[] mTmp2Right; - if (mOutLeft) delete[] mOutLeft; - if (mOutRight) delete[] mOutRight; -} - -void AudioHardware::DownSampler::reset() -{ - mInInBuf = 0; - mInTmpBuf = 0; - mInTmp2Buf = 0; - mOutBufPos = 0; - mInOutBuf = 0; -} - - -int AudioHardware::DownSampler::resample(int16_t* out, size_t *outFrameCount) -{ - if (mStatus != NO_ERROR) { - return mStatus; - } - - if (out == NULL || outFrameCount == NULL) { - return BAD_VALUE; - } - - int16_t *outLeft = mTmp2Left; - int16_t *outRight = mTmp2Left; - if (mSampleRate == 22050) { - outLeft = mTmpLeft; - outRight = mTmpRight; - } else if (mSampleRate == 8000){ - outLeft = mOutLeft; - outRight = mOutRight; - } - - int outFrames = 0; - int remaingFrames = *outFrameCount; - - if (mInOutBuf) { - int frames = (remaingFrames > mInOutBuf) ? mInOutBuf : remaingFrames; - - for (int i = 0; i < frames; ++i) { - out[i] = outLeft[mOutBufPos + i]; - } - if (mChannelCount == 2) { - for (int i = 0; i < frames; ++i) { - out[i * 2] = outLeft[mOutBufPos + i]; - out[i * 2 + 1] = outRight[mOutBufPos + i]; - } - } - remaingFrames -= frames; - mInOutBuf -= frames; - mOutBufPos += frames; - outFrames += frames; - } - - while (remaingFrames) { - LOGW_IF((mInOutBuf != 0), "mInOutBuf should be 0 here"); - - AudioHardware::BufferProvider::Buffer buf; - buf.frameCount = mFrameCount - mInInBuf; - int ret = mProvider->getNextBuffer(&buf); - if (buf.raw == NULL) { - *outFrameCount = outFrames; - return ret; - } - - for (size_t i = 0; i < buf.frameCount; ++i) { - mInLeft[i + mInInBuf] = buf.i16[i]; - } - if (mChannelCount == 2) { - for (size_t i = 0; i < buf.frameCount; ++i) { - mInLeft[i + mInInBuf] = buf.i16[i * 2]; - mInRight[i + mInInBuf] = buf.i16[i * 2 + 1]; - } - } - mInInBuf += buf.frameCount; - mProvider->releaseBuffer(&buf); - - /* 44010 -> 22050 */ - { - int samples_in_left = mInInBuf; - int samples_out_left; - resample_2_1(mInLeft, mTmpLeft + mInTmpBuf, &samples_in_left, &samples_out_left); - - if (mChannelCount == 2) { - int samples_in_right = mInInBuf; - int samples_out_right; - resample_2_1(mInRight, mTmpRight + mInTmpBuf, &samples_in_right, &samples_out_right); - } - - mInInBuf = samples_in_left; - mInTmpBuf += samples_out_left; - mInOutBuf = samples_out_left; - } - - if (mSampleRate == 11025 || mSampleRate == 8000) { - /* 22050 - > 11025 */ - int samples_in_left = mInTmpBuf; - int samples_out_left; - resample_2_1(mTmpLeft, mTmp2Left + mInTmp2Buf, &samples_in_left, &samples_out_left); - - if (mChannelCount == 2) { - int samples_in_right = mInTmpBuf; - int samples_out_right; - resample_2_1(mTmpRight, mTmp2Right + mInTmp2Buf, &samples_in_right, &samples_out_right); - } - - - mInTmpBuf = samples_in_left; - mInTmp2Buf += samples_out_left; - mInOutBuf = samples_out_left; - - if (mSampleRate == 8000) { - /* 11025 -> 8000*/ - int samples_in_left = mInTmp2Buf; - int samples_out_left; - resample_441_320(mTmp2Left, mOutLeft, &samples_in_left, &samples_out_left); - - if (mChannelCount == 2) { - int samples_in_right = mInTmp2Buf; - int samples_out_right; - resample_441_320(mTmp2Right, mOutRight, &samples_in_right, &samples_out_right); - } - - mInTmp2Buf = samples_in_left; - mInOutBuf = samples_out_left; - } else { - mInTmp2Buf = 0; - } - - } else if (mSampleRate == 16000) { - /* 22050 -> 16000*/ - int samples_in_left = mInTmpBuf; - int samples_out_left; - resample_441_320(mTmpLeft, mTmp2Left, &samples_in_left, &samples_out_left); - - if (mChannelCount == 2) { - int samples_in_right = mInTmpBuf; - int samples_out_right; - resample_441_320(mTmpRight, mTmp2Right, &samples_in_right, &samples_out_right); - } - - mInTmpBuf = samples_in_left; - mInOutBuf = samples_out_left; - } else { - mInTmpBuf = 0; - } - - int frames = (remaingFrames > mInOutBuf) ? mInOutBuf : remaingFrames; - - for (int i = 0; i < frames; ++i) { - out[outFrames + i] = outLeft[i]; - } - if (mChannelCount == 2) { - for (int i = 0; i < frames; ++i) { - out[(outFrames + i) * 2] = outLeft[i]; - out[(outFrames + i) * 2 + 1] = outRight[i]; - } - } - remaingFrames -= frames; - outFrames += frames; - mOutBufPos = frames; - mInOutBuf -= frames; - } - - return 0; -} - - - - - - - -//------------------------------------------------------------------------------ -// Factory -//------------------------------------------------------------------------------ - -extern "C" AudioHardwareInterface* createAudioHardware(void) { - return new AudioHardware(); -} - -}; // namespace android diff --git a/aries/libaudio/AudioHardware.h b/aries/libaudio/AudioHardware.h deleted file mode 100644 index a23e6c9..0000000 --- a/aries/libaudio/AudioHardware.h +++ /dev/null @@ -1,367 +0,0 @@ -/* -** Copyright 2008, The Android Open-Source Project -** -** 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_AUDIO_HARDWARE_H -#define ANDROID_AUDIO_HARDWARE_H - -#include -#include - -#include -#include - -#include -#include - -#include "secril-client.h" - -extern "C" { - struct pcm; - struct mixer; - struct mixer_ctl; -}; - -namespace android { - -// TODO: determine actual audio DSP and hardware latency -// Additionnal latency introduced by audio DSP and hardware in ms -#define AUDIO_HW_OUT_LATENCY_MS 0 -// Default audio output sample rate -#define AUDIO_HW_OUT_SAMPLERATE 44100 -// Default audio output channel mask -#define AUDIO_HW_OUT_CHANNELS (AudioSystem::CHANNEL_OUT_STEREO) -// Default audio output sample format -#define AUDIO_HW_OUT_FORMAT (AudioSystem::PCM_16_BIT) -// Kernel pcm out buffer size in frames at 44.1kHz -#define AUDIO_HW_OUT_PERIOD_MULT 8 // (8 * 128 = 1024 frames) -#define AUDIO_HW_OUT_PERIOD_SZ (PCM_PERIOD_SZ_MIN * AUDIO_HW_OUT_PERIOD_MULT) -#define AUDIO_HW_OUT_PERIOD_CNT 4 -// Default audio output buffer size in bytes -#define AUDIO_HW_OUT_PERIOD_BYTES (AUDIO_HW_OUT_PERIOD_SZ * 2 * sizeof(int16_t)) - -// Default audio input sample rate -#define AUDIO_HW_IN_SAMPLERATE 8000 -// Default audio input channel mask -#define AUDIO_HW_IN_CHANNELS (AudioSystem::CHANNEL_IN_MONO) -// Default audio input sample format -#define AUDIO_HW_IN_FORMAT (AudioSystem::PCM_16_BIT) -// Number of buffers in audio driver for input -#define AUDIO_HW_NUM_IN_BUF 2 -// Kernel pcm in buffer size in frames at 44.1kHz (before resampling) -#define AUDIO_HW_IN_PERIOD_MULT 16 // (16 * 128 = 2048 frames) -#define AUDIO_HW_IN_PERIOD_SZ (PCM_PERIOD_SZ_MIN * AUDIO_HW_IN_PERIOD_MULT) -#define AUDIO_HW_IN_PERIOD_CNT 2 -// Default audio input buffer size in bytes (8kHz mono) -#define AUDIO_HW_IN_PERIOD_BYTES ((AUDIO_HW_IN_PERIOD_SZ*sizeof(int16_t))/8) - - -class AudioHardware : public AudioHardwareBase -{ - class AudioStreamOutALSA; - class AudioStreamInALSA; -public: - - // input path names used to translate from input sources to driver paths - static const char *inputPathNameDefault; - static const char *inputPathNameCamcorder; - static const char *inputPathNameVoiceRecognition; - static const char *inputPathNameVoiceCommunication; - - AudioHardware(); - virtual ~AudioHardware(); - virtual status_t initCheck(); - - virtual status_t setVoiceVolume(float volume); - virtual status_t setMasterVolume(float volume); - - virtual status_t setMode(int mode); - - virtual status_t setMicMute(bool state); - virtual status_t getMicMute(bool* state); - - virtual status_t setParameters(const String8& keyValuePairs); - virtual String8 getParameters(const String8& keys); - - virtual AudioStreamOut* openOutputStream( - uint32_t devices, int *format=0, uint32_t *channels=0, - uint32_t *sampleRate=0, status_t *status=0); - - virtual AudioStreamIn* openInputStream( - uint32_t devices, int *format, uint32_t *channels, - uint32_t *sampleRate, status_t *status, - AudioSystem::audio_in_acoustics acoustics); - - virtual void closeOutputStream(AudioStreamOut* out); - virtual void closeInputStream(AudioStreamIn* in); - - virtual size_t getInputBufferSize( - uint32_t sampleRate, int format, int channelCount); - - int mode() { return mMode; } - const char *getOutputRouteFromDevice(uint32_t device); - const char *getInputRouteFromDevice(uint32_t device); - const char *getVoiceRouteFromDevice(uint32_t device); - - status_t setIncallPath_l(uint32_t device); - - status_t setInputSource_l(audio_source source); - - static uint32_t getInputSampleRate(uint32_t sampleRate); - sp getActiveInput_l(); - - Mutex& lock() { return mLock; } - - struct pcm *openPcmOut_l(); - void closePcmOut_l(); - - struct mixer *openMixer_l(); - void closeMixer_l(); - - sp output() { return mOutput; } - -protected: - virtual status_t dump(int fd, const Vector& args); - -private: - - enum tty_modes { - TTY_MODE_OFF, - TTY_MODE_VCO, - TTY_MODE_HCO, - TTY_MODE_FULL - }; - - bool mInit; - bool mMicMute; - sp mOutput; - SortedVector < sp > mInputs; - Mutex mLock; - struct pcm* mPcm; - struct mixer* mMixer; - uint32_t mPcmOpenCnt; - uint32_t mMixerOpenCnt; - bool mInCallAudioMode; - - audio_source mInputSource; - bool mBluetoothNrec; - int mTTYMode; - - void* mSecRilLibHandle; - HRilClient mRilClient; - bool mActivatedCP; - HRilClient (*openClientRILD) (void); - int (*disconnectRILD) (HRilClient); - int (*closeClientRILD) (HRilClient); - int (*isConnectedRILD) (HRilClient); - int (*connectRILD) (HRilClient); - int (*setCallVolume) (HRilClient, SoundType, int); - int (*setCallAudioPath)(HRilClient, AudioPath); - int (*setCallClockSync)(HRilClient, SoundClockCondition); - void loadRILD(void); - status_t connectRILDIfRequired(void); - - // trace driver operations for dump - int mDriverOp; - - static uint32_t checkInputSampleRate(uint32_t sampleRate); - static const uint32_t inputSamplingRates[]; - - class AudioStreamOutALSA : public AudioStreamOut, public RefBase - { - public: - AudioStreamOutALSA(); - virtual ~AudioStreamOutALSA(); - status_t set(AudioHardware* mHardware, - uint32_t devices, - int *pFormat, - uint32_t *pChannels, - uint32_t *pRate); - virtual uint32_t sampleRate() - const { return mSampleRate; } - virtual size_t bufferSize() - const { return mBufferSize; } - virtual uint32_t channels() - const { return mChannels; } - virtual int format() - const { return AUDIO_HW_OUT_FORMAT; } - virtual uint32_t latency() - const { return (1000 * AUDIO_HW_OUT_PERIOD_CNT * - (bufferSize()/frameSize()))/sampleRate() + - AUDIO_HW_OUT_LATENCY_MS; } - virtual status_t setVolume(float left, float right) - { return INVALID_OPERATION; } - virtual ssize_t write(const void* buffer, size_t bytes); - virtual status_t standby(); - bool checkStandby(); - - virtual status_t dump(int fd, const Vector& args); - virtual status_t setParameters(const String8& keyValuePairs); - virtual String8 getParameters(const String8& keys); - uint32_t device() { return mDevices; } - virtual status_t getRenderPosition(uint32_t *dspFrames); - - void doStandby_l(); - void close_l(); - status_t open_l(); - int standbyCnt() { return mStandbyCnt; } - - int prepareLock(); - void lock(); - void unlock(); - - private: - - Mutex mLock; - AudioHardware* mHardware; - struct pcm *mPcm; - struct mixer *mMixer; - struct mixer_ctl *mRouteCtl; - const char *next_route; - bool mStandby; - uint32_t mDevices; - uint32_t mChannels; - uint32_t mSampleRate; - size_t mBufferSize; - // trace driver operations for dump - int mDriverOp; - int mStandbyCnt; - bool mSleepReq; - }; - - class DownSampler; - - class BufferProvider - { - public: - - struct Buffer { - union { - void* raw; - short* i16; - int8_t* i8; - }; - size_t frameCount; - }; - - virtual ~BufferProvider() {} - - virtual status_t getNextBuffer(Buffer* buffer) = 0; - virtual void releaseBuffer(Buffer* buffer) = 0; - }; - - class DownSampler { - public: - DownSampler(uint32_t outSampleRate, - uint32_t channelCount, - uint32_t frameCount, - BufferProvider* provider); - - virtual ~DownSampler(); - - void reset(); - status_t initCheck() { return mStatus; } - int resample(int16_t* out, size_t *outFrameCount); - - private: - status_t mStatus; - BufferProvider* mProvider; - uint32_t mSampleRate; - uint32_t mChannelCount; - uint32_t mFrameCount; - int16_t *mInLeft; - int16_t *mInRight; - int16_t *mTmpLeft; - int16_t *mTmpRight; - int16_t *mTmp2Left; - int16_t *mTmp2Right; - int16_t *mOutLeft; - int16_t *mOutRight; - int mInInBuf; - int mInTmpBuf; - int mInTmp2Buf; - int mOutBufPos; - int mInOutBuf; - }; - - - class AudioStreamInALSA : public AudioStreamIn, public BufferProvider, public RefBase - { - - public: - AudioStreamInALSA(); - virtual ~AudioStreamInALSA(); - status_t set(AudioHardware* hw, - uint32_t devices, - int *pFormat, - uint32_t *pChannels, - uint32_t *pRate, - AudioSystem::audio_in_acoustics acoustics); - virtual size_t bufferSize() const { return mBufferSize; } - virtual uint32_t channels() const { return mChannels; } - virtual int format() const { return AUDIO_HW_IN_FORMAT; } - virtual uint32_t sampleRate() const { return mSampleRate; } - virtual status_t setGain(float gain) { return INVALID_OPERATION; } - virtual ssize_t read(void* buffer, ssize_t bytes); - virtual status_t dump(int fd, const Vector& args); - virtual status_t standby(); - bool checkStandby(); - virtual status_t setParameters(const String8& keyValuePairs); - virtual String8 getParameters(const String8& keys); - virtual unsigned int getInputFramesLost() const { return 0; } - uint32_t device() { return mDevices; } - void doStandby_l(); - void close_l(); - status_t open_l(); - int standbyCnt() { return mStandbyCnt; } - - static size_t getBufferSize(uint32_t sampleRate, int channelCount); - - // BufferProvider - virtual status_t getNextBuffer(BufferProvider::Buffer* buffer); - virtual void releaseBuffer(BufferProvider::Buffer* buffer); - - int prepareLock(); - void lock(); - void unlock(); - - private: - Mutex mLock; - AudioHardware* mHardware; - struct pcm *mPcm; - struct mixer *mMixer; - struct mixer_ctl *mRouteCtl; - const char *next_route; - bool mStandby; - uint32_t mDevices; - uint32_t mChannels; - uint32_t mChannelCount; - uint32_t mSampleRate; - size_t mBufferSize; - DownSampler *mDownSampler; - status_t mReadStatus; - size_t mInPcmInBuf; - int16_t *mPcmIn; - // trace driver operations for dump - int mDriverOp; - int mStandbyCnt; - bool mSleepReq; - }; - -}; - -}; // namespace android - -#endif diff --git a/aries/libaudio/AudioPolicyManager.cpp b/aries/libaudio/AudioPolicyManager.cpp deleted file mode 100644 index c53d1e9..0000000 --- a/aries/libaudio/AudioPolicyManager.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * 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. - */ - -#define LOG_TAG "AudioPolicyManager" -//#define LOG_NDEBUG 0 -#include -#include "AudioPolicyManager.h" -#include - -namespace android { - - - -// ---------------------------------------------------------------------------- -// AudioPolicyManager for crespo platform -// Common audio policy manager code is implemented in AudioPolicyManagerBase class -// ---------------------------------------------------------------------------- - -// --- class factory - - -extern "C" AudioPolicyInterface* createAudioPolicyManager(AudioPolicyClientInterface *clientInterface) -{ - return new AudioPolicyManager(clientInterface); -} - -extern "C" void destroyAudioPolicyManager(AudioPolicyInterface *interface) -{ - delete interface; -} - - -}; // namespace android diff --git a/aries/libaudio/AudioPolicyManager.h b/aries/libaudio/AudioPolicyManager.h deleted file mode 100644 index 03141e5..0000000 --- a/aries/libaudio/AudioPolicyManager.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * 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 - - -namespace android { - -class AudioPolicyManager: public AudioPolicyManagerBase -{ - -public: - AudioPolicyManager(AudioPolicyClientInterface *clientInterface) - : AudioPolicyManagerBase(clientInterface) {} - - virtual ~AudioPolicyManager() {} - -protected: - // true is current platform implements a back microphone - virtual bool hasBackMicrophone() const { return false; } -#ifdef WITH_A2DP - // true is current platform supports duplication of notifications and ringtones over A2DP output - virtual bool a2dpUsedForSonification() const { return true; } -#endif - -}; -}; diff --git a/aries/libaudio/alsa_audio.h b/aries/libaudio/alsa_audio.h deleted file mode 100644 index 3cb86d9..0000000 --- a/aries/libaudio/alsa_audio.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -** Copyright 2010, The Android Open-Source Project -** -** 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 _AUDIO_H_ -#define _AUDIO_H_ - -struct pcm; - -#define PCM_OUT 0x00000000 -#define PCM_IN 0x10000000 - -#define PCM_STEREO 0x00000000 -#define PCM_MONO 0x01000000 - -#define PCM_44100HZ 0x00000000 -#define PCM_48000HZ 0x00100000 -#define PCM_8000HZ 0x00200000 -#define PCM_RATE_MASK 0x00F00000 - -#define PCM_PERIOD_CNT_MIN 2 -#define PCM_PERIOD_CNT_SHIFT 16 -#define PCM_PERIOD_CNT_MASK (0xF << PCM_PERIOD_CNT_SHIFT) -#define PCM_PERIOD_SZ_MIN 128 -#define PCM_PERIOD_SZ_SHIFT 12 -#define PCM_PERIOD_SZ_MASK (0xF << PCM_PERIOD_SZ_SHIFT) - -/* Acquire/release a pcm channel. - * Returns non-zero on error - */ -struct pcm *pcm_open(unsigned flags); -int pcm_close(struct pcm *pcm); -int pcm_ready(struct pcm *pcm); - -/* Returns a human readable reason for the last error. */ -const char *pcm_error(struct pcm *pcm); - -/* Returns the buffer size (int bytes) that should be used for pcm_write. - * This will be 1/2 of the actual fifo size. - */ -unsigned pcm_buffer_size(struct pcm *pcm); - -/* Write data to the fifo. - * Will start playback on the first write or on a write that - * occurs after a fifo underrun. - */ -int pcm_write(struct pcm *pcm, void *data, unsigned count); -int pcm_read(struct pcm *pcm, void *data, unsigned count); - -struct mixer; -struct mixer_ctl; - -struct mixer *mixer_open(void); -void mixer_close(struct mixer *mixer); -void mixer_dump(struct mixer *mixer); - -struct mixer_ctl *mixer_get_control(struct mixer *mixer, - const char *name, unsigned index); -struct mixer_ctl *mixer_get_nth_control(struct mixer *mixer, unsigned n); - -int mixer_ctl_set(struct mixer_ctl *ctl, unsigned percent); -int mixer_ctl_select(struct mixer_ctl *ctl, const char *value); -void mixer_ctl_print(struct mixer_ctl *ctl); - -#endif diff --git a/aries/libaudio/alsa_mixer.c b/aries/libaudio/alsa_mixer.c deleted file mode 100644 index 3036ef8..0000000 --- a/aries/libaudio/alsa_mixer.c +++ /dev/null @@ -1,371 +0,0 @@ -/* -** Copyright 2010, The Android Open-Source Project -** -** 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 -#define __force -#define __bitwise -#define __user -#include "asound.h" - -#include "alsa_audio.h" - -static const char *elem_iface_name(snd_ctl_elem_iface_t n) -{ - switch (n) { - case SNDRV_CTL_ELEM_IFACE_CARD: return "CARD"; - case SNDRV_CTL_ELEM_IFACE_HWDEP: return "HWDEP"; - case SNDRV_CTL_ELEM_IFACE_MIXER: return "MIXER"; - case SNDRV_CTL_ELEM_IFACE_PCM: return "PCM"; - case SNDRV_CTL_ELEM_IFACE_RAWMIDI: return "MIDI"; - case SNDRV_CTL_ELEM_IFACE_TIMER: return "TIMER"; - case SNDRV_CTL_ELEM_IFACE_SEQUENCER: return "SEQ"; - default: return "???"; - } -} - -static const char *elem_type_name(snd_ctl_elem_type_t n) -{ - switch (n) { - case SNDRV_CTL_ELEM_TYPE_NONE: return "NONE"; - case SNDRV_CTL_ELEM_TYPE_BOOLEAN: return "BOOL"; - case SNDRV_CTL_ELEM_TYPE_INTEGER: return "INT32"; - case SNDRV_CTL_ELEM_TYPE_ENUMERATED: return "ENUM"; - case SNDRV_CTL_ELEM_TYPE_BYTES: return "BYTES"; - case SNDRV_CTL_ELEM_TYPE_IEC958: return "IEC958"; - case SNDRV_CTL_ELEM_TYPE_INTEGER64: return "INT64"; - default: return "???"; - } -} - - -struct mixer_ctl { - struct mixer *mixer; - struct snd_ctl_elem_info *info; - char **ename; -}; - -struct mixer { - int fd; - struct snd_ctl_elem_info *info; - struct mixer_ctl *ctl; - unsigned count; -}; - -void mixer_close(struct mixer *mixer) -{ - unsigned n,m; - - if (mixer->fd >= 0) - close(mixer->fd); - - if (mixer->ctl) { - for (n = 0; n < mixer->count; n++) { - if (mixer->ctl[n].ename) { - unsigned max = mixer->ctl[n].info->value.enumerated.items; - for (m = 0; m < max; m++) - free(mixer->ctl[n].ename[m]); - free(mixer->ctl[n].ename); - } - } - free(mixer->ctl); - } - - if (mixer->info) - free(mixer->info); - - free(mixer); -} - -struct mixer *mixer_open(void) -{ - struct snd_ctl_elem_list elist; - struct snd_ctl_elem_info tmp; - struct snd_ctl_elem_id *eid = NULL; - struct mixer *mixer = NULL; - unsigned n, m; - int fd; - - fd = open("/dev/snd/controlC0", O_RDWR); - if (fd < 0) - return 0; - - memset(&elist, 0, sizeof(elist)); - if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_LIST, &elist) < 0) - goto fail; - - mixer = calloc(1, sizeof(*mixer)); - if (!mixer) - goto fail; - - mixer->ctl = calloc(elist.count, sizeof(struct mixer_ctl)); - mixer->info = calloc(elist.count, sizeof(struct snd_ctl_elem_info)); - if (!mixer->ctl || !mixer->info) - goto fail; - - eid = calloc(elist.count, sizeof(struct snd_ctl_elem_id)); - if (!eid) - goto fail; - - mixer->count = elist.count; - mixer->fd = fd; - elist.space = mixer->count; - elist.pids = eid; - if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_LIST, &elist) < 0) - goto fail; - - for (n = 0; n < mixer->count; n++) { - struct snd_ctl_elem_info *ei = mixer->info + n; - ei->id.numid = eid[n].numid; - if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_INFO, ei) < 0) - goto fail; - mixer->ctl[n].info = ei; - mixer->ctl[n].mixer = mixer; - if (ei->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED) { - char **enames = calloc(ei->value.enumerated.items, sizeof(char*)); - if (!enames) - goto fail; - mixer->ctl[n].ename = enames; - for (m = 0; m < ei->value.enumerated.items; m++) { - memset(&tmp, 0, sizeof(tmp)); - tmp.id.numid = ei->id.numid; - tmp.value.enumerated.item = m; - if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_INFO, &tmp) < 0) - goto fail; - enames[m] = strdup(tmp.value.enumerated.name); - if (!enames[m]) - goto fail; - } - } - } - - free(eid); - return mixer; - -fail: - if (eid) - free(eid); - if (mixer) - mixer_close(mixer); - else if (fd >= 0) - close(fd); - return 0; -} - -void mixer_dump(struct mixer *mixer) -{ - unsigned n, m; - - printf(" id iface dev sub idx num perms type name\n"); - for (n = 0; n < mixer->count; n++) { - struct snd_ctl_elem_info *ei = mixer->info + n; - - printf("%4d %5s %3d %3d %3d %3d %c%c%c%c%c%c%c%c%c %-6s %s", - ei->id.numid, elem_iface_name(ei->id.iface), - ei->id.device, ei->id.subdevice, ei->id.index, - ei->count, - (ei->access & SNDRV_CTL_ELEM_ACCESS_READ) ? 'r' : ' ', - (ei->access & SNDRV_CTL_ELEM_ACCESS_WRITE) ? 'w' : ' ', - (ei->access & SNDRV_CTL_ELEM_ACCESS_VOLATILE) ? 'V' : ' ', - (ei->access & SNDRV_CTL_ELEM_ACCESS_TIMESTAMP) ? 'T' : ' ', - (ei->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) ? 'R' : ' ', - (ei->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) ? 'W' : ' ', - (ei->access & SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND) ? 'C' : ' ', - (ei->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE) ? 'I' : ' ', - (ei->access & SNDRV_CTL_ELEM_ACCESS_LOCK) ? 'L' : ' ', - elem_type_name(ei->type), - ei->id.name); - switch (ei->type) { - case SNDRV_CTL_ELEM_TYPE_INTEGER: - printf(ei->value.integer.step ? - " { %ld-%ld, %ld }\n" : " { %ld-%ld }", - ei->value.integer.min, - ei->value.integer.max, - ei->value.integer.step); - break; - case SNDRV_CTL_ELEM_TYPE_INTEGER64: - printf(ei->value.integer64.step ? - " { %lld-%lld, %lld }\n" : " { %lld-%lld }", - ei->value.integer64.min, - ei->value.integer64.max, - ei->value.integer64.step); - break; - case SNDRV_CTL_ELEM_TYPE_ENUMERATED: { - unsigned m; - printf(" { %s=0", mixer->ctl[n].ename[0]); - for (m = 1; m < ei->value.enumerated.items; m++) - printf(", %s=%d", mixer->ctl[n].ename[m],m); - printf(" }"); - break; - } - } - printf("\n"); - } -} - -struct mixer_ctl *mixer_get_control(struct mixer *mixer, - const char *name, unsigned index) -{ - unsigned n; - for (n = 0; n < mixer->count; n++) { - if (mixer->info[n].id.index == index) { - if (!strcmp(name, (char*) mixer->info[n].id.name)) { - return mixer->ctl + n; - } - } - } - return 0; -} - -struct mixer_ctl *mixer_get_nth_control(struct mixer *mixer, unsigned n) -{ - if (n < mixer->count) - return mixer->ctl + n; - return 0; -} - -void mixer_ctl_print(struct mixer_ctl *ctl) -{ - struct snd_ctl_elem_value ev; - unsigned n; - - memset(&ev, 0, sizeof(ev)); - ev.id.numid = ctl->info->id.numid; - if (ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev)) - return; - printf("%s:", ctl->info->id.name); - - switch (ctl->info->type) { - case SNDRV_CTL_ELEM_TYPE_BOOLEAN: - for (n = 0; n < ctl->info->count; n++) - printf(" %s", ev.value.integer.value[n] ? "ON" : "OFF"); - break; - case SNDRV_CTL_ELEM_TYPE_INTEGER: { - for (n = 0; n < ctl->info->count; n++) - printf(" %ld", ev.value.integer.value[n]); - break; - } - case SNDRV_CTL_ELEM_TYPE_INTEGER64: - for (n = 0; n < ctl->info->count; n++) - printf(" %lld", ev.value.integer64.value[n]); - break; - case SNDRV_CTL_ELEM_TYPE_ENUMERATED: - for (n = 0; n < ctl->info->count; n++) { - unsigned v = ev.value.enumerated.item[n]; - printf(" %d (%s)", v, - (v < ctl->info->value.enumerated.items) ? ctl->ename[v] : "???"); - } - break; - default: - printf(" ???"); - } - printf("\n"); -} - -static long scale_int(struct snd_ctl_elem_info *ei, unsigned _percent) -{ - long percent; - long range; - - if (_percent > 100) - percent = 100; - else - percent = (long) _percent; - - range = (ei->value.integer.max - ei->value.integer.min); - - return ei->value.integer.min + (range * percent) / 100LL; -} - -static long long scale_int64(struct snd_ctl_elem_info *ei, unsigned _percent) -{ - long long percent; - long long range; - - if (_percent > 100) - percent = 100; - else - percent = (long) _percent; - - range = (ei->value.integer.max - ei->value.integer.min) * 100LL; - - return ei->value.integer.min + (range / percent); -} - -int mixer_ctl_set(struct mixer_ctl *ctl, unsigned percent) -{ - struct snd_ctl_elem_value ev; - unsigned n; - - memset(&ev, 0, sizeof(ev)); - ev.id.numid = ctl->info->id.numid; - switch (ctl->info->type) { - case SNDRV_CTL_ELEM_TYPE_BOOLEAN: - for (n = 0; n < ctl->info->count; n++) - ev.value.integer.value[n] = !!percent; - break; - case SNDRV_CTL_ELEM_TYPE_INTEGER: { - long value = scale_int(ctl->info, percent); - for (n = 0; n < ctl->info->count; n++) - ev.value.integer.value[n] = value; - break; - } - case SNDRV_CTL_ELEM_TYPE_INTEGER64: { - long long value = scale_int64(ctl->info, percent); - for (n = 0; n < ctl->info->count; n++) - ev.value.integer64.value[n] = value; - break; - } - default: - errno = EINVAL; - return -1; - } - - return ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev); -} - -int mixer_ctl_select(struct mixer_ctl *ctl, const char *value) -{ - unsigned n, max; - struct snd_ctl_elem_value ev; - - if (ctl->info->type != SNDRV_CTL_ELEM_TYPE_ENUMERATED) { - errno = EINVAL; - return -1; - } - - max = ctl->info->value.enumerated.items; - for (n = 0; n < max; n++) { - if (!strcmp(value, ctl->ename[n])) { - memset(&ev, 0, sizeof(ev)); - ev.value.enumerated.item[0] = n; - ev.id.numid = ctl->info->id.numid; - if (ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev) < 0) - return -1; - return 0; - } - } - - errno = EINVAL; - return -1; -} diff --git a/aries/libaudio/alsa_pcm.c b/aries/libaudio/alsa_pcm.c deleted file mode 100644 index 5673391..0000000 --- a/aries/libaudio/alsa_pcm.c +++ /dev/null @@ -1,405 +0,0 @@ -/* -** Copyright 2010, The Android Open-Source Project -** -** 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. -*/ - -#define LOG_TAG "alsa_pcm" -//#define LOG_NDEBUG 0 -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "alsa_audio.h" - -#define __force -#define __bitwise -#define __user -#include "asound.h" - -#define DEBUG 0 - -/* alsa parameter manipulation cruft */ - -#define PARAM_MAX SNDRV_PCM_HW_PARAM_LAST_INTERVAL - -static inline int param_is_mask(int p) -{ - return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) && - (p <= SNDRV_PCM_HW_PARAM_LAST_MASK); -} - -static inline int param_is_interval(int p) -{ - return (p >= SNDRV_PCM_HW_PARAM_FIRST_INTERVAL) && - (p <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL); -} - -static inline struct snd_interval *param_to_interval(struct snd_pcm_hw_params *p, int n) -{ - return &(p->intervals[n - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]); -} - -static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p, int n) -{ - return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]); -} - -static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned bit) -{ - if (bit >= SNDRV_MASK_MAX) - return; - if (param_is_mask(n)) { - struct snd_mask *m = param_to_mask(p, n); - m->bits[0] = 0; - m->bits[1] = 0; - m->bits[bit >> 5] |= (1 << (bit & 31)); - } -} - -static void param_set_min(struct snd_pcm_hw_params *p, int n, unsigned val) -{ - if (param_is_interval(n)) { - struct snd_interval *i = param_to_interval(p, n); - i->min = val; - } -} - -static void param_set_max(struct snd_pcm_hw_params *p, int n, unsigned val) -{ - if (param_is_interval(n)) { - struct snd_interval *i = param_to_interval(p, n); - i->max = val; - } -} - -static void param_set_int(struct snd_pcm_hw_params *p, int n, unsigned val) -{ - if (param_is_interval(n)) { - struct snd_interval *i = param_to_interval(p, n); - i->min = val; - i->max = val; - i->integer = 1; - } -} - -static void param_init(struct snd_pcm_hw_params *p) -{ - int n; - memset(p, 0, sizeof(*p)); - for (n = SNDRV_PCM_HW_PARAM_FIRST_MASK; - n <= SNDRV_PCM_HW_PARAM_LAST_MASK; n++) { - struct snd_mask *m = param_to_mask(p, n); - m->bits[0] = ~0; - m->bits[1] = ~0; - } - for (n = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; - n <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; n++) { - struct snd_interval *i = param_to_interval(p, n); - i->min = 0; - i->max = ~0; - } -} - -/* debugging gunk */ - -#if DEBUG -static const char *param_name[PARAM_MAX+1] = { - [SNDRV_PCM_HW_PARAM_ACCESS] = "access", - [SNDRV_PCM_HW_PARAM_FORMAT] = "format", - [SNDRV_PCM_HW_PARAM_SUBFORMAT] = "subformat", - - [SNDRV_PCM_HW_PARAM_SAMPLE_BITS] = "sample_bits", - [SNDRV_PCM_HW_PARAM_FRAME_BITS] = "frame_bits", - [SNDRV_PCM_HW_PARAM_CHANNELS] = "channels", - [SNDRV_PCM_HW_PARAM_RATE] = "rate", - [SNDRV_PCM_HW_PARAM_PERIOD_TIME] = "period_time", - [SNDRV_PCM_HW_PARAM_PERIOD_SIZE] = "period_size", - [SNDRV_PCM_HW_PARAM_PERIOD_BYTES] = "period_bytes", - [SNDRV_PCM_HW_PARAM_PERIODS] = "periods", - [SNDRV_PCM_HW_PARAM_BUFFER_TIME] = "buffer_time", - [SNDRV_PCM_HW_PARAM_BUFFER_SIZE] = "buffer_size", - [SNDRV_PCM_HW_PARAM_BUFFER_BYTES] = "buffer_bytes", - [SNDRV_PCM_HW_PARAM_TICK_TIME] = "tick_time", -}; - -static void param_dump(struct snd_pcm_hw_params *p) -{ - int n; - - for (n = SNDRV_PCM_HW_PARAM_FIRST_MASK; - n <= SNDRV_PCM_HW_PARAM_LAST_MASK; n++) { - struct snd_mask *m = param_to_mask(p, n); - LOGV("%s = %08x%08x\n", param_name[n], - m->bits[1], m->bits[0]); - } - for (n = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; - n <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; n++) { - struct snd_interval *i = param_to_interval(p, n); - LOGV("%s = (%d,%d) omin=%d omax=%d int=%d empty=%d\n", - param_name[n], i->min, i->max, i->openmin, - i->openmax, i->integer, i->empty); - } - LOGV("info = %08x\n", p->info); - LOGV("msbits = %d\n", p->msbits); - LOGV("rate = %d/%d\n", p->rate_num, p->rate_den); - LOGV("fifo = %d\n", (int) p->fifo_size); -} - -static void info_dump(struct snd_pcm_info *info) -{ - LOGV("device = %d\n", info->device); - LOGV("subdevice = %d\n", info->subdevice); - LOGV("stream = %d\n", info->stream); - LOGV("card = %d\n", info->card); - LOGV("id = '%s'\n", info->id); - LOGV("name = '%s'\n", info->name); - LOGV("subname = '%s'\n", info->subname); - LOGV("dev_class = %d\n", info->dev_class); - LOGV("dev_subclass = %d\n", info->dev_subclass); - LOGV("subdevices_count = %d\n", info->subdevices_count); - LOGV("subdevices_avail = %d\n", info->subdevices_avail); -} -#else -static void param_dump(struct snd_pcm_hw_params *p) {} -static void info_dump(struct snd_pcm_info *info) {} -#endif - -#define PCM_ERROR_MAX 128 - -struct pcm { - int fd; - unsigned flags; - int running:1; - int underruns; - unsigned buffer_size; - char error[PCM_ERROR_MAX]; -}; - -unsigned pcm_buffer_size(struct pcm *pcm) -{ - return pcm->buffer_size; -} - -const char* pcm_error(struct pcm *pcm) -{ - return pcm->error; -} - -static int oops(struct pcm *pcm, int e, const char *fmt, ...) -{ - va_list ap; - int sz; - - va_start(ap, fmt); - vsnprintf(pcm->error, PCM_ERROR_MAX, fmt, ap); - va_end(ap); - sz = strlen(pcm->error); - - if (errno) - snprintf(pcm->error + sz, PCM_ERROR_MAX - sz, - ": %s", strerror(e)); - return -1; -} - -int pcm_write(struct pcm *pcm, void *data, unsigned count) -{ - struct snd_xferi x; - - if (pcm->flags & PCM_IN) - return -EINVAL; - - x.buf = data; - x.frames = (pcm->flags & PCM_MONO) ? (count / 2) : (count / 4); - - for (;;) { - if (!pcm->running) { - if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_PREPARE)) - return oops(pcm, errno, "cannot prepare channel"); - if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &x)) - return oops(pcm, errno, "cannot write initial data"); - pcm->running = 1; - return 0; - } - if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &x)) { - pcm->running = 0; - if (errno == EPIPE) { - /* we failed to make our window -- try to restart */ - pcm->underruns++; - continue; - } - return oops(pcm, errno, "cannot write stream data"); - } - return 0; - } -} - -int pcm_read(struct pcm *pcm, void *data, unsigned count) -{ - struct snd_xferi x; - - if (!(pcm->flags & PCM_IN)) - return -EINVAL; - - x.buf = data; - x.frames = (pcm->flags & PCM_MONO) ? (count / 2) : (count / 4); - -// LOGV("read() %d frames", x.frames); - for (;;) { - if (!pcm->running) { - if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_PREPARE)) - return oops(pcm, errno, "cannot prepare channel"); - if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_START)) - return oops(pcm, errno, "cannot start channel"); - pcm->running = 1; - } - if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_READI_FRAMES, &x)) { - pcm->running = 0; - if (errno == EPIPE) { - /* we failed to make our window -- try to restart */ - pcm->underruns++; - continue; - } - return oops(pcm, errno, "cannot read stream data"); - } -// LOGV("read() got %d frames", x.frames); - return 0; - } -} - -static struct pcm bad_pcm = { - .fd = -1, -}; - -int pcm_close(struct pcm *pcm) -{ - if (pcm == &bad_pcm) - return 0; - - if (pcm->fd >= 0) - close(pcm->fd); - pcm->running = 0; - pcm->buffer_size = 0; - pcm->fd = -1; - return 0; -} - -struct pcm *pcm_open(unsigned flags) -{ - const char *dname; - struct pcm *pcm; - struct snd_pcm_info info; - struct snd_pcm_hw_params params; - struct snd_pcm_sw_params sparams; - unsigned period_sz; - unsigned period_cnt; - - LOGV("pcm_open(0x%08x)",flags); - - pcm = calloc(1, sizeof(struct pcm)); - if (!pcm) - return &bad_pcm; - - if (flags & PCM_IN) { - dname = "/dev/snd/pcmC0D0c"; - } else { - dname = "/dev/snd/pcmC0D0p"; - } - - LOGV("pcm_open() period sz multiplier %d", - ((flags & PCM_PERIOD_SZ_MASK) >> PCM_PERIOD_SZ_SHIFT) + 1); - period_sz = 128 * (((flags & PCM_PERIOD_SZ_MASK) >> PCM_PERIOD_SZ_SHIFT) + 1); - LOGV("pcm_open() period cnt %d", - ((flags & PCM_PERIOD_CNT_MASK) >> PCM_PERIOD_CNT_SHIFT) + PCM_PERIOD_CNT_MIN); - period_cnt = ((flags & PCM_PERIOD_CNT_MASK) >> PCM_PERIOD_CNT_SHIFT) + PCM_PERIOD_CNT_MIN; - - pcm->flags = flags; - pcm->fd = open(dname, O_RDWR); - if (pcm->fd < 0) { - oops(pcm, errno, "cannot open device '%s'"); - return pcm; - } - - if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_INFO, &info)) { - oops(pcm, errno, "cannot get info - %s"); - goto fail; - } - info_dump(&info); - - LOGV("pcm_open() period_cnt %d period_sz %d channels %d", - period_cnt, period_sz, (flags & PCM_MONO) ? 1 : 2); - - param_init(¶ms); - param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_ACCESS, - SNDRV_PCM_ACCESS_RW_INTERLEAVED); - param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_FORMAT, - SNDRV_PCM_FORMAT_S16_LE); - param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_SUBFORMAT, - SNDRV_PCM_SUBFORMAT_STD); - param_set_min(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, period_sz); - param_set_int(¶ms, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, 16); - param_set_int(¶ms, SNDRV_PCM_HW_PARAM_FRAME_BITS, - (flags & PCM_MONO) ? 16 : 32); - param_set_int(¶ms, SNDRV_PCM_HW_PARAM_CHANNELS, - (flags & PCM_MONO) ? 1 : 2); - param_set_int(¶ms, SNDRV_PCM_HW_PARAM_PERIODS, period_cnt); - param_set_int(¶ms, SNDRV_PCM_HW_PARAM_RATE, 44100); - - if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_HW_PARAMS, ¶ms)) { - oops(pcm, errno, "cannot set hw params"); - goto fail; - } - param_dump(¶ms); - - memset(&sparams, 0, sizeof(sparams)); - sparams.tstamp_mode = SNDRV_PCM_TSTAMP_NONE; - sparams.period_step = 1; - sparams.avail_min = 1; - sparams.start_threshold = period_cnt * period_sz; - sparams.stop_threshold = period_cnt * period_sz; - sparams.xfer_align = period_sz / 2; /* needed for old kernels */ - sparams.silence_size = 0; - sparams.silence_threshold = 0; - - if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sparams)) { - oops(pcm, errno, "cannot set sw params"); - goto fail; - } - - pcm->buffer_size = period_cnt * period_sz; - pcm->underruns = 0; - return pcm; - -fail: - close(pcm->fd); - pcm->fd = -1; - return pcm; -} - -int pcm_ready(struct pcm *pcm) -{ - return pcm->fd >= 0; -} diff --git a/aries/libaudio/amix.c b/aries/libaudio/amix.c deleted file mode 100644 index d978caa..0000000 --- a/aries/libaudio/amix.c +++ /dev/null @@ -1,78 +0,0 @@ -/* -** Copyright 2010, The Android Open-Source Project -** -** 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 "alsa_audio.h" - - -struct mixer_ctl *get_ctl(struct mixer *mixer, char *name) -{ - char *p; - unsigned idx = 0; - - if (isdigit(name[0])) - return mixer_get_nth_control(mixer, atoi(name) - 1); - - p = strrchr(name, '#'); - if (p) { - *p++ = 0; - idx = atoi(p); - } - - return mixer_get_control(mixer, name, idx); -} - -int main(int argc, char **argv) -{ - struct mixer *mixer; - struct mixer_ctl *ctl; - int r; - - mixer = mixer_open(); - if (!mixer) - return -1; - - if (argc == 1) { - mixer_dump(mixer); - return 0; - } - - ctl = get_ctl(mixer, argv[1]); - argc -= 2; - argv += 2; - - if (!ctl) { - fprintf(stderr,"can't find control\n"); - return -1; - } - - if (argc) { - if (isdigit(argv[0][0])) - r = mixer_ctl_set(ctl, atoi(argv[0])); - else - r = mixer_ctl_select(ctl, argv[0]); - if (r) - fprintf(stderr,"oops: %s\n", strerror(errno)); - } else { - mixer_ctl_print(ctl); - } - return 0; -} diff --git a/aries/libaudio/aplay.c b/aries/libaudio/aplay.c deleted file mode 100644 index 0ac0ac0..0000000 --- a/aries/libaudio/aplay.c +++ /dev/null @@ -1,140 +0,0 @@ -/* -** Copyright 2010, The Android Open-Source Project -** -** 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 "alsa_audio.h" - -#define ID_RIFF 0x46464952 -#define ID_WAVE 0x45564157 -#define ID_FMT 0x20746d66 -#define ID_DATA 0x61746164 - -#define FORMAT_PCM 1 - -struct wav_header { - uint32_t riff_id; - uint32_t riff_sz; - uint32_t riff_fmt; - uint32_t fmt_id; - uint32_t fmt_sz; - uint16_t audio_format; - uint16_t num_channels; - uint32_t sample_rate; - uint32_t byte_rate; /* sample_rate * num_channels * bps / 8 */ - uint16_t block_align; /* num_channels * bps / 8 */ - uint16_t bits_per_sample; - uint32_t data_id; - uint32_t data_sz; -}; - -int play_file(unsigned rate, unsigned channels, int fd, unsigned count) -{ - struct pcm *pcm; - struct mixer *mixer; - struct pcm_ctl *ctl = NULL; - unsigned bufsize; - char *data; - unsigned flags = PCM_OUT; - - if (channels == 1) - flags |= PCM_MONO; - else - flags |= PCM_STEREO; - - pcm = pcm_open(flags); - if (!pcm_ready(pcm)) { - pcm_close(pcm); - return -1; - } - - mixer = mixer_open(); - if (mixer) - ctl = mixer_get_control(mixer,"Playback Path", 0); - - bufsize = pcm_buffer_size(pcm); - data = malloc(bufsize); - if (!data) { - fprintf(stderr,"could not allocate %d bytes\n", count); - return -1; - } - - while (read(fd, data, bufsize) == bufsize) { - if (pcm_write(pcm, data, bufsize)) - break; - - /* HACK: remove */ - if (ctl) { - //mixer_ctl_select(ctl, "SPK"); - ctl = 0; - } - } - pcm_close(pcm); - return 0; -} - -int play_wav(const char *fn) -{ - struct wav_header hdr; - unsigned rate, channels; - int fd; - fd = open(fn, O_RDONLY); - if (fd < 0) { - fprintf(stderr, "aplay: cannot open '%s'\n", fn); - return -1; - } - if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) { - fprintf(stderr, "aplay: cannot read header\n"); - return -1; - } - fprintf(stderr,"aplay: %d ch, %d hz, %d bit, %s\n", - hdr.num_channels, hdr.sample_rate, hdr.bits_per_sample, - hdr.audio_format == FORMAT_PCM ? "PCM" : "unknown"); - - if ((hdr.riff_id != ID_RIFF) || - (hdr.riff_fmt != ID_WAVE) || - (hdr.fmt_id != ID_FMT)) { - fprintf(stderr, "aplay: '%s' is not a riff/wave file\n", fn); - return -1; - } - if ((hdr.audio_format != FORMAT_PCM) || - (hdr.fmt_sz != 16)) { - fprintf(stderr, "aplay: '%s' is not pcm format\n", fn); - return -1; - } - if (hdr.bits_per_sample != 16) { - fprintf(stderr, "aplay: '%s' is not 16bit per sample\n", fn); - return -1; - } - - return play_file(hdr.sample_rate, hdr.num_channels, fd, hdr.data_sz); -} - -int main(int argc, char **argv) -{ - if (argc != 2) { - fprintf(stderr,"usage: aplay \n"); - return -1; - } - - return play_wav(argv[1]); -} - diff --git a/aries/libaudio/arec.c b/aries/libaudio/arec.c deleted file mode 100644 index b1e9eda..0000000 --- a/aries/libaudio/arec.c +++ /dev/null @@ -1,128 +0,0 @@ -/* -** Copyright 2010, The Android Open-Source Project -** -** 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 "alsa_audio.h" - -#define ID_RIFF 0x46464952 -#define ID_WAVE 0x45564157 -#define ID_FMT 0x20746d66 -#define ID_DATA 0x61746164 - -#define FORMAT_PCM 1 - -struct wav_header { - uint32_t riff_id; - uint32_t riff_sz; - uint32_t riff_fmt; - uint32_t fmt_id; - uint32_t fmt_sz; - uint16_t audio_format; - uint16_t num_channels; - uint32_t sample_rate; - uint32_t byte_rate; /* sample_rate * num_channels * bps / 8 */ - uint16_t block_align; /* num_channels * bps / 8 */ - uint16_t bits_per_sample; - uint32_t data_id; - uint32_t data_sz; -}; - -int record_file(unsigned rate, unsigned channels, int fd, unsigned count) -{ - struct pcm *pcm; - unsigned avail, xfer, bufsize; - char *data, *next; - int r; - - pcm = pcm_open(PCM_IN|PCM_MONO); - if (!pcm_ready(pcm)) { - pcm_close(pcm); - goto fail; - } - - bufsize = pcm_buffer_size(pcm); - - data = malloc(bufsize); - if (!data) { - fprintf(stderr,"could not allocate %d bytes\n", count); - return -1; - } - - while (!pcm_read(pcm, data, bufsize)) { - if (write(fd, data, bufsize) != bufsize) { - fprintf(stderr,"could not write %d bytes\n", bufsize); - return -1; - } - } - - close(fd); - pcm_close(pcm); - return 0; - -fail: - fprintf(stderr,"pcm error: %s\n", pcm_error(pcm)); - return -1; -} - -int rec_wav(const char *fn) -{ - struct wav_header hdr; - unsigned rate, channels; - int fd; - fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC, 0664); - if (fd < 0) { - fprintf(stderr, "arec: cannot open '%s'\n", fn); - return -1; - } - - hdr.riff_id = ID_RIFF; - hdr.riff_fmt = ID_WAVE; - hdr.fmt_id = ID_FMT; - hdr.audio_format = FORMAT_PCM; - hdr.fmt_sz = 16; - hdr.bits_per_sample = 16; - hdr.num_channels = 1; - hdr.data_sz = 0; - hdr.sample_rate = 44100; - - if (write(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) { - fprintf(stderr, "arec: cannot write header\n"); - return -1; - } - fprintf(stderr,"arec: %d ch, %d hz, %d bit, %s\n", - hdr.num_channels, hdr.sample_rate, hdr.bits_per_sample, - hdr.audio_format == FORMAT_PCM ? "PCM" : "unknown"); - - - return record_file(hdr.sample_rate, hdr.num_channels, fd, hdr.data_sz); -} - -int main(int argc, char **argv) -{ - if (argc != 2) { - fprintf(stderr,"usage: arec \n"); - return -1; - } - - return rec_wav(argv[1]); -} - diff --git a/aries/libaudio/asound.h b/aries/libaudio/asound.h deleted file mode 100644 index 6a17f29..0000000 --- a/aries/libaudio/asound.h +++ /dev/null @@ -1,814 +0,0 @@ -/**************************************************************************** - **************************************************************************** - *** - *** This header was automatically generated from a Linux kernel header - *** of the same name, to make information necessary for userspace to - *** call into the kernel available to libc. It contains only constants, - *** structures, and macros generated from the original header, and thus, - *** contains no copyrightable information. - *** - **************************************************************************** - ****************************************************************************/ -#ifndef __SOUND_ASOUND_H -#define __SOUND_ASOUND_H - -#include - -#define SNDRV_PROTOCOL_VERSION(major, minor, subminor) (((major)<<16)|((minor)<<8)|(subminor)) -#define SNDRV_PROTOCOL_MAJOR(version) (((version)>>16)&0xffff) -#define SNDRV_PROTOCOL_MINOR(version) (((version)>>8)&0xff) -#define SNDRV_PROTOCOL_MICRO(version) ((version)&0xff) -#define SNDRV_PROTOCOL_INCOMPATIBLE(kversion, uversion) (SNDRV_PROTOCOL_MAJOR(kversion) != SNDRV_PROTOCOL_MAJOR(uversion) || (SNDRV_PROTOCOL_MAJOR(kversion) == SNDRV_PROTOCOL_MAJOR(uversion) && SNDRV_PROTOCOL_MINOR(kversion) != SNDRV_PROTOCOL_MINOR(uversion))) - -struct snd_aes_iec958 { - unsigned char status[24]; - unsigned char subcode[147]; - unsigned char pad; - unsigned char dig_subframe[4]; -}; - -#define SNDRV_HWDEP_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 1) - -enum { - SNDRV_HWDEP_IFACE_OPL2 = 0, - SNDRV_HWDEP_IFACE_OPL3, - SNDRV_HWDEP_IFACE_OPL4, - SNDRV_HWDEP_IFACE_SB16CSP, - SNDRV_HWDEP_IFACE_EMU10K1, - SNDRV_HWDEP_IFACE_YSS225, - SNDRV_HWDEP_IFACE_ICS2115, - SNDRV_HWDEP_IFACE_SSCAPE, - SNDRV_HWDEP_IFACE_VX, - SNDRV_HWDEP_IFACE_MIXART, - SNDRV_HWDEP_IFACE_USX2Y, - SNDRV_HWDEP_IFACE_EMUX_WAVETABLE, - SNDRV_HWDEP_IFACE_BLUETOOTH, - SNDRV_HWDEP_IFACE_USX2Y_PCM, - SNDRV_HWDEP_IFACE_PCXHR, - SNDRV_HWDEP_IFACE_SB_RC, - SNDRV_HWDEP_IFACE_HDA, - SNDRV_HWDEP_IFACE_USB_STREAM, - - SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_USB_STREAM -}; - -struct snd_hwdep_info { - unsigned int device; - int card; - unsigned char id[64]; - unsigned char name[80]; - int iface; - unsigned char reserved[64]; -}; - -struct snd_hwdep_dsp_status { - unsigned int version; - unsigned char id[32]; - unsigned int num_dsps; - unsigned int dsp_loaded; - unsigned int chip_ready; - unsigned char reserved[16]; -}; - -struct snd_hwdep_dsp_image { - unsigned int index; - unsigned char name[64]; - unsigned char __user *image; - size_t length; - unsigned long driver_data; -}; - -#define SNDRV_HWDEP_IOCTL_PVERSION _IOR ('H', 0x00, int) -#define SNDRV_HWDEP_IOCTL_INFO _IOR ('H', 0x01, struct snd_hwdep_info) -#define SNDRV_HWDEP_IOCTL_DSP_STATUS _IOR('H', 0x02, struct snd_hwdep_dsp_status) -#define SNDRV_HWDEP_IOCTL_DSP_LOAD _IOW('H', 0x03, struct snd_hwdep_dsp_image) - -#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 10) - -typedef unsigned long snd_pcm_uframes_t; -typedef signed long snd_pcm_sframes_t; - -enum { - SNDRV_PCM_CLASS_GENERIC = 0, - SNDRV_PCM_CLASS_MULTI, - SNDRV_PCM_CLASS_MODEM, - SNDRV_PCM_CLASS_DIGITIZER, - - SNDRV_PCM_CLASS_LAST = SNDRV_PCM_CLASS_DIGITIZER, -}; - -enum { - SNDRV_PCM_SUBCLASS_GENERIC_MIX = 0, - SNDRV_PCM_SUBCLASS_MULTI_MIX, - - SNDRV_PCM_SUBCLASS_LAST = SNDRV_PCM_SUBCLASS_MULTI_MIX, -}; - -enum { - SNDRV_PCM_STREAM_PLAYBACK = 0, - SNDRV_PCM_STREAM_CAPTURE, - SNDRV_PCM_STREAM_LAST = SNDRV_PCM_STREAM_CAPTURE, -}; - -typedef int __bitwise snd_pcm_access_t; -#define SNDRV_PCM_ACCESS_MMAP_INTERLEAVED ((__force snd_pcm_access_t) 0) -#define SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED ((__force snd_pcm_access_t) 1) -#define SNDRV_PCM_ACCESS_MMAP_COMPLEX ((__force snd_pcm_access_t) 2) -#define SNDRV_PCM_ACCESS_RW_INTERLEAVED ((__force snd_pcm_access_t) 3) -#define SNDRV_PCM_ACCESS_RW_NONINTERLEAVED ((__force snd_pcm_access_t) 4) -#define SNDRV_PCM_ACCESS_LAST SNDRV_PCM_ACCESS_RW_NONINTERLEAVED - -typedef int __bitwise snd_pcm_format_t; -#define SNDRV_PCM_FORMAT_S8 ((__force snd_pcm_format_t) 0) -#define SNDRV_PCM_FORMAT_U8 ((__force snd_pcm_format_t) 1) -#define SNDRV_PCM_FORMAT_S16_LE ((__force snd_pcm_format_t) 2) -#define SNDRV_PCM_FORMAT_S16_BE ((__force snd_pcm_format_t) 3) -#define SNDRV_PCM_FORMAT_U16_LE ((__force snd_pcm_format_t) 4) -#define SNDRV_PCM_FORMAT_U16_BE ((__force snd_pcm_format_t) 5) -#define SNDRV_PCM_FORMAT_S24_LE ((__force snd_pcm_format_t) 6) -#define SNDRV_PCM_FORMAT_S24_BE ((__force snd_pcm_format_t) 7) -#define SNDRV_PCM_FORMAT_U24_LE ((__force snd_pcm_format_t) 8) -#define SNDRV_PCM_FORMAT_U24_BE ((__force snd_pcm_format_t) 9) -#define SNDRV_PCM_FORMAT_S32_LE ((__force snd_pcm_format_t) 10) -#define SNDRV_PCM_FORMAT_S32_BE ((__force snd_pcm_format_t) 11) -#define SNDRV_PCM_FORMAT_U32_LE ((__force snd_pcm_format_t) 12) -#define SNDRV_PCM_FORMAT_U32_BE ((__force snd_pcm_format_t) 13) -#define SNDRV_PCM_FORMAT_FLOAT_LE ((__force snd_pcm_format_t) 14) -#define SNDRV_PCM_FORMAT_FLOAT_BE ((__force snd_pcm_format_t) 15) -#define SNDRV_PCM_FORMAT_FLOAT64_LE ((__force snd_pcm_format_t) 16) -#define SNDRV_PCM_FORMAT_FLOAT64_BE ((__force snd_pcm_format_t) 17) -#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE ((__force snd_pcm_format_t) 18) -#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE ((__force snd_pcm_format_t) 19) -#define SNDRV_PCM_FORMAT_MU_LAW ((__force snd_pcm_format_t) 20) -#define SNDRV_PCM_FORMAT_A_LAW ((__force snd_pcm_format_t) 21) -#define SNDRV_PCM_FORMAT_IMA_ADPCM ((__force snd_pcm_format_t) 22) -#define SNDRV_PCM_FORMAT_MPEG ((__force snd_pcm_format_t) 23) -#define SNDRV_PCM_FORMAT_GSM ((__force snd_pcm_format_t) 24) -#define SNDRV_PCM_FORMAT_SPECIAL ((__force snd_pcm_format_t) 31) -#define SNDRV_PCM_FORMAT_S24_3LE ((__force snd_pcm_format_t) 32) -#define SNDRV_PCM_FORMAT_S24_3BE ((__force snd_pcm_format_t) 33) -#define SNDRV_PCM_FORMAT_U24_3LE ((__force snd_pcm_format_t) 34) -#define SNDRV_PCM_FORMAT_U24_3BE ((__force snd_pcm_format_t) 35) -#define SNDRV_PCM_FORMAT_S20_3LE ((__force snd_pcm_format_t) 36) -#define SNDRV_PCM_FORMAT_S20_3BE ((__force snd_pcm_format_t) 37) -#define SNDRV_PCM_FORMAT_U20_3LE ((__force snd_pcm_format_t) 38) -#define SNDRV_PCM_FORMAT_U20_3BE ((__force snd_pcm_format_t) 39) -#define SNDRV_PCM_FORMAT_S18_3LE ((__force snd_pcm_format_t) 40) -#define SNDRV_PCM_FORMAT_S18_3BE ((__force snd_pcm_format_t) 41) -#define SNDRV_PCM_FORMAT_U18_3LE ((__force snd_pcm_format_t) 42) -#define SNDRV_PCM_FORMAT_U18_3BE ((__force snd_pcm_format_t) 43) -#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_U18_3BE - -#ifdef SNDRV_LITTLE_ENDIAN -#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE -#define SNDRV_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16_LE -#define SNDRV_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24_LE -#define SNDRV_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24_LE -#define SNDRV_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32_LE -#define SNDRV_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32_LE -#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_LE -#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_LE -#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE -#endif -#ifdef SNDRV_BIG_ENDIAN -#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_BE -#define SNDRV_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16_BE -#define SNDRV_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24_BE -#define SNDRV_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24_BE -#define SNDRV_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32_BE -#define SNDRV_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32_BE -#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_BE -#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_BE -#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE -#endif - -typedef int __bitwise snd_pcm_subformat_t; -#define SNDRV_PCM_SUBFORMAT_STD ((__force snd_pcm_subformat_t) 0) -#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_STD - -#define SNDRV_PCM_INFO_MMAP 0x00000001 -#define SNDRV_PCM_INFO_MMAP_VALID 0x00000002 -#define SNDRV_PCM_INFO_DOUBLE 0x00000004 -#define SNDRV_PCM_INFO_BATCH 0x00000010 -#define SNDRV_PCM_INFO_INTERLEAVED 0x00000100 -#define SNDRV_PCM_INFO_NONINTERLEAVED 0x00000200 -#define SNDRV_PCM_INFO_COMPLEX 0x00000400 -#define SNDRV_PCM_INFO_BLOCK_TRANSFER 0x00010000 -#define SNDRV_PCM_INFO_OVERRANGE 0x00020000 -#define SNDRV_PCM_INFO_RESUME 0x00040000 -#define SNDRV_PCM_INFO_PAUSE 0x00080000 -#define SNDRV_PCM_INFO_HALF_DUPLEX 0x00100000 -#define SNDRV_PCM_INFO_JOINT_DUPLEX 0x00200000 -#define SNDRV_PCM_INFO_SYNC_START 0x00400000 -#define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 - -typedef int __bitwise snd_pcm_state_t; -#define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) -#define SNDRV_PCM_STATE_SETUP ((__force snd_pcm_state_t) 1) -#define SNDRV_PCM_STATE_PREPARED ((__force snd_pcm_state_t) 2) -#define SNDRV_PCM_STATE_RUNNING ((__force snd_pcm_state_t) 3) -#define SNDRV_PCM_STATE_XRUN ((__force snd_pcm_state_t) 4) -#define SNDRV_PCM_STATE_DRAINING ((__force snd_pcm_state_t) 5) -#define SNDRV_PCM_STATE_PAUSED ((__force snd_pcm_state_t) 6) -#define SNDRV_PCM_STATE_SUSPENDED ((__force snd_pcm_state_t) 7) -#define SNDRV_PCM_STATE_DISCONNECTED ((__force snd_pcm_state_t) 8) -#define SNDRV_PCM_STATE_LAST SNDRV_PCM_STATE_DISCONNECTED - -enum { - SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000, - SNDRV_PCM_MMAP_OFFSET_STATUS = 0x80000000, - SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000, -}; - -union snd_pcm_sync_id { - unsigned char id[16]; - unsigned short id16[8]; - unsigned int id32[4]; -}; - -struct snd_pcm_info { - unsigned int device; - unsigned int subdevice; - int stream; - int card; - unsigned char id[64]; - unsigned char name[80]; - unsigned char subname[32]; - int dev_class; - int dev_subclass; - unsigned int subdevices_count; - unsigned int subdevices_avail; - union snd_pcm_sync_id sync; - unsigned char reserved[64]; -}; - -typedef int snd_pcm_hw_param_t; -#define SNDRV_PCM_HW_PARAM_ACCESS 0 -#define SNDRV_PCM_HW_PARAM_FORMAT 1 -#define SNDRV_PCM_HW_PARAM_SUBFORMAT 2 -#define SNDRV_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_ACCESS -#define SNDRV_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_SUBFORMAT - -#define SNDRV_PCM_HW_PARAM_SAMPLE_BITS 8 -#define SNDRV_PCM_HW_PARAM_FRAME_BITS 9 -#define SNDRV_PCM_HW_PARAM_CHANNELS 10 -#define SNDRV_PCM_HW_PARAM_RATE 11 -#define SNDRV_PCM_HW_PARAM_PERIOD_TIME 12 -#define SNDRV_PCM_HW_PARAM_PERIOD_SIZE 13 -#define SNDRV_PCM_HW_PARAM_PERIOD_BYTES 14 -#define SNDRV_PCM_HW_PARAM_PERIODS 15 -#define SNDRV_PCM_HW_PARAM_BUFFER_TIME 16 -#define SNDRV_PCM_HW_PARAM_BUFFER_SIZE 17 -#define SNDRV_PCM_HW_PARAM_BUFFER_BYTES 18 -#define SNDRV_PCM_HW_PARAM_TICK_TIME 19 -#define SNDRV_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_SAMPLE_BITS -#define SNDRV_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_TICK_TIME - -#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) - -struct snd_interval { - unsigned int min, max; - unsigned int openmin:1, - openmax:1, - integer:1, - empty:1; -}; - -#define SNDRV_MASK_MAX 256 - -struct snd_mask { - __u32 bits[(SNDRV_MASK_MAX+31)/32]; -}; - -struct snd_pcm_hw_params { - unsigned int flags; - struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - - SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; - struct snd_mask mres[5]; - struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1]; - struct snd_interval ires[9]; - unsigned int rmask; - unsigned int cmask; - unsigned int info; - unsigned int msbits; - unsigned int rate_num; - unsigned int rate_den; - snd_pcm_uframes_t fifo_size; - unsigned char reserved[64]; -}; - -enum { - SNDRV_PCM_TSTAMP_NONE = 0, - SNDRV_PCM_TSTAMP_ENABLE, - SNDRV_PCM_TSTAMP_LAST = SNDRV_PCM_TSTAMP_ENABLE, -}; - -struct snd_pcm_sw_params { - int tstamp_mode; - unsigned int period_step; - unsigned int sleep_min; - snd_pcm_uframes_t avail_min; - snd_pcm_uframes_t xfer_align; - snd_pcm_uframes_t start_threshold; - snd_pcm_uframes_t stop_threshold; - snd_pcm_uframes_t silence_threshold; - snd_pcm_uframes_t silence_size; - snd_pcm_uframes_t boundary; - unsigned char reserved[64]; -}; - -struct snd_pcm_channel_info { - unsigned int channel; - __kernel_off_t offset; - unsigned int first; - unsigned int step; -}; - -struct snd_pcm_status { - snd_pcm_state_t state; - struct timespec trigger_tstamp; - struct timespec tstamp; - snd_pcm_uframes_t appl_ptr; - snd_pcm_uframes_t hw_ptr; - snd_pcm_sframes_t delay; - snd_pcm_uframes_t avail; - snd_pcm_uframes_t avail_max; - snd_pcm_uframes_t overrange; - snd_pcm_state_t suspended_state; - unsigned char reserved[60]; -}; - -struct snd_pcm_mmap_status { - snd_pcm_state_t state; - int pad1; - snd_pcm_uframes_t hw_ptr; - struct timespec tstamp; - snd_pcm_state_t suspended_state; -}; - -struct snd_pcm_mmap_control { - snd_pcm_uframes_t appl_ptr; - snd_pcm_uframes_t avail_min; -}; - -#define SNDRV_PCM_SYNC_PTR_HWSYNC (1<<0) -#define SNDRV_PCM_SYNC_PTR_APPL (1<<1) -#define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1<<2) - -struct snd_pcm_sync_ptr { - unsigned int flags; - union { - struct snd_pcm_mmap_status status; - unsigned char reserved[64]; - } s; - union { - struct snd_pcm_mmap_control control; - unsigned char reserved[64]; - } c; -}; - -struct snd_xferi { - snd_pcm_sframes_t result; - void __user *buf; - snd_pcm_uframes_t frames; -}; - -struct snd_xfern { - snd_pcm_sframes_t result; - void __user * __user *bufs; - snd_pcm_uframes_t frames; -}; - -enum { - SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0, - SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, - SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, -}; - -#define SNDRV_PCM_IOCTL_PVERSION _IOR('A', 0x00, int) -#define SNDRV_PCM_IOCTL_INFO _IOR('A', 0x01, struct snd_pcm_info) -#define SNDRV_PCM_IOCTL_TSTAMP _IOW('A', 0x02, int) -#define SNDRV_PCM_IOCTL_TTSTAMP _IOW('A', 0x03, int) -#define SNDRV_PCM_IOCTL_HW_REFINE _IOWR('A', 0x10, struct snd_pcm_hw_params) -#define SNDRV_PCM_IOCTL_HW_PARAMS _IOWR('A', 0x11, struct snd_pcm_hw_params) -#define SNDRV_PCM_IOCTL_HW_FREE _IO('A', 0x12) -#define SNDRV_PCM_IOCTL_SW_PARAMS _IOWR('A', 0x13, struct snd_pcm_sw_params) -#define SNDRV_PCM_IOCTL_STATUS _IOR('A', 0x20, struct snd_pcm_status) -#define SNDRV_PCM_IOCTL_DELAY _IOR('A', 0x21, snd_pcm_sframes_t) -#define SNDRV_PCM_IOCTL_HWSYNC _IO('A', 0x22) -#define SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct snd_pcm_sync_ptr) -#define SNDRV_PCM_IOCTL_CHANNEL_INFO _IOR('A', 0x32, struct snd_pcm_channel_info) -#define SNDRV_PCM_IOCTL_PREPARE _IO('A', 0x40) -#define SNDRV_PCM_IOCTL_RESET _IO('A', 0x41) -#define SNDRV_PCM_IOCTL_START _IO('A', 0x42) -#define SNDRV_PCM_IOCTL_DROP _IO('A', 0x43) -#define SNDRV_PCM_IOCTL_DRAIN _IO('A', 0x44) -#define SNDRV_PCM_IOCTL_PAUSE _IOW('A', 0x45, int) -#define SNDRV_PCM_IOCTL_REWIND _IOW('A', 0x46, snd_pcm_uframes_t) -#define SNDRV_PCM_IOCTL_RESUME _IO('A', 0x47) -#define SNDRV_PCM_IOCTL_XRUN _IO('A', 0x48) -#define SNDRV_PCM_IOCTL_FORWARD _IOW('A', 0x49, snd_pcm_uframes_t) -#define SNDRV_PCM_IOCTL_WRITEI_FRAMES _IOW('A', 0x50, struct snd_xferi) -#define SNDRV_PCM_IOCTL_READI_FRAMES _IOR('A', 0x51, struct snd_xferi) -#define SNDRV_PCM_IOCTL_WRITEN_FRAMES _IOW('A', 0x52, struct snd_xfern) -#define SNDRV_PCM_IOCTL_READN_FRAMES _IOR('A', 0x53, struct snd_xfern) -#define SNDRV_PCM_IOCTL_LINK _IOW('A', 0x60, int) -#define SNDRV_PCM_IOCTL_UNLINK _IO('A', 0x61) - -#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 0) - -enum { - SNDRV_RAWMIDI_STREAM_OUTPUT = 0, - SNDRV_RAWMIDI_STREAM_INPUT, - SNDRV_RAWMIDI_STREAM_LAST = SNDRV_RAWMIDI_STREAM_INPUT, -}; - -#define SNDRV_RAWMIDI_INFO_OUTPUT 0x00000001 -#define SNDRV_RAWMIDI_INFO_INPUT 0x00000002 -#define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004 - -struct snd_rawmidi_info { - unsigned int device; - unsigned int subdevice; - int stream; - int card; - unsigned int flags; - unsigned char id[64]; - unsigned char name[80]; - unsigned char subname[32]; - unsigned int subdevices_count; - unsigned int subdevices_avail; - unsigned char reserved[64]; -}; - -struct snd_rawmidi_params { - int stream; - size_t buffer_size; - size_t avail_min; - unsigned int no_active_sensing: 1; - unsigned char reserved[16]; -}; - -struct snd_rawmidi_status { - int stream; - struct timespec tstamp; - size_t avail; - size_t xruns; - unsigned char reserved[16]; -}; - -#define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int) -#define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info) -#define SNDRV_RAWMIDI_IOCTL_PARAMS _IOWR('W', 0x10, struct snd_rawmidi_params) -#define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status) -#define SNDRV_RAWMIDI_IOCTL_DROP _IOW('W', 0x30, int) -#define SNDRV_RAWMIDI_IOCTL_DRAIN _IOW('W', 0x31, int) - -#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6) - -enum { - SNDRV_TIMER_CLASS_NONE = -1, - SNDRV_TIMER_CLASS_SLAVE = 0, - SNDRV_TIMER_CLASS_GLOBAL, - SNDRV_TIMER_CLASS_CARD, - SNDRV_TIMER_CLASS_PCM, - SNDRV_TIMER_CLASS_LAST = SNDRV_TIMER_CLASS_PCM, -}; - -enum { - SNDRV_TIMER_SCLASS_NONE = 0, - SNDRV_TIMER_SCLASS_APPLICATION, - SNDRV_TIMER_SCLASS_SEQUENCER, - SNDRV_TIMER_SCLASS_OSS_SEQUENCER, - SNDRV_TIMER_SCLASS_LAST = SNDRV_TIMER_SCLASS_OSS_SEQUENCER, -}; - -#define SNDRV_TIMER_GLOBAL_SYSTEM 0 -#define SNDRV_TIMER_GLOBAL_RTC 1 -#define SNDRV_TIMER_GLOBAL_HPET 2 -#define SNDRV_TIMER_GLOBAL_HRTIMER 3 - -#define SNDRV_TIMER_FLG_SLAVE (1<<0) - -struct snd_timer_id { - int dev_class; - int dev_sclass; - int card; - int device; - int subdevice; -}; - -struct snd_timer_ginfo { - struct snd_timer_id tid; - unsigned int flags; - int card; - unsigned char id[64]; - unsigned char name[80]; - unsigned long reserved0; - unsigned long resolution; - unsigned long resolution_min; - unsigned long resolution_max; - unsigned int clients; - unsigned char reserved[32]; -}; - -struct snd_timer_gparams { - struct snd_timer_id tid; - unsigned long period_num; - unsigned long period_den; - unsigned char reserved[32]; -}; - -struct snd_timer_gstatus { - struct snd_timer_id tid; - unsigned long resolution; - unsigned long resolution_num; - unsigned long resolution_den; - unsigned char reserved[32]; -}; - -struct snd_timer_select { - struct snd_timer_id id; - unsigned char reserved[32]; -}; - -struct snd_timer_info { - unsigned int flags; - int card; - unsigned char id[64]; - unsigned char name[80]; - unsigned long reserved0; - unsigned long resolution; - unsigned char reserved[64]; -}; - -#define SNDRV_TIMER_PSFLG_AUTO (1<<0) -#define SNDRV_TIMER_PSFLG_EXCLUSIVE (1<<1) -#define SNDRV_TIMER_PSFLG_EARLY_EVENT (1<<2) - -struct snd_timer_params { - unsigned int flags; - unsigned int ticks; - unsigned int queue_size; - unsigned int reserved0; - unsigned int filter; - unsigned char reserved[60]; -}; - -struct snd_timer_status { - struct timespec tstamp; - unsigned int resolution; - unsigned int lost; - unsigned int overrun; - unsigned int queue; - unsigned char reserved[64]; -}; - -#define SNDRV_TIMER_IOCTL_PVERSION _IOR('T', 0x00, int) -#define SNDRV_TIMER_IOCTL_NEXT_DEVICE _IOWR('T', 0x01, struct snd_timer_id) -#define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x02, int) -#define SNDRV_TIMER_IOCTL_GINFO _IOWR('T', 0x03, struct snd_timer_ginfo) -#define SNDRV_TIMER_IOCTL_GPARAMS _IOW('T', 0x04, struct snd_timer_gparams) -#define SNDRV_TIMER_IOCTL_GSTATUS _IOWR('T', 0x05, struct snd_timer_gstatus) -#define SNDRV_TIMER_IOCTL_SELECT _IOW('T', 0x10, struct snd_timer_select) -#define SNDRV_TIMER_IOCTL_INFO _IOR('T', 0x11, struct snd_timer_info) -#define SNDRV_TIMER_IOCTL_PARAMS _IOW('T', 0x12, struct snd_timer_params) -#define SNDRV_TIMER_IOCTL_STATUS _IOR('T', 0x14, struct snd_timer_status) - -#define SNDRV_TIMER_IOCTL_START _IO('T', 0xa0) -#define SNDRV_TIMER_IOCTL_STOP _IO('T', 0xa1) -#define SNDRV_TIMER_IOCTL_CONTINUE _IO('T', 0xa2) -#define SNDRV_TIMER_IOCTL_PAUSE _IO('T', 0xa3) - -struct snd_timer_read { - unsigned int resolution; - unsigned int ticks; -}; - -enum { - SNDRV_TIMER_EVENT_RESOLUTION = 0, - SNDRV_TIMER_EVENT_TICK, - SNDRV_TIMER_EVENT_START, - SNDRV_TIMER_EVENT_STOP, - SNDRV_TIMER_EVENT_CONTINUE, - SNDRV_TIMER_EVENT_PAUSE, - SNDRV_TIMER_EVENT_EARLY, - SNDRV_TIMER_EVENT_SUSPEND, - SNDRV_TIMER_EVENT_RESUME, - - SNDRV_TIMER_EVENT_MSTART = SNDRV_TIMER_EVENT_START + 10, - SNDRV_TIMER_EVENT_MSTOP = SNDRV_TIMER_EVENT_STOP + 10, - SNDRV_TIMER_EVENT_MCONTINUE = SNDRV_TIMER_EVENT_CONTINUE + 10, - SNDRV_TIMER_EVENT_MPAUSE = SNDRV_TIMER_EVENT_PAUSE + 10, - SNDRV_TIMER_EVENT_MSUSPEND = SNDRV_TIMER_EVENT_SUSPEND + 10, - SNDRV_TIMER_EVENT_MRESUME = SNDRV_TIMER_EVENT_RESUME + 10, -}; - -struct snd_timer_tread { - int event; - struct timespec tstamp; - unsigned int val; -}; - -#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6) - -struct snd_ctl_card_info { - int card; - int pad; - unsigned char id[16]; - unsigned char driver[16]; - unsigned char name[32]; - unsigned char longname[80]; - unsigned char reserved_[16]; - unsigned char mixername[80]; - unsigned char components[128]; -}; - -typedef int __bitwise snd_ctl_elem_type_t; -#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0) -#define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1) -#define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2) -#define SNDRV_CTL_ELEM_TYPE_ENUMERATED ((__force snd_ctl_elem_type_t) 3) -#define SNDRV_CTL_ELEM_TYPE_BYTES ((__force snd_ctl_elem_type_t) 4) -#define SNDRV_CTL_ELEM_TYPE_IEC958 ((__force snd_ctl_elem_type_t) 5) -#define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force snd_ctl_elem_type_t) 6) -#define SNDRV_CTL_ELEM_TYPE_LAST SNDRV_CTL_ELEM_TYPE_INTEGER64 - -typedef int __bitwise snd_ctl_elem_iface_t; -#define SNDRV_CTL_ELEM_IFACE_CARD ((__force snd_ctl_elem_iface_t) 0) -#define SNDRV_CTL_ELEM_IFACE_HWDEP ((__force snd_ctl_elem_iface_t) 1) -#define SNDRV_CTL_ELEM_IFACE_MIXER ((__force snd_ctl_elem_iface_t) 2) -#define SNDRV_CTL_ELEM_IFACE_PCM ((__force snd_ctl_elem_iface_t) 3) -#define SNDRV_CTL_ELEM_IFACE_RAWMIDI ((__force snd_ctl_elem_iface_t) 4) -#define SNDRV_CTL_ELEM_IFACE_TIMER ((__force snd_ctl_elem_iface_t) 5) -#define SNDRV_CTL_ELEM_IFACE_SEQUENCER ((__force snd_ctl_elem_iface_t) 6) -#define SNDRV_CTL_ELEM_IFACE_LAST SNDRV_CTL_ELEM_IFACE_SEQUENCER - -#define SNDRV_CTL_ELEM_ACCESS_READ (1<<0) -#define SNDRV_CTL_ELEM_ACCESS_WRITE (1<<1) -#define SNDRV_CTL_ELEM_ACCESS_READWRITE (SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE) -#define SNDRV_CTL_ELEM_ACCESS_VOLATILE (1<<2) -#define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP (1<<3) -#define SNDRV_CTL_ELEM_ACCESS_TLV_READ (1<<4) -#define SNDRV_CTL_ELEM_ACCESS_TLV_WRITE (1<<5) -#define SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE (SNDRV_CTL_ELEM_ACCESS_TLV_READ|SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) -#define SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND (1<<6) -#define SNDRV_CTL_ELEM_ACCESS_INACTIVE (1<<8) -#define SNDRV_CTL_ELEM_ACCESS_LOCK (1<<9) -#define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10) -#define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28) -#define SNDRV_CTL_ELEM_ACCESS_USER (1<<29) - -#define SNDRV_CTL_POWER_D0 0x0000 -#define SNDRV_CTL_POWER_D1 0x0100 -#define SNDRV_CTL_POWER_D2 0x0200 -#define SNDRV_CTL_POWER_D3 0x0300 -#define SNDRV_CTL_POWER_D3hot (SNDRV_CTL_POWER_D3|0x0000) -#define SNDRV_CTL_POWER_D3cold (SNDRV_CTL_POWER_D3|0x0001) - -struct snd_ctl_elem_id { - unsigned int numid; - snd_ctl_elem_iface_t iface; - unsigned int device; - unsigned int subdevice; - unsigned char name[44]; - unsigned int index; -}; - -struct snd_ctl_elem_list { - unsigned int offset; - unsigned int space; - unsigned int used; - unsigned int count; - struct snd_ctl_elem_id __user *pids; - unsigned char reserved[50]; -}; - -struct snd_ctl_elem_info { - struct snd_ctl_elem_id id; - snd_ctl_elem_type_t type; - unsigned int access; - unsigned int count; - __kernel_pid_t owner; - union { - struct { - long min; - long max; - long step; - } integer; - struct { - long long min; - long long max; - long long step; - } integer64; - struct { - unsigned int items; - unsigned int item; - char name[64]; - } enumerated; - unsigned char reserved[128]; - } value; - union { - unsigned short d[4]; - unsigned short *d_ptr; - } dimen; - unsigned char reserved[64-4*sizeof(unsigned short)]; -}; - -struct snd_ctl_elem_value { - struct snd_ctl_elem_id id; - unsigned int indirect: 1; - union { - union { - long value[128]; - long *value_ptr; - } integer; - union { - long long value[64]; - long long *value_ptr; - } integer64; - union { - unsigned int item[128]; - unsigned int *item_ptr; - } enumerated; - union { - unsigned char data[512]; - unsigned char *data_ptr; - } bytes; - struct snd_aes_iec958 iec958; - } value; - struct timespec tstamp; - unsigned char reserved[128-sizeof(struct timespec)]; -}; - -struct snd_ctl_tlv { - unsigned int numid; - unsigned int length; - unsigned int tlv[0]; -}; - -#define SNDRV_CTL_IOCTL_PVERSION _IOR('U', 0x00, int) -#define SNDRV_CTL_IOCTL_CARD_INFO _IOR('U', 0x01, struct snd_ctl_card_info) -#define SNDRV_CTL_IOCTL_ELEM_LIST _IOWR('U', 0x10, struct snd_ctl_elem_list) -#define SNDRV_CTL_IOCTL_ELEM_INFO _IOWR('U', 0x11, struct snd_ctl_elem_info) -#define SNDRV_CTL_IOCTL_ELEM_READ _IOWR('U', 0x12, struct snd_ctl_elem_value) -#define SNDRV_CTL_IOCTL_ELEM_WRITE _IOWR('U', 0x13, struct snd_ctl_elem_value) -#define SNDRV_CTL_IOCTL_ELEM_LOCK _IOW('U', 0x14, struct snd_ctl_elem_id) -#define SNDRV_CTL_IOCTL_ELEM_UNLOCK _IOW('U', 0x15, struct snd_ctl_elem_id) -#define SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS _IOWR('U', 0x16, int) -#define SNDRV_CTL_IOCTL_ELEM_ADD _IOWR('U', 0x17, struct snd_ctl_elem_info) -#define SNDRV_CTL_IOCTL_ELEM_REPLACE _IOWR('U', 0x18, struct snd_ctl_elem_info) -#define SNDRV_CTL_IOCTL_ELEM_REMOVE _IOWR('U', 0x19, struct snd_ctl_elem_id) -#define SNDRV_CTL_IOCTL_TLV_READ _IOWR('U', 0x1a, struct snd_ctl_tlv) -#define SNDRV_CTL_IOCTL_TLV_WRITE _IOWR('U', 0x1b, struct snd_ctl_tlv) -#define SNDRV_CTL_IOCTL_TLV_COMMAND _IOWR('U', 0x1c, struct snd_ctl_tlv) -#define SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE _IOWR('U', 0x20, int) -#define SNDRV_CTL_IOCTL_HWDEP_INFO _IOR('U', 0x21, struct snd_hwdep_info) -#define SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE _IOR('U', 0x30, int) -#define SNDRV_CTL_IOCTL_PCM_INFO _IOWR('U', 0x31, struct snd_pcm_info) -#define SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE _IOW('U', 0x32, int) -#define SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE _IOWR('U', 0x40, int) -#define SNDRV_CTL_IOCTL_RAWMIDI_INFO _IOWR('U', 0x41, struct snd_rawmidi_info) -#define SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE _IOW('U', 0x42, int) -#define SNDRV_CTL_IOCTL_POWER _IOWR('U', 0xd0, int) -#define SNDRV_CTL_IOCTL_POWER_STATE _IOR('U', 0xd1, int) - -enum sndrv_ctl_event_type { - SNDRV_CTL_EVENT_ELEM = 0, - SNDRV_CTL_EVENT_LAST = SNDRV_CTL_EVENT_ELEM, -}; - -#define SNDRV_CTL_EVENT_MASK_VALUE (1<<0) -#define SNDRV_CTL_EVENT_MASK_INFO (1<<1) -#define SNDRV_CTL_EVENT_MASK_ADD (1<<2) -#define SNDRV_CTL_EVENT_MASK_TLV (1<<3) -#define SNDRV_CTL_EVENT_MASK_REMOVE (~0U) - -struct snd_ctl_event { - int type; - union { - struct { - unsigned int mask; - struct snd_ctl_elem_id id; - } elem; - unsigned char data8[60]; - } data; -}; - -#define SNDRV_CTL_NAME_NONE "" -#define SNDRV_CTL_NAME_PLAYBACK "Playback " -#define SNDRV_CTL_NAME_CAPTURE "Capture " - -#define SNDRV_CTL_NAME_IEC958_NONE "" -#define SNDRV_CTL_NAME_IEC958_SWITCH "Switch" -#define SNDRV_CTL_NAME_IEC958_VOLUME "Volume" -#define SNDRV_CTL_NAME_IEC958_DEFAULT "Default" -#define SNDRV_CTL_NAME_IEC958_MASK "Mask" -#define SNDRV_CTL_NAME_IEC958_CON_MASK "Con Mask" -#define SNDRV_CTL_NAME_IEC958_PRO_MASK "Pro Mask" -#define SNDRV_CTL_NAME_IEC958_PCM_STREAM "PCM Stream" -#define SNDRV_CTL_NAME_IEC958(expl,direction,what) "IEC958 " expl SNDRV_CTL_NAME_##direction SNDRV_CTL_NAME_IEC958_##what - -#endif - diff --git a/aries/libaudio/secril-client.h b/aries/libaudio/secril-client.h deleted file mode 100644 index 7bbaa03..0000000 --- a/aries/libaudio/secril-client.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * 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 __SECRIL_CLIENT_H__ -#define __SECRIL_CLIENT_H__ - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - -struct RilClient { - void *prv; -}; - -typedef struct RilClient * HRilClient; - - -//--------------------------------------------------------------------------- -// Defines -//--------------------------------------------------------------------------- -#define RIL_CLIENT_ERR_SUCCESS 0 -#define RIL_CLIENT_ERR_AGAIN 1 -#define RIL_CLIENT_ERR_INIT 2 // Client is not initialized -#define RIL_CLIENT_ERR_INVAL 3 // Invalid value -#define RIL_CLIENT_ERR_CONNECT 4 // Connection error -#define RIL_CLIENT_ERR_IO 5 // IO error -#define RIL_CLIENT_ERR_RESOURCE 6 // Resource not available -#define RIL_CLIENT_ERR_UNKNOWN 7 - - -//--------------------------------------------------------------------------- -// Type definitions -//--------------------------------------------------------------------------- - -typedef int (*RilOnComplete)(HRilClient handle, const void *data, size_t datalen); - -typedef int (*RilOnUnsolicited)(HRilClient handle, const void *data, size_t datalen); - -typedef int (*RilOnError)(void *data, int error); - - -//--------------------------------------------------------------------------- -// Client APIs -//--------------------------------------------------------------------------- - -/** - * Open RILD multi-client. - * Return is client handle, NULL on error. - */ -HRilClient OpenClient_RILD(void); - -/** - * Stop RILD multi-client. If client socket was connected, - * it will be disconnected. - */ -int CloseClient_RILD(HRilClient client); - -/** - * Connect to RIL deamon. One client task starts. - * Return is 0 or error code. - */ -int Connect_RILD(HRilClient client); - -/** - * check whether RILD is connected - * Returns 0 or 1 - */ -int isConnected_RILD(HRilClient client); - -/** - * Disconnect connection to RIL deamon(socket close). - * Return is 0 or error code. - */ -int Disconnect_RILD(HRilClient client); - -/** - * Register unsolicited response handler. If handler is NULL, - * the handler for the request ID is unregistered. - * The response handler is invoked in the client task context. - * Return is 0 or error code. - */ -int RegisterUnsolicitedHandler(HRilClient client, uint32_t id, RilOnUnsolicited handler); - -/** - * Register solicited response handler. If handler is NULL, - * the handler for the ID is unregistered. - * The response handler is invoked in the client task context. - * Return is 0 or error code. - */ -int RegisterRequestCompleteHandler(HRilClient client, uint32_t id, RilOnComplete handler); - -/** - * Register error callback. If handler is NULL, - * the callback is unregistered. - * The response handler is invoked in the client task context. - * Return is 0 or error code. - */ -int RegisterErrorCallback(HRilClient client, RilOnError cb, void *data); - -/** - * Invoke OEM request. Request ID is RIL_REQUEST_OEM_HOOK_RAW. - * Return is 0 or error code. For RIL_CLIENT_ERR_AGAIN caller should retry. - */ -int InvokeOemRequestHookRaw(HRilClient client, char *data, size_t len); - -/** - * Sound device types. - */ -typedef enum _SoundType { - SOUND_TYPE_VOICE, - SOUND_TYPE_SPEAKER, - SOUND_TYPE_HEADSET, - SOUND_TYPE_BTVOICE -} SoundType; - -/** - * External sound device path. - */ -typedef enum _AudioPath { - SOUND_AUDIO_PATH_HANDSET, - SOUND_AUDIO_PATH_HEADSET, - SOUND_AUDIO_PATH_SPEAKER, - SOUND_AUDIO_PATH_BLUETOOTH, - SOUND_AUDIO_PATH_BLUETOOTH_NO_NR, - SOUND_AUDIO_PATH_HEADPHONE -} AudioPath; - -/** - * Clock adjustment parameters. - */ -typedef enum _SoundClockCondition { - SOUND_CLOCK_STOP, - SOUND_CLOCK_START -} SoundClockCondition; - -/** - * Set in-call volume. - */ -int SetCallVolume(HRilClient client, SoundType type, int vol_level); - -/** - * Set external sound device path for noise reduction. - */ -int SetCallAudioPath(HRilClient client, AudioPath path); - -/** - * Set modem clock to master or slave. - */ -int SetCallClockSync(HRilClient client, SoundClockCondition condition); - -#ifdef __cplusplus -}; -#endif - -#endif // __SECRIL_CLIENT_H__ - -// end of file - diff --git a/aries/libcamera/Android.mk b/aries/libcamera/Android.mk deleted file mode 100644 index f4b41bb..0000000 --- a/aries/libcamera/Android.mk +++ /dev/null @@ -1,51 +0,0 @@ -ifeq ($(Y_U_NO_HAVE_CAMERA),true) - -# When zero we link against libqcamera; when 1, we dlopen libqcamera. -ifeq ($(BOARD_CAMERA_LIBRARIES),libcamera) - -DLOPEN_LIBSECCAMERA:=1 - -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_CFLAGS:=-fno-short-enums -LOCAL_CFLAGS+=-DDLOPEN_LIBSECCAMERA=$(DLOPEN_LIBSECCAMERA) - -ifdef BOARD_CAMERA_DEVICE - LOCAL_CFLAGS += -DCAMERA_DEV_NAME=\"$(BOARD_CAMERA_DEVICE)\" -endif - -ifdef BOARD_SECOND_CAMERA_DEVICE - LOCAL_CFLAGS += -DCAMERA_DEV_NAME2=\"$(BOARD_SECOND_CAMERA_DEVICE)\" - LOCAL_CFLAGS += -DFFC_PRESENT -endif - -LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include -LOCAL_C_INCLUDES += $(LOCAL_PATH)/../libs3cjpeg - - -LOCAL_SRC_FILES:= \ - SecCamera.cpp \ - SecCameraHWInterface.cpp - - -LOCAL_SHARED_LIBRARIES:= libutils libui liblog libbinder libcutils -LOCAL_SHARED_LIBRARIES+= libs3cjpeg.aries -LOCAL_SHARED_LIBRARIES+= libcamera_client - -ifeq ($(BOARD_USES_OVERLAY),true) -LOCAL_CFLAGS += -DBOARD_USES_OVERLAY -endif - -ifeq ($(DLOPEN_LIBSECCAMERA),1) -LOCAL_SHARED_LIBRARIES+= libdl -endif - -LOCAL_MODULE:= libcamera - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_SHARED_LIBRARY) - -endif -endif diff --git a/aries/libcamera/NOTICE b/aries/libcamera/NOTICE deleted file mode 100644 index f921593..0000000 --- a/aries/libcamera/NOTICE +++ /dev/null @@ -1,190 +0,0 @@ - - Copyright (C) 2008 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - - 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. - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - diff --git a/aries/libcamera/SecCamera.cpp b/aries/libcamera/SecCamera.cpp deleted file mode 100644 index 4bd3fc7..0000000 --- a/aries/libcamera/SecCamera.cpp +++ /dev/null @@ -1,3142 +0,0 @@ -/* - * Copyright 2008, The Android Open Source Project - * Copyright 2010, Samsung Electronics Co. LTD - * - * 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. - */ - -/* -************************************ -* Filename: SecCamera.cpp -* Author: Sachin P. Kamat -* Purpose: This file interacts with the Camera and JPEG drivers. -************************************* -*/ - -//#define LOG_NDEBUG 0 -#define LOG_TAG "SecCamera" - -#include - -#include -#include -#include -#include "SecCamera.h" -#include "cutils/properties.h" - -using namespace android; - -#define CHECK(return_value) \ - if (return_value < 0) { \ - LOGE("%s::%d fail. errno: %s, m_camera_id = %d\n", \ - __func__, __LINE__, strerror(errno), m_camera_id); \ - return -1; \ - } - - -#define CHECK_PTR(return_value) \ - if (return_value < 0) { \ - LOGE("%s::%d fail, errno: %s, m_camera_id = %d\n", \ - __func__,__LINE__, strerror(errno), m_camera_id); \ - return NULL; \ - } - -#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5) -#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7) -#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13) - -namespace android { - -// ====================================================================== -// Camera controls - -static struct timeval time_start; -static struct timeval time_stop; - -unsigned long measure_time(struct timeval *start, struct timeval *stop) -{ - unsigned long sec, usec, time; - - sec = stop->tv_sec - start->tv_sec; - - if (stop->tv_usec >= start->tv_usec) { - usec = stop->tv_usec - start->tv_usec; - } else { - usec = stop->tv_usec + 1000000 - start->tv_usec; - sec--; - } - - time = (sec * 1000000) + usec; - - return time; -} - -static int get_pixel_depth(unsigned int fmt) -{ - int depth = 0; - - switch (fmt) { - case V4L2_PIX_FMT_NV12: - depth = 12; - break; - case V4L2_PIX_FMT_NV12T: - depth = 12; - break; - case V4L2_PIX_FMT_NV21: - depth = 12; - break; - case V4L2_PIX_FMT_YUV420: - depth = 12; - break; - - case V4L2_PIX_FMT_RGB565: - case V4L2_PIX_FMT_YUYV: - case V4L2_PIX_FMT_YVYU: - case V4L2_PIX_FMT_UYVY: - case V4L2_PIX_FMT_VYUY: - case V4L2_PIX_FMT_NV16: - case V4L2_PIX_FMT_NV61: - case V4L2_PIX_FMT_YUV422P: - depth = 16; - break; - - case V4L2_PIX_FMT_RGB32: - depth = 32; - break; - } - - return depth; -} - -#define ALIGN_W(x) (((x) + 0x7F) & (~0x7F)) // Set as multiple of 128 -#define ALIGN_H(x) (((x) + 0x1F) & (~0x1F)) // Set as multiple of 32 -#define ALIGN_BUF(x) (((x) + 0x1FFF)& (~0x1FFF)) // Set as multiple of 8K - -static int init_preview_buffers(struct fimc_buffer *buffers, int width, int height, unsigned int fmt) -{ - int i, len; - - if (fmt==V4L2_PIX_FMT_NV12T) { - len = ALIGN_BUF(ALIGN_W(width) * ALIGN_H(height)) + - ALIGN_BUF(ALIGN_W(width) * ALIGN_H(height / 2)); - } else { - len = (width * height * get_pixel_depth(fmt)) / 8; - } - - for (i = 0; i < MAX_BUFFERS; i++) { - buffers[i].length = len; - } - - return 0; -} - -static int fimc_poll(struct pollfd *events) -{ - int ret; - - /* 10 second delay is because sensor can take a long time - * to do auto focus and capture in dark settings - */ - ret = poll(events, 1, 10000); - if (ret < 0) { - LOGE("ERR(%s):poll error\n", __func__); - return ret; - } - - if (ret == 0) { - LOGE("ERR(%s):No data in 10 secs..\n", __func__); - return ret; - } - - return ret; -} - -int SecCamera::previewPoll(bool preview) -{ - int ret; - - if (preview) { -#ifdef ENABLE_ESD_PREVIEW_CHECK - int status = 0; - - if (!(++m_esd_check_count % 60)) { - status = getCameraSensorESDStatus(); - m_esd_check_count = 0; - if (status) { - LOGE("ERR(%s) ESD status(%d)", __func__, status); - return status; - } - } -#endif - - ret = poll(&m_events_c, 1, 1000); - } else { - ret = poll(&m_events_c2, 1, 1000); - } - - if (ret < 0) { - LOGE("ERR(%s):poll error\n", __func__); - return ret; - } - - if (ret == 0) { - LOGE("ERR(%s):No data in 1 secs.. Camera Device Reset \n", __func__); - return ret; - } - - return ret; -} - -static int fimc_v4l2_querycap(int fp) -{ - struct v4l2_capability cap; - int ret = 0; - - ret = ioctl(fp, VIDIOC_QUERYCAP, &cap); - - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_QUERYCAP failed\n", __func__); - return -1; - } - - if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { - LOGE("ERR(%s):no capture devices\n", __func__); - return -1; - } - - return ret; -} - -static const __u8* fimc_v4l2_enuminput(int fp, int index) -{ - static struct v4l2_input input; - - input.index = index; - if (ioctl(fp, VIDIOC_ENUMINPUT, &input) != 0) { - LOGE("ERR(%s):No matching index found\n", __func__); - return NULL; - } - LOGI("Name of input channel[%d] is %s\n", input.index, input.name); - - return input.name; -} - - -static int fimc_v4l2_s_input(int fp, int index) -{ - struct v4l2_input input; - int ret; - - input.index = index; - - ret = ioctl(fp, VIDIOC_S_INPUT, &input); - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_S_INPUT failed\n", __func__); - return ret; - } - - return ret; -} - -static int fimc_v4l2_s_fmt(int fp, int width, int height, unsigned int fmt, int flag_capture) -{ - struct v4l2_format v4l2_fmt; - struct v4l2_pix_format pixfmt; - int ret; - - v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - memset(&pixfmt, 0, sizeof(pixfmt)); - - pixfmt.width = width; - pixfmt.height = height; - pixfmt.pixelformat = fmt; - - pixfmt.sizeimage = (width * height * get_pixel_depth(fmt)) / 8; - - pixfmt.field = V4L2_FIELD_NONE; - - v4l2_fmt.fmt.pix = pixfmt; - - /* Set up for capture */ - ret = ioctl(fp, VIDIOC_S_FMT, &v4l2_fmt); - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_S_FMT failed\n", __func__); - return -1; - } - - return 0; -} - -static int fimc_v4l2_s_fmt_cap(int fp, int width, int height, unsigned int fmt) -{ - struct v4l2_format v4l2_fmt; - struct v4l2_pix_format pixfmt; - int ret; - - memset(&pixfmt, 0, sizeof(pixfmt)); - - v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - pixfmt.width = width; - pixfmt.height = height; - pixfmt.pixelformat = fmt; - if (fmt == V4L2_PIX_FMT_JPEG) { - pixfmt.colorspace = V4L2_COLORSPACE_JPEG; - } - - pixfmt.sizeimage = (width * height * get_pixel_depth(fmt)) / 8; - - v4l2_fmt.fmt.pix = pixfmt; - - LOGV("ori_w %d, ori_h %d, w %d, h %d\n", width, height, v4l2_fmt.fmt.pix.width, v4l2_fmt.fmt.pix.height); - - /* Set up for capture */ - ret = ioctl(fp, VIDIOC_S_FMT, &v4l2_fmt); - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_S_FMT failed\n", __func__); - return ret; - } - - return ret; -} - -static int fimc_v4l2_enum_fmt(int fp, unsigned int fmt) -{ - struct v4l2_fmtdesc fmtdesc; - int found = 0; - - fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - fmtdesc.index = 0; - - while (ioctl(fp, VIDIOC_ENUM_FMT, &fmtdesc) == 0) { - if (fmtdesc.pixelformat == fmt) { - LOGV("passed fmt = %#x found pixel format[%d]: %s\n", fmt, fmtdesc.index, fmtdesc.description); - found = 1; - break; - } - - fmtdesc.index++; - } - - if (!found) { - LOGE("unsupported pixel format\n"); - return -1; - } - - return 0; -} - -static int fimc_v4l2_reqbufs(int fp, enum v4l2_buf_type type, int nr_bufs) -{ - struct v4l2_requestbuffers req; - int ret; - - req.count = nr_bufs; - req.type = type; - req.memory = V4L2_MEMORY_MMAP; - - ret = ioctl(fp, VIDIOC_REQBUFS, &req); - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_REQBUFS failed\n", __func__); - return -1; - } - - return req.count; -} - -static int fimc_v4l2_querybuf(int fp, struct fimc_buffer *buffer, enum v4l2_buf_type type) -{ - struct v4l2_buffer v4l2_buf; - int ret; - - LOGI("%s :", __func__); - - v4l2_buf.type = type; - v4l2_buf.memory = V4L2_MEMORY_MMAP; - v4l2_buf.index = 0; - - ret = ioctl(fp , VIDIOC_QUERYBUF, &v4l2_buf); - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_QUERYBUF failed\n", __func__); - return -1; - } - - buffer->length = v4l2_buf.length; - if ((buffer->start = (char *)mmap(0, v4l2_buf.length, - PROT_READ | PROT_WRITE, MAP_SHARED, - fp, v4l2_buf.m.offset)) < 0) { - LOGE("%s %d] mmap() failed\n",__func__, __LINE__); - return -1; - } - - LOGI("%s: buffer->start = %p v4l2_buf.length = %d", - __func__, buffer->start, v4l2_buf.length); - - return 0; -} - -static int fimc_v4l2_streamon(int fp) -{ - enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - int ret; - - ret = ioctl(fp, VIDIOC_STREAMON, &type); - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_STREAMON failed\n", __func__); - return ret; - } - - return ret; -} - -static int fimc_v4l2_streamoff(int fp) -{ - enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - int ret; - - LOGV("%s :", __func__); - ret = ioctl(fp, VIDIOC_STREAMOFF, &type); - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_STREAMOFF failed\n", __func__); - return ret; - } - - return ret; -} - -static int fimc_v4l2_qbuf(int fp, int index) -{ - struct v4l2_buffer v4l2_buf; - int ret; - - v4l2_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - v4l2_buf.memory = V4L2_MEMORY_MMAP; - v4l2_buf.index = index; - - ret = ioctl(fp, VIDIOC_QBUF, &v4l2_buf); - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_QBUF failed\n", __func__); - return ret; - } - - return 0; -} - -static int fimc_v4l2_dqbuf(int fp) -{ - struct v4l2_buffer v4l2_buf; - int ret; - - v4l2_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - v4l2_buf.memory = V4L2_MEMORY_MMAP; - - ret = ioctl(fp, VIDIOC_DQBUF, &v4l2_buf); - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_DQBUF failed, dropped frame\n", __func__); - return ret; - } - - return v4l2_buf.index; -} - -static int fimc_v4l2_g_ctrl(int fp, unsigned int id) -{ - struct v4l2_control ctrl; - int ret; - - ctrl.id = id; - - ret = ioctl(fp, VIDIOC_G_CTRL, &ctrl); - if (ret < 0) { - LOGE("ERR(%s): VIDIOC_G_CTRL(id = 0x%x (%d)) failed, ret = %d\n", - __func__, id, id-V4L2_CID_PRIVATE_BASE, ret); - return ret; - } - - return ctrl.value; -} - -static int fimc_v4l2_s_ctrl(int fp, unsigned int id, unsigned int value) -{ - struct v4l2_control ctrl; - int ret; - - ctrl.id = id; - ctrl.value = value; - - ret = ioctl(fp, VIDIOC_S_CTRL, &ctrl); - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_S_CTRL(id = %#x (%d), value = %d) failed ret = %d\n", - __func__, id, id-V4L2_CID_PRIVATE_BASE, value, ret); - - return ret; - } - - return ctrl.value; -} - -static int fimc_v4l2_s_ext_ctrl(int fp, unsigned int id, void *value) -{ - struct v4l2_ext_controls ctrls; - struct v4l2_ext_control ctrl; - int ret; - - ctrl.id = id; - ctrl.reserved = value; - - ctrls.ctrl_class = V4L2_CTRL_CLASS_CAMERA; - ctrls.count = 1; - ctrls.controls = &ctrl; - - ret = ioctl(fp, VIDIOC_S_EXT_CTRLS, &ctrls); - if (ret < 0) - LOGE("ERR(%s):VIDIOC_S_EXT_CTRLS failed\n", __func__); - - return ret; -} - -static int fimc_v4l2_g_parm(int fp, struct v4l2_streamparm *streamparm) -{ - int ret; - - streamparm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - ret = ioctl(fp, VIDIOC_G_PARM, streamparm); - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_G_PARM failed\n", __func__); - return -1; - } - - LOGV("%s : timeperframe: numerator %d, denominator %d\n", __func__, - streamparm->parm.capture.timeperframe.numerator, - streamparm->parm.capture.timeperframe.denominator); - - return 0; -} - -static int fimc_v4l2_s_parm(int fp, struct v4l2_streamparm *streamparm) -{ - int ret; - - streamparm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - - ret = ioctl(fp, VIDIOC_S_PARM, streamparm); - if (ret < 0) { - LOGE("ERR(%s):VIDIOC_S_PARM failed\n", __func__); - return ret; - } - - return 0; -} - -// ====================================================================== -// Constructor & Destructor - -SecCamera::SecCamera() : - m_flag_init(0), - m_camera_id(CAMERA_ID_BACK), - m_preview_v4lformat(V4L2_PIX_FMT_NV21), - m_preview_width (0), - m_preview_height (0), - m_preview_max_width (MAX_BACK_CAMERA_PREVIEW_WIDTH), - m_preview_max_height (MAX_BACK_CAMERA_PREVIEW_HEIGHT), - m_snapshot_v4lformat(-1), - m_snapshot_width (0), - m_snapshot_height (0), - m_snapshot_max_width (MAX_BACK_CAMERA_SNAPSHOT_WIDTH), - m_snapshot_max_height (MAX_BACK_CAMERA_SNAPSHOT_HEIGHT), - m_angle(-1), - m_anti_banding(-1), - m_wdr(-1), - m_anti_shake(-1), - m_zoom_level(-1), - m_object_tracking(-1), - m_smart_auto(-1), - m_beauty_shot(-1), - m_vintage_mode(-1), - m_face_detect(-1), - m_gps_latitude(-1), - m_gps_longitude(-1), - m_gps_altitude(-1), - m_gps_timestamp(-1), - m_vtmode(0), - m_sensor_mode(-1), - m_shot_mode(-1), - m_exif_orientation(-1), - m_blur_level(-1), - m_chk_dataline(-1), - m_video_gamma(-1), - m_slow_ae(-1), - m_camera_af_flag(-1), - m_flag_camera_start(0), - m_jpeg_thumbnail_width (0), - m_jpeg_thumbnail_height(0), - m_jpeg_quality(100) -#ifdef ENABLE_ESD_PREVIEW_CHECK - , - m_esd_check_count(0) -#endif // ENABLE_ESD_PREVIEW_CHECK -{ - m_params = (struct sec_cam_parm*)&m_streamparm.parm.raw_data; - struct v4l2_captureparm capture; - m_params->capture.timeperframe.numerator = 1; - m_params->capture.timeperframe.denominator = 0; - m_params->contrast = -1; - m_params->effects = -1; - m_params->brightness = -1; - m_params->flash_mode = -1; - m_params->focus_mode = -1; - m_params->iso = -1; - m_params->metering = -1; - m_params->saturation = -1; - m_params->scene_mode = -1; - m_params->sharpness = -1; - m_params->white_balance = -1; - - memset(&m_capture_buf, 0, sizeof(m_capture_buf)); - - LOGV("%s :", __func__); -} - -int SecCamera::flagCreate(void) const -{ - LOGV("%s : : %d", __func__, m_flag_init); - return m_flag_init; -} - -SecCamera::~SecCamera() -{ - LOGV("%s :", __func__); -} - -int SecCamera::initCamera(int index) -{ - LOGV("%s :", __func__); - int ret = 0; - - if (!m_flag_init) { - /* Arun C - * Reset the lense position only during camera starts; don't do - * reset between shot to shot - */ - m_camera_af_flag = -1; - - m_cam_fd_temp = -1; - m_cam_fd2_temp = -1; - - m_cam_fd = open(CAMERA_DEV_NAME, O_RDWR); - if (m_cam_fd < 0) { - LOGE("ERR(%s):Cannot open %s (error : %s)\n", __func__, CAMERA_DEV_NAME, strerror(errno)); - return -1; - } - - if (m_cam_fd < 3) { // for 0, 1, 2 - LOGE("ERR(%s):m_cam_fd is %d\n", __func__, m_cam_fd); - - close(m_cam_fd); - - m_cam_fd_temp = open(CAMERA_DEV_NAME_TEMP, O_CREAT); - - LOGE("ERR(%s):m_cam_fd_temp is %d\n", __func__, m_cam_fd_temp); - - m_cam_fd = open(CAMERA_DEV_NAME, O_RDWR); - - if (m_cam_fd < 3) { // for 0, 1, 2 - LOGE("ERR(%s):retring to open %s is failed, %d\n", __func__, CAMERA_DEV_NAME, m_cam_fd); - - if (m_cam_fd < 0) { - return -1; - } else { - close(m_cam_fd); - m_cam_fd = -1; - } - - if (m_cam_fd_temp != -1){ - close(m_cam_fd_temp); - m_cam_fd_temp = -1; - } - return -1; - } - } - - LOGE("initCamera: m_cam_fd(%d), m_jpeg_fd(%d)", m_cam_fd, m_jpeg_fd); - - ret = fimc_v4l2_querycap(m_cam_fd); - CHECK(ret); - if (!fimc_v4l2_enuminput(m_cam_fd, index)) - return -1; - ret = fimc_v4l2_s_input(m_cam_fd, index); - CHECK(ret); - - m_cam_fd2 = open(CAMERA_DEV_NAME2, O_RDWR); - if (m_cam_fd2 < 0) { - LOGE("ERR(%s):Cannot open %s (error : %s)\n", __func__, CAMERA_DEV_NAME2, strerror(errno)); - return -1; - } - if (m_cam_fd2 < 3) { // for 0, 1, 2 - LOGE("ERR(%s):m_cam_fd2 is %d\n", __func__, m_cam_fd2); - - close(m_cam_fd2); - - m_cam_fd2_temp = open(CAMERA_DEV_NAME2_TEMP, O_CREAT); - - LOGE("ERR(%s):m_cam_fd2_temp is %d\n", __func__, m_cam_fd2_temp); - - m_cam_fd2 = open(CAMERA_DEV_NAME2, O_RDWR); - - if (m_cam_fd2 < 3) { // for 0, 1, 2 - LOGE("ERR(%s):retring to open %s is failed, %d\n", __func__, CAMERA_DEV_NAME2, m_cam_fd2); - - if (m_cam_fd2 < 0) { - return -1; - } - else{ - close(m_cam_fd2); - m_cam_fd2 = -1; - } - - if (m_cam_fd2_temp != -1) { - close(m_cam_fd2_temp); - m_cam_fd2_temp = -1; - } - - return -1; - } - } - - if (m_cam_fd_temp != -1) { - close(m_cam_fd_temp); - m_cam_fd_temp = -1; - } - - if (m_cam_fd2_temp != -1) { - close(m_cam_fd2_temp); - m_cam_fd2_temp = -1; - } - - LOGE("initCamera: m_cam_fd2(%d)", m_cam_fd2); - - ret = fimc_v4l2_querycap(m_cam_fd2); - CHECK(ret); - if (!fimc_v4l2_enuminput(m_cam_fd2, index)) - return -1; - ret = fimc_v4l2_s_input(m_cam_fd2, index); - CHECK(ret); - - m_camera_id = index; - - switch (m_camera_id) { - case CAMERA_ID_FRONT: - m_preview_max_width = MAX_FRONT_CAMERA_PREVIEW_WIDTH; - m_preview_max_height = MAX_FRONT_CAMERA_PREVIEW_HEIGHT; - m_snapshot_max_width = MAX_FRONT_CAMERA_SNAPSHOT_WIDTH; - m_snapshot_max_height = MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT; - break; - - case CAMERA_ID_BACK: - m_preview_max_width = MAX_BACK_CAMERA_PREVIEW_WIDTH; - m_preview_max_height = MAX_BACK_CAMERA_PREVIEW_HEIGHT; - m_snapshot_max_width = MAX_BACK_CAMERA_SNAPSHOT_WIDTH; - m_snapshot_max_height = MAX_BACK_CAMERA_SNAPSHOT_HEIGHT; - break; - } - - setExifFixedAttribute(); - - m_flag_init = 1; - } - return 0; -} - -void SecCamera::resetCamera() -{ - LOGV("%s :", __func__); - DeinitCamera(); - initCamera(m_camera_id); -} - -void SecCamera::DeinitCamera() -{ - LOGV("%s :", __func__); - - if (m_flag_init) { - - stopRecord(); - - /* close m_cam_fd after stopRecord() because stopRecord() - * uses m_cam_fd to change frame rate - */ - LOGI("DeinitCamera: m_cam_fd(%d)", m_cam_fd); - if (m_cam_fd > -1) { - close(m_cam_fd); - m_cam_fd = -1; - } - - LOGI("DeinitCamera: m_cam_fd2(%d)", m_cam_fd2); - if (m_cam_fd2 > -1) { - close(m_cam_fd2); - m_cam_fd2 = -1; - } - - if (m_cam_fd_temp != -1) { - close(m_cam_fd_temp); - m_cam_fd_temp = -1; - } - - if (m_cam_fd2_temp != -1) { - close(m_cam_fd2_temp); - m_cam_fd2_temp = -1; - } - - m_flag_init = 0; - } -} - - -int SecCamera::getCameraFd(void) -{ - return m_cam_fd; -} - -// ====================================================================== -// Preview - -int SecCamera::startPreview(void) -{ - v4l2_streamparm streamparm; - struct sec_cam_parm *parms; - parms = (struct sec_cam_parm*)&streamparm.parm.raw_data; - LOGV("%s :", __func__); - - // aleady started - if (m_flag_camera_start > 0) { - LOGE("ERR(%s):Preview was already started\n", __func__); - return 0; - } - - if (m_cam_fd <= 0) { - LOGE("ERR(%s):Camera was closed\n", __func__); - return -1; - } - - memset(&m_events_c, 0, sizeof(m_events_c)); - m_events_c.fd = m_cam_fd; - m_events_c.events = POLLIN | POLLERR; - - /* enum_fmt, s_fmt sample */ - int ret = fimc_v4l2_enum_fmt(m_cam_fd,m_preview_v4lformat); - CHECK(ret); - ret = fimc_v4l2_s_fmt(m_cam_fd, m_preview_width,m_preview_height,m_preview_v4lformat, 0); - CHECK(ret); - - ret = fimc_v4l2_reqbufs(m_cam_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS); - CHECK(ret); - - LOGV("%s : m_preview_width: %d m_preview_height: %d m_angle: %d\n", - __func__, m_preview_width, m_preview_height, m_angle); - - ret = fimc_v4l2_s_ctrl(m_cam_fd, - V4L2_CID_CAMERA_CHECK_DATALINE, m_chk_dataline); - CHECK(ret); - - if (m_camera_id == CAMERA_ID_FRONT) { - /* VT mode setting */ - ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VT_MODE, m_vtmode); - CHECK(ret); - } - - /* start with all buffers in queue */ - for (int i = 0; i < MAX_BUFFERS; i++) { - ret = fimc_v4l2_qbuf(m_cam_fd, i); - CHECK(ret); - } - - ret = fimc_v4l2_streamon(m_cam_fd); - CHECK(ret); - - m_flag_camera_start = 1; - - ret = fimc_v4l2_s_parm(m_cam_fd, &m_streamparm); - CHECK(ret); - - if (m_camera_id == CAMERA_ID_FRONT) { - /* Blur setting */ - LOGV("m_blur_level = %d", m_blur_level); - ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VGA_BLUR, - m_blur_level); - CHECK(ret); - } - - // It is a delay for a new frame, not to show the previous bigger ugly picture frame. - ret = fimc_poll(&m_events_c); - CHECK(ret); - ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_RETURN_FOCUS, 0); - CHECK(ret); - - LOGV("%s: got the first frame of the preview\n", __func__); - - return 0; -} - -int SecCamera::stopPreview(void) -{ - int ret; - - LOGV("%s :", __func__); - - if (m_flag_camera_start == 0) { - LOGW("%s: doing nothing because m_flag_camera_start is zero", __func__); - return 0; - } - - if (m_params->flash_mode == FLASH_MODE_TORCH) - setFlashMode(FLASH_MODE_OFF); - - if (m_cam_fd <= 0) { - LOGE("ERR(%s):Camera was closed\n", __func__); - return -1; - } - - ret = fimc_v4l2_streamoff(m_cam_fd); - CHECK(ret); - - m_flag_camera_start = 0; - - return ret; -} - -//Recording -int SecCamera::startRecord(void) -{ - int ret, i; - - LOGV("%s :", __func__); - - // aleady started - if (m_flag_record_start > 0) { - LOGE("ERR(%s):Preview was already started\n", __func__); - return 0; - } - - if (m_cam_fd2 <= 0) { - LOGE("ERR(%s):Camera was closed\n", __func__); - return -1; - } - - /* enum_fmt, s_fmt sample */ - ret = fimc_v4l2_enum_fmt(m_cam_fd2, V4L2_PIX_FMT_NV12T); - CHECK(ret); - - LOGI("%s: m_recording_width = %d, m_recording_height = %d\n", - __func__, m_recording_width, m_recording_height); - - ret = fimc_v4l2_s_fmt(m_cam_fd2, m_recording_width, - m_recording_height, V4L2_PIX_FMT_NV12T, 0); - CHECK(ret); - - ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FRAME_RATE, - m_params->capture.timeperframe.denominator); - CHECK(ret); - - ret = fimc_v4l2_reqbufs(m_cam_fd2, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS); - CHECK(ret); - - /* start with all buffers in queue */ - for (i = 0; i < MAX_BUFFERS; i++) { - ret = fimc_v4l2_qbuf(m_cam_fd2, i); - CHECK(ret); - } - - ret = fimc_v4l2_streamon(m_cam_fd2); - CHECK(ret); - - // Get and throw away the first frame since it is often garbled. - memset(&m_events_c2, 0, sizeof(m_events_c2)); - m_events_c2.fd = m_cam_fd2; - m_events_c2.events = POLLIN | POLLERR; - ret = fimc_poll(&m_events_c2); - CHECK(ret); - - m_flag_record_start = 1; - - return 0; -} - -int SecCamera::stopRecord(void) -{ - int ret; - - LOGV("%s :", __func__); - - if (m_flag_record_start == 0) { - LOGW("%s: doing nothing because m_flag_record_start is zero", __func__); - return 0; - } - - if (m_cam_fd2 <= 0) { - LOGE("ERR(%s):Camera was closed\n", __func__); - return -1; - } - - m_flag_record_start = 0; - - ret = fimc_v4l2_streamoff(m_cam_fd2); - CHECK(ret); - - ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FRAME_RATE, - FRAME_RATE_AUTO); - CHECK(ret); - - return 0; -} - -unsigned int SecCamera::getRecPhyAddrY(int index) -{ - unsigned int addr_y; - - addr_y = fimc_v4l2_s_ctrl(m_cam_fd2, V4L2_CID_PADDR_Y, index); - CHECK((int)addr_y); - return addr_y; -} - -unsigned int SecCamera::getRecPhyAddrC(int index) -{ - unsigned int addr_c; - - addr_c = fimc_v4l2_s_ctrl(m_cam_fd2, V4L2_CID_PADDR_CBCR, index); - CHECK((int)addr_c); - return addr_c; -} - -unsigned int SecCamera::getPhyAddrY(int index) -{ - unsigned int addr_y; - - addr_y = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_PADDR_Y, index); - CHECK((int)addr_y); - return addr_y; -} - -unsigned int SecCamera::getPhyAddrC(int index) -{ - unsigned int addr_c; - - addr_c = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_PADDR_CBCR, index); - CHECK((int)addr_c); - return addr_c; -} - -void SecCamera::pausePreview() -{ - fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0); -} - -int SecCamera::getPreview() -{ - int index; - int ret; - - if (m_flag_camera_start == 0 || previewPoll(true) == 0) { - LOGE("ERR(%s):Start Camera Device Reset \n", __func__); - /* GAUDI Project([arun.c@samsung.com]) 2010.05.20. [Implemented ESD code] */ - /* - * When there is no data for more than 1 second from the camera we inform - * the FIMC driver by calling fimc_v4l2_s_input() with a special value = 1000 - * FIMC driver identify that there is something wrong with the camera - * and it restarts the sensor. - */ - stopPreview(); - /* Reset Only Camera Device */ - ret = fimc_v4l2_querycap(m_cam_fd); - CHECK(ret); - if (fimc_v4l2_enuminput(m_cam_fd, m_camera_id)) - return -1; - ret = fimc_v4l2_s_input(m_cam_fd, 1000); - CHECK(ret); - ret = startPreview(); - if (ret < 0) { - LOGE("ERR(%s): startPreview() return %d\n", __func__, ret); - return 0; - } - } - - index = fimc_v4l2_dqbuf(m_cam_fd); - if (!(0 <= index && index < MAX_BUFFERS)) { - LOGE("ERR(%s):wrong index = %d\n", __func__, index); - return -1; - } - - ret = fimc_v4l2_qbuf(m_cam_fd, index); - CHECK(ret); - - return index; -} - -int SecCamera::getRecordFrame() -{ - if (m_flag_record_start == 0) { - LOGE("%s: m_flag_record_start is 0", __func__); - return -1; - } - - previewPoll(false); - return fimc_v4l2_dqbuf(m_cam_fd2); -} - -int SecCamera::releaseRecordFrame(int index) -{ - if (!m_flag_record_start) { - /* this can happen when recording frames are returned after - * the recording is stopped at the driver level. we don't - * need to return the buffers in this case and we've seen - * cases where fimc could crash if we called qbuf and it - * wasn't expecting it. - */ - LOGI("%s: recording not in progress, ignoring", __func__); - return 0; - } - - return fimc_v4l2_qbuf(m_cam_fd2, index); -} - -int SecCamera::setPreviewSize(int width, int height, int pixel_format) -{ - LOGV("%s(width(%d), height(%d), format(%d))", __func__, width, height, pixel_format); - - int v4lpixelformat = pixel_format; - -#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0 - if (v4lpixelformat == V4L2_PIX_FMT_YUV420) - LOGV("PreviewFormat:V4L2_PIX_FMT_YUV420"); - else if (v4lpixelformat == V4L2_PIX_FMT_NV12) - LOGV("PreviewFormat:V4L2_PIX_FMT_NV12"); - else if (v4lpixelformat == V4L2_PIX_FMT_NV12T) - LOGV("PreviewFormat:V4L2_PIX_FMT_NV12T"); - else if (v4lpixelformat == V4L2_PIX_FMT_NV21) - LOGV("PreviewFormat:V4L2_PIX_FMT_NV21"); - else if (v4lpixelformat == V4L2_PIX_FMT_YUV422P) - LOGV("PreviewFormat:V4L2_PIX_FMT_YUV422P"); - else if (v4lpixelformat == V4L2_PIX_FMT_YUYV) - LOGV("PreviewFormat:V4L2_PIX_FMT_YUYV"); - else if (v4lpixelformat == V4L2_PIX_FMT_RGB565) - LOGV("PreviewFormat:V4L2_PIX_FMT_RGB565"); - else - LOGV("PreviewFormat:UnknownFormat"); -#endif - m_preview_width = width; - m_preview_height = height; - m_preview_v4lformat = v4lpixelformat; - - return 0; -} - -int SecCamera::getPreviewSize(int *width, int *height, int *frame_size) -{ - *width = m_preview_width; - *height = m_preview_height; - *frame_size = m_frameSize(m_preview_v4lformat, m_preview_width, m_preview_height); - - return 0; -} - -int SecCamera::getPreviewMaxSize(int *width, int *height) -{ - *width = m_preview_max_width; - *height = m_preview_max_height; - - return 0; -} - -int SecCamera::getPreviewPixelFormat(void) -{ - return m_preview_v4lformat; -} - - -// ====================================================================== -// Snapshot -/* - * Devide getJpeg() as two funcs, setSnapshotCmd() & getJpeg() because of the shutter sound timing. - * Here, just send the capture cmd to camera ISP to start JPEG capture. - */ -int SecCamera::setSnapshotCmd(void) -{ - LOGV("%s :", __func__); - - int ret = 0; - - LOG_TIME_DEFINE(0) - LOG_TIME_DEFINE(1) - - if (m_cam_fd <= 0) { - LOGE("ERR(%s):Camera was closed\n", __func__); - return 0; - } - - if (m_flag_camera_start > 0) { - LOG_TIME_START(0) - LOGW("WARN(%s):Camera was in preview, should have been stopped\n", __func__); - stopPreview(); - LOG_TIME_END(0) - } - - memset(&m_events_c, 0, sizeof(m_events_c)); - m_events_c.fd = m_cam_fd; - m_events_c.events = POLLIN | POLLERR; - - LOG_TIME_START(1) // prepare - int nframe = 1; - - ret = fimc_v4l2_enum_fmt(m_cam_fd,m_snapshot_v4lformat); - CHECK(ret); - ret = fimc_v4l2_s_fmt_cap(m_cam_fd, m_snapshot_width, m_snapshot_height, V4L2_PIX_FMT_JPEG); - CHECK(ret); - ret = fimc_v4l2_reqbufs(m_cam_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, nframe); - CHECK(ret); - ret = fimc_v4l2_querybuf(m_cam_fd, &m_capture_buf, V4L2_BUF_TYPE_VIDEO_CAPTURE); - CHECK(ret); - - ret = fimc_v4l2_qbuf(m_cam_fd, 0); - CHECK(ret); - - ret = fimc_v4l2_streamon(m_cam_fd); - CHECK(ret); - LOG_TIME_END(1) - - return 0; -} - -int SecCamera::endSnapshot(void) -{ - int ret; - - LOGI("%s :", __func__); - if (m_capture_buf.start) { - munmap(m_capture_buf.start, m_capture_buf.length); - LOGI("munmap():virt. addr %p size = %d\n", - m_capture_buf.start, m_capture_buf.length); - m_capture_buf.start = NULL; - m_capture_buf.length = 0; - } - return 0; -} - -/* - * Set Jpeg quality & exif info and get JPEG data from camera ISP - */ -unsigned char* SecCamera::getJpeg(int *jpeg_size, unsigned int *phyaddr) -{ - LOGV("%s :", __func__); - - int index, ret = 0; - unsigned char *addr; - - LOG_TIME_DEFINE(2) - - // capture - ret = fimc_poll(&m_events_c); - CHECK_PTR(ret); - index = fimc_v4l2_dqbuf(m_cam_fd); - if (index != 0) { - LOGE("ERR(%s):wrong index = %d\n", __func__, index); - return NULL; - } - - *jpeg_size = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_MAIN_SIZE); - CHECK_PTR(*jpeg_size); - - int main_offset = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_MAIN_OFFSET); - CHECK_PTR(main_offset); - m_postview_offset = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_POSTVIEW_OFFSET); - CHECK_PTR(m_postview_offset); - - ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0); - CHECK_PTR(ret); - LOGV("\nsnapshot dqueued buffer = %d snapshot_width = %d snapshot_height = %d, size = %d\n\n", - index, m_snapshot_width, m_snapshot_height, *jpeg_size); - - addr = (unsigned char*)(m_capture_buf.start) + main_offset; - *phyaddr = getPhyAddrY(index) + m_postview_offset; - - LOG_TIME_START(2) // post - ret = fimc_v4l2_streamoff(m_cam_fd); - CHECK_PTR(ret); - LOG_TIME_END(2) - - return addr; -} - -int SecCamera::getExif(unsigned char *pExifDst, unsigned char *pThumbSrc) -{ - JpegEncoder jpgEnc; - - LOGV("%s : m_jpeg_thumbnail_width = %d, height = %d", - __func__, m_jpeg_thumbnail_width, m_jpeg_thumbnail_height); - if ((m_jpeg_thumbnail_width > 0) && (m_jpeg_thumbnail_height > 0)) { - int inFormat = JPG_MODESEL_YCBCR; - int outFormat = JPG_422; - switch (m_snapshot_v4lformat) { - case V4L2_PIX_FMT_NV12: - case V4L2_PIX_FMT_NV21: - case V4L2_PIX_FMT_NV12T: - case V4L2_PIX_FMT_YUV420: - outFormat = JPG_420; - break; - case V4L2_PIX_FMT_YUYV: - case V4L2_PIX_FMT_UYVY: - case V4L2_PIX_FMT_YUV422P: - outFormat = JPG_422; - break; - } - - if (jpgEnc.setConfig(JPEG_SET_ENCODE_IN_FORMAT, inFormat) != JPG_SUCCESS) - return -1; - - if (jpgEnc.setConfig(JPEG_SET_SAMPING_MODE, outFormat) != JPG_SUCCESS) - return -1; - - if (jpgEnc.setConfig(JPEG_SET_ENCODE_QUALITY, JPG_QUALITY_LEVEL_2) != JPG_SUCCESS) - return -1; - - int thumbWidth, thumbHeight, thumbSrcSize; - getThumbnailConfig(&thumbWidth, &thumbHeight, &thumbSrcSize); - if (jpgEnc.setConfig(JPEG_SET_ENCODE_WIDTH, thumbWidth) != JPG_SUCCESS) - return -1; - - if (jpgEnc.setConfig(JPEG_SET_ENCODE_HEIGHT, thumbHeight) != JPG_SUCCESS) - return -1; - - char *pInBuf = (char *)jpgEnc.getInBuf(thumbSrcSize); - if (pInBuf == NULL) - return -1; - memcpy(pInBuf, pThumbSrc, thumbSrcSize); - - unsigned int thumbSize; - - jpgEnc.encode(&thumbSize, NULL); - - LOGV("%s : enableThumb set to true", __func__); - mExifInfo.enableThumb = true; - } else { - LOGV("%s : enableThumb set to false", __func__); - mExifInfo.enableThumb = false; - } - - unsigned int exifSize; - - setExifChangedAttribute(); - - LOGV("%s: calling jpgEnc.makeExif, mExifInfo.width set to %d, height to %d\n", - __func__, mExifInfo.width, mExifInfo.height); - - jpgEnc.makeExif(pExifDst, &mExifInfo, &exifSize, true); - - return exifSize; -} - -void SecCamera::getPostViewConfig(int *width, int *height, int *size) -{ - if (m_preview_width == 1024) { - *width = BACK_CAMERA_POSTVIEW_WIDE_WIDTH; - *height = BACK_CAMERA_POSTVIEW_HEIGHT; - *size = BACK_CAMERA_POSTVIEW_WIDE_WIDTH * BACK_CAMERA_POSTVIEW_HEIGHT * BACK_CAMERA_POSTVIEW_BPP / 8; - } else { - *width = BACK_CAMERA_POSTVIEW_WIDTH; - *height = BACK_CAMERA_POSTVIEW_HEIGHT; - *size = BACK_CAMERA_POSTVIEW_WIDTH * BACK_CAMERA_POSTVIEW_HEIGHT * BACK_CAMERA_POSTVIEW_BPP / 8; - } - LOGV("[5B] m_preview_width : %d, mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d", - m_preview_width, *width, *height, *size); -} - -void SecCamera::getThumbnailConfig(int *width, int *height, int *size) -{ - if (m_camera_id == CAMERA_ID_BACK) { - *width = BACK_CAMERA_THUMBNAIL_WIDTH; - *height = BACK_CAMERA_THUMBNAIL_HEIGHT; - *size = BACK_CAMERA_THUMBNAIL_WIDTH * BACK_CAMERA_THUMBNAIL_HEIGHT - * BACK_CAMERA_THUMBNAIL_BPP / 8; - } else { - *width = FRONT_CAMERA_THUMBNAIL_WIDTH; - *height = FRONT_CAMERA_THUMBNAIL_HEIGHT; - *size = FRONT_CAMERA_THUMBNAIL_WIDTH * FRONT_CAMERA_THUMBNAIL_HEIGHT - * FRONT_CAMERA_THUMBNAIL_BPP / 8; - } -} - -int SecCamera::getPostViewOffset(void) -{ - return m_postview_offset; -} - -int SecCamera::getSnapshotAndJpeg(unsigned char *yuv_buf, unsigned char *jpeg_buf, - unsigned int *output_size) -{ - LOGV("%s :", __func__); - - int index; - //unsigned int addr; - unsigned char *addr; - int ret = 0; - - LOG_TIME_DEFINE(0) - LOG_TIME_DEFINE(1) - LOG_TIME_DEFINE(2) - LOG_TIME_DEFINE(3) - LOG_TIME_DEFINE(4) - LOG_TIME_DEFINE(5) - - //fimc_v4l2_streamoff(m_cam_fd); [zzangdol] remove - it is separate in HWInterface with camera_id - - if (m_cam_fd <= 0) { - LOGE("ERR(%s):Camera was closed\n", __func__); - return -1; - } - - if (m_flag_camera_start > 0) { - LOG_TIME_START(0) - LOGW("WARN(%s):Camera was in preview, should have been stopped\n", __func__); - stopPreview(); - LOG_TIME_END(0) - } - - memset(&m_events_c, 0, sizeof(m_events_c)); - m_events_c.fd = m_cam_fd; - m_events_c.events = POLLIN | POLLERR; - -#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0 - if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV420) - LOGV("SnapshotFormat:V4L2_PIX_FMT_YUV420"); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12) - LOGV("SnapshotFormat:V4L2_PIX_FMT_NV12"); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12T) - LOGV("SnapshotFormat:V4L2_PIX_FMT_NV12T"); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV21) - LOGV("SnapshotFormat:V4L2_PIX_FMT_NV21"); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV422P) - LOGV("SnapshotFormat:V4L2_PIX_FMT_YUV422P"); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUYV) - LOGV("SnapshotFormat:V4L2_PIX_FMT_YUYV"); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_UYVY) - LOGV("SnapshotFormat:V4L2_PIX_FMT_UYVY"); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_RGB565) - LOGV("SnapshotFormat:V4L2_PIX_FMT_RGB565"); - else - LOGV("SnapshotFormat:UnknownFormat"); -#endif - - LOG_TIME_START(1) // prepare - int nframe = 1; - - ret = fimc_v4l2_enum_fmt(m_cam_fd,m_snapshot_v4lformat); - CHECK(ret); - ret = fimc_v4l2_s_fmt_cap(m_cam_fd, m_snapshot_width, m_snapshot_height, m_snapshot_v4lformat); - CHECK(ret); - ret = fimc_v4l2_reqbufs(m_cam_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, nframe); - CHECK(ret); - ret = fimc_v4l2_querybuf(m_cam_fd, &m_capture_buf, V4L2_BUF_TYPE_VIDEO_CAPTURE); - CHECK(ret); - - ret = fimc_v4l2_qbuf(m_cam_fd, 0); - CHECK(ret); - - ret = fimc_v4l2_streamon(m_cam_fd); - CHECK(ret); - LOG_TIME_END(1) - - LOG_TIME_START(2) // capture - fimc_poll(&m_events_c); - index = fimc_v4l2_dqbuf(m_cam_fd); - fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0); - LOGV("\nsnapshot dequeued buffer = %d snapshot_width = %d snapshot_height = %d\n\n", - index, m_snapshot_width, m_snapshot_height); - - LOG_TIME_END(2) - - LOGI("%s : calling memcpy from m_capture_buf", __func__); - memcpy(yuv_buf, (unsigned char*)m_capture_buf.start, m_snapshot_width * m_snapshot_height * 2); - LOG_TIME_START(5) // post - fimc_v4l2_streamoff(m_cam_fd); - LOG_TIME_END(5) - - LOG_CAMERA("getSnapshotAndJpeg intervals : stopPreview(%lu), prepare(%lu)," - " capture(%lu), memcpy(%lu), yuv2Jpeg(%lu), post(%lu) us", - LOG_TIME(0), LOG_TIME(1), LOG_TIME(2), LOG_TIME(3), LOG_TIME(4), LOG_TIME(5)); - /* JPEG encoding */ - JpegEncoder jpgEnc; - int inFormat = JPG_MODESEL_YCBCR; - int outFormat = JPG_422; - - switch (m_snapshot_v4lformat) { - case V4L2_PIX_FMT_NV12: - case V4L2_PIX_FMT_NV21: - case V4L2_PIX_FMT_NV12T: - case V4L2_PIX_FMT_YUV420: - outFormat = JPG_420; - break; - case V4L2_PIX_FMT_YUYV: - case V4L2_PIX_FMT_UYVY: - case V4L2_PIX_FMT_YUV422P: - default: - outFormat = JPG_422; - break; - } - - if (jpgEnc.setConfig(JPEG_SET_ENCODE_IN_FORMAT, inFormat) != JPG_SUCCESS) - LOGE("[JPEG_SET_ENCODE_IN_FORMAT] Error\n"); - - if (jpgEnc.setConfig(JPEG_SET_SAMPING_MODE, outFormat) != JPG_SUCCESS) - LOGE("[JPEG_SET_SAMPING_MODE] Error\n"); - - image_quality_type_t jpegQuality; - if (m_jpeg_quality >= 90) - jpegQuality = JPG_QUALITY_LEVEL_1; - else if (m_jpeg_quality >= 80) - jpegQuality = JPG_QUALITY_LEVEL_2; - else if (m_jpeg_quality >= 70) - jpegQuality = JPG_QUALITY_LEVEL_3; - else - jpegQuality = JPG_QUALITY_LEVEL_4; - - if (jpgEnc.setConfig(JPEG_SET_ENCODE_QUALITY, jpegQuality) != JPG_SUCCESS) - LOGE("[JPEG_SET_ENCODE_QUALITY] Error\n"); - if (jpgEnc.setConfig(JPEG_SET_ENCODE_WIDTH, m_snapshot_width) != JPG_SUCCESS) - LOGE("[JPEG_SET_ENCODE_WIDTH] Error\n"); - - if (jpgEnc.setConfig(JPEG_SET_ENCODE_HEIGHT, m_snapshot_height) != JPG_SUCCESS) - LOGE("[JPEG_SET_ENCODE_HEIGHT] Error\n"); - - unsigned int snapshot_size = m_snapshot_width * m_snapshot_height * 2; - unsigned char *pInBuf = (unsigned char *)jpgEnc.getInBuf(snapshot_size); - - if (pInBuf == NULL) { - LOGE("JPEG input buffer is NULL!!\n"); - return -1; - } - memcpy(pInBuf, yuv_buf, snapshot_size); - - setExifChangedAttribute(); - jpgEnc.encode(output_size, &mExifInfo); - - uint64_t outbuf_size; - unsigned char *pOutBuf = (unsigned char *)jpgEnc.getOutBuf(&outbuf_size); - - if (pOutBuf == NULL) { - LOGE("JPEG output buffer is NULL!!\n"); - return -1; - } - - memcpy(jpeg_buf, pOutBuf, outbuf_size); - - return 0; -} - - -int SecCamera::setSnapshotSize(int width, int height) -{ - LOGV("%s(width(%d), height(%d))", __func__, width, height); - - m_snapshot_width = width; - m_snapshot_height = height; - - return 0; -} - -int SecCamera::getSnapshotSize(int *width, int *height, int *frame_size) -{ - *width = m_snapshot_width; - *height = m_snapshot_height; - - int frame = 0; - - frame = m_frameSize(m_snapshot_v4lformat, m_snapshot_width, m_snapshot_height); - - // set it big. - if (frame == 0) - frame = m_snapshot_width * m_snapshot_height * BPP; - - *frame_size = frame; - - return 0; -} - -int SecCamera::getSnapshotMaxSize(int *width, int *height) -{ - switch (m_camera_id) { - case CAMERA_ID_FRONT: - m_snapshot_max_width = MAX_FRONT_CAMERA_SNAPSHOT_WIDTH; - m_snapshot_max_height = MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT; - break; - - default: - case CAMERA_ID_BACK: - m_snapshot_max_width = MAX_BACK_CAMERA_SNAPSHOT_WIDTH; - m_snapshot_max_height = MAX_BACK_CAMERA_SNAPSHOT_HEIGHT; - break; - } - - *width = m_snapshot_max_width; - *height = m_snapshot_max_height; - - return 0; -} - -int SecCamera::setSnapshotPixelFormat(int pixel_format) -{ - int v4lpixelformat= pixel_format; - - if (m_snapshot_v4lformat != v4lpixelformat) { - m_snapshot_v4lformat = v4lpixelformat; - } - -#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0 - if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV420) - LOGE("%s : SnapshotFormat:V4L2_PIX_FMT_YUV420", __func__); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12) - LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_NV12", __func__); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12T) - LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_NV12T", __func__); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV21) - LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_NV21", __func__); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV422P) - LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_YUV422P", __func__); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUYV) - LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_YUYV", __func__); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_UYVY) - LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_UYVY", __func__); - else if (m_snapshot_v4lformat == V4L2_PIX_FMT_RGB565) - LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_RGB565", __func__); - else - LOGD("SnapshotFormat:UnknownFormat"); -#endif - return 0; -} - -int SecCamera::getSnapshotPixelFormat(void) -{ - return m_snapshot_v4lformat; -} - -// ====================================================================== -// Settings - -int SecCamera::getCameraId(void) -{ - return m_camera_id; -} - -// ----------------------------------- - -int SecCamera::setAutofocus(void) -{ - LOGV("%s :", __func__); - - if (m_cam_fd <= 0) { - LOGE("ERR(%s):Camera was closed\n", __func__); - return -1; - } - - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_AUTO_FOCUS, AUTO_FOCUS_ON) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_AUTO_FOCUS", __func__); - return -1; - } - - return 0; -} - -int SecCamera::getAutoFocusResult(void) -{ - int af_result; - - af_result = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_AUTO_FOCUS_RESULT); - - LOGV("%s : returning %d", __func__, af_result); - - return af_result; -} - -int SecCamera::cancelAutofocus(void) -{ - LOGV("%s :", __func__); - - if (m_cam_fd <= 0) { - LOGE("ERR(%s):Camera was closed\n", __func__); - return -1; - } - - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_AUTO_FOCUS, AUTO_FOCUS_OFF) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_AUTO_FOCUS", __func__); - return -1; - } - - return 0; -} - -// ----------------------------------- - -int SecCamera::zoomIn(void) -{ - LOGV("%s :", __func__); - return 0; -} - -int SecCamera::zoomOut(void) -{ - LOGV("%s :", __func__); - return 0; -} - -// ----------------------------------- - -int SecCamera::SetRotate(int angle) -{ - LOGE("%s(angle(%d))", __func__, angle); - - if (m_angle != angle) { - switch (angle) { - case -360: - case 0: - case 360: - m_angle = 0; - break; - - case -270: - case 90: - m_angle = 90; - break; - - case -180: - case 180: - m_angle = 180; - break; - - case -90: - case 270: - m_angle = 270; - break; - - default: - LOGE("ERR(%s):Invalid angle(%d)", __func__, angle); - return -1; - } - - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_ROTATION, angle) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_ROTATION", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getRotate(void) -{ - LOGV("%s : angle(%d)", __func__, m_angle); - return m_angle; -} - -int SecCamera::setFrameRate(int frame_rate) -{ - LOGV("%s(FrameRate(%d))", __func__, frame_rate); - - if (frame_rate < FRAME_RATE_AUTO || FRAME_RATE_MAX < frame_rate ) - LOGE("ERR(%s):Invalid frame_rate(%d)", __func__, frame_rate); - - if (m_params->capture.timeperframe.denominator != (unsigned)frame_rate) { - m_params->capture.timeperframe.denominator = frame_rate; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FRAME_RATE, frame_rate) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FRAME_RATE", __func__); - return -1; - } - } - } - - return 0; -} - -// ----------------------------------- - -int SecCamera::setVerticalMirror(void) -{ - LOGV("%s :", __func__); - - if (m_cam_fd <= 0) { - LOGE("ERR(%s):Camera was closed\n", __func__); - return -1; - } - - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_VFLIP, 0) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_VFLIP", __func__); - return -1; - } - - return 0; -} - -int SecCamera::setHorizontalMirror(void) -{ - LOGV("%s :", __func__); - - if (m_cam_fd <= 0) { - LOGE("ERR(%s):Camera was closed\n", __func__); - return -1; - } - - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_HFLIP, 0) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_HFLIP", __func__); - return -1; - } - - return 0; -} - -// ----------------------------------- - -int SecCamera::setWhiteBalance(int white_balance) -{ - LOGV("%s(white_balance(%d))", __func__, white_balance); - - if (white_balance <= WHITE_BALANCE_BASE || WHITE_BALANCE_MAX <= white_balance) { - LOGE("ERR(%s):Invalid white_balance(%d)", __func__, white_balance); - return -1; - } - - if (m_params->white_balance != white_balance) { - m_params->white_balance = white_balance; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WHITE_BALANCE, white_balance) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_WHITE_BALANCE", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getWhiteBalance(void) -{ - LOGV("%s : white_balance(%d)", __func__, m_params->white_balance); - return m_params->white_balance; -} - -// ----------------------------------- - -int SecCamera::setBrightness(int brightness) -{ - LOGV("%s(brightness(%d))", __func__, brightness); - - brightness += EV_DEFAULT; - - if (brightness < EV_MINUS_4 || EV_PLUS_4 < brightness) { - LOGE("ERR(%s):Invalid brightness(%d)", __func__, brightness); - return -1; - } - - if (m_params->brightness != brightness) { - m_params->brightness = brightness; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, brightness) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BRIGHTNESS", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getBrightness(void) -{ - LOGV("%s : brightness(%d)", __func__, m_params->brightness); - return m_params->brightness; -} - -// ----------------------------------- - -int SecCamera::setImageEffect(int image_effect) -{ - LOGV("%s(image_effect(%d))", __func__, image_effect); - - if (image_effect <= IMAGE_EFFECT_BASE || IMAGE_EFFECT_MAX <= image_effect) { - LOGE("ERR(%s):Invalid image_effect(%d)", __func__, image_effect); - return -1; - } - - if (m_params->effects != image_effect) { - m_params->effects = image_effect; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EFFECT, image_effect) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_EFFECT", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getImageEffect(void) -{ - LOGV("%s : image_effect(%d)", __func__, m_params->effects); - return m_params->effects; -} - -// ====================================================================== -int SecCamera::setAntiBanding(int anti_banding) -{ - LOGV("%s(anti_banding(%d))", __func__, anti_banding); - - if (anti_banding < ANTI_BANDING_AUTO || ANTI_BANDING_OFF < anti_banding) { - LOGE("ERR(%s):Invalid anti_banding (%d)", __func__, anti_banding); - return -1; - } - - if (m_anti_banding != anti_banding) { - m_anti_banding = anti_banding; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ANTI_BANDING, anti_banding) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ANTI_BANDING", __func__); - return -1; - } - } - } - - return 0; -} - -//====================================================================== -int SecCamera::setSceneMode(int scene_mode) -{ - LOGV("%s(scene_mode(%d))", __func__, scene_mode); - - if (scene_mode <= SCENE_MODE_BASE || SCENE_MODE_MAX <= scene_mode) { - LOGE("ERR(%s):Invalid scene_mode (%d)", __func__, scene_mode); - return -1; - } - - if (m_params->scene_mode != scene_mode) { - m_params->scene_mode = scene_mode; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SCENE_MODE, scene_mode) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SCENE_MODE", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getSceneMode(void) -{ - return m_params->scene_mode; -} - -//====================================================================== - -int SecCamera::setFlashMode(int flash_mode) -{ - LOGV("%s(flash_mode(%d))", __func__, flash_mode); - - if (flash_mode <= FLASH_MODE_BASE || FLASH_MODE_MAX <= flash_mode) { - LOGE("ERR(%s):Invalid flash_mode (%d)", __func__, flash_mode); - return -1; - } - - if (m_params->flash_mode != flash_mode) { - m_params->flash_mode = flash_mode; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FLASH_MODE, flash_mode) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FLASH_MODE", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getFlashMode(void) -{ - return m_params->flash_mode; -} - -//====================================================================== - -int SecCamera::setISO(int iso_value) -{ - LOGV("%s(iso_value(%d))", __func__, iso_value); - if (iso_value < ISO_AUTO || ISO_MAX <= iso_value) { - LOGE("ERR(%s):Invalid iso_value (%d)", __func__, iso_value); - return -1; - } - - if (m_params->iso != iso_value) { - m_params->iso = iso_value; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ISO, iso_value) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ISO", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getISO(void) -{ - return m_params->iso; -} - -//====================================================================== - -int SecCamera::setContrast(int contrast_value) -{ - LOGV("%s(contrast_value(%d))", __func__, contrast_value); - - if (contrast_value < CONTRAST_MINUS_2 || CONTRAST_MAX <= contrast_value) { - LOGE("ERR(%s):Invalid contrast_value (%d)", __func__, contrast_value); - return -1; - } - - if (m_params->contrast != contrast_value) { - m_params->contrast = contrast_value; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CONTRAST, contrast_value) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_CONTRAST", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getContrast(void) -{ - return m_params->contrast; -} - -//====================================================================== - -int SecCamera::setSaturation(int saturation_value) -{ - LOGV("%s(saturation_value(%d))", __func__, saturation_value); - - if (saturation_value saturation != saturation_value) { - m_params->saturation = saturation_value; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SATURATION, saturation_value) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SATURATION", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getSaturation(void) -{ - return m_params->saturation; -} - -//====================================================================== - -int SecCamera::setSharpness(int sharpness_value) -{ - LOGV("%s(sharpness_value(%d))", __func__, sharpness_value); - - if (sharpness_value < SHARPNESS_MINUS_2 || SHARPNESS_MAX <= sharpness_value) { - LOGE("ERR(%s):Invalid sharpness_value (%d)", __func__, sharpness_value); - return -1; - } - - if (m_params->sharpness != sharpness_value) { - m_params->sharpness = sharpness_value; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SHARPNESS, sharpness_value) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SHARPNESS", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getSharpness(void) -{ - return m_params->sharpness; -} - -//====================================================================== - -int SecCamera::setWDR(int wdr_value) -{ - LOGV("%s(wdr_value(%d))", __func__, wdr_value); - - if (wdr_value < WDR_OFF || WDR_MAX <= wdr_value) { - LOGE("ERR(%s):Invalid wdr_value (%d)", __func__, wdr_value); - return -1; - } - - if (m_wdr != wdr_value) { - m_wdr = wdr_value; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WDR, wdr_value) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_WDR", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getWDR(void) -{ - return m_wdr; -} - -//====================================================================== - -int SecCamera::setAntiShake(int anti_shake) -{ - LOGV("%s(anti_shake(%d))", __func__, anti_shake); - - if (anti_shake < ANTI_SHAKE_OFF || ANTI_SHAKE_MAX <= anti_shake) { - LOGE("ERR(%s):Invalid anti_shake (%d)", __func__, anti_shake); - return -1; - } - - if (m_anti_shake != anti_shake) { - m_anti_shake = anti_shake; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ANTI_SHAKE, anti_shake) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ANTI_SHAKE", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getAntiShake(void) -{ - return m_anti_shake; -} - -//====================================================================== - - -int SecCamera::setMetering(int metering_value) -{ - LOGV("%s(metering (%d))", __func__, metering_value); - - if (metering_value <= METERING_BASE || METERING_MAX <= metering_value) { - LOGE("ERR(%s):Invalid metering_value (%d)", __func__, metering_value); - return -1; - } - - if (m_params->metering != metering_value) { - m_params->metering = metering_value; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_METERING, metering_value) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_METERING", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getMetering(void) -{ - return m_params->metering; -} - -//====================================================================== - -int SecCamera::setJpegQuality(int jpeg_quality) -{ - LOGV("%s(jpeg_quality (%d))", __func__, jpeg_quality); - - if (jpeg_quality < JPEG_QUALITY_ECONOMY || JPEG_QUALITY_MAX <= jpeg_quality) { - LOGE("ERR(%s):Invalid jpeg_quality (%d)", __func__, jpeg_quality); - return -1; - } - - if (m_jpeg_quality != jpeg_quality) { - m_jpeg_quality = jpeg_quality; - if (m_flag_camera_start && (m_camera_id == CAMERA_ID_BACK)) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_QUALITY, jpeg_quality) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAM_JPEG_QUALITY", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getJpegQuality(void) -{ - return m_jpeg_quality; -} - -//====================================================================== - -int SecCamera::setZoom(int zoom_level) -{ - LOGV("%s(zoom_level (%d))", __func__, zoom_level); - - if (zoom_level < ZOOM_LEVEL_0 || ZOOM_LEVEL_MAX <= zoom_level) { - LOGE("ERR(%s):Invalid zoom_level (%d)", __func__, zoom_level); - return -1; - } - - if (m_zoom_level != zoom_level) { - m_zoom_level = zoom_level; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ZOOM, zoom_level) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ZOOM", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getZoom(void) -{ - return m_zoom_level; -} - -//====================================================================== - -int SecCamera::setObjectTracking(int object_tracking) -{ - LOGV("%s(object_tracking (%d))", __func__, object_tracking); - - if (object_tracking < OBJECT_TRACKING_OFF || OBJECT_TRACKING_MAX <= object_tracking) { - LOGE("ERR(%s):Invalid object_tracking (%d)", __func__, object_tracking); - return -1; - } - - if (m_object_tracking != object_tracking) { - m_object_tracking = object_tracking; - } - - return 0; -} - -int SecCamera::getObjectTracking(void) -{ - return m_object_tracking; -} - -int SecCamera::getObjectTrackingStatus(void) -{ - int obj_status = 0; - obj_status = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJ_TRACKING_STATUS); - return obj_status; -} - -int SecCamera::setObjectTrackingStartStop(int start_stop) -{ - LOGV("%s(object_tracking_start_stop (%d))", __func__, start_stop); - - if (m_object_tracking_start_stop != start_stop) { - m_object_tracking_start_stop = start_stop; - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJ_TRACKING_START_STOP, start_stop) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJ_TRACKING_START_STOP", __func__); - return -1; - } - } - - return 0; -} - -int SecCamera::setTouchAFStartStop(int start_stop) -{ - LOGV("%s(touch_af_start_stop (%d))", __func__, start_stop); - - if (m_touch_af_start_stop != start_stop) { - m_touch_af_start_stop = start_stop; - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_TOUCH_AF_START_STOP, start_stop) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_TOUCH_AF_START_STOP", __func__); - return -1; - } - } - - return 0; -} - -//====================================================================== - -int SecCamera::setSmartAuto(int smart_auto) -{ - LOGV("%s(smart_auto (%d))", __func__, smart_auto); - - if (smart_auto < SMART_AUTO_OFF || SMART_AUTO_MAX <= smart_auto) { - LOGE("ERR(%s):Invalid smart_auto (%d)", __func__, smart_auto); - return -1; - } - - if (m_smart_auto != smart_auto) { - m_smart_auto = smart_auto; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SMART_AUTO, smart_auto) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SMART_AUTO", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getSmartAuto(void) -{ - return m_smart_auto; -} - -int SecCamera::getAutosceneStatus(void) -{ - int autoscene_status = -1; - - if (getSmartAuto() == SMART_AUTO_ON) { - autoscene_status = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_SMART_AUTO_STATUS); - - if ((autoscene_status < SMART_AUTO_STATUS_AUTO) || (autoscene_status > SMART_AUTO_STATUS_MAX)) { - LOGE("ERR(%s):Invalid getAutosceneStatus (%d)", __func__, autoscene_status); - return -1; - } - } - //LOGV("%s : autoscene_status (%d)", __func__, autoscene_status); - return autoscene_status; -} -//====================================================================== - -int SecCamera::setBeautyShot(int beauty_shot) -{ - LOGV("%s(beauty_shot (%d))", __func__, beauty_shot); - - if (beauty_shot < BEAUTY_SHOT_OFF || BEAUTY_SHOT_MAX <= beauty_shot) { - LOGE("ERR(%s):Invalid beauty_shot (%d)", __func__, beauty_shot); - return -1; - } - - if (m_beauty_shot != beauty_shot) { - m_beauty_shot = beauty_shot; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BEAUTY_SHOT, beauty_shot) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BEAUTY_SHOT", __func__); - return -1; - } - } - - setFaceDetect(FACE_DETECTION_ON_BEAUTY); - } - - return 0; -} - -int SecCamera::getBeautyShot(void) -{ - return m_beauty_shot; -} - -//====================================================================== - -int SecCamera::setVintageMode(int vintage_mode) -{ - LOGV("%s(vintage_mode(%d))", __func__, vintage_mode); - - if (vintage_mode <= VINTAGE_MODE_BASE || VINTAGE_MODE_MAX <= vintage_mode) { - LOGE("ERR(%s):Invalid vintage_mode (%d)", __func__, vintage_mode); - return -1; - } - - if (m_vintage_mode != vintage_mode) { - m_vintage_mode = vintage_mode; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VINTAGE_MODE, vintage_mode) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_VINTAGE_MODE", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getVintageMode(void) -{ - return m_vintage_mode; -} - -//====================================================================== - -int SecCamera::setFocusMode(int focus_mode) -{ - LOGV("%s(focus_mode(%d))", __func__, focus_mode); - - if (FOCUS_MODE_MAX <= focus_mode) { - LOGE("ERR(%s):Invalid focus_mode (%d)", __func__, focus_mode); - return -1; - } - - if (m_params->focus_mode != focus_mode) { - m_params->focus_mode = focus_mode; - - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, focus_mode) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FOCUS_MODE", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getFocusMode(void) -{ - return m_params->focus_mode; -} - -//====================================================================== - -int SecCamera::setFaceDetect(int face_detect) -{ - LOGV("%s(face_detect(%d))", __func__, face_detect); - - if (m_face_detect != face_detect) { - m_face_detect = face_detect; - if (m_flag_camera_start) { - if (m_face_detect != FACE_DETECTION_OFF) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, FOCUS_MODE_AUTO) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FOCUS_MODin face detecion", __func__); - return -1; - } - } - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FACE_DETECTION, face_detect) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FACE_DETECTION", __func__); - return -1; - } - } - } - - return 0; -} - -int SecCamera::getFaceDetect(void) -{ - return m_face_detect; -} - -//====================================================================== - -int SecCamera::setGPSLatitude(const char *gps_latitude) -{ - double conveted_latitude = 0; - LOGV("%s(gps_latitude(%s))", __func__, gps_latitude); - if (gps_latitude == NULL) - m_gps_latitude = 0; - else { - conveted_latitude = atof(gps_latitude); - m_gps_latitude = (long)(conveted_latitude * 10000 / 1); - } - - LOGV("%s(m_gps_latitude(%ld))", __func__, m_gps_latitude); - return 0; -} - -int SecCamera::setGPSLongitude(const char *gps_longitude) -{ - double conveted_longitude = 0; - LOGV("%s(gps_longitude(%s))", __func__, gps_longitude); - if (gps_longitude == NULL) - m_gps_longitude = 0; - else { - conveted_longitude = atof(gps_longitude); - m_gps_longitude = (long)(conveted_longitude * 10000 / 1); - } - - LOGV("%s(m_gps_longitude(%ld))", __func__, m_gps_longitude); - return 0; -} - -int SecCamera::setGPSAltitude(const char *gps_altitude) -{ - double conveted_altitude = 0; - LOGV("%s(gps_altitude(%s))", __func__, gps_altitude); - if (gps_altitude == NULL) - m_gps_altitude = 0; - else { - conveted_altitude = atof(gps_altitude); - m_gps_altitude = (long)(conveted_altitude * 100 / 1); - } - - LOGV("%s(m_gps_altitude(%ld))", __func__, m_gps_altitude); - return 0; -} - -int SecCamera::setGPSTimeStamp(const char *gps_timestamp) -{ - LOGV("%s(gps_timestamp(%s))", __func__, gps_timestamp); - if (gps_timestamp == NULL) - m_gps_timestamp = 0; - else - m_gps_timestamp = atol(gps_timestamp); - - LOGV("%s(m_gps_timestamp(%ld))", __func__, m_gps_timestamp); - return 0; -} - -int SecCamera::setGPSProcessingMethod(const char *gps_processing_method) -{ - LOGV("%s(gps_processing_method(%s))", __func__, gps_processing_method); - memset(mExifInfo.gps_processing_method, 0, sizeof(mExifInfo.gps_processing_method)); - if (gps_processing_method != NULL) { - size_t len = strlen(gps_processing_method); - if (len > sizeof(mExifInfo.gps_processing_method)) { - len = sizeof(mExifInfo.gps_processing_method); - } - memcpy(mExifInfo.gps_processing_method, gps_processing_method, len); - } - return 0; -} - -int SecCamera::setFaceDetectLockUnlock(int facedetect_lockunlock) -{ - LOGV("%s(facedetect_lockunlock(%d))", __func__, facedetect_lockunlock); - - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FACEDETECT_LOCKUNLOCK, facedetect_lockunlock) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FACEDETECT_LOCKUNLOCK", __func__); - return -1; - } - - return 0; -} - -int SecCamera::setObjectPosition(int x, int y) -{ - LOGV("%s(setObjectPosition(x=%d, y=%d))", __func__, x, y); - - if (m_preview_width ==640) - x = x - 80; - - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_X, x) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_X", __func__); - return -1; - } - - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_Y, y) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_Y", __func__); - return -1; - } - - return 0; -} - -//====================================================================== - -int SecCamera::setGamma(int gamma) -{ - LOGV("%s(gamma(%d))", __func__, gamma); - - if (gamma < GAMMA_OFF || GAMMA_MAX <= gamma) { - LOGE("ERR(%s):Invalid gamma (%d)", __func__, gamma); - return -1; - } - - if (m_video_gamma != gamma) { - m_video_gamma = gamma; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_GAMMA, gamma) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_GAMMA", __func__); - return -1; - } - } - } - - return 0; -} - -//====================================================================== - -int SecCamera::setSlowAE(int slow_ae) -{ - LOGV("%s(slow_ae(%d))", __func__, slow_ae); - - if (slow_ae < GAMMA_OFF || GAMMA_MAX <= slow_ae) { - LOGE("ERR(%s):Invalid slow_ae (%d)", __func__, slow_ae); - return -1; - } - - if (m_slow_ae!= slow_ae) { - m_slow_ae = slow_ae; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_SLOW_AE, slow_ae) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_SLOW_AE", __func__); - return -1; - } - } - } - - return 0; -} - -//====================================================================== -int SecCamera::setRecordingSize(int width, int height) -{ - LOGV("%s(width(%d), height(%d))", __func__, width, height); - - m_recording_width = width; - m_recording_height = height; - - return 0; -} - -//====================================================================== - -int SecCamera::setExifOrientationInfo(int orientationInfo) -{ - LOGV("%s(orientationInfo(%d))", __func__, orientationInfo); - - if (orientationInfo < 0) { - LOGE("ERR(%s):Invalid orientationInfo (%d)", __func__, orientationInfo); - return -1; - } - m_exif_orientation = orientationInfo; - - return 0; -} - -//====================================================================== -int SecCamera::setBatchReflection() -{ - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BATCH_REFLECTION, 1) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BATCH_REFLECTION", __func__); - return -1; - } - } - - return 0; -} - -/*Video call*/ -int SecCamera::setVTmode(int vtmode) -{ - LOGV("%s(vtmode (%d))", __func__, vtmode); - - if (vtmode < VT_MODE_OFF || VT_MODE_MAX <= vtmode) { - LOGE("ERR(%s):Invalid vtmode (%d)", __func__, vtmode); - return -1; - } - - if (m_vtmode != vtmode) { - m_vtmode = vtmode; - } - - return 0; -} - -/* Camcorder fix fps */ -int SecCamera::setSensorMode(int sensor_mode) -{ - LOGV("%s(sensor_mode (%d))", __func__, sensor_mode); - - if (sensor_mode < SENSOR_MODE_CAMERA || SENSOR_MODE_MOVIE < sensor_mode) { - LOGE("ERR(%s):Invalid sensor mode (%d)", __func__, sensor_mode); - return -1; - } - - if (m_sensor_mode != sensor_mode) { - m_sensor_mode = sensor_mode; - } - - return 0; -} - -/* Shot mode */ -/* SINGLE = 0 -* CONTINUOUS = 1 -* PANORAMA = 2 -* SMILE = 3 -* SELF = 6 -*/ -int SecCamera::setShotMode(int shot_mode) -{ - LOGV("%s(shot_mode (%d))", __func__, shot_mode); - if (shot_mode < SHOT_MODE_SINGLE || SHOT_MODE_SELF < shot_mode) { - LOGE("ERR(%s):Invalid shot_mode (%d)", __func__, shot_mode); - return -1; - } - m_shot_mode = shot_mode; - - return 0; -} - -int SecCamera::getVTmode(void) -{ - return m_vtmode; -} - -int SecCamera::setBlur(int blur_level) -{ - LOGV("%s(level (%d))", __func__, blur_level); - - if (blur_level < BLUR_LEVEL_0 || BLUR_LEVEL_MAX <= blur_level) { - LOGE("ERR(%s):Invalid level (%d)", __func__, blur_level); - return -1; - } - - if (m_blur_level != blur_level) { - m_blur_level = blur_level; - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VGA_BLUR, blur_level) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_VGA_BLUR", __func__); - return -1; - } - } - } - return 0; -} - -int SecCamera::getBlur(void) -{ - return m_blur_level; -} - -int SecCamera::setDataLineCheck(int chk_dataline) -{ - LOGV("%s(chk_dataline (%d))", __func__, chk_dataline); - - if (chk_dataline < CHK_DATALINE_OFF || CHK_DATALINE_MAX <= chk_dataline) { - LOGE("ERR(%s):Invalid chk_dataline (%d)", __func__, chk_dataline); - return -1; - } - - if (m_chk_dataline != chk_dataline) { - m_chk_dataline = chk_dataline; - } - - return 0; -} - -int SecCamera::getDataLineCheck(void) -{ - return m_chk_dataline; -} - -int SecCamera::setDataLineCheckStop(void) -{ - LOGV("%s", __func__); - - if (m_flag_camera_start) { - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CHECK_DATALINE_STOP, 1) < 0) { - LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_CHECK_DATALINE_STOP", __func__); - return -1; - } - } - return 0; -} - -const __u8* SecCamera::getCameraSensorName(void) -{ - LOGV("%s", __func__); - - return fimc_v4l2_enuminput(m_cam_fd, getCameraId()); -} - -#ifdef ENABLE_ESD_PREVIEW_CHECK -int SecCamera::getCameraSensorESDStatus(void) -{ - LOGV("%s", __func__); - - // 0 : normal operation, 1 : abnormal operation - int status = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_ESD_INT); - - return status; -} -#endif // ENABLE_ESD_PREVIEW_CHECK - -// ====================================================================== -// Jpeg - -int SecCamera::setJpegThumbnailSize(int width, int height) -{ - LOGV("%s(width(%d), height(%d))", __func__, width, height); - - m_jpeg_thumbnail_width = width; - m_jpeg_thumbnail_height = height; - - return 0; -} - -int SecCamera::getJpegThumbnailSize(int *width, int *height) -{ - if (width) - *width = m_jpeg_thumbnail_width; - if (height) - *height = m_jpeg_thumbnail_height; - - return 0; -} - -void SecCamera::setExifFixedAttribute() -{ - char property[PROPERTY_VALUE_MAX]; - - //2 0th IFD TIFF Tags - //3 Maker - property_get("ro.product.brand", property, EXIF_DEF_MAKER); - strncpy((char *)mExifInfo.maker, property, - sizeof(mExifInfo.maker) - 1); - mExifInfo.maker[sizeof(mExifInfo.maker) - 1] = '\0'; - //3 Model - property_get("ro.product.model", property, EXIF_DEF_MODEL); - strncpy((char *)mExifInfo.model, property, - sizeof(mExifInfo.model) - 1); - mExifInfo.model[sizeof(mExifInfo.model) - 1] = '\0'; - //3 Software - property_get("ro.build.id", property, EXIF_DEF_SOFTWARE); - strncpy((char *)mExifInfo.software, property, - sizeof(mExifInfo.software) - 1); - mExifInfo.software[sizeof(mExifInfo.software) - 1] = '\0'; - - //3 YCbCr Positioning - mExifInfo.ycbcr_positioning = EXIF_DEF_YCBCR_POSITIONING; - - //2 0th IFD Exif Private Tags - //3 F Number - mExifInfo.fnumber.num = EXIF_DEF_FNUMBER_NUM; - mExifInfo.fnumber.den = EXIF_DEF_FNUMBER_DEN; - //3 Exposure Program - mExifInfo.exposure_program = EXIF_DEF_EXPOSURE_PROGRAM; - //3 Exif Version - memcpy(mExifInfo.exif_version, EXIF_DEF_EXIF_VERSION, sizeof(mExifInfo.exif_version)); - //3 Aperture - uint32_t av = APEX_FNUM_TO_APERTURE((double)mExifInfo.fnumber.num/mExifInfo.fnumber.den); - mExifInfo.aperture.num = av*EXIF_DEF_APEX_DEN; - mExifInfo.aperture.den = EXIF_DEF_APEX_DEN; - //3 Maximum lens aperture - mExifInfo.max_aperture.num = mExifInfo.aperture.num; - mExifInfo.max_aperture.den = mExifInfo.aperture.den; - //3 Lens Focal Length - if (m_camera_id == CAMERA_ID_BACK) - mExifInfo.focal_length.num = BACK_CAMERA_FOCAL_LENGTH; - else - mExifInfo.focal_length.num = FRONT_CAMERA_FOCAL_LENGTH; - - mExifInfo.focal_length.den = EXIF_DEF_FOCAL_LEN_DEN; - //3 User Comments - strcpy((char *)mExifInfo.user_comment, EXIF_DEF_USERCOMMENTS); - //3 Color Space information - mExifInfo.color_space = EXIF_DEF_COLOR_SPACE; - //3 Exposure Mode - mExifInfo.exposure_mode = EXIF_DEF_EXPOSURE_MODE; - - //2 0th IFD GPS Info Tags - unsigned char gps_version[4] = { 0x02, 0x02, 0x00, 0x00 }; - memcpy(mExifInfo.gps_version_id, gps_version, sizeof(gps_version)); - - //2 1th IFD TIFF Tags - mExifInfo.compression_scheme = EXIF_DEF_COMPRESSION; - mExifInfo.x_resolution.num = EXIF_DEF_RESOLUTION_NUM; - mExifInfo.x_resolution.den = EXIF_DEF_RESOLUTION_DEN; - mExifInfo.y_resolution.num = EXIF_DEF_RESOLUTION_NUM; - mExifInfo.y_resolution.den = EXIF_DEF_RESOLUTION_DEN; - mExifInfo.resolution_unit = EXIF_DEF_RESOLUTION_UNIT; -} - -void SecCamera::setExifChangedAttribute() -{ - //2 0th IFD TIFF Tags - //3 Width - mExifInfo.width = m_snapshot_width; - //3 Height - mExifInfo.height = m_snapshot_height; - //3 Orientation - switch (m_exif_orientation) { - case 0: - mExifInfo.orientation = EXIF_ORIENTATION_UP; - break; - case 90: - mExifInfo.orientation = EXIF_ORIENTATION_90; - break; - case 180: - mExifInfo.orientation = EXIF_ORIENTATION_180; - break; - case 270: - mExifInfo.orientation = EXIF_ORIENTATION_270; - break; - default: - mExifInfo.orientation = EXIF_ORIENTATION_UP; - break; - } - //3 Date time - time_t rawtime; - struct tm *timeinfo; - time(&rawtime); - timeinfo = localtime(&rawtime); - strftime((char *)mExifInfo.date_time, 20, "%Y:%m:%d %H:%M:%S", timeinfo); - - //2 0th IFD Exif Private Tags - //3 Exposure Time - int shutterSpeed = fimc_v4l2_g_ctrl(m_cam_fd, - V4L2_CID_CAMERA_GET_SHT_TIME); - /* TBD - front camera needs to be fixed to support this g_ctrl, - it current returns a negative err value, so avoid putting - odd value into exif for now */ - if (shutterSpeed < 0) { - LOGE("%s: error %d getting shutterSpeed, camera_id = %d, using 100", - __func__, shutterSpeed, m_camera_id); - shutterSpeed = 100; - } - mExifInfo.exposure_time.num = 1; - // x us -> 1/x s */ - mExifInfo.exposure_time.den = (uint32_t)(1000000 / shutterSpeed); - - //3 ISO Speed Rating - int iso = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_GET_ISO); - /* TBD - front camera needs to be fixed to support this g_ctrl, - it current returns a negative err value, so avoid putting - odd value into exif for now */ - if (iso < 0) { - LOGE("%s: error %d getting iso, camera_id = %d, using 100", - __func__, iso, m_camera_id); - iso = ISO_100; - } - switch(iso) { - case ISO_50: - mExifInfo.iso_speed_rating = 50; - break; - case ISO_100: - mExifInfo.iso_speed_rating = 100; - break; - case ISO_200: - mExifInfo.iso_speed_rating = 200; - break; - case ISO_400: - mExifInfo.iso_speed_rating = 400; - break; - case ISO_800: - mExifInfo.iso_speed_rating = 800; - break; - case ISO_1600: - mExifInfo.iso_speed_rating = 1600; - break; - default: - mExifInfo.iso_speed_rating = 100; - break; - } - - uint32_t av, tv, bv, sv, ev; - av = APEX_FNUM_TO_APERTURE((double)mExifInfo.fnumber.num / mExifInfo.fnumber.den); - tv = APEX_EXPOSURE_TO_SHUTTER((double)mExifInfo.exposure_time.num / mExifInfo.exposure_time.den); - sv = APEX_ISO_TO_FILMSENSITIVITY(mExifInfo.iso_speed_rating); - bv = av + tv - sv; - ev = av + tv; - LOGD("Shutter speed=%d us, iso=%d\n", shutterSpeed, mExifInfo.iso_speed_rating); - LOGD("AV=%d, TV=%d, SV=%d\n", av, tv, sv); - - //3 Shutter Speed - mExifInfo.shutter_speed.num = tv*EXIF_DEF_APEX_DEN; - mExifInfo.shutter_speed.den = EXIF_DEF_APEX_DEN; - //3 Brightness - mExifInfo.brightness.num = bv*EXIF_DEF_APEX_DEN; - mExifInfo.brightness.den = EXIF_DEF_APEX_DEN; - //3 Exposure Bias - if (m_params->scene_mode == SCENE_MODE_BEACH_SNOW) { - mExifInfo.exposure_bias.num = EXIF_DEF_APEX_DEN; - mExifInfo.exposure_bias.den = EXIF_DEF_APEX_DEN; - } else { - mExifInfo.exposure_bias.num = 0; - mExifInfo.exposure_bias.den = 0; - } - //3 Metering Mode - switch (m_params->metering) { - case METERING_SPOT: - mExifInfo.metering_mode = EXIF_METERING_SPOT; - break; - case METERING_MATRIX: - mExifInfo.metering_mode = EXIF_METERING_AVERAGE; - break; - case METERING_CENTER: - mExifInfo.metering_mode = EXIF_METERING_CENTER; - break; - default : - mExifInfo.metering_mode = EXIF_METERING_AVERAGE; - break; - } - - //3 Flash - int flash = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_GET_FLASH_ONOFF); - if (flash < 0) - mExifInfo.flash = EXIF_DEF_FLASH; - else - mExifInfo.flash = flash; - - //3 White Balance - if (m_params->white_balance == WHITE_BALANCE_AUTO) - mExifInfo.white_balance = EXIF_WB_AUTO; - else - mExifInfo.white_balance = EXIF_WB_MANUAL; - //3 Scene Capture Type - switch (m_params->scene_mode) { - case SCENE_MODE_PORTRAIT: - mExifInfo.scene_capture_type = EXIF_SCENE_PORTRAIT; - break; - case SCENE_MODE_LANDSCAPE: - mExifInfo.scene_capture_type = EXIF_SCENE_LANDSCAPE; - break; - case SCENE_MODE_NIGHTSHOT: - mExifInfo.scene_capture_type = EXIF_SCENE_NIGHT; - break; - default: - mExifInfo.scene_capture_type = EXIF_SCENE_STANDARD; - break; - } - - //2 0th IFD GPS Info Tags - if (m_gps_latitude != 0 && m_gps_longitude != 0) { - if (m_gps_latitude > 0) - strcpy((char *)mExifInfo.gps_latitude_ref, "N"); - else - strcpy((char *)mExifInfo.gps_latitude_ref, "S"); - - if (m_gps_longitude > 0) - strcpy((char *)mExifInfo.gps_longitude_ref, "E"); - else - strcpy((char *)mExifInfo.gps_longitude_ref, "W"); - - if (m_gps_altitude > 0) - mExifInfo.gps_altitude_ref = 0; - else - mExifInfo.gps_altitude_ref = 1; - - double latitude = fabs(m_gps_latitude / 10000.0); - double longitude = fabs(m_gps_longitude / 10000.0); - double altitude = fabs(m_gps_altitude / 100.0); - - mExifInfo.gps_latitude[0].num = (uint32_t)latitude; - mExifInfo.gps_latitude[0].den = 1; - mExifInfo.gps_latitude[1].num = (uint32_t)((latitude - mExifInfo.gps_latitude[0].num) * 60); - mExifInfo.gps_latitude[1].den = 1; - mExifInfo.gps_latitude[2].num = (uint32_t)((((latitude - mExifInfo.gps_latitude[0].num) * 60) - - mExifInfo.gps_latitude[1].num) * 60); - mExifInfo.gps_latitude[2].den = 1; - - mExifInfo.gps_longitude[0].num = (uint32_t)longitude; - mExifInfo.gps_longitude[0].den = 1; - mExifInfo.gps_longitude[1].num = (uint32_t)((longitude - mExifInfo.gps_longitude[0].num) * 60); - mExifInfo.gps_longitude[1].den = 1; - mExifInfo.gps_longitude[2].num = (uint32_t)((((longitude - mExifInfo.gps_longitude[0].num) * 60) - - mExifInfo.gps_longitude[1].num) * 60); - mExifInfo.gps_longitude[2].den = 1; - - mExifInfo.gps_altitude.num = (uint32_t)altitude; - mExifInfo.gps_altitude.den = 1; - - struct tm tm_data; - gmtime_r(&m_gps_timestamp, &tm_data); - mExifInfo.gps_timestamp[0].num = tm_data.tm_hour; - mExifInfo.gps_timestamp[0].den = 1; - mExifInfo.gps_timestamp[1].num = tm_data.tm_min; - mExifInfo.gps_timestamp[1].den = 1; - mExifInfo.gps_timestamp[2].num = tm_data.tm_sec; - mExifInfo.gps_timestamp[2].den = 1; - snprintf((char*)mExifInfo.gps_datestamp, sizeof(mExifInfo.gps_datestamp), - "%04d:%02d:%02d", tm_data.tm_year + 1900, tm_data.tm_mon, tm_data.tm_mday); - - mExifInfo.enableGps = true; - } else { - mExifInfo.enableGps = false; - } - - //2 1th IFD TIFF Tags - mExifInfo.widthThumb = m_jpeg_thumbnail_width; - mExifInfo.heightThumb = m_jpeg_thumbnail_height; -} - -// ====================================================================== -// Conversions - -inline int SecCamera::m_frameSize(int format, int width, int height) -{ - int size = 0; - - switch (format) { - case V4L2_PIX_FMT_YUV420: - case V4L2_PIX_FMT_NV12: - case V4L2_PIX_FMT_NV21: - size = (width * height * 3 / 2); - break; - - case V4L2_PIX_FMT_NV12T: - size = ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)) + - ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2)); - break; - - case V4L2_PIX_FMT_YUV422P: - case V4L2_PIX_FMT_YUYV: - case V4L2_PIX_FMT_UYVY: - size = (width * height * 2); - break; - - default : - LOGE("ERR(%s):Invalid V4L2 pixel format(%d)\n", __func__, format); - case V4L2_PIX_FMT_RGB565: - size = (width * height * BPP); - break; - } - - return size; -} - -status_t SecCamera::dump(int fd, const Vector &args) -{ - const size_t SIZE = 256; - char buffer[SIZE]; - String8 result; - snprintf(buffer, 255, "dump(%d)\n", fd); - result.append(buffer); - ::write(fd, result.string(), result.size()); - return NO_ERROR; -} - -double SecCamera::jpeg_ratio = 0.7; -int SecCamera::interleaveDataSize = 4261248; -int SecCamera::jpegLineLength = 636; - -}; // namespace android diff --git a/aries/libcamera/SecCamera.h b/aries/libcamera/SecCamera.h deleted file mode 100644 index b846201..0000000 --- a/aries/libcamera/SecCamera.h +++ /dev/null @@ -1,538 +0,0 @@ -/* -** -** Copyright 2008, The Android Open Source Project -** Copyright 2010, Samsung Electronics Co. LTD -** -** 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_SEC_H -#define ANDROID_HARDWARE_CAMERA_SEC_H - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "JpegEncoder.h" - -#include - -namespace android { - -#define ENABLE_ESD_PREVIEW_CHECK - -#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0 -#define LOG_CAMERA LOGD -#define LOG_CAMERA_PREVIEW LOGD - -#define LOG_TIME_DEFINE(n) \ - struct timeval time_start_##n, time_stop_##n; unsigned long log_time_##n = 0; - -#define LOG_TIME_START(n) \ - gettimeofday(&time_start_##n, NULL); - -#define LOG_TIME_END(n) \ - gettimeofday(&time_stop_##n, NULL); log_time_##n = measure_time(&time_start_##n, &time_stop_##n); - -#define LOG_TIME(n) \ - log_time_##n - -#else -#define LOG_CAMERA(...) -#define LOG_CAMERA_PREVIEW(...) -#define LOG_TIME_DEFINE(n) -#define LOG_TIME_START(n) -#define LOG_TIME_END(n) -#define LOG_TIME(n) -#endif - -#define MAX_BACK_CAMERA_PREVIEW_WIDTH 720 -#define MAX_BACK_CAMERA_PREVIEW_HEIGHT 480 -#define MAX_BACK_CAMERA_SNAPSHOT_WIDTH 2560 -#define MAX_BACK_CAMERA_SNAPSHOT_HEIGHT 1920 -#define BACK_CAMERA_POSTVIEW_WIDTH 640 -#define BACK_CAMERA_POSTVIEW_WIDE_WIDTH 800 -#define BACK_CAMERA_POSTVIEW_HEIGHT 480 -#define BACK_CAMERA_POSTVIEW_BPP 16 -#define BACK_CAMERA_THUMBNAIL_WIDTH 320 -#define BACK_CAMERA_THUMBNAIL_HEIGHT 240 -#define BACK_CAMERA_THUMBNAIL_BPP 16 - -#define BACK_CAMERA_FOCAL_LENGTH 379 /* 3.79mm */ - -#define MAX_FRONT_CAMERA_PREVIEW_WIDTH 640 -#define MAX_FRONT_CAMERA_PREVIEW_HEIGHT 480 -#define MAX_FRONT_CAMERA_SNAPSHOT_WIDTH 640 -#define MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT 480 - -#define FRONT_CAMERA_THUMBNAIL_WIDTH 160 -#define FRONT_CAMERA_THUMBNAIL_HEIGHT 120 -#define FRONT_CAMERA_THUMBNAIL_BPP 16 -#define FRONT_CAMERA_FOCAL_LENGTH 130 /* 1.3mm */ - -#define DEFAULT_JPEG_THUMBNAIL_WIDTH 256 -#define DEFAULT_JPEG_THUMBNAIL_HEIGHT 192 - -#ifndef CAMERA_DEV_NAME -#define CAMERA_DEV_NAME "/dev/video0" -#endif -#ifndef CAMERA_DEV_NAME2 -#define CAMERA_DEV_NAME2 "/dev/video2" -#endif - -#define CAMERA_DEV_NAME_TEMP "/data/videotmp_000" -#define CAMERA_DEV_NAME2_TEMP "/data/videotemp_002" - - -#define BPP 2 -#define MIN(x, y) (((x) < (y)) ? (x) : (y)) -#define MAX_BUFFERS 11 - -/* - * V 4 L 2 F I M C E X T E N S I O N S - * - */ -#define V4L2_CID_ROTATION (V4L2_CID_PRIVATE_BASE + 0) -#define V4L2_CID_PADDR_Y (V4L2_CID_PRIVATE_BASE + 1) -#define V4L2_CID_PADDR_CB (V4L2_CID_PRIVATE_BASE + 2) -#define V4L2_CID_PADDR_CR (V4L2_CID_PRIVATE_BASE + 3) -#define V4L2_CID_PADDR_CBCR (V4L2_CID_PRIVATE_BASE + 4) -#define V4L2_CID_STREAM_PAUSE (V4L2_CID_PRIVATE_BASE + 53) - -#define V4L2_CID_CAM_JPEG_MAIN_SIZE (V4L2_CID_PRIVATE_BASE + 32) -#define V4L2_CID_CAM_JPEG_MAIN_OFFSET (V4L2_CID_PRIVATE_BASE + 33) -#define V4L2_CID_CAM_JPEG_THUMB_SIZE (V4L2_CID_PRIVATE_BASE + 34) -#define V4L2_CID_CAM_JPEG_THUMB_OFFSET (V4L2_CID_PRIVATE_BASE + 35) -#define V4L2_CID_CAM_JPEG_POSTVIEW_OFFSET (V4L2_CID_PRIVATE_BASE + 36) -#define V4L2_CID_CAM_JPEG_QUALITY (V4L2_CID_PRIVATE_BASE + 37) - -#define TPATTERN_COLORBAR 1 -#define TPATTERN_HORIZONTAL 2 -#define TPATTERN_VERTICAL 3 - -#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') - -/* FOURCC for FIMC specific */ -#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') -#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') -#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') -#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2') -/* - * U S E R D E F I N E D T Y P E S - * - */ - -struct fimc_buffer { - void *start; - size_t length; -}; - -struct yuv_fmt_list { - const char *name; - const char *desc; - unsigned int fmt; - int depth; - int planes; -}; - -//s1 [Apply factory standard] -struct camsensor_date_info { - unsigned int year; - unsigned int month; - unsigned int date; -}; - - -class SecCamera { -public: - - enum CAMERA_ID { - CAMERA_ID_BACK = 0, - CAMERA_ID_FRONT = 1, - }; - - enum JPEG_QUALITY { - JPEG_QUALITY_ECONOMY = 0, - JPEG_QUALITY_NORMAL = 50, - JPEG_QUALITY_SUPERFINE = 100, - JPEG_QUALITY_MAX, - }; - - enum OBJECT_TRACKING { - OBJECT_TRACKING_OFF, - OBJECT_TRACKING_ON, - OBJECT_TRACKING_MAX, - }; - - /*VT call*/ - enum VT_MODE { - VT_MODE_OFF, - VT_MODE_ON, - VT_MODE_MAX, - }; - - /*Camera sensor mode - Camcorder fix fps*/ - enum SENSOR_MODE { - SENSOR_MODE_CAMERA, - SENSOR_MODE_MOVIE, - }; - - /*Camera Shot mode*/ - enum SHOT_MODE { - SHOT_MODE_SINGLE = 0, - SHOT_MODE_CONTINUOUS = 1, - SHOT_MODE_PANORAMA = 2, - SHOT_MODE_SMILE = 3, - SHOT_MODE_SELF = 6, - }; - - enum CHK_DATALINE { - CHK_DATALINE_OFF, - CHK_DATALINE_ON, - CHK_DATALINE_MAX, - }; - - int m_touch_af_start_stop; - - struct gps_info_latiude { - unsigned int north_south; - unsigned int dgree; - unsigned int minute; - unsigned int second; - } gpsInfoLatitude; - struct gps_info_longitude { - unsigned int east_west; - unsigned int dgree; - unsigned int minute; - unsigned int second; - } gpsInfoLongitude; - struct gps_info_altitude { - unsigned int plus_minus; - unsigned int dgree; - unsigned int minute; - unsigned int second; - } gpsInfoAltitude; - - SecCamera(); - ~SecCamera(); - - static SecCamera* createInstance(void) - { - static SecCamera singleton; - return &singleton; - } - status_t dump(int fd, const Vector& args); - - int flagCreate(void) const; - - int getCameraId(void); - - int startPreview(void); - int stopPreview(void); - - int startRecord(void); - int stopRecord(void); - int getRecordFrame(void); - int releaseRecordFrame(int index); - unsigned int getRecPhyAddrY(int); - unsigned int getRecPhyAddrC(int); - - int getPreview(void); - int setPreviewSize(int width, int height, int pixel_format); - int getPreviewSize(int *width, int *height, int *frame_size); - int getPreviewMaxSize(int *width, int *height); - int getPreviewPixelFormat(void); - int setPreviewImage(int index, unsigned char *buffer, int size); - - int setSnapshotSize(int width, int height); - int getSnapshotSize(int *width, int *height, int *frame_size); - int getSnapshotMaxSize(int *width, int *height); - int setSnapshotPixelFormat(int pixel_format); - int getSnapshotPixelFormat(void); - - unsigned char* getJpeg(unsigned char *snapshot_data, int snapshot_size, int *size); - unsigned char* yuv2Jpeg(unsigned char *raw_data, int raw_size, - int *jpeg_size, - int width, int height, int pixel_format); - - int setJpegThumbnailSize(int width, int height); - int getJpegThumbnailSize(int *width, int *height); - - int setAutofocus(void); - int zoomIn(void); - int zoomOut(void); - - int SetRotate(int angle); - int getRotate(void); - - int setVerticalMirror(void); - int setHorizontalMirror(void); - - int setWhiteBalance(int white_balance); - int getWhiteBalance(void); - - int setBrightness(int brightness); - int getBrightness(void); - - int setImageEffect(int image_effect); - int getImageEffect(void); - - int setSceneMode(int scene_mode); - int getSceneMode(void); - - int setFlashMode(int flash_mode); - int getFlashMode(void); - - int setMetering(int metering_value); - int getMetering(void); - - int setISO(int iso_value); - int getISO(void); - - int setContrast(int contrast_value); - int getContrast(void); - - int setSaturation(int saturation_value); - int getSaturation(void); - - int setSharpness(int sharpness_value); - int getSharpness(void); - - int setWDR(int wdr_value); - int getWDR(void); - - int setAntiShake(int anti_shake); - int getAntiShake(void); - - int setJpegQuality(int jpeg_qality); - int getJpegQuality(void); - - int setZoom(int zoom_level); - int getZoom(void); - - int setObjectTracking(int object_tracking); - int getObjectTracking(void); - int getObjectTrackingStatus(void); - - int setSmartAuto(int smart_auto); - int getSmartAuto(void); - int getAutosceneStatus(void); - - int setBeautyShot(int beauty_shot); - int getBeautyShot(void); - - int setVintageMode(int vintage_mode); - int getVintageMode(void); - - int setFocusMode(int focus_mode); - int getFocusMode(void); - - int setFaceDetect(int face_detect); - int getFaceDetect(void); - - int setGPSLatitude(const char *gps_latitude); - int setGPSLongitude(const char *gps_longitude); - int setGPSAltitude(const char *gps_altitude); - int setGPSTimeStamp(const char *gps_timestamp); - int setGPSProcessingMethod(const char *gps_timestamp); - int cancelAutofocus(void); - int setFaceDetectLockUnlock(int facedetect_lockunlock); - int setObjectPosition(int x, int y); - int setObjectTrackingStartStop(int start_stop); - int setTouchAFStartStop(int start_stop); - int setCAFStatus(int on_off); - int getAutoFocusResult(void); - int setAntiBanding(int anti_banding); - int getPostview(void); - int setRecordingSize(int width, int height); - int setGamma(int gamma); - int setSlowAE(int slow_ae); - int setExifOrientationInfo(int orientationInfo); - int setBatchReflection(void); - int setSnapshotCmd(void); - int endSnapshot(void); - int setCameraSensorReset(void); - int setSensorMode(int sensor_mode); /* Camcorder fix fps */ - int setShotMode(int shot_mode); /* Shot mode */ - /*VT call*/ - int setVTmode(int vtmode); - int getVTmode(void); - int setBlur(int blur_level); - int getBlur(void); - int setDataLineCheck(int chk_dataline); - int getDataLineCheck(void); - int setDataLineCheckStop(void); - int setDefultIMEI(int imei); - int getDefultIMEI(void); - const __u8* getCameraSensorName(void); - int previewPoll(bool preview); -#ifdef ENABLE_ESD_PREVIEW_CHECK - int getCameraSensorESDStatus(void); -#endif // ENABLE_ESD_PREVIEW_CHECK - - int setFrameRate(int frame_rate); - unsigned char* getJpeg(int*, unsigned int*); - int getSnapshotAndJpeg(unsigned char *yuv_buf, unsigned char *jpeg_buf, - unsigned int *output_size); - int getExif(unsigned char *pExifDst, unsigned char *pThumbSrc); - - void getPostViewConfig(int*, int*, int*); - void getThumbnailConfig(int *width, int *height, int *size); - - int getPostViewOffset(void); - int getCameraFd(void); - int getJpegFd(void); - void SetJpgAddr(unsigned char *addr); - unsigned int getPhyAddrY(int); - unsigned int getPhyAddrC(int); - void pausePreview(); - int initCamera(int index); - void DeinitCamera(); - static void setJpegRatio(double ratio) - { - if((ratio < 0) || (ratio > 1)) - return; - - jpeg_ratio = ratio; - } - - static double getJpegRatio() - { - return jpeg_ratio; - } - - static void setInterleaveDataSize(int x) - { - interleaveDataSize = x; - } - - static int getInterleaveDataSize() - { - return interleaveDataSize; - } - - static void setJpegLineLength(int x) - { - jpegLineLength = x; - } - - static int getJpegLineLength() - { - return jpegLineLength; - } - - -private: - v4l2_streamparm m_streamparm; - struct sec_cam_parm *m_params; - int m_flag_init; - - int m_camera_id; - - int m_cam_fd; - - int m_cam_fd_temp; - int m_cam_fd2_temp; - - int m_cam_fd2; - struct pollfd m_events_c2; - int m_flag_record_start; - - int m_preview_v4lformat; - int m_preview_width; - int m_preview_height; - int m_preview_max_width; - int m_preview_max_height; - - int m_snapshot_v4lformat; - int m_snapshot_width; - int m_snapshot_height; - int m_snapshot_max_width; - int m_snapshot_max_height; - - int m_angle; - int m_anti_banding; - int m_wdr; - int m_anti_shake; - int m_zoom_level; - int m_object_tracking; - int m_smart_auto; - int m_beauty_shot; - int m_vintage_mode; - int m_face_detect; - int m_object_tracking_start_stop; - int m_recording_width; - int m_recording_height; - long m_gps_latitude; - long m_gps_longitude; - long m_gps_altitude; - long m_gps_timestamp; - int m_vtmode; - int m_sensor_mode; /*Camcorder fix fps */ - int m_shot_mode; /* Shot mode */ - int m_exif_orientation; - int m_blur_level; - int m_chk_dataline; - int m_video_gamma; - int m_slow_ae; - int m_caf_on_off; - int m_default_imei; - int m_camera_af_flag; - - int m_flag_camera_start; - - int m_jpeg_fd; - int m_jpeg_thumbnail_width; - int m_jpeg_thumbnail_height; - int m_jpeg_quality; - - int m_postview_offset; - -#ifdef ENABLE_ESD_PREVIEW_CHECK - int m_esd_check_count; -#endif // ENABLE_ESD_PREVIEW_CHECK - - exif_attribute_t mExifInfo; - - struct fimc_buffer m_capture_buf; - struct pollfd m_events_c; - - inline int m_frameSize(int format, int width, int height); - - void setExifChangedAttribute(); - void setExifFixedAttribute(); - void resetCamera(); - - static double jpeg_ratio; - static int interleaveDataSize; - static int jpegLineLength; -}; - -extern unsigned long measure_time(struct timeval *start, struct timeval *stop); - -}; // namespace android - -#endif // ANDROID_HARDWARE_CAMERA_SEC_H diff --git a/aries/libcamera/SecCameraHWInterface.cpp b/aries/libcamera/SecCameraHWInterface.cpp deleted file mode 100644 index f019e01..0000000 --- a/aries/libcamera/SecCameraHWInterface.cpp +++ /dev/null @@ -1,2142 +0,0 @@ -/* -** -** Copyright 2008, The Android Open Source Project -** Copyright 2010, Samsung Electronics Co. LTD -** -** 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. -*/ - -#define LOG_NDEBUG 0 -#define LOG_TAG "CameraHardwareSec" -#include - -#include "SecCameraHWInterface.h" -#include -#include -#include - -#if defined(BOARD_USES_OVERLAY) -#include -#include -#define CACHEABLE_BUFFERS 0x1 -#define ALL_BUFFERS_FLUSHED -66 -#endif - -#define VIDEO_COMMENT_MARKER_H 0xFFBE -#define VIDEO_COMMENT_MARKER_L 0xFFBF -#define VIDEO_COMMENT_MARKER_LENGTH 4 -#define JPEG_EOI_MARKER 0xFFD9 -#define HIBYTE(x) (((x) >> 8) & 0xFF) -#define LOBYTE(x) ((x) & 0xFF) - -#define BACK_CAMERA_AUTO_FOCUS_DISTANCES_STR "0.10,1.20,Infinity" -#define BACK_CAMERA_MACRO_FOCUS_DISTANCES_STR "0.10,0.20,Infinity" -#define BACK_CAMERA_INFINITY_FOCUS_DISTANCES_STR "0.10,1.20,Infinity" -#define FRONT_CAMERA_FOCUS_DISTANCES_STR "0.20,0.25,Infinity" - -namespace android { - -struct addrs { - unsigned int addr_y; - unsigned int addr_cbcr; - unsigned int buf_index; - unsigned int reserved; -}; - -struct addrs_cap { - unsigned int addr_y; - unsigned int width; - unsigned int height; -}; - -static const int INITIAL_SKIP_FRAME = 3; -static const int EFFECT_SKIP_FRAME = 1; - -CameraHardwareSec::CameraHardwareSec(int cameraId) - : - mCaptureInProgress(false), - mParameters(), - mPreviewHeap(0), - mRawHeap(0), - mRecordHeap(0), - mJpegHeap(0), - mSecCamera(NULL), - mCameraSensorName(NULL), - mSkipFrame(0), -#if defined(BOARD_USES_OVERLAY) - mUseOverlay(false), - mOverlayBufferIdx(0), -#endif - mNotifyCb(0), - mDataCb(0), - mDataCbTimestamp(0), - mCallbackCookie(0), - mMsgEnabled(0), - mRecordRunning(false), - mPostViewWidth(0), - mPostViewHeight(0), - mPostViewSize(0) -{ - LOGV("%s :", __func__); - int ret = 0; - - mSecCamera = SecCamera::createInstance(); - - if (mSecCamera == NULL) { - LOGE("ERR(%s):Fail on mSecCamera object creation", __func__); - } - - ret = mSecCamera->initCamera(cameraId); - if (ret < 0) { - LOGE("ERR(%s):Fail on mSecCamera init", __func__); - } - - if (mSecCamera->flagCreate() == 0) { - LOGE("ERR(%s):Fail on mSecCamera->flagCreate()", __func__); - } - - int recordHeapSize = sizeof(struct addrs) * kBufferCount; - LOGV("mRecordHeap : MemoryHeapBase(recordHeapSize(%d))", recordHeapSize); - mRecordHeap = new MemoryHeapBase(recordHeapSize); - if (mRecordHeap->getHeapID() < 0) { - LOGE("ERR(%s): Record heap creation fail", __func__); - mRecordHeap.clear(); - } - - mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize); - LOGV("mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d", - mPostViewWidth,mPostViewHeight,mPostViewSize); - - int rawHeapSize = mPostViewSize; - LOGV("mRawHeap : MemoryHeapBase(previewHeapSize(%d))", rawHeapSize); - mRawHeap = new MemoryHeapBase(rawHeapSize); - if (mRawHeap->getHeapID() < 0) { - LOGE("ERR(%s): Raw heap creation fail", __func__); - mRawHeap.clear(); - } - - initDefaultParameters(cameraId); - - mExitAutoFocusThread = false; - mExitPreviewThread = false; - /* whether the PreviewThread is active in preview or stopped. we - * create the thread but it is initially in stopped state. - */ - mPreviewRunning = false; - mPreviewThread = new PreviewThread(this); - mAutoFocusThread = new AutoFocusThread(this); - mPictureThread = new PictureThread(this); -} - -void CameraHardwareSec::initDefaultParameters(int cameraId) -{ - if (mSecCamera == NULL) { - LOGE("ERR(%s):mSecCamera object is NULL", __func__); - return; - } - - CameraParameters p; - CameraParameters ip; - - mCameraSensorName = mSecCamera->getCameraSensorName(); - LOGV("CameraSensorName: %s", mCameraSensorName); - - int preview_max_width = 0; - int preview_max_height = 0; - int snapshot_max_width = 0; - int snapshot_max_height = 0; - - if (cameraId == SecCamera::CAMERA_ID_BACK) { - p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, - "720x480,640x480,320x240,176x144"); - p.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, - "2560x1920,2048x1536,1600x1200,1600x960,640x480"); - } else { - p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, - "640x480,320x240,176x144"); - p.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, - "640x480"); - } - - // If these fail, then we are using an invalid cameraId and we'll leave the - // sizes at zero to catch the error. - if (mSecCamera->getPreviewMaxSize(&preview_max_width, - &preview_max_height) < 0) - LOGE("getPreviewMaxSize fail (%d / %d) \n", - preview_max_width, preview_max_height); - if (mSecCamera->getSnapshotMaxSize(&snapshot_max_width, - &snapshot_max_height) < 0) - LOGE("getSnapshotMaxSize fail (%d / %d) \n", - snapshot_max_width, snapshot_max_height); - - p.setPreviewFormat(CameraParameters::PIXEL_FORMAT_YUV420SP); - p.setPreviewSize(preview_max_width, preview_max_height); - - p.setPictureFormat(CameraParameters::PIXEL_FORMAT_JPEG); - p.setPictureSize(snapshot_max_width, snapshot_max_height); - p.set(CameraParameters::KEY_JPEG_QUALITY, "100"); // maximum quality - - p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS, - CameraParameters::PIXEL_FORMAT_YUV420SP); - p.set(CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS, - CameraParameters::PIXEL_FORMAT_JPEG); - p.set(CameraParameters::KEY_VIDEO_FRAME_FORMAT, - CameraParameters::PIXEL_FORMAT_YUV420SP); - - String8 parameterString; - - if (cameraId == SecCamera::CAMERA_ID_BACK) { - parameterString = CameraParameters::FOCUS_MODE_AUTO; - parameterString.append(","); - parameterString.append(CameraParameters::FOCUS_MODE_INFINITY); - parameterString.append(","); - parameterString.append(CameraParameters::FOCUS_MODE_MACRO); - p.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES, - parameterString.string()); - p.set(CameraParameters::KEY_FOCUS_MODE, - CameraParameters::FOCUS_MODE_AUTO); - p.set(CameraParameters::KEY_FOCUS_DISTANCES, - BACK_CAMERA_AUTO_FOCUS_DISTANCES_STR); - p.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, - "320x240,0x0"); - p.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, "320"); - p.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, "240"); - p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES, "30"); - p.setPreviewFrameRate(30); - } else { - parameterString = CameraParameters::FOCUS_MODE_FIXED; - p.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES, - parameterString.string()); - p.set(CameraParameters::KEY_FOCUS_MODE, - CameraParameters::FOCUS_MODE_FIXED); - p.set(CameraParameters::KEY_FOCUS_DISTANCES, - FRONT_CAMERA_FOCUS_DISTANCES_STR); - p.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, - "160x120,0x0"); - p.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, "160"); - p.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, "120"); - p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES, "15"); - p.setPreviewFrameRate(15); - } - - parameterString = CameraParameters::EFFECT_NONE; - parameterString.append(","); - parameterString.append(CameraParameters::EFFECT_MONO); - parameterString.append(","); - parameterString.append(CameraParameters::EFFECT_NEGATIVE); - parameterString.append(","); - parameterString.append(CameraParameters::EFFECT_SEPIA); - p.set(CameraParameters::KEY_SUPPORTED_EFFECTS, parameterString.string()); - - if (cameraId == SecCamera::CAMERA_ID_BACK) { - parameterString = CameraParameters::FLASH_MODE_ON; - parameterString.append(","); - parameterString.append(CameraParameters::FLASH_MODE_OFF); - parameterString.append(","); - parameterString.append(CameraParameters::FLASH_MODE_AUTO); - parameterString.append(","); - parameterString.append(CameraParameters::FLASH_MODE_TORCH); - p.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, - parameterString.string()); - p.set(CameraParameters::KEY_FLASH_MODE, - CameraParameters::FLASH_MODE_OFF); - - parameterString = CameraParameters::SCENE_MODE_AUTO; - parameterString.append(","); - parameterString.append(CameraParameters::SCENE_MODE_PORTRAIT); - parameterString.append(","); - parameterString.append(CameraParameters::SCENE_MODE_LANDSCAPE); - parameterString.append(","); - parameterString.append(CameraParameters::SCENE_MODE_NIGHT); - parameterString.append(","); - parameterString.append(CameraParameters::SCENE_MODE_BEACH); - parameterString.append(","); - parameterString.append(CameraParameters::SCENE_MODE_SNOW); - parameterString.append(","); - parameterString.append(CameraParameters::SCENE_MODE_SUNSET); - parameterString.append(","); - parameterString.append(CameraParameters::SCENE_MODE_FIREWORKS); - parameterString.append(","); - parameterString.append(CameraParameters::SCENE_MODE_SPORTS); - parameterString.append(","); - parameterString.append(CameraParameters::SCENE_MODE_PARTY); - parameterString.append(","); - parameterString.append(CameraParameters::SCENE_MODE_CANDLELIGHT); - p.set(CameraParameters::KEY_SUPPORTED_SCENE_MODES, - parameterString.string()); - p.set(CameraParameters::KEY_SCENE_MODE, - CameraParameters::SCENE_MODE_AUTO); - - /* we have two ranges, 4-30fps for night mode and - * 15-30fps for all others - */ - p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, "(15000,30000)"); - p.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, "15000,30000"); - - p.set(CameraParameters::KEY_FOCAL_LENGTH, "3.43"); - } else { - p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, "(7500,30000)"); - p.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, "7500,30000"); - - p.set(CameraParameters::KEY_FOCAL_LENGTH, "0.9"); - } - - parameterString = CameraParameters::WHITE_BALANCE_AUTO; - parameterString.append(","); - parameterString.append(CameraParameters::WHITE_BALANCE_INCANDESCENT); - parameterString.append(","); - parameterString.append(CameraParameters::WHITE_BALANCE_FLUORESCENT); - parameterString.append(","); - parameterString.append(CameraParameters::WHITE_BALANCE_DAYLIGHT); - parameterString.append(","); - parameterString.append(CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT); - p.set(CameraParameters::KEY_SUPPORTED_WHITE_BALANCE, - parameterString.string()); - - ip.set("sharpness-min", 0); - ip.set("sharpness-max", 4); - ip.set("saturation-min", 0); - ip.set("saturation-max", 4); - ip.set("contrast-min", 0); - ip.set("contrast-max", 4); - - p.set(CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY, "100"); - - p.set(CameraParameters::KEY_ROTATION, 0); - p.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO); - - p.set(CameraParameters::KEY_EFFECT, CameraParameters::EFFECT_NONE); - - ip.set("sharpness", SHARPNESS_DEFAULT); - ip.set("contrast", CONTRAST_DEFAULT); - ip.set("saturation", SATURATION_DEFAULT); - ip.set("iso", "auto"); - ip.set("metering", "center"); - - ip.set("wdr", 0); - ip.set("chk_dataline", 0); - if (cameraId == SecCamera::CAMERA_ID_FRONT) { - ip.set("vtmode", 0); - ip.set("blur", 0); - } - - p.set(CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE, "51.2"); - p.set(CameraParameters::KEY_VERTICAL_VIEW_ANGLE, "39.4"); - - p.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, "0"); - p.set(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "4"); - p.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-4"); - p.set(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5"); - - mParameters = p; - mInternalParameters = ip; - - /* make sure mSecCamera has all the settings we do. applications - * aren't required to call setParameters themselves (only if they - * want to change something. - */ - setParameters(p); - mSecCamera->setISO(ISO_AUTO); - mSecCamera->setMetering(METERING_CENTER); - mSecCamera->setContrast(CONTRAST_DEFAULT); - mSecCamera->setSharpness(SHARPNESS_DEFAULT); - mSecCamera->setSaturation(SATURATION_DEFAULT); - if (cameraId == SecCamera::CAMERA_ID_BACK) - mSecCamera->setFrameRate(30); - else - mSecCamera->setFrameRate(15); -} - -CameraHardwareSec::~CameraHardwareSec() -{ - LOGV("%s :", __func__); - - singleton.clear(); -} - -sp CameraHardwareSec::getPreviewHeap() const -{ - return mPreviewHeap; -} - -sp CameraHardwareSec::getRawHeap() const -{ - return mRawHeap; -} - -void CameraHardwareSec::setCallbacks(notify_callback notify_cb, - data_callback data_cb, - data_callback_timestamp data_cb_timestamp, - void *user) -{ - mNotifyCb = notify_cb; - mDataCb = data_cb; - mDataCbTimestamp = data_cb_timestamp; - mCallbackCookie = user; -} - -void CameraHardwareSec::enableMsgType(int32_t msgType) -{ - LOGV("%s : msgType = 0x%x, mMsgEnabled before = 0x%x", - __func__, msgType, mMsgEnabled); - mMsgEnabled |= msgType; - LOGV("%s : mMsgEnabled = 0x%x", __func__, mMsgEnabled); -} - -void CameraHardwareSec::disableMsgType(int32_t msgType) -{ - LOGV("%s : msgType = 0x%x, mMsgEnabled before = 0x%x", - __func__, msgType, mMsgEnabled); - mMsgEnabled &= ~msgType; - LOGV("%s : mMsgEnabled = 0x%x", __func__, mMsgEnabled); -} - -bool CameraHardwareSec::msgTypeEnabled(int32_t msgType) -{ - return (mMsgEnabled & msgType); -} - -// --------------------------------------------------------------------------- -void CameraHardwareSec::setSkipFrame(int frame) -{ - Mutex::Autolock lock(mSkipFrameLock); - if (frame < mSkipFrame) - return; - - mSkipFrame = frame; -} - -int CameraHardwareSec::previewThreadWrapper() -{ - LOGI("%s: starting", __func__); - while (1) { - mPreviewLock.lock(); - while (!mPreviewRunning) { - LOGI("%s: calling mSecCamera->stopPreview() and waiting", __func__); - mSecCamera->stopPreview(); - /* signal that we're stopping */ - mPreviewStoppedCondition.signal(); - mPreviewCondition.wait(mPreviewLock); - LOGI("%s: return from wait", __func__); - } - mPreviewLock.unlock(); - - if (mExitPreviewThread) { - LOGI("%s: exiting", __func__); - mSecCamera->stopPreview(); - return 0; - } - previewThread(); - } -} - -int CameraHardwareSec::previewThread() -{ - int index; - nsecs_t timestamp; - unsigned int phyYAddr; - unsigned int phyCAddr; - struct addrs *addrs; - - index = mSecCamera->getPreview(); - if (index < 0) { - LOGE("ERR(%s):Fail on SecCamera->getPreview()", __func__); - return UNKNOWN_ERROR; - } - mSkipFrameLock.lock(); - if (mSkipFrame > 0) { - mSkipFrame--; - mSkipFrameLock.unlock(); - return NO_ERROR; - } - mSkipFrameLock.unlock(); - - timestamp = systemTime(SYSTEM_TIME_MONOTONIC); - - phyYAddr = mSecCamera->getPhyAddrY(index); - phyCAddr = mSecCamera->getPhyAddrC(index); - - if (phyYAddr == 0xffffffff || phyCAddr == 0xffffffff) { - LOGE("ERR(%s):Fail on SecCamera getPhyAddr Y addr = %0x C addr = %0x", __func__, phyYAddr, phyCAddr); - return UNKNOWN_ERROR; - } - - int width, height, frame_size, offset; - - mSecCamera->getPreviewSize(&width, &height, &frame_size); - - offset = (frame_size + 16) * index; - sp buffer = new MemoryBase(mPreviewHeap, offset, frame_size); - - memcpy(static_cast(mPreviewHeap->base()) + (offset + frame_size ), &phyYAddr, 4); - memcpy(static_cast(mPreviewHeap->base()) + (offset + frame_size + 4), &phyCAddr, 4); - -#if defined(BOARD_USES_OVERLAY) - if (mUseOverlay) { - int ret; - overlay_buffer_t overlay_buffer; - - mOverlayBufferIdx ^= 1; - memcpy(static_cast(mPreviewHeap->base()) + offset + frame_size + sizeof(phyYAddr) + sizeof(phyCAddr), - &mOverlayBufferIdx, sizeof(mOverlayBufferIdx)); - - ret = mOverlay->queueBuffer((void*)(static_cast(mPreviewHeap->base()) + (offset + frame_size))); - - if (ret == -1 ) { - LOGE("ERR(%s):overlay queueBuffer fail", __func__); - } else if (ret != ALL_BUFFERS_FLUSHED) { - ret = mOverlay->dequeueBuffer(&overlay_buffer); - if (ret == -1) { - LOGE("ERR(%s):overlay dequeueBuffer fail", __func__); - } - } - } -#endif - - // Notify the client of a new frame. - if (mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME) { - mDataCb(CAMERA_MSG_PREVIEW_FRAME, buffer, mCallbackCookie); - } - - Mutex::Autolock lock(mRecordLock); - if (mRecordRunning == true) { - index = mSecCamera->getRecordFrame(); - if (index < 0) { - LOGE("ERR(%s):Fail on SecCamera->getRecord()", __func__); - return UNKNOWN_ERROR; - } - - phyYAddr = mSecCamera->getRecPhyAddrY(index); - phyCAddr = mSecCamera->getRecPhyAddrC(index); - - if (phyYAddr == 0xffffffff || phyCAddr == 0xffffffff) { - LOGE("ERR(%s):Fail on SecCamera getRectPhyAddr Y addr = %0x C addr = %0x", __func__, phyYAddr, phyCAddr); - return UNKNOWN_ERROR; - } - - addrs = (struct addrs *)mRecordHeap->base(); - - sp buffer = new MemoryBase(mRecordHeap, index * sizeof(struct addrs), sizeof(struct addrs)); - addrs[index].addr_y = phyYAddr; - addrs[index].addr_cbcr = phyCAddr; - addrs[index].buf_index = index; - - // Notify the client of a new frame. - if (mMsgEnabled & CAMERA_MSG_VIDEO_FRAME) { - mDataCbTimestamp(timestamp, CAMERA_MSG_VIDEO_FRAME, buffer, mCallbackCookie); - } else { - mSecCamera->releaseRecordFrame(index); - } - } - - return NO_ERROR; -} - -status_t CameraHardwareSec::startPreview() -{ - int ret = 0; //s1 [Apply factory standard] - - LOGV("%s :", __func__); - - Mutex::Autolock lock(mStateLock); - if (mCaptureInProgress) { - LOGE("%s : capture in progress, not allowed", __func__); - return INVALID_OPERATION; - } - - mPreviewLock.lock(); - if (mPreviewRunning) { - // already running - LOGE("%s : preview thread already running", __func__); - mPreviewLock.unlock(); - return INVALID_OPERATION; - } - - setSkipFrame(INITIAL_SKIP_FRAME); - - ret = mSecCamera->startPreview(); - LOGV("%s : mSecCamera->startPreview() returned %d", __func__, ret); - - if (ret < 0) { - LOGE("ERR(%s):Fail on mSecCamera->startPreview()", __func__); - return -1; //UNKNOWN_ERROR; - } - - if (mPreviewHeap != NULL) - mPreviewHeap.clear(); - - int width, height, frame_size; - - mSecCamera->getPreviewSize(&width, &height, &frame_size); - - int previewHeapSize = (frame_size + 16) * kBufferCount; - - LOGD("MemoryHeapBase(fd(%d), size(%d), width(%d), height(%d))", (int)mSecCamera->getCameraFd(), (size_t)(previewHeapSize), width, height); - mPreviewHeap = new MemoryHeapBase((int)mSecCamera->getCameraFd(), (size_t)(previewHeapSize), (uint32_t)0); - - mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize); - LOGV("CameraHardwareSec: mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d",mPostViewWidth,mPostViewHeight,mPostViewSize); - - mPreviewRunning = true; - mPreviewCondition.signal(); - mPreviewLock.unlock(); - - return NO_ERROR; -} - -#if defined(BOARD_USES_OVERLAY) -bool CameraHardwareSec::useOverlay() -{ - LOGV("%s: returning true", __func__); - return true; -} - -status_t CameraHardwareSec::setOverlay(const sp &overlay) -{ - LOGV("%s :", __func__); - - int overlayWidth = 0; - int overlayHeight = 0; - int overlayFrameSize = 0; - - if (overlay == NULL) { - LOGV("%s : overlay == NULL", __func__); - goto setOverlayFail; - } - LOGV("%s : overlay = %p", __func__, overlay->getHandleRef()); - - if (overlay->getHandleRef()== NULL && mUseOverlay == true) { - if (mOverlay != 0) - mOverlay->destroy(); - - mOverlay = NULL; - mUseOverlay = false; - - return NO_ERROR; - } - - if (overlay->getStatus() != NO_ERROR) { - LOGE("ERR(%s):overlay->getStatus() fail", __func__); - goto setOverlayFail; - } - - mSecCamera->getPreviewSize(&overlayWidth, &overlayHeight, &overlayFrameSize); - - if (overlay->setCrop(0, 0, overlayWidth, overlayHeight) != NO_ERROR) { - LOGE("ERR(%s)::(mOverlay->setCrop(0, 0, %d, %d) fail", __func__, overlayWidth, overlayHeight); - goto setOverlayFail; - } - - mOverlay = overlay; - mUseOverlay = true; - - return NO_ERROR; - -setOverlayFail : - if (mOverlay != 0) - mOverlay->destroy(); - mOverlay = 0; - - mUseOverlay = false; - - return UNKNOWN_ERROR; -} -#endif - -void CameraHardwareSec::stopPreview() -{ - LOGV("%s :", __func__); - - /* request that the preview thread stop. */ - mPreviewLock.lock(); - if (mPreviewRunning) { - mPreviewRunning = false; - mPreviewCondition.signal(); - /* wait until preview thread is stopped */ - mPreviewStoppedCondition.wait(mPreviewLock); - } else { - LOGI("%s : preview not running, doing nothing", __func__); - } - mPreviewLock.unlock(); -} - -bool CameraHardwareSec::previewEnabled() -{ - Mutex::Autolock lock(mPreviewLock); - LOGV("%s : %d", __func__, mPreviewRunning); - return mPreviewRunning; -} - -// --------------------------------------------------------------------------- - -status_t CameraHardwareSec::startRecording() -{ - LOGV("%s :", __func__); - - Mutex::Autolock lock(mRecordLock); - - if (mRecordRunning == false) { - if (mSecCamera->startRecord() < 0) { - LOGE("ERR(%s):Fail on mSecCamera->startRecord()", __func__); - return UNKNOWN_ERROR; - } - mRecordRunning = true; - } - return NO_ERROR; -} - -void CameraHardwareSec::stopRecording() -{ - LOGV("%s :", __func__); - - Mutex::Autolock lock(mRecordLock); - - if (mRecordRunning == true) { - if (mSecCamera->stopRecord() < 0) { - LOGE("ERR(%s):Fail on mSecCamera->stopRecord()", __func__); - return; - } - mRecordRunning = false; - } -} - -bool CameraHardwareSec::recordingEnabled() -{ - LOGV("%s :", __func__); - - return mRecordRunning; -} - -void CameraHardwareSec::releaseRecordingFrame(const sp& mem) -{ - ssize_t offset; - sp heap = mem->getMemory(&offset, NULL); - struct addrs *addrs = (struct addrs *)((uint8_t *)heap->base() + offset); - - mSecCamera->releaseRecordFrame(addrs->buf_index); -} - -// --------------------------------------------------------------------------- - -int CameraHardwareSec::autoFocusThread() -{ - int count =0; - int af_status =0 ; - - LOGV("%s : starting", __func__); - - /* block until we're told to start. we don't want to use - * a restartable thread and requestExitAndWait() in cancelAutoFocus() - * because it would cause deadlock between our callbacks and the - * caller of cancelAutoFocus() which both want to grab the same lock - * in CameraServices layer. - */ - mFocusLock.lock(); - /* check early exit request */ - if (mExitAutoFocusThread) { - mFocusLock.unlock(); - LOGV("%s : exiting on request0", __func__); - return NO_ERROR; - } - mFocusCondition.wait(mFocusLock); - /* check early exit request */ - if (mExitAutoFocusThread) { - mFocusLock.unlock(); - LOGV("%s : exiting on request1", __func__); - return NO_ERROR; - } - mFocusLock.unlock(); - - LOGV("%s : calling setAutoFocus", __func__); - if (mSecCamera->setAutofocus() < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setAutofocus()", __func__); - return UNKNOWN_ERROR; - } - - af_status = mSecCamera->getAutoFocusResult(); - - int i; - - i = 0; - - af_status = mSecCamera->getAutoFocusResult(); - - while(af_status == 0x05 && i < 100) - { - LOGV("%s : AF Result == 0X05 sleeping!!", __func__); - usleep(50000); - af_status = mSecCamera->getAutoFocusResult(); - i++; - } - - LOGV("%s : AF Result == %d", __func__, af_status); - - if (af_status == 0x02) { - LOGV("%s : AF Success!!", __func__); - if (mMsgEnabled & CAMERA_MSG_FOCUS) - mNotifyCb(CAMERA_MSG_FOCUS, true, 0, mCallbackCookie); - } -//FIXME: determine that the user cancled the AF -#if 0 - else if (af_status == 0x02) { - LOGV("%s : AF Cancelled !!", __func__); - if (mMsgEnabled & CAMERA_MSG_FOCUS) { - /* CAMERA_MSG_FOCUS only takes a bool. true for - * finished and false for failure. cancel is still - * considered a true result. - */ - mNotifyCb(CAMERA_MSG_FOCUS, true, 0, mCallbackCookie); - } - } -#endif - else { - LOGV("%s : AF Fail !!", __func__); - LOGV("%s : mMsgEnabled = 0x%x", __func__, mMsgEnabled); - if (mMsgEnabled & CAMERA_MSG_FOCUS) - mNotifyCb(CAMERA_MSG_FOCUS, false, 0, mCallbackCookie); - } - - LOGV("%s : exiting with no error", __func__); - return NO_ERROR; -} - -status_t CameraHardwareSec::autoFocus() -{ - LOGV("%s :", __func__); - /* signal autoFocusThread to run once */ - mFocusCondition.signal(); - return NO_ERROR; -} - -/* 2009.10.14 by icarus for added interface */ -status_t CameraHardwareSec::cancelAutoFocus() -{ - LOGV("%s :", __func__); - - if (mSecCamera->cancelAutofocus() < 0) { - LOGE("ERR(%s):Fail on mSecCamera->cancelAutofocus()", __func__); - return UNKNOWN_ERROR; - } - - return NO_ERROR; -} - -int CameraHardwareSec::save_jpeg( unsigned char *real_jpeg, int jpeg_size) -{ - FILE *yuv_fp = NULL; - char filename[100], *buffer = NULL; - - /* file create/open, note to "wb" */ - yuv_fp = fopen("/data/camera_dump.jpeg", "wb"); - if (yuv_fp == NULL) { - LOGE("Save jpeg file open error"); - return -1; - } - - LOGV("[BestIQ] real_jpeg size ========> %d\n", jpeg_size); - buffer = (char *) malloc(jpeg_size); - if (buffer == NULL) { - LOGE("Save YUV] buffer alloc failed"); - if (yuv_fp) - fclose(yuv_fp); - - return -1; - } - - memcpy(buffer, real_jpeg, jpeg_size); - - fflush(stdout); - - fwrite(buffer, 1, jpeg_size, yuv_fp); - - fflush(yuv_fp); - - if (yuv_fp) - fclose(yuv_fp); - if (buffer) - free(buffer); - - return 0; -} - -void CameraHardwareSec::save_postview(const char *fname, uint8_t *buf, uint32_t size) -{ - int nw; - int cnt = 0; - uint32_t written = 0; - - LOGD("opening file [%s]\n", fname); - int fd = open(fname, O_RDWR | O_CREAT); - if (fd < 0) { - LOGE("failed to create file [%s]: %s", fname, strerror(errno)); - return; - } - - LOGD("writing %d bytes to file [%s]\n", size, fname); - while (written < size) { - nw = ::write(fd, buf + written, size - written); - if (nw < 0) { - LOGE("failed to write to file %d [%s]: %s",written,fname, strerror(errno)); - break; - } - written += nw; - cnt++; - } - LOGD("done writing %d bytes to file [%s] in %d passes\n",size, fname, cnt); - ::close(fd); -} - -bool CameraHardwareSec::scaleDownYuv422(char *srcBuf, uint32_t srcWidth, uint32_t srcHeight, - char *dstBuf, uint32_t dstWidth, uint32_t dstHeight) -{ - int32_t step_x, step_y; - int32_t iXsrc, iXdst; - int32_t x, y, src_y_start_pos, dst_pos, src_pos; - - if (dstWidth % 2 != 0 || dstHeight % 2 != 0){ - LOGE("scale_down_yuv422: invalid width, height for scaling"); - return false; - } - - step_x = srcWidth / dstWidth; - step_y = srcHeight / dstHeight; - - dst_pos = 0; - for (uint32_t y = 0; y < dstHeight; y++) { - src_y_start_pos = (y * step_y * (srcWidth * 2)); - - for (uint32_t x = 0; x < dstWidth; x += 2) { - src_pos = src_y_start_pos + (x * (step_x * 2)); - - dstBuf[dst_pos++] = srcBuf[src_pos ]; - dstBuf[dst_pos++] = srcBuf[src_pos + 1]; - dstBuf[dst_pos++] = srcBuf[src_pos + 2]; - dstBuf[dst_pos++] = srcBuf[src_pos + 3]; - } - } - - return true; -} - -bool CameraHardwareSec::YUY2toNV21(void *srcBuf, void *dstBuf, uint32_t srcWidth, uint32_t srcHeight) -{ - int32_t x, y, src_y_start_pos, dst_cbcr_pos, dst_pos, src_pos; - unsigned char *srcBufPointer = (unsigned char *)srcBuf; - unsigned char *dstBufPointer = (unsigned char *)dstBuf; - - dst_pos = 0; - dst_cbcr_pos = srcWidth*srcHeight; - for (uint32_t y = 0; y < srcHeight; y++) { - src_y_start_pos = (y * (srcWidth * 2)); - - for (uint32_t x = 0; x < (srcWidth * 2); x += 2) { - src_pos = src_y_start_pos + x; - - dstBufPointer[dst_pos++] = srcBufPointer[src_pos]; - } - } - for (uint32_t y = 0; y < srcHeight; y += 2) { - src_y_start_pos = (y * (srcWidth * 2)); - - for (uint32_t x = 0; x < (srcWidth * 2); x += 4) { - src_pos = src_y_start_pos + x; - - dstBufPointer[dst_cbcr_pos++] = srcBufPointer[src_pos + 3]; - dstBufPointer[dst_cbcr_pos++] = srcBufPointer[src_pos + 1]; - } - } - - return true; -} - -int CameraHardwareSec::pictureThread() -{ - LOGV("%s :", __func__); - - int jpeg_size = 0; - int ret = NO_ERROR; - unsigned char *jpeg_data = NULL; - int postview_offset = 0; - unsigned char *postview_data = NULL; - - unsigned char *addr = NULL; - int mPostViewWidth, mPostViewHeight, mPostViewSize; - int mThumbWidth, mThumbHeight, mThumbSize; - int cap_width, cap_height, cap_frame_size; - - unsigned int output_size = 0; - - mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize); - mSecCamera->getThumbnailConfig(&mThumbWidth, &mThumbHeight, &mThumbSize); - int postviewHeapSize = mPostViewSize; - mSecCamera->getSnapshotSize(&cap_width, &cap_height, &cap_frame_size); - int mJpegHeapSize; - if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) - mJpegHeapSize = cap_frame_size * SecCamera::getJpegRatio(); - else - mJpegHeapSize = cap_frame_size; - - LOG_TIME_DEFINE(0) - LOG_TIME_START(0) - - sp buffer = new MemoryBase(mRawHeap, 0, mPostViewSize + 8); - - struct addrs_cap *addrs = (struct addrs_cap *)mRawHeap->base(); - - addrs[0].width = mPostViewWidth; - addrs[0].height = mPostViewHeight; - LOGV("[5B] mPostViewWidth = %d mPostViewHeight = %d\n",mPostViewWidth,mPostViewHeight); - - sp JpegHeap = new MemoryHeapBase(mJpegHeapSize); - sp PostviewHeap = new MemoryHeapBase(mPostViewSize); - sp ThumbnailHeap = new MemoryHeapBase(mThumbSize); - - if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE) { - LOG_TIME_DEFINE(1) - LOG_TIME_START(1) - - int picture_size, picture_width, picture_height; - mSecCamera->getSnapshotSize(&picture_width, &picture_height, &picture_size); - int picture_format = mSecCamera->getSnapshotPixelFormat(); - - unsigned int phyAddr; - - // Modified the shutter sound timing for Jpeg capture - if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) - mSecCamera->setSnapshotCmd(); - if (mMsgEnabled & CAMERA_MSG_SHUTTER) { - mNotifyCb(CAMERA_MSG_SHUTTER, 0, 0, mCallbackCookie); - } - - if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK){ - jpeg_data = mSecCamera->getJpeg(&jpeg_size, &phyAddr); - if (jpeg_data == NULL) { - LOGE("ERR(%s):Fail on SecCamera->getSnapshot()", __func__); - ret = UNKNOWN_ERROR; - } - } else { - if (mSecCamera->getSnapshotAndJpeg((unsigned char*)PostviewHeap->base(), - (unsigned char*)JpegHeap->base(), &output_size) < 0) { - mStateLock.lock(); - mCaptureInProgress = false; - mStateLock.unlock(); - return UNKNOWN_ERROR; - } - LOGI("snapshotandjpeg done\n"); - } - - addrs[0].addr_y = phyAddr; - - LOG_TIME_END(1) - LOG_CAMERA("getSnapshotAndJpeg interval: %lu us", LOG_TIME(1)); - } - - /* the capture is done at this point so we can allow sensor commands - * again, we still need to do jpeg and thumbnail processing, but the - * sensor is available for something else - */ - mStateLock.lock(); - mCaptureInProgress = false; - mStateLock.unlock(); - - if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE) { - mDataCb(CAMERA_MSG_RAW_IMAGE, buffer, mCallbackCookie); - } - - if (mMsgEnabled & CAMERA_MSG_COMPRESSED_IMAGE) { - - memcpy(JpegHeap->base (), jpeg_data, jpeg_size + 2); - - int JpegExifSize; - sp ExifHeap = new MemoryHeapBase(EXIF_FILE_SIZE + JPG_STREAM_BUF_SIZE); - JpegExifSize = mSecCamera->getExif((unsigned char *)ExifHeap->base(), - (unsigned char *)ThumbnailHeap->base()); - - LOGV("JpegExifSize=%d", JpegExifSize); - - if (JpegExifSize < 0) { - ret = UNKNOWN_ERROR; - goto out; - } - - unsigned char *ExifStart = (unsigned char *)JpegHeap->base() + 2; - unsigned char *ImageStart = ExifStart + JpegExifSize; - memmove(ImageStart, ExifStart, jpeg_size - 2); - memcpy(ExifStart, ExifHeap->base(), JpegExifSize); - - sp mem = new MemoryBase(JpegHeap, 0, jpeg_size + JpegExifSize); - - mDataCb(CAMERA_MSG_COMPRESSED_IMAGE, mem, mCallbackCookie); - } - - LOG_TIME_END(0) - LOG_CAMERA("pictureThread interval: %lu us", LOG_TIME(0)); -out: - LOGV("%s : pictureThread end", __func__); - return ret; -} - -status_t CameraHardwareSec::takePicture() -{ - LOGV("%s :", __func__); - - stopPreview(); - - Mutex::Autolock lock(mStateLock); - if (mCaptureInProgress) { - LOGE("%s : capture already in progress", __func__); - return INVALID_OPERATION; - } - - if (mPictureThread->run("CameraPictureThread", PRIORITY_DEFAULT) != NO_ERROR) { - LOGE("%s : couldn't run picture thread", __func__); - return INVALID_OPERATION; - } - mCaptureInProgress = true; - - return NO_ERROR; -} - -status_t CameraHardwareSec::cancelPicture() -{ - mPictureThread->requestExitAndWait(); - - return NO_ERROR; -} - -bool CameraHardwareSec::CheckVideoStartMarker(unsigned char *pBuf) -{ - if (!pBuf) { - LOGE("CheckVideoStartMarker() => pBuf is NULL\n"); - return false; - } - - if (HIBYTE(VIDEO_COMMENT_MARKER_H) == * pBuf && LOBYTE(VIDEO_COMMENT_MARKER_H) == *(pBuf + 1) && - HIBYTE(VIDEO_COMMENT_MARKER_L) == *(pBuf + 2) && LOBYTE(VIDEO_COMMENT_MARKER_L) == *(pBuf + 3)) - return true; - - return false; -} - -bool CameraHardwareSec::CheckEOIMarker(unsigned char *pBuf) -{ - if (!pBuf) { - LOGE("CheckEOIMarker() => pBuf is NULL\n"); - return false; - } - - // EOI marker [FF D9] - if (HIBYTE(JPEG_EOI_MARKER) == *pBuf && LOBYTE(JPEG_EOI_MARKER) == *(pBuf + 1)) - return true; - - return false; -} - -bool CameraHardwareSec::FindEOIMarkerInJPEG(unsigned char *pBuf, int dwBufSize, int *pnJPEGsize) -{ - if (NULL == pBuf || 0 >= dwBufSize) { - LOGE("FindEOIMarkerInJPEG() => There is no contents."); - return false; - } - - unsigned char *pBufEnd = pBuf + dwBufSize; - - while (pBuf < pBufEnd) { - if (CheckEOIMarker(pBuf++)) - return true; - - (*pnJPEGsize)++; - } - - return false; -} - -bool CameraHardwareSec::SplitFrame(unsigned char *pFrame, int dwSize, - int dwJPEGLineLength, int dwVideoLineLength, int dwVideoHeight, - void *pJPEG, int *pdwJPEGSize, - void *pVideo, int *pdwVideoSize) -{ - LOGV("===========SplitFrame Start=============="); - - if (NULL == pFrame || 0 >= dwSize) { - LOGE("There is no contents.\r\n"); - return false; - } - - if (0 == dwJPEGLineLength || 0 == dwVideoLineLength) { - LOGE("There in no input information for decoding interleaved jpeg"); - return false; - } - - unsigned char *pSrc = pFrame; - unsigned char *pSrcEnd = pFrame + dwSize; - - unsigned char *pJ = (unsigned char *)pJPEG; - int dwJSize = 0; - unsigned char *pV = (unsigned char *)pVideo; - int dwVSize = 0; - - bool bRet = false; - bool isFinishJpeg = false; - - while (pSrc < pSrcEnd) { - // Check video start marker - if (CheckVideoStartMarker(pSrc)) { - int copyLength; - - if (pSrc + dwVideoLineLength <= pSrcEnd) - copyLength = dwVideoLineLength; - else - copyLength = pSrcEnd - pSrc - VIDEO_COMMENT_MARKER_LENGTH; - - // Copy video data - if (pV) { - memcpy(pV, pSrc + VIDEO_COMMENT_MARKER_LENGTH, copyLength); - pV += copyLength; - dwVSize += copyLength; - } - - pSrc += copyLength + VIDEO_COMMENT_MARKER_LENGTH; - } else { - // Copy pure JPEG data - int size = 0; - int dwCopyBufLen = dwJPEGLineLength <= pSrcEnd-pSrc ? dwJPEGLineLength : pSrcEnd - pSrc; - - if (FindEOIMarkerInJPEG((unsigned char *)pSrc, dwCopyBufLen, &size)) { - isFinishJpeg = true; - size += 2; // to count EOF marker size - } else { - if ((dwCopyBufLen == 1) && (pJPEG < pJ)) { - unsigned char checkBuf[2] = { *(pJ - 1), *pSrc }; - - if (CheckEOIMarker(checkBuf)) - isFinishJpeg = true; - } - size = dwCopyBufLen; - } - - memcpy(pJ, pSrc, size); - - dwJSize += size; - - pJ += dwCopyBufLen; - pSrc += dwCopyBufLen; - } - if (isFinishJpeg) - break; - } - - if (isFinishJpeg) { - bRet = true; - if(pdwJPEGSize) - *pdwJPEGSize = dwJSize; - if(pdwVideoSize) - *pdwVideoSize = dwVSize; - } else { - LOGE("DecodeInterleaveJPEG_WithOutDT() => Can not find EOI"); - bRet = false; - if(pdwJPEGSize) - *pdwJPEGSize = 0; - if(pdwVideoSize) - *pdwVideoSize = 0; - } - LOGV("===========SplitFrame end=============="); - - return bRet; -} - -int CameraHardwareSec::decodeInterleaveData(unsigned char *pInterleaveData, - int interleaveDataSize, - int yuvWidth, - int yuvHeight, - int *pJpegSize, - void *pJpegData, - void *pYuvData) -{ - if (pInterleaveData == NULL) - return false; - - bool ret = true; - unsigned int *interleave_ptr = (unsigned int *)pInterleaveData; - unsigned char *jpeg_ptr = (unsigned char *)pJpegData; - unsigned char *yuv_ptr = (unsigned char *)pYuvData; - unsigned char *p; - int jpeg_size = 0; - int yuv_size = 0; - - int i = 0; - - LOGV("decodeInterleaveData Start~~~"); - while (i < interleaveDataSize) { - if ((*interleave_ptr == 0xFFFFFFFF) || (*interleave_ptr == 0x02FFFFFF) || - (*interleave_ptr == 0xFF02FFFF)) { - // Padding Data -// LOGE("%d(%x) padding data\n", i, *interleave_ptr); - interleave_ptr++; - i += 4; - } - else if ((*interleave_ptr & 0xFFFF) == 0x05FF) { - // Start-code of YUV Data -// LOGE("%d(%x) yuv data\n", i, *interleave_ptr); - p = (unsigned char *)interleave_ptr; - p += 2; - i += 2; - - // Extract YUV Data - if (pYuvData != NULL) { - memcpy(yuv_ptr, p, yuvWidth * 2); - yuv_ptr += yuvWidth * 2; - yuv_size += yuvWidth * 2; - } - p += yuvWidth * 2; - i += yuvWidth * 2; - - // Check End-code of YUV Data - if ((*p == 0xFF) && (*(p + 1) == 0x06)) { - interleave_ptr = (unsigned int *)(p + 2); - i += 2; - } else { - ret = false; - break; - } - } else { - // Extract JPEG Data -// LOGE("%d(%x) jpg data, jpeg_size = %d bytes\n", i, *interleave_ptr, jpeg_size); - if (pJpegData != NULL) { - memcpy(jpeg_ptr, interleave_ptr, 4); - jpeg_ptr += 4; - jpeg_size += 4; - } - interleave_ptr++; - i += 4; - } - } - if (ret) { - if (pJpegData != NULL) { - // Remove Padding after EOI - for (i = 0; i < 3; i++) { - if (*(--jpeg_ptr) != 0xFF) { - break; - } - jpeg_size--; - } - *pJpegSize = jpeg_size; - - } - // Check YUV Data Size - if (pYuvData != NULL) { - if (yuv_size != (yuvWidth * yuvHeight * 2)) { - ret = false; - } - } - } - LOGV("decodeInterleaveData End~~~"); - return ret; -} - -status_t CameraHardwareSec::dump(int fd, const Vector& args) const -{ - const size_t SIZE = 256; - char buffer[SIZE]; - String8 result; - - if (mSecCamera != 0) { - mSecCamera->dump(fd, args); - mParameters.dump(fd, args); - mInternalParameters.dump(fd, args); - snprintf(buffer, 255, " preview running(%s)\n", mPreviewRunning?"true": "false"); - result.append(buffer); - } else { - result.append("No camera client yet.\n"); - } - write(fd, result.string(), result.size()); - return NO_ERROR; -} - -status_t CameraHardwareSec::setParameters(const CameraParameters& params) -{ - LOGV("%s :", __func__); - - status_t ret = NO_ERROR; - - /* if someone calls us while picture thread is running, it could screw - * up the sensor quite a bit so return error. we can't wait because - * that would cause deadlock with the callbacks - */ - mStateLock.lock(); - if (mCaptureInProgress) { - mStateLock.unlock(); - LOGE("%s : capture in progress, not allowed", __func__); - return UNKNOWN_ERROR; - } - mStateLock.unlock(); - - // preview size - int new_preview_width = 0; - int new_preview_height = 0; - params.getPreviewSize(&new_preview_width, &new_preview_height); - const char *new_str_preview_format = params.getPreviewFormat(); - LOGV("%s : new_preview_width x new_preview_height = %dx%d, format = %s", - __func__, new_preview_width, new_preview_height, new_str_preview_format); - - if (0 < new_preview_width && 0 < new_preview_height && new_str_preview_format != NULL) { - int new_preview_format = 0; - - if (!strcmp(new_str_preview_format, - CameraParameters::PIXEL_FORMAT_RGB565)) - new_preview_format = V4L2_PIX_FMT_RGB565; - else if (!strcmp(new_str_preview_format, - CameraParameters::PIXEL_FORMAT_YUV420SP)) - new_preview_format = V4L2_PIX_FMT_NV21; - else if (!strcmp(new_str_preview_format, "yuv420sp_custom")) - new_preview_format = V4L2_PIX_FMT_NV12T; - else if (!strcmp(new_str_preview_format, "yuv420p")) - new_preview_format = V4L2_PIX_FMT_YUV420; - else if (!strcmp(new_str_preview_format, "yuv422i")) - new_preview_format = V4L2_PIX_FMT_YUYV; - else if (!strcmp(new_str_preview_format, "yuv422p")) - new_preview_format = V4L2_PIX_FMT_YUV422P; - else - new_preview_format = V4L2_PIX_FMT_NV21; //for 3rd party - - if (mSecCamera->setPreviewSize(new_preview_width, new_preview_height, new_preview_format) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setPreviewSize(width(%d), height(%d), format(%d))", - __func__, new_preview_width, new_preview_height, new_preview_format); - ret = UNKNOWN_ERROR; - } else { - mParameters.setPreviewSize(new_preview_width, new_preview_height); - mParameters.setPreviewFormat(new_str_preview_format); - } -#if defined(BOARD_USES_OVERLAY) - if (mUseOverlay == true && mOverlay != 0) { - if (mOverlay->setCrop(0, 0, new_preview_width, new_preview_height) != NO_ERROR) { - LOGE("ERR(%s)::(mOverlay->setCrop(0, 0, %d, %d) fail", - __func__, new_preview_width, new_preview_height); - } - } -#endif - } - - int new_picture_width = 0; - int new_picture_height = 0; - - params.getPictureSize(&new_picture_width, &new_picture_height); - LOGV("%s : new_picture_width x new_picture_height = %dx%d", __func__, new_picture_width, new_picture_height); - if (0 < new_picture_width && 0 < new_picture_height) { - if (mSecCamera->setSnapshotSize(new_picture_width, new_picture_height) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setSnapshotSize(width(%d), height(%d))", - __func__, new_picture_width, new_picture_height); - ret = UNKNOWN_ERROR; - } else { - mParameters.setPictureSize(new_picture_width, new_picture_height); - } - } - - // picture format - const char *new_str_picture_format = params.getPictureFormat(); - LOGV("%s : new_str_picture_format %s", __func__, new_str_picture_format); - if (new_str_picture_format != NULL) { - int new_picture_format = 0; - - if (!strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_RGB565)) - new_picture_format = V4L2_PIX_FMT_RGB565; - else if (!strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_YUV420SP)) - new_picture_format = V4L2_PIX_FMT_NV21; - else if (!strcmp(new_str_picture_format, "yuv420sp_custom")) - new_picture_format = V4L2_PIX_FMT_NV12T; - else if (!strcmp(new_str_picture_format, "yuv420p")) - new_picture_format = V4L2_PIX_FMT_YUV420; - else if (!strcmp(new_str_picture_format, "yuv422i")) - new_picture_format = V4L2_PIX_FMT_YUYV; - else if (!strcmp(new_str_picture_format, "uyv422i_custom")) //Zero copy UYVY format - new_picture_format = V4L2_PIX_FMT_UYVY; - else if (!strcmp(new_str_picture_format, "uyv422i")) //Non-zero copy UYVY format - new_picture_format = V4L2_PIX_FMT_UYVY; - else if (!strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_JPEG)) - new_picture_format = V4L2_PIX_FMT_YUYV; - else if (!strcmp(new_str_picture_format, "yuv422p")) - new_picture_format = V4L2_PIX_FMT_YUV422P; - else - new_picture_format = V4L2_PIX_FMT_NV21; //for 3rd party - - if (mSecCamera->setSnapshotPixelFormat(new_picture_format) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setSnapshotPixelFormat(format(%d))", __func__, new_picture_format); - ret = UNKNOWN_ERROR; - } else { - mParameters.setPictureFormat(new_str_picture_format); - } - } - - //JPEG image quality - int new_jpeg_quality = params.getInt(CameraParameters::KEY_JPEG_QUALITY); - LOGV("%s : new_jpeg_quality %d", __func__, new_jpeg_quality); - /* we ignore bad values */ - if (new_jpeg_quality >=1 && new_jpeg_quality <= 100) { - if (mSecCamera->setJpegQuality(new_jpeg_quality) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setJpegQuality(quality(%d))", __func__, new_jpeg_quality); - ret = UNKNOWN_ERROR; - } else { - mParameters.set(CameraParameters::KEY_JPEG_QUALITY, new_jpeg_quality); - } - } - - // JPEG thumbnail size - int new_jpeg_thumbnail_width = params.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH); - int new_jpeg_thumbnail_height= params.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT); - if (0 <= new_jpeg_thumbnail_width && 0 <= new_jpeg_thumbnail_height) { - if (mSecCamera->setJpegThumbnailSize(new_jpeg_thumbnail_width, new_jpeg_thumbnail_height) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setJpegThumbnailSize(width(%d), height(%d))", __func__, new_jpeg_thumbnail_width, new_jpeg_thumbnail_height); - ret = UNKNOWN_ERROR; - } else { - mParameters.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, new_jpeg_thumbnail_width); - mParameters.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, new_jpeg_thumbnail_height); - } - } - - // frame rate - int new_frame_rate = params.getPreviewFrameRate(); - /* ignore any fps request, we're determine fps automatically based - * on scene mode. don't return an error because it causes CTS failure. - */ - if (new_frame_rate != mParameters.getPreviewFrameRate()) { - LOGW("WARN(%s): request for preview frame %d not allowed, != %d\n", - __func__, new_frame_rate, mParameters.getPreviewFrameRate()); - } - - // rotation - int new_rotation = params.getInt(CameraParameters::KEY_ROTATION); - LOGV("%s : new_rotation %d", __func__, new_rotation); - if (0 <= new_rotation) { - LOGV("%s : set orientation:%d\n", __func__, new_rotation); - if (mSecCamera->setExifOrientationInfo(new_rotation) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setExifOrientationInfo(%d)", __func__, new_rotation); - ret = UNKNOWN_ERROR; - } else { - mParameters.set(CameraParameters::KEY_ROTATION, new_rotation); - } - } - - // brightness - int new_exposure_compensation = params.getInt(CameraParameters::KEY_EXPOSURE_COMPENSATION); - int max_exposure_compensation = params.getInt(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION); - int min_exposure_compensation = params.getInt(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION); - LOGV("%s : new_exposure_compensation %d", __func__, new_exposure_compensation); - if ((min_exposure_compensation <= new_exposure_compensation) && - (max_exposure_compensation >= new_exposure_compensation)) { - if (mSecCamera->setBrightness(new_exposure_compensation) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setBrightness(brightness(%d))", __func__, new_exposure_compensation); - ret = UNKNOWN_ERROR; - } else { - mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, new_exposure_compensation); - } - } - - // whitebalance - const char *new_white_str = params.get(CameraParameters::KEY_WHITE_BALANCE); - LOGV("%s : new_white_str %s", __func__, new_white_str); - if (new_white_str != NULL) { - int new_white = -1; - - if (!strcmp(new_white_str, CameraParameters::WHITE_BALANCE_AUTO)) - new_white = WHITE_BALANCE_AUTO; - else if (!strcmp(new_white_str, - CameraParameters::WHITE_BALANCE_DAYLIGHT)) - new_white = WHITE_BALANCE_SUNNY; - else if (!strcmp(new_white_str, - CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT)) - new_white = WHITE_BALANCE_CLOUDY; - else if (!strcmp(new_white_str, - CameraParameters::WHITE_BALANCE_FLUORESCENT)) - new_white = WHITE_BALANCE_FLUORESCENT; - else if (!strcmp(new_white_str, - CameraParameters::WHITE_BALANCE_INCANDESCENT)) - new_white = WHITE_BALANCE_TUNGSTEN; - else { - LOGE("ERR(%s):Invalid white balance(%s)", __func__, new_white_str); //twilight, shade, warm_flourescent - ret = UNKNOWN_ERROR; - } - - if (0 <= new_white) { - if (mSecCamera->setWhiteBalance(new_white) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setWhiteBalance(white(%d))", __func__, new_white); - ret = UNKNOWN_ERROR; - } else { - mParameters.set(CameraParameters::KEY_WHITE_BALANCE, new_white_str); - } - } - } - - // scene mode - const char *new_scene_mode_str = params.get(CameraParameters::KEY_SCENE_MODE); - const char *current_scene_mode_str = mParameters.get(CameraParameters::KEY_SCENE_MODE); - - // fps range - int new_min_fps = 0; - int new_max_fps = 0; - int current_min_fps, current_max_fps; - params.getPreviewFpsRange(&new_min_fps, &new_max_fps); - mParameters.getPreviewFpsRange(¤t_min_fps, ¤t_max_fps); - /* our fps range is determined by the sensor, reject any request - * that isn't exactly what we're already at. - * but the check is performed when requesting only changing fps range - */ - if (new_scene_mode_str && current_scene_mode_str) { - if (!strcmp(new_scene_mode_str, current_scene_mode_str)) { - if ((new_min_fps != current_min_fps) || (new_max_fps != current_max_fps)) { - LOGW("%s : requested new_min_fps = %d, new_max_fps = %d not allowed", - __func__, new_min_fps, new_max_fps); - LOGE("%s : current_min_fps = %d, current_max_fps = %d", - __func__, current_min_fps, current_max_fps); - ret = UNKNOWN_ERROR; - } - } - } else { - /* Check basic validation if scene mode is different */ - if ((new_min_fps > new_max_fps) || - (new_min_fps < 0) || (new_max_fps < 0)) - ret = UNKNOWN_ERROR; - } - - if (new_scene_mode_str != NULL) { - int new_scene_mode = -1; - - const char *new_flash_mode_str = params.get(CameraParameters::KEY_FLASH_MODE); - const char *new_focus_mode_str; - - new_focus_mode_str = params.get(CameraParameters::KEY_FOCUS_MODE); - // fps range is (15000,30000) by default. - mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, "(15000,30000)"); - mParameters.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, - "15000,30000"); - - if (!strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_AUTO)) { - new_scene_mode = SCENE_MODE_NONE; - } else { - // defaults for non-auto scene modes - if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) { - new_focus_mode_str = CameraParameters::FOCUS_MODE_AUTO; - } - new_flash_mode_str = CameraParameters::FLASH_MODE_OFF; - - if (!strcmp(new_scene_mode_str, - CameraParameters::SCENE_MODE_PORTRAIT)) { - new_scene_mode = SCENE_MODE_PORTRAIT; - new_flash_mode_str = CameraParameters::FLASH_MODE_AUTO; - } else if (!strcmp(new_scene_mode_str, - CameraParameters::SCENE_MODE_LANDSCAPE)) { - new_scene_mode = SCENE_MODE_LANDSCAPE; - } else if (!strcmp(new_scene_mode_str, - CameraParameters::SCENE_MODE_SPORTS)) { - new_scene_mode = SCENE_MODE_SPORTS; - } else if (!strcmp(new_scene_mode_str, - CameraParameters::SCENE_MODE_PARTY)) { - new_scene_mode = SCENE_MODE_PARTY_INDOOR; - new_flash_mode_str = CameraParameters::FLASH_MODE_AUTO; - } else if ((!strcmp(new_scene_mode_str, - CameraParameters::SCENE_MODE_BEACH)) || - (!strcmp(new_scene_mode_str, - CameraParameters::SCENE_MODE_SNOW))) { - new_scene_mode = SCENE_MODE_BEACH_SNOW; - } else if (!strcmp(new_scene_mode_str, - CameraParameters::SCENE_MODE_SUNSET)) { - new_scene_mode = SCENE_MODE_SUNSET; - } else if (!strcmp(new_scene_mode_str, - CameraParameters::SCENE_MODE_NIGHT)) { - new_scene_mode = SCENE_MODE_NIGHTSHOT; - mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, "(4000,30000)"); - mParameters.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, - "4000,30000"); - } else if (!strcmp(new_scene_mode_str, - CameraParameters::SCENE_MODE_FIREWORKS)) { - new_scene_mode = SCENE_MODE_FIREWORKS; - } else if (!strcmp(new_scene_mode_str, - CameraParameters::SCENE_MODE_CANDLELIGHT)) { - new_scene_mode = SCENE_MODE_CANDLE_LIGHT; - } else { - LOGE("%s::unmatched scene_mode(%s)", - __func__, new_scene_mode_str); //action, night-portrait, theatre, steadyphoto - ret = UNKNOWN_ERROR; - } - } - - // focus mode - if (new_focus_mode_str != NULL) { - int new_focus_mode = -1; - - if (!strcmp(new_focus_mode_str, - CameraParameters::FOCUS_MODE_AUTO)) { - new_focus_mode = FOCUS_MODE_AUTO; - mParameters.set(CameraParameters::KEY_FOCUS_DISTANCES, - BACK_CAMERA_AUTO_FOCUS_DISTANCES_STR); - } - else if (!strcmp(new_focus_mode_str, - CameraParameters::FOCUS_MODE_MACRO)) { - new_focus_mode = FOCUS_MODE_MACRO; - mParameters.set(CameraParameters::KEY_FOCUS_DISTANCES, - BACK_CAMERA_MACRO_FOCUS_DISTANCES_STR); - } - else if (!strcmp(new_focus_mode_str, - CameraParameters::FOCUS_MODE_INFINITY)) { - new_focus_mode = FOCUS_MODE_INFINITY; - mParameters.set(CameraParameters::KEY_FOCUS_DISTANCES, - BACK_CAMERA_INFINITY_FOCUS_DISTANCES_STR); - } - else { - LOGE("%s::unmatched focus_mode(%s)", __func__, new_focus_mode_str); - ret = UNKNOWN_ERROR; - } - - if (0 <= new_focus_mode) { - if (mSecCamera->setFocusMode(new_focus_mode) < 0) { - LOGE("%s::mSecCamera->setFocusMode(%d) fail", __func__, new_focus_mode); - ret = UNKNOWN_ERROR; - } else { - mParameters.set(CameraParameters::KEY_FOCUS_MODE, new_focus_mode_str); - } - } - } - - // flash.. - if (new_flash_mode_str != NULL) { - int new_flash_mode = -1; - - if (!strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_OFF)) - new_flash_mode = FLASH_MODE_OFF; - else if (!strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_AUTO)) - new_flash_mode = FLASH_MODE_AUTO; - else if (!strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_ON)) - new_flash_mode = FLASH_MODE_ON; - else if (!strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_TORCH)) - new_flash_mode = FLASH_MODE_TORCH; - else { - LOGE("%s::unmatched flash_mode(%s)", __func__, new_flash_mode_str); //red-eye - ret = UNKNOWN_ERROR; - } - if (0 <= new_flash_mode) { - if (mSecCamera->setFlashMode(new_flash_mode) < 0) { - LOGE("%s::mSecCamera->setFlashMode(%d) fail", __func__, new_flash_mode); - ret = UNKNOWN_ERROR; - } else { - mParameters.set(CameraParameters::KEY_FLASH_MODE, new_flash_mode_str); - } - } - } - - // scene.. - if (0 <= new_scene_mode) { - if (mSecCamera->setSceneMode(new_scene_mode) < 0) { - LOGE("%s::mSecCamera->setSceneMode(%d) fail", __func__, new_scene_mode); - ret = UNKNOWN_ERROR; - } else { - mParameters.set(CameraParameters::KEY_SCENE_MODE, new_scene_mode_str); - } - } - } - - // --------------------------------------------------------------------------- - - // image effect - const char *new_image_effect_str = params.get(CameraParameters::KEY_EFFECT); - if (new_image_effect_str != NULL) { - - int new_image_effect = -1; - - if (!strcmp(new_image_effect_str, CameraParameters::EFFECT_NONE)) - new_image_effect = IMAGE_EFFECT_NONE; - else if (!strcmp(new_image_effect_str, CameraParameters::EFFECT_MONO)) - new_image_effect = IMAGE_EFFECT_BNW; - else if (!strcmp(new_image_effect_str, CameraParameters::EFFECT_SEPIA)) - new_image_effect = IMAGE_EFFECT_SEPIA; - else if (!strcmp(new_image_effect_str, CameraParameters::EFFECT_AQUA)) - new_image_effect = IMAGE_EFFECT_AQUA; - else if (!strcmp(new_image_effect_str, CameraParameters::EFFECT_NEGATIVE)) - new_image_effect = IMAGE_EFFECT_NEGATIVE; - else { - //posterize, whiteboard, blackboard, solarize - LOGE("ERR(%s):Invalid effect(%s)", __func__, new_image_effect_str); - ret = UNKNOWN_ERROR; - } - - if (new_image_effect >= 0) { - if (mSecCamera->setImageEffect(new_image_effect) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setImageEffect(effect(%d))", __func__, new_image_effect); - ret = UNKNOWN_ERROR; - } else { - const char *old_image_effect_str = mParameters.get(CameraParameters::KEY_EFFECT); - - if (old_image_effect_str) { - if (strcmp(old_image_effect_str, new_image_effect_str)) { - setSkipFrame(EFFECT_SKIP_FRAME); - } - } - - mParameters.set(CameraParameters::KEY_EFFECT, new_image_effect_str); - } - } - } - - //vt mode - int new_vtmode = mInternalParameters.getInt("vtmode"); - if (0 <= new_vtmode) { - if (mSecCamera->setVTmode(new_vtmode) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setVTMode(%d)", __func__, new_vtmode); - ret = UNKNOWN_ERROR; - } - } - - //contrast - int new_contrast = mInternalParameters.getInt("contrast"); - - if (0 <= new_contrast) { - if (mSecCamera->setContrast(new_contrast) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setContrast(%d)", __func__, new_contrast); - ret = UNKNOWN_ERROR; - } - } - - //WDR - int new_wdr = mInternalParameters.getInt("wdr"); - - if (0 <= new_wdr) { - if (mSecCamera->setWDR(new_wdr) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setWDR(%d)", __func__, new_wdr); - ret = UNKNOWN_ERROR; - } - } - - //anti shake - int new_anti_shake = mInternalParameters.getInt("anti-shake"); - - if (0 <= new_anti_shake) { - if (mSecCamera->setAntiShake(new_anti_shake) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setWDR(%d)", __func__, new_anti_shake); - ret = UNKNOWN_ERROR; - } - } - - // gps latitude - const char *new_gps_latitude_str = params.get(CameraParameters::KEY_GPS_LATITUDE); - if (mSecCamera->setGPSLatitude(new_gps_latitude_str) < 0) { - LOGE("%s::mSecCamera->setGPSLatitude(%s) fail", __func__, new_gps_latitude_str); - ret = UNKNOWN_ERROR; - } else { - if (new_gps_latitude_str) { - mParameters.set(CameraParameters::KEY_GPS_LATITUDE, new_gps_latitude_str); - } else { - mParameters.remove(CameraParameters::KEY_GPS_LATITUDE); - } - } - - // gps longitude - const char *new_gps_longitude_str = params.get(CameraParameters::KEY_GPS_LONGITUDE); - - if (mSecCamera->setGPSLongitude(new_gps_longitude_str) < 0) { - LOGE("%s::mSecCamera->setGPSLongitude(%s) fail", __func__, new_gps_longitude_str); - ret = UNKNOWN_ERROR; - } else { - if (new_gps_longitude_str) { - mParameters.set(CameraParameters::KEY_GPS_LONGITUDE, new_gps_longitude_str); - } else { - mParameters.remove(CameraParameters::KEY_GPS_LONGITUDE); - } - } - - // gps altitude - const char *new_gps_altitude_str = params.get(CameraParameters::KEY_GPS_ALTITUDE); - - if (mSecCamera->setGPSAltitude(new_gps_altitude_str) < 0) { - LOGE("%s::mSecCamera->setGPSAltitude(%s) fail", __func__, new_gps_altitude_str); - ret = UNKNOWN_ERROR; - } else { - if (new_gps_altitude_str) { - mParameters.set(CameraParameters::KEY_GPS_ALTITUDE, new_gps_altitude_str); - } else { - mParameters.remove(CameraParameters::KEY_GPS_ALTITUDE); - } - } - - // gps timestamp - const char *new_gps_timestamp_str = params.get(CameraParameters::KEY_GPS_TIMESTAMP); - - if (mSecCamera->setGPSTimeStamp(new_gps_timestamp_str) < 0) { - LOGE("%s::mSecCamera->setGPSTimeStamp(%s) fail", __func__, new_gps_timestamp_str); - ret = UNKNOWN_ERROR; - } else { - if (new_gps_timestamp_str) { - mParameters.set(CameraParameters::KEY_GPS_TIMESTAMP, new_gps_timestamp_str); - } else { - mParameters.remove(CameraParameters::KEY_GPS_TIMESTAMP); - } - } - - // gps processing method - const char *new_gps_processing_method_str = params.get(CameraParameters::KEY_GPS_PROCESSING_METHOD); - - if (mSecCamera->setGPSProcessingMethod(new_gps_processing_method_str) < 0) { - LOGE("%s::mSecCamera->setGPSProcessingMethod(%s) fail", __func__, new_gps_processing_method_str); - ret = UNKNOWN_ERROR; - } else { - if (new_gps_processing_method_str) { - mParameters.set(CameraParameters::KEY_GPS_PROCESSING_METHOD, new_gps_processing_method_str); - } else { - mParameters.remove(CameraParameters::KEY_GPS_PROCESSING_METHOD); - } - } - - // Recording size - int new_recording_width = mInternalParameters.getInt("recording-size-width"); - int new_recording_height= mInternalParameters.getInt("recording-size-height"); - - if (0 < new_recording_width && 0 < new_recording_height) { - if (mSecCamera->setRecordingSize(new_recording_width, new_recording_height) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setRecordingSize(width(%d), height(%d))", __func__, new_recording_width, new_recording_height); - ret = UNKNOWN_ERROR; - } - } else { - if (mSecCamera->setRecordingSize(new_preview_width, new_preview_height) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setRecordingSize(width(%d), height(%d))", __func__, new_preview_width, new_preview_height); - ret = UNKNOWN_ERROR; - } - } - - //gamma - const char *new_gamma_str = mInternalParameters.get("video_recording_gamma"); - - if (new_gamma_str != NULL) { - int new_gamma = -1; - if (!strcmp(new_gamma_str, "off")) - new_gamma = GAMMA_OFF; - else if (!strcmp(new_gamma_str, "on")) - new_gamma = GAMMA_ON; - else { - LOGE("%s::unmatched gamma(%s)", __func__, new_gamma_str); - ret = UNKNOWN_ERROR; - } - - if (0 <= new_gamma) { - if (mSecCamera->setGamma(new_gamma) < 0) { - LOGE("%s::mSecCamera->setGamma(%d) fail", __func__, new_gamma); - ret = UNKNOWN_ERROR; - } - } - } - - //slow ae - const char *new_slow_ae_str = mInternalParameters.get("slow_ae"); - - if (new_slow_ae_str != NULL) { - int new_slow_ae = -1; - - if (!strcmp(new_slow_ae_str, "off")) - new_slow_ae = SLOW_AE_OFF; - else if (!strcmp(new_slow_ae_str, "on")) - new_slow_ae = SLOW_AE_ON; - else { - LOGE("%s::unmatched slow_ae(%s)", __func__, new_slow_ae_str); - ret = UNKNOWN_ERROR; - } - - if (0 <= new_slow_ae) { - if (mSecCamera->setSlowAE(new_slow_ae) < 0) { - LOGE("%s::mSecCamera->setSlowAE(%d) fail", __func__, new_slow_ae); - ret = UNKNOWN_ERROR; - } - } - } - - /*Camcorder fix fps*/ - int new_sensor_mode = mInternalParameters.getInt("cam_mode"); - - if (0 <= new_sensor_mode) { - if (mSecCamera->setSensorMode(new_sensor_mode) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setSensorMode(%d)", __func__, new_sensor_mode); - ret = UNKNOWN_ERROR; - } - } else { - new_sensor_mode=0; - } - - /*Shot mode*/ - int new_shot_mode = mInternalParameters.getInt("shot_mode"); - - if (0 <= new_shot_mode) { - if (mSecCamera->setShotMode(new_shot_mode) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setShotMode(%d)", __func__, new_shot_mode); - ret = UNKNOWN_ERROR; - } - } else { - new_shot_mode=0; - } - - //blur for Video call - int new_blur_level = mInternalParameters.getInt("blur"); - - if (0 <= new_blur_level) { - if (mSecCamera->setBlur(new_blur_level) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setBlur(%d)", __func__, new_blur_level); - ret = UNKNOWN_ERROR; - } - } - - - // chk_dataline - int new_dataline = mInternalParameters.getInt("chk_dataline"); - - if (0 <= new_dataline) { - if (mSecCamera->setDataLineCheck(new_dataline) < 0) { - LOGE("ERR(%s):Fail on mSecCamera->setDataLineCheck(%d)", __func__, new_dataline); - ret = UNKNOWN_ERROR; - } - } - LOGV("%s return ret = %d", __func__, ret); - - if (mSecCamera->stopPreview() < 0) { - LOGE("ERR(%s):Fail on mSecCamera->stopPreview", __func__); - ret = UNKNOWN_ERROR; - } - - //sleep a bit to give the cam a chance to get ready - usleep(100000); - if (mSecCamera->startPreview() < 0) { - LOGE("ERR(%s):Fail on mSecCamera->startPreview", __func__); - ret = UNKNOWN_ERROR; - } - - return ret; -} - -CameraParameters CameraHardwareSec::getParameters() const -{ - LOGV("%s :", __func__); - return mParameters; -} - -status_t CameraHardwareSec::sendCommand(int32_t command, int32_t arg1, int32_t arg2) -{ - return BAD_VALUE; -} - -void CameraHardwareSec::release() -{ - LOGV("%s :", __func__); - - /* shut down any threads we have that might be running. do it here - * instead of the destructor. we're guaranteed to be on another thread - * than the ones below. if we used the destructor, since the threads - * have a reference to this object, we could wind up trying to wait - * for ourself to exit, which is a deadlock. - */ - if (mPreviewThread != NULL) { - /* this thread is normally already in it's threadLoop but blocked - * on the condition variable or running. signal it so it wakes - * up and can exit. - */ - mPreviewThread->requestExit(); - mExitPreviewThread = true; - mPreviewRunning = true; /* let it run so it can exit */ - mPreviewCondition.signal(); - mPreviewThread->requestExitAndWait(); - mPreviewThread.clear(); - } - if (mAutoFocusThread != NULL) { - /* this thread is normally already in it's threadLoop but blocked - * on the condition variable. signal it so it wakes up and can exit. - */ - mFocusLock.lock(); - mAutoFocusThread->requestExit(); - mExitAutoFocusThread = true; - mFocusCondition.signal(); - mFocusLock.unlock(); - mAutoFocusThread->requestExitAndWait(); - mAutoFocusThread.clear(); - } - if (mPictureThread != NULL) { - mPictureThread->requestExitAndWait(); - mPictureThread.clear(); - } - if (mRawHeap != NULL) - mRawHeap.clear(); - - if (mJpegHeap != NULL) - mJpegHeap.clear(); - - if (mPreviewHeap != NULL) { - LOGI("%s: calling mPreviewHeap.dispose()", __func__); - mPreviewHeap->dispose(); - mPreviewHeap.clear(); - } - - if (mRecordHeap != NULL) - mRecordHeap.clear(); - -#if defined(BOARD_USES_OVERLAY) - if (mUseOverlay) { - mOverlay->destroy(); - mUseOverlay = false; - mOverlay = NULL; - } -#endif - - /* close after all the heaps are cleared since those - * could have dup'd our file descriptor. - */ - mSecCamera->DeinitCamera(); - mSecCamera = NULL; - -} - -wp CameraHardwareSec::singleton; - -sp CameraHardwareSec::createInstance(int cameraId) -{ - LOGV("%s :", __func__); - if (singleton != 0) { - sp hardware = singleton.promote(); - if (hardware != 0) { - return hardware; - } - } - sp hardware(new CameraHardwareSec(cameraId)); - singleton = hardware; - return hardware; -} - -static CameraInfo sCameraInfo[] = { - { - CAMERA_FACING_BACK, - 90, /* orientation */ - }, -#ifdef FFC_PRESENT - { - CAMERA_FACING_FRONT, - 0, /* orientation */ - } -#endif -}; - -extern "C" int HAL_getNumberOfCameras() -{ - return sizeof(sCameraInfo) / sizeof(sCameraInfo[0]); -} - -extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo *cameraInfo) -{ - memcpy(cameraInfo, &sCameraInfo[cameraId], sizeof(CameraInfo)); -} - -extern "C" sp HAL_openCameraHardware(int cameraId) -{ - return CameraHardwareSec::createInstance(cameraId); -} - -}; // namespace android diff --git a/aries/libcamera/SecCameraHWInterface.h b/aries/libcamera/SecCameraHWInterface.h deleted file mode 100644 index 75526c6..0000000 --- a/aries/libcamera/SecCameraHWInterface.h +++ /dev/null @@ -1,212 +0,0 @@ -/* -** -** Copyright 2008, The Android Open Source Project -** Copyright 2010, Samsung Electronics Co. LTD -** -** 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_SEC_H -#define ANDROID_HARDWARE_CAMERA_HARDWARE_SEC_H - -#include "SecCamera.h" -#include -#include -#include -#include -#include - -namespace android { -class CameraHardwareSec : public CameraHardwareInterface { -public: - virtual sp getPreviewHeap() const; - virtual sp getRawHeap() const; - - virtual void setCallbacks(notify_callback notify_cb, - data_callback data_cb, - data_callback_timestamp data_cb_timestamp, - void *user); - - virtual void enableMsgType(int32_t msgType); - virtual void disableMsgType(int32_t msgType); - virtual bool msgTypeEnabled(int32_t msgType); - - virtual status_t startPreview(); -#if defined(BOARD_USES_OVERLAY) - virtual bool useOverlay(); - virtual status_t setOverlay(const sp &overlay); -#endif - virtual void stopPreview(); - virtual bool previewEnabled(); - - virtual status_t startRecording(); - virtual void stopRecording(); - virtual bool recordingEnabled(); - virtual void releaseRecordingFrame(const sp &mem); - - virtual status_t autoFocus(); - virtual status_t cancelAutoFocus(); - virtual status_t takePicture(); - virtual status_t cancelPicture(); - virtual status_t dump(int fd, const Vector &args) const; - virtual status_t setParameters(const CameraParameters& params); - virtual CameraParameters getParameters() const; - virtual status_t sendCommand(int32_t command, int32_t arg1, - int32_t arg2); - virtual void release(); - - static sp createInstance(int cameraId); - -private: - CameraHardwareSec(int cameraId); - virtual ~CameraHardwareSec(); - - static wp singleton; - - static const int kBufferCount = MAX_BUFFERS; - static const int kBufferCountForRecord = MAX_BUFFERS; - - class PreviewThread : public Thread { - CameraHardwareSec *mHardware; - public: - PreviewThread(CameraHardwareSec *hw): - Thread(false), - mHardware(hw) { } - virtual void onFirstRef() { - run("CameraPreviewThread", PRIORITY_URGENT_DISPLAY); - } - virtual bool threadLoop() { - mHardware->previewThreadWrapper(); - return false; - } - }; - - class PictureThread : public Thread { - CameraHardwareSec *mHardware; - public: - PictureThread(CameraHardwareSec *hw): - Thread(false), - mHardware(hw) { } - virtual bool threadLoop() { - mHardware->pictureThread(); - mHardware->mSecCamera->endSnapshot(); - return false; - } - }; - - class AutoFocusThread : public Thread { - CameraHardwareSec *mHardware; - public: - AutoFocusThread(CameraHardwareSec *hw): Thread(false), mHardware(hw) { } - virtual void onFirstRef() { - run("CameraAutoFocusThread", PRIORITY_DEFAULT); - } - virtual bool threadLoop() { - mHardware->autoFocusThread(); - return true; - } - }; - - void initDefaultParameters(int cameraId); - void initHeapLocked(); - - sp mPreviewThread; - int previewThread(); - int previewThreadWrapper(); - - sp mAutoFocusThread; - int autoFocusThread(); - - sp mPictureThread; - int pictureThread(); - bool mCaptureInProgress; - - int save_jpeg(unsigned char *real_jpeg, int jpeg_size); - void save_postview(const char *fname, uint8_t *buf, - uint32_t size); - int decodeInterleaveData(unsigned char *pInterleaveData, - int interleaveDataSize, - int yuvWidth, - int yuvHeight, - int *pJpegSize, - void *pJpegData, - void *pYuvData); - bool YUY2toNV21(void *srcBuf, void *dstBuf, uint32_t srcWidth, uint32_t srcHeight); - bool scaleDownYuv422(char *srcBuf, uint32_t srcWidth, - uint32_t srcHight, char *dstBuf, - uint32_t dstWidth, uint32_t dstHight); - - bool CheckVideoStartMarker(unsigned char *pBuf); - bool CheckEOIMarker(unsigned char *pBuf); - bool FindEOIMarkerInJPEG(unsigned char *pBuf, - int dwBufSize, int *pnJPEGsize); - bool SplitFrame(unsigned char *pFrame, int dwSize, - int dwJPEGLineLength, int dwVideoLineLength, - int dwVideoHeight, void *pJPEG, - int *pdwJPEGSize, void *pVideo, - int *pdwVideoSize); - void setSkipFrame(int frame); - /* used by auto focus thread to block until it's told to run */ - mutable Mutex mFocusLock; - mutable Condition mFocusCondition; - bool mExitAutoFocusThread; - - /* used by preview thread to block until it's told to run */ - mutable Mutex mPreviewLock; - mutable Condition mPreviewCondition; - mutable Condition mPreviewStoppedCondition; - bool mPreviewRunning; - bool mExitPreviewThread; - - /* used to guard threading state */ - mutable Mutex mStateLock; - - CameraParameters mParameters; - CameraParameters mInternalParameters; - - sp mPreviewHeap; - sp mRawHeap; - sp mRecordHeap; - sp mJpegHeap; - sp mBuffers[kBufferCount]; - sp mRecordBuffers[kBufferCountForRecord]; - - SecCamera *mSecCamera; - const __u8 *mCameraSensorName; - - mutable Mutex mSkipFrameLock; - int mSkipFrame; - -#if defined(BOARD_USES_OVERLAY) - sp mOverlay; - bool mUseOverlay; - int mOverlayBufferIdx; -#endif - - notify_callback mNotifyCb; - data_callback mDataCb; - data_callback_timestamp mDataCbTimestamp; - void *mCallbackCookie; - - int32_t mMsgEnabled; - - bool mRecordRunning; - mutable Mutex mRecordLock; - int mPostViewWidth; - int mPostViewHeight; - int mPostViewSize; -}; - -}; // namespace android - -#endif diff --git a/aries/liblight/Android.mk b/aries/liblight/Android.mk deleted file mode 100644 index 9933c34..0000000 --- a/aries/liblight/Android.mk +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (C) 2008 The Android Open Source Project -# -# 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 implemenation, not prelinked and stored in -# hw/..so -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := lights.c - -LOCAL_PRELINK_MODULE := false -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw - -LOCAL_SHARED_LIBRARIES := liblog - -LOCAL_MODULE := lights.aries - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_SHARED_LIBRARY) - diff --git a/aries/liblight/NOTICE b/aries/liblight/NOTICE deleted file mode 100644 index f921593..0000000 --- a/aries/liblight/NOTICE +++ /dev/null @@ -1,190 +0,0 @@ - - Copyright (C) 2008 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - - 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. - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - diff --git a/aries/liblight/lights.c b/aries/liblight/lights.c deleted file mode 100644 index 118fa66..0000000 --- a/aries/liblight/lights.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * Copyright (C) 2011 - * - * 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. - */ - -#define LOG_TAG "lights" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static pthread_once_t g_init = PTHREAD_ONCE_INIT; -static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; - -char const *const LCD_FILE = "/sys/class/backlight/s5p_bl/brightness"; -char const *const LED_FILE = "/sys/class/misc/notification/led"; - -static int write_int(char const *path, int value) -{ - int fd; - static int already_warned; - - already_warned = 0; - - LOGV("write_int: path %s, value %d", path, value); - fd = open(path, O_RDWR); - - if (fd >= 0) { - char buffer[20]; - int bytes = sprintf(buffer, "%d\n", value); - int amt = write(fd, buffer, bytes); - close(fd); - return amt == -1 ? -errno : 0; - } else { - if (already_warned == 0) { - LOGE("write_int failed to open %s\n", path); - already_warned = 1; - } - return -errno; - } -} - -static int rgb_to_brightness(struct light_state_t const *state) -{ - int color = state->color & 0x00ffffff; - - return ((77*((color>>16) & 0x00ff)) - + (150*((color>>8) & 0x00ff)) + (29*(color & 0x00ff))) >> 8; -} - -static int set_light_notifications(struct light_device_t* dev, - struct light_state_t const* state) -{ - int brightness = rgb_to_brightness(state); - int v = 0; - int ret = 0; - pthread_mutex_lock(&g_lock); - - if (brightness+state->color == 0 || brightness > 100) { - if (state->color & 0x00ffffff) - v = 1; - } else - v = 0; - - LOGI("color %u fm %u status %u is lit %u brightness", state->color, state->flashMode, v, (state->color & 0x00ffffff), brightness); - ret = write_int(LED_FILE, v); - pthread_mutex_unlock(&g_lock); - return ret; -} - -static int set_light_backlight(struct light_device_t *dev, - struct light_state_t const *state) -{ - int err = 0; - int brightness = rgb_to_brightness(state); - - pthread_mutex_lock(&g_lock); - err = write_int(LCD_FILE, brightness); - - pthread_mutex_unlock(&g_lock); - return err; -} - -static int close_lights(struct light_device_t *dev) -{ - LOGV("close_light is called"); - if (dev) - free(dev); - - return 0; -} - -static int open_lights(const struct hw_module_t *module, char const *name, - struct hw_device_t **device) -{ - int (*set_light)(struct light_device_t *dev, - struct light_state_t const *state); - - LOGV("open_lights: open with %s", name); - - if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) - set_light = set_light_backlight; - else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) - set_light = set_light_notifications; - else - return -EINVAL; - - pthread_mutex_init(&g_lock, NULL); - - struct light_device_t *dev = malloc(sizeof(struct light_device_t)); - memset(dev, 0, sizeof(*dev)); - - dev->common.tag = HARDWARE_DEVICE_TAG; - dev->common.version = 0; - dev->common.module = (struct hw_module_t *)module; - dev->common.close = (int (*)(struct hw_device_t *))close_lights; - dev->set_light = set_light; - - *device = (struct hw_device_t *)dev; - - return 0; -} - -static struct hw_module_methods_t lights_module_methods = { - .open = open_lights, -}; - -const struct hw_module_t HAL_MODULE_INFO_SYM = { - .tag = HARDWARE_MODULE_TAG, - .version_major = 1, - .version_minor = 0, - .id = LIGHTS_HARDWARE_MODULE_ID, - .name = "lights Module", - .author = "Google, Inc.", - .methods = &lights_module_methods, -}; diff --git a/aries/liboverlay/Android.mk b/aries/liboverlay/Android.mk deleted file mode 100644 index c4de48c..0000000 --- a/aries/liboverlay/Android.mk +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (C) 2008 The Android Open Source Project -# -# 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 implemenation, not prelinked and stored in -# hw/..so - -include $(CLEAR_VARS) -LOCAL_PRELINK_MODULE := false -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw -LOCAL_SHARED_LIBRARIES := liblog libcutils - -ifdef BOARD_V4L2_DEVICE - LOCAL_CFLAGS += -DV4L2_DEVICE=\"$(BOARD_V4L2_DEVICE)\" -endif - -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/../include - -LOCAL_SRC_FILES := v4l2_utils.c overlay.cpp - -LOCAL_MODULE := overlay.aries -LOCAL_MODULE_TAGS := optional -include $(BUILD_SHARED_LIBRARY) diff --git a/aries/liboverlay/overlay.cpp b/aries/liboverlay/overlay.cpp deleted file mode 100644 index d0a4289..0000000 --- a/aries/liboverlay/overlay.cpp +++ /dev/null @@ -1,1490 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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. - */ - -/*#define LOG_NDEBUG 0*/ -#define LOG_TAG "SEC_Overlay" - -#include -#include - -extern "C" { -#include "v4l2_utils.h" -} - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "linux/fb.h" - -/*****************************************************************************/ - -#define LOG_FUNCTION_NAME LOGV(" %s %s", __FILE__, __func__) - -#define NUM_OVERLAY_BUFFERS_REQUESTED (3) -/* OVRLYSHM on phone keypad*/ -#define SHARED_DATA_MARKER (0x68759746) - -/* These values should come from Surface Flinger */ -unsigned int g_lcd_width = 480; -unsigned int g_lcd_height = 800; -unsigned int g_lcd_bpp = 32; - -#define CACHEABLE_BUFFERS 0x1 - -/* shared with Camera/Video Playback HAL */ -#define ALL_BUFFERS_FLUSHED -66 - -uint32_t phyAddr; -s5p_fimc_t g_s5p_fimc; - -typedef struct -{ - uint32_t posX; - uint32_t posY; - uint32_t posW; - uint32_t posH; - uint32_t rotation; - uint32_t flip; - - uint32_t posX_org; - uint32_t posY_org; - uint32_t posW_org; - uint32_t posH_org; - -} overlay_ctrl_t; - -typedef struct -{ - uint32_t cropX; - uint32_t cropY; - uint32_t cropW; - uint32_t cropH; -} overlay_data_t; - -typedef struct -{ - uint32_t marker; - uint32_t size; - - volatile int32_t refCnt; - - uint32_t controlReady; /* Only updated by the control side */ - uint32_t dataReady; /* Only updated by the data side */ - - pthread_mutex_t lock; - pthread_mutexattr_t attr; - - uint32_t streamEn; - uint32_t streamingReset; - - uint32_t dispW; - uint32_t dispH; - -} overlay_shared_t; - -/* Only one instance is created per platform */ -struct overlay_control_context_t { - struct overlay_control_device_t device; - /* our private state goes below here */ - struct overlay_t* overlay_video1; - struct overlay_t* overlay_video2; -}; - -/* A separate instance is created per overlay data side user*/ -struct overlay_data_context_t { - struct overlay_data_device_t device; - /* our private state goes below here */ - int ctl_fd; - int shared_fd; - int shared_size; - int width; - int height; - int format; - int num_buffers; - size_t *buffers_len; - void **buffers; - - overlay_data_t data; - overlay_shared_t *shared; - struct mapping_data *mapping_data; - /* Need to count Qd buffers - to be sure we don't block DQ'ing when exiting */ - int qd_buf_count; - int cacheable_buffers; - - bool zerocopy; -}; - -static int create_shared_data(overlay_shared_t **shared); -static void destroy_shared_data(int shared_fd, overlay_shared_t *shared, - bool closefd); -static int open_shared_data(overlay_data_context_t *ctx); -static void close_shared_data(overlay_data_context_t *ctx); -enum { LOCK_REQUIRED = 1, NO_LOCK_NEEDED = 0 }; -static int enable_streaming(overlay_shared_t *shared, int ovly_fd, - int lock_required ); - -static int overlay_device_open(const struct hw_module_t* module, - const char* name, struct hw_device_t** device); - -static int check_fimc_dst_constraints(s5p_fimc_t *s5p_fimc, - unsigned int rotation); -static int check_fimc_src_constraints(s5p_fimc_t *s5p_fimc); - -static struct hw_module_methods_t overlay_module_methods = { -open: overlay_device_open -}; - -struct overlay_module_t HAL_MODULE_INFO_SYM = { -common: { -tag: HARDWARE_MODULE_TAG, - version_major: 1, - version_minor: 0, - id: OVERLAY_HARDWARE_MODULE_ID, - name: "SEC Overlay module", - author: "The Android Open Source Project", - methods: &overlay_module_methods, - } -}; - -/*****************************************************************************/ - -/* - * This is the overlay_t object, it is returned to the user and represents - * an overlay. here we use a subclass, where we can store our own state. - * This handles will be passed across processes and possibly given to other - * HAL modules (for instance video decode modules). - */ -struct handle_t : public native_handle { - /* add the data fields we need here, for instance: */ - int ctl_fd; - int shared_fd; - int width; - int height; - int format; - int num_buffers; - int shared_size; -}; - -static int handle_format(const overlay_handle_t overlay) { - return static_cast(overlay)->format; -} - -static int handle_ctl_fd(const overlay_handle_t overlay) { - return static_cast(overlay)->ctl_fd; -} - -static int handle_shared_fd(const overlay_handle_t overlay) { - return static_cast(overlay)->shared_fd; -} - -static int handle_num_buffers(const overlay_handle_t overlay) { - return static_cast(overlay)->num_buffers; -} - -static int handle_width(const overlay_handle_t overlay) { - return static_cast(overlay)->width; -} - -static int handle_height(const overlay_handle_t overlay) { - return static_cast(overlay)->height; -} - -static int handle_shared_size(const overlay_handle_t overlay) { - return static_cast(overlay)->shared_size; -} - -/* A separate instance of this class is created per overlay */ -class overlay_object : public overlay_t -{ - handle_t mHandle; - - overlay_ctrl_t mCtl; - overlay_ctrl_t mCtlStage; - overlay_shared_t *mShared; - - static overlay_handle_t getHandleRef(struct overlay_t* overlay) { - /* returns a reference to the handle, caller doesn't take ownership */ - return &(static_cast(overlay)->mHandle); - } - - public: - overlay_object(int ctl_fd, int shared_fd, int shared_size, int w, int h, - int format, int num_buffers) { - this->overlay_t::getHandleRef = getHandleRef; - mHandle.version = sizeof(native_handle); - mHandle.numFds = 2; - mHandle.numInts = 5; /* extra ints we have in our handle */ - mHandle.ctl_fd = ctl_fd; - mHandle.shared_fd = shared_fd; - mHandle.width = w; - mHandle.height = h; - mHandle.format = format; - mHandle.num_buffers = num_buffers; - mHandle.shared_size = shared_size; - this->w = w; - this->h = h; - this->format = format; - - memset( &mCtl, 0, sizeof( mCtl ) ); - memset( &mCtlStage, 0, sizeof( mCtlStage ) ); - } - - int ctl_fd() { return mHandle.ctl_fd; } - int shared_fd() { return mHandle.shared_fd; } - overlay_ctrl_t* data() { return &mCtl; } - overlay_ctrl_t* staging() { return &mCtlStage; } - overlay_shared_t* getShared() { return mShared; } - void setShared( overlay_shared_t *p ) { mShared = p; } -}; - -/***************************************************************************** - * Local Functions - *****************************************************************************/ - -static int create_shared_data(overlay_shared_t **shared) -{ - int fd; - /* assuming sizeof(overlay_shared_t) < a single page */ - int size = getpagesize(); - overlay_shared_t *p; - - if ((fd = ashmem_create_region("overlay_data", size)) < 0) { - LOGE("Failed to Create Overlay Shared Data!\n"); - return fd; - } - - p = (overlay_shared_t*)mmap(NULL, size, PROT_READ | PROT_WRITE, - MAP_SHARED, fd, 0); - if (p == MAP_FAILED) { - LOGE("Failed to Map Overlay Shared Data!\n"); - close(fd); - return -1; - } - - memset(p, 0, size); - p->marker = SHARED_DATA_MARKER; - p->size = size; - p->refCnt = 1; - if (pthread_mutexattr_init(&p->attr) != 0) { - LOGE("Failed to initialize overlay mutex attr"); - goto MutexAttrErr; - } - if (pthread_mutexattr_setpshared(&p->attr, PTHREAD_PROCESS_SHARED) != 0) { - LOGE("Failed to set the overlay mutex attr to be shared across-processes"); - goto MutexAttrSetErr; - } - if (pthread_mutex_init(&p->lock, &p->attr) != 0) { - LOGE("Failed to initialize overlay mutex\n"); - goto MutexErr; - } - - *shared = p; - return fd; - -MutexErr: -MutexAttrSetErr: - pthread_mutexattr_destroy(&p->attr); -MutexAttrErr: - munmap(p, size); - close(fd); - return -1; -} - -static void destroy_shared_data(int shared_fd, overlay_shared_t *shared, - bool closefd ) -{ - if (shared == NULL) - return; - - /* Last side deallocated releases the mutex, otherwise the remaining */ - /* side will deadlock trying to use an already released mutex */ - if (android_atomic_dec(&shared->refCnt) == 1) { - if (pthread_mutex_destroy(&shared->lock)) { - LOGE("Failed to uninitialize overlay mutex!\n"); - } - - if (pthread_mutexattr_destroy(&shared->attr)) { - LOGE("Failed to uninitialize the overlay mutex attr!\n"); - } - shared->marker = 0; - } - - if (munmap(shared, shared->size)) { - LOGE("Failed to Unmap Overlay Shared Data!\n"); - } - - if (closefd && close(shared_fd)) { - LOGE("Failed to Close Overlay Shared Data!\n"); - } -} - -static int open_shared_data( overlay_data_context_t *ctx ) -{ - int rc = -1; - int mode = PROT_READ | PROT_WRITE; - int fd = ctx->shared_fd; - int size = ctx->shared_size; - - if (ctx->shared != NULL) { - /* Already open, return success */ - LOGI("Overlay Shared Data Already Open\n"); - return 0; - } - ctx->shared = (overlay_shared_t*)mmap(0, size, mode, MAP_SHARED, fd, 0); - - if (ctx->shared == MAP_FAILED) { - LOGE("Failed to Map Overlay Shared Data!\n"); - } else if ( ctx->shared->marker != SHARED_DATA_MARKER ) { - LOGE("Invalid Overlay Shared Marker!\n"); - munmap( ctx->shared, size); - } else if ( (int)ctx->shared->size != size ) { - LOGE("Invalid Overlay Shared Size!\n"); - munmap(ctx->shared, size); - } else { - android_atomic_inc(&ctx->shared->refCnt); - rc = 0; - } - - return rc; -} - -static void close_shared_data(overlay_data_context_t *ctx) -{ - destroy_shared_data(ctx->shared_fd, ctx->shared, false); - ctx->shared = NULL; -} - -static int enable_streaming_locked(overlay_shared_t *shared, int ovly_fd) -{ - int rc = 0; - - if (!shared->controlReady || !shared->dataReady) { - LOGI("Postponing Stream Enable/%d/%d\n", shared->controlReady, - shared->dataReady); - } else { - shared->streamEn = 1; - rc = v4l2_overlay_stream_on(ovly_fd); - if (rc) { - LOGE("Stream Enable Failed!/%d\n", rc); - shared->streamEn = 0; - } - } - - return rc; -} - -static int enable_streaming(overlay_shared_t *shared, int ovly_fd) -{ - int ret; - - pthread_mutex_lock(&shared->lock); - ret = enable_streaming_locked(shared, ovly_fd); - pthread_mutex_unlock(&shared->lock); - return ret; -} - -static int disable_streaming_locked(overlay_shared_t *shared, int ovly_fd) -{ - int ret = 0; - - if (shared->streamEn) { - ret = v4l2_overlay_stream_off( ovly_fd ); - if (ret) { - LOGE("Stream Off Failed!/%d\n", ret); - } else { - shared->streamingReset = 1; - shared->streamEn = 0; - } - } - - return ret; -} - -static void set_color_space(unsigned int overlay_color_format, unsigned int *v4l2_color_format) -{ - switch (overlay_color_format) { - case OVERLAY_FORMAT_RGB_565: - *v4l2_color_format = V4L2_PIX_FMT_RGB565; - break; - - case OVERLAY_FORMAT_YCbYCr_422_I: - case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I: - *v4l2_color_format = V4L2_PIX_FMT_YUYV; - break; - - case OVERLAY_FORMAT_CbYCrY_422_I: - case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I: - *v4l2_color_format = V4L2_PIX_FMT_UYVY; - break; - - case HAL_PIXEL_FORMAT_YCbCr_420_P: - *v4l2_color_format = V4L2_PIX_FMT_YUV420; - break; - - case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP: - *v4l2_color_format = V4L2_PIX_FMT_NV12T; - break; - - case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP: - *v4l2_color_format = V4L2_PIX_FMT_NV21; - break; - - default : - LOGE("unsupported pixel format (0x%x)", overlay_color_format); - *v4l2_color_format = -1; - } -} - -/**************************************************************************** - * Control module - *****************************************************************************/ - -static int overlay_get(struct overlay_control_device_t *dev, int name) -{ - int result = -1; - - switch (name) { - /* 0 = no limit */ - case OVERLAY_MINIFICATION_LIMIT: result = 0; break; - /* 0 = no limit */ - case OVERLAY_MAGNIFICATION_LIMIT: result = 0; break; - /* 0 = infinite */ - case OVERLAY_SCALING_FRAC_BITS: result = 0; break; - /* 90 rotation steps (for instance) */ - case OVERLAY_ROTATION_STEP_DEG: result = 90; break; - /* 1-pixel alignment */ - case OVERLAY_HORIZONTAL_ALIGNMENT: result = 1; break; - /* 1-pixel alignment */ - case OVERLAY_VERTICAL_ALIGNMENT: result = 1; break; - /* 1-pixel alignment */ - case OVERLAY_WIDTH_ALIGNMENT: result = 1; break; - case OVERLAY_HEIGHT_ALIGNMENT: break; - } - - return result; -} - -static int get_fb_var_screeninfo( struct fb_var_screeninfo *info ) -{ - int fd = -1; - int i=0; - char name[64]; - int ret = 0; - - char const * const device_template[] = { - "/dev/graphics/fb%u", - "/dev/fb%u", - 0 }; - - while ((fd==-1) && device_template[i]) { - snprintf(name, 64, device_template[i], 0); - fd = open(name, O_RDWR, 0); - i++; - } - - if (fd < 0) - ret = -EINVAL; - - if (ioctl(fd, FBIOGET_VSCREENINFO, info) == -1) - ret = -EINVAL; - - if (fd > 0) - close(fd); - - return 0; -} -static overlay_t* overlay_createOverlay(struct overlay_control_device_t *dev, - uint32_t w, uint32_t h, int32_t format) -{ - LOGD("overlay_createOverlay:IN w=%d h=%d format=%d\n", w, h, format); - LOG_FUNCTION_NAME; - - overlay_object *overlay; - overlay_control_context_t *ctx = (overlay_control_context_t *)dev; - overlay_shared_t *shared; - - int ret; - uint32_t num = NUM_OVERLAY_BUFFERS_REQUESTED; - int fd; - int shared_fd; - struct fb_var_screeninfo info; - bool zerocopy = false; - - phyAddr = 0; - - if (format == OVERLAY_FORMAT_DEFAULT) { - LOGD("format == OVERLAY_FORMAT_DEFAULT\n"); - LOGD("set to HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP\n"); - format = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP; - } - - if (ctx->overlay_video1) { - LOGE("Error - overlays already in use\n"); - return NULL; - } - - shared_fd = create_shared_data(&shared); - if (shared_fd < 0) { - LOGE("Failed to create shared data"); - return NULL; - } - - fd = v4l2_overlay_open(V4L2_OVERLAY_PLANE_VIDEO1); - if (fd < 0) { - LOGE("Failed to open overlay device : %s\n", strerror(errno)); - goto error; - } - - g_s5p_fimc.params.src.full_width = w; - g_s5p_fimc.params.src.full_height = h; - g_s5p_fimc.params.src.width = w; - g_s5p_fimc.params.src.height = h; - set_color_space(format, &g_s5p_fimc.params.src.color_space); - ret = check_fimc_src_constraints(&g_s5p_fimc); - if(ret != 0) { - if(ret < 0) { - LOGE("Not supported source image size"); - goto error1; - } else { - LOGD("src width, height are changed [w= %d, h= %d]->[w=%d, h= %d]" - , w, h, g_s5p_fimc.params.src.width - , g_s5p_fimc.params.src.height); - w = g_s5p_fimc.params.src.width; - h = g_s5p_fimc.params.src.height; - } - } - - if (v4l2_overlay_init(fd, w, h, format, phyAddr)) { - LOGE("Failed initializing overlays\n"); - goto error1; - } - - if (v4l2_overlay_set_crop(fd, 0, 0, w, h)) { - LOGE("Failed defaulting crop window\n"); - goto error1; - } - - if (v4l2_overlay_set_flip(fd, 0)) { - LOGE("Failed defaulting flip\n"); - goto error1; - } - - if (v4l2_overlay_set_rotation(fd, 0, 0)) { - LOGE("Failed defaulting rotation\n"); - goto error1; - } - - if (format >= HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP - && format < HAL_PIXEL_FORMAT_CUSTOM_MAX) - zerocopy = true; - - if (v4l2_overlay_req_buf(fd, &num, 0, (int)zerocopy)) { - LOGE("Failed requesting buffers\n"); - goto error1; - } - - v4l2_overlay_init_fimc(fd, &g_s5p_fimc); - - overlay = new overlay_object(fd, shared_fd, shared->size, - w, h, format, num); - if (overlay == NULL) { - LOGE("Failed to create overlay object\n"); - goto error1; - } - ctx->overlay_video1 = overlay; - - overlay->setShared(shared); - - shared->controlReady = 0; - shared->streamEn = 0; - shared->streamingReset = 0; - - /* get lcd size from kernel framebuffer */ - if(get_fb_var_screeninfo(&info) == 0) { - shared->dispW = info.xres; - shared->dispH = info.yres; - g_lcd_width = info.xres; - g_lcd_height = info.yres; - g_lcd_bpp = info.bits_per_pixel; - } else { - shared->dispW = g_lcd_width; /* Need to determine this properly */ - shared->dispH = g_lcd_height; /* Need to determine this properly */ - } - - LOGI("Opened video1/fd=%d/obj=%08lx/shm=%d/size=%d", fd, - (unsigned long)overlay, shared_fd, shared->size); - - return overlay; - -error1: - close(fd); -error: - destroy_shared_data(shared_fd, shared, true); - return NULL; -} - -static void overlay_destroyOverlay(struct overlay_control_device_t *dev, - overlay_t* overlay) -{ - LOGD("overlay_destroyOverlay:IN dev (%p) and overlay (%p)", dev, overlay); - LOG_FUNCTION_NAME; - - overlay_control_context_t *ctx = (overlay_control_context_t *)dev; - overlay_object *obj = static_cast(overlay); - - int rc; - int fd = obj->ctl_fd(); - uint32_t num = 0; - - overlay_shared_t *shared = obj->getShared(); - - if (shared == NULL) { - LOGE("Overlay was already destroyed - nothing needs to be done\n"); - return; - } - - pthread_mutex_lock(&shared->lock); - - disable_streaming_locked(shared, fd); - - pthread_mutex_unlock(&shared->lock); - - destroy_shared_data(obj->shared_fd(), shared, true); - obj->setShared(NULL); - - if (v4l2_overlay_req_buf(fd, &num, 0, 0)) { - LOGE("Failed requesting buffers\n"); - } - - LOGI("Destroying overlay/fd=%d/obj=%08lx", fd, (unsigned long)overlay); - - if (close(fd)) { - LOGE( "Error closing overly fd/%d\n", errno); - } - - if (overlay) { - if (ctx->overlay_video1 == overlay) - ctx->overlay_video1 = NULL; - delete overlay; - overlay = NULL; - } - LOGD("overlay_destroyOverlay:OUT"); -} - -static int overlay_setPosition(struct overlay_control_device_t *dev, - overlay_t* overlay, int x, int y, uint32_t w, - uint32_t h) -{ - LOG_FUNCTION_NAME; - - overlay_object *obj = static_cast(overlay); - - overlay_ctrl_t *stage = obj->staging(); - overlay_shared_t *shared = obj->getShared(); - - int rc = 0; - int temp_x = x, temp_y = y, temp_w = w, temp_h = h; - - /* - * This logic here is to return an error if the rectangle is not fully - * within the display, unless we have not received a valid position yet, - * in which case we will do our best to adjust the rectangle to be within - * the display. - */ - - /* Require a minimum size */ - if (temp_w < 16) - temp_w = 16; - if (temp_h < 8) - temp_h = 8; - - if (!shared->controlReady) { - if ( temp_x < 0 ) temp_x = 0; - if ( temp_y < 0 ) temp_y = 0; - if ( temp_w > shared->dispW ) temp_w = shared->dispW; - if ( temp_h > shared->dispH ) temp_h = shared->dispH; - if ( (temp_x + temp_w) > shared->dispW ) temp_w = shared->dispW - temp_x; - if ( (temp_y + temp_h) > shared->dispH ) temp_h = shared->dispH - temp_y; - } else if (temp_x < 0 || temp_y < 0 || (temp_x + temp_w) > shared->dispW || - (temp_y + temp_h) > shared->dispH) { - /* Return an error */ - rc = -1; - } - - if (rc == 0) { - stage->posX = temp_x; - stage->posY = temp_y; - stage->posW = temp_w; - stage->posH = temp_h; - - stage->posX_org = x; - stage->posY_org = y; - stage->posW_org = w; - stage->posH_org = h; - } - - return rc; -} - -static int overlay_getPosition(struct overlay_control_device_t *dev, - overlay_t* overlay, int* x, int* y, uint32_t* w, - uint32_t* h) -{ - LOG_FUNCTION_NAME; - - overlay_object *obj = static_cast(overlay); - overlay_ctrl_t *stage = obj->staging(); - - *x = stage->posX_org; - *y = stage->posY_org; - *w = stage->posW_org; - *h = stage->posH_org; - - return 0; -} - -static int overlay_setParameter(struct overlay_control_device_t *dev, - overlay_t* overlay, int param, int value) -{ - LOG_FUNCTION_NAME; - - overlay_ctrl_t *stage = static_cast(overlay)->staging(); - int rc = 0; - - switch (param) { - case OVERLAY_DITHER: - break; - - case OVERLAY_TRANSFORM: - switch ( value ) - { - case 0: - stage->rotation = 0; - stage->flip = 0; - break; - case OVERLAY_TRANSFORM_ROT_90: - stage->rotation = 90; - stage->flip = 0; - break; - case OVERLAY_TRANSFORM_ROT_180: - stage->rotation = 180; - stage->flip = 0; - break; - case OVERLAY_TRANSFORM_ROT_270: - stage->rotation = 270; - stage->flip = 0; - break; - // FIMC VFLIP = android overlay FLIP_H. - case OVERLAY_TRANSFORM_FLIP_H: - stage->rotation = 0; - stage->flip = V4L2_CID_VFLIP; - break; - case OVERLAY_TRANSFORM_FLIP_V: - stage->rotation = 0; - stage->flip = V4L2_CID_HFLIP; - break; - // FIMC rotates first but android flips first. - case OVERLAY_TRANSFORM_ROT_90+OVERLAY_TRANSFORM_FLIP_H: - stage->rotation = 90; - stage->flip = V4L2_CID_HFLIP; - break; - case OVERLAY_TRANSFORM_ROT_90+OVERLAY_TRANSFORM_FLIP_V: - stage->rotation = 90; - stage->flip = V4L2_CID_VFLIP; - break; - - default: - rc = -EINVAL; - break; - } - break; - } - - return rc; -} - -static int overlay_stage(struct overlay_control_device_t *dev, - overlay_t* overlay) { - return 0; -} - -static int overlay_commit(struct overlay_control_device_t *dev, - overlay_t* overlay) { - LOG_FUNCTION_NAME; - - overlay_object *obj = static_cast(overlay); - - overlay_ctrl_t *data = obj->data(); - overlay_ctrl_t *stage = obj->staging(); - overlay_shared_t *shared = obj->getShared(); - - int ret = 0; - int fd = obj->ctl_fd(); - - if (shared == NULL) { - LOGI("Shared Data Not Init'd!\n"); - return -1; - } - - pthread_mutex_lock(&shared->lock); - - if (!shared->controlReady) { - shared->controlReady = 1; - } - - g_s5p_fimc.params.dst.full_width = g_lcd_width; - g_s5p_fimc.params.dst.full_height = g_lcd_height; - g_s5p_fimc.params.dst.width = stage->posW; - g_s5p_fimc.params.dst.height = stage->posH; - if (g_lcd_bpp == 32) - g_s5p_fimc.params.dst.color_space = V4L2_PIX_FMT_RGB32; - else - g_s5p_fimc.params.dst.color_space = V4L2_PIX_FMT_RGB565; - ret = check_fimc_dst_constraints(&g_s5p_fimc, stage->rotation); - if (ret != 0) { - if (ret < 0) { - LOGE("Unsupported destination image size"); - goto end; - } else { - LOGD("dst width, height have changed [w= %d, h= %d] -> [w=%d, h= %d]", - stage->posW, stage->posH, g_s5p_fimc.params.dst.width, - g_s5p_fimc.params.dst.height); - stage->posW = g_s5p_fimc.params.dst.width; - stage->posH = g_s5p_fimc.params.dst.height; - } - } - - if (data->posX == stage->posX && data->posY == stage->posY && - data->posW == stage->posW && data->posH == stage->posH && - data->rotation == stage->rotation && - data->flip == stage->flip) { - LOGI("Nothing to do!\n"); - goto end; - } - - LOGD("Position/X%d/Y%d/W%d/H%d\n", data->posX, data->posY, data->posW, - data->posH); - LOGD("Adjusted Position/X%d/Y%d/W%d/H%d\n", stage->posX, stage->posY, - stage->posW, stage->posH); - LOGD("Rotation/%d\n", stage->rotation ); - - if ((ret = disable_streaming_locked(shared, fd))) - goto end; - - if (stage->flip != data->flip) { - ret = v4l2_overlay_set_flip(fd, stage->flip); - if (ret) { - LOGE("Set Flip Failed!/%d\n", ret); - goto end; - } - } - - if (stage->rotation != data->rotation) { - ret = v4l2_overlay_set_rotation(fd, stage->rotation, 0); - if (ret) { - LOGE("Set Rotation Failed!/%d\n", ret); - goto end; - } - v4l2_overlay_s_fbuf(fd, stage->rotation); - } - - ret = v4l2_overlay_set_position(fd, stage->posX, stage->posY, - stage->posW, stage->posH, stage->rotation); - if (ret) { - LOGE("Set Position Failed!/%d\n", ret); - goto end; - } - - data->posX = stage->posX; - data->posY = stage->posY; - data->posW = stage->posW; - data->posH = stage->posH; - data->rotation = stage->rotation; - data->flip = stage->flip; - - ret = enable_streaming_locked(shared, fd); - -end: - pthread_mutex_unlock(&shared->lock); - - return ret; -} - -static int overlay_control_close(struct hw_device_t *dev) -{ - LOG_FUNCTION_NAME; - - struct overlay_control_context_t* ctx = - (struct overlay_control_context_t*)dev; - overlay_object *overlay_v1; - - if (ctx) { - overlay_v1 = static_cast(ctx->overlay_video1); - - overlay_destroyOverlay((struct overlay_control_device_t *)ctx, - overlay_v1); - - free(ctx); - } - return 0; -} - -static int get_pixel_format_type(unsigned int pixelformat) -{ - switch(pixelformat) { - case V4L2_PIX_FMT_RGB32: - case V4L2_PIX_FMT_RGB565: - return PFT_RGB; - - case V4L2_PIX_FMT_NV12: - case V4L2_PIX_FMT_NV12T: - case V4L2_PIX_FMT_NV21: - case V4L2_PIX_FMT_YUV420: - return PFT_YUV420; - - case V4L2_PIX_FMT_YUYV: - case V4L2_PIX_FMT_UYVY: - case V4L2_PIX_FMT_YVYU: - case V4L2_PIX_FMT_VYUY: - case V4L2_PIX_FMT_NV16: - case V4L2_PIX_FMT_NV61: - case V4L2_PIX_FMT_YUV422P: - return PFT_YUV422; - - default: - return PFT_YUV444; - } -} - -/* check the constraints of destination image size */ -static int check_fimc_dst_constraints(s5p_fimc_t *s5p_fimc, - unsigned int rotation) -{ - int tmp = 0; - - if((s5p_fimc->params.dst.height > 0) && (s5p_fimc->params.dst.height < 16)) - s5p_fimc->params.dst.height = 16; - - if(s5p_fimc->params.dst.width%8 != 0) { - tmp = s5p_fimc->params.dst.width - (s5p_fimc->params.dst.width%8); - if(tmp <= 0) - return -1; - else - s5p_fimc->params.dst.width = tmp; - } - - return 1; -} -/* check the constraints of source image size */ -static int check_fimc_src_constraints(s5p_fimc_t *s5p_fimc) -{ - int format_type = 0; - - if(s5p_fimc->params.src.full_width < 16 || - s5p_fimc->params.src.full_height < 8 ) - return -1; - - if(s5p_fimc->hw_ver == 0x50) { - format_type = get_pixel_format_type(s5p_fimc->params.src.color_space); - switch (format_type) { - case PFT_YUV420: - if (s5p_fimc->params.src.height%2 != 0) - s5p_fimc->params.src.height = s5p_fimc->params.src.height - - (s5p_fimc->params.src.height)%2; - - if (s5p_fimc->params.src.width%2 != 0) - s5p_fimc->params.src.width = s5p_fimc->params.src.width - - (s5p_fimc->params.src.width)%2; - break; - - case PFT_YUV422: - if (s5p_fimc->params.src.width%2 != 0) - s5p_fimc->params.src.width = s5p_fimc->params.src.width - - (s5p_fimc->params.src.width)%2; - } - } else { - if (s5p_fimc->params.src.height < 8) { - s5p_fimc->params.src.height = 8; - } - - if (s5p_fimc->params.src.width%16 != 0) { - s5p_fimc->params.src.width = s5p_fimc->params.src.width - - (s5p_fimc->params.src.width)%16; - } - } - - return 1; -} - -/**************************************************************************** - * Data module - *****************************************************************************/ - -int overlay_initialize(struct overlay_data_device_t *dev, - overlay_handle_t handle) -{ - LOG_FUNCTION_NAME; - - struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; - struct stat stat; - - int i; - int rc = -1; - - ctx->num_buffers = handle_num_buffers(handle); - ctx->width = handle_width(handle); - ctx->height = handle_height(handle); - ctx->format = handle_format(handle); - ctx->ctl_fd = handle_ctl_fd(handle); - ctx->shared_fd = handle_shared_fd(handle); - ctx->shared_size = handle_shared_size(handle); - ctx->shared = NULL; - ctx->qd_buf_count = 0; - ctx->cacheable_buffers = 0; - - if (ctx->format >= HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP - && ctx->format < HAL_PIXEL_FORMAT_CUSTOM_MAX) - ctx->zerocopy = true; - else - ctx->zerocopy = false; - - if (fstat(ctx->ctl_fd, &stat)) { - LOGE("Error = %s from %s\n", strerror(errno), "overlay initialize"); - return -1; - } - - if (open_shared_data(ctx)) { - return -1; - } - - ctx->shared->dataReady = 0; - - ctx->mapping_data = new struct mapping_data; - ctx->buffers = new void* [ctx->num_buffers]; - ctx->buffers_len = new size_t[ctx->num_buffers]; - - if (!ctx->buffers || !ctx->buffers_len || !ctx->mapping_data) { - LOGE("Failed alloc'ing buffer arrays\n"); - goto error; - } else { - - /* - * in the zero copy case, - * don't need to mmap buffer for source - */ - if (ctx->zerocopy) - rc = 0; - else { - for (i = 0; i < ctx->num_buffers; i++) { - rc = v4l2_overlay_map_buf(ctx->ctl_fd, i, &ctx->buffers[i], - &ctx->buffers_len[i]); - if (rc) { - LOGE("Failed mapping buffers\n"); - goto error; - } - } - } - } - - v4l2_overlay_init_fimc(ctx->ctl_fd, &g_s5p_fimc); - - return ( rc ); - -error: - - if(ctx->mapping_data) - delete (ctx->mapping_data); - if(ctx->buffers) - delete [] ctx->buffers; - if(ctx->buffers_len) - delete [] ctx->buffers_len; - - close_shared_data( ctx ); - - return -1; -} - -static int overlay_resizeInput(struct overlay_data_device_t *dev, uint32_t w, - uint32_t h) -{ - int rc = -1; - int ret = 0; - - struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; - - if ((ctx->width == (int)w) && (ctx->width == (int)h)) { - LOGV("same as current width and height. so do nothing"); - return 0; - } - - if (!ctx->shared) { - LOGI("Shared Data Not Init'd!\n"); - return -1; - } - - if (ctx->shared->dataReady) { - LOGV("Either setCrop() or queueBuffer() was called prior to this!" - "Therefore failing this call.\n"); - return -1; - } - - pthread_mutex_lock(&ctx->shared->lock); - - if ((rc = disable_streaming_locked(ctx->shared, ctx->ctl_fd))) - goto end; - - if (!ctx->zerocopy) { - for (int i = 0; i < ctx->num_buffers; i++) { - v4l2_overlay_unmap_buf(ctx->buffers[i], ctx->buffers_len[i]); - } - } - - g_s5p_fimc.params.src.full_width = w; - g_s5p_fimc.params.src.full_height = h; - g_s5p_fimc.params.src.width = w; - g_s5p_fimc.params.src.height = h; - set_color_space(ctx->format, &g_s5p_fimc.params.src.color_space); - ret = check_fimc_src_constraints(&g_s5p_fimc); - - if(ret != 0) { - if(ret < 0) { - LOGE("Not supported source image size"); - goto end; - } else { - LOGD("src width, height are changed [w= %d, h= %d] -> [w=%d, h= %d]" - , w, h, g_s5p_fimc.params.src.width - , g_s5p_fimc.params.src.height); - w = g_s5p_fimc.params.src.width; - h = g_s5p_fimc.params.src.height; - } - } - - rc = v4l2_overlay_init(ctx->ctl_fd, w, h, ctx->format, phyAddr); - if (rc) { - LOGE("Error initializing overlay"); - goto end; - } - rc = v4l2_overlay_set_crop(ctx->ctl_fd, 0, 0, w, h); - if (rc) { - LOGE("Error setting crop window\n"); - goto end; - } - rc = v4l2_overlay_req_buf(ctx->ctl_fd, (uint32_t *)(&ctx->num_buffers), - ctx->cacheable_buffers, (int)ctx->zerocopy); - if (rc) { - LOGE("Error creating buffers"); - goto end; - } - - if (!ctx->zerocopy) { - for (int i = 0; i < ctx->num_buffers; i++) - v4l2_overlay_map_buf(ctx->ctl_fd, i, &ctx->buffers[i], - &ctx->buffers_len[i]); - } - - rc = enable_streaming_locked(ctx->shared, ctx->ctl_fd); - -end: - pthread_mutex_unlock(&ctx->shared->lock); - - return rc; -} - - -static int overlay_data_setParameter(struct overlay_data_device_t *dev, - int param, int value) -{ - int ret = 0; - struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; - - if (ctx->shared == NULL) { - LOGI("Shared Data Not Init'd!\n"); - return -1; - } - - if (ctx->shared->dataReady) { - LOGI("Too late. Cant set it now!\n"); - return -1; - } - - if (param == CACHEABLE_BUFFERS) - ctx->cacheable_buffers = value; - - return ( ret ); -} - - -static int overlay_setCrop(struct overlay_data_device_t *dev, uint32_t x, - uint32_t y, uint32_t w, uint32_t h) { - LOG_FUNCTION_NAME; - - int rc = 0; - int cnt = 0; - struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; - - if (ctx->shared == NULL) { - LOGI("Shared Data Not Init'd!\n"); - return -1; - } - - pthread_mutex_lock(&ctx->shared->lock); - - ctx->shared->dataReady = 1; - - if (ctx->data.cropX == x && ctx->data.cropY == y && ctx->data.cropW == w - && ctx->data.cropH == h) { - goto end; - } - - ctx->data.cropX = x; - ctx->data.cropY = y; - ctx->data.cropW = w; - ctx->data.cropH = h; - - LOGD("Crop Win/X%d/Y%d/W%d/H%d\n", x, y, w, h ); - - if ((rc = disable_streaming_locked(ctx->shared, ctx->ctl_fd))) - goto end; - - rc = v4l2_overlay_set_crop(ctx->ctl_fd, x, y, w, h); - if (rc) { - LOGE("Set Crop Window Failed!/%d\n", rc); - } - - rc = enable_streaming_locked(ctx->shared, ctx->ctl_fd); - -end: - pthread_mutex_unlock(&ctx->shared->lock); - return rc; -} - -static int overlay_getCrop(struct overlay_data_device_t *dev , uint32_t* x, - uint32_t* y, uint32_t* w, uint32_t* h) { - struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; - - return v4l2_overlay_get_crop(ctx->ctl_fd, x, y, w, h); -} - -int overlay_dequeueBuffer(struct overlay_data_device_t *dev, - overlay_buffer_t *buffer) { - /* blocks until a buffer is available and return an opaque structure - * representing this buffer. - */ - - struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; - - int rc=0; - int i = -1; - uint32_t num = 0; - int cnt = 0; - - pthread_mutex_lock(&ctx->shared->lock); - if ( ctx->shared->streamingReset ) { - ctx->shared->streamingReset = 0; - pthread_mutex_unlock(&ctx->shared->lock); - return ALL_BUFFERS_FLUSHED; - } - pthread_mutex_unlock(&ctx->shared->lock); - - /* If we are not streaming dequeue will fail, - skip to prevent error printouts */ - if (ctx->shared->streamEn && ctx->qd_buf_count) { - if ((rc = v4l2_overlay_dq_buf( ctx->ctl_fd, &i ,ctx->zerocopy)) != 0) { - LOGE("Failed to DQ/%d\n", rc); - } - else if (i < 0 || i > ctx->num_buffers) { - rc = -EINVAL; - } else { - *((int *)buffer) = i; - ctx->qd_buf_count --; - } - } else { - rc = -1; - } - - return rc; -} - -int overlay_queueBuffer(struct overlay_data_device_t *dev, - overlay_buffer_t buffer) { - struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; - - int cnt = 0; - - pthread_mutex_lock(&ctx->shared->lock); - if ( ctx->shared->streamingReset ) { - ctx->shared->streamingReset = 0; - pthread_mutex_unlock(&ctx->shared->lock); - return ALL_BUFFERS_FLUSHED; - } - pthread_mutex_unlock(&ctx->shared->lock); - - /* Catch the case where the data side had no need to set the crop window */ - if (!ctx->shared->dataReady) { - ctx->shared->dataReady = 1; - enable_streaming(ctx->shared, ctx->ctl_fd); - } - - if (!ctx->shared->controlReady) return -1; - int rc = v4l2_overlay_q_buf( ctx->ctl_fd, (int)buffer, (int) ctx->zerocopy ); - if (rc == 0 && ctx->qd_buf_count < ctx->num_buffers) { - ctx->qd_buf_count ++; - } - - return rc; -} - -void *overlay_getBufferAddress(struct overlay_data_device_t *dev, - overlay_buffer_t buffer) -{ - LOG_FUNCTION_NAME; - - /* this may fail (NULL) if this feature is not supported. In that case, - * presumably, there is some other HAL module that can fill the buffer, - * using a DSP for instance - */ - int ret; - struct v4l2_buffer buf; - struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; - - if (ctx->zerocopy) - return NULL; - - if ((int)buffer >= 0 && (int)buffer < ctx->num_buffers) - return (void*) ctx->buffers[(int)buffer]; - else - return NULL; -} - -int overlay_getBufferCount(struct overlay_data_device_t *dev) -{ - LOG_FUNCTION_NAME; - - struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; - - return (ctx->num_buffers); -} - -static int overlay_data_close(struct hw_device_t *dev) { - - LOG_FUNCTION_NAME; - - struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; - int rc; - - if (ctx) { - overlay_data_device_t *overlay_dev = &ctx->device; - int buf; - int i; - - pthread_mutex_lock(&ctx->shared->lock); - - if (!ctx->zerocopy) - for (i = 0; i < ctx->num_buffers; i++) { - LOGV("Unmap Buffer/%d/%08lx/%d", i, (unsigned long)ctx->buffers[i], - ctx->buffers_len[i] ); - rc = v4l2_overlay_unmap_buf(ctx->buffers[i], ctx->buffers_len[i]); - if (rc != 0) { - LOGE("Error unmapping the buffer/%d/%d", i, rc); - } - } - - delete (ctx->mapping_data); - delete [] ctx->buffers; - delete [] ctx->buffers_len; - - pthread_mutex_unlock(&ctx->shared->lock); - - ctx->shared->dataReady = 0; - close_shared_data( ctx ); - - free(ctx); - } - - return 0; -} - -/*****************************************************************************/ - -static int overlay_device_open(const struct hw_module_t* module, - const char* name, struct hw_device_t** device) -{ - LOG_FUNCTION_NAME; - int status = -EINVAL; - - if (!strcmp(name, OVERLAY_HARDWARE_CONTROL)) { - struct overlay_control_context_t *dev; - dev = (overlay_control_context_t*)malloc(sizeof(*dev)); - - /* initialize our state here */ - memset(dev, 0, sizeof(*dev)); - - /* initialize the procs */ - dev->device.common.tag = HARDWARE_DEVICE_TAG; - dev->device.common.version = 0; - dev->device.common.module = const_cast(module); - dev->device.common.close = overlay_control_close; - - dev->device.get = overlay_get; - dev->device.createOverlay = overlay_createOverlay; - dev->device.destroyOverlay = overlay_destroyOverlay; - dev->device.setPosition = overlay_setPosition; - dev->device.getPosition = overlay_getPosition; - dev->device.setParameter = overlay_setParameter; - dev->device.stage = overlay_stage; - dev->device.commit = overlay_commit; - - *device = &dev->device.common; - status = 0; - } else if (!strcmp(name, OVERLAY_HARDWARE_DATA)) { - struct overlay_data_context_t *dev; - dev = (overlay_data_context_t*)malloc(sizeof(*dev)); - - /* initialize our state here */ - memset(dev, 0, sizeof(*dev)); - - /* initialize the procs */ - dev->device.common.tag = HARDWARE_DEVICE_TAG; - dev->device.common.version = 0; - dev->device.common.module = const_cast(module); - dev->device.common.close = overlay_data_close; - - dev->device.initialize = overlay_initialize; - dev->device.resizeInput = overlay_resizeInput; - dev->device.setCrop = overlay_setCrop; - dev->device.getCrop = overlay_getCrop; - dev->device.setParameter = overlay_data_setParameter; - dev->device.dequeueBuffer = overlay_dequeueBuffer; - dev->device.queueBuffer = overlay_queueBuffer; - dev->device.getBufferAddress = overlay_getBufferAddress; - dev->device.getBufferCount = overlay_getBufferCount; - - *device = &dev->device.common; - status = 0; - } - return status; -} diff --git a/aries/liboverlay/v4l2_utils.c b/aries/liboverlay/v4l2_utils.c deleted file mode 100644 index f3ebbc2..0000000 --- a/aries/liboverlay/v4l2_utils.c +++ /dev/null @@ -1,788 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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. - */ - -/* #define OVERLAY_DEBUG 1 */ -#define LOG_TAG "v4l2_utils" - -#include -#include -#include -#include -#include -#include -#include -#include "v4l2_utils.h" - -#ifndef V4L2_DEVICE -#define V4L2_DEVICE "/dev/video1" -#endif - - - -#define LOG_FUNCTION_NAME LOGV("%s: %s", __FILE__, __func__); - -#define V4L2_CID_PRIV_OFFSET 0x0 -#define V4L2_CID_PRIV_ROTATION (V4L2_CID_PRIVATE_BASE \ - + V4L2_CID_PRIV_OFFSET + 0) -#define V4L2_CID_PRIV_COLORKEY (V4L2_CID_PRIVATE_BASE \ - + V4L2_CID_PRIV_OFFSET + 1) -#define V4L2_CID_PRIV_COLORKEY_EN (V4L2_CID_PRIVATE_BASE \ - + V4L2_CID_PRIV_OFFSET + 2) - -extern unsigned int g_lcd_width; -extern unsigned int g_lcd_height; -extern unsigned int g_lcd_bpp; - -int v4l2_overlay_get(int name) -{ - int result = -1; - switch (name) { - case OVERLAY_MINIFICATION_LIMIT: - result = 4; /* 0 = no limit */ - break; - case OVERLAY_MAGNIFICATION_LIMIT: - result = 2; /* 0 = no limit */ - break; - case OVERLAY_SCALING_FRAC_BITS: - result = 0; /* 0 = infinite */ - break; - case OVERLAY_ROTATION_STEP_DEG: - result = 90; /* 90 rotation steps (for instance) */ - break; - case OVERLAY_HORIZONTAL_ALIGNMENT: - result = 1; /* 1-pixel alignment */ - break; - case OVERLAY_VERTICAL_ALIGNMENT: - result = 1; /* 1-pixel alignment */ - break; - case OVERLAY_WIDTH_ALIGNMENT: - result = 1; /* 1-pixel alignment */ - break; - case OVERLAY_HEIGHT_ALIGNMENT: - result = 1; /* 1-pixel alignment */ - break; - } - return result; -} - -int v4l2_overlay_open(int id) -{ - LOG_FUNCTION_NAME - return open(V4L2_DEVICE, O_RDWR); -} - -int v4l2_overlay_init_fimc(int fd, s5p_fimc_t *s5p_fimc) -{ - int ret; - struct v4l2_control vc; - - if (fd < 0) - return -1; - - vc.id = V4L2_CID_FIMC_VERSION; - vc.value = 0; - - s5p_fimc->dev_fd = fd; - - ret = ioctl(s5p_fimc->dev_fd, VIDIOC_G_CTRL, &vc); - if (ret < 0) { - LOGE("Error in video VIDIOC_G_CTRL - V4L2_CID_FIMC_VERSION (%d)", ret); - LOGE("FIMC version is set with default"); - vc.value = 0x43; - } - s5p_fimc->hw_ver = vc.value; - return 0; -} - -void dump_pixfmt(struct v4l2_pix_format *pix) -{ - LOGV("w: %d\n", pix->width); - LOGV("h: %d\n", pix->height); - LOGV("color: %x\n", pix->colorspace); - - switch (pix->pixelformat) { - case V4L2_PIX_FMT_YUYV: - LOGV("YUYV\n"); - break; - case V4L2_PIX_FMT_UYVY: - LOGV("UYVY\n"); - break; - case V4L2_PIX_FMT_RGB565: - LOGV("RGB565\n"); - break; - case V4L2_PIX_FMT_RGB565X: - LOGV("RGB565X\n"); - break; - default: - LOGV("not supported\n"); - } -} - -void dump_crop(struct v4l2_crop *crop) -{ - LOGV("crop l: %d ", crop->c.left); - LOGV("crop t: %d ", crop->c.top); - LOGV("crop w: %d ", crop->c.width); - LOGV("crop h: %d\n", crop->c.height); -} - -void dump_window(struct v4l2_window *win) -{ - LOGV("window l: %d ", win->w.left); - LOGV("window t: %d ", win->w.top); - LOGV("window w: %d ", win->w.width); - LOGV("window h: %d\n", win->w.height); -} - -void v4l2_overlay_dump_state(int fd) -{ - struct v4l2_format format; - struct v4l2_crop crop; - int ret; - - LOGV("dumping driver state:"); - format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - ret = ioctl(fd, VIDIOC_G_FMT, &format); - if (ret < 0) - return; - LOGV("output pixfmt:\n"); - dump_pixfmt(&format.fmt.pix); - - format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; - ret = ioctl(fd, VIDIOC_G_FMT, &format); - if (ret < 0) - return; - LOGV("v4l2_overlay window:\n"); - dump_window(&format.fmt.win); - - crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - ret = ioctl(fd, VIDIOC_G_CROP, &crop); - if (ret < 0) - return; - LOGV("output crop:\n"); - dump_crop(&crop); -} - -static void error(int fd, const char *msg) -{ - LOGE("Error = %s from %s", strerror(errno), msg); -#ifdef OVERLAY_DEBUG - v4l2_overlay_dump_state(fd); -#endif -} - -static int v4l2_overlay_ioctl(int fd, int req, void *arg, const char* msg) -{ - int ret; - ret = ioctl(fd, req, arg); - if (ret < 0) { - error(fd, msg); - return -1; - } - return 0; -} - -#define v4l2_fourcc(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \ - ((__u32)(c) << 16) | ((__u32)(d) << 24)) -/* 12 Y/CbCr 4:2:0 64x32 macroblocks */ -#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2') - -int configure_pixfmt(struct v4l2_pix_format *pix, int32_t fmt, - uint32_t w, uint32_t h) -{ - LOG_FUNCTION_NAME - int fd; - - switch (fmt) { - case OVERLAY_FORMAT_RGBA_8888: - return -1; - case OVERLAY_FORMAT_RGB_565: - pix->pixelformat = V4L2_PIX_FMT_RGB565; - break; - case OVERLAY_FORMAT_BGRA_8888: - return -1; - case OVERLAY_FORMAT_YCbYCr_422_I: - case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I: - pix->pixelformat = V4L2_PIX_FMT_YUYV; - break; - case OVERLAY_FORMAT_CbYCrY_422_I: - case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I: - pix->pixelformat = V4L2_PIX_FMT_UYVY; - break; - case HAL_PIXEL_FORMAT_YCbCr_420_P: - pix->pixelformat = V4L2_PIX_FMT_YUV420; - break; - case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP: - pix->pixelformat = V4L2_PIX_FMT_NV12T; - break; - case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP: - pix->pixelformat = V4L2_PIX_FMT_NV21; - break; - default: - return -1; - } - pix->width = w; - pix->height = h; - return 0; -} - -static void configure_window(struct v4l2_window *win, int32_t w, - int32_t h, int32_t x, int32_t y) -{ - LOG_FUNCTION_NAME - - win->w.left = x; - win->w.top = y; - win->w.width = w; - win->w.height = h; -} - -void get_window(struct v4l2_format *format, int32_t *x, - int32_t *y, int32_t *w, int32_t *h) -{ - LOG_FUNCTION_NAME - - *x = format->fmt.win.w.left; - *y = format->fmt.win.w.top; - *w = format->fmt.win.w.width; - *h = format->fmt.win.w.height; -} - -int v4l2_overlay_init(int fd, uint32_t w, uint32_t h, uint32_t fmt, - uint32_t addr) -{ - LOG_FUNCTION_NAME - - struct v4l2_format format; - struct v4l2_framebuffer fbuf; - int ret; - - format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FMT, &format, "get format"); - if (ret) - return ret; - LOGV("v4l2_overlay_init:: w=%d h=%d\n", format.fmt.pix.width, - format.fmt.pix.height); - - format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - configure_pixfmt(&format.fmt.pix, fmt, w, h); - LOGV("v4l2_overlay_init:: w=%d h=%d\n", format.fmt.pix.width, - format.fmt.pix.height); - ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FMT, &format, "set output format"); - if (ret) - return ret; - - ret = v4l2_overlay_s_fbuf(fd, 0); - if (ret) - return ret; - - return ret; -} - -int v4l2_overlay_s_fbuf(int fd, int rotation) -{ - struct v4l2_framebuffer fbuf; - int ret; - - /* configure the v4l2_overlay framebuffer */ - ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FBUF, &fbuf, "get fbuf"); - if (ret) - return ret; - - /* if fbuf.base value is set by 0, using local DMA. */ - fbuf.base = (void *)0; - if (rotation == 0 || rotation == 180) { - fbuf.fmt.width = g_lcd_width; - fbuf.fmt.height = g_lcd_height; - } else { - fbuf.fmt.width = g_lcd_height; - fbuf.fmt.height = g_lcd_width; - } - - if (g_lcd_bpp == 32) - fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB32; - else - fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB565; - - ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FBUF, &fbuf, "set fbuf"); - if (ret) - return ret; - - return ret; -} - -int v4l2_overlay_get_input_size_and_format(int fd, uint32_t *w, uint32_t *h - , uint32_t *fmt) -{ - LOG_FUNCTION_NAME - - struct v4l2_format format; - int ret; - - format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FMT, &format, "get format"); - *w = format.fmt.pix.width; - *h = format.fmt.pix.height; - if (format.fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) - *fmt = OVERLAY_FORMAT_CbYCrY_422_I; - else - return -EINVAL; - return ret; -} - -int v4l2_overlay_set_position(int fd, int32_t x, int32_t y - , int32_t w, int32_t h, int rotation) -{ - LOG_FUNCTION_NAME - - struct v4l2_format format; - int ret; - int rot_x = 0, rot_y = 0 , rot_w = 0, rot_h = 0; - - /* configure the src format pix */ - /* configure the dst v4l2_overlay window */ - format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; - ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FMT, &format, - "get v4l2_overlay format"); - if (ret) - return ret; - LOGV("v4l2_overlay_set_position:: w=%d h=%d", format.fmt.win.w.width - , format.fmt.win.w.height); - - if (rotation == 0) { - rot_x = x; - rot_y = y; - rot_w = w; - rot_h = h; - } else if (rotation == 90) { - rot_x = y; - rot_y = g_lcd_width - (x + w); - rot_w = h; - rot_h = w; - } else if (rotation == 180) { - rot_x = g_lcd_width - (x + w); - rot_y = g_lcd_height - (y + h); - rot_w = w; - rot_h = h; - } else if (rotation == 270) { - rot_x = g_lcd_height - (y + h); - rot_y = x; - rot_w = h; - rot_h = w; - } - - configure_window(&format.fmt.win, rot_w, rot_h, rot_x, rot_y); - - format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; - ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FMT, &format, - "set v4l2_overlay format"); - - LOGV("v4l2_overlay_set_position:: w=%d h=%d rotation=%d" - , format.fmt.win.w.width, format.fmt.win.w.height, rotation); - - if (ret) - return ret; - v4l2_overlay_dump_state(fd); - - return 0; -} - -int v4l2_overlay_get_position(int fd, int32_t *x, int32_t *y, int32_t *w, - int32_t *h) -{ - struct v4l2_format format; - int ret; - - format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; - ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FMT, &format, - "get v4l2_overlay format"); - - if (ret) - return ret; - - get_window(&format, x, y, w, h); - - return 0; -} - -int v4l2_overlay_set_crop(int fd, uint32_t x, uint32_t y, uint32_t w, - uint32_t h) -{ - LOG_FUNCTION_NAME - - struct v4l2_crop crop; - int ret; - - crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - ret = v4l2_overlay_ioctl(fd, VIDIOC_G_CROP, &crop, "get crop"); - crop.c.left = x; - crop.c.top = y; - crop.c.width = w; - crop.c.height = h; - crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - - LOGV("%s:crop.c.left = %d\n", __func__, crop.c.left); - LOGV("%s:crop.c.top = %d\n", __func__, crop.c.top); - LOGV("%s:crop.c.width = %d\n", __func__, crop.c.width); - LOGV("%s:crop.c.height = %d\n", __func__, crop.c.height); - LOGV("%s:crop.type = 0x%x\n", __func__, crop.type); - - return v4l2_overlay_ioctl(fd, VIDIOC_S_CROP, &crop, "set crop"); -} - -int v4l2_overlay_get_crop(int fd, uint32_t *x, uint32_t *y, uint32_t *w, - uint32_t *h) -{ - LOG_FUNCTION_NAME - - struct v4l2_crop crop; - int ret; - - crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - ret = v4l2_overlay_ioctl(fd, VIDIOC_G_CROP, &crop, "get crop"); - *x = crop.c.left; - *y = crop.c.top; - *w = crop.c.width; - *h = crop.c.height; - return ret; -} - -int v4l2_overlay_set_flip(int fd, int flip) -{ - LOG_FUNCTION_NAME - - int ret; - struct v4l2_control ctrl_v; - struct v4l2_control ctrl_h; - - switch (flip) { - case 0: - ctrl_v.value = 0; - ctrl_h.value = 0; - break; - case V4L2_CID_HFLIP: - ctrl_v.value = 0; - ctrl_h.value = 1; - break; - case V4L2_CID_VFLIP: - ctrl_v.value = 1; - ctrl_h.value = 0; - break; - default: - return -1; - } - - ctrl_v.id = V4L2_CID_VFLIP; - ret = v4l2_overlay_ioctl(fd, VIDIOC_S_CTRL, &ctrl_v, "set vflip"); - if (ret) return ret; - - ctrl_h.id = V4L2_CID_HFLIP; - ret = v4l2_overlay_ioctl(fd, VIDIOC_S_CTRL, &ctrl_h, "set hflip"); - return ret; -} - -int v4l2_overlay_set_rotation(int fd, int degree, int step) -{ - LOG_FUNCTION_NAME - - int ret; - struct v4l2_control ctrl; - - ctrl.id = V4L2_CID_PRIV_ROTATION; - ctrl.value = degree; - ret = v4l2_overlay_ioctl(fd, VIDIOC_S_CTRL, &ctrl, "set rotation"); - - return ret; -} - -int v4l2_overlay_set_colorkey(int fd, int enable, int colorkey) -{ - LOG_FUNCTION_NAME - - int ret; - struct v4l2_framebuffer fbuf; - struct v4l2_format fmt; - - memset(&fbuf, 0, sizeof(fbuf)); - ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FBUF, &fbuf, - "get transparency enables"); - - if (ret) - return ret; - - if (enable) - fbuf.flags |= V4L2_FBUF_FLAG_CHROMAKEY; - else - fbuf.flags &= ~V4L2_FBUF_FLAG_CHROMAKEY; - - ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FBUF, &fbuf, "enable colorkey"); - - if (ret) - return ret; - - if (enable) { - memset(&fmt, 0, sizeof(fmt)); - fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; - ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FMT, &fmt, "get colorkey"); - - if (ret) - return ret; - - fmt.fmt.win.chromakey = colorkey & 0xFFFFFF; - - ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FMT, &fmt, "set colorkey"); - } - - return ret; -} - -int v4l2_overlay_set_global_alpha(int fd, int enable, int alpha) -{ - LOG_FUNCTION_NAME - - int ret; - struct v4l2_framebuffer fbuf; - struct v4l2_format fmt; - - memset(&fbuf, 0, sizeof(fbuf)); - ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FBUF, &fbuf, - "get transparency enables"); - - if (ret) - return ret; - - if (enable) - fbuf.flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; - else - fbuf.flags &= ~V4L2_FBUF_FLAG_GLOBAL_ALPHA; - - ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FBUF, &fbuf, "enable global alpha"); - - if (ret) - return ret; - - if (enable) { - memset(&fmt, 0, sizeof(fmt)); - fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; - ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FMT, &fmt, "get global alpha"); - - if (ret) - return ret; - - fmt.fmt.win.global_alpha = alpha & 0xFF; - - ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FMT, &fmt, "set global alpha"); - } - - return ret; -} - -int v4l2_overlay_set_local_alpha(int fd, int enable) -{ - int ret; - struct v4l2_framebuffer fbuf; - - ret = 0; - - return ret; -} - -int v4l2_overlay_req_buf(int fd, uint32_t *num_bufs, int cacheable_buffers, int zerocopy) -{ - struct v4l2_requestbuffers reqbuf; - int ret, i; - - reqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - - if (zerocopy) - reqbuf.memory = V4L2_MEMORY_USERPTR; - else - reqbuf.memory = V4L2_MEMORY_MMAP; - reqbuf.count = *num_bufs; - - ret = ioctl(fd, VIDIOC_REQBUFS, &reqbuf); - if (ret < 0) { - error(fd, "reqbuf ioctl"); - return ret; - } - - if (reqbuf.count > *num_bufs) { - error(fd, "Not enough buffer structs passed to get_buffers"); - return -ENOMEM; - } - *num_bufs = reqbuf.count; - - return 0; -} - -static int is_mmaped(struct v4l2_buffer *buf) -{ - return buf->flags == V4L2_BUF_FLAG_MAPPED; -} - -static int is_queued(struct v4l2_buffer *buf) -{ - /* is either on the input or output queue in the kernel */ - return (buf->flags & V4L2_BUF_FLAG_QUEUED) || - (buf->flags & V4L2_BUF_FLAG_DONE); -} - -static int is_dequeued(struct v4l2_buffer *buf) -{ - /* is on neither input or output queue in kernel */ - return !(buf->flags & V4L2_BUF_FLAG_QUEUED) && - !(buf->flags & V4L2_BUF_FLAG_DONE); -} - -int v4l2_overlay_query_buffer(int fd, int index, struct v4l2_buffer *buf) -{ - LOG_FUNCTION_NAME - - memset(buf, 0, sizeof(struct v4l2_buffer)); - - buf->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - buf->memory = V4L2_MEMORY_MMAP; - buf->index = index; - LOGV("query buffer, mem=%u type=%u index=%u\n", - buf->memory, buf->type, buf->index); - return v4l2_overlay_ioctl(fd, VIDIOC_QUERYBUF, buf, "querybuf ioctl"); -} - -int v4l2_overlay_map_buf(int fd, int index, void **start, size_t *len) -{ - LOG_FUNCTION_NAME - - struct v4l2_buffer buf; - int ret; - - ret = v4l2_overlay_query_buffer(fd, index, &buf); - if (ret) - return ret; - - if (is_mmaped(&buf)) { - LOGE("Trying to mmap buffers that are already mapped!\n"); - return -EINVAL; - } - - *len = buf.length; - *start = mmap(NULL, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, - fd, buf.m.offset); - if (*start == MAP_FAILED) { - LOGE("map failed, length=%u offset=%u\n", buf.length, buf.m.offset); - return -EINVAL; - } - return 0; -} - -int v4l2_overlay_unmap_buf(void *start, size_t len) -{ - LOG_FUNCTION_NAME - return munmap(start, len); -} - - -int v4l2_overlay_get_caps(int fd, struct v4l2_capability *caps) -{ - return v4l2_overlay_ioctl(fd, VIDIOC_QUERYCAP, caps, "query cap"); -} - -int v4l2_overlay_stream_on(int fd) -{ - int ret; - uint32_t type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - - ret = v4l2_overlay_set_local_alpha(fd, 1); - if (ret) - return ret; - - ret = v4l2_overlay_ioctl(fd, VIDIOC_STREAMON, &type, "stream on"); - - return ret; -} - -int v4l2_overlay_stream_off(int fd) -{ - int ret; - uint32_t type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - - ret = v4l2_overlay_set_local_alpha(fd, 0); - if (ret) - return ret; - - ret = v4l2_overlay_ioctl(fd, VIDIOC_STREAMOFF, &type, "stream off"); - - return ret; -} - -int v4l2_overlay_q_buf(int fd, int buffer, int zerocopy) -{ - struct v4l2_buffer buf; - int ret; - - if (zerocopy) { - uint8_t *pPhyYAddr; - uint8_t *pPhyCAddr; - struct fimc_buf fimc_src_buf; - uint8_t index; - - memcpy(&pPhyYAddr, (void *) buffer, sizeof(pPhyYAddr)); - memcpy(&pPhyCAddr, (void *) (buffer + sizeof(pPhyYAddr)), - sizeof(pPhyCAddr)); - memcpy(&index, - (void *) (buffer + sizeof(pPhyYAddr) + sizeof(pPhyCAddr)), - sizeof(index)); - - fimc_src_buf.base[0] = (dma_addr_t) pPhyYAddr; - fimc_src_buf.base[1] = (dma_addr_t) pPhyCAddr; - fimc_src_buf.base[2] = - (dma_addr_t) (pPhyCAddr + (pPhyCAddr - pPhyYAddr)/4); - - buf.index = index; - buf.memory = V4L2_MEMORY_USERPTR; - buf.m.userptr = (unsigned long)&fimc_src_buf; - buf.length = 0; - } else { - buf.index = buffer; - buf.memory = V4L2_MEMORY_MMAP; - } - - buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - buf.field = V4L2_FIELD_NONE; - buf.timestamp.tv_sec = 0; - buf.timestamp.tv_usec = 0; - buf.flags = 0; - - return v4l2_overlay_ioctl(fd, VIDIOC_QBUF, &buf, "qbuf"); -} - -int v4l2_overlay_dq_buf(int fd, int *index, int zerocopy) -{ - struct v4l2_buffer buf; - int ret; - - buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - - if (zerocopy) - buf.memory = V4L2_MEMORY_USERPTR; - else - buf.memory = V4L2_MEMORY_MMAP; - - ret = v4l2_overlay_ioctl(fd, VIDIOC_DQBUF, &buf, "dqbuf"); - if (ret) - return ret; - *index = buf.index; - return 0; -} diff --git a/aries/liboverlay/v4l2_utils.h b/aries/liboverlay/v4l2_utils.h deleted file mode 100644 index 02797c3..0000000 --- a/aries/liboverlay/v4l2_utils.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2009 Google Inc. All Rights Reserved. - * Author: rschultz@google.com (Rebecca Schultz Zavin) - */ - -#ifndef ANDROID_ZOOM_REPO_HARDWARE_SEC_LIBOVERLAY_V4L2_UTILS_H_ -#define ANDROID_ZOOM_REPO_HARDWARE_SEC_LIBOVERLAY_V4L2_UTILS_H_ - -#include "s5p_fimc.h" - -int v4l2_overlay_open(int id); -int v4l2_overlay_get_caps(int fd, struct v4l2_capability *caps); -int v4l2_overlay_req_buf(int fd, uint32_t *num_bufs, int cacheable_buffers, - int zerocopy); -int v4l2_overlay_query_buffer(int fd, int index, struct v4l2_buffer *buf); -int v4l2_overlay_map_buf(int fd, int index, void **start, size_t *len); -int v4l2_overlay_unmap_buf(void *start, size_t len); -int v4l2_overlay_stream_on(int fd); -int v4l2_overlay_stream_off(int fd); -int v4l2_overlay_q_buf(int fd, int index, int zerocopy); -int v4l2_overlay_dq_buf(int fd, int *index, int zerocopy); -int v4l2_overlay_init(int fd, uint32_t w, uint32_t h, uint32_t fmt, - uint32_t addr); -int v4l2_overlay_get_input_size(int fd, uint32_t *w, uint32_t *h, - uint32_t *fmt); -int v4l2_overlay_set_position(int fd, int32_t x, int32_t y, int32_t w, - int32_t h, int rotation); -int v4l2_overlay_get_position(int fd, int32_t *x, int32_t *y, int32_t *w, - int32_t *h); -int v4l2_overlay_set_crop(int fd, uint32_t x, uint32_t y, uint32_t w, - uint32_t h); -int v4l2_overlay_get_crop(int fd, uint32_t *x, uint32_t *y, uint32_t *w, - uint32_t *h); -int v4l2_overlay_set_flip(int fd, int degree); -int v4l2_overlay_set_rotation(int fd, int degree, int step); -int v4l2_overlay_set_colorkey(int fd, int enable, int colorkey); -int v4l2_overlay_set_global_alpha(int fd, int enable, int alpha); -int v4l2_overlay_set_local_alpha(int fd, int enable); -int v4l2_overlay_init_fimc(int fd, s5p_fimc_t *s5p_fimc); -int v4l2_overlay_s_fbuf(int fd, int rotation); - -enum { - V4L2_OVERLAY_PLANE_GRAPHICS, - V4L2_OVERLAY_PLANE_VIDEO1, - V4L2_OVERLAY_PLANE_VIDEO2, -}; - -enum { - /* support customed format for zero copy */ - HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x21, - HAL_PIXEL_FORMAT_YCbCr_420_P = 0x13, - HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP = 0x100, - HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I = 0x101, - HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I = 0x102, - HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP = 0x103, - HAL_PIXEL_FORMAT_CUSTOM_MAX -}; - -enum { - PFT_RGB, - PFT_YUV420, - PFT_YUV422, - PFT_YUV444, -}; - -struct mapping_data { - int fd; - size_t length; - uint32_t offset; - void *ptr; -}; - -#define ALL_BUFFERS_FLUSHED -66 - -#endif /* ANDROID_ZOOM_REPO_HARDWARE_SEC_LIBOVERLAY_V4L2_UTILS_H_*/ diff --git a/aries/libs3cjpeg/Android.mk b/aries/libs3cjpeg/Android.mk deleted file mode 100644 index 7a1acd6..0000000 --- a/aries/libs3cjpeg/Android.mk +++ /dev/null @@ -1,36 +0,0 @@ -ifeq ($(Y_U_NO_HAVE_CAMERA),true) -# Copyright (C) 2008 The Android Open Source Project -# -# 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_C_INCLUDES := $(LOCAL_PATH) -LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include - -LOCAL_SRC_FILES:= \ - JpegEncoder.cpp - -LOCAL_SHARED_LIBRARIES:= liblog -LOCAL_SHARED_LIBRARIES+= libdl - -LOCAL_MODULE:= libs3cjpeg.aries - -LOCAL_MODULE_TAGS := optional - -LOCAL_PRELINK_MODULE := false - -include $(BUILD_SHARED_LIBRARY) -endif diff --git a/aries/libs3cjpeg/Exif.h b/aries/libs3cjpeg/Exif.h deleted file mode 100644 index 96e11dd..0000000 --- a/aries/libs3cjpeg/Exif.h +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright Samsung Electronics Co.,LTD. - * Copyright (C) 2010 The Android Open Source Project - * - * 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_EXIF_H -#define ANDROID_HARDWARE_EXIF_H - -#include - -#define EXIF_LOG2(x) (log((double)(x)) / log(2.0)) -#define APEX_FNUM_TO_APERTURE(x) ((int)(EXIF_LOG2((double)(x)) * 2 + 0.5)) -#define APEX_EXPOSURE_TO_SHUTTER(x) ((x) >= 1 ? \ - (int)(-(EXIF_LOG2((double)(x)) + 0.5)) : \ - (int)(-(EXIF_LOG2((double)(x)) - 0.5))) -#define APEX_ISO_TO_FILMSENSITIVITY(x) ((int)(EXIF_LOG2((x) / 3.125) + 0.5)) - -#define NUM_SIZE 2 -#define IFD_SIZE 12 -#define OFFSET_SIZE 4 - -#define NUM_0TH_IFD_TIFF 10 -#define NUM_0TH_IFD_EXIF 22 -#define NUM_0TH_IFD_GPS 10 -#define NUM_1TH_IFD_TIFF 9 - -/* Type */ -#define EXIF_TYPE_BYTE 1 -#define EXIF_TYPE_ASCII 2 -#define EXIF_TYPE_SHORT 3 -#define EXIF_TYPE_LONG 4 -#define EXIF_TYPE_RATIONAL 5 -#define EXIF_TYPE_UNDEFINED 7 -#define EXIF_TYPE_SLONG 9 -#define EXIF_TYPE_SRATIONAL 10 - -#define EXIF_FILE_SIZE 28800 - -/* 0th IFD TIFF Tags */ -#define EXIF_TAG_IMAGE_WIDTH 0x0100 -#define EXIF_TAG_IMAGE_HEIGHT 0x0101 -#define EXIF_TAG_MAKE 0x010f -#define EXIF_TAG_MODEL 0x0110 -#define EXIF_TAG_ORIENTATION 0x0112 -#define EXIF_TAG_SOFTWARE 0x0131 -#define EXIF_TAG_DATE_TIME 0x0132 -#define EXIF_TAG_YCBCR_POSITIONING 0x0213 -#define EXIF_TAG_EXIF_IFD_POINTER 0x8769 -#define EXIF_TAG_GPS_IFD_POINTER 0x8825 - -/* 0th IFD Exif Private Tags */ -#define EXIF_TAG_EXPOSURE_TIME 0x829A -#define EXIF_TAG_FNUMBER 0x829D -#define EXIF_TAG_EXPOSURE_PROGRAM 0x8822 -#define EXIF_TAG_ISO_SPEED_RATING 0x8827 -#define EXIF_TAG_EXIF_VERSION 0x9000 -#define EXIF_TAG_DATE_TIME_ORG 0x9003 -#define EXIF_TAG_DATE_TIME_DIGITIZE 0x9004 -#define EXIF_TAG_SHUTTER_SPEED 0x9201 -#define EXIF_TAG_APERTURE 0x9202 -#define EXIF_TAG_BRIGHTNESS 0x9203 -#define EXIF_TAG_EXPOSURE_BIAS 0x9204 -#define EXIF_TAG_MAX_APERTURE 0x9205 -#define EXIF_TAG_METERING_MODE 0x9207 -#define EXIF_TAG_FLASH 0x9209 -#define EXIF_TAG_FOCAL_LENGTH 0x920A -#define EXIF_TAG_USER_COMMENT 0x9286 -#define EXIF_TAG_COLOR_SPACE 0xA001 -#define EXIF_TAG_PIXEL_X_DIMENSION 0xA002 -#define EXIF_TAG_PIXEL_Y_DIMENSION 0xA003 -#define EXIF_TAG_EXPOSURE_MODE 0xA402 -#define EXIF_TAG_WHITE_BALANCE 0xA403 -#define EXIF_TAG_SCENCE_CAPTURE_TYPE 0xA406 - -/* 0th IFD GPS Info Tags */ -#define EXIF_TAG_GPS_VERSION_ID 0x0000 -#define EXIF_TAG_GPS_LATITUDE_REF 0x0001 -#define EXIF_TAG_GPS_LATITUDE 0x0002 -#define EXIF_TAG_GPS_LONGITUDE_REF 0x0003 -#define EXIF_TAG_GPS_LONGITUDE 0x0004 -#define EXIF_TAG_GPS_ALTITUDE_REF 0x0005 -#define EXIF_TAG_GPS_ALTITUDE 0x0006 -#define EXIF_TAG_GPS_TIMESTAMP 0x0007 -#define EXIF_TAG_GPS_PROCESSING_METHOD 0x001B -#define EXIF_TAG_GPS_DATESTAMP 0x001D - -/* 1th IFD TIFF Tags */ -#define EXIF_TAG_COMPRESSION_SCHEME 0x0103 -#define EXIF_TAG_X_RESOLUTION 0x011A -#define EXIF_TAG_Y_RESOLUTION 0x011B -#define EXIF_TAG_RESOLUTION_UNIT 0x0128 -#define EXIF_TAG_JPEG_INTERCHANGE_FORMAT 0x0201 -#define EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LEN 0x0202 - - -typedef enum { - EXIF_ORIENTATION_UP = 1, - EXIF_ORIENTATION_90 = 6, - EXIF_ORIENTATION_180 = 3, - EXIF_ORIENTATION_270 = 8, -} ExifOrientationType; - -typedef enum { - EXIF_SCENE_STANDARD, - EXIF_SCENE_LANDSCAPE, - EXIF_SCENE_PORTRAIT, - EXIF_SCENE_NIGHT, -} CamExifSceneCaptureType; - -typedef enum { - EXIF_METERING_UNKNOWN, - EXIF_METERING_AVERAGE, - EXIF_METERING_CENTER, - EXIF_METERING_SPOT, - EXIF_METERING_MULTISPOT, - EXIF_METERING_PATTERN, - EXIF_METERING_PARTIAL, - EXIF_METERING_OTHER = 255, -} CamExifMeteringModeType; - -typedef enum { - EXIF_EXPOSURE_AUTO, - EXIF_EXPOSURE_MANUAL, - EXIF_EXPOSURE_AUTO_BRACKET, -} CamExifExposureModeType; - -typedef enum { - EXIF_WB_AUTO, - EXIF_WB_MANUAL, -} CamExifWhiteBalanceType; - -/* Values */ -#define EXIF_DEF_MAKER "SAMSUNG" -#define EXIF_DEF_MODEL "GT-I9020" -#define EXIF_DEF_SOFTWARE "CRESPOJH2" -#define EXIF_DEF_EXIF_VERSION "0220" -#define EXIF_DEF_USERCOMMENTS "User comments" - -#define EXIF_DEF_YCBCR_POSITIONING 1 /* centered */ -#define EXIF_DEF_FNUMBER_NUM 26 /* 2.6 */ -#define EXIF_DEF_FNUMBER_DEN 10 -#define EXIF_DEF_EXPOSURE_PROGRAM 3 /* aperture priority */ -#define EXIF_DEF_FOCAL_LEN_NUM 278 /* 2.78mm */ -#define EXIF_DEF_FOCAL_LEN_DEN 100 -#define EXIF_DEF_FLASH 0 /* O: off, 1: on*/ -#define EXIF_DEF_COLOR_SPACE 1 -#define EXIF_DEF_EXPOSURE_MODE EXIF_EXPOSURE_AUTO -#define EXIF_DEF_APEX_DEN 10 - -#define EXIF_DEF_COMPRESSION 6 -#define EXIF_DEF_RESOLUTION_NUM 72 -#define EXIF_DEF_RESOLUTION_DEN 1 -#define EXIF_DEF_RESOLUTION_UNIT 2 /* inches */ - -typedef struct { - uint32_t num; - uint32_t den; -} rational_t; - -typedef struct { - int32_t num; - int32_t den; -} srational_t; - -typedef struct { - bool enableGps; - bool enableThumb; - - unsigned char maker[32]; - unsigned char model[32]; - unsigned char software[32]; - unsigned char exif_version[4]; - unsigned char date_time[20]; - unsigned char user_comment[150]; - - uint32_t width; - uint32_t height; - uint32_t widthThumb; - uint32_t heightThumb; - - uint16_t orientation; - uint16_t ycbcr_positioning; - uint16_t exposure_program; - uint16_t iso_speed_rating; - uint16_t metering_mode; - uint16_t flash; - uint16_t color_space; - uint16_t exposure_mode; - uint16_t white_balance; - uint16_t scene_capture_type; - - rational_t exposure_time; - rational_t fnumber; - rational_t aperture; - rational_t max_aperture; - rational_t focal_length; - - srational_t shutter_speed; - srational_t brightness; - srational_t exposure_bias; - - unsigned char gps_latitude_ref[2]; - unsigned char gps_longitude_ref[2]; - - uint8_t gps_version_id[4]; - uint8_t gps_altitude_ref; - - rational_t gps_latitude[3]; - rational_t gps_longitude[3]; - rational_t gps_altitude; - rational_t gps_timestamp[3]; - unsigned char gps_datestamp[11]; - unsigned char gps_processing_method[100]; - - rational_t x_resolution; - rational_t y_resolution; - uint16_t resolution_unit; - uint16_t compression_scheme; -} exif_attribute_t; - - -#endif /* ANDROID_HARDWARE_EXIF_H */ diff --git a/aries/libs3cjpeg/JpegEncoder.cpp b/aries/libs3cjpeg/JpegEncoder.cpp deleted file mode 100644 index 1361bca..0000000 --- a/aries/libs3cjpeg/JpegEncoder.cpp +++ /dev/null @@ -1,796 +0,0 @@ -/* - * Copyright Samsung Electronics Co.,LTD. - * Copyright (C) 2010 The Android Open Source Project - * - * 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. - * - * JPEG DRIVER MODULE (JpegEncoder.cpp) - * Author : ge.lee -- initial version - * Date : 03 June 2010 - * Purpose : This file implements the JPEG encoder APIs as needed by Camera HAL - */ -#define LOG_TAG "JpegEncoder" -#define MAIN_DUMP 0 -#define THUMB_DUMP 0 - -#include -#include -#include - -#include "JpegEncoder.h" - -static const char ExifAsciiPrefix[] = { 0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0 }; - -namespace android { -JpegEncoder::JpegEncoder() : available(false) -{ - mArgs.mmapped_addr = (char *)MAP_FAILED; - mArgs.enc_param = NULL; - mArgs.thumb_enc_param = NULL; - - mDevFd = open(JPG_DRIVER_NAME, O_RDWR); - if (mDevFd < 0) { - LOGE("Failed to open the device"); - return; - } - - mArgs.mmapped_addr = (char *)mmap(0, - JPG_TOTAL_BUF_SIZE, - PROT_READ | PROT_WRITE, - MAP_SHARED, - mDevFd, - 0); - - if (mArgs.mmapped_addr == MAP_FAILED) { - LOGE("Failed to mmap"); - return; - } - - mArgs.enc_param = new jpg_enc_proc_param; - if (mArgs.enc_param == NULL) { - LOGE("Failed to allocate the memory for enc_param"); - return; - } - memset(mArgs.enc_param, 0, sizeof(jpg_enc_proc_param)); - - mArgs.thumb_enc_param = new jpg_enc_proc_param; - if (mArgs.thumb_enc_param == NULL) { - LOGE("Failed to allocate the memory for thumb_enc_param"); - delete mArgs.enc_param; - return; - } - memset(mArgs.thumb_enc_param, 0, sizeof(jpg_enc_proc_param)); - - mArgs.enc_param->sample_mode = JPG_420; - mArgs.enc_param->enc_type = JPG_MAIN; - mArgs.thumb_enc_param->sample_mode = JPG_420; - mArgs.thumb_enc_param->enc_type = JPG_THUMBNAIL; - - available = true; -} - -JpegEncoder::~JpegEncoder() -{ - if (mArgs.mmapped_addr != (char*)MAP_FAILED) - munmap(mArgs.mmapped_addr, JPG_TOTAL_BUF_SIZE); - - delete mArgs.enc_param; - - delete mArgs.thumb_enc_param; - - if (mDevFd > 0) - close(mDevFd); -} - -jpg_return_status JpegEncoder::setConfig(jpeg_conf type, int32_t value) -{ - if (!available) - return JPG_FAIL; - - jpg_return_status ret = JPG_SUCCESS; - - switch (type) { - case JPEG_SET_ENCODE_WIDTH: - if (value < 0 || value > MAX_JPG_WIDTH) - ret = JPG_FAIL; - else - mArgs.enc_param->width = value; - break; - - case JPEG_SET_ENCODE_HEIGHT: - if (value < 0 || value > MAX_JPG_HEIGHT) - ret = JPG_FAIL; - else - mArgs.enc_param->height = value; - break; - - case JPEG_SET_ENCODE_QUALITY: - if (value < JPG_QUALITY_LEVEL_1 || value > JPG_QUALITY_LEVEL_4) - ret = JPG_FAIL; - else - mArgs.enc_param->quality = (image_quality_type_t)value; - break; - - case JPEG_SET_ENCODE_IN_FORMAT: - if (value != JPG_MODESEL_YCBCR && value != JPG_MODESEL_RGB) { - ret = JPG_FAIL; - } else { - mArgs.enc_param->in_format = (in_mode_t)value; - mArgs.thumb_enc_param->in_format = (in_mode_t)value; - } - break; - - case JPEG_SET_SAMPING_MODE: - if (value != JPG_420 && value != JPG_422) { - ret = JPG_FAIL; - } else { - mArgs.enc_param->sample_mode = (sample_mode_t)value; - mArgs.thumb_enc_param->sample_mode = (sample_mode_t)value; - } - break; - - case JPEG_SET_THUMBNAIL_WIDTH: - if (value < 0 || value > MAX_JPG_THUMBNAIL_WIDTH) - ret = JPG_FAIL; - else - mArgs.thumb_enc_param->width = value; - break; - - case JPEG_SET_THUMBNAIL_HEIGHT: - if (value < 0 || value > MAX_JPG_THUMBNAIL_HEIGHT) - ret = JPG_FAIL; - else - mArgs.thumb_enc_param->height = value; - break; - - default: - LOGE("Invalid Config type"); - ret = ERR_UNKNOWN; - } - - if (ret == JPG_FAIL) - LOGE("Invalid value(%d) for %d type", value, type); - - return ret; -} - -void* JpegEncoder::getInBuf(uint64_t size) -{ - if (!available) - return NULL; - - if (size > JPG_FRAME_BUF_SIZE) { - LOGE("The buffer size requested is too large"); - return NULL; - } - mArgs.in_buf = (char *)ioctl(mDevFd, IOCTL_JPG_GET_FRMBUF, mArgs.mmapped_addr); - return (void *)(mArgs.in_buf); -} - -void* JpegEncoder::getOutBuf(uint64_t *size) -{ - if (!available) - return NULL; - - if (mArgs.enc_param->file_size <= 0) { - LOGE("The buffer requested doesn't have data"); - return NULL; - } - mArgs.out_buf = (char *)ioctl(mDevFd, IOCTL_JPG_GET_STRBUF, mArgs.mmapped_addr); - *size = mArgs.enc_param->file_size; - return (void *)(mArgs.out_buf); -} - -void* JpegEncoder::getThumbInBuf(uint64_t size) -{ - if (!available) - return NULL; - - if (size > JPG_FRAME_THUMB_BUF_SIZE) { - LOGE("The buffer size requested is too large"); - return NULL; - } - mArgs.in_thumb_buf = (char *)ioctl(mDevFd, IOCTL_JPG_GET_THUMB_FRMBUF, mArgs.mmapped_addr); - return (void *)(mArgs.in_thumb_buf); -} - -void* JpegEncoder::getThumbOutBuf(uint64_t *size) -{ - if (!available) - return NULL; - - if (mArgs.thumb_enc_param->file_size <= 0) { - LOGE("The buffer requested doesn't have data"); - return NULL; - } - mArgs.out_thumb_buf = (char *)ioctl(mDevFd, IOCTL_JPG_GET_THUMB_STRBUF, mArgs.mmapped_addr); - *size = mArgs.thumb_enc_param->file_size; - return (void *)(mArgs.out_thumb_buf); -} - -jpg_return_status JpegEncoder::encode(unsigned int *size, exif_attribute_t *exifInfo) -{ - if (!available) - return JPG_FAIL; - - LOGD("encode E"); - - jpg_return_status ret = JPG_FAIL; - unsigned char *exifOut = NULL; - jpg_enc_proc_param *param = mArgs.enc_param; - - ret = checkMcu(param->sample_mode, param->width, param->height, false); - if (ret != JPG_SUCCESS) - return ret; - - param->enc_type = JPG_MAIN; - ret = (jpg_return_status)ioctl(mDevFd, IOCTL_JPG_ENCODE, &mArgs); - if (ret != JPG_SUCCESS) { - LOGE("Failed to encode main image"); - return ret; - } - - mArgs.out_buf = (char *)ioctl(mDevFd, IOCTL_JPG_GET_STRBUF, mArgs.mmapped_addr); - - if (exifInfo) { - unsigned int thumbLen, exifLen; - - uint_t bufSize = 0; - if (exifInfo->enableThumb) { - ret = encodeThumbImg(&thumbLen); - if (ret != JPG_SUCCESS) { - LOGE("Failed to encode for thumbnail image"); - bufSize = EXIF_FILE_SIZE; - exifInfo->enableThumb = false; - } else { - bufSize = EXIF_FILE_SIZE + thumbLen; - } - } else { - bufSize = EXIF_FILE_SIZE; - } - - if (mArgs.enc_param->file_size + bufSize > JPG_TOTAL_BUF_SIZE) - return ret; - - exifOut = new unsigned char[bufSize]; - if (exifOut == NULL) { - LOGE("Failed to allocate for exifOut"); - return ret; - } - memset(exifOut, 0, bufSize); - - ret = makeExif (exifOut, exifInfo, &exifLen); - if (ret != JPG_SUCCESS) { - LOGE("Failed to make EXIF"); - delete[] exifOut; - return ret; - } - - memmove(&mArgs.out_buf[exifLen + 2], &mArgs.out_buf[2], param->file_size - 2); - memcpy(&mArgs.out_buf[2], exifOut, exifLen); - param->file_size += exifLen; - } - - delete[] exifOut; - - *size = param->file_size; - -#if MAIN_DUMP - FILE *fout = NULL; - char file_name[50] = "/data/main.jpg"; - fout = fopen(file_name, "wb"); - if (!fout) - perror(&file_name[0]); - size_t nwrite = fwrite(mArgs.out_buf, sizeof(char), param->file_size, fout); - fclose(fout); -#endif - - LOGD("encode X"); - - return ret; -} - -jpg_return_status JpegEncoder::encodeThumbImg(unsigned int *size, bool useMain) -{ - if (!available) - return JPG_FAIL; - - LOGD("encodeThumbImg E"); - - jpg_return_status ret = JPG_FAIL; - jpg_enc_proc_param *param = mArgs.thumb_enc_param; - - if (useMain) { - mArgs.in_thumb_buf = (char *)getThumbInBuf(param->width*param->height*2); - if (mArgs.in_thumb_buf == NULL) { - LOGE("Failed to get the buffer for thumbnail"); - return JPG_FAIL; - } - - ret = (jpg_return_status)scaleDownYuv422(mArgs.in_buf, - mArgs.enc_param->width, - mArgs.enc_param->height, - mArgs.in_thumb_buf, - param->width, - param->height); - if (ret != JPG_SUCCESS) - return JPG_FAIL; - } - - ret = checkMcu(param->sample_mode, param->width, param->height, true); - if (ret != JPG_SUCCESS) - return JPG_FAIL; - - mArgs.enc_param->enc_type = JPG_THUMBNAIL; - ret = (jpg_return_status)ioctl(mDevFd, IOCTL_JPG_ENCODE, &mArgs); - if (ret != JPG_SUCCESS) { - LOGE("Failed to encode for thumbnail"); - return JPG_FAIL; - } - - mArgs.out_thumb_buf = (char *)ioctl(mDevFd, IOCTL_JPG_GET_THUMB_STRBUF, mArgs.mmapped_addr); - -#if THUMB_DUMP - FILE *fout = NULL; - char file_name[50] = "/data/thumb.jpg"; - fout = fopen(file_name, "wb"); - if (!fout) - perror(&file_name[0]); - size_t nwrite = fwrite(mArgs.out_thumb_buf, sizeof(char), param->file_size, fout); - fclose(fout); -#endif - - LOGD("encodeThumbImg X"); - - return JPG_SUCCESS; -} - -jpg_return_status JpegEncoder::makeExif (unsigned char *exifOut, - exif_attribute_t *exifInfo, - unsigned int *size, - bool useMainbufForThumb) -{ - if (!available) - return JPG_FAIL; - - LOGD("makeExif E"); - - unsigned char *pCur, *pApp1Start, *pIfdStart, *pGpsIfdPtr, *pNextIfdOffset; - unsigned int tmp, LongerTagOffest = 0; - pApp1Start = pCur = exifOut; - - //2 Exif Identifier Code & TIFF Header - pCur += 4; // Skip 4 Byte for APP1 marker and length - unsigned char ExifIdentifierCode[6] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 }; - memcpy(pCur, ExifIdentifierCode, 6); - pCur += 6; - - /* Byte Order - little endian, Offset of IFD - 0x00000008.H */ - unsigned char TiffHeader[8] = { 0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00 }; - memcpy(pCur, TiffHeader, 8); - pIfdStart = pCur; - pCur += 8; - - //2 0th IFD TIFF Tags - if (exifInfo->enableGps) - tmp = NUM_0TH_IFD_TIFF; - else - tmp = NUM_0TH_IFD_TIFF - 1; - - memcpy(pCur, &tmp, NUM_SIZE); - pCur += NUM_SIZE; - - LongerTagOffest += 8 + NUM_SIZE + tmp*IFD_SIZE + OFFSET_SIZE; - - writeExifIfd(&pCur, EXIF_TAG_IMAGE_WIDTH, EXIF_TYPE_LONG, - 1, exifInfo->width); - writeExifIfd(&pCur, EXIF_TAG_IMAGE_HEIGHT, EXIF_TYPE_LONG, - 1, exifInfo->height); - writeExifIfd(&pCur, EXIF_TAG_MAKE, EXIF_TYPE_ASCII, - strlen((char *)exifInfo->maker) + 1, exifInfo->maker, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_MODEL, EXIF_TYPE_ASCII, - strlen((char *)exifInfo->model) + 1, exifInfo->model, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_ORIENTATION, EXIF_TYPE_SHORT, - 1, exifInfo->orientation); - writeExifIfd(&pCur, EXIF_TAG_SOFTWARE, EXIF_TYPE_ASCII, - strlen((char *)exifInfo->software) + 1, exifInfo->software, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_DATE_TIME, EXIF_TYPE_ASCII, - 20, exifInfo->date_time, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_YCBCR_POSITIONING, EXIF_TYPE_SHORT, - 1, exifInfo->ycbcr_positioning); - writeExifIfd(&pCur, EXIF_TAG_EXIF_IFD_POINTER, EXIF_TYPE_LONG, - 1, LongerTagOffest); - if (exifInfo->enableGps) { - pGpsIfdPtr = pCur; - pCur += IFD_SIZE; // Skip a ifd size for gps IFD pointer - } - - pNextIfdOffset = pCur; // Skip a offset size for next IFD offset - pCur += OFFSET_SIZE; - - //2 0th IFD Exif Private Tags - pCur = pIfdStart + LongerTagOffest; - - tmp = NUM_0TH_IFD_EXIF; - memcpy(pCur, &tmp , NUM_SIZE); - pCur += NUM_SIZE; - - LongerTagOffest += NUM_SIZE + NUM_0TH_IFD_EXIF*IFD_SIZE + OFFSET_SIZE; - - writeExifIfd(&pCur, EXIF_TAG_EXPOSURE_TIME, EXIF_TYPE_RATIONAL, - 1, &exifInfo->exposure_time, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_FNUMBER, EXIF_TYPE_RATIONAL, - 1, &exifInfo->fnumber, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_EXPOSURE_PROGRAM, EXIF_TYPE_SHORT, - 1, exifInfo->exposure_program); - writeExifIfd(&pCur, EXIF_TAG_ISO_SPEED_RATING, EXIF_TYPE_SHORT, - 1, exifInfo->iso_speed_rating); - writeExifIfd(&pCur, EXIF_TAG_EXIF_VERSION, EXIF_TYPE_UNDEFINED, - 4, exifInfo->exif_version); - writeExifIfd(&pCur, EXIF_TAG_DATE_TIME_ORG, EXIF_TYPE_ASCII, - 20, exifInfo->date_time, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_DATE_TIME_DIGITIZE, EXIF_TYPE_ASCII, - 20, exifInfo->date_time, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_SHUTTER_SPEED, EXIF_TYPE_SRATIONAL, - 1, (rational_t *)&exifInfo->shutter_speed, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_APERTURE, EXIF_TYPE_RATIONAL, - 1, &exifInfo->aperture, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_BRIGHTNESS, EXIF_TYPE_SRATIONAL, - 1, (rational_t *)&exifInfo->brightness, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_EXPOSURE_BIAS, EXIF_TYPE_SRATIONAL, - 1, (rational_t *)&exifInfo->exposure_bias, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_MAX_APERTURE, EXIF_TYPE_RATIONAL, - 1, &exifInfo->max_aperture, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_METERING_MODE, EXIF_TYPE_SHORT, - 1, exifInfo->metering_mode); - writeExifIfd(&pCur, EXIF_TAG_FLASH, EXIF_TYPE_SHORT, - 1, exifInfo->flash); - writeExifIfd(&pCur, EXIF_TAG_FOCAL_LENGTH, EXIF_TYPE_RATIONAL, - 1, &exifInfo->focal_length, &LongerTagOffest, pIfdStart); - char code[8] = { 0x00, 0x00, 0x00, 0x49, 0x49, 0x43, 0x53, 0x41 }; - int commentsLen = strlen((char *)exifInfo->user_comment) + 1; - memmove(exifInfo->user_comment + sizeof(code), exifInfo->user_comment, commentsLen); - memcpy(exifInfo->user_comment, code, sizeof(code)); - writeExifIfd(&pCur, EXIF_TAG_USER_COMMENT, EXIF_TYPE_UNDEFINED, - commentsLen + sizeof(code), exifInfo->user_comment, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_COLOR_SPACE, EXIF_TYPE_SHORT, - 1, exifInfo->color_space); - writeExifIfd(&pCur, EXIF_TAG_PIXEL_X_DIMENSION, EXIF_TYPE_LONG, - 1, exifInfo->width); - writeExifIfd(&pCur, EXIF_TAG_PIXEL_Y_DIMENSION, EXIF_TYPE_LONG, - 1, exifInfo->height); - writeExifIfd(&pCur, EXIF_TAG_EXPOSURE_MODE, EXIF_TYPE_LONG, - 1, exifInfo->exposure_mode); - writeExifIfd(&pCur, EXIF_TAG_WHITE_BALANCE, EXIF_TYPE_LONG, - 1, exifInfo->white_balance); - writeExifIfd(&pCur, EXIF_TAG_SCENCE_CAPTURE_TYPE, EXIF_TYPE_LONG, - 1, exifInfo->scene_capture_type); - tmp = 0; - memcpy(pCur, &tmp, OFFSET_SIZE); // next IFD offset - pCur += OFFSET_SIZE; - - //2 0th IFD GPS Info Tags - if (exifInfo->enableGps) { - writeExifIfd(&pGpsIfdPtr, EXIF_TAG_GPS_IFD_POINTER, EXIF_TYPE_LONG, - 1, LongerTagOffest); // GPS IFD pointer skipped on 0th IFD - - pCur = pIfdStart + LongerTagOffest; - - if (exifInfo->gps_processing_method[0] == 0) { - // don't create GPS_PROCESSING_METHOD tag if there isn't any - tmp = NUM_0TH_IFD_GPS - 1; - } else { - tmp = NUM_0TH_IFD_GPS; - } - memcpy(pCur, &tmp, NUM_SIZE); - pCur += NUM_SIZE; - - LongerTagOffest += NUM_SIZE + tmp*IFD_SIZE + OFFSET_SIZE; - - writeExifIfd(&pCur, EXIF_TAG_GPS_VERSION_ID, EXIF_TYPE_BYTE, - 4, exifInfo->gps_version_id); - writeExifIfd(&pCur, EXIF_TAG_GPS_LATITUDE_REF, EXIF_TYPE_ASCII, - 2, exifInfo->gps_latitude_ref); - writeExifIfd(&pCur, EXIF_TAG_GPS_LATITUDE, EXIF_TYPE_RATIONAL, - 3, exifInfo->gps_latitude, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_GPS_LONGITUDE_REF, EXIF_TYPE_ASCII, - 2, exifInfo->gps_longitude_ref); - writeExifIfd(&pCur, EXIF_TAG_GPS_LONGITUDE, EXIF_TYPE_RATIONAL, - 3, exifInfo->gps_longitude, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_GPS_ALTITUDE_REF, EXIF_TYPE_BYTE, - 1, exifInfo->gps_altitude_ref); - writeExifIfd(&pCur, EXIF_TAG_GPS_ALTITUDE, EXIF_TYPE_RATIONAL, - 1, &exifInfo->gps_altitude, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_GPS_TIMESTAMP, EXIF_TYPE_RATIONAL, - 3, exifInfo->gps_timestamp, &LongerTagOffest, pIfdStart); - tmp = strlen((char*)exifInfo->gps_processing_method); - if (tmp > 0) { - if (tmp > 100) { - tmp = 100; - } - unsigned char tmp_buf[100+sizeof(ExifAsciiPrefix)]; - memcpy(tmp_buf, ExifAsciiPrefix, sizeof(ExifAsciiPrefix)); - memcpy(&tmp_buf[sizeof(ExifAsciiPrefix)], exifInfo->gps_processing_method, tmp); - writeExifIfd(&pCur, EXIF_TAG_GPS_PROCESSING_METHOD, EXIF_TYPE_UNDEFINED, - tmp+sizeof(ExifAsciiPrefix), tmp_buf, &LongerTagOffest, pIfdStart); - } - writeExifIfd(&pCur, EXIF_TAG_GPS_DATESTAMP, EXIF_TYPE_ASCII, - 11, exifInfo->gps_datestamp, &LongerTagOffest, pIfdStart); - tmp = 0; - memcpy(pCur, &tmp, OFFSET_SIZE); // next IFD offset - pCur += OFFSET_SIZE; - } - - //2 1th IFD TIFF Tags - char *thumbBuf; - int thumbSize; - - if (useMainbufForThumb) { - thumbBuf = mArgs.out_buf; - thumbSize = mArgs.enc_param->file_size; - } else { - thumbBuf = mArgs.out_thumb_buf; - thumbSize = mArgs.thumb_enc_param->file_size; - } - - if (exifInfo->enableThumb && (thumbBuf != NULL) && (thumbSize > 0)) { - tmp = LongerTagOffest; - memcpy(pNextIfdOffset, &tmp, OFFSET_SIZE); // NEXT IFD offset skipped on 0th IFD - - pCur = pIfdStart + LongerTagOffest; - - tmp = NUM_1TH_IFD_TIFF; - memcpy(pCur, &tmp, NUM_SIZE); - pCur += NUM_SIZE; - - LongerTagOffest += NUM_SIZE + NUM_1TH_IFD_TIFF*IFD_SIZE + OFFSET_SIZE; - - writeExifIfd(&pCur, EXIF_TAG_IMAGE_WIDTH, EXIF_TYPE_LONG, - 1, exifInfo->widthThumb); - writeExifIfd(&pCur, EXIF_TAG_IMAGE_HEIGHT, EXIF_TYPE_LONG, - 1, exifInfo->heightThumb); - writeExifIfd(&pCur, EXIF_TAG_COMPRESSION_SCHEME, EXIF_TYPE_SHORT, - 1, exifInfo->compression_scheme); - writeExifIfd(&pCur, EXIF_TAG_ORIENTATION, EXIF_TYPE_SHORT, - 1, exifInfo->orientation); - writeExifIfd(&pCur, EXIF_TAG_X_RESOLUTION, EXIF_TYPE_RATIONAL, - 1, &exifInfo->x_resolution, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_Y_RESOLUTION, EXIF_TYPE_RATIONAL, - 1, &exifInfo->y_resolution, &LongerTagOffest, pIfdStart); - writeExifIfd(&pCur, EXIF_TAG_RESOLUTION_UNIT, EXIF_TYPE_SHORT, - 1, exifInfo->resolution_unit); - writeExifIfd(&pCur, EXIF_TAG_JPEG_INTERCHANGE_FORMAT, EXIF_TYPE_LONG, - 1, LongerTagOffest); - writeExifIfd(&pCur, EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LEN, EXIF_TYPE_LONG, - 1, thumbSize); - - tmp = 0; - memcpy(pCur, &tmp, OFFSET_SIZE); // next IFD offset - pCur += OFFSET_SIZE; - - memcpy(pIfdStart + LongerTagOffest, - thumbBuf, thumbSize); - LongerTagOffest += thumbSize; - } else { - tmp = 0; - memcpy(pNextIfdOffset, &tmp, OFFSET_SIZE); // NEXT IFD offset skipped on 0th IFD - } - - unsigned char App1Marker[2] = { 0xff, 0xe1 }; - memcpy(pApp1Start, App1Marker, 2); - pApp1Start += 2; - - *size = 10 + LongerTagOffest; - tmp = *size - 2; // APP1 Maker isn't counted - unsigned char size_mm[2] = {(tmp >> 8) & 0xFF, tmp & 0xFF}; - memcpy(pApp1Start, size_mm, 2); - - LOGD("makeExif X"); - - return JPG_SUCCESS; -} - -jpg_return_status JpegEncoder::checkMcu(sample_mode_t sampleMode, - uint32_t width, uint32_t height, bool isThumb) -{ - if (!available) - return JPG_FAIL; - - uint32_t expectedWidth = width; - uint32_t expectedHeight = height; - - switch (sampleMode){ - case JPG_422: - if (width % 16 != 0) - expectedWidth = width + 16 - (width % 16); - if (height % 8 != 0) - expectedHeight = height + 8 - (height % 8); - break; - - case JPG_420: - if (width % 16 != 0) - expectedWidth = width + 16 - (width % 16); - if (height % 16 != 0) - expectedHeight = height + 16 - (height % 16); - break; - - default: - LOGE("Invaild sample mode"); - return JPG_FAIL; - } - - if (expectedWidth == width && expectedHeight == height) - return JPG_SUCCESS; - - LOGW("The image is not matched for MCU"); - - uint32_t size = width*height * 2; - char *srcBuf, *dstBuf; - - if ((srcBuf = new char[size]) == NULL) { - LOGE("Failed to allocate for srcBuf"); - return JPG_FAIL; - } - - if (!isThumb) - dstBuf = mArgs.in_buf; - else - dstBuf = mArgs.in_thumb_buf; - - memcpy(srcBuf, dstBuf, size); - bool ret = pad(srcBuf, width, height, dstBuf, expectedWidth, expectedHeight); - - delete[] srcBuf; - - return JPG_SUCCESS; -} - -bool JpegEncoder::pad(char *srcBuf, uint32_t srcWidth, uint32_t srcHight, - char *dstBuf, uint32_t dstWidth, uint32_t dstHight) -{ - if (!available) - return false; - - if (srcBuf == NULL || dstBuf == NULL) { - LOGE("srcBuf or dstBuf is NULL"); - return false; - } - - int padW = dstWidth - srcWidth; - int padH = dstHight - srcHight; - - if ((int)(dstWidth - srcWidth) < 0 || - (int)(dstHight - srcHight) < 0) { - LOGE("dstSize is smaller than srcSize"); - return false; - } - memset(dstBuf, 0, dstWidth*dstHight * 2); - - for (uint32_t i = 0; i < srcHight; i++) - memcpy(dstBuf + i * dstWidth * 2, srcBuf + i * srcWidth * 2, srcWidth * 2); - - return true; -} - -bool JpegEncoder::scaleDownYuv422(char *srcBuf, uint32_t srcWidth, uint32_t srcHight, - char *dstBuf, uint32_t dstWidth, uint32_t dstHight) -{ - if (!available) - return false; - - int32_t step_x, step_y; - int32_t iXsrc, iXdst; - int32_t x, y, src_y_start_pos, dst_pos, src_pos; - - if (dstWidth % 2 != 0 || dstHight % 2 != 0){ - LOGE("scale_down_yuv422: invalid width, height for scaling"); - return false; - } - - step_x = srcWidth / dstWidth; - step_y = srcHight / dstHight; - - dst_pos = 0; - for (uint32_t y = 0; y < dstHight; y++) { - src_y_start_pos = (y * step_y * (srcWidth * 2)); - - for (uint32_t x = 0; x < dstWidth; x += 2) { - src_pos = src_y_start_pos + (x * (step_x * 2)); - - dstBuf[dst_pos++] = srcBuf[src_pos ]; - dstBuf[dst_pos++] = srcBuf[src_pos + 1]; - dstBuf[dst_pos++] = srcBuf[src_pos + 2]; - dstBuf[dst_pos++] = srcBuf[src_pos + 3]; - } - } - - return true; -} - -inline void JpegEncoder::writeExifIfd(unsigned char **pCur, - unsigned short tag, - unsigned short type, - unsigned int count, - uint32_t value) -{ - memcpy(*pCur, &tag, 2); - *pCur += 2; - memcpy(*pCur, &type, 2); - *pCur += 2; - memcpy(*pCur, &count, 4); - *pCur += 4; - memcpy(*pCur, &value, 4); - *pCur += 4; -} - -inline void JpegEncoder::writeExifIfd(unsigned char **pCur, - unsigned short tag, - unsigned short type, - unsigned int count, - unsigned char *pValue) -{ - char buf[4] = { 0,}; - - memcpy(buf, pValue, count); - memcpy(*pCur, &tag, 2); - *pCur += 2; - memcpy(*pCur, &type, 2); - *pCur += 2; - memcpy(*pCur, &count, 4); - *pCur += 4; - memcpy(*pCur, buf, 4); - *pCur += 4; -} - - -inline void JpegEncoder::writeExifIfd(unsigned char **pCur, - unsigned short tag, - unsigned short type, - unsigned int count, - unsigned char *pValue, - unsigned int *offset, - unsigned char *start) -{ - memcpy(*pCur, &tag, 2); - *pCur += 2; - memcpy(*pCur, &type, 2); - *pCur += 2; - memcpy(*pCur, &count, 4); - *pCur += 4; - memcpy(*pCur, offset, 4); - *pCur += 4; - memcpy(start + *offset, pValue, count); - *offset += count; -} - -inline void JpegEncoder::writeExifIfd(unsigned char **pCur, - unsigned short tag, - unsigned short type, - unsigned int count, - rational_t *pValue, - unsigned int *offset, - unsigned char *start) -{ - memcpy(*pCur, &tag, 2); - *pCur += 2; - memcpy(*pCur, &type, 2); - *pCur += 2; - memcpy(*pCur, &count, 4); - *pCur += 4; - memcpy(*pCur, offset, 4); - *pCur += 4; - memcpy(start + *offset, pValue, 8 * count); - *offset += 8 * count; -} - -}; diff --git a/aries/libs3cjpeg/JpegEncoder.h b/aries/libs3cjpeg/JpegEncoder.h deleted file mode 100644 index b95b1b1..0000000 --- a/aries/libs3cjpeg/JpegEncoder.h +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright Samsung Electronics Co.,LTD. - * Copyright (C) 2010 The Android Open Source Project - * - * 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. - * - * JPEG DRIVER MODULE (JpegEncoder.h) - * Author : ge.lee -- initial version - * Date : 03 June 2010 - * Purpose : This file implements the JPEG encoder APIs as needed by Camera HAL - */ -#ifndef __JPG_API_H__ -#define __JPG_API_H__ - -#include -#include - -#include "Exif.h" - -namespace android { -#define MAX_JPG_WIDTH 800 -#define MAX_JPG_HEIGHT 480 -#define MAX_JPG_RESOLUTION (MAX_JPG_WIDTH * MAX_JPG_HEIGHT) - -#define MAX_JPG_THUMBNAIL_WIDTH 320 -#define MAX_JPG_THUMBNAIL_HEIGHT 240 -#define MAX_JPG_THUMBNAIL_RESOLUTION (MAX_JPG_THUMBNAIL_WIDTH * \ - MAX_JPG_THUMBNAIL_HEIGHT) - -#define MAX_RGB_WIDTH 800 -#define MAX_RGB_HEIGHT 480 -#define MAX_RGB_RESOLUTION (MAX_RGB_WIDTH * MAX_RGB_HEIGHT) - -/*******************************************************************************/ -/* define JPG & image memory */ -/* memory area is 4k(PAGE_SIZE) aligned because of VirtualCopyEx() */ -#define JPG_STREAM_BUF_SIZE \ - (MAX_JPG_RESOLUTION / PAGE_SIZE + 1) * PAGE_SIZE -#define JPG_STREAM_THUMB_BUF_SIZE \ - (MAX_JPG_THUMBNAIL_RESOLUTION / PAGE_SIZE + 1) * PAGE_SIZE -#define JPG_FRAME_BUF_SIZE \ - ((MAX_JPG_RESOLUTION * 3) / PAGE_SIZE + 1) * PAGE_SIZE -#define JPG_FRAME_THUMB_BUF_SIZE \ - ((MAX_JPG_THUMBNAIL_RESOLUTION * 3) / PAGE_SIZE + 1) * PAGE_SIZE -#define JPG_RGB_BUF_SIZE \ - ((MAX_RGB_RESOLUTION * 4) / PAGE_SIZE + 1) * PAGE_SIZE - -#define JPG_TOTAL_BUF_SIZE (JPG_STREAM_BUF_SIZE + \ - JPG_STREAM_THUMB_BUF_SIZE + \ - JPG_FRAME_BUF_SIZE + \ - JPG_FRAME_THUMB_BUF_SIZE + \ - JPG_RGB_BUF_SIZE) - -#define JPG_MAIN_START 0x00 -#define JPG_THUMB_START JPG_STREAM_BUF_SIZE -#define IMG_MAIN_START (JPG_STREAM_BUF_SIZE + JPG_STREAM_THUMB_BUF_SIZE) -#define IMG_THUMB_START (IMG_MAIN_START + JPG_FRAME_BUF_SIZE) -/*******************************************************************************/ - -#define JPG_DRIVER_NAME "/dev/s3c-jpg" - -#define JPEG_IOCTL_MAGIC 'J' -#define IOCTL_JPG_DECODE _IO(JPEG_IOCTL_MAGIC, 1) -#define IOCTL_JPG_ENCODE _IO(JPEG_IOCTL_MAGIC, 2) -#define IOCTL_JPG_GET_STRBUF _IO(JPEG_IOCTL_MAGIC, 3) -#define IOCTL_JPG_GET_FRMBUF _IO(JPEG_IOCTL_MAGIC, 4) -#define IOCTL_JPG_GET_THUMB_STRBUF _IO(JPEG_IOCTL_MAGIC, 5) -#define IOCTL_JPG_GET_THUMB_FRMBUF _IO(JPEG_IOCTL_MAGIC, 6) -#define IOCTL_JPG_GET_PHY_FRMBUF _IO(JPEG_IOCTL_MAGIC, 7) -#define IOCTL_JPG_GET_PHY_THUMB_FRMBUF _IO(JPEG_IOCTL_MAGIC, 8) - -typedef enum { - JPEG_SET_ENCODE_WIDTH, - JPEG_SET_ENCODE_HEIGHT, - JPEG_SET_ENCODE_QUALITY, - JPEG_SET_ENCODE_IN_FORMAT, - JPEG_SET_SAMPING_MODE, - JPEG_SET_THUMBNAIL_WIDTH, - JPEG_SET_THUMBNAIL_HEIGHT -} jpeg_conf; - -typedef enum { - JPG_FAIL, - JPG_SUCCESS, - OK_HD_PARSING, - ERR_HD_PARSING, - OK_ENC_OR_DEC, - ERR_ENC_OR_DEC, - ERR_UNKNOWN -} jpg_return_status; - -typedef enum { - JPG_RGB16, - JPG_YCBYCR, - JPG_TYPE_UNKNOWN -} image_type_t; - -typedef enum { - JPG_444, - JPG_422, - JPG_420, - JPG_400, - RESERVED1, - RESERVED2, - JPG_411, - JPG_SAMPLE_UNKNOWN -} sample_mode_t; - -typedef enum { - YCBCR_422, - YCBCR_420, - YCBCR_SAMPLE_UNKNOWN -} out_mode_t; - -typedef enum { - JPG_MODESEL_YCBCR = 1, - JPG_MODESEL_RGB, - JPG_MODESEL_UNKNOWN -} in_mode_t; - -typedef enum { - JPG_MAIN, - JPG_THUMBNAIL -} encode_type_t; - -typedef enum { - JPG_QUALITY_LEVEL_1, /* high */ - JPG_QUALITY_LEVEL_2, - JPG_QUALITY_LEVEL_3, - JPG_QUALITY_LEVEL_4 /* low */ -} image_quality_type_t; - -typedef struct { - sample_mode_t sample_mode; - encode_type_t dec_type; - out_mode_t out_format; - uint32_t width; - uint32_t height; - uint32_t data_size; - uint32_t file_size; -} jpg_dec_proc_param; - -typedef struct { - sample_mode_t sample_mode; - encode_type_t enc_type; - in_mode_t in_format; - image_quality_type_t quality; - uint32_t width; - uint32_t height; - uint32_t data_size; - uint32_t file_size; - uint32_t set_framebuf; -} jpg_enc_proc_param; - -typedef struct { - char *in_buf; - char *phy_in_buf; - int in_buf_size; - char *out_buf; - char *phy_out_buf; - int out_buf_size; - char *in_thumb_buf; - char *phy_in_thumb_buf; - int in_thumb_buf_size; - char *out_thumb_buf; - char *phy_out_thumb_buf; - int out_thumb_buf_size; - char *mmapped_addr; - jpg_dec_proc_param *dec_param; - jpg_enc_proc_param *enc_param; - jpg_enc_proc_param *thumb_enc_param; -} jpg_args; - -class JpegEncoder { -public: - JpegEncoder(); - virtual ~JpegEncoder(); - - int openHardware(); - jpg_return_status setConfig(jpeg_conf type, int32_t value); - void *getInBuf(uint64_t size); - void *getOutBuf(uint64_t *size); - void *getThumbInBuf(uint64_t size); - void *getThumbOutBuf(uint64_t *size); - jpg_return_status encode(unsigned int *size, exif_attribute_t *exifInfo); - jpg_return_status encodeThumbImg(unsigned int *size, bool useMain = true); - jpg_return_status makeExif(unsigned char *exifOut, - exif_attribute_t *exifIn, - unsigned int *size, - bool useMainbufForThumb = false); - -private: - jpg_return_status checkMcu(sample_mode_t sampleMode, uint32_t width, uint32_t height, bool isThumb); - bool pad(char *srcBuf, uint32_t srcWidth, uint32_t srcHight, - char *dstBuf, uint32_t dstWidth, uint32_t dstHight); - bool scaleDownYuv422(char *srcBuf, uint32_t srcWidth, uint32_t srcHight, - char *dstBuf, uint32_t dstWidth, uint32_t dstHight); - - inline void writeExifIfd(unsigned char **pCur, - unsigned short tag, - unsigned short type, - unsigned int count, - uint32_t value); - inline void writeExifIfd(unsigned char **pCur, - unsigned short tag, - unsigned short type, - unsigned int count, - unsigned char *pValue); - inline void writeExifIfd(unsigned char **pCur, - unsigned short tag, - unsigned short type, - unsigned int count, - rational_t *pValue, - unsigned int *offset, - unsigned char *start); - inline void writeExifIfd(unsigned char **pCur, - unsigned short tag, - unsigned short type, - unsigned int count, - unsigned char *pValue, - unsigned int *offset, - unsigned char *start); - int mDevFd; - jpg_args mArgs; - - bool available; - -}; -}; -#endif /* __JPG_API_H__ */ diff --git a/aries/libsensors/Android.mk b/aries/libsensors/Android.mk deleted file mode 100644 index 228bfe7..0000000 --- a/aries/libsensors/Android.mk +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (C) 2008 The Android Open Source Project -# -# 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) - -ifneq ($(TARGET_SIMULATOR),true) - -# HAL module implemenation, not prelinked, and stored in -# hw/..so -include $(CLEAR_VARS) - -LOCAL_MODULE := sensors.aries - -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw - -LOCAL_MODULE_TAGS := optional - -LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" - -ifeq ($(TARGET_DEVICE),captivate) - LOCAL_CFLAGS += -DCAPTIVATE -endif - -LOCAL_SRC_FILES := \ - sensors.cpp \ - SensorBase.cpp \ - LightSensor.cpp \ - ProximitySensor.cpp \ - Smb380Sensor.cpp \ - CompassSensor.cpp \ - OrientationSensor.cpp \ - InputEventReader.cpp - -LOCAL_SHARED_LIBRARIES := liblog libcutils libdl -LOCAL_PRELINK_MODULE := false - -include $(BUILD_SHARED_LIBRARY) - -endif diff --git a/aries/libsensors/BoschYamaha.cpp b/aries/libsensors/BoschYamaha.cpp deleted file mode 100644 index ba88ff9..0000000 --- a/aries/libsensors/BoschYamaha.cpp +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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 "BoschYamaha.h" - -/*****************************************************************************/ - -int stub_is_sensor_enabled(uint32_t sensor_type) { - return 0; -} - -int stub_enable_disable_sensor(uint32_t sensor_type) { - return -ENODEV; -} - -int stub_set_delay(uint64_t delay) { - return -ENODEV; -} - -BoschYamaha::BoschYamaha() -: SensorBase(NULL, NULL), - //mEnabled(0), - mPendingMask(0), - mInputReaderMagnetic(4), - mInputReaderAccel(4) -{ - - counterAccel = 0; - - /* FIXME set input device name for magnetic sensor */ - data_name = "input0"; - data_compass_fd = openInput("geomagnetic"); - - - //Open Compass - if (data_compass_fd) { - strcpy(input_sysfs_path, "/sys/class/input/"); - strcat(input_sysfs_path, input_name); - strcat(input_sysfs_path, "/device/"); - input_sysfs_path_len = strlen(input_sysfs_path); - //enable(MagneticField, 1); - - } - - /* FIXME set input device name for accelereometer sensor */ - data_accel_name = "event6"; - data_fd = openInput("SMB380-Sensor"); - - //Open Compass - if (data_fd) { - strcpy(input_accel_sysfs_path, "/sys/class/input/"); - strcat(input_accel_sysfs_path, data_accel_name); - strcat(input_accel_sysfs_path, "/device/"); - input_accel_sysfs_path_len = strlen(input_accel_sysfs_path); - - enable(Accelerometer, 1); - - } - - - memset(mPendingEvents, 0, sizeof(mPendingEvents)); - - mPendingEvents[Accelerometer].version = sizeof(sensors_event_t); - mPendingEvents[Accelerometer].sensor = ID_A; - mPendingEvents[Accelerometer].type = SENSOR_TYPE_ACCELEROMETER; - mPendingEvents[Accelerometer].acceleration.status = SENSOR_STATUS_ACCURACY_HIGH; - - mPendingEvents[MagneticField].version = sizeof(sensors_event_t); - mPendingEvents[MagneticField].sensor = ID_M; - mPendingEvents[MagneticField].type = SENSOR_TYPE_MAGNETIC_FIELD; - mPendingEvents[MagneticField].magnetic.status = SENSOR_STATUS_ACCURACY_HIGH; - - mPendingEvents[Orientation].version = sizeof(sensors_event_t); - mPendingEvents[Orientation].sensor = ID_O; - mPendingEvents[Orientation].type = SENSOR_TYPE_ORIENTATION; - mPendingEvents[Orientation].orientation.status = SENSOR_STATUS_ACCURACY_HIGH; - - - - - for (int i=0 ; i= numSensors) - return -EINVAL; - - int newState = en ? 1 : 0; - int err = 0; - - /* - //FIXME enabling the right sensor over sysfs interface - if(what == MagneticField){ - what = Accelerometer; //Enable also Accel - //Compass - LOGD("BoschYamaha::~enable Compass(0, %d)", en); - int flags = en ? 1 : 0; - if (flags != compassEnabled) { - int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); - LOGD("BoschYamaha::~enable Compass(0, %d) open %s",en, input_sysfs_path); - fd = open(input_sysfs_path, O_RDWR); - if (fd >= 0) { - LOGD("CompassSensor::~enable(0, %d) opened %s",en, input_sysfs_path); - char buf[2]; - int err; - buf[1] = 0; - if (flags) { - buf[0] = '1'; - } else { - buf[0] = '0'; - } - err = write(fd, buf, sizeof(buf)); - close(fd); - //mEnabled = flags; - compassEnabled = flags; - return 0; - } - } - } - */ - - if(what == Accelerometer){ - //Accelerometer - LOGD("BoschYamaha::~enable Accel(0, %d)", en); - int flags = en ? 1 : 0; - if (flags != accelEnabled) { - int fd; - strcpy(&input_accel_sysfs_path[input_accel_sysfs_path_len], "enable"); - LOGD("BoschYamaha::~enable Accel(0, %d) open %s",en, input_accel_sysfs_path); - fd = open(input_accel_sysfs_path, O_RDWR); - if (fd >= 0) { - LOGD("CompassSensor::~enable(0, %d) opened %s",en, input_accel_sysfs_path); - char buf[2]; - int err; - buf[1] = 0; - if (flags) { - // counterAccel++; - buf[0] = '1'; - } else { - // counterAccel--; - buf[0] = '0'; - } - //if(counterAccel <= 1){ - err = write(fd, buf, sizeof(buf)); - //} - close(fd); - //mEnabled = flags; - accelEnabled = flags; - return 0; - } - } - } - - - return err; -} - -int BoschYamaha::setDelay(int32_t handle, int64_t ns) -{ - int what = -1; - switch (handle) { - case ID_A: what = Accelerometer; break; - case ID_M: what = MagneticField; break; - case ID_O: what = Orientation; break; - } - - if (uint32_t(what) >= numSensors) - return -EINVAL; - - if (ns < 0) - return -EINVAL; - - mDelays[what] = ns; - return update_delay(); -} - -int BoschYamaha::update_delay() -{ - return 0; -} - - -bool BoschYamaha::hasPendingEvents() { - - //LOGD("hasPendingEvents was called"); - if(accelEnabled || compassEnabled){ - //LOGD("hasPendingEvents will return true"); - return true; - } - else { - //LOGD("hasPendingEvents will return false"); - return false; - } -} - - - -int BoschYamaha::readEvents(sensors_event_t* data, int count) -{ - if (count < 1) - return -EINVAL; - - - int numEventReceived = 0; - - //LOGD("Sensor: Read events was called with count: %d", count); - - if(compassEnabled) - { - //LOGD("Sensor: Compass is enabled, going to take care of it, count: %d", count); - ssize_t n = mInputReaderMagnetic.fill(data_compass_fd); - if (n < 0) - return n; - - input_event const* event; - - while ( count && mInputReaderMagnetic.readEvent(&event)) { - int type = event->type; - //Everything is ABS! - if (type == EV_ABS) { - float value = event->value; - if (event->code == EVENT_TYPE_MAGV_X) { - mPendingEvents[MagneticField].magnetic.x = (value * CONVERT_M_X); - } else if (event->code == EVENT_TYPE_MAGV_Y) { - mPendingEvents[MagneticField].magnetic.y = (value * CONVERT_M_Y); - } else if (event->code == EVENT_TYPE_MAGV_Z) { - mPendingEvents[MagneticField].magnetic.z = (value * CONVERT_M_Z); - } - } - else if (type == EV_SYN) { - mPendingEvents[MagneticField].timestamp = timevalToNano(event->time); - if (compassEnabled) { - //LOGD("Sensor: Compass was enabled, made a read and received a Sync"); - compassDataReady = 1; - compassLastRead[0] = mPendingEvents[MagneticField].magnetic.x; - compassLastRead[1] = mPendingEvents[MagneticField].magnetic.y; - compassLastRead[2] = mPendingEvents[MagneticField].magnetic.z; - - *data++ = mPendingEvents[MagneticField]; - count--; - numEventReceived++; - } - } else { - LOGE("BoschYamaha: unknown event (type=%d, code=%d)", type, event->code); - - } - mInputReaderMagnetic.next(); - } - } - - //LOGD("Sensor: Compass read quited, count: %d", count); - - - if(accelEnabled) - { - //LOGD("Sensor: Accel is enabled, going to take care of it, count: %d", count); - - ssize_t n = mInputReaderAccel.fill(data_fd); - //LOGD("Sensor: Accel Input Reader was filled up: %d", count); - if (n < 0) - return n; - - input_event const* event; - - while (count && mInputReaderAccel.readEvent(&event)) { - int type = event->type; - if (type == EV_ABS) { - //LOGD("Sensor: Received one EV_ABS Event"); - float value = event->value; - if (event->code == EVENT_TYPE_ACCEL_X) { - mPendingEvents[Accelerometer].acceleration.x = value * CONVERT_A_X; - } else if (event->code == EVENT_TYPE_ACCEL_Y) { - mPendingEvents[Accelerometer].acceleration.y = value * CONVERT_A_Y; - } else if (event->code == EVENT_TYPE_ACCEL_Z) { - mPendingEvents[Accelerometer].acceleration.z = value * CONVERT_A_Z; - } - } else if (type == EV_SYN) { - mPendingEvents[Accelerometer].timestamp = timevalToNano(event->time); - if (accelEnabled) { - //LOGD("Sensor: Accel was enabled, made a read and received a Sync"); - accelDataReady = 1; - accelLastRead[0] = mPendingEvents[Accelerometer].acceleration.x; - accelLastRead[1] = mPendingEvents[Accelerometer].acceleration.y; - accelLastRead[2] = mPendingEvents[Accelerometer].acceleration.z; - *data++ = mPendingEvents[Accelerometer]; - count--; - numEventReceived++; - } - } - else { - LOGE("BoschYamaha: unknown event (type=%d, code=%d)", type, event->code); - - } - mInputReaderAccel.next(); - } - } - - //LOGD("Sensor: Accel read quited, count: %d, acceldata Ready: %d, compassData Ready = %d", count, accelDataReady, compassDataReady); - - if( (accelDataReady == 1) && (compassDataReady == 1)){ - //LOGD("BoschYamaha: Going to Process Orientation Data"); - accelDataReady = 0; - compassDataReady = 0; - processOrientation(); - *data++ = mPendingEvents[Orientation]; - numEventReceived++; - } - - - return numEventReceived; -} - - -int BoschYamaha::processOrientation(){ - - float matrix[9], euler[3]; - int rt, i; - - - rt = get_rotation_matrix(accelLastRead, compassLastRead, matrix); - - - if (rt < 0) { - for (i = 0; i < 3; i++) { - euler[i] = 0; - } - } - else { - get_euler(matrix, euler); - } - - //LOGD("BoschYamaha: azimuth is %d", (int)(euler[0])); - //LOGD("BoschYamaha: pitch is %d", (int)(euler[1])); - //LOGD("BoschYamaha: roll is %d", (int)(euler[2])); - - //Use CONVERT_O_A - mPendingEvents[Orientation].orientation.azimuth = (int)(euler[0]); - mPendingEvents[Orientation].orientation.pitch = (int)(euler[1]); - mPendingEvents[Orientation].orientation.roll = (int)(euler[2]); - //mPendingEvents[Orientation].orientation.status = uint8_t(value & SENSOR_STATE_MASK); - - return 1; - -} - - -float BoschYamaha::calc_intensity(float x, float y, float z) -{ - return sqrt(x*x + y*y + z*z); -} - - -int BoschYamaha::get_rotation_matrix(const float *gsdata, const float *msdata, float *matrix) -{ - float m_intensity, g_intensity, a_intensity, b_intensity; - float gdata[3], mdata[3], adata[3], bdata[3]; - int i; - - if (gsdata == NULL || msdata == NULL || matrix == NULL) { - return -1; - } - g_intensity = calc_intensity(gsdata[0], gsdata[1], gsdata[2]); - m_intensity = calc_intensity(msdata[0], msdata[1], msdata[2]); - if (g_intensity == 0 || m_intensity == 0) { - return -1; - } - for (i = 0; i < 3; i++) { - gdata[i] = -gsdata[i] / g_intensity; - mdata[i] = msdata[i] / m_intensity; - } - - adata[0] = (gdata[1] * mdata[2] - gdata[2] * mdata[1]); - adata[1] = (gdata[2] * mdata[0] - gdata[0] * mdata[2]); - adata[2] = (gdata[0] * mdata[1] - gdata[1] * mdata[0]); - a_intensity = calc_intensity(adata[0], adata[1], adata[2]); - if (a_intensity == 0) { - return -1; - } - for (i = 0; i < 3; i++) { - adata[i] /= a_intensity; - } - - bdata[0] = (adata[1] * gdata[2] - adata[2] * gdata[1]); - bdata[1] = (adata[2] * gdata[0] - adata[0] * gdata[2]); - bdata[2] = (adata[0] * gdata[1] - adata[1] * gdata[0]); - b_intensity = calc_intensity(bdata[0], bdata[1], bdata[2]); - if (b_intensity == 0) { - return -1; - } - for (i = 0; i < 3; i++) { - bdata[i] /= b_intensity; - } - - matrix[0] = adata[0]; - matrix[1] = adata[1]; - matrix[2] = adata[2]; - matrix[3] = bdata[0]; - matrix[4] = bdata[1]; - matrix[5] = bdata[2]; - matrix[6] = -gdata[0]; - matrix[7] = -gdata[1]; - matrix[8] = -gdata[2]; - - return 0; -} - -int BoschYamaha::get_euler(const float *matrix, float *euler) -{ - float m11, m12; - float m21, m22; - float m31, m32, m33; - float yaw = 0, roll = 0, pitch = 0; - - if (matrix == NULL || euler == NULL) { - return -1; - } - - m11 = matrix[0]; - m12 = matrix[1]; - m21 = matrix[3]; - m22 = matrix[4]; - m31 = matrix[6]; - m32 = matrix[7]; - m33 = matrix[8]; - - yaw = atan2(m12-m21, m11+m22); - pitch = -asin(m32); - roll = asin(m31); - - yaw *= 180.0 / M_PI; - pitch *= 180.0 / M_PI; - roll *= 180.0 / M_PI; - - if (m33 < 0) { - pitch = -180 - pitch; - if (pitch < -180) { - pitch += 360; - } - } - if (yaw < 0) { - yaw += 360.0f; - } - - euler[0] = (float)(int)yaw; /* yaw */ - - euler[1] = (float)(int)pitch; /* pitch */ - euler[2] = (float)(int)roll; /* roll */ - - return 0; -} - - - diff --git a/aries/libsensors/BoschYamaha.h b/aries/libsensors/BoschYamaha.h deleted file mode 100644 index 52af86b..0000000 --- a/aries/libsensors/BoschYamaha.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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_BOSCHYAMAHA_SENSOR_H -#define ANDROID_BOSCHYAMAHA_SENSOR_H - -#include -#include -#include -#include - - -#include "sensors.h" -#include "SensorBase.h" -#include "InputEventReader.h" - -/*****************************************************************************/ - -struct input_event; - -class BoschYamaha : public SensorBase { -public: - BoschYamaha(); - virtual ~BoschYamaha(); - - - - enum { - Accelerometer = 0, - MagneticField = 1, - Orientation = 2, - numSensors - }; - - virtual int setDelay(int32_t handle, int64_t ns); - virtual int enable(int32_t handle, int enabled); - virtual int readEvents(sensors_event_t* data, int count); - virtual bool hasPendingEvents(); - int processOrientation(); - float calc_intensity(float x, float y, float z); - int get_rotation_matrix(const float *gsdata, const float *msdata, float *matrix); - int get_euler(const float *matrix, float *euler); - -private: - const char* data_accel_name; - int data_compass_fd; - int update_delay(); - //uint32_t mEnabled; - int compassEnabled; - int accelEnabled; - float accelLastRead[3]; - float compassLastRead[3]; - int compassDataReady; - int accelDataReady; - int counterAccel; - uint32_t mPendingMask; - InputEventCircularReader mInputReaderMagnetic; - InputEventCircularReader mInputReaderAccel; - sensors_event_t mPendingEvents[numSensors]; - uint64_t mDelays[numSensors]; - char input_sysfs_path[PATH_MAX]; - int input_sysfs_path_len; - char input_accel_sysfs_path[PATH_MAX]; - int input_accel_sysfs_path_len; - -}; - -/*****************************************************************************/ - -#endif // ANDROID_BOSCHYAMAHA_SENSOR_H diff --git a/aries/libsensors/CompassSensor.cpp b/aries/libsensors/CompassSensor.cpp deleted file mode 100644 index c4b6822..0000000 --- a/aries/libsensors/CompassSensor.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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 "CompassSensor.h" - - -/*****************************************************************************/ -CompassSensor::CompassSensor() - : SensorBase(NULL, "magnetic_sensor"), - //mEnabled(0), - mInputReader(4), - mHasPendingEvent(false) -{ - LOGD("CompassSensor::CompassSensor()"); - mPendingEvent.version = sizeof(sensors_event_t); - mPendingEvent.sensor = ID_M; - mPendingEvent.type = SENSOR_TYPE_MAGNETIC_FIELD; - mPendingEvent.magnetic.status = SENSOR_STATUS_ACCURACY_HIGH; - - - memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); - - LOGD("CompassSensor::CompassSensor() open data_fd"); - - if (data_fd) { - strcpy(input_sysfs_path, "/sys/class/input/"); - strcat(input_sysfs_path, input_name); - strcat(input_sysfs_path, "/device/"); - input_sysfs_path_len = strlen(input_sysfs_path); - - //enable(0, 1); - } -} - -CompassSensor::~CompassSensor() { - - LOGD("CompassSensor::~CompassSensor()"); - if (mEnabled) { - enable(0, 0); - } -} - - - -int CompassSensor::enable(int32_t, int en) { - - - LOGD("CompassSensor::~enable(0, %d)", en); - int flags = en ? 1 : 0; - if (flags != mEnabled) { - int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); - LOGD("CompassSensor::~enable(0, %d) open %s",en, input_sysfs_path); - fd = open(input_sysfs_path, O_RDWR); - if (fd >= 0) { - LOGD("CompassSensor::~enable(0, %d) opened %s",en, input_sysfs_path); - char buf[2]; - int err; - buf[1] = 0; - if (flags) { - buf[0] = '1'; - } else { - buf[0] = '0'; - } - err = write(fd, buf, sizeof(buf)); - close(fd); - mEnabled = flags; - return 0; - } - return -1; - } - return 0; -} - - -bool CompassSensor::hasPendingEvents() const { - /* FIXME probably here should be returning mEnabled but instead - mHasPendingEvents. It does not work, so we cheat.*/ - //LOGD("CompassSensor::~hasPendingEvents %d", mHasPendingEvent ? 1 : 0 ); - return mHasPendingEvent; -} - - -int CompassSensor::setDelay(int32_t handle, int64_t ns) -{ - LOGD("CompassSensor::~setDelay(%d, %d)", handle, ns); - /* FIXME needs changes to the kernel driver. - We need to add a IOCTL that can set the samplingrate - the driver in ther kernel supports this allready only need - to add a IOCTL on both sides for that*/ - return 0; -} - - -int CompassSensor::readEvents(sensors_event_t* data, int count) -{ - //LOGD("CompassSensor::~readEvents() %d", count); - if (count < 1) - return -EINVAL; - - if (mHasPendingEvent) { - mHasPendingEvent = false; - mPendingEvent.timestamp = getTimestamp(); - *data = mPendingEvent; - return mEnabled ? 1 : 0; - } - - ssize_t n = mInputReader.fill(data_fd); - if (n < 0) - return n; - - int numEventReceived = 0; - input_event const* event; - - while (count && mInputReader.readEvent(&event)) { - int type = event->type; - if (type == EV_REL) { - float value = event->value; - if (event->code == EVENT_TYPE_MAGV_X) { - mPendingEvent.magnetic.x = value * CONVERT_M_X; - } else if (event->code == EVENT_TYPE_MAGV_Y) { - mPendingEvent.magnetic.y = value * CONVERT_M_Y; - } else if (event->code == EVENT_TYPE_MAGV_Z) { - mPendingEvent.magnetic.z = value * CONVERT_M_Z; - } - } else if (type == EV_SYN) { - mPendingEvent.timestamp = timevalToNano(event->time); - if (mEnabled) { - *data++ = mPendingEvent; - count--; - numEventReceived++; - } - } else { - LOGE("CompassSensor: unknown event (type=%d, code=%d)", - type, event->code); - } - mInputReader.next(); - } - - //LOGD("CompassSensor::~readEvents() numEventReceived = %d", numEventReceived); - return numEventReceived++; - -} diff --git a/aries/libsensors/CompassSensor.h b/aries/libsensors/CompassSensor.h deleted file mode 100644 index 0270431..0000000 --- a/aries/libsensors/CompassSensor.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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_COMPASS_SENSOR_H -#define ANDROID_COMPASS_SENSOR_H - -#include -#include -#include -#include - -#include "sensors.h" -#include "SensorBase.h" -#include "InputEventReader.h" - -/*****************************************************************************/ - - -struct input_event; - -class CompassSensor : public SensorBase { - int mEnabled; - InputEventCircularReader mInputReader; - sensors_event_t mPendingEvent; - bool mHasPendingEvent; - char input_sysfs_path[PATH_MAX]; - int input_sysfs_path_len; - - -public: - CompassSensor(); - virtual ~CompassSensor(); - virtual int readEvents(sensors_event_t* data, int count); - virtual bool hasPendingEvents() const; - virtual int setDelay(int32_t handle, int64_t ns); - virtual int enable(int32_t handle, int enabled); -}; - -/*****************************************************************************/ - -#endif // ANDROID_GYRO_SENSOR_H diff --git a/aries/libsensors/GyroSensor.cpp b/aries/libsensors/GyroSensor.cpp deleted file mode 100644 index 11df71e..0000000 --- a/aries/libsensors/GyroSensor.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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 "GyroSensor.h" - -#define FETCH_FULL_EVENT_BEFORE_RETURN 1 - -/*****************************************************************************/ - -GyroSensor::GyroSensor() - : SensorBase(NULL, "gyro"), - mEnabled(0), - mInputReader(4), - mHasPendingEvent(false) -{ - mPendingEvent.version = sizeof(sensors_event_t); - mPendingEvent.sensor = ID_GY; - mPendingEvent.type = SENSOR_TYPE_GYROSCOPE; - memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); - - if (data_fd) { - strcpy(input_sysfs_path, "/sys/class/input/"); - strcat(input_sysfs_path, input_name); - strcat(input_sysfs_path, "/device/"); - input_sysfs_path_len = strlen(input_sysfs_path); - enable(0, 1); - } -} - -GyroSensor::~GyroSensor() { - if (mEnabled) { - enable(0, 0); - } -} - -int GyroSensor::setInitialState() { - struct input_absinfo absinfo_x; - struct input_absinfo absinfo_y; - struct input_absinfo absinfo_z; - float value; - if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_GYRO_X), &absinfo_x) && - !ioctl(data_fd, EVIOCGABS(EVENT_TYPE_GYRO_X), &absinfo_y) && - !ioctl(data_fd, EVIOCGABS(EVENT_TYPE_GYRO_X), &absinfo_z)) { - value = absinfo_x.value; - mPendingEvent.data[0] = value * CONVERT_GYRO_X; - value = absinfo_x.value; - mPendingEvent.data[1] = value * CONVERT_GYRO_Y; - value = absinfo_x.value; - mPendingEvent.data[2] = value * CONVERT_GYRO_Z; - mHasPendingEvent = true; - } - return 0; -} - -int GyroSensor::enable(int32_t, int en) { - int flags = en ? 1 : 0; - if (flags != mEnabled) { - int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); - fd = open(input_sysfs_path, O_RDWR); - if (fd >= 0) { - char buf[2]; - int err; - buf[1] = 0; - if (flags) { - buf[0] = '1'; - } else { - buf[0] = '0'; - } - err = write(fd, buf, sizeof(buf)); - close(fd); - mEnabled = flags; - setInitialState(); - return 0; - } - return -1; - } - return 0; -} - -bool GyroSensor::hasPendingEvents() const { - return mHasPendingEvent; -} - -int GyroSensor::setDelay(int32_t handle, int64_t delay_ns) -{ - int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay"); - fd = open(input_sysfs_path, O_RDWR); - if (fd >= 0) { - char buf[80]; - sprintf(buf, "%lld", delay_ns); - write(fd, buf, strlen(buf)+1); - close(fd); - return 0; - } - return -1; -} - -int GyroSensor::readEvents(sensors_event_t* data, int count) -{ - if (count < 1) - return -EINVAL; - - if (mHasPendingEvent) { - mHasPendingEvent = false; - mPendingEvent.timestamp = getTimestamp(); - *data = mPendingEvent; - return mEnabled ? 1 : 0; - } - - ssize_t n = mInputReader.fill(data_fd); - if (n < 0) - return n; - - int numEventReceived = 0; - input_event const* event; - -#if FETCH_FULL_EVENT_BEFORE_RETURN -again: -#endif - while (count && mInputReader.readEvent(&event)) { - int type = event->type; - if (type == EV_REL) { - float value = event->value; - if (event->code == EVENT_TYPE_GYRO_X) { - mPendingEvent.data[0] = value * CONVERT_GYRO_X; - } else if (event->code == EVENT_TYPE_GYRO_Y) { - mPendingEvent.data[1] = value * CONVERT_GYRO_Y; - } else if (event->code == EVENT_TYPE_GYRO_Z) { - mPendingEvent.data[2] = value * CONVERT_GYRO_Z; - } - } else if (type == EV_SYN) { - mPendingEvent.timestamp = timevalToNano(event->time); - if (mEnabled) { - *data++ = mPendingEvent; - count--; - numEventReceived++; - } - } else { - LOGE("GyroSensor: unknown event (type=%d, code=%d)", - type, event->code); - } - mInputReader.next(); - } - -#if FETCH_FULL_EVENT_BEFORE_RETURN - /* if we didn't read a complete event, see if we can fill and - try again instead of returning with nothing and redoing poll. */ - if (numEventReceived == 0 && mEnabled == 1) { - n = mInputReader.fill(data_fd); - if (n) - goto again; - } -#endif - - return numEventReceived; -} - diff --git a/aries/libsensors/GyroSensor.h b/aries/libsensors/GyroSensor.h deleted file mode 100644 index 1b206bd..0000000 --- a/aries/libsensors/GyroSensor.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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_GYRO_SENSOR_H -#define ANDROID_GYRO_SENSOR_H - -#include -#include -#include -#include - -#include "sensors.h" -#include "SensorBase.h" -#include "InputEventReader.h" - -/*****************************************************************************/ - -struct input_event; - -class GyroSensor : public SensorBase { - int mEnabled; - InputEventCircularReader mInputReader; - sensors_event_t mPendingEvent; - bool mHasPendingEvent; - char input_sysfs_path[PATH_MAX]; - int input_sysfs_path_len; - - int setInitialState(); - -public: - GyroSensor(); - virtual ~GyroSensor(); - virtual int readEvents(sensors_event_t* data, int count); - virtual bool hasPendingEvents() const; - virtual int setDelay(int32_t handle, int64_t ns); - virtual int enable(int32_t handle, int enabled); -}; - -/*****************************************************************************/ - -#endif // ANDROID_GYRO_SENSOR_H diff --git a/aries/libsensors/InputEventReader.cpp b/aries/libsensors/InputEventReader.cpp deleted file mode 100644 index c6bac93..0000000 --- a/aries/libsensors/InputEventReader.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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 "InputEventReader.h" - -/*****************************************************************************/ - -struct input_event; - -InputEventCircularReader::InputEventCircularReader(size_t numEvents) - : mBuffer(new input_event[numEvents * 2]), - mBufferEnd(mBuffer + numEvents), - mHead(mBuffer), - mCurr(mBuffer), - mFreeSpace(numEvents) -{ -} - -InputEventCircularReader::~InputEventCircularReader() -{ - delete [] mBuffer; -} - -ssize_t InputEventCircularReader::fill(int fd) -{ - size_t numEventsRead = 0; - if (mFreeSpace) { - const ssize_t nread = read(fd, mHead, mFreeSpace * sizeof(input_event)); - if (nread<0 || nread % sizeof(input_event)) { - // we got a partial event!! - return nread<0 ? -errno : -EINVAL; - } - - numEventsRead = nread / sizeof(input_event); - if (numEventsRead) { - mHead += numEventsRead; - mFreeSpace -= numEventsRead; - if (mHead > mBufferEnd) { - size_t s = mHead - mBufferEnd; - memcpy(mBuffer, mBufferEnd, s * sizeof(input_event)); - mHead = mBuffer + s; - } - } - } - - return numEventsRead; -} - -ssize_t InputEventCircularReader::readEvent(input_event const** events) -{ - *events = mCurr; - ssize_t available = (mBufferEnd - mBuffer) - mFreeSpace; - return available ? 1 : 0; -} - -void InputEventCircularReader::next() -{ - mCurr++; - mFreeSpace++; - if (mCurr >= mBufferEnd) { - mCurr = mBuffer; - } -} diff --git a/aries/libsensors/InputEventReader.h b/aries/libsensors/InputEventReader.h deleted file mode 100644 index fbf5121..0000000 --- a/aries/libsensors/InputEventReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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_INPUT_EVENT_READER_H -#define ANDROID_INPUT_EVENT_READER_H - -#include -#include -#include -#include - -/*****************************************************************************/ - -struct input_event; - -class InputEventCircularReader -{ - struct input_event* const mBuffer; - struct input_event* const mBufferEnd; - struct input_event* mHead; - struct input_event* mCurr; - ssize_t mFreeSpace; - -public: - InputEventCircularReader(size_t numEvents); - ~InputEventCircularReader(); - ssize_t fill(int fd); - ssize_t readEvent(input_event const** events); - void next(); -}; - -/*****************************************************************************/ - -#endif // ANDROID_INPUT_EVENT_READER_H diff --git a/aries/libsensors/LightSensor.cpp b/aries/libsensors/LightSensor.cpp deleted file mode 100644 index ea3e250..0000000 --- a/aries/libsensors/LightSensor.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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 "LightSensor.h" - -/*****************************************************************************/ - -/* The Crespo ADC sends 4 somewhat bogus events after enabling the sensor. - This becomes a problem if the phone is turned off in bright light - and turned back on in the dark. - To avoid this we ignore the first 4 events received after enabling the sensor. - */ -#define FIRST_GOOD_EVENT 5 - -LightSensor::LightSensor() - : SensorBase(NULL, "light_sensor"), - mEnabled(0), - mEventsSinceEnable(0), - mInputReader(4), - mHasPendingEvent(false) -{ - mPendingEvent.version = sizeof(sensors_event_t); - mPendingEvent.sensor = ID_L; - mPendingEvent.type = SENSOR_TYPE_LIGHT; - memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); - - if (data_fd) { - strcpy(input_sysfs_path, "/sys/class/input/"); - strcat(input_sysfs_path, input_name); - strcat(input_sysfs_path, "/device/"); - input_sysfs_path_len = strlen(input_sysfs_path); - enable(0, 1); - } -} - -LightSensor::~LightSensor() { - if (mEnabled) { - enable(0, 0); - } -} - -int LightSensor::setDelay(int32_t handle, int64_t ns) -{ - int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay"); - fd = open(input_sysfs_path, O_RDWR); - if (fd >= 0) { - char buf[80]; - sprintf(buf, "%lld", ns); - write(fd, buf, strlen(buf)+1); - close(fd); - return 0; - } - return -1; -} - -int LightSensor::enable(int32_t handle, int en) -{ - int flags = en ? 1 : 0; - mEventsSinceEnable = 0; - mPreviousLight = -1; - if (flags != mEnabled) { - int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); - fd = open(input_sysfs_path, O_RDWR); - if (fd >= 0) { - char buf[2]; - int err; - buf[1] = 0; - if (flags) { - buf[0] = '1'; - } else { - buf[0] = '0'; - } - err = write(fd, buf, sizeof(buf)); - close(fd); - mEnabled = flags; - return 0; - } - return -1; - } - return 0; -} - -bool LightSensor::hasPendingEvents() const { - return mHasPendingEvent; -} - -int LightSensor::readEvents(sensors_event_t* data, int count) -{ - if (count < 1) - return -EINVAL; - - if (mHasPendingEvent) { - mHasPendingEvent = false; - mPendingEvent.timestamp = getTimestamp(); - *data = mPendingEvent; - return mEnabled ? 1 : 0; - } - - ssize_t n = mInputReader.fill(data_fd); - if (n < 0) - return n; - - int numEventReceived = 0; - input_event const* event; - - while (count && mInputReader.readEvent(&event)) { - int type = event->type; - if (type == EV_ABS) { - if (event->code == EVENT_TYPE_LIGHT) { - mPendingEvent.light = indexToValue(event->value); - if (mEventsSinceEnable < FIRST_GOOD_EVENT) - mEventsSinceEnable++; - } - } else if (type == EV_SYN) { - mPendingEvent.timestamp = timevalToNano(event->time); - if (mEnabled && (mPendingEvent.light != mPreviousLight) && - mEventsSinceEnable >= FIRST_GOOD_EVENT) { - *data++ = mPendingEvent; - count--; - numEventReceived++; - mPreviousLight = mPendingEvent.light; - } - } else { - LOGE("LightSensor: unknown event (type=%d, code=%d)", - type, event->code); - } - mInputReader.next(); - } - - return numEventReceived; -} - -float LightSensor::indexToValue(size_t index) const -{ - /* Driver gives a rolling average adc value. We convert it lux levels. */ - static const struct adcToLux { - size_t adc_value; - float lux_value; - } adcToLux[] = { - { 150, 10.0 }, /* from 0 - 150 adc, we map to 10.0 lux */ - { 800, 160.0 }, /* from 151 - 800 adc, we map to 160.0 lux */ - { 900, 225.0 }, /* from 801 - 900 adc, we map to 225.0 lux */ - { 1000, 320.0 }, /* from 901 - 1000 adc, we map to 320.0 lux */ - { 1200, 640.0 }, /* from 1001 - 1200 adc, we map to 640.0 lux */ - { 1400, 1280.0 }, /* from 1201 - 1400 adc, we map to 1280.0 lux */ - { 1600, 2600.0 }, /* from 1401 - 1600 adc, we map to 2600.0 lux */ - { 4095, 10240.0 }, /* from 1601 - 4095 adc, we map to 10240.0 lux */ - }; - size_t i; - for (i = 0; i < ARRAY_SIZE(adcToLux); i++) { - if (index < adcToLux[i].adc_value) { - return adcToLux[i].lux_value; - } - } - return adcToLux[ARRAY_SIZE(adcToLux)-1].lux_value; -} diff --git a/aries/libsensors/LightSensor.h b/aries/libsensors/LightSensor.h deleted file mode 100644 index cc1a00d..0000000 --- a/aries/libsensors/LightSensor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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_LIGHT_SENSOR_H -#define ANDROID_LIGHT_SENSOR_H - -#include -#include -#include -#include - -#include "sensors.h" -#include "SensorBase.h" -#include "InputEventReader.h" - -/*****************************************************************************/ - -struct input_event; - -class LightSensor : public SensorBase { - int mEnabled; - int mEventsSinceEnable; - InputEventCircularReader mInputReader; - sensors_event_t mPendingEvent; - bool mHasPendingEvent; - char input_sysfs_path[PATH_MAX]; - int input_sysfs_path_len; - - int setInitialState(); - float mPreviousLight; - float indexToValue(size_t index) const; - -public: - LightSensor(); - virtual ~LightSensor(); - virtual int readEvents(sensors_event_t* data, int count); - virtual bool hasPendingEvents() const; - virtual int setDelay(int32_t handle, int64_t ns); - virtual int enable(int32_t handle, int enabled); -}; - -/*****************************************************************************/ - -#endif // ANDROID_LIGHT_SENSOR_H diff --git a/aries/libsensors/OrientationSensor.cpp b/aries/libsensors/OrientationSensor.cpp deleted file mode 100644 index 3fb5d29..0000000 --- a/aries/libsensors/OrientationSensor.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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 "OrientationSensor.h" - - -/*****************************************************************************/ -OrientationSensor::OrientationSensor() - : SensorBase(NULL, "orientation_sensor"), - mEnabled(0), - mInputReader(4), - mHasPendingEvent(false) -{ - LOGD("OrientationSensor::OrientationSensor()"); - mPendingEvent.version = sizeof(sensors_event_t); - mPendingEvent.sensor = ID_O; - mPendingEvent.type = SENSOR_TYPE_ORIENTATION; - memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); - - LOGD("OrientationSensor::OrientationSensor() open data_fd"); - - if (data_fd) { - strcpy(input_sysfs_path, "/sys/class/input/"); - strcat(input_sysfs_path, input_name); - strcat(input_sysfs_path, "/device/"); - input_sysfs_path_len = strlen(input_sysfs_path); - - // enable(0, 1); - } -} - -OrientationSensor::~OrientationSensor() { - - LOGD("OrientationSensor::~OrientationSensor()"); - if (mEnabled) { - enable(0, 0); - } -} - - -int OrientationSensor::enable(int32_t, int en) { - - - LOGD("OrientationSensor::~enable(0, %d)", en); - int flags = en ? 1 : 0; - if (flags != mEnabled) { - int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); - LOGD("OrientationSensor::~enable(0, %d) open %s",en, input_sysfs_path); - fd = open(input_sysfs_path, O_RDWR); - if (fd >= 0) { - LOGD("OrientationSensor::~enable(0, %d) opened %s",en, input_sysfs_path); - char buf[2]; - int err; - buf[1] = 0; - if (flags) { - buf[0] = '1'; - } else { - buf[0] = '0'; - } - err = write(fd, buf, sizeof(buf)); - close(fd); - mEnabled = flags; - //setInitialState(); - return 0; - } - return -1; - } - return 0; -} - - -bool OrientationSensor::hasPendingEvents() const { - /* FIXME probably here should be returning mEnabled but instead - mHasPendingEvents. It does not work, so we cheat.*/ - //LOGD("OrientationSensor::~hasPendingEvents %d", mHasPendingEvent ? 1 : 0 ); - return mHasPendingEvent; -} - - -int OrientationSensor::setDelay(int32_t handle, int64_t ns) -{ - LOGD("OrientationSensor::~setDelay(%d, %d)", handle, ns); - /* FIXME needs changes to the kernel driver. - We need to add a IOCTL that can set the samplingrate - the driver in ther kernel supports this allready only need - to add a IOCTL on both sides for that*/ - return 0; -} - - -int OrientationSensor::readEvents(sensors_event_t* data, int count) -{ - //LOGD("OrientationSensor::~readEvents() %d", count); - if (count < 1) - return -EINVAL; - - if (mHasPendingEvent) { - mHasPendingEvent = false; - mPendingEvent.timestamp = getTimestamp(); - *data = mPendingEvent; - return mEnabled ? 1 : 0; - } - - ssize_t n = mInputReader.fill(data_fd); - if (n < 0) - return n; - - int numEventReceived = 0; - input_event const* event; - - while (count && mInputReader.readEvent(&event)) { - int type = event->type; - if (type == EV_REL) { - float value = event->value; - if (event->code == EVENT_TYPE_YAW) { - mPendingEvent.orientation.azimuth = value * CONVERT_O_A; - } else if (event->code == EVENT_TYPE_PITCH) { - mPendingEvent.orientation.pitch = value * CONVERT_O_P; - } else if (event->code == EVENT_TYPE_ROLL) { - mPendingEvent.orientation.roll = value * CONVERT_O_R; - } - } else if (type == EV_SYN) { - mPendingEvent.timestamp = timevalToNano(event->time); - if (mEnabled) { - *data++ = mPendingEvent; - count--; - numEventReceived++; - } - } else { - LOGE("OrientationSensor: unknown event (type=%d, code=%d)", - type, event->code); - } - mInputReader.next(); - } - - //LOGD("OrientationSensor::~readEvents() numEventReceived = %d", numEventReceived); - return numEventReceived++; - -} diff --git a/aries/libsensors/OrientationSensor.h b/aries/libsensors/OrientationSensor.h deleted file mode 100644 index cbb7064..0000000 --- a/aries/libsensors/OrientationSensor.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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_ORIEN_SENSOR_H -#define ANDROID_ORIEN_SENSOR_H - -#include -#include -#include -#include - -#include "sensors.h" -#include "SensorBase.h" -#include "InputEventReader.h" - -/*****************************************************************************/ - - -struct input_event; - -class OrientationSensor : public SensorBase { - int mEnabled; - InputEventCircularReader mInputReader; - sensors_event_t mPendingEvent; - bool mHasPendingEvent; - char input_sysfs_path[PATH_MAX]; - int input_sysfs_path_len; - - -public: - OrientationSensor(); - virtual ~OrientationSensor(); - virtual int readEvents(sensors_event_t* data, int count); - virtual bool hasPendingEvents() const; - virtual int setDelay(int32_t handle, int64_t ns); - virtual int enable(int32_t handle, int enabled); -}; - -/*****************************************************************************/ - -#endif // ANDROID_GYRO_SENSOR_H diff --git a/aries/libsensors/ProximitySensor.cpp b/aries/libsensors/ProximitySensor.cpp deleted file mode 100644 index f7151ee..0000000 --- a/aries/libsensors/ProximitySensor.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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 "ProximitySensor.h" - -/*****************************************************************************/ - -ProximitySensor::ProximitySensor() - : SensorBase(NULL, "proximity_sensor"), - mEnabled(0), - mInputReader(4), - mHasPendingEvent(false) -{ - mPendingEvent.version = sizeof(sensors_event_t); - mPendingEvent.sensor = ID_P; - mPendingEvent.type = SENSOR_TYPE_PROXIMITY; - memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); - - if (data_fd) { - strcpy(input_sysfs_path, "/sys/class/input/"); - strcat(input_sysfs_path, input_name); - strcat(input_sysfs_path, "/device/"); - input_sysfs_path_len = strlen(input_sysfs_path); - enable(0, 1); - } -} - -ProximitySensor::~ProximitySensor() { - if (mEnabled) { - enable(0, 0); - } -} - -int ProximitySensor::setInitialState() { - struct input_absinfo absinfo; - if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_PROXIMITY), &absinfo)) { - // make sure to report an event immediately - mHasPendingEvent = true; - mPendingEvent.distance = indexToValue(absinfo.value); - } - return 0; -} - -int ProximitySensor::enable(int32_t, int en) { - int flags = en ? 1 : 0; - if (flags != mEnabled) { - int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); - fd = open(input_sysfs_path, O_RDWR); - if (fd >= 0) { - char buf[2]; - buf[1] = 0; - if (flags) { - buf[0] = '1'; - } else { - buf[0] = '0'; - } - write(fd, buf, sizeof(buf)); - close(fd); - mEnabled = flags; - setInitialState(); - return 0; - } - return -1; - } - return 0; -} - -bool ProximitySensor::hasPendingEvents() const { - return mHasPendingEvent; -} - -int ProximitySensor::readEvents(sensors_event_t* data, int count) -{ - if (count < 1) - return -EINVAL; - - if (mHasPendingEvent) { - mHasPendingEvent = false; - mPendingEvent.timestamp = getTimestamp(); - *data = mPendingEvent; - return mEnabled ? 1 : 0; - } - - ssize_t n = mInputReader.fill(data_fd); - if (n < 0) - return n; - - int numEventReceived = 0; - input_event const* event; - - while (count && mInputReader.readEvent(&event)) { - int type = event->type; - if (type == EV_ABS) { - if (event->code == EVENT_TYPE_PROXIMITY) { - if (event->value != -1) { - // FIXME: not sure why we're getting -1 sometimes - mPendingEvent.distance = indexToValue(event->value); - } - } - } else if (type == EV_SYN) { - mPendingEvent.timestamp = timevalToNano(event->time); - if (mEnabled) { - *data++ = mPendingEvent; - count--; - numEventReceived++; - } - } else { - LOGE("ProximitySensor: unknown event (type=%d, code=%d)", - type, event->code); - } - mInputReader.next(); - } - - return numEventReceived; -} - -float ProximitySensor::indexToValue(size_t index) const -{ - return index * PROXIMITY_THRESHOLD_GP2A; -} diff --git a/aries/libsensors/ProximitySensor.h b/aries/libsensors/ProximitySensor.h deleted file mode 100644 index e9f782f..0000000 --- a/aries/libsensors/ProximitySensor.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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_PROXIMITY_SENSOR_H -#define ANDROID_PROXIMITY_SENSOR_H - -#include -#include -#include -#include - -#include "sensors.h" -#include "SensorBase.h" -#include "InputEventReader.h" - -/*****************************************************************************/ - -struct input_event; - -class ProximitySensor : public SensorBase { - int mEnabled; - InputEventCircularReader mInputReader; - sensors_event_t mPendingEvent; - bool mHasPendingEvent; - char input_sysfs_path[PATH_MAX]; - int input_sysfs_path_len; - - int setInitialState(); - float indexToValue(size_t index) const; - -public: - ProximitySensor(); - virtual ~ProximitySensor(); - virtual int readEvents(sensors_event_t* data, int count); - virtual bool hasPendingEvents() const; - virtual int enable(int32_t handle, int enabled); -}; - -/*****************************************************************************/ - -#endif // ANDROID_PROXIMITY_SENSOR_H diff --git a/aries/libsensors/SensorBase.cpp b/aries/libsensors/SensorBase.cpp deleted file mode 100644 index 2fe5c2d..0000000 --- a/aries/libsensors/SensorBase.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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 "SensorBase.h" - -/*****************************************************************************/ - -SensorBase::SensorBase( - const char* dev_name, - const char* data_name) - : dev_name(dev_name), data_name(data_name), - dev_fd(-1), data_fd(-1) -{ - if (data_name) { - data_fd = openInput(data_name); - } -} - -SensorBase::~SensorBase() { - if (data_fd >= 0) { - close(data_fd); - } - if (dev_fd >= 0) { - close(dev_fd); - } -} - -int SensorBase::open_device() { - if (dev_fd<0 && dev_name) { - dev_fd = open(dev_name, O_RDONLY); - LOGE_IF(dev_fd<0, "Couldn't open %s (%s)", dev_name, strerror(errno)); - } - return 0; -} - -int SensorBase::close_device() { - if (dev_fd >= 0) { - close(dev_fd); - dev_fd = -1; - } - return 0; -} - -int SensorBase::getFd() const { - if (!data_name) { - return dev_fd; - } - return data_fd; -} - -int SensorBase::setDelay(int32_t handle, int64_t ns) { - return 0; -} - -bool SensorBase::hasPendingEvents() const { - return false; -} - -int64_t SensorBase::getTimestamp() { - struct timespec t; - t.tv_sec = t.tv_nsec = 0; - clock_gettime(CLOCK_MONOTONIC, &t); - return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec; -} - -int SensorBase::openInput(const char* inputName) { - int fd = -1; - const char *dirname = "/dev/input"; - char devname[PATH_MAX]; - char *filename; - DIR *dir; - struct dirent *de; - dir = opendir(dirname); - if(dir == NULL) - return -1; - strcpy(devname, dirname); - filename = devname + strlen(devname); - *filename++ = '/'; - while((de = readdir(dir))) { - if(de->d_name[0] == '.' && - (de->d_name[1] == '\0' || - (de->d_name[1] == '.' && de->d_name[2] == '\0'))) - continue; - strcpy(filename, de->d_name); - fd = open(devname, O_RDONLY); - if (fd>=0) { - char name[80]; - if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) { - name[0] = '\0'; - } - if (!strcmp(name, inputName)) { - strcpy(input_name, filename); - break; - } else { - close(fd); - fd = -1; - } - } - } - closedir(dir); - LOGE_IF(fd<0, "couldn't find '%s' input device", inputName); - return fd; -} diff --git a/aries/libsensors/SensorBase.h b/aries/libsensors/SensorBase.h deleted file mode 100644 index 6b4b555..0000000 --- a/aries/libsensors/SensorBase.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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_SENSOR_BASE_H -#define ANDROID_SENSOR_BASE_H - -#include -#include -#include -#include - - -/*****************************************************************************/ - -struct sensors_event_t; - -class SensorBase { -protected: - const char* dev_name; - const char* data_name; - char input_name[PATH_MAX]; - int dev_fd; - int data_fd; - - int openInput(const char* inputName); - static int64_t getTimestamp(); - - - static int64_t timevalToNano(timeval const& t) { - return t.tv_sec*1000000000LL + t.tv_usec*1000; - } - - int open_device(); - int close_device(); - -public: - SensorBase( - const char* dev_name, - const char* data_name); - - virtual ~SensorBase(); - - virtual int readEvents(sensors_event_t* data, int count) = 0; - virtual bool hasPendingEvents() const; - virtual int getFd() const; - virtual int setDelay(int32_t handle, int64_t ns); - virtual int enable(int32_t handle, int enabled) = 0; -}; - -/*****************************************************************************/ - -#endif // ANDROID_SENSOR_BASE_H diff --git a/aries/libsensors/Smb380Sensor.cpp b/aries/libsensors/Smb380Sensor.cpp deleted file mode 100644 index 3de4d9b..0000000 --- a/aries/libsensors/Smb380Sensor.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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 "Smb380Sensor.h" - - -/*****************************************************************************/ -Smb380Sensor::Smb380Sensor() - : SensorBase(NULL, "accelerometer_sensor"), - mEnabled(0), - - mInputReader(4), - mHasPendingEvent(false) -{ - LOGD("Smb380Sensor::Smb380Sensor()"); - mPendingEvent.version = sizeof(sensors_event_t); - mPendingEvent.sensor = ID_A; - mPendingEvent.type = SENSOR_TYPE_ACCELEROMETER; - memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); - - LOGD("Smb380Sensor::Smb380Sensor() open data_fd"); - - if (data_fd) { - strcpy(input_sysfs_path, "/sys/class/input/"); - strcat(input_sysfs_path, input_name); - strcat(input_sysfs_path, "/device/"); - input_sysfs_path_len = strlen(input_sysfs_path); - - //enable(0, 1); - } -} - -Smb380Sensor::~Smb380Sensor() { - - LOGD("Smb380Sensor::~Smb380Sensor()"); - if (mEnabled) { - enable(0, 0); - } -} - - - -int Smb380Sensor::enable(int32_t, int en) { - - - LOGD("Smb380Sensor::~enable(0, %d)", en); - int flags = en ? 1 : 0; - if (flags != mEnabled) { - int fd; - strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); - LOGD("Smb380Sensor::~enable(0, %d) open %s",en, input_sysfs_path); - fd = open(input_sysfs_path, O_RDWR); - if (fd >= 0) { - LOGD("Smb380Sensor::~enable(0, %d) opened %s",en, input_sysfs_path); - char buf[2]; - int err; - buf[1] = 0; - if (flags) { - buf[0] = '1'; - } else { - buf[0] = '0'; - } - err = write(fd, buf, sizeof(buf)); - close(fd); - mEnabled = flags; - //setInitialState(); - return 0; - } - return -1; - } - return 0; -} - - -bool Smb380Sensor::hasPendingEvents() const { - /* FIXME probably here should be returning mEnabled but instead - mHasPendingEvents. It does not work, so we cheat.*/ - //LOGD("Smb380Sensor::~hasPendingEvents %d", mHasPendingEvent ? 1 : 0 ); - return mHasPendingEvent; -} - - -int Smb380Sensor::setDelay(int32_t handle, int64_t ns) -{ - LOGD("Smb380Sensor::~setDelay(%d, %d)", handle, ns); - /* FIXME needs changes to the kernel driver. - We need to add a IOCTL that can set the samplingrate - the driver in ther kernel supports this allready only need - to add a IOCTL on both sides for that*/ - return 0; -} - - -int Smb380Sensor::readEvents(sensors_event_t* data, int count) -{ - //LOGD("Smb380Sensor::~readEvents() %d", count); - if (count < 1) - return -EINVAL; - - if (mHasPendingEvent) { - mHasPendingEvent = false; - mPendingEvent.timestamp = getTimestamp(); - *data = mPendingEvent; - return mEnabled ? 1 : 0; - } - - ssize_t n = mInputReader.fill(data_fd); - if (n < 0) - return n; - - int numEventReceived = 0; - input_event const* event; - - while (count && mInputReader.readEvent(&event)) { - int type = event->type; - if (type == EV_REL) { - float value = event->value; - if (event->code == EVENT_TYPE_ACCEL_X) { - mPendingEvent.acceleration.x = value * CONVERT_A_X; - } else if (event->code == EVENT_TYPE_ACCEL_Y) { - mPendingEvent.acceleration.y = value * CONVERT_A_Y; - } else if (event->code == EVENT_TYPE_ACCEL_Z) { - mPendingEvent.acceleration.z = value * CONVERT_A_Z; - } - } else if (type == EV_SYN) { - mPendingEvent.timestamp = timevalToNano(event->time); - if (mEnabled) { - *data++ = mPendingEvent; - count--; - numEventReceived++; - } - } else { - LOGE("Smb380Sensor: unknown event (type=%d, code=%d)", - type, event->code); - } - mInputReader.next(); - } - - //LOGD("Smb380Sensor::~readEvents() numEventReceived = %d", numEventReceived); - return numEventReceived++; - -} diff --git a/aries/libsensors/Smb380Sensor.h b/aries/libsensors/Smb380Sensor.h deleted file mode 100644 index 5e55e9b..0000000 --- a/aries/libsensors/Smb380Sensor.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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_SMB380_SENSOR_H -#define ANDROID_SMB380_SENSOR_H - -#include -#include -#include -#include - -#include "sensors.h" -#include "SensorBase.h" -#include "InputEventReader.h" - -/*****************************************************************************/ - - -struct smb380acc_t { - short x, /**< holds x-axis acceleration data sign extended. Range -512 to 511. */ - y, /**< holds y-axis acceleration data sign extended. Range -512 to 511. */ - z; /**< holds z-axis acceleration data sign extended. Range -512 to 511. */ -} ; - -/* smb ioctl command label */ -#define IOCTL_SMB_GET_ACC_VALUE 0 -#define DCM_IOC_MAGIC 's' -#define IOC_SET_ACCELEROMETER _IO (DCM_IOC_MAGIC, 0x64) -#define BMA150_CALIBRATION _IOWR(DCM_IOC_MAGIC,48,short) - -#define SMB_POWER_OFF 0 -#define SMB_POWER_ON 1 - -struct input_event; - -class Smb380Sensor : public SensorBase { - int mEnabled; - InputEventCircularReader mInputReader; - sensors_event_t mPendingEvent; - bool mHasPendingEvent; - char input_sysfs_path[PATH_MAX]; - int input_sysfs_path_len; - - -public: - Smb380Sensor(); - virtual ~Smb380Sensor(); - virtual int readEvents(sensors_event_t* data, int count); - virtual bool hasPendingEvents() const; - virtual int setDelay(int32_t handle, int64_t ns); - virtual int enable(int32_t handle, int enabled); -}; - -/*****************************************************************************/ - -#endif // ANDROID_GYRO_SENSOR_H diff --git a/aries/libsensors/sensors.cpp b/aries/libsensors/sensors.cpp deleted file mode 100644 index 2358a2e..0000000 --- a/aries/libsensors/sensors.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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. - */ - -#define LOG_TAG "Sensors" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -#include -#include - -#include "sensors.h" - -#include "LightSensor.h" -#include "ProximitySensor.h" -//#include "BoschYamaha.h" -#include "Smb380Sensor.h" -#include "CompassSensor.h" -#include "OrientationSensor.h" - -/*****************************************************************************/ - -#define DELAY_OUT_TIME 0x7FFFFFFF - -#define LIGHT_SENSOR_POLLTIME 2000000000 - - -#define SENSORS_ACCELERATION (1<getFd(); - mPollFds[light].events = POLLIN; - mPollFds[light].revents = 0; - - mSensors[proximity] = new ProximitySensor(); - mPollFds[proximity].fd = mSensors[proximity]->getFd(); - mPollFds[proximity].events = POLLIN; - mPollFds[proximity].revents = 0; - - mSensors[bosch] = new Smb380Sensor(); - mPollFds[bosch].fd = mSensors[bosch]->getFd(); - mPollFds[bosch].events = POLLIN; - mPollFds[bosch].revents = 0; - - mSensors[yamaha] = new CompassSensor(); - mPollFds[yamaha].fd = mSensors[yamaha]->getFd(); - mPollFds[yamaha].events = POLLIN; - mPollFds[yamaha].revents = 0; - - mSensors[orientation] = new OrientationSensor(); - mPollFds[orientation].fd = mSensors[orientation]->getFd(); - mPollFds[orientation].events = POLLIN; - mPollFds[orientation].revents = 0; - - int wakeFds[2]; - int result = pipe(wakeFds); - LOGE_IF(result<0, "error creating wake pipe (%s)", strerror(errno)); - fcntl(wakeFds[0], F_SETFL, O_NONBLOCK); - fcntl(wakeFds[1], F_SETFL, O_NONBLOCK); - mWritePipeFd = wakeFds[1]; - - mPollFds[wake].fd = wakeFds[0]; - mPollFds[wake].events = POLLIN; - mPollFds[wake].revents = 0; -} - -sensors_poll_context_t::~sensors_poll_context_t() { - for (int i=0 ; ienable(handle, enabled); - if (enabled && !err) { - const char wakeMessage(WAKE_MESSAGE); - int result = write(mWritePipeFd, &wakeMessage, 1); - LOGE_IF(result<0, "error sending wake message (%s)", strerror(errno)); - } - return err; -} - -int sensors_poll_context_t::setDelay(int handle, int64_t ns) { - - int index = handleToDriver(handle); - if (index < 0) return index; - return mSensors[index]->setDelay(handle, ns); -} - -int sensors_poll_context_t::pollEvents(sensors_event_t* data, int count) -{ - int nbEvents = 0; - int n = 0; - - do { - // see if we have some leftover from the last poll() - for (int i=0 ; count && ihasPendingEvents())) { - int nb = sensor->readEvents(data, count); - if (nb < count) { - // no more data for this sensor - mPollFds[i].revents = 0; - } - count -= nb; - nbEvents += nb; - data += nb; - } - } - - if (count) { - // we still have some room, so try to see if we can get - // some events immediately or just wait if we don't have - // anything to return - n = poll(mPollFds, numFds, nbEvents ? 0 : -1); - if (n<0) { - LOGE("poll() failed (%s)", strerror(errno)); - return -errno; - } - if (mPollFds[wake].revents & POLLIN) { - char msg; - int result = read(mPollFds[wake].fd, &msg, 1); - LOGE_IF(result<0, "error reading from wake pipe (%s)", strerror(errno)); - LOGE_IF(msg != WAKE_MESSAGE, "unknown message on wake queue (0x%02x)", int(msg)); - - mPollFds[wake].revents = 0; - } - } - // if we have events and space, go read them - } while (n && count); - - return nbEvents; -} - -/*****************************************************************************/ - -static int poll__close(struct hw_device_t *dev) -{ - sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; - if (ctx) { - delete ctx; - } - return 0; -} - -static int poll__activate(struct sensors_poll_device_t *dev, - int handle, int enabled) { - sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; - return ctx->activate(handle, enabled); -} - -static int poll__setDelay(struct sensors_poll_device_t *dev, - int handle, int64_t ns) { - sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; - return ctx->setDelay(handle, ns); -} - -static int poll__poll(struct sensors_poll_device_t *dev, - sensors_event_t* data, int count) { - sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; - return ctx->pollEvents(data, count); -} - -/*****************************************************************************/ - -/** Open a new instance of a sensor device using name */ -static int open_sensors(const struct hw_module_t* module, const char* id, - struct hw_device_t** device) -{ - int status = -EINVAL; - sensors_poll_context_t *dev = new sensors_poll_context_t(); - - memset(&dev->device, 0, sizeof(sensors_poll_device_t)); - - dev->device.common.tag = HARDWARE_DEVICE_TAG; - dev->device.common.version = 0; - dev->device.common.module = const_cast(module); - dev->device.common.close = poll__close; - dev->device.activate = poll__activate; - dev->device.setDelay = poll__setDelay; - dev->device.poll = poll__poll; - - *device = &dev->device.common; - status = 0; - - return status; -} - diff --git a/aries/libsensors/sensors.h b/aries/libsensors/sensors.h deleted file mode 100644 index 4943fc1..0000000 --- a/aries/libsensors/sensors.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * 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_SENSORS_H -#define ANDROID_SENSORS_H - -#include -#include -#include -#include - -#include - -#include -#include - -__BEGIN_DECLS - -/*****************************************************************************/ - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - -#define ID_A (0) -#define ID_M (1) -#define ID_O (2) -#define ID_L (3) -#define ID_P (4) -#define ID_GY (5) - -/*****************************************************************************/ - -/* - * The SENSORS Module - */ - -/* the GP2A is a binary proximity sensor that triggers around 5 cm on - * this hardware */ -#define PROXIMITY_THRESHOLD_GP2A 5.0f - -/*****************************************************************************/ - -#define AKM_DEVICE_NAME "/dev/akm8973_aot" - - -#define EVENT_TYPE_ACCEL_X ABS_X -#define EVENT_TYPE_ACCEL_Y ABS_Y -#define EVENT_TYPE_ACCEL_Z ABS_Z - -#define EVENT_TYPE_YAW REL_X -#define EVENT_TYPE_PITCH REL_Y -#define EVENT_TYPE_ROLL REL_Z -#define EVENT_TYPE_ORIENT_STATUS REL_WHEEL - -/* For AK8973iB */ -#define EVENT_TYPE_MAGV_X ABS_X -#define EVENT_TYPE_MAGV_Y ABS_Y -#define EVENT_TYPE_MAGV_Z ABS_Z - -#define EVENT_TYPE_PROXIMITY ABS_DISTANCE -#define EVENT_TYPE_LIGHT ABS_MISC - -#define EVENT_TYPE_GYRO_X REL_RY -#define EVENT_TYPE_GYRO_Y REL_RX -#define EVENT_TYPE_GYRO_Z REL_RZ - - -// 720 LSG = 1G -#define LSG (720.0f) -#define NUMOFACCDATA 8 - -// conversion of acceleration data to SI units (m/s^2) -#define RANGE_A (2*GRAVITY_EARTH) -#define RESOLUTION_A (RANGE_A/(512)) -#define CONVERT_A (RANGE_A/(512)) -#define CONVERT_A_X (CONVERT_A) -#define CONVERT_A_Y (CONVERT_A) -#define CONVERT_A_Z (CONVERT_A) - -// conversion of magnetic data to uT units -#define CONVERT_M (1.0f/1000.0f) -#define CONVERT_M_X (CONVERT_M) -#define CONVERT_M_Y (CONVERT_M) -#define CONVERT_M_Z (CONVERT_M) - -/* conversion of orientation data to degree units */ -#define CONVERT_O (1.0f/1000.0f) -#define CONVERT_O_A (CONVERT_O) -#define CONVERT_O_P (CONVERT_O) -#define CONVERT_O_R (CONVERT_O) - -// conversion of gyro data to SI units (radian/sec) -#define RANGE_GYRO (2000.0f*(float)M_PI/180.0f) -#define CONVERT_GYRO ((70.0f / 1000.0f) * ((float)M_PI / 180.0f)) -#define CONVERT_GYRO_X (CONVERT_GYRO) -#define CONVERT_GYRO_Y (-CONVERT_GYRO) -#define CONVERT_GYRO_Z (CONVERT_GYRO) - -#define SENSOR_STATE_MASK (0x7FFF) - -/*****************************************************************************/ - -__END_DECLS - -#endif // ANDROID_SENSORS_H diff --git a/aries/libstagefrighthw/Android.mk b/aries/libstagefrighthw/Android.mk deleted file mode 100644 index 7716541..0000000 --- a/aries/libstagefrighthw/Android.mk +++ /dev/null @@ -1,27 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - stagefright_overlay_output.cpp \ - SecHardwareRenderer.cpp \ - SEC_OMX_Plugin.cpp - -LOCAL_CFLAGS += $(PV_CFLAGS_MINUS_VISIBILITY) - -LOCAL_C_INCLUDES:= \ - $(TOP)/frameworks/base/include/media/stagefright/openmax \ - $(LOCAL_PATH)/../include \ - $(LOCAL_PATH)/../liboverlay - -LOCAL_SHARED_LIBRARIES := \ - libbinder \ - libutils \ - libcutils \ - libui \ - libdl \ - libsurfaceflinger_client - -LOCAL_MODULE := libstagefrighthw - -LOCAL_MODULE_TAGS := optional -include $(BUILD_SHARED_LIBRARY) diff --git a/aries/libstagefrighthw/SEC_OMX_Plugin.cpp b/aries/libstagefrighthw/SEC_OMX_Plugin.cpp deleted file mode 100644 index 0bb70c5..0000000 --- a/aries/libstagefrighthw/SEC_OMX_Plugin.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * 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 "SEC_OMX_Plugin.h" - -#include - -#include -#include - -namespace android { - -OMXPluginBase *createOMXPlugin() { - return new SECOMXPlugin; -} - -SECOMXPlugin::SECOMXPlugin() - : mLibHandle(dlopen("libSEC_OMX_Core.aries.so", RTLD_NOW)), - mInit(NULL), - mDeinit(NULL), - mComponentNameEnum(NULL), - mGetHandle(NULL), - mFreeHandle(NULL), - mGetRolesOfComponentHandle(NULL) { - if (mLibHandle != NULL) { - mInit = (InitFunc)dlsym(mLibHandle, "SEC_OMX_Init"); - mDeinit = (DeinitFunc)dlsym(mLibHandle, "SEC_OMX_DeInit"); - - mComponentNameEnum = - (ComponentNameEnumFunc)dlsym(mLibHandle, "SEC_OMX_ComponentNameEnum"); - - mGetHandle = (GetHandleFunc)dlsym(mLibHandle, "SEC_OMX_GetHandle"); - mFreeHandle = (FreeHandleFunc)dlsym(mLibHandle, "SEC_OMX_FreeHandle"); - - mGetRolesOfComponentHandle = - (GetRolesOfComponentFunc)dlsym( - mLibHandle, "SEC_OMX_GetRolesOfComponent"); - - (*mInit)(); - - } -} - -SECOMXPlugin::~SECOMXPlugin() { - if (mLibHandle != NULL) { - (*mDeinit)(); - - dlclose(mLibHandle); - mLibHandle = NULL; - } -} - -OMX_ERRORTYPE SECOMXPlugin::makeComponentInstance( - const char *name, - const OMX_CALLBACKTYPE *callbacks, - OMX_PTR appData, - OMX_COMPONENTTYPE **component) { - if (mLibHandle == NULL) { - return OMX_ErrorUndefined; - } - - return (*mGetHandle)( - reinterpret_cast(component), - const_cast(name), - appData, const_cast(callbacks)); -} - -OMX_ERRORTYPE SECOMXPlugin::destroyComponentInstance( - OMX_COMPONENTTYPE *component) { - if (mLibHandle == NULL) { - return OMX_ErrorUndefined; - } - - return (*mFreeHandle)(reinterpret_cast(component)); -} - -OMX_ERRORTYPE SECOMXPlugin::enumerateComponents( - OMX_STRING name, - size_t size, - OMX_U32 index) { - if (mLibHandle == NULL) { - return OMX_ErrorUndefined; - } - - return (*mComponentNameEnum)(name, size, index); -} - -OMX_ERRORTYPE SECOMXPlugin::getRolesOfComponent( - const char *name, - Vector *roles) { - roles->clear(); - - if (mLibHandle == NULL) { - return OMX_ErrorUndefined; - } - - OMX_U32 numRoles; - OMX_ERRORTYPE err = (*mGetRolesOfComponentHandle)( - const_cast(name), &numRoles, NULL); - - if (err != OMX_ErrorNone) { - return err; - } - - if (numRoles > 0) { - OMX_U8 **array = new OMX_U8 *[numRoles]; - for (OMX_U32 i = 0; i < numRoles; ++i) { - array[i] = new OMX_U8[OMX_MAX_STRINGNAME_SIZE]; - } - - OMX_U32 numRoles2; - err = (*mGetRolesOfComponentHandle)( - const_cast(name), &numRoles2, array); - - CHECK_EQ(err, OMX_ErrorNone); - CHECK_EQ(numRoles, numRoles2); - - for (OMX_U32 i = 0; i < numRoles; ++i) { - String8 s((const char *)array[i]); - roles->push(s); - - delete[] array[i]; - array[i] = NULL; - } - - delete[] array; - array = NULL; - } - - return OMX_ErrorNone; -} - -} // namespace android - diff --git a/aries/libstagefrighthw/SEC_OMX_Plugin.h b/aries/libstagefrighthw/SEC_OMX_Plugin.h deleted file mode 100644 index 6df2d31..0000000 --- a/aries/libstagefrighthw/SEC_OMX_Plugin.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * 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 SEC_OMX_PLUGIN - -#define SEC_OMX_PLUGIN - -#include - -namespace android { - -struct SECOMXPlugin : public OMXPluginBase { - SECOMXPlugin(); - virtual ~SECOMXPlugin(); - - virtual OMX_ERRORTYPE makeComponentInstance( - const char *name, - const OMX_CALLBACKTYPE *callbacks, - OMX_PTR appData, - OMX_COMPONENTTYPE **component); - - virtual OMX_ERRORTYPE destroyComponentInstance( - OMX_COMPONENTTYPE *component); - - virtual OMX_ERRORTYPE enumerateComponents( - OMX_STRING name, - size_t size, - OMX_U32 index); - - virtual OMX_ERRORTYPE getRolesOfComponent( - const char *name, - Vector *roles); - -private: - void *mLibHandle; - - typedef OMX_ERRORTYPE (*InitFunc)(); - typedef OMX_ERRORTYPE (*DeinitFunc)(); - typedef OMX_ERRORTYPE (*ComponentNameEnumFunc)( - OMX_STRING, OMX_U32, OMX_U32); - - typedef OMX_ERRORTYPE (*GetHandleFunc)( - OMX_HANDLETYPE *, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE *); - - typedef OMX_ERRORTYPE (*FreeHandleFunc)(OMX_HANDLETYPE *); - - typedef OMX_ERRORTYPE (*GetRolesOfComponentFunc)( - OMX_STRING, OMX_U32 *, OMX_U8 **); - - InitFunc mInit; - DeinitFunc mDeinit; - ComponentNameEnumFunc mComponentNameEnum; - GetHandleFunc mGetHandle; - FreeHandleFunc mFreeHandle; - GetRolesOfComponentFunc mGetRolesOfComponentHandle; - - SECOMXPlugin(const SECOMXPlugin &); - SECOMXPlugin &operator=(const SECOMXPlugin &); -}; - -} // namespace android - -#endif // SEC_OMX_PLUGIN diff --git a/aries/libstagefrighthw/SecHardwareRenderer.cpp b/aries/libstagefrighthw/SecHardwareRenderer.cpp deleted file mode 100644 index cb9e8e8..0000000 --- a/aries/libstagefrighthw/SecHardwareRenderer.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * 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. - */ - -#define LOG_TAG "SecHardwareRenderer" -#define LOG_NDEBUG 0 -#include - -#include "SecHardwareRenderer.h" - -#include -#include -#include - -#include - -#include "v4l2_utils.h" -#include "utils/Timers.h" - -#define CACHEABLE_BUFFERS 0x1 - -#define USE_ZERO_COPY -//#define SEC_DEBUG - -namespace android { - -//////////////////////////////////////////////////////////////////////////////// - -SecHardwareRenderer::SecHardwareRenderer( - const sp &surface, - size_t displayWidth, size_t displayHeight, - size_t decodedWidth, size_t decodedHeight, - OMX_COLOR_FORMATTYPE colorFormat, - int32_t rotationDegrees, - bool fromHardwareDecoder) - : mISurface(surface), - mDisplayWidth(displayWidth), - mDisplayHeight(displayHeight), - mDecodedWidth(decodedWidth), - mDecodedHeight(decodedHeight), - mColorFormat(colorFormat), - mInitCheck(NO_INIT), - mFrameSize(mDecodedWidth * mDecodedHeight * 2), - mIsFirstFrame(true), - mCustomFormat(false), - mIndex(0) { - - CHECK(mISurface.get() != NULL); - CHECK(mDecodedWidth > 0); - CHECK(mDecodedHeight > 0); - - if (colorFormat != OMX_COLOR_FormatCbYCrY - && colorFormat != OMX_COLOR_FormatYUV420Planar - && colorFormat != OMX_COLOR_FormatYUV420SemiPlanar) { - LOGE("Invalid colorFormat (0x%x)", colorFormat); - return; - } - - uint32_t orientation; - switch (rotationDegrees) { - case 0: orientation = ISurface::BufferHeap::ROT_0; break; - case 90: orientation = ISurface::BufferHeap::ROT_90; break; - case 180: orientation = ISurface::BufferHeap::ROT_180; break; - case 270: orientation = ISurface::BufferHeap::ROT_270; break; - default: orientation = ISurface::BufferHeap::ROT_0; break; - } - - sp ref; - -#if defined (USE_ZERO_COPY) - if (fromHardwareDecoder) { - ref = mISurface->createOverlay( - mDecodedWidth, mDecodedHeight, - HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP, orientation); - mCustomFormat = true; - } -#else - else - { - ref = mISurface->createOverlay( - mDecodedWidth, mDecodedHeight, HAL_PIXEL_FORMAT_YCbCr_420_P, - orientation); - } -#endif - - if (ref.get() == NULL) { - LOGE("Unable to create the overlay!"); - return; - } - - mOverlay = new Overlay(ref); - mOverlay->setParameter(CACHEABLE_BUFFERS, 0); - - mNumBuf = mOverlay->getBufferCount(); - - if (mCustomFormat) { - mFrameSize = 32; - mMemoryHeap = new MemoryHeapBase(mNumBuf * mFrameSize); - } else { - for (size_t i = 0; i < (size_t)mNumBuf; ++i) { - void *addr = mOverlay->getBufferAddress((void *)i); - mOverlayAddresses.push(addr); - } - } - - mInitCheck = OK; -} - -SecHardwareRenderer::~SecHardwareRenderer() { - - if(mMemoryHeap != NULL) - mMemoryHeap.clear(); - - if (mOverlay.get() != NULL) { - mOverlay->destroy(); - mOverlay.clear(); - } -} - -void SecHardwareRenderer::handleYUV420Planar( - const void *data, size_t size) { - - int FrameSize; - uint8_t* pPhyYAddr; - uint8_t* pPhyCAddr; - int AddrSize; - size_t offset; - - CHECK(size >= (mDecodedWidth * mDecodedHeight * 3) / 2); - - offset = mIndex * mFrameSize; - void *dst = (uint8_t *)mMemoryHeap->getBase() + offset; - - AddrSize = sizeof(void *); - memcpy(&FrameSize, data, sizeof(FrameSize)); - memcpy(&pPhyYAddr, data + sizeof(FrameSize), sizeof(pPhyYAddr)); - memcpy(&pPhyCAddr, data + sizeof(FrameSize) + (AddrSize * 1), sizeof(pPhyCAddr)); - - memcpy(dst , &pPhyYAddr, sizeof(pPhyYAddr)); - memcpy(dst + sizeof(pPhyYAddr) , &pPhyCAddr, sizeof(pPhyCAddr)); - memcpy(dst + sizeof(pPhyYAddr) + sizeof(pPhyCAddr), &mIndex, sizeof(mIndex)); -} - -void SecHardwareRenderer::render( - const void *data, size_t size, void *platformPrivate) { - - if (mOverlay.get() == NULL) { - return; - } - - if (mCustomFormat) { - /* zero copy solution case */ - - overlay_buffer_t dst = (uint8_t *)mMemoryHeap->getBase() + mIndex*mFrameSize; - - if (mColorFormat == OMX_COLOR_FormatYUV420Planar || - mColorFormat == OMX_COLOR_FormatYUV420SemiPlanar) { - handleYUV420Planar(data, size); - } - - if (mOverlay->queueBuffer(dst) == ALL_BUFFERS_FLUSHED) { - mIsFirstFrame = true; - if (mOverlay->queueBuffer((void *)dst) != 0) { - return; - } - } - - if (++mIndex == mNumBuf) { - mIndex = 0; - } - - overlay_buffer_t overlay_buffer; - if (!mIsFirstFrame) { - status_t err = mOverlay->dequeueBuffer(&overlay_buffer); - if (err == ALL_BUFFERS_FLUSHED) { - mIsFirstFrame = true; - } else { - return; - } - } else { - mIsFirstFrame = false; - } - } else { - /* normal frame case */ - if (mColorFormat == OMX_COLOR_FormatYUV420Planar) { - memcpy(mOverlayAddresses[mIndex], data, size); - } - - if (mOverlay->queueBuffer((void *)mIndex) == ALL_BUFFERS_FLUSHED) { - mIsFirstFrame = true; - if (mOverlay->queueBuffer((void *)mIndex) != 0) { - return; - } - } - - if (++mIndex == mNumBuf) { - mIndex = 0; - } - - overlay_buffer_t overlay_buffer; - if (!mIsFirstFrame) { - status_t err = mOverlay->dequeueBuffer(&overlay_buffer); - - if (err == ALL_BUFFERS_FLUSHED) { - mIsFirstFrame = true; - } else { - return; - } - } else { - mIsFirstFrame = false; - } - } -} - -} // namespace android - diff --git a/aries/libstagefrighthw/SecHardwareRenderer.h b/aries/libstagefrighthw/SecHardwareRenderer.h deleted file mode 100644 index 3fad243..0000000 --- a/aries/libstagefrighthw/SecHardwareRenderer.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * 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 SEC_HARDWARE_RENDERER_H_ - -#define SEC_HARDWARE_RENDERER_H_ - -#include -#include -#include - -#include - -#include -#include - -namespace android { - -class ISurface; -class Overlay; - -class SecHardwareRenderer : public VideoRenderer { -public: - SecHardwareRenderer( - const sp &surface, - size_t displayWidth, size_t displayHeight, - size_t decodedWidth, size_t decodedHeight, - OMX_COLOR_FORMATTYPE colorFormat, - int32_t rotationDegrees, - bool fromHardwareDecoder); - - virtual ~SecHardwareRenderer(); - - status_t initCheck() const { return mInitCheck; } - - virtual void render( - const void *data, size_t size, void *platformPrivate); - - -private: - sp mISurface; - size_t mDisplayWidth, mDisplayHeight; - size_t mDecodedWidth, mDecodedHeight; - OMX_COLOR_FORMATTYPE mColorFormat; - status_t mInitCheck; - size_t mFrameSize; - sp mOverlay; - sp mMemoryHeap; - Vector mOverlayAddresses; - bool mIsFirstFrame; - int mNumBuf; - size_t mIndex; - bool mCustomFormat; - - - SecHardwareRenderer(const SecHardwareRenderer &); - SecHardwareRenderer &operator=(const SecHardwareRenderer &); - - void handleYUV420Planar(const void *, size_t); -}; - -} // namespace android - -#endif // SEC_HARDWARE_RENDERER_H_ - diff --git a/aries/libstagefrighthw/stagefright_overlay_output.cpp b/aries/libstagefrighthw/stagefright_overlay_output.cpp deleted file mode 100644 index fce1d7e..0000000 --- a/aries/libstagefrighthw/stagefright_overlay_output.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * 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 "SecHardwareRenderer.h" - -#include - -using android::sp; -using android::ISurface; -using android::VideoRenderer; - -VideoRenderer *createRendererWithRotation( - const sp &surface, - const char *componentName, - OMX_COLOR_FORMATTYPE colorFormat, - size_t displayWidth, size_t displayHeight, - size_t decodedWidth, size_t decodedHeight, - int32_t rotationDegrees) { - using android::SecHardwareRenderer; - - bool fromHardwareDecoder = !strncmp(componentName, "OMX.SEC.", 8); - - SecHardwareRenderer *renderer = - new SecHardwareRenderer( - surface, displayWidth, displayHeight, - decodedWidth, decodedHeight, - colorFormat, - rotationDegrees, - fromHardwareDecoder); - - if (renderer->initCheck() != android::OK) { - delete renderer; - renderer = NULL; - } - - return renderer; -} - diff --git a/aries/mkshbootimg.py b/aries/mkshbootimg.py deleted file mode 100755 index dcc8294..0000000 --- a/aries/mkshbootimg.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -import sys, os - -def copydata(outfile, infile): - while 1: - data = infile.read(512) - if (data): - outfile.write(data) - else: - break - -def alignoffset(outfile): - offset = outfile.tell() - outfile.seek((offset + 511) & ~511) - return outfile.tell() - -def appendimage(outfile, infile): - offset = alignoffset(outfile) - copydata(outfile, infile) - length = alignoffset(outfile) - offset - assert (offset % 512 == 0) - assert (length % 512 == 0) - return (offset/512, length/512) - -if len(sys.argv) < 4: - print "Usage:", sys.argv[0], "output kernel boot [recovery]" - sys.exit(1) - -outfile = open(sys.argv[1], 'wb') -kernel = open(sys.argv[2], 'r') -boot = open(sys.argv[3], 'r') -recovery = None -if (len(sys.argv) == 5): - recovery = open(sys.argv[4], 'r') -offset_table = "\n\nBOOT_IMAGE_OFFSETS\n" -copydata(outfile, kernel) -table_loc = alignoffset(outfile) -outfile.write('\x00' * 512) -offset_table += "boot_offset=%d;boot_len=%d;" % appendimage(outfile, boot) -if recovery: - offset_table += "recovery_offset=%d;recovery_len=%d;" % appendimage(outfile, recovery) -offset_table += "\n\n" -outfile.seek(table_loc) -outfile.write(offset_table) -outfile.flush() -os.fsync(outfile.fileno()) -outfile.close() diff --git a/aries/sec_mm/Android.mk b/aries/sec_mm/Android.mk deleted file mode 100644 index 6571161..0000000 --- a/aries/sec_mm/Android.mk +++ /dev/null @@ -1 +0,0 @@ -include $(all-subdir-makefiles) diff --git a/aries/sec_mm/sec_omx/Android.mk b/aries/sec_mm/sec_omx/Android.mk deleted file mode 100644 index cbae428..0000000 --- a/aries/sec_mm/sec_omx/Android.mk +++ /dev/null @@ -1,22 +0,0 @@ - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -SEC_OMX_TOP := $(LOCAL_PATH) -SEC_CODECS := $(SEC_OMX_TOP)/sec_codecs/ - -SEC_OMX_INC := $(SEC_OMX_TOP)/sec_omx_include/ -SEC_OMX_COMPONENT := $(SEC_OMX_TOP)/sec_omx_component - -include $(SEC_OMX_TOP)/sec_osal/Android.mk -include $(SEC_OMX_TOP)/sec_omx_core/Android.mk - -include $(SEC_CODECS)/Android.mk -include $(SEC_OMX_COMPONENT)/common/Android.mk -include $(SEC_OMX_COMPONENT)/video/dec/Android.mk -include $(SEC_OMX_COMPONENT)/video/dec/h264dec/Android.mk -include $(SEC_OMX_COMPONENT)/video/dec/mpeg4dec/Android.mk -include $(SEC_OMX_COMPONENT)/video/enc/Android.mk -include $(SEC_OMX_COMPONENT)/video/enc/h264enc/Android.mk -include $(SEC_OMX_COMPONENT)/video/enc/mpeg4enc/Android.mk diff --git a/aries/sec_mm/sec_omx/sec_codecs/Android.mk b/aries/sec_mm/sec_omx/sec_codecs/Android.mk deleted file mode 100644 index a51a075..0000000 --- a/aries/sec_mm/sec_omx/sec_codecs/Android.mk +++ /dev/null @@ -1,7 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -include $(SEC_CODECS)/video/mfc_c110/dec/Android.mk -include $(SEC_CODECS)/video/mfc_c110/enc/Android.mk - diff --git a/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/Android.mk b/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/Android.mk deleted file mode 100644 index a694deb..0000000 --- a/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/Android.mk +++ /dev/null @@ -1,26 +0,0 @@ - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := \ - src/SsbSipMfcDecAPI.c - -LOCAL_MODULE := libsecmfcdecapi.aries - -LOCAL_PRELINK_MODULE := false - -LOCAL_CFLAGS := - -LOCAL_ARM_MODE := arm - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := liblog - -LOCAL_C_INCLUDES := \ - $(SEC_CODECS)/video/mfc_c110/include - -include $(BUILD_STATIC_LIBRARY) - diff --git a/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/src/SsbSipMfcDecAPI.c b/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/src/SsbSipMfcDecAPI.c deleted file mode 100644 index 508f290..0000000 --- a/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/src/SsbSipMfcDecAPI.c +++ /dev/null @@ -1,675 +0,0 @@ -/* - * Copyright 2010 Samsung Electronics Co. LTD - * - * 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 "mfc_interface.h" -#include "SsbSipMfcApi.h" - -#define _MFCLIB_MAGIC_NUMBER 0x92241000 - -#define USR_DATA_START_CODE (0x000001B2) -#define VOP_START_CODE (0x000001B6) -#define MP4_START_CODE (0x000001) - -static void getAByte(char *buff, int *code) -{ - int byte; - - *code = (*code << 8); - byte = (int)*buff; - byte &= 0xFF; - *code |= byte; -} - -static mfc_packed_mode isPBPacked(_MFCLIB *pCtx, int length) -{ - char *strmBuffer = NULL; - char *strmBufferEnd = NULL; - int startCode = 0xFFFFFFFF; - - strmBuffer = (char *)pCtx->virStrmBuf; - strmBufferEnd = (char *)pCtx->virStrmBuf + length; - - while (1) { - while (startCode != USR_DATA_START_CODE) { - if (startCode == VOP_START_CODE) { - LOGV("isPBPacked: VOP START Found !!.....return\n"); - LOGV("isPBPacked: Non Packed PB\n"); - return MFC_UNPACKED_PB; - } - getAByte(strmBuffer, &startCode); - strmBuffer++; - if (strmBuffer >= strmBufferEnd) - goto out; - } - LOGV("isPBPacked: User Data Found !!\n"); - - do { - if (*strmBuffer == 'p') { - LOGI("isPBPacked: Packed PB\n"); - return MFC_PACKED_PB; - } - getAByte(strmBuffer, &startCode); - strmBuffer++; - if (strmBuffer >= strmBufferEnd) - goto out; - } while ((startCode >> 8) != MP4_START_CODE); - } - -out: - LOGV("isPBPacked: Non Packed PB\n"); - return MFC_UNPACKED_PB; -} - -void *SsbSipMfcDecOpen(void) -{ - int hMFCOpen; - unsigned int mapped_addr; - _MFCLIB *pCTX; - - pCTX = (_MFCLIB *)malloc(sizeof(_MFCLIB)); - if (pCTX == NULL) { - LOGE("SsbSipMfcDecOpen: malloc failed.\n"); - return NULL; - } - memset(pCTX, 0, sizeof(_MFCLIB)); - - hMFCOpen = open(S5PC110_MFC_DEV_NAME, O_RDWR | O_NDELAY); - if (hMFCOpen < 0) { - LOGE("SsbSipMfcDecOpen: MFC Open failure\n"); - return NULL; - } - - mapped_addr = (unsigned int)mmap(0, MMAP_BUFFER_SIZE_MMAP, PROT_READ | PROT_WRITE, MAP_SHARED, hMFCOpen, 0); - if (!mapped_addr) { - LOGE("SsbSipMfcDecOpen: FIMV5.0 driver address mapping failed\n"); - return NULL; - } - - pCTX->magic = _MFCLIB_MAGIC_NUMBER; - pCTX->hMFC = hMFCOpen; - pCTX->mapped_addr = mapped_addr; - pCTX->inter_buff_status = MFC_USE_NONE; - - return (void *)pCTX; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcDecInit(void *openHandle, SSBSIP_MFC_CODEC_TYPE codec_type, int Frameleng) -{ - int ret_code; - int packedPB = MFC_UNPACKED_PB; - mfc_common_args DecArg; - _MFCLIB *pCTX; - - if (openHandle == NULL) { - LOGE("SsbSipMfcDecSetConfig: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX = (_MFCLIB *)openHandle; - memset(&DecArg, 0x00, sizeof(DecArg)); - - if ((codec_type != MPEG4_DEC) && - (codec_type != H264_DEC) && - (codec_type != H263_DEC) && - (codec_type != MPEG1_DEC) && - (codec_type != MPEG2_DEC) && - (codec_type != FIMV1_DEC) && - (codec_type != FIMV2_DEC) && - (codec_type != FIMV3_DEC) && - (codec_type != FIMV4_DEC) && - (codec_type != XVID_DEC) && - (codec_type != VC1RCV_DEC) && - (codec_type != VC1_DEC)) { - LOGE("SsbSipMfcDecOpen: Undefined codec type.\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX->codec_type = codec_type; - - if ((pCTX->codec_type == MPEG4_DEC) || - (pCTX->codec_type == FIMV1_DEC) || - (pCTX->codec_type == FIMV2_DEC) || - (pCTX->codec_type == FIMV3_DEC) || - (pCTX->codec_type == FIMV4_DEC) || - (pCTX->codec_type == XVID_DEC)) - packedPB = isPBPacked(pCTX, Frameleng); - - /* init args */ - DecArg.args.dec_init.in_codec_type = pCTX->codec_type; - DecArg.args.dec_init.in_strm_size = Frameleng; - DecArg.args.dec_init.in_strm_buf = pCTX->phyStrmBuf; - DecArg.args.dec_init.in_packed_PB = packedPB; - - /* mem alloc args */ - DecArg.args.dec_init.in_mapped_addr = pCTX->mapped_addr; - - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_DEC_INIT, &DecArg); - if (DecArg.ret_code != MFC_RET_OK) { - LOGE("SsbSipMfcDecInit: IOCTL_MFC_DEC_INIT (%d) failed\n", DecArg.ret_code); - return MFC_RET_DEC_INIT_FAIL; - } - - pCTX->decOutInfo.img_width = DecArg.args.dec_init.out_img_width; - pCTX->decOutInfo.img_height = DecArg.args.dec_init.out_img_height; - pCTX->decOutInfo.buf_width = DecArg.args.dec_init.out_buf_width; - pCTX->decOutInfo.buf_height = DecArg.args.dec_init.out_buf_height; - - /* by RainAde : crop information */ - pCTX->decOutInfo.crop_top_offset = DecArg.args.dec_init.out_crop_top_offset; - pCTX->decOutInfo.crop_bottom_offset = DecArg.args.dec_init.out_crop_bottom_offset; - pCTX->decOutInfo.crop_left_offset = DecArg.args.dec_init.out_crop_left_offset; - pCTX->decOutInfo.crop_right_offset = DecArg.args.dec_init.out_crop_right_offset; - - pCTX->virFrmBuf.luma = DecArg.args.dec_init.out_u_addr.luma; - pCTX->virFrmBuf.chroma = DecArg.args.dec_init.out_u_addr.chroma; - - pCTX->phyFrmBuf.luma = DecArg.args.dec_init.out_p_addr.luma; - pCTX->phyFrmBuf.chroma = DecArg.args.dec_init.out_p_addr.chroma; - pCTX->sizeFrmBuf.luma = DecArg.args.dec_init.out_frame_buf_size.luma; - pCTX->sizeFrmBuf.chroma = DecArg.args.dec_init.out_frame_buf_size.chroma; - pCTX->inter_buff_status |= MFC_USE_YUV_BUFF; - - return MFC_RET_OK; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcDecExe(void *openHandle, int lengthBufFill) -{ - int ret_code; - int Yoffset; - int Coffset; - _MFCLIB *pCTX; - mfc_common_args DecArg; - - if (openHandle == NULL) { - LOGE("SsbSipMfcDecExe: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - if ((lengthBufFill < 0) || (lengthBufFill > MAX_DECODER_INPUT_BUFFER_SIZE)) { - LOGE("SsbSipMfcDecExe: lengthBufFill is invalid. (lengthBufFill=%d)\n", lengthBufFill); - return MFC_RET_INVALID_PARAM; - } - - pCTX = (_MFCLIB *)openHandle; - memset(&DecArg, 0x00, sizeof(DecArg)); - - DecArg.args.dec_exe.in_codec_type = pCTX->codec_type; - DecArg.args.dec_exe.in_strm_buf = pCTX->phyStrmBuf; - DecArg.args.dec_exe.in_strm_size = lengthBufFill; - DecArg.args.dec_exe.in_frm_buf.luma = pCTX->phyFrmBuf.luma; - DecArg.args.dec_exe.in_frm_buf.chroma = pCTX->phyFrmBuf.chroma; - DecArg.args.dec_exe.in_frm_size.luma = pCTX->sizeFrmBuf.luma; - DecArg.args.dec_exe.in_frm_size.chroma = pCTX->sizeFrmBuf.chroma; - DecArg.args.dec_exe.in_frametag = pCTX->in_frametag; - - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_DEC_EXE, &DecArg); - if (DecArg.ret_code != MFC_RET_OK) { - LOGE("SsbSipMfcDecExe: IOCTL_MFC_DEC_EXE failed(ret : %d)\n", DecArg.ret_code); - return MFC_RET_DEC_EXE_ERR; - } - - Yoffset = DecArg.args.dec_exe.out_display_Y_addr - DecArg.args.dec_exe.in_frm_buf.luma; - Coffset = DecArg.args.dec_exe.out_display_C_addr - DecArg.args.dec_exe.in_frm_buf.chroma; - - pCTX->decOutInfo.YPhyAddr = (void *)(DecArg.args.dec_exe.out_display_Y_addr); - pCTX->decOutInfo.CPhyAddr = (void *)(DecArg.args.dec_exe.out_display_C_addr); - pCTX->decOutInfo.YVirAddr = (void *)(pCTX->virFrmBuf.luma + Yoffset); - pCTX->decOutInfo.CVirAddr = (void *)(pCTX->virFrmBuf.chroma + Coffset); - pCTX->decOutInfo.timestamp_top = DecArg.args.dec_exe.out_timestamp_top; - pCTX->decOutInfo.timestamp_bottom = DecArg.args.dec_exe.out_timestamp_bottom; - pCTX->decOutInfo.consumedByte = DecArg.args.dec_exe.out_consume_bytes; - pCTX->decOutInfo.res_change = DecArg.args.dec_exe.out_res_change; - pCTX->decOutInfo.crop_top_offset = DecArg.args.dec_exe.out_crop_top_offset; - pCTX->decOutInfo.crop_bottom_offset = DecArg.args.dec_exe.out_crop_bottom_offset; - pCTX->decOutInfo.crop_left_offset = DecArg.args.dec_exe.out_crop_left_offset; - pCTX->decOutInfo.crop_right_offset = DecArg.args.dec_exe.out_crop_right_offset; - pCTX->out_frametag_top = DecArg.args.dec_exe.out_frametag_top; - pCTX->out_frametag_bottom = DecArg.args.dec_exe.out_frametag_bottom; - pCTX->displayStatus = DecArg.args.dec_exe.out_display_status; - - return MFC_RET_OK; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcDecClose(void *openHandle) -{ - int ret_code; - _MFCLIB *pCTX; - mfc_common_args free_arg; - - if (openHandle == NULL) { - LOGE("SsbSipMfcDecClose: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX = (_MFCLIB *)openHandle; - - if (pCTX->inter_buff_status & MFC_USE_YUV_BUFF) { - free_arg.args.mem_free.u_addr = pCTX->virFrmBuf.luma; - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_FREE_BUF, &free_arg); - free_arg.args.mem_free.u_addr = pCTX->virFrmBuf.chroma; - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_FREE_BUF, &free_arg); - } - - if (pCTX->inter_buff_status & MFC_USE_STRM_BUFF) { - free_arg.args.mem_free.u_addr = pCTX->virStrmBuf; - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_FREE_BUF, &free_arg); - } - - pCTX->inter_buff_status = MFC_USE_NONE; - - munmap((void *)pCTX->mapped_addr, MMAP_BUFFER_SIZE_MMAP); - close(pCTX->hMFC); - free(pCTX); - - return MFC_RET_OK; -} - -void *SsbSipMfcDecGetInBuf(void *openHandle, void **phyInBuf, int inputBufferSize) -{ - int ret_code; - _MFCLIB *pCTX; - mfc_common_args user_addr_arg, phys_addr_arg; - - if (inputBufferSize < 0) { - LOGE("SsbSipMfcDecGetInBuf: inputBufferSize = %d is invalid\n", inputBufferSize); - return NULL; - } - - if (openHandle == NULL) { - LOGE("SsbSipMfcDecGetInBuf: openHandle is NULL\n"); - return NULL; - } - - pCTX = (_MFCLIB *)openHandle; - - user_addr_arg.args.mem_alloc.codec_type = pCTX->codec_type; - user_addr_arg.args.mem_alloc.buff_size = inputBufferSize; - user_addr_arg.args.mem_alloc.mapped_addr = pCTX->mapped_addr; - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_GET_IN_BUF, &user_addr_arg); - if (ret_code < 0) { - LOGE("SsbSipMfcDecGetInBuf: IOCTL_MFC_GET_IN_BUF failed\n"); - return NULL; - } - pCTX->virStrmBuf = user_addr_arg.args.mem_alloc.out_uaddr; - pCTX->phyStrmBuf = user_addr_arg.args.mem_alloc.out_paddr; - pCTX->sizeStrmBuf = inputBufferSize; - pCTX->inter_buff_status |= MFC_USE_STRM_BUFF; - - *phyInBuf = (void *)pCTX->phyStrmBuf; - - return (void *)pCTX->virStrmBuf; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcDecSetInBuf(void *openHandle, void *phyInBuf, void *virInBuf, int inputBufferSize) -{ - _MFCLIB *pCTX; - - if (openHandle == NULL) { - LOGE("SsbSipMfcDecSetInBuf: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX = (_MFCLIB *)openHandle; - - pCTX->phyStrmBuf = (int)phyInBuf; - pCTX->virStrmBuf = (int)virInBuf; - pCTX->sizeStrmBuf = inputBufferSize; - return MFC_RET_OK; -} - -SSBSIP_MFC_DEC_OUTBUF_STATUS SsbSipMfcDecGetOutBuf(void *openHandle, SSBSIP_MFC_DEC_OUTPUT_INFO *output_info) -{ - _MFCLIB *pCTX; - - if (openHandle == NULL) { - LOGE("SsbSipMfcDecGetOutBuf: openHandle is NULL\n"); - return MFC_GETOUTBUF_DISPLAY_END; - } - - pCTX = (_MFCLIB *)openHandle; - - output_info->YPhyAddr = pCTX->decOutInfo.YPhyAddr; - output_info->CPhyAddr = pCTX->decOutInfo.CPhyAddr; - - output_info->YVirAddr = pCTX->decOutInfo.YVirAddr; - output_info->CVirAddr = pCTX->decOutInfo.CVirAddr; - - output_info->img_width = pCTX->decOutInfo.img_width; - output_info->img_height= pCTX->decOutInfo.img_height; - - output_info->buf_width = pCTX->decOutInfo.buf_width; - output_info->buf_height= pCTX->decOutInfo.buf_height; - - /* by RainAde : for crop information */ - output_info->crop_top_offset = pCTX->decOutInfo.crop_top_offset; - output_info->crop_bottom_offset= pCTX->decOutInfo.crop_bottom_offset; - output_info->crop_left_offset = pCTX->decOutInfo.crop_left_offset; - output_info->crop_right_offset= pCTX->decOutInfo.crop_right_offset; - - if (pCTX->displayStatus == 0) - return MFC_GETOUTBUF_DISPLAY_END; - else if (pCTX->displayStatus == 1) - return MFC_GETOUTBUF_DISPLAY_DECODING; - else if (pCTX->displayStatus == 2) - return MFC_GETOUTBUF_DISPLAY_ONLY; - else - return MFC_GETOUTBUF_DECODING_ONLY; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcDecSetConfig(void *openHandle, SSBSIP_MFC_DEC_CONF conf_type, void *value) -{ - int ret_code; - _MFCLIB *pCTX; - mfc_common_args DecArg; - SSBSIP_MFC_IMG_RESOLUTION *img_resolution; - - if (openHandle == NULL) { - LOGE("SsbSipMfcDecSetConfig: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - if (value == NULL) { - LOGE("SsbSipMfcDecSetConfig: value is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX = (_MFCLIB *)openHandle; - memset(&DecArg, 0x00, sizeof(DecArg)); - - switch (conf_type) { - case MFC_DEC_SETCONF_POST_ENABLE: - case MFC_DEC_SETCONF_EXTRA_BUFFER_NUM: - case MFC_DEC_SETCONF_DISPLAY_DELAY: - case MFC_DEC_SETCONF_IS_LAST_FRAME: - case MFC_DEC_SETCONF_SLICE_ENABLE: - case MFC_DEC_SETCONF_CRC_ENABLE: - DecArg.args.set_config.in_config_param = conf_type; - DecArg.args.set_config.in_config_value[0] = *((unsigned int *)value); - DecArg.args.set_config.in_config_value[1] = 0; - break; - - case MFC_DEC_SETCONF_FIMV1_WIDTH_HEIGHT: - img_resolution = (SSBSIP_MFC_IMG_RESOLUTION *)value; - DecArg.args.set_config.in_config_param = conf_type; - DecArg.args.set_config.in_config_value[0] = img_resolution->width; - DecArg.args.set_config.in_config_value[1] = img_resolution->height; - break; - - case MFC_DEC_SETCONF_FRAME_TAG: - pCTX->in_frametag = *((int *)value); - return MFC_RET_OK; - - default: - LOGE("SsbSipMfcDecSetConfig: No such conf_type is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_SET_CONFIG, &DecArg); - if (DecArg.ret_code != MFC_RET_OK) { - LOGE("SsbSipMfcDecSetConfig: IOCTL_MFC_SET_CONFIG failed(ret : %d, conf_type: %d)\n", DecArg.ret_code, conf_type); - return MFC_RET_DEC_SET_CONF_FAIL; - } - - return MFC_RET_OK; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcDecGetConfig(void *openHandle, SSBSIP_MFC_DEC_CONF conf_type, void *value) -{ - int ret_code; - _MFCLIB *pCTX; - mfc_common_args DecArg; - - SSBSIP_MFC_IMG_RESOLUTION *img_resolution; - SSBSIP_MFC_CROP_INFORMATION *crop_information; - MFC_CRC_DATA *crc_data; - - if (openHandle == NULL) { - LOGE("SsbSipMfcDecGetConfig: openHandle is NULL\n"); - return MFC_RET_FAIL; - } - - if (value == NULL) { - LOGE("SsbSipMfcDecGetConfig: value is NULL\n"); - return MFC_RET_FAIL; - } - - pCTX = (_MFCLIB *)openHandle; - memset(&DecArg, 0x00, sizeof(DecArg)); - - switch (conf_type) { - case MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT: - img_resolution = (SSBSIP_MFC_IMG_RESOLUTION *)value; - img_resolution->width = pCTX->decOutInfo.img_width; - img_resolution->height = pCTX->decOutInfo.img_height; - img_resolution->buf_width = pCTX->decOutInfo.buf_width; - img_resolution->buf_height = pCTX->decOutInfo.buf_height; - break; - - /* Added by RainAde */ - case MFC_DEC_GETCONF_CROP_INFO: - crop_information = (SSBSIP_MFC_CROP_INFORMATION*)value; - crop_information->crop_top_offset = pCTX->decOutInfo.crop_top_offset; - crop_information->crop_bottom_offset= pCTX->decOutInfo.crop_bottom_offset; - crop_information->crop_left_offset = pCTX->decOutInfo.crop_left_offset; - crop_information->crop_right_offset= pCTX->decOutInfo.crop_right_offset; - break; - - case MFC_DEC_GETCONF_CRC_DATA: - crc_data = (MFC_CRC_DATA *)value; - - DecArg.args.get_config.in_config_param = conf_type; - - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_GET_CONFIG, &DecArg); - if (DecArg.ret_code != MFC_RET_OK) { - LOGE("SsbSipMfcDecGetConfig: IOCTL_MFC_GET_CONFIG failed(ret : %d, conf_type: %d)\n", DecArg.ret_code, conf_type); - return MFC_RET_DEC_GET_CONF_FAIL; - } - crc_data->luma0 = DecArg.args.get_config.out_config_value[0]; - crc_data->chroma0 = DecArg.args.get_config.out_config_value[1]; - break; - - case MFC_DEC_GETCONF_FRAME_TAG: - *((unsigned int *)value) = pCTX->out_frametag_top; - break; - - default: - LOGE("SsbSipMfcDecGetConfig: No such conf_type is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - - return MFC_RET_OK; -} - -int tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos) -{ - int pixel_x_m1, pixel_y_m1; - int roundup_x, roundup_y; - int linear_addr0, linear_addr1, bank_addr ; - int x_addr; - int trans_addr; - - pixel_x_m1 = x_size -1; - pixel_y_m1 = y_size -1; - - roundup_x = ((pixel_x_m1 >> 7) + 1); - roundup_y = ((pixel_x_m1 >> 6) + 1); - - x_addr = x_pos >> 2; - - if ((y_size <= y_pos+32) && ( y_pos < y_size) && - (((pixel_y_m1 >> 5) & 0x1) == 0) && (((y_pos >> 5) & 0x1) == 0)) { - linear_addr0 = (((y_pos & 0x1f) <<4) | (x_addr & 0xf)); - linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 6) & 0x3f)); - - if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1)) - bank_addr = ((x_addr >> 4) & 0x1); - else - bank_addr = 0x2 | ((x_addr >> 4) & 0x1); - } else { - linear_addr0 = (((y_pos & 0x1f) << 4) | (x_addr & 0xf)); - linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 5) & 0x7f)); - - if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1)) - bank_addr = ((x_addr >> 4) & 0x1); - else - bank_addr = 0x2 | ((x_addr >> 4) & 0x1); - } - - linear_addr0 = linear_addr0 << 2; - trans_addr = (linear_addr1 <<13) | (bank_addr << 11) | linear_addr0; - - return trans_addr; -} - -void Y_tile_to_linear_4x2(unsigned char *p_linear_addr, unsigned char *p_tiled_addr, unsigned int x_size, unsigned int y_size) -{ - int trans_addr; - unsigned int i, j, k, index; - unsigned char data8[4]; - unsigned int max_index = x_size * y_size; - - for (i = 0; i < y_size; i = i + 16) { - for (j = 0; j < x_size; j = j + 16) { - trans_addr = tile_4x2_read(x_size, y_size, j, i); - for (k = 0; k < 16; k++) { - /* limit check - prohibit segmentation fault */ - index = (i * x_size) + (x_size * k) + j; - /* remove equal condition to solve thumbnail bug */ - if (index + 16 > max_index) { - continue; - } - - data8[0] = p_tiled_addr[trans_addr + 64 * k + 0]; - data8[1] = p_tiled_addr[trans_addr + 64 * k + 1]; - data8[2] = p_tiled_addr[trans_addr + 64 * k + 2]; - data8[3] = p_tiled_addr[trans_addr + 64 * k + 3]; - - p_linear_addr[index] = data8[0]; - p_linear_addr[index + 1] = data8[1]; - p_linear_addr[index + 2] = data8[2]; - p_linear_addr[index + 3] = data8[3]; - - data8[0] = p_tiled_addr[trans_addr + 64 * k + 4]; - data8[1] = p_tiled_addr[trans_addr + 64 * k + 5]; - data8[2] = p_tiled_addr[trans_addr + 64 * k + 6]; - data8[3] = p_tiled_addr[trans_addr + 64 * k + 7]; - - p_linear_addr[index + 4] = data8[0]; - p_linear_addr[index + 5] = data8[1]; - p_linear_addr[index + 6] = data8[2]; - p_linear_addr[index + 7] = data8[3]; - - data8[0] = p_tiled_addr[trans_addr + 64 * k + 8]; - data8[1] = p_tiled_addr[trans_addr + 64 * k + 9]; - data8[2] = p_tiled_addr[trans_addr + 64 * k + 10]; - data8[3] = p_tiled_addr[trans_addr + 64 * k + 11]; - - p_linear_addr[index + 8] = data8[0]; - p_linear_addr[index + 9] = data8[1]; - p_linear_addr[index + 10] = data8[2]; - p_linear_addr[index + 11] = data8[3]; - - data8[0] = p_tiled_addr[trans_addr + 64 * k + 12]; - data8[1] = p_tiled_addr[trans_addr + 64 * k + 13]; - data8[2] = p_tiled_addr[trans_addr + 64 * k + 14]; - data8[3] = p_tiled_addr[trans_addr + 64 * k + 15]; - - p_linear_addr[index + 12] = data8[0]; - p_linear_addr[index + 13] = data8[1]; - p_linear_addr[index + 14] = data8[2]; - p_linear_addr[index + 15] = data8[3]; - } - } - } -} - -void CbCr_tile_to_linear_4x2(unsigned char *p_linear_addr, unsigned char *p_tiled_addr, unsigned int x_size, unsigned int y_size) -{ - int trans_addr; - unsigned int i, j, k, index; - unsigned char data8[4]; - unsigned int half_y_size = y_size / 2; - unsigned int max_index = x_size * half_y_size; - unsigned char *pUVAddr[2]; - - pUVAddr[0] = p_linear_addr; - pUVAddr[1] = p_linear_addr + ((x_size * half_y_size) / 2); - - for (i = 0; i < half_y_size; i = i + 16) { - for (j = 0; j < x_size; j = j + 16) { - trans_addr = tile_4x2_read(x_size, half_y_size, j, i); - for (k = 0; k < 16; k++) { - /* limit check - prohibit segmentation fault */ - index = (i * x_size) + (x_size * k) + j; - /* remove equal condition to solve thumbnail bug */ - if (index + 16 > max_index) { - continue; - } - - data8[0] = p_tiled_addr[trans_addr + 64 * k + 0]; - data8[1] = p_tiled_addr[trans_addr + 64 * k + 1]; - data8[2] = p_tiled_addr[trans_addr + 64 * k + 2]; - data8[3] = p_tiled_addr[trans_addr + 64 * k + 3]; - - pUVAddr[index%2][index/2] = data8[0]; - pUVAddr[(index+1)%2][(index+1)/2] = data8[1]; - pUVAddr[(index+2)%2][(index+2)/2] = data8[2]; - pUVAddr[(index+3)%2][(index+3)/2] = data8[3]; - - data8[0] = p_tiled_addr[trans_addr + 64 * k + 4]; - data8[1] = p_tiled_addr[trans_addr + 64 * k + 5]; - data8[2] = p_tiled_addr[trans_addr + 64 * k + 6]; - data8[3] = p_tiled_addr[trans_addr + 64 * k + 7]; - - pUVAddr[(index+4)%2][(index+4)/2] = data8[0]; - pUVAddr[(index+5)%2][(index+5)/2] = data8[1]; - pUVAddr[(index+6)%2][(index+6)/2] = data8[2]; - pUVAddr[(index+7)%2][(index+7)/2] = data8[3]; - - data8[0] = p_tiled_addr[trans_addr + 64 * k + 8]; - data8[1] = p_tiled_addr[trans_addr + 64 * k + 9]; - data8[2] = p_tiled_addr[trans_addr + 64 * k + 10]; - data8[3] = p_tiled_addr[trans_addr + 64 * k + 11]; - - pUVAddr[(index+8)%2][(index+8)/2] = data8[0]; - pUVAddr[(index+9)%2][(index+9)/2] = data8[1]; - pUVAddr[(index+10)%2][(index+10)/2] = data8[2]; - pUVAddr[(index+11)%2][(index+11)/2] = data8[3]; - - data8[0] = p_tiled_addr[trans_addr + 64 * k + 12]; - data8[1] = p_tiled_addr[trans_addr + 64 * k + 13]; - data8[2] = p_tiled_addr[trans_addr + 64 * k + 14]; - data8[3] = p_tiled_addr[trans_addr + 64 * k + 15]; - - pUVAddr[(index+12)%2][(index+12)/2] = data8[0]; - pUVAddr[(index+13)%2][(index+13)/2] = data8[1]; - pUVAddr[(index+14)%2][(index+14)/2] = data8[2]; - pUVAddr[(index+15)%2][(index+15)/2] = data8[3]; - } - } - } -} diff --git a/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/Android.mk b/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/Android.mk deleted file mode 100644 index e138a99..0000000 --- a/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/Android.mk +++ /dev/null @@ -1,26 +0,0 @@ - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := \ - src/SsbSipMfcEncAPI.c - -LOCAL_MODULE := libsecmfcencapi.aries - -LOCAL_PRELINK_MODULE := false - -LOCAL_CFLAGS := -DUSE_FIMC_FRAME_BUFFER - -LOCAL_ARM_MODE := arm - -LOCAL_STATIC_LIBRARIES := - -LOCAL_SHARED_LIBRARIES := liblog - -LOCAL_C_INCLUDES := \ - $(SEC_CODECS)/video/mfc_c110/include - -include $(BUILD_STATIC_LIBRARY) - diff --git a/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/src/SsbSipMfcEncAPI.c b/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/src/SsbSipMfcEncAPI.c deleted file mode 100644 index 2c33c5b..0000000 --- a/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/src/SsbSipMfcEncAPI.c +++ /dev/null @@ -1,630 +0,0 @@ -/* - * Copyright 2010 Samsung Electronics Co. LTD - * - * 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 "SsbSipMfcApi.h" -#include "mfc_interface.h" - -#define _MFCLIB_MAGIC_NUMBER 0x92241001 - -void *SsbSipMfcEncOpen(void) -{ - int hMFCOpen; - _MFCLIB *pCTX; - unsigned int mapped_addr; - - hMFCOpen = open(S5PC110_MFC_DEV_NAME, O_RDWR | O_NDELAY); - if (hMFCOpen < 0) { - LOGE("SsbSipMfcEncOpen: MFC Open failure\n"); - return NULL; - } - - pCTX = (_MFCLIB *)malloc(sizeof(_MFCLIB)); - if (pCTX == NULL) { - LOGE("SsbSipMfcEncOpen: malloc failed.\n"); - close(hMFCOpen); - return NULL; - } - - mapped_addr = (unsigned int)mmap(0, MMAP_BUFFER_SIZE_MMAP, PROT_READ | PROT_WRITE, MAP_SHARED, hMFCOpen, 0); - if (!mapped_addr) { - LOGE("SsbSipMfcEncOpen: FIMV5.0 driver address mapping failed\n"); - return NULL; - } - - memset(pCTX, 0, sizeof(_MFCLIB)); - - pCTX->magic = _MFCLIB_MAGIC_NUMBER; - pCTX->hMFC = hMFCOpen; - pCTX->mapped_addr = mapped_addr; - pCTX->inter_buff_status = MFC_USE_NONE; - - return (void *)pCTX; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncInit(void *openHandle, void *param) -{ - int ret_code; - int dpbBufSize; - - _MFCLIB *pCTX; - mfc_common_args EncArg; - mfc_common_args user_addr_arg, phys_addr_arg; - SSBSIP_MFC_ENC_H264_PARAM *h264_arg; - SSBSIP_MFC_ENC_MPEG4_PARAM *mpeg4_arg; - SSBSIP_MFC_ENC_H263_PARAM *h263_arg; - SSBSIP_MFC_CODEC_TYPE codec_type; - - pCTX = (_MFCLIB *)openHandle; - memset(&EncArg, 0, sizeof(mfc_common_args)); - - LOGV("SsbSipMfcEncInit: Encode Init start\n"); - - mpeg4_arg = (SSBSIP_MFC_ENC_MPEG4_PARAM *)param; - codec_type = mpeg4_arg->codecType; - - if ((codec_type != MPEG4_ENC) && - (codec_type != H264_ENC) && - (codec_type != H263_ENC)) { - LOGE("SsbSipMfcEncOpen: Undefined codec type.\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX->codec_type = codec_type; - - switch (pCTX->codec_type) { - case MPEG4_ENC: - LOGV("SsbSipMfcEncInit: MPEG4 Encode\n"); - mpeg4_arg = (SSBSIP_MFC_ENC_MPEG4_PARAM *)param; - - pCTX->width = mpeg4_arg->SourceWidth; - pCTX->height = mpeg4_arg->SourceHeight; - break; - - case H263_ENC: - LOGV("SsbSipMfcEncInit: H263 Encode\n"); - h263_arg = (SSBSIP_MFC_ENC_H263_PARAM *)param; - - pCTX->width = h263_arg->SourceWidth; - pCTX->height = h263_arg->SourceHeight; - break; - - case H264_ENC: - LOGV("SsbSipMfcEncInit: H264 Encode\n"); - h264_arg = (SSBSIP_MFC_ENC_H264_PARAM *)param; - - pCTX->width = h264_arg->SourceWidth; - pCTX->height = h264_arg->SourceHeight; - break; - - default: - break; - } - - switch (pCTX->codec_type) { - case MPEG4_ENC: - mpeg4_arg = (SSBSIP_MFC_ENC_MPEG4_PARAM*)param; - - EncArg.args.enc_init_mpeg4.in_codec_type = pCTX->codec_type; - EncArg.args.enc_init_mpeg4.in_profile_level = ENC_PROFILE_LEVEL(mpeg4_arg->ProfileIDC, mpeg4_arg->LevelIDC); - - EncArg.args.enc_init_mpeg4.in_width = mpeg4_arg->SourceWidth; - EncArg.args.enc_init_mpeg4.in_height = mpeg4_arg->SourceHeight; - EncArg.args.enc_init_mpeg4.in_gop_num = mpeg4_arg->IDRPeriod; - if (mpeg4_arg->DisableQpelME) - EncArg.args.enc_init_mpeg4.in_qpelME_enable = 0; - else - EncArg.args.enc_init_mpeg4.in_qpelME_enable = 1; - - EncArg.args.enc_init_mpeg4.in_MS_mode = mpeg4_arg->SliceMode; - EncArg.args.enc_init_mpeg4.in_MS_size = mpeg4_arg->SliceArgument; - - if (mpeg4_arg->NumberBFrames > 2) { - LOGE("SsbSipMfcEncInit: No such BframeNum is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_mpeg4.in_BframeNum = mpeg4_arg->NumberBFrames; - EncArg.args.enc_init_mpeg4.in_mb_refresh = mpeg4_arg->RandomIntraMBRefresh; - - /* rate control*/ - EncArg.args.enc_init_mpeg4.in_RC_frm_enable = mpeg4_arg->EnableFRMRateControl; - if ((mpeg4_arg->QSCodeMin > 51) || (mpeg4_arg->QSCodeMax > 51)) { - LOGE("SsbSipMfcEncInit: No such Min/Max QP is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_mpeg4.in_RC_qbound = ENC_RC_QBOUND(mpeg4_arg->QSCodeMin, mpeg4_arg->QSCodeMax); - EncArg.args.enc_init_mpeg4.in_RC_rpara = mpeg4_arg->CBRPeriodRf; - - /* pad control */ - EncArg.args.enc_init_mpeg4.in_pad_ctrl_on = mpeg4_arg->PadControlOn; - if ((mpeg4_arg->LumaPadVal > 255) || (mpeg4_arg->CbPadVal > 255) || (mpeg4_arg->CrPadVal > 255)) { - LOGE("SsbSipMfcEncInit: No such Pad value is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_mpeg4.in_luma_pad_val = mpeg4_arg->LumaPadVal; - EncArg.args.enc_init_mpeg4.in_cb_pad_val = mpeg4_arg->CbPadVal; - EncArg.args.enc_init_mpeg4.in_cr_pad_val = mpeg4_arg->CrPadVal; - - EncArg.args.enc_init_mpeg4.in_time_increament_res = mpeg4_arg->TimeIncreamentRes; - EncArg.args.enc_init_mpeg4.in_time_vop_time_increament = mpeg4_arg->VopTimeIncreament; - EncArg.args.enc_init_mpeg4.in_RC_framerate = (mpeg4_arg->TimeIncreamentRes / mpeg4_arg->VopTimeIncreament); - EncArg.args.enc_init_mpeg4.in_RC_bitrate = mpeg4_arg->Bitrate; - if ((mpeg4_arg->FrameQp > 51) || (mpeg4_arg->FrameQp_P) > 51 || (mpeg4_arg->FrameQp_B > 51)) { - LOGE("SsbSipMfcEncInit: No such FrameQp is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_mpeg4.in_frame_qp = mpeg4_arg->FrameQp; - if (mpeg4_arg->FrameQp_P) - EncArg.args.enc_init_mpeg4.in_frame_P_qp = mpeg4_arg->FrameQp_P; - else - EncArg.args.enc_init_mpeg4.in_frame_P_qp = mpeg4_arg->FrameQp; - if (mpeg4_arg->FrameQp_B) - EncArg.args.enc_init_mpeg4.in_frame_B_qp = mpeg4_arg->FrameQp_B; - else - EncArg.args.enc_init_mpeg4.in_frame_B_qp = mpeg4_arg->FrameQp; - - break; - - case H263_ENC: - h263_arg = (SSBSIP_MFC_ENC_H263_PARAM *)param; - - EncArg.args.enc_init_mpeg4.in_codec_type = pCTX->codec_type; - EncArg.args.enc_init_mpeg4.in_profile_level = ENC_PROFILE_LEVEL(66, 40); - EncArg.args.enc_init_mpeg4.in_width = h263_arg->SourceWidth; - EncArg.args.enc_init_mpeg4.in_height = h263_arg->SourceHeight; - EncArg.args.enc_init_mpeg4.in_gop_num = h263_arg->IDRPeriod; - EncArg.args.enc_init_mpeg4.in_mb_refresh = h263_arg->RandomIntraMBRefresh; - EncArg.args.enc_init_mpeg4.in_MS_mode = h263_arg->SliceMode; - EncArg.args.enc_init_mpeg4.in_MS_size = 0; - - /* rate control*/ - EncArg.args.enc_init_mpeg4.in_RC_frm_enable = h263_arg->EnableFRMRateControl; - if ((h263_arg->QSCodeMin > 51) || (h263_arg->QSCodeMax > 51)) { - LOGE("SsbSipMfcEncInit: No such Min/Max QP is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_mpeg4.in_RC_qbound = ENC_RC_QBOUND(h263_arg->QSCodeMin, h263_arg->QSCodeMax); - EncArg.args.enc_init_mpeg4.in_RC_rpara = h263_arg->CBRPeriodRf; - - /* pad control */ - EncArg.args.enc_init_mpeg4.in_pad_ctrl_on = h263_arg->PadControlOn; - if ((h263_arg->LumaPadVal > 255) || (h263_arg->CbPadVal > 255) || (h263_arg->CrPadVal > 255)) { - LOGE("SsbSipMfcEncInit: No such Pad value is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_mpeg4.in_luma_pad_val = h263_arg->LumaPadVal; - EncArg.args.enc_init_mpeg4.in_cb_pad_val = h263_arg->CbPadVal; - EncArg.args.enc_init_mpeg4.in_cr_pad_val = h263_arg->CrPadVal; - - EncArg.args.enc_init_mpeg4.in_RC_framerate = h263_arg->FrameRate; - EncArg.args.enc_init_mpeg4.in_RC_bitrate = h263_arg->Bitrate; - if (h263_arg->FrameQp > 51) { - LOGE("SsbSipMfcEncInit: No such FrameQp is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_mpeg4.in_frame_qp = h263_arg->FrameQp; - if (h263_arg->FrameQp_P) - EncArg.args.enc_init_mpeg4.in_frame_P_qp = h263_arg->FrameQp_P; - else - EncArg.args.enc_init_mpeg4.in_frame_P_qp = h263_arg->FrameQp; - - break; - - case H264_ENC: - h264_arg = (SSBSIP_MFC_ENC_H264_PARAM *)param; - - EncArg.args.enc_init_h264.in_codec_type = H264_ENC; - EncArg.args.enc_init_h264.in_profile_level = ENC_PROFILE_LEVEL(h264_arg->ProfileIDC, h264_arg->LevelIDC); - - EncArg.args.enc_init_h264.in_width = h264_arg->SourceWidth; - EncArg.args.enc_init_h264.in_height = h264_arg->SourceHeight; - EncArg.args.enc_init_h264.in_gop_num = h264_arg->IDRPeriod; - - if ((h264_arg->NumberRefForPframes > 2) || (h264_arg->NumberReferenceFrames > 2)) { - LOGE("SsbSipMfcEncInit: No such ref Num is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_h264.in_reference_num = h264_arg->NumberReferenceFrames; - EncArg.args.enc_init_h264.in_ref_num_p = h264_arg->NumberRefForPframes; - - if ((h264_arg->SliceMode == 0) || (h264_arg->SliceMode == 1) || - (h264_arg->SliceMode == 2) || (h264_arg->SliceMode == 4)) { - EncArg.args.enc_init_h264.in_MS_mode = h264_arg->SliceMode; - } else { - LOGE("SsbSipMfcEncInit: No such slice mode is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_h264.in_MS_size = h264_arg->SliceArgument; - - if (h264_arg->NumberBFrames > 2) { - LOGE("SsbSipMfcEncInit: No such BframeNum is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_h264.in_BframeNum = h264_arg->NumberBFrames; - - EncArg.args.enc_init_h264.in_deblock_filt = h264_arg->LoopFilterDisable; - if ((abs(h264_arg->LoopFilterAlphaC0Offset) > 6) || (abs(h264_arg->LoopFilterBetaOffset) > 6)) { - LOGE("SsbSipMfcEncInit: No such AlphaC0Offset or BetaOffset is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_h264.in_deblock_alpha_C0 = h264_arg->LoopFilterAlphaC0Offset; - EncArg.args.enc_init_h264.in_deblock_beta = h264_arg->LoopFilterBetaOffset; - - EncArg.args.enc_init_h264.in_symbolmode = h264_arg->SymbolMode; - EncArg.args.enc_init_h264.in_interlace_mode = h264_arg->PictureInterlace; - EncArg.args.enc_init_h264.in_transform8x8_mode = h264_arg->Transform8x8Mode; - - EncArg.args.enc_init_h264.in_mb_refresh = h264_arg->RandomIntraMBRefresh; - - /* pad control */ - EncArg.args.enc_init_h264.in_pad_ctrl_on = h264_arg->PadControlOn; - if ((h264_arg->LumaPadVal > 255) || (h264_arg->CbPadVal > 255) || (h264_arg->CrPadVal > 255)) { - LOGE("SsbSipMfcEncInit: No such Pad value is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_h264.in_luma_pad_val = h264_arg->LumaPadVal; - EncArg.args.enc_init_h264.in_cb_pad_val = h264_arg->CbPadVal; - EncArg.args.enc_init_h264.in_cr_pad_val = h264_arg->CrPadVal; - - /* rate control*/ - EncArg.args.enc_init_h264.in_RC_frm_enable = h264_arg->EnableFRMRateControl; - EncArg.args.enc_init_h264.in_RC_mb_enable = h264_arg->EnableMBRateControl; - EncArg.args.enc_init_h264.in_RC_framerate = h264_arg->FrameRate; - EncArg.args.enc_init_h264.in_RC_bitrate = h264_arg->Bitrate; - if (h264_arg->FrameQp > 51) { - LOGE("SsbSipMfcEncInit: No such FrameQp is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_h264.in_frame_qp = h264_arg->FrameQp; - if (h264_arg->FrameQp_P) - EncArg.args.enc_init_h264.in_frame_P_qp = h264_arg->FrameQp_P; - else - EncArg.args.enc_init_h264.in_frame_P_qp = h264_arg->FrameQp; - if (h264_arg->FrameQp_B) - EncArg.args.enc_init_h264.in_frame_B_qp = h264_arg->FrameQp_B; - else - EncArg.args.enc_init_h264.in_frame_B_qp = h264_arg->FrameQp; - - if ((h264_arg->QSCodeMin > 51) || (h264_arg->QSCodeMax > 51)) { - LOGE("SsbSipMfcEncInit: No such Min/Max QP is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - EncArg.args.enc_init_h264.in_RC_qbound = ENC_RC_QBOUND(h264_arg->QSCodeMin, h264_arg->QSCodeMax); - EncArg.args.enc_init_h264.in_RC_rpara = h264_arg->CBRPeriodRf; - EncArg.args.enc_init_h264.in_RC_mb_dark_disable = h264_arg->DarkDisable; - EncArg.args.enc_init_h264.in_RC_mb_smooth_disable = h264_arg->SmoothDisable; - EncArg.args.enc_init_h264.in_RC_mb_static_disable = h264_arg->StaticDisable; - EncArg.args.enc_init_h264.in_RC_mb_activity_disable = h264_arg->ActivityDisable; - - /* default setting */ - EncArg.args.enc_init_h264.in_md_interweight_pps = 0; - EncArg.args.enc_init_h264.in_md_intraweight_pps = 0; - break; - - default: - break; - } - - EncArg.args.enc_init_mpeg4.in_mapped_addr = pCTX->mapped_addr; - - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_ENC_INIT, &EncArg); - if (EncArg.ret_code != MFC_RET_OK) { - LOGE("SsbSipMfcEncInit: IOCTL_MFC_ENC_INIT (%d) failed\n", EncArg.ret_code); - return MFC_RET_ENC_INIT_FAIL; - } - - pCTX->virStrmBuf = EncArg.args.enc_init_mpeg4.out_u_addr.strm_ref_y; - pCTX->phyStrmBuf = EncArg.args.enc_init_mpeg4.out_p_addr.strm_ref_y; - pCTX->sizeStrmBuf = MAX_ENCODER_OUTPUT_BUFFER_SIZE; - pCTX->encodedHeaderSize = EncArg.args.enc_init_mpeg4.out_header_size; - - pCTX->virMvRefYC = EncArg.args.enc_init_mpeg4.out_u_addr.mv_ref_yc; - - pCTX->inter_buff_status |= MFC_USE_STRM_BUFF; - - return MFC_RET_OK; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncExe(void *openHandle) -{ - int ret_code; - _MFCLIB *pCTX; - mfc_common_args EncArg; - - if (openHandle == NULL) { - LOGE("SsbSipMfcEncExe: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX = (_MFCLIB *)openHandle; - - memset(&EncArg, 0x00, sizeof(mfc_common_args)); - - EncArg.args.enc_exe.in_codec_type = pCTX->codec_type; - EncArg.args.enc_exe.in_Y_addr = (unsigned int)pCTX->phyFrmBuf.luma; - EncArg.args.enc_exe.in_CbCr_addr = (unsigned int)pCTX->phyFrmBuf.chroma; - EncArg.args.enc_exe.in_Y_addr_vir = (unsigned int)pCTX->virFrmBuf.luma; - EncArg.args.enc_exe.in_CbCr_addr_vir = (unsigned int)pCTX->virFrmBuf.chroma; - EncArg.args.enc_exe.in_strm_st = (unsigned int)pCTX->phyStrmBuf; - EncArg.args.enc_exe.in_strm_end = (unsigned int)pCTX->phyStrmBuf + pCTX->sizeStrmBuf; - EncArg.args.enc_exe.in_frametag = pCTX->in_frametag; - - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_ENC_EXE, &EncArg); - if (EncArg.ret_code != MFC_RET_OK) { - LOGE("SsbSipMfcDecExe: IOCTL_MFC_ENC_EXE failed(ret : %d)\n", EncArg.ret_code); - return MFC_RET_ENC_EXE_ERR; - } - - pCTX->encodedDataSize = EncArg.args.enc_exe.out_encoded_size; - pCTX->encodedframeType = EncArg.args.enc_exe.out_frame_type; - pCTX->encoded_Y_paddr = EncArg.args.enc_exe.out_encoded_Y_paddr; - pCTX->encoded_C_paddr = EncArg.args.enc_exe.out_encoded_C_paddr; - pCTX->out_frametag_top = EncArg.args.enc_exe.out_frametag_top; - pCTX->out_frametag_bottom = EncArg.args.enc_exe.out_frametag_bottom; - - return MFC_RET_OK; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncClose(void *openHandle) -{ - int ret_code; - _MFCLIB *pCTX; - mfc_common_args free_arg; - - if (openHandle == NULL) { - LOGE("SsbSipMfcEncClose: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX = (_MFCLIB *)openHandle; - - if (pCTX->inter_buff_status & MFC_USE_YUV_BUFF) { - free_arg.args.mem_free.u_addr = pCTX->virFrmBuf.luma; - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_FREE_BUF, &free_arg); - } - - if (pCTX->inter_buff_status & MFC_USE_STRM_BUFF) { - free_arg.args.mem_free.u_addr = pCTX->virStrmBuf; - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_FREE_BUF, &free_arg); - free_arg.args.mem_free.u_addr = pCTX->virMvRefYC; - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_FREE_BUF, &free_arg); - } - - pCTX->inter_buff_status = MFC_USE_NONE; - - munmap((void *)pCTX->mapped_addr, MMAP_BUFFER_SIZE_MMAP); - close(pCTX->hMFC); - free(pCTX); - - return MFC_RET_OK; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetInBuf(void *openHandle, SSBSIP_MFC_ENC_INPUT_INFO *input_info) -{ - int ret_code; - _MFCLIB *pCTX; - mfc_common_args user_addr_arg, phys_addr_arg; - int y_size, c_size; - int aligned_y_size, aligned_c_size; - - if (openHandle == NULL) { - LOGE("SsbSipMfcEncGetInBuf: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX = (_MFCLIB *)openHandle; - - user_addr_arg.args.mem_alloc.codec_type = pCTX->codec_type; - - y_size = pCTX->width * pCTX->height; - c_size = (pCTX->width * pCTX->height) >> 1; - - aligned_y_size = ALIGN_TO_8KB(ALIGN_TO_128B(pCTX->width) * ALIGN_TO_32B(pCTX->height)); - aligned_c_size = ALIGN_TO_8KB(ALIGN_TO_128B(pCTX->width) * ALIGN_TO_32B(pCTX->height/2)); - - /* Allocate luma & chroma buf */ - user_addr_arg.args.mem_alloc.buff_size = aligned_y_size + aligned_c_size; - user_addr_arg.args.mem_alloc.mapped_addr = pCTX->mapped_addr; - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_GET_IN_BUF, &user_addr_arg); - if (ret_code < 0) { - LOGE("SsbSipMfcEncGetInBuf: IOCTL_MFC_GET_IN_BUF failed\n"); - return MFC_RET_ENC_GET_INBUF_FAIL; - } - pCTX->virFrmBuf.luma = user_addr_arg.args.mem_alloc.out_uaddr; - pCTX->virFrmBuf.chroma = user_addr_arg.args.mem_alloc.out_uaddr + (unsigned int)aligned_y_size; - pCTX->phyFrmBuf.luma = user_addr_arg.args.mem_alloc.out_paddr; - pCTX->phyFrmBuf.chroma = user_addr_arg.args.mem_alloc.out_paddr + (unsigned int)aligned_y_size; - - pCTX->sizeFrmBuf.luma = (unsigned int)y_size; - pCTX->sizeFrmBuf.chroma = (unsigned int)c_size; - pCTX->inter_buff_status |= MFC_USE_YUV_BUFF; - - input_info->YPhyAddr = (void*)pCTX->phyFrmBuf.luma; - input_info->CPhyAddr = (void*)pCTX->phyFrmBuf.chroma; - input_info->YVirAddr = (void*)pCTX->virFrmBuf.luma; - input_info->CVirAddr = (void*)pCTX->virFrmBuf.chroma; - - return MFC_RET_OK; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetInBuf(void *openHandle, SSBSIP_MFC_ENC_INPUT_INFO *input_info) -{ - _MFCLIB *pCTX; - - if (openHandle == NULL) { - LOGE("SsbSipMfcEncSetInBuf: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - LOGV("SsbSipMfcEncSetInBuf: input_info->YPhyAddr & input_info->CPhyAddr should be 64KB aligned\n"); - - pCTX = (_MFCLIB *)openHandle; - - pCTX->phyFrmBuf.luma = (unsigned int)input_info->YPhyAddr; - pCTX->phyFrmBuf.chroma = (unsigned int)input_info->CPhyAddr; - pCTX->virFrmBuf.luma = (unsigned int)input_info->YVirAddr; - pCTX->virFrmBuf.chroma = (unsigned int)input_info->CVirAddr; - - pCTX->sizeFrmBuf.luma = (unsigned int)input_info->YSize; - pCTX->sizeFrmBuf.chroma = (unsigned int)input_info->CSize; - - return MFC_RET_OK; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetOutBuf(void *openHandle, SSBSIP_MFC_ENC_OUTPUT_INFO *output_info) -{ - _MFCLIB *pCTX; - - if (openHandle == NULL) { - LOGE("SsbSipMfcEncGetOutBuf: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX = (_MFCLIB *)openHandle; - - output_info->headerSize = pCTX->encodedHeaderSize; - output_info->dataSize = pCTX->encodedDataSize; - output_info->StrmPhyAddr = (void *)pCTX->phyStrmBuf; - output_info->StrmVirAddr = (void *)pCTX->virStrmBuf; - - if (pCTX->encodedframeType == 0) - output_info->frameType = MFC_FRAME_TYPE_NOT_CODED; - else if (pCTX->encodedframeType == 1) - output_info->frameType = MFC_FRAME_TYPE_I_FRAME; - else if (pCTX->encodedframeType == 2) - output_info->frameType = MFC_FRAME_TYPE_P_FRAME; - else if (pCTX->encodedframeType == 3) - output_info->frameType = MFC_FRAME_TYPE_B_FRAME; - else if (pCTX->encodedframeType == 4) - output_info->frameType = MFC_FRAME_TYPE_OTHERS; - else { - LOGE("Strange encoded frame type = %d\n", pCTX->encodedframeType); - return MFC_RET_INVALID_PARAM; - } - - output_info->encodedYPhyAddr = (void *)pCTX->encoded_Y_paddr; - output_info->encodedCPhyAddr = (void *)pCTX->encoded_C_paddr; - - return MFC_RET_OK; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetOutBuf(void *openHandle, void *phyOutbuf, void *virOutbuf, int outputBufferSize) -{ - _MFCLIB *pCTX; - - if (openHandle == NULL) { - LOGE("SsbSipMfcEncSetOutBuf: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX = (_MFCLIB *)openHandle; - - pCTX->phyStrmBuf = (int)phyOutbuf; - pCTX->virStrmBuf = (int)virOutbuf; - pCTX->sizeStrmBuf = outputBufferSize; - - return MFC_RET_OK; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetConfig(void *openHandle, SSBSIP_MFC_ENC_CONF conf_type, void *value) -{ - int ret_code; - _MFCLIB *pCTX; - mfc_common_args EncArg; - - if (openHandle == NULL) { - LOGE("SsbSipMfcEncSetConfig: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - if (value == NULL) { - LOGE("SsbSipMfcEncSetConfig: value is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX = (_MFCLIB *)openHandle; - memset(&EncArg, 0x00, sizeof(mfc_common_args)); - - switch (conf_type) { - case MFC_ENC_SETCONF_FRAME_TYPE: - case MFC_ENC_SETCONF_CHANGE_FRAME_RATE: - case MFC_ENC_SETCONF_CHANGE_BIT_RATE: - case MFC_ENC_SETCONF_ALLOW_FRAME_SKIP: - EncArg.args.set_config.in_config_param = conf_type; - EncArg.args.set_config.in_config_value[0] = *((unsigned int *) value); - EncArg.args.set_config.in_config_value[1] = 0; - break; - - case MFC_ENC_SETCONF_FRAME_TAG: - pCTX->in_frametag = *((int *)value); - return MFC_RET_OK; - - default: - LOGE("SsbSipMfcEncSetConfig: No such conf_type is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - - ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_SET_CONFIG, &EncArg); - if (EncArg.ret_code != MFC_RET_OK) { - LOGE("SsbSipMfcEncSetConfig: IOCTL_MFC_SET_CONFIG failed(ret : %d)\n", EncArg.ret_code); - return MFC_RET_ENC_SET_CONF_FAIL; - } - - return MFC_RET_OK; -} - -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetConfig(void *openHandle, SSBSIP_MFC_ENC_CONF conf_type, void *value) -{ - int ret_code; - _MFCLIB *pCTX; - mfc_common_args EncArg; - - pCTX = (_MFCLIB *)openHandle; - - if (openHandle == NULL) { - LOGE("SsbSipMfcEncGetConfig: openHandle is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - if (value == NULL) { - LOGE("SsbSipMfcEncGetConfig: value is NULL\n"); - return MFC_RET_INVALID_PARAM; - } - - pCTX = (_MFCLIB *)openHandle; - memset(&EncArg, 0x00, sizeof(mfc_common_args)); - - switch (conf_type) { - case MFC_ENC_GETCONF_FRAME_TAG: - *((unsigned int *)value) = pCTX->out_frametag_top; - break; - - default: - LOGE("SsbSipMfcEncGetConfig: No such conf_type is supported.\n"); - return MFC_RET_INVALID_PARAM; - } - - return MFC_RET_OK; -} diff --git a/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/SsbSipMfcApi.h b/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/SsbSipMfcApi.h deleted file mode 100644 index e083998..0000000 --- a/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/SsbSipMfcApi.h +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright 2010 Samsung Electronics Co. LTD - * - * 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 _SSBSIP_MFC_API_H_ -#define _SSBSIP_MFC_API_H_ - -/*--------------------------------------------------------------------------------*/ -/* Definition */ -/*--------------------------------------------------------------------------------*/ -#define MAX_DECODER_INPUT_BUFFER_SIZE (1024 * 3072) -#define MAX_ENCODER_OUTPUT_BUFFER_SIZE (1024 * 3072) - -#define SUPPORT_1080P 1 - -#if SUPPORT_1080P -#define MMAP_BUFFER_SIZE_MMAP (63*1024*1024) -#else -#define MMAP_BUFFER_SIZE_MMAP (49*1024*1024) -#endif - -#define S5PC110_MFC_DEV_NAME "/dev/s3c-mfc" - -/*--------------------------------------------------------------------------------*/ -/* Structure and Type */ -/*--------------------------------------------------------------------------------*/ -typedef enum { - H264_DEC, - VC1_DEC, /* VC1 advaced Profile decoding */ - MPEG4_DEC, - XVID_DEC, - MPEG1_DEC, - MPEG2_DEC, - H263_DEC, - VC1RCV_DEC, /* VC1 simple/main profile decoding */ - FIMV1_DEC, - FIMV2_DEC, - FIMV3_DEC, - FIMV4_DEC, - H264_ENC, - MPEG4_ENC, - H263_ENC, - UNKNOWN_TYPE -} SSBSIP_MFC_CODEC_TYPE; - -typedef enum { - DONT_CARE = 0, - I_FRAME = 1, - NOT_CODED = 2 -} SSBSIP_MFC_FORCE_SET_FRAME_TYPE; - -typedef enum { - MFC_DEC_SETCONF_POST_ENABLE = 1, - MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, - MFC_DEC_SETCONF_DISPLAY_DELAY, - MFC_DEC_SETCONF_IS_LAST_FRAME, - MFC_DEC_SETCONF_SLICE_ENABLE, - MFC_DEC_SETCONF_CRC_ENABLE, - MFC_DEC_SETCONF_FIMV1_WIDTH_HEIGHT, - MFC_DEC_SETCONF_FRAME_TAG, - MFC_DEC_GETCONF_CRC_DATA, - MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, - MFC_DEC_GETCONF_CROP_INFO, - MFC_DEC_GETCONF_FRAME_TAG -} SSBSIP_MFC_DEC_CONF; - -typedef enum { - MFC_ENC_SETCONF_FRAME_TYPE = 100, - MFC_ENC_SETCONF_CHANGE_FRAME_RATE, - MFC_ENC_SETCONF_CHANGE_BIT_RATE, - MFC_ENC_SETCONF_FRAME_TAG, - MFC_ENC_SETCONF_ALLOW_FRAME_SKIP, - MFC_ENC_GETCONF_FRAME_TAG -} SSBSIP_MFC_ENC_CONF; - -typedef enum { - MFC_GETOUTBUF_STATUS_NULL = 0, - MFC_GETOUTBUF_DECODING_ONLY = 1, - MFC_GETOUTBUF_DISPLAY_DECODING, - MFC_GETOUTBUF_DISPLAY_ONLY, - MFC_GETOUTBUF_DISPLAY_END -} SSBSIP_MFC_DEC_OUTBUF_STATUS; - -typedef enum { - MFC_FRAME_TYPE_NOT_CODED, - MFC_FRAME_TYPE_I_FRAME, - MFC_FRAME_TYPE_P_FRAME, - MFC_FRAME_TYPE_B_FRAME, - MFC_FRAME_TYPE_OTHERS -} SSBSIP_MFC_FRAME_TYPE; - -typedef enum { - MFC_RET_OK = 1, - MFC_RET_FAIL = -1000, - MFC_RET_OPEN_FAIL = -1001, - MFC_RET_CLOSE_FAIL = -1002, - - MFC_RET_DEC_INIT_FAIL = -2000, - MFC_RET_DEC_EXE_TIME_OUT = -2001, - MFC_RET_DEC_EXE_ERR = -2002, - MFC_RET_DEC_GET_INBUF_FAIL = -2003, - MFC_RET_DEC_SET_INBUF_FAIL = -2004, - MFC_RET_DEC_GET_OUTBUF_FAIL = -2005, - MFC_RET_DEC_GET_CONF_FAIL = -2006, - MFC_RET_DEC_SET_CONF_FAIL = -2007, - - MFC_RET_ENC_INIT_FAIL = -3000, - MFC_RET_ENC_EXE_TIME_OUT = -3001, - MFC_RET_ENC_EXE_ERR = -3002, - MFC_RET_ENC_GET_INBUF_FAIL = -3003, - MFC_RET_ENC_SET_INBUF_FAIL = -3004, - MFC_RET_ENC_GET_OUTBUF_FAIL = -3005, - MFC_RET_ENC_SET_OUTBUF_FAIL = -3006, - MFC_RET_ENC_GET_CONF_FAIL = -3007, - MFC_RET_ENC_SET_CONF_FAIL = -3008, - - MFC_RET_INVALID_PARAM = -4000 -} SSBSIP_MFC_ERROR_CODE; - -typedef struct { - void *YPhyAddr; // [OUT] physical address of Y - void *CPhyAddr; // [OUT] physical address of CbCr - void *YVirAddr; // [OUT] virtual address of Y - void *CVirAddr; // [OUT] virtual address of CbCr - - int img_width; // [OUT] width of real image - int img_height; // [OUT] height of real image - int buf_width; // [OUT] width aligned to 16 - int buf_height; // [OUT] height alighed to 16 - - int timestamp_top; // [OUT] timestamp of top filed(This is used for interlaced stream) - int timestamp_bottom; // [OUT] timestamp of bottom filed(This is used for interlaced stream) - int consumedByte; // [OUT] the number of byte consumed during decoding - int res_change; // [OUT] whether resolution is changed or not. 0: not change, 1: increased, 2: decreased - int crop_top_offset; // [OUT] crop information, top_offset - int crop_bottom_offset; // [OUT] crop information, bottom_offset - int crop_left_offset; // [OUT] crop information, left_offset - int crop_right_offset; // [OUT] crop information, right_offset -} SSBSIP_MFC_DEC_OUTPUT_INFO; - -typedef struct { - void *YPhyAddr; // [IN/OUT] physical address of Y - void *CPhyAddr; // [IN/OUT] physical address of CbCr - void *YVirAddr; // [IN/OUT] virtual address of Y - void *CVirAddr; // [IN/OUT] virtual address of CbCr - int YSize; // [IN/OUT] input size of Y data - int CSize; // [IN/OUT] input size of CbCr data -} SSBSIP_MFC_ENC_INPUT_INFO; - -typedef struct { - unsigned int dataSize; // [OUT] encoded data size(without header) - unsigned int headerSize; // [OUT] encoded header size - unsigned int frameType; // [OUT] frame type of encoded stream - void *StrmPhyAddr; // [OUT] physical address of Y - void *StrmVirAddr; // [OUT] virtual address of Y - void *encodedYPhyAddr; // [OUT] physical address of Y which is flushed - void *encodedCPhyAddr; // [OUT] physical address of C which is flushed -} SSBSIP_MFC_ENC_OUTPUT_INFO; - -typedef struct { - // common parameters - SSBSIP_MFC_CODEC_TYPE codecType; // [IN] codec type - int SourceWidth; // [IN] width of video to be encoded - int SourceHeight; // [IN] height of video to be encoded - int IDRPeriod; // [IN] GOP number(interval of I-frame) - int SliceMode; // [IN] Multi slice mode - int RandomIntraMBRefresh; // [IN] cyclic intra refresh - int EnableFRMRateControl; // [IN] frame based rate control enable - int Bitrate; // [IN] rate control parameter(bit rate) - int FrameQp; // [IN] The quantization parameter of the frame - int FrameQp_P; // [IN] The quantization parameter of the P frame - int QSCodeMax; // [IN] Maximum Quantization value - int QSCodeMin; // [IN] Minimum Quantization value - int CBRPeriodRf; // [IN] Reaction coefficient parameter for rate control - int PadControlOn; // [IN] Enable padding control - int LumaPadVal; // [IN] Luma pel value used to fill padding area - int CbPadVal; // [IN] CB pel value used to fill padding area - int CrPadVal; // [IN] CR pel value used to fill padding area - - // H.264 specific parameters - int ProfileIDC; // [IN] profile - int LevelIDC; // [IN] level - int FrameQp_B; // [IN] The quantization parameter of the B frame - int FrameRate; // [IN] rate control parameter(frame rate) - int SliceArgument; // [IN] MB number or byte number - int NumberBFrames; // [IN] The number of consecutive B frame inserted - int NumberReferenceFrames; // [IN] The number of reference pictures used - int NumberRefForPframes; // [IN] The number of reference pictures used for encoding P pictures - int LoopFilterDisable; // [IN] disable the loop filter - int LoopFilterAlphaC0Offset; // [IN] Alpha & C0 offset for H.264 loop filter - int LoopFilterBetaOffset; // [IN] Beta offset for H.264 loop filter - int SymbolMode; // [IN] The mode of entropy coding(CABAC, CAVLC) - int PictureInterlace; // [IN] Enables the interlace mode - int Transform8x8Mode; // [IN] Allow 8x8 transform(This is allowed only for high profile) - int EnableMBRateControl; // [IN] Enable macroblock-level rate control - int DarkDisable; // [IN] Disable adaptive rate control on dark region - int SmoothDisable; // [IN] Disable adaptive rate control on smooth region - int StaticDisable; // [IN] Disable adaptive rate control on static region - int ActivityDisable; // [IN] Disable adaptive rate control on high activity region -} SSBSIP_MFC_ENC_H264_PARAM; - -typedef struct { - // common parameters - SSBSIP_MFC_CODEC_TYPE codecType; // [IN] codec type - int SourceWidth; // [IN] width of video to be encoded - int SourceHeight; // [IN] height of video to be encoded - int IDRPeriod; // [IN] GOP number(interval of I-frame) - int SliceMode; // [IN] Multi slice mode - int RandomIntraMBRefresh; // [IN] cyclic intra refresh - int EnableFRMRateControl; // [IN] frame based rate control enable - int Bitrate; // [IN] rate control parameter(bit rate) - int FrameQp; // [IN] The quantization parameter of the frame - int FrameQp_P; // [IN] The quantization parameter of the P frame - int QSCodeMax; // [IN] Maximum Quantization value - int QSCodeMin; // [IN] Minimum Quantization value - int CBRPeriodRf; // [IN] Reaction coefficient parameter for rate control - int PadControlOn; // [IN] Enable padding control - int LumaPadVal; // [IN] Luma pel value used to fill padding area - int CbPadVal; // [IN] CB pel value used to fill padding area - int CrPadVal; // [IN] CR pel value used to fill padding area - - // MPEG4 specific parameters - int ProfileIDC; // [IN] profile - int LevelIDC; // [IN] level - int FrameQp_B; // [IN] The quantization parameter of the B frame - int TimeIncreamentRes; // [IN] frame rate - int VopTimeIncreament; // [IN] frame rate - int SliceArgument; // [IN] MB number or byte number - int NumberBFrames; // [IN] The number of consecutive B frame inserted - int DisableQpelME; // [IN] disable quarter-pixel motion estimation -} SSBSIP_MFC_ENC_MPEG4_PARAM; - -typedef struct { - // common parameters - SSBSIP_MFC_CODEC_TYPE codecType; // [IN] codec type - int SourceWidth; // [IN] width of video to be encoded - int SourceHeight; // [IN] height of video to be encoded - int IDRPeriod; // [IN] GOP number(interval of I-frame) - int SliceMode; // [IN] Multi slice mode - int RandomIntraMBRefresh; // [IN] cyclic intra refresh - int EnableFRMRateControl; // [IN] frame based rate control enable - int Bitrate; // [IN] rate control parameter(bit rate) - int FrameQp; // [IN] The quantization parameter of the frame - int FrameQp_P; // [IN] The quantization parameter of the P frame - int QSCodeMax; // [IN] Maximum Quantization value - int QSCodeMin; // [IN] Minimum Quantization value - int CBRPeriodRf; // [IN] Reaction coefficient parameter for rate control - int PadControlOn; // [IN] Enable padding control - int LumaPadVal; // [IN] Luma pel value used to fill padding area - int CbPadVal; // [IN] CB pel value used to fill padding area - int CrPadVal; // [IN] CR pel value used to fill padding area - - // H.263 specific parameters - int FrameRate; // [IN] rate control parameter(frame rate) -} SSBSIP_MFC_ENC_H263_PARAM; - -typedef struct { - int width; - int height; - int buf_width; - int buf_height; -} SSBSIP_MFC_IMG_RESOLUTION; - -typedef struct { - int crop_top_offset; - int crop_bottom_offset; - int crop_left_offset; - int crop_right_offset; -} SSBSIP_MFC_CROP_INFORMATION; - -#ifdef __cplusplus -extern "C" { -#endif - -/*--------------------------------------------------------------------------------*/ -/* Format Conversion API */ -/*--------------------------------------------------------------------------------*/ -void Y_tile_to_linear_4x2(unsigned char *p_linear_addr, unsigned char *p_tiled_addr, unsigned int x_size, unsigned int y_size); -void CbCr_tile_to_linear_4x2(unsigned char *p_linear_addr, unsigned char *p_tiled_addr, unsigned int x_size, unsigned int y_size); - -/*--------------------------------------------------------------------------------*/ -/* Decoding APIs */ -/*--------------------------------------------------------------------------------*/ -void *SsbSipMfcDecOpen(void); -SSBSIP_MFC_ERROR_CODE SsbSipMfcDecInit(void *openHandle, SSBSIP_MFC_CODEC_TYPE codec_type, int Frameleng); -SSBSIP_MFC_ERROR_CODE SsbSipMfcDecExe(void *openHandle, int lengthBufFill); -SSBSIP_MFC_ERROR_CODE SsbSipMfcDecClose(void *openHandle); - -void *SsbSipMfcDecGetInBuf(void *openHandle, void **phyInBuf, int inputBufferSize); -SSBSIP_MFC_ERROR_CODE SsbSipMfcDecSetInBuf(void *openHandle, void *phyInBuf, void *virInBuf, int inputBufferSize); - -SSBSIP_MFC_DEC_OUTBUF_STATUS SsbSipMfcDecGetOutBuf(void *openHandle, SSBSIP_MFC_DEC_OUTPUT_INFO *output_info); - -SSBSIP_MFC_ERROR_CODE SsbSipMfcDecSetConfig(void *openHandle, SSBSIP_MFC_DEC_CONF conf_type, void *value); -SSBSIP_MFC_ERROR_CODE SsbSipMfcDecGetConfig(void *openHandle, SSBSIP_MFC_DEC_CONF conf_type, void *value); - -/*--------------------------------------------------------------------------------*/ -/* Encoding APIs */ -/*--------------------------------------------------------------------------------*/ -void *SsbSipMfcEncOpen(void); -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncInit(void *openHandle, void *param); -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncExe(void *openHandle); -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncClose(void *openHandle); - -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetInBuf(void *openHandle, SSBSIP_MFC_ENC_INPUT_INFO *input_info); -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetInBuf(void *openHandle, SSBSIP_MFC_ENC_INPUT_INFO *input_info); - -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetOutBuf(void *openHandle, SSBSIP_MFC_ENC_OUTPUT_INFO *output_info); -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetOutBuf (void *openHandle, void *phyOutbuf, void *virOutbuf, int outputBufferSize); - -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetConfig(void *openHandle, SSBSIP_MFC_ENC_CONF conf_type, void *value); -SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetConfig(void *openHandle, SSBSIP_MFC_ENC_CONF conf_type, void *value); - -#ifdef __cplusplus -} -#endif - -#endif /* _SSBSIP_MFC_API_H_ */ diff --git a/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/mfc_interface.h b/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/mfc_interface.h deleted file mode 100644 index e7e23c3..0000000 --- a/aries/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/mfc_interface.h +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright 2010 Samsung Electronics Co. LTD - * - * 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 _MFC_INTERFACE_H_ -#define _MFC_INTERFACE_H_ - -#include "SsbSipMfcApi.h" - -#define IOCTL_MFC_DEC_INIT 0x00800001 -#define IOCTL_MFC_ENC_INIT 0x00800002 -#define IOCTL_MFC_DEC_EXE 0x00800003 -#define IOCTL_MFC_ENC_EXE 0x00800004 - -#define IOCTL_MFC_GET_IN_BUF 0x00800010 -#define IOCTL_MFC_FREE_BUF 0x00800011 -#define IOCTL_MFC_GET_PHYS_ADDR 0x00800012 - -#define IOCTL_MFC_SET_CONFIG 0x00800101 -#define IOCTL_MFC_GET_CONFIG 0x00800102 - -/* MFC H/W support maximum 32 extra DPB */ -#define MFC_MAX_EXTRA_DPB 5 - -#define ENC_PROFILE_LEVEL(profile, level) ((profile) | ((level) << 8)) - -#define ENC_PROFILE_MPEG4_SP 0 -#define ENC_PROFILE_MPEG4_ASP 1 -#define ENC_PROFILE_H264_BP 0 -#define ENC_PROFILE_H264_MAIN 1 -#define ENC_PROFILE_H264_HIGH 2 - -#define ENC_RC_DISABLE 0 -#define ENC_RC_ENABLE_MACROBLOCK 1 -#define ENC_RC_ENABLE_FRAME 2 - -#define ENC_RC_QBOUND(min_qp, max_qp) ((min_qp) | ((max_qp) << 8)) -#define ENC_RC_MB_CTRL_DARK_DISABLE (1 << 3) -#define ENC_RC_MB_CTRL_SMOOTH_DISABLE (1 << 2) -#define ENC_RC_MB_CTRL_STATIC_DISABLE (1 << 1) -#define ENC_RC_MB_CTRL_ACTIVITY_DISABLE (1 << 0) - -#define ALIGN_TO_16B(x) ((((x) + (1 << 4) - 1) >> 4) << 4) -#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5) -#define ALIGN_TO_64B(x) ((((x) + (1 << 6) - 1) >> 6) << 6) -#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7) -#define ALIGN_TO_2KB(x) ((((x) + (1 << 11) - 1) >> 11) << 11) -#define ALIGN_TO_4KB(x) ((((x) + (1 << 12) - 1) >> 12) << 12) -#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13) -#define ALIGN_TO_64KB(x) ((((x) + (1 << 16) - 1) >> 16) << 16) -#define ALIGN_TO_128KB(x) ((((x) + (1 << 17) - 1) >> 17) << 17) - -typedef struct { - int luma0; // per frame (or top field) - int chroma0; // per frame (or top field) - int luma1; // per frame (or bottom field) - int chroma1; // per frame (or bottom field) -} MFC_CRC_DATA; - -typedef enum { - MFC_USE_NONE = 0x00, - MFC_USE_YUV_BUFF = 0x01, - MFC_USE_STRM_BUFF = 0x10 -} mfc_interbuff_status; - -typedef enum { - MFC_UNPACKED_PB = 0, - MFC_PACKED_PB = 1 -} mfc_packed_mode; - -typedef struct tag_strm_ref_buf_arg { - unsigned int strm_ref_y; - unsigned int mv_ref_yc; -} mfc_strm_ref_buf_arg_t; - -typedef struct tag_frame_buf_arg { - unsigned int luma; - unsigned int chroma; -} mfc_frame_buf_arg_t; - -typedef struct { - SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */ - int in_width; /* [IN] width of YUV420 frame to be encoded */ - int in_height; /* [IN] height of YUV420 frame to be encoded */ - int in_profile_level; /* [IN] profile & level */ - int in_gop_num; /* [IN] GOP Number (interval of I-frame) */ - int in_frame_qp; /* [IN] the quantization parameter of the frame */ - int in_frame_P_qp; /* [IN] the quantization parameter of the P frame */ - int in_frame_B_qp; /* [IN] the quantization parameter of the B frame */ - - int in_RC_frm_enable; /* [IN] RC enable (0:disable, 1:frame level RC) */ - int in_RC_framerate; /* [IN] RC parameter (framerate) */ - int in_RC_bitrate; /* [IN] RC parameter (bitrate in kbps) */ - int in_RC_qbound; /* [IN] RC parameter (Q bound) */ - int in_RC_rpara; /* [IN] RC parameter (Reaction Coefficient) */ - - int in_MS_mode; /* [IN] Multi-slice mode (0:single, 1:multiple) */ - int in_MS_size; /* [IN] Multi-slice size (in num. of mb or byte) */ - int in_mb_refresh; /* [IN] Macroblock refresh */ - int in_interlace_mode; /* [IN] interlace mode(0:progressive, 1:interlace) */ - int in_BframeNum; /* [IN] B frame number */ - - int in_pad_ctrl_on; /* [IN] Enable (1) / Disable (0) padding */ - int in_luma_pad_val; /* [IN] pad value if pad_ctrl_on is Enable */ - int in_cb_pad_val; - int in_cr_pad_val; - - unsigned int in_mapped_addr; - mfc_strm_ref_buf_arg_t out_u_addr; - mfc_strm_ref_buf_arg_t out_p_addr; - mfc_strm_ref_buf_arg_t out_buf_size; - unsigned int out_header_size; - - /* MPEG4 Only */ - int in_qpelME_enable; /* [IN] Quarter-pel MC enable(1:enable, 0:disable) */ - int in_time_increament_res; /* [IN] time increment resolution */ - int in_time_vop_time_increament; /* [IN] time increment */ -} mfc_enc_init_mpeg4_arg_t; - -typedef mfc_enc_init_mpeg4_arg_t mfc_enc_init_h263_arg_t; - -typedef struct { - SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */ - int in_width; /* [IN] width of YUV420 frame to be encoded */ - int in_height; /* [IN] height of YUV420 frame to be encoded */ - int in_profile_level; /* [IN] profile & level */ - int in_gop_num; /* [IN] GOP Number (interval of I-frame) */ - int in_frame_qp; /* [IN] the quantization parameter of the frame */ - int in_frame_P_qp; /* [IN] the quantization parameter of the P frame */ - int in_frame_B_qp; /* [IN] the quantization parameter of the B frame */ - - int in_RC_frm_enable; /* [IN] RC enable (0:disable, 1:frame level RC) */ - int in_RC_framerate; /* [IN] RC parameter (framerate) */ - int in_RC_bitrate; /* [IN] RC parameter (bitrate in kbps) */ - int in_RC_qbound; /* [IN] RC parameter (Q bound) */ - int in_RC_rpara; /* [IN] RC parameter (Reaction Coefficient) */ - - int in_MS_mode; /* [IN] Multi-slice mode (0:single, 1:multiple) */ - int in_MS_size; /* [IN] Multi-slice size (in num. of mb or byte) */ - int in_mb_refresh; /* [IN] Macroblock refresh */ - int in_interlace_mode; /* [IN] interlace mode(0:progressive, 1:interlace) */ - int in_BframeNum; - - int in_pad_ctrl_on; /* [IN] Enable padding control */ - int in_luma_pad_val; /* [IN] Luma pel value used to fill padding area */ - int in_cb_pad_val; /* [IN] CB pel value used to fill padding area */ - int in_cr_pad_val; /* [IN] CR pel value used to fill padding area */ - - unsigned int in_mapped_addr; - mfc_strm_ref_buf_arg_t out_u_addr; - mfc_strm_ref_buf_arg_t out_p_addr; - mfc_strm_ref_buf_arg_t out_buf_size; - unsigned int out_header_size; - - /* H264 Only */ - int in_RC_mb_enable; /* [IN] RC enable (0:disable, 1:MB level RC) */ - int in_reference_num; /* [IN] The number of reference pictures used */ - int in_ref_num_p; /* [IN] The number of reference pictures used for P pictures */ - int in_RC_mb_dark_disable; /* [IN] Disable adaptive rate control on dark region */ - int in_RC_mb_smooth_disable; /* [IN] Disable adaptive rate control on smooth region */ - int in_RC_mb_static_disable; /* [IN] Disable adaptive rate control on static region */ - int in_RC_mb_activity_disable; /* [IN] Disable adaptive rate control on static region */ - int in_deblock_filt; /* [IN] disable the loop filter */ - int in_deblock_alpha_C0; /* [IN] Alpha & C0 offset for H.264 loop filter */ - int in_deblock_beta; /* [IN] Beta offset for H.264 loop filter */ - int in_symbolmode; /* [IN] The mode of entropy coding(CABAC, CAVLC) */ - int in_transform8x8_mode; /* [IN] Allow 8x8 transform(only for high profile) */ - int in_md_interweight_pps; /* [IN] Inter weighted parameter for mode decision */ - int in_md_intraweight_pps; /* [IN] Intra weighted parameter for mode decision */ -} mfc_enc_init_h264_arg_t; - -typedef struct { - SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */ - unsigned int in_Y_addr; /* [IN] In-buffer addr of Y component */ - unsigned int in_CbCr_addr; /* [IN] In-buffer addr of CbCr component */ - unsigned int in_Y_addr_vir; /* [IN] In-buffer addr of Y component */ - unsigned int in_CbCr_addr_vir; /* [IN] In-buffer addr of CbCr component */ - unsigned int in_strm_st; /* [IN] Out-buffer start addr of encoded strm */ - unsigned int in_strm_end; /* [IN] Out-buffer end addr of encoded strm */ - int in_frametag; /* [IN] unique frame ID */ - - unsigned int out_frame_type; /* [OUT] frame type */ - int out_encoded_size; /* [OUT] Length of Encoded video stream */ - unsigned int out_encoded_Y_paddr; /* [OUT] physical Y address which is flushed */ - unsigned int out_encoded_C_paddr; /* [OUT] physical C address which is flushed */ - int out_frametag_top; /* [OUT] unique frame ID of an output frame or top field */ - int out_frametag_bottom; /* [OUT] unique frame ID of bottom field */ -} mfc_enc_exe_arg; - -typedef struct { - SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */ - unsigned int in_strm_buf; /* [IN] the physical address of STRM_BUF */ - int in_strm_size; /* [IN] size of video stream filled in STRM_BUF */ - int in_packed_PB; /* [IN] Is packed PB frame or not, 1: packedPB 0: unpacked */ - - int out_img_width; /* [OUT] width of YUV420 frame */ - int out_img_height; /* [OUT] height of YUV420 frame */ - int out_buf_width; /* [OUT] width of YUV420 frame */ - int out_buf_height; /* [OUT] height of YUV420 frame */ - int out_dpb_cnt; /* [OUT] the number of buffers which is nessary during decoding */ - - int out_crop_top_offset; /* [OUT] crop information, top offset */ - int out_crop_bottom_offset; /* [OUT] crop information, bottom offset */ - int out_crop_left_offset; /* [OUT] crop information, left offset */ - int out_crop_right_offset; /* [OUT] crop information, right offset */ - - mfc_frame_buf_arg_t in_frm_buf; /* [IN] the address of dpb FRAME_BUF */ - mfc_frame_buf_arg_t in_frm_size; /* [IN] size of dpb FRAME_BUF */ - unsigned int in_mapped_addr; - - mfc_frame_buf_arg_t out_u_addr; - mfc_frame_buf_arg_t out_p_addr; - mfc_frame_buf_arg_t out_frame_buf_size; -} mfc_dec_init_arg_t; - -typedef struct { - SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */ - unsigned int in_strm_buf; /* [IN] the physical address of STRM_BUF */ - int in_strm_size; /* [IN] Size of video stream filled in STRM_BUF */ - mfc_frame_buf_arg_t in_frm_buf; /* [IN] the address of dpb FRAME_BUF */ - mfc_frame_buf_arg_t in_frm_size; /* [IN] size of dpb FRAME_BUF */ - int in_frametag; /* [IN] unique frame ID */ - - unsigned int out_display_Y_addr; /* [OUT] the physical address of display buf */ - unsigned int out_display_C_addr; /* [OUT] the physical address of display buf */ - int out_display_status; /* [OUT] whether display frame exist or not. */ - int out_timestamp_top; /* [OUT] presentation time of an output frame or top field */ - int out_timestamp_bottom; /* [OUT] presentation time of bottom field */ - int out_consume_bytes; /* [OUT] consumed bytes when decoding finished */ - int out_frametag_top; /* [OUT] unique frame ID of an output frame or top field */ - int out_frametag_bottom; /* [OUT] unique frame ID of bottom field */ - int out_res_change; /* [OUT] whether resolution is changed or not (0, 1, 2) */ - int out_crop_top_offset; /* [OUT] crop information, top offset */ - int out_crop_bottom_offset; /* [OUT] crop information, bottom offset */ - int out_crop_left_offset; /* [OUT] crop information, left offset */ - int out_crop_right_offset; /* [OUT] crop information, right offset */ -} mfc_dec_exe_arg_t; - -typedef struct { - int in_config_param; /* [IN] Configurable parameter type */ - int out_config_value[4]; /* [IN] Values to get for the configurable parameter. */ -} mfc_get_config_arg_t; - -typedef struct { - int in_config_param; /* [IN] Configurable parameter type */ - int in_config_value[2]; /* [IN] Values to be set for the configurable parameter. */ - int out_config_value_old[2]; /* [OUT] Old values of the configurable parameters */ -} mfc_set_config_arg_t; - -typedef struct tag_get_phys_addr_arg -{ - unsigned int u_addr; - unsigned int p_addr; -} mfc_get_phys_addr_arg_t; - -typedef struct tag_mem_alloc_arg -{ - SSBSIP_MFC_CODEC_TYPE codec_type; - int buff_size; - unsigned int mapped_addr; - unsigned int out_uaddr; - unsigned int out_paddr; -} mfc_mem_alloc_arg_t; - -typedef struct tag_mem_free_arg_t -{ - unsigned int u_addr; -} mfc_mem_free_arg_t; - -typedef union { - mfc_enc_init_mpeg4_arg_t enc_init_mpeg4; - mfc_enc_init_h263_arg_t enc_init_h263; - mfc_enc_init_h264_arg_t enc_init_h264; - mfc_enc_exe_arg enc_exe; - - mfc_dec_init_arg_t dec_init; - mfc_dec_exe_arg_t dec_exe; - - mfc_get_config_arg_t get_config; - mfc_set_config_arg_t set_config; - - mfc_mem_alloc_arg_t mem_alloc; - mfc_mem_free_arg_t mem_free; - mfc_get_phys_addr_arg_t get_phys_addr; -} mfc_args; - -typedef struct tag_mfc_args { - SSBSIP_MFC_ERROR_CODE ret_code; /* [OUT] error code */ - mfc_args args; -} mfc_common_args; - -typedef struct { - int magic; - int hMFC; - int width; - int height; - int sizeStrmBuf; - mfc_frame_buf_arg_t sizeFrmBuf; - int displayStatus; - int inter_buff_status; - unsigned int virFreeStrmAddr; - unsigned int phyStrmBuf; - unsigned int virStrmBuf; - unsigned int virMvRefYC; - mfc_frame_buf_arg_t phyFrmBuf; - mfc_frame_buf_arg_t virFrmBuf; - unsigned int mapped_addr; - mfc_common_args MfcArg; - SSBSIP_MFC_CODEC_TYPE codec_type; - SSBSIP_MFC_DEC_OUTPUT_INFO decOutInfo; - unsigned int encodedHeaderSize; - int encodedDataSize; - unsigned int encodedframeType; - int in_frametag; - int out_frametag_top; - int out_frametag_bottom; - unsigned int encoded_Y_paddr; - unsigned int encoded_C_paddr; -} _MFCLIB; - -#endif /* _MFC_INTERFACE_H_ */ diff --git a/aries/sec_mm/sec_omx/sec_omx_component/common/Android.mk b/aries/sec_mm/sec_omx/sec_omx_component/common/Android.mk deleted file mode 100644 index 6633682..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/common/Android.mk +++ /dev/null @@ -1,24 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := \ - SEC_OMX_Basecomponent.c \ - SEC_OMX_Baseport.c \ - SEC_OMX_Resourcemanager.c - -LOCAL_PRELINK_MODULE := false -LOCAL_MODULE := libsecbasecomponent.aries - -LOCAL_CFLAGS := - -LOCAL_STATIC_LIBRARIES := libsecosal.aries -LOCAL_SHARED_LIBRARIES := libcutils libutils - -LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ - $(SEC_OMX_INC)/sec \ - $(SEC_OMX_TOP)/sec_osal - -include $(BUILD_STATIC_LIBRARY) - diff --git a/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c b/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c deleted file mode 100644 index d1b224f..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c +++ /dev/null @@ -1,1486 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Basecomponent.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include - -#include "SEC_OSAL_Event.h" -#include "SEC_OSAL_Thread.h" -#include "SEC_OMX_Baseport.h" -#include "SEC_OMX_Basecomponent.h" -#include "SEC_OMX_Macros.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_BASE_COMP" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -/* Change CHECK_SIZE_VERSION Macro */ -OMX_ERRORTYPE SEC_OMX_Check_SizeVersion(OMX_PTR header, OMX_U32 size) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - - OMX_VERSIONTYPE* version = NULL; - if (header == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - version = (OMX_VERSIONTYPE*)((char*)header + sizeof(OMX_U32)); - if (*((OMX_U32*)header) != size) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (version->s.nVersionMajor != VERSIONMAJOR_NUMBER || - version->s.nVersionMinor != VERSIONMINOR_NUMBER) { - ret = OMX_ErrorVersionMismatch; - goto EXIT; - } - ret = OMX_ErrorNone; -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OMX_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 ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - OMX_U32 compUUID[3]; - - FunctionIn(); - - /* check parameters */ - if (hComponent == NULL || - pComponentName == NULL || pComponentVersion == NULL || - pSpecVersion == NULL || pComponentUUID == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - SEC_OSAL_Strcpy(pComponentName, pSECComponent->componentName); - SEC_OSAL_Memcpy(pComponentVersion, &(pSECComponent->componentVersion), sizeof(OMX_VERSIONTYPE)); - SEC_OSAL_Memcpy(pSpecVersion, &(pSECComponent->specVersion), sizeof(OMX_VERSIONTYPE)); - - /* Fill UUID with handle address, PID and UID. - * This should guarantee uiniqness */ - compUUID[0] = (OMX_U32)pOMXComponent; - compUUID[1] = getpid(); - compUUID[2] = getuid(); - SEC_OSAL_Memcpy(*pComponentUUID, compUUID, 3 * sizeof(*compUUID)); - - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_GetState ( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_STATETYPE *pState) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pState == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - *pState = pSECComponent->currentState; - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -static OMX_ERRORTYPE SEC_OMX_BufferProcessThread(OMX_PTR threadData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_MESSAGE *message = NULL; - - FunctionIn(); - - if (threadData == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)threadData; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pSECComponent->sec_BufferProcess(pOMXComponent); - - SEC_OSAL_TheadExit(NULL); - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_ComponentStateSet(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 messageParam) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_MESSAGE *message; - OMX_STATETYPE destState = messageParam; - OMX_STATETYPE currentState = pSECComponent->currentState; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_S32 countValue = 0; - int i = 0, j = 0; - - FunctionIn(); - - /* check parameters */ - if (currentState == destState) { - ret = OMX_ErrorSameState; - goto EXIT; - } - if (currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - if ((currentState == OMX_StateLoaded) && (destState == OMX_StateIdle)) { - ret = SEC_OMX_Get_Resource(pOMXComponent); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - } - if (((currentState == OMX_StateIdle) && (destState == OMX_StateLoaded)) || - ((currentState == OMX_StateIdle) && (destState == OMX_StateInvalid)) || - ((currentState == OMX_StateExecuting) && (destState == OMX_StateInvalid)) || - ((currentState == OMX_StatePause) && (destState == OMX_StateInvalid))) { - SEC_OMX_Release_Resource(pOMXComponent); - } - - SEC_OSAL_Log(SEC_LOG_TRACE, "destState: %d", destState); - - switch (destState) { - case OMX_StateInvalid: - switch (currentState) { - case OMX_StateIdle: - case OMX_StateExecuting: - case OMX_StatePause: - case OMX_StateLoaded: - case OMX_StateWaitForResources: - pSECComponent->currentState = OMX_StateInvalid; - if (pSECComponent->hBufferProcess) { - pSECComponent->bExitBufferProcessThread = OMX_TRUE; - - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[i].bufferSemID, &countValue); - if (countValue == 0) - SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[i].bufferSemID); - } - - SEC_OSAL_SignalSet(pSECComponent->pauseEvent); - SEC_OSAL_ThreadTerminate(pSECComponent->hBufferProcess); - pSECComponent->hBufferProcess = NULL; - - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_MutexTerminate(pSECComponent->secDataBuffer[i].bufferMutex); - pSECComponent->secDataBuffer[i].bufferMutex = NULL; - } - - SEC_OSAL_SignalTerminate(pSECComponent->pauseEvent); - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_SemaphoreTerminate(pSECComponent->pSECPort[i].bufferSemID); - pSECComponent->pSECPort[i].bufferSemID = NULL; - } - } - if (pSECComponent->sec_mfc_componentTerminate != NULL) - pSECComponent->sec_mfc_componentTerminate(pOMXComponent); - break; - } - ret = OMX_ErrorInvalidState; - break; - case OMX_StateLoaded: - switch (currentState) { - case OMX_StateIdle: - pSECComponent->bExitBufferProcessThread = OMX_TRUE; - - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[i].bufferSemID, &countValue); - if (countValue == 0) - SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[i].bufferSemID); - } - - SEC_OSAL_SignalSet(pSECComponent->pauseEvent); - SEC_OSAL_ThreadTerminate(pSECComponent->hBufferProcess); - pSECComponent->hBufferProcess = NULL; - - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_MutexTerminate(pSECComponent->secDataBuffer[i].bufferMutex); - pSECComponent->secDataBuffer[i].bufferMutex = NULL; - } - - SEC_OSAL_SignalTerminate(pSECComponent->pauseEvent); - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_SemaphoreTerminate(pSECComponent->pSECPort[i].bufferSemID); - pSECComponent->pSECPort[i].bufferSemID = NULL; - } - - pSECComponent->sec_mfc_componentTerminate(pOMXComponent); - - for (i = 0; i < (pSECComponent->portParam.nPorts); i++) { - pSECPort = (pSECComponent->pSECPort + i); - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) > 0) { - message = (SEC_OMX_MESSAGE*)SEC_OSAL_Dequeue(&pSECPort->bufferQ); - if (message != NULL) - SEC_OSAL_Free(message); - } - ret = pSECComponent->sec_FreeTunnelBuffer(pSECComponent, i); - if (OMX_ErrorNone != ret) { - goto EXIT; - } - } else { - if (CHECK_PORT_ENABLED(pSECPort)) { - SEC_OSAL_SemaphoreWait(pSECPort->unloadedResource); - pSECPort->portDefinition.bPopulated = OMX_FALSE; - } - } - } - pSECComponent->currentState = OMX_StateLoaded; - break; - case OMX_StateWaitForResources: - ret = SEC_OMX_Out_WaitForResource(pOMXComponent); - pSECComponent->currentState = OMX_StateLoaded; - break; - case OMX_StateExecuting: - case OMX_StatePause: - default: - ret = OMX_ErrorIncorrectStateTransition; - break; - } - break; - case OMX_StateIdle: - switch (currentState) { - case OMX_StateLoaded: - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECPort = (pSECComponent->pSECPort + i); - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - if (CHECK_PORT_ENABLED(pSECPort)) { - ret = pSECComponent->sec_AllocateTunnelBuffer(pSECPort, i); - if (ret!=OMX_ErrorNone) - goto EXIT; - } - } else { - if (CHECK_PORT_ENABLED(pSECPort)) { - SEC_OSAL_SemaphoreWait(pSECComponent->pSECPort[i].loadedResource); - pSECPort->portDefinition.bPopulated = OMX_TRUE; - } - } - } - ret = pSECComponent->sec_mfc_componentInit(pOMXComponent); - if (ret != OMX_ErrorNone) { - /* - * if (CHECK_PORT_TUNNELED == OMX_TRUE) thenTunnel Buffer Free - */ - goto EXIT; - } - pSECComponent->bExitBufferProcessThread = OMX_FALSE; - SEC_OSAL_SignalCreate(&pSECComponent->pauseEvent); - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_SemaphoreCreate(&pSECComponent->pSECPort[i].bufferSemID); - } - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_MutexCreate(&pSECComponent->secDataBuffer[i].bufferMutex); - } - ret = SEC_OSAL_ThreadCreate(&pSECComponent->hBufferProcess, - SEC_OMX_BufferProcessThread, - pOMXComponent); - if (ret != OMX_ErrorNone) { - /* - * if (CHECK_PORT_TUNNELED == OMX_TRUE) thenTunnel Buffer Free - */ - - SEC_OSAL_SignalTerminate(pSECComponent->pauseEvent); - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_MutexTerminate(pSECComponent->secDataBuffer[i].bufferMutex); - pSECComponent->secDataBuffer[i].bufferMutex = NULL; - } - for (i = 0; i < ALL_PORT_NUM; i++) { - SEC_OSAL_SemaphoreTerminate(pSECComponent->pSECPort[i].bufferSemID); - pSECComponent->pSECPort[i].bufferSemID = NULL; - } - - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - pSECComponent->currentState = OMX_StateIdle; - break; - case OMX_StateExecuting: - case OMX_StatePause: - SEC_OMX_BufferFlushProcessNoEvent(pOMXComponent, ALL_PORT_INDEX); - pSECComponent->currentState = OMX_StateIdle; - break; - case OMX_StateWaitForResources: - pSECComponent->currentState = OMX_StateIdle; - break; - } - break; - case OMX_StateExecuting: - switch (currentState) { - case OMX_StateLoaded: - ret = OMX_ErrorIncorrectStateTransition; - break; - case OMX_StateIdle: - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECPort = &pSECComponent->pSECPort[i]; - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort) && CHECK_PORT_ENABLED(pSECPort)) { - for (j = 0; j < pSECPort->tunnelBufferNum; j++) { - SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[i].bufferSemID); - } - } - } - - pSECComponent->transientState = SEC_OMX_TransStateMax; - pSECComponent->currentState = OMX_StateExecuting; - SEC_OSAL_SignalSet(pSECComponent->pauseEvent); - break; - case OMX_StatePause: - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECPort = &pSECComponent->pSECPort[i]; - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort) && CHECK_PORT_ENABLED(pSECPort)) { - OMX_U32 semaValue = 0, cnt = 0; - SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[i].bufferSemID, &semaValue); - if (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) > semaValue) { - cnt = SEC_OSAL_GetElemNum(&pSECPort->bufferQ) - semaValue; - for (j = 0; j < cnt; j++) { - SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[i].bufferSemID); - } - } - } - } - - pSECComponent->currentState = OMX_StateExecuting; - SEC_OSAL_SignalSet(pSECComponent->pauseEvent); - break; - case OMX_StateWaitForResources: - ret = OMX_ErrorIncorrectStateTransition; - break; - } - break; - case OMX_StatePause: - switch (currentState) { - case OMX_StateLoaded: - ret = OMX_ErrorIncorrectStateTransition; - break; - case OMX_StateIdle: - pSECComponent->currentState = OMX_StatePause; - break; - case OMX_StateExecuting: - pSECComponent->currentState = OMX_StatePause; - break; - case OMX_StateWaitForResources: - ret = OMX_ErrorIncorrectStateTransition; - break; - } - break; - case OMX_StateWaitForResources: - switch (currentState) { - case OMX_StateLoaded: - ret = SEC_OMX_In_WaitForResource(pOMXComponent); - pSECComponent->currentState = OMX_StateWaitForResources; - break; - case OMX_StateIdle: - case OMX_StateExecuting: - case OMX_StatePause: - ret = OMX_ErrorIncorrectStateTransition; - break; - } - break; - } - -EXIT: - if (ret == OMX_ErrorNone) { - if (pSECComponent->pCallbacks != NULL) { - pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, - pSECComponent->callbackData, - OMX_EventCmdComplete, OMX_CommandStateSet, - destState, NULL); - } - } else { - if (pSECComponent->pCallbacks != NULL) { - pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, ret, 0, NULL); - } - } - FunctionOut(); - - return ret; -} - -static OMX_ERRORTYPE SEC_OMX_MessageHandlerThread(OMX_PTR threadData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_MESSAGE *message = NULL; - OMX_U32 messageType = 0, portIndex = 0; - - FunctionIn(); - - if (threadData == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pOMXComponent = (OMX_COMPONENTTYPE *)threadData; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - while (pSECComponent->bExitMessageHandlerThread != OMX_TRUE) { - SEC_OSAL_SemaphoreWait(pSECComponent->msgSemaphoreHandle); - message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECComponent->messageQ); - if (message != NULL) { - messageType = message->messageType; - switch (messageType) { - case OMX_CommandStateSet: - ret = SEC_OMX_ComponentStateSet(pOMXComponent, message->messageParam); - break; - case OMX_CommandFlush: - ret = SEC_OMX_BufferFlushProcess(pOMXComponent, message->messageParam); - break; - case OMX_CommandPortDisable: - ret = SEC_OMX_PortDisableProcess(pOMXComponent, message->messageParam); - break; - case OMX_CommandPortEnable: - ret = SEC_OMX_PortEnableProcess(pOMXComponent, message->messageParam); - break; - case OMX_CommandMarkBuffer: - portIndex = message->messageParam; - pSECComponent->pSECPort[portIndex].markType.hMarkTargetComponent = ((OMX_MARKTYPE *)message->pCmdData)->hMarkTargetComponent; - pSECComponent->pSECPort[portIndex].markType.pMarkData = ((OMX_MARKTYPE *)message->pCmdData)->pMarkData; - break; - case (OMX_COMMANDTYPE)SEC_OMX_CommandComponentDeInit: - pSECComponent->bExitMessageHandlerThread = OMX_TRUE; - break; - default: - break; - } - SEC_OSAL_Free(message); - message = NULL; - } - } - - SEC_OSAL_TheadExit(NULL); - -EXIT: - FunctionOut(); - - return ret; -} - -static OMX_ERRORTYPE SEC_StateSet(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) -{ - OMX_U32 destState = nParam; - OMX_U32 i = 0; - - if ((destState == OMX_StateIdle) && (pSECComponent->currentState == OMX_StateLoaded)) { - pSECComponent->transientState = SEC_OMX_TransStateLoadedToIdle; - for(i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECComponent->pSECPort[i].portState = OMX_StateIdle; - } - SEC_OSAL_Log(SEC_LOG_TRACE, "to OMX_StateIdle"); - } else if ((destState == OMX_StateLoaded) && (pSECComponent->currentState == OMX_StateIdle)) { - pSECComponent->transientState = SEC_OMX_TransStateIdleToLoaded; - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECComponent->pSECPort[i].portState = OMX_StateLoaded; - } - SEC_OSAL_Log(SEC_LOG_TRACE, "to OMX_StateLoaded"); - } else if ((destState == OMX_StateIdle) && (pSECComponent->currentState == OMX_StateExecuting)) { - pSECComponent->transientState = SEC_OMX_TransStateExecutingToIdle; - SEC_OSAL_Log(SEC_LOG_TRACE, "to OMX_StateIdle"); - } else if ((destState == OMX_StateExecuting) && (pSECComponent->currentState == OMX_StateIdle)) { - pSECComponent->transientState = SEC_OMX_TransStateIdleToExecuting; - SEC_OSAL_Log(SEC_LOG_TRACE, "to OMX_StateExecuting"); - } else if (destState == OMX_StateInvalid) { - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECComponent->pSECPort[i].portState = OMX_StateInvalid; - } - } - - return OMX_ErrorNone; -} - -static OMX_ERRORTYPE SEC_SetPortFlush(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_U32 portIndex = nParam; - OMX_U16 i = 0, cnt = 0, index = 0; - - - if ((pSECComponent->currentState == OMX_StateExecuting) || - (pSECComponent->currentState == OMX_StatePause)) { - if ((portIndex != ALL_PORT_INDEX) && - ((OMX_S32)portIndex >= (OMX_S32)pSECComponent->portParam.nPorts)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - /********************* - * need flush event set ????? - **********************/ - cnt = (portIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1; - for (i = 0; i < cnt; i++) { - if (portIndex == ALL_PORT_INDEX) - index = i; - else - index = portIndex; - pSECComponent->pSECPort[index].bIsPortFlushed = OMX_TRUE; - } - } else { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - ret = OMX_ErrorNone; - -EXIT: - return ret; -} - -static OMX_ERRORTYPE SEC_SetPortEnable(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_U32 portIndex = nParam; - OMX_U16 i = 0, cnt = 0; - - FunctionIn(); - - if ((portIndex != ALL_PORT_INDEX) && - ((OMX_S32)portIndex >= (OMX_S32)pSECComponent->portParam.nPorts)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - if (portIndex == ALL_PORT_INDEX) { - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECPort = &pSECComponent->pSECPort[i]; - if (CHECK_PORT_ENABLED(pSECPort)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } else { - pSECPort->portState = OMX_StateIdle; - } - } - } else { - pSECPort = &pSECComponent->pSECPort[portIndex]; - if (CHECK_PORT_ENABLED(pSECPort)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } else { - pSECPort->portState = OMX_StateIdle; - } - } - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; - -} - -static OMX_ERRORTYPE SEC_SetPortDisable(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_U32 portIndex = nParam; - OMX_U16 i = 0, cnt = 0; - - FunctionIn(); - - if ((portIndex != ALL_PORT_INDEX) && - ((OMX_S32)portIndex >= (OMX_S32)pSECComponent->portParam.nPorts)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - if (portIndex == ALL_PORT_INDEX) { - for (i = 0; i < pSECComponent->portParam.nPorts; i++) { - pSECPort = &pSECComponent->pSECPort[i]; - if (!CHECK_PORT_ENABLED(pSECPort)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - pSECPort->portState = OMX_StateLoaded; - pSECPort->bIsPortDisabled = OMX_TRUE; - } - } else { - pSECPort = &pSECComponent->pSECPort[portIndex]; - pSECPort->portState = OMX_StateLoaded; - pSECPort->bIsPortDisabled = OMX_TRUE; - } - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -static OMX_ERRORTYPE SEC_SetMarkBuffer(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_U32 portIndex = nParam; - OMX_U16 i = 0, cnt = 0; - - - if (nParam >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - if ((pSECComponent->currentState == OMX_StateExecuting) || - (pSECComponent->currentState == OMX_StatePause)) { - ret = OMX_ErrorNone; - } else { - ret = OMX_ErrorIncorrectStateOperation; - } - -EXIT: - return ret; -} - -static OMX_ERRORTYPE SEC_OMX_CommandQueue( - SEC_OMX_BASECOMPONENT *pSECComponent, - OMX_COMMANDTYPE Cmd, - OMX_U32 nParam, - OMX_PTR pCmdData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_MESSAGE *command = (SEC_OMX_MESSAGE *)SEC_OSAL_Malloc(sizeof(SEC_OMX_MESSAGE)); - - if (command == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - command->messageType = (OMX_U32)Cmd; - command->messageParam = nParam; - command->pCmdData = pCmdData; - - ret = SEC_OSAL_Queue(&pSECComponent->messageQ, (void *)command); - if (ret != 0) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - ret = SEC_OSAL_SemaphorePost(pSECComponent->msgSemaphoreHandle); - -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OMX_SendCommand( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_COMMANDTYPE Cmd, - OMX_IN OMX_U32 nParam, - OMX_IN OMX_PTR pCmdData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_MESSAGE *message = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - switch (Cmd) { - case OMX_CommandStateSet : - SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandStateSet"); - SEC_StateSet(pSECComponent, nParam); - break; - case OMX_CommandFlush : - SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandFlush"); - ret = SEC_SetPortFlush(pSECComponent, nParam); - if (ret != OMX_ErrorNone) - goto EXIT; - break; - case OMX_CommandPortDisable : - SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandPortDisable"); - ret = SEC_SetPortDisable(pSECComponent, nParam); - if (ret != OMX_ErrorNone) - goto EXIT; - break; - case OMX_CommandPortEnable : - SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandPortEnable"); - ret = SEC_SetPortEnable(pSECComponent, nParam); - if (ret != OMX_ErrorNone) - goto EXIT; - break; - case OMX_CommandMarkBuffer : - SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandMarkBuffer"); - ret = SEC_SetMarkBuffer(pSECComponent, nParam); - if (ret != OMX_ErrorNone) - goto EXIT; - break; -/* - case SEC_CommandFillBuffer : - case SEC_CommandEmptyBuffer : - case SEC_CommandDeInit : -*/ - default: - break; - } - - ret = SEC_OMX_CommandQueue(pSECComponent, Cmd, nParam, pCmdData); - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_GetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR ComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (ComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - switch (nParamIndex) { - case (OMX_INDEXTYPE)OMX_COMPONENT_CAPABILITY_TYPE_INDEX: - { - /* For Android PV OpenCORE */ - OMXComponentCapabilityFlagsType *capabilityFlags = (OMXComponentCapabilityFlagsType *)ComponentParameterStructure; - SEC_OSAL_Memcpy(capabilityFlags, &pSECComponent->capabilityFlags, sizeof(OMXComponentCapabilityFlagsType)); - } - break; - case OMX_IndexParamAudioInit: - case OMX_IndexParamVideoInit: - case OMX_IndexParamImageInit: - case OMX_IndexParamOtherInit: - { - OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure; - ret = SEC_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - portParam->nPorts = 0; - portParam->nStartPortNumber = 0; - } - break; - case OMX_IndexParamPortDefinition: - { - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = portDefinition->nPortIndex; - SEC_OMX_BASEPORT *pSECPort; - - if (portIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(portDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[portIndex]; - SEC_OSAL_Memcpy(portDefinition, &pSECPort->portDefinition, portDefinition->nSize); - } - break; - case OMX_IndexParamPriorityMgmt: - { - OMX_PRIORITYMGMTTYPE *compPriority = (OMX_PRIORITYMGMTTYPE *)ComponentParameterStructure; - - ret = SEC_OMX_Check_SizeVersion(compPriority, sizeof(OMX_PRIORITYMGMTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - compPriority->nGroupID = pSECComponent->compPriority.nGroupID; - compPriority->nGroupPriority = pSECComponent->compPriority.nGroupPriority; - } - break; - - case OMX_IndexParamCompBufferSupplier: - { - OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = bufferSupplier->nPortIndex; - SEC_OMX_BASEPORT *pSECPort; - - if ((pSECComponent->currentState == OMX_StateLoaded) || - (pSECComponent->currentState == OMX_StateWaitForResources)) { - if (portIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(bufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[portIndex]; - - - if (pSECPort->portDefinition.eDir == OMX_DirInput) { - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - bufferSupplier->eBufferSupplier = OMX_BufferSupplyInput; - } else if (CHECK_PORT_TUNNELED(pSECPort)) { - bufferSupplier->eBufferSupplier = OMX_BufferSupplyOutput; - } else { - bufferSupplier->eBufferSupplier = OMX_BufferSupplyUnspecified; - } - } else { - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - bufferSupplier->eBufferSupplier = OMX_BufferSupplyOutput; - } else if (CHECK_PORT_TUNNELED(pSECPort)) { - bufferSupplier->eBufferSupplier = OMX_BufferSupplyInput; - } else { - bufferSupplier->eBufferSupplier = OMX_BufferSupplyUnspecified; - } - } - } - else - { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - } - break; - default: - { - ret = OMX_ErrorUnsupportedIndex; - goto EXIT; - } - break; - } - - ret = OMX_ErrorNone; - -EXIT: - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_SetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR ComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (ComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - switch (nIndex) { - case OMX_IndexParamAudioInit: - case OMX_IndexParamVideoInit: - case OMX_IndexParamImageInit: - case OMX_IndexParamOtherInit: - { - OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure; - ret = SEC_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((pSECComponent->currentState != OMX_StateLoaded) && - (pSECComponent->currentState != OMX_StateWaitForResources)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - ret = OMX_ErrorUndefined; - /* SEC_OSAL_Memcpy(&pSECComponent->portParam, portParam, sizeof(OMX_PORT_PARAM_TYPE)); */ - } - break; - case OMX_IndexParamPortDefinition: - { - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = portDefinition->nPortIndex; - SEC_OMX_BASEPORT *pSECPort; - - if (portIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(portDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[portIndex]; - - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - if (pSECPort->portDefinition.bEnabled == OMX_TRUE) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - } - if (portDefinition->nBufferCountActual < pSECPort->portDefinition.nBufferCountMin) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - SEC_OSAL_Memcpy(&pSECPort->portDefinition, portDefinition, portDefinition->nSize); - } - break; - case OMX_IndexParamPriorityMgmt: - { - OMX_PRIORITYMGMTTYPE *compPriority = (OMX_PRIORITYMGMTTYPE *)ComponentParameterStructure; - - if ((pSECComponent->currentState != OMX_StateLoaded) && - (pSECComponent->currentState != OMX_StateWaitForResources)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - ret = SEC_OMX_Check_SizeVersion(compPriority, sizeof(OMX_PRIORITYMGMTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECComponent->compPriority.nGroupID = compPriority->nGroupID; - pSECComponent->compPriority.nGroupPriority = compPriority->nGroupPriority; - } - break; - case OMX_IndexParamCompBufferSupplier: - { - OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = bufferSupplier->nPortIndex; - SEC_OMX_BASEPORT *pSECPort; - - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - if (pSECPort->portDefinition.bEnabled == OMX_TRUE) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - } - - if (portIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(bufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[portIndex]; - if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyUnspecified) { - ret = OMX_ErrorNone; - goto EXIT; - } - if (CHECK_PORT_TUNNELED(pSECPort) == 0) { - ret = OMX_ErrorNone; /*OMX_ErrorNone ?????*/ - goto EXIT; - } - - if (pSECPort->portDefinition.eDir == OMX_DirInput) { - if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyInput) { - /* - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - ret = OMX_ErrorNone; - } - */ - pSECPort->tunnelFlags |= SEC_TUNNEL_IS_SUPPLIER; - bufferSupplier->nPortIndex = pSECPort->tunneledPort; - ret = OMX_SetParameter(pSECPort->tunneledComponent, OMX_IndexParamCompBufferSupplier, bufferSupplier); - goto EXIT; - } else if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyOutput) { - ret = OMX_ErrorNone; - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - pSECPort->tunnelFlags &= ~SEC_TUNNEL_IS_SUPPLIER; - bufferSupplier->nPortIndex = pSECPort->tunneledPort; - ret = OMX_SetParameter(pSECPort->tunneledComponent, OMX_IndexParamCompBufferSupplier, bufferSupplier); - } - goto EXIT; - } - } else if (pSECPort->portDefinition.eDir == OMX_DirOutput) { - if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyInput) { - ret = OMX_ErrorNone; - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - pSECPort->tunnelFlags &= ~SEC_TUNNEL_IS_SUPPLIER; - ret = OMX_ErrorNone; - } - goto EXIT; - } else if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyOutput) { - /* - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - ret = OMX_ErrorNone; - } - */ - pSECPort->tunnelFlags |= SEC_TUNNEL_IS_SUPPLIER; - ret = OMX_ErrorNone; - goto EXIT; - } - } - } - break; - default: - { - ret = OMX_ErrorUnsupportedIndex; - goto EXIT; - } - break; - } - - ret = OMX_ErrorNone; - -EXIT: - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_GetConfig( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_INOUT OMX_PTR pComponentConfigStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pComponentConfigStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_SetConfig( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentConfigStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pComponentConfigStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_GetExtensionIndex( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, - OMX_OUT OMX_INDEXTYPE *pIndexType) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if ((cParameterName == NULL) || (pIndexType == NULL)) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - ret = OMX_ErrorBadParameter; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_SetCallbacks ( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_CALLBACKTYPE* pCallbacks, - OMX_IN OMX_PTR pAppData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pCallbacks == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - if (pSECComponent->currentState != OMX_StateLoaded) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - pSECComponent->pCallbacks = pCallbacks; - pSECComponent->callbackData = pAppData; - - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_UseEGLImage( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN void *eglImage) -{ - return OMX_ErrorNotImplemented; -} - -OMX_ERRORTYPE SEC_OMX_BaseComponent_Constructor( - OMX_IN OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - pSECComponent = SEC_OSAL_Malloc(sizeof(SEC_OMX_BASECOMPONENT)); - if (pSECComponent == NULL) { - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - SEC_OSAL_Memset(pSECComponent, 0, sizeof(SEC_OMX_BASECOMPONENT)); - pOMXComponent->pComponentPrivate = (OMX_PTR)pSECComponent; - - ret = SEC_OSAL_SemaphoreCreate(&pSECComponent->msgSemaphoreHandle); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - ret = SEC_OSAL_MutexCreate(&pSECComponent->compMutex); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - - pSECComponent->bExitMessageHandlerThread = OMX_FALSE; - SEC_OSAL_QueueCreate(&pSECComponent->messageQ); - ret = SEC_OSAL_ThreadCreate(&pSECComponent->hMessageHandler, SEC_OMX_MessageHandlerThread, pOMXComponent); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - - pOMXComponent->GetComponentVersion = &SEC_OMX_GetComponentVersion; - pOMXComponent->SendCommand = &SEC_OMX_SendCommand; - pOMXComponent->GetConfig = &SEC_OMX_GetConfig; - pOMXComponent->GetExtensionIndex = &SEC_OMX_GetExtensionIndex; - pOMXComponent->GetState = &SEC_OMX_GetState; - pOMXComponent->SetCallbacks = &SEC_OMX_SetCallbacks; - pOMXComponent->UseEGLImage = &SEC_OMX_UseEGLImage; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_BaseComponent_Destructor( - OMX_IN OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - OMX_U32 semaValue = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - SEC_OMX_CommandQueue(pSECComponent, SEC_OMX_CommandComponentDeInit, 0, NULL); - SEC_OSAL_SleepMillisec(0); - SEC_OSAL_Get_SemaphoreCount(pSECComponent->msgSemaphoreHandle, &semaValue); - if (semaValue == 0) - SEC_OSAL_SemaphorePost(pSECComponent->msgSemaphoreHandle); - SEC_OSAL_SemaphorePost(pSECComponent->msgSemaphoreHandle); - - SEC_OSAL_ThreadTerminate(pSECComponent->hMessageHandler); - pSECComponent->hMessageHandler = NULL; - - SEC_OSAL_MutexTerminate(pSECComponent->compMutex); - pSECComponent->compMutex = NULL; - SEC_OSAL_SemaphoreTerminate(pSECComponent->msgSemaphoreHandle); - pSECComponent->msgSemaphoreHandle = NULL; - SEC_OSAL_QueueTerminate(&pSECComponent->messageQ); - - SEC_OSAL_Free(pSECComponent); - pSECComponent = NULL; - - ret = OMX_ErrorNone; -EXIT: - FunctionOut(); - - return ret; -} - - diff --git a/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.h b/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.h deleted file mode 100644 index d413257..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Basecomponent.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_BASECOMP -#define SEC_OMX_BASECOMP - -#include "SEC_OMX_Def.h" -#include "OMX_Component.h" -#include "SEC_OSAL_Queue.h" -#include "SEC_OMX_Baseport.h" - - -typedef struct _SEC_OMX_MESSAGE -{ - OMX_U32 messageType; - OMX_U32 messageParam; - OMX_PTR pCmdData; -} SEC_OMX_MESSAGE; - -typedef struct _SEC_OMX_DATABUFFER -{ - OMX_HANDLETYPE bufferMutex; - OMX_BUFFERHEADERTYPE* bufferHeader; - OMX_BOOL dataValid; - OMX_U32 allocSize; - OMX_U32 dataLen; - OMX_U32 usedDataLen; - OMX_U32 remainDataLen; - OMX_U32 nFlags; - OMX_TICKS timeStamp; -} SEC_OMX_DATABUFFER; - -typedef struct _SEC_BUFFER_HEADER{ - void *YPhyAddr; // [IN/OUT] physical address of Y - void *CPhyAddr; // [IN/OUT] physical address of CbCr - void *YVirAddr; // [IN/OUT] virtual address of Y - void *CVirAddr; // [IN/OUT] virtual address of CbCr - int YSize; // [IN/OUT] input size of Y data - int CSize; // [IN/OUT] input size of CbCr data -} SEC_BUFFER_HEADER; - -typedef struct _SEC_OMX_DATA -{ - OMX_BYTE dataBuffer; - OMX_U32 allocSize; - OMX_U32 dataLen; - OMX_U32 usedDataLen; - OMX_U32 remainDataLen; - OMX_U32 previousDataLen; - OMX_U32 nFlags; - OMX_TICKS timeStamp; - SEC_BUFFER_HEADER specificBufferHeader; -} SEC_OMX_DATA; - -/* for Check TimeStamp after Seek */ -typedef struct _SEC_OMX_TIMESTAPM -{ - OMX_BOOL needSetStartTimeStamp; - OMX_BOOL needCheckStartTimeStamp; - OMX_TICKS startTimeStamp; - OMX_U32 nStartFlags; -} SEC_OMX_TIMESTAMP; - -typedef struct _SEC_OMX_BASECOMPONENT -{ - OMX_STRING componentName; - OMX_VERSIONTYPE componentVersion; - OMX_VERSIONTYPE specVersion; - - OMX_STATETYPE currentState; - SEC_OMX_TRANS_STATETYPE transientState; - - SEC_CODEC_TYPE codecType; - SEC_OMX_PRIORITYMGMTTYPE compPriority; - OMX_MARKTYPE propagateMarkType; - OMX_HANDLETYPE compMutex; - - OMX_HANDLETYPE hCodecHandle; - - /* Message Handler */ - OMX_BOOL bExitMessageHandlerThread; - OMX_HANDLETYPE hMessageHandler; - OMX_HANDLETYPE msgSemaphoreHandle; - SEC_QUEUE messageQ; - - /* Buffer Process */ - OMX_BOOL bExitBufferProcessThread; - OMX_HANDLETYPE hBufferProcess; - - /* Buffer */ - SEC_OMX_DATABUFFER secDataBuffer[2]; - - /* Data */ - SEC_OMX_DATA processData[2]; - - /* Port */ - OMX_PORT_PARAM_TYPE portParam; - SEC_OMX_BASEPORT *pSECPort; - - OMX_HANDLETYPE pauseEvent; - - /* Callback function */ - OMX_CALLBACKTYPE *pCallbacks; - OMX_PTR callbackData; - - /* Save Timestamp */ - OMX_TICKS timeStamp[MAX_TIMESTAMP]; - SEC_OMX_TIMESTAMP checkTimeStamp; - - /* Save Flags */ - OMX_U32 nFlags[MAX_FLAGS]; - - OMX_BOOL getAllDelayBuffer; - OMX_BOOL remainOutputData; - OMX_BOOL reInputData; - - /* Android CapabilityFlags */ - OMXComponentCapabilityFlagsType capabilityFlags; - - OMX_BOOL bUseFlagEOF; - OMX_BOOL bSaveFlagEOS; - - OMX_ERRORTYPE (*sec_mfc_componentInit)(OMX_COMPONENTTYPE *pOMXComponent); - OMX_ERRORTYPE (*sec_mfc_componentTerminate)(OMX_COMPONENTTYPE *pOMXComponent); - OMX_ERRORTYPE (*sec_mfc_bufferProcess) (OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData); - - OMX_ERRORTYPE (*sec_AllocateTunnelBuffer)(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex); - OMX_ERRORTYPE (*sec_FreeTunnelBuffer)(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex); - OMX_ERRORTYPE (*sec_BufferProcess)(OMX_HANDLETYPE hComponent); - OMX_ERRORTYPE (*sec_BufferReset)(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex); - OMX_ERRORTYPE (*sec_InputBufferReturn)(OMX_COMPONENTTYPE *pOMXComponent); - OMX_ERRORTYPE (*sec_OutputBufferReturn)(OMX_COMPONENTTYPE *pOMXComponent); - - int (*sec_checkInputFrame)(unsigned char *pInputStream, int buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame); - -} SEC_OMX_BASECOMPONENT; - - -#ifdef __cplusplus -extern "C" { -#endif - - OMX_ERRORTYPE SEC_OMX_Check_SizeVersion(OMX_PTR header, OMX_U32 size); - - -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c b/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c deleted file mode 100644 index 0e0f7ea..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c +++ /dev/null @@ -1,1005 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Baseport.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * HyeYeon Chung (hyeon.chung@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include - -#include "SEC_OMX_Macros.h" -#include "SEC_OSAL_Event.h" -#include "SEC_OSAL_Semaphore.h" -#include "SEC_OSAL_Mutex.h" - -#include "SEC_OMX_Baseport.h" -#include "SEC_OMX_Basecomponent.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_BASE_PORT" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -OMX_ERRORTYPE SEC_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BUFFERHEADERTYPE *bufferHeader = NULL; - SEC_OMX_MESSAGE *message = NULL; - OMX_U32 flushNum = 0; - OMX_S32 semValue = 0; - - FunctionIn(); - - pSECPort = &pSECComponent->pSECPort[portIndex]; - while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) > 0) { - SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[portIndex].bufferSemID, &semValue); - if (semValue == 0) - SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[portIndex].bufferSemID); - SEC_OSAL_SemaphoreWait(pSECComponent->pSECPort[portIndex].bufferSemID); - - message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ); - if (message != NULL) { - bufferHeader = (OMX_BUFFERHEADERTYPE *)message->pCmdData; - bufferHeader->nFilledLen = 0; - - if (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - if (portIndex) { - OMX_EmptyThisBuffer(pSECPort->tunneledComponent, bufferHeader); - } else { - OMX_FillThisBuffer(pSECPort->tunneledComponent, bufferHeader); - } - SEC_OSAL_Free(message); - message = NULL; - } else if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - SEC_OSAL_Log(SEC_LOG_ERROR, "Tunneled mode is not working, Line:%d", __LINE__); - ret = OMX_ErrorNotImplemented; - SEC_OSAL_Queue(&pSECPort->bufferQ, pSECPort); - goto EXIT; - } else { - if (portIndex == OUTPUT_PORT_INDEX) { - pSECComponent->pCallbacks->FillBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); - } else { - pSECComponent->pCallbacks->EmptyBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); - } - - SEC_OSAL_Free(message); - message = NULL; - } - } - } - - if (pSECComponent->secDataBuffer[portIndex].dataValid == OMX_TRUE) { - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - message = SEC_OSAL_Malloc(sizeof(SEC_OMX_MESSAGE)); - message->pCmdData = pSECComponent->secDataBuffer[portIndex].bufferHeader; - message->messageType = 0; - message->messageParam = -1; - SEC_OSAL_Queue(&pSECPort->bufferQ, message); - pSECComponent->sec_BufferReset(pOMXComponent, portIndex); - } else { - if (portIndex == INPUT_PORT_INDEX) - pSECComponent->sec_InputBufferReturn(pOMXComponent); - else if (portIndex == OUTPUT_PORT_INDEX) - pSECComponent->sec_OutputBufferReturn(pOMXComponent); - } - } - - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) < pSECPort->assignedBufferNum) { - SEC_OSAL_SemaphoreWait(pSECComponent->pSECPort[portIndex].bufferSemID); - } - if (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) != pSECPort->assignedBufferNum) - SEC_OSAL_SetElemNum(&pSECPort->bufferQ, pSECPort->assignedBufferNum); - } else { - while(1) { - int cnt; - SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[portIndex].bufferSemID, &cnt); - if (cnt == 0) - break; - SEC_OSAL_SemaphoreWait(pSECComponent->pSECPort[portIndex].bufferSemID); - } - SEC_OSAL_SetElemNum(&pSECPort->bufferQ, 0); - } - - pSECComponent->processData[portIndex].dataLen = 0; - pSECComponent->processData[portIndex].nFlags = 0; - pSECComponent->processData[portIndex].remainDataLen = 0; - pSECComponent->processData[portIndex].timeStamp = 0; - pSECComponent->processData[portIndex].usedDataLen = 0; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_BufferFlushProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_S32 portIndex = 0; - OMX_U32 i = 0, cnt = 0; - SEC_OMX_DATABUFFER *flushBuffer = NULL; - - FunctionIn(); - - if (pOMXComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - cnt = (nPortIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1; - - for (i = 0; i < cnt; i++) { - if (nPortIndex == ALL_PORT_INDEX) - portIndex = i; - else - portIndex = nPortIndex; - - SEC_OSAL_SignalSet(pSECComponent->pauseEvent); - - flushBuffer = &pSECComponent->secDataBuffer[portIndex]; - - SEC_OSAL_MutexLock(flushBuffer->bufferMutex); - ret = SEC_OMX_FlushPort(pOMXComponent, portIndex); - SEC_OSAL_MutexUnlock(flushBuffer->bufferMutex); - - pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_FALSE; - - if (ret == OMX_ErrorNone) { - SEC_OSAL_Log(SEC_LOG_TRACE,"OMX_CommandFlush EventCmdComplete"); - pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, - pSECComponent->callbackData, - OMX_EventCmdComplete, - OMX_CommandFlush, portIndex, NULL); - } - - if (portIndex == INPUT_PORT_INDEX) { - pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE; - pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; - SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); - SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); - pSECComponent->getAllDelayBuffer = OMX_FALSE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - pSECComponent->reInputData = OMX_FALSE; - } else if (portIndex == OUTPUT_PORT_INDEX) { - pSECComponent->remainOutputData = OMX_FALSE; - } - } - -EXIT: - if (ret != OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, - ret, 0, NULL); - } - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_BufferFlushProcessNoEvent(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_S32 portIndex = 0; - OMX_U32 i = 0, cnt = 0; - SEC_OMX_DATABUFFER *flushBuffer = NULL; - - FunctionIn(); - - if (pOMXComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - cnt = (nPortIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1; - - for (i = 0; i < cnt; i++) { - if (nPortIndex == ALL_PORT_INDEX) - portIndex = i; - else - portIndex = nPortIndex; - - pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_TRUE; - - SEC_OSAL_SignalSet(pSECComponent->pauseEvent); - - flushBuffer = &pSECComponent->secDataBuffer[portIndex]; - - SEC_OSAL_MutexLock(flushBuffer->bufferMutex); - ret = SEC_OMX_FlushPort(pOMXComponent, portIndex); - SEC_OSAL_MutexUnlock(flushBuffer->bufferMutex); - - pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_FALSE; - - if (portIndex == INPUT_PORT_INDEX) { - pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE; - pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; - SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); - SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); - pSECComponent->getAllDelayBuffer = OMX_FALSE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - pSECComponent->remainOutputData = OMX_FALSE; - pSECComponent->reInputData = OMX_FALSE; - } - } - -EXIT: - if (ret != OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, - ret, 0, NULL); - } - - FunctionOut(); - - return ret; -} - - -OMX_ERRORTYPE SEC_OMX_EnablePort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_U32 i = 0, cnt = 0; - - FunctionIn(); - - pSECPort = &pSECComponent->pSECPort[portIndex]; - pSECPort->portDefinition.bEnabled = OMX_TRUE; - - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - ret = pSECComponent->sec_AllocateTunnelBuffer(pSECPort, portIndex); - if (OMX_ErrorNone != ret) { - goto EXIT; - } - pSECPort->portDefinition.bPopulated = OMX_TRUE; - if (pSECComponent->currentState == OMX_StateExecuting) { - for (i=0; itunnelBufferNum; i++) { - SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[portIndex].bufferSemID); - } - } - } else if (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - SEC_OSAL_SemaphoreWait(pSECPort->loadedResource); - pSECPort->portDefinition.bPopulated = OMX_TRUE; - } - } else { - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - SEC_OSAL_SemaphoreWait(pSECPort->loadedResource); - pSECPort->portDefinition.bPopulated = OMX_TRUE; - } - } - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_PortEnableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - OMX_S32 portIndex = 0; - OMX_U32 i = 0, cnt = 0; - - FunctionIn(); - - if (pOMXComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - cnt = (nPortIndex == ALL_PORT_INDEX) ? ALL_PORT_NUM : 1; - - for (i = 0; i < cnt; i++) { - if (nPortIndex == ALL_PORT_INDEX) - portIndex = i; - else - portIndex = nPortIndex; - - ret = SEC_OMX_EnablePort(pOMXComponent, portIndex); - if (ret == OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventCmdComplete, - OMX_CommandPortEnable, portIndex, NULL); - } - } - -EXIT: - if (ret != OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, - ret, 0, NULL); - } - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_DisablePort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_U32 i = 0, elemNum = 0; - SEC_OMX_MESSAGE *message; - - FunctionIn(); - - pSECPort = &pSECComponent->pSECPort[portIndex]; - - if (!CHECK_PORT_ENABLED(pSECPort)) { - ret = OMX_ErrorNone; - goto EXIT; - } - - if (pSECComponent->currentState!=OMX_StateLoaded) { - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) >0 ) { - message = (SEC_OMX_MESSAGE*)SEC_OSAL_Dequeue(&pSECPort->bufferQ); - SEC_OSAL_Free(message); - } - ret = pSECComponent->sec_FreeTunnelBuffer(pSECPort, portIndex); - if (OMX_ErrorNone != ret) { - goto EXIT; - } - pSECPort->portDefinition.bPopulated = OMX_FALSE; - } else if (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - pSECPort->portDefinition.bPopulated = OMX_FALSE; - SEC_OSAL_SemaphoreWait(pSECPort->unloadedResource); - } else { - if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) >0 ) { - message = (SEC_OMX_MESSAGE*)SEC_OSAL_Dequeue(&pSECPort->bufferQ); - SEC_OSAL_Free(message); - } - } - pSECPort->portDefinition.bPopulated = OMX_FALSE; - SEC_OSAL_SemaphoreWait(pSECPort->unloadedResource); - } - } - pSECPort->portDefinition.bEnabled = OMX_FALSE; - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_PortDisableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - OMX_S32 portIndex = 0; - OMX_U32 i = 0, cnt = 0; - SEC_OMX_DATABUFFER *flushBuffer = NULL; - - FunctionIn(); - - if (pOMXComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - cnt = (nPortIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1; - - /* port flush*/ - for(i = 0; i < cnt; i++) { - if (nPortIndex == ALL_PORT_INDEX) - portIndex = i; - else - portIndex = nPortIndex; - - pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_TRUE; - - flushBuffer = &pSECComponent->secDataBuffer[portIndex]; - - SEC_OSAL_MutexLock(flushBuffer->bufferMutex); - ret = SEC_OMX_FlushPort(pOMXComponent, portIndex); - SEC_OSAL_MutexUnlock(flushBuffer->bufferMutex); - - pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_FALSE; - - if (portIndex == INPUT_PORT_INDEX) { - pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE; - pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; - SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); - SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); - pSECComponent->getAllDelayBuffer = OMX_FALSE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - pSECComponent->reInputData = OMX_FALSE; - } else if (portIndex == OUTPUT_PORT_INDEX) { - pSECComponent->remainOutputData = OMX_FALSE; - } - } - - for(i = 0; i < cnt; i++) { - if (nPortIndex == ALL_PORT_INDEX) - portIndex = i; - else - portIndex = nPortIndex; - - ret = SEC_OMX_DisablePort(pOMXComponent, portIndex); - pSECComponent->pSECPort[portIndex].bIsPortDisabled = OMX_FALSE; - if (ret == OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventCmdComplete, - OMX_CommandPortDisable, portIndex, NULL); - } - } - -EXIT: - if (ret != OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, - ret, 0, NULL); - } - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_EmptyThisBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BOOL findBuffer = OMX_FALSE; - SEC_OMX_MESSAGE *message; - OMX_U32 i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - if (pBuffer == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pBuffer->nInputPortIndex != INPUT_PORT_INDEX) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - ret = SEC_OMX_Check_SizeVersion(pBuffer, sizeof(OMX_BUFFERHEADERTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((pSECComponent->currentState != OMX_StateIdle) && - (pSECComponent->currentState != OMX_StateExecuting) && - (pSECComponent->currentState != OMX_StatePause)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - if ((!CHECK_PORT_ENABLED(pSECPort)) || - ((CHECK_PORT_BEING_FLUSHED(pSECPort) || CHECK_PORT_BEING_DISABLED(pSECPort)) && - (!CHECK_PORT_TUNNELED(pSECPort) || !CHECK_PORT_BUFFER_SUPPLIER(pSECPort))) || - ((pSECComponent->transientState == SEC_OMX_TransStateExecutingToIdle) && - (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)))) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { - if (pBuffer == pSECPort->bufferHeader[i]) { - findBuffer = OMX_TRUE; - break; - } - } - - if (findBuffer == OMX_FALSE) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } else { - ret = OMX_ErrorNone; - } - - message = SEC_OSAL_Malloc(sizeof(SEC_OMX_MESSAGE)); - if (message == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - message->messageType = SEC_OMX_CommandEmptyBuffer; - message->messageParam = (OMX_U32) i; - message->pCmdData = (OMX_PTR)pBuffer; - - SEC_OSAL_Queue(&pSECPort->bufferQ, (void *)message); - SEC_OSAL_SemaphorePost(pSECPort->bufferSemID); - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_FillThisBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BOOL findBuffer = OMX_FALSE; - SEC_OMX_MESSAGE *message; - OMX_U32 i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - if (pBuffer == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pBuffer->nOutputPortIndex != OUTPUT_PORT_INDEX) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - ret = SEC_OMX_Check_SizeVersion(pBuffer, sizeof(OMX_BUFFERHEADERTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((pSECComponent->currentState != OMX_StateIdle) && - (pSECComponent->currentState != OMX_StateExecuting) && - (pSECComponent->currentState != OMX_StatePause)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - if ((!CHECK_PORT_ENABLED(pSECPort)) || - ((CHECK_PORT_BEING_FLUSHED(pSECPort) || CHECK_PORT_BEING_DISABLED(pSECPort)) && - (!CHECK_PORT_TUNNELED(pSECPort) || !CHECK_PORT_BUFFER_SUPPLIER(pSECPort))) || - ((pSECComponent->transientState == SEC_OMX_TransStateExecutingToIdle) && - (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)))) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { - if (pBuffer == pSECPort->bufferHeader[i]) { - findBuffer = OMX_TRUE; - break; - } - } - - if (findBuffer == OMX_FALSE) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } else { - ret = OMX_ErrorNone; - } - - message = SEC_OSAL_Malloc(sizeof(SEC_OMX_MESSAGE)); - if (message == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - message->messageType = SEC_OMX_CommandFillBuffer; - message->messageParam = (OMX_U32) i; - message->pCmdData = (OMX_PTR)pBuffer; - - SEC_OSAL_Queue(&pSECPort->bufferQ, (void *)message); - SEC_OSAL_SemaphorePost(pSECPort->bufferSemID); - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_Port_Constructor(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - SEC_OMX_BASEPORT *pSECInputPort = NULL; - SEC_OMX_BASEPORT *pSECOutputPort = NULL; - int i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - INIT_SET_SIZE_VERSION(&pSECComponent->portParam, OMX_PORT_PARAM_TYPE); - pSECComponent->portParam.nPorts = ALL_PORT_NUM; - pSECComponent->portParam.nStartPortNumber = INPUT_PORT_INDEX; - - pSECPort = SEC_OSAL_Malloc(sizeof(SEC_OMX_BASEPORT) * ALL_PORT_NUM); - if (pSECPort == NULL) { - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - SEC_OSAL_Memset(pSECPort, 0, sizeof(SEC_OMX_BASEPORT) * ALL_PORT_NUM); - pSECComponent->pSECPort = pSECPort; - - /* Input Port */ - pSECInputPort = &pSECPort[INPUT_PORT_INDEX]; - - SEC_OSAL_QueueCreate(&pSECInputPort->bufferQ); - - pSECInputPort->bufferHeader = SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE*) * MAX_BUFFER_NUM); - if (pSECInputPort->bufferHeader == NULL) { - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - SEC_OSAL_Memset(pSECInputPort->bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE*) * MAX_BUFFER_NUM); - - pSECInputPort->bufferStateAllocate = SEC_OSAL_Malloc(sizeof(OMX_U32) * MAX_BUFFER_NUM); - if (pSECInputPort->bufferStateAllocate == NULL) { - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - SEC_OSAL_Memset(pSECInputPort->bufferStateAllocate, 0, sizeof(OMX_U32) * MAX_BUFFER_NUM); - - pSECInputPort->bufferSemID = NULL; - pSECInputPort->assignedBufferNum = 0; - pSECInputPort->portState = OMX_StateMax; - pSECInputPort->bIsPortFlushed = OMX_FALSE; - pSECInputPort->bIsPortDisabled = OMX_FALSE; - pSECInputPort->tunneledComponent = NULL; - pSECInputPort->tunneledPort = 0; - pSECInputPort->tunnelBufferNum = 0; - pSECInputPort->bufferSupplier = OMX_BufferSupplyUnspecified; - pSECInputPort->tunnelFlags = 0; - pSECInputPort->eControlRate = OMX_Video_ControlRateDisable; - ret = SEC_OSAL_SemaphoreCreate(&pSECInputPort->loadedResource); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); - pSECInputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - goto EXIT; - } - ret = SEC_OSAL_SemaphoreCreate(&pSECInputPort->unloadedResource); - if (ret != OMX_ErrorNone) { - SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); - pSECInputPort->loadedResource = NULL; - SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); - pSECInputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - goto EXIT; - } - - INIT_SET_SIZE_VERSION(&pSECInputPort->portDefinition, OMX_PARAM_PORTDEFINITIONTYPE); - pSECInputPort->portDefinition.nPortIndex = INPUT_PORT_INDEX; - pSECInputPort->portDefinition.eDir = OMX_DirInput; - pSECInputPort->portDefinition.nBufferCountActual = 0; - pSECInputPort->portDefinition.nBufferCountMin = 0; - pSECInputPort->portDefinition.nBufferSize = 0; - pSECInputPort->portDefinition.bEnabled = OMX_FALSE; - pSECInputPort->portDefinition.bPopulated = OMX_FALSE; - pSECInputPort->portDefinition.eDomain = OMX_PortDomainMax; - pSECInputPort->portDefinition.bBuffersContiguous = OMX_FALSE; - pSECInputPort->portDefinition.nBufferAlignment = 0; - pSECInputPort->markType.hMarkTargetComponent = NULL; - pSECInputPort->markType.pMarkData = NULL; - - /* Output Port */ - pSECOutputPort = &pSECPort[OUTPUT_PORT_INDEX]; - - SEC_OSAL_QueueCreate(&pSECOutputPort->bufferQ); - - pSECOutputPort->bufferHeader = SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE*) * MAX_BUFFER_NUM); - if (pSECOutputPort->bufferHeader == NULL) { - SEC_OSAL_SemaphoreTerminate(pSECInputPort->unloadedResource); - pSECInputPort->unloadedResource = NULL; - SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); - pSECInputPort->loadedResource = NULL; - SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); - pSECInputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - SEC_OSAL_Memset(pSECOutputPort->bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE*) * MAX_BUFFER_NUM); - - pSECOutputPort->bufferStateAllocate = SEC_OSAL_Malloc(sizeof(OMX_U32) * MAX_BUFFER_NUM); - if (pSECOutputPort->bufferStateAllocate == NULL) { - SEC_OSAL_Free(pSECOutputPort->bufferHeader); - pSECOutputPort->bufferHeader = NULL; - - SEC_OSAL_SemaphoreTerminate(pSECInputPort->unloadedResource); - pSECInputPort->unloadedResource = NULL; - SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); - pSECInputPort->loadedResource = NULL; - SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); - pSECInputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - SEC_OSAL_Memset(pSECOutputPort->bufferStateAllocate, 0, sizeof(OMX_U32) * MAX_BUFFER_NUM); - - pSECOutputPort->bufferSemID = NULL; - pSECOutputPort->assignedBufferNum = 0; - pSECOutputPort->portState = OMX_StateMax; - pSECOutputPort->bIsPortFlushed = OMX_FALSE; - pSECOutputPort->bIsPortDisabled = OMX_FALSE; - pSECOutputPort->tunneledComponent = NULL; - pSECOutputPort->tunneledPort = 0; - pSECOutputPort->tunnelBufferNum = 0; - pSECOutputPort->bufferSupplier = OMX_BufferSupplyUnspecified; - pSECOutputPort->tunnelFlags = 0; - pSECOutputPort->eControlRate = OMX_Video_ControlRateDisable; - ret = SEC_OSAL_SemaphoreCreate(&pSECOutputPort->loadedResource); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Free(pSECOutputPort->bufferStateAllocate); - pSECOutputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECOutputPort->bufferHeader); - pSECOutputPort->bufferHeader = NULL; - - SEC_OSAL_SemaphoreTerminate(pSECInputPort->unloadedResource); - pSECInputPort->unloadedResource = NULL; - SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); - pSECInputPort->loadedResource = NULL; - SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); - pSECInputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - goto EXIT; - } - ret = SEC_OSAL_SemaphoreCreate(&pSECOutputPort->unloadedResource); - if (ret != OMX_ErrorNone) { - SEC_OSAL_SemaphoreTerminate(pSECOutputPort->loadedResource); - pSECOutputPort->loadedResource = NULL; - SEC_OSAL_Free(pSECOutputPort->bufferStateAllocate); - pSECOutputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECOutputPort->bufferHeader); - pSECOutputPort->bufferHeader = NULL; - - SEC_OSAL_SemaphoreTerminate(pSECInputPort->unloadedResource); - pSECInputPort->unloadedResource = NULL; - SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); - pSECInputPort->loadedResource = NULL; - SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); - pSECInputPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECInputPort->bufferHeader); - pSECInputPort->bufferHeader = NULL; - SEC_OSAL_Free(pSECPort); - pSECPort = NULL; - goto EXIT; - } - - INIT_SET_SIZE_VERSION(&pSECOutputPort->portDefinition, OMX_PARAM_PORTDEFINITIONTYPE); - pSECOutputPort->portDefinition.nPortIndex = OUTPUT_PORT_INDEX; - pSECOutputPort->portDefinition.eDir = OMX_DirOutput; - pSECOutputPort->portDefinition.nBufferCountActual = 0; - pSECOutputPort->portDefinition.nBufferCountMin = 0; - pSECOutputPort->portDefinition.nBufferSize = 0; - pSECOutputPort->portDefinition.bEnabled = OMX_FALSE; - pSECOutputPort->portDefinition.bPopulated = OMX_FALSE; - pSECOutputPort->portDefinition.eDomain = OMX_PortDomainMax; - pSECOutputPort->portDefinition.bBuffersContiguous = OMX_FALSE; - pSECOutputPort->portDefinition.nBufferAlignment = 0; - pSECOutputPort->markType.hMarkTargetComponent = NULL; - pSECOutputPort->markType.pMarkData = NULL; - - pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE; - pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; - pSECComponent->checkTimeStamp.startTimeStamp = 0; - pSECComponent->checkTimeStamp.nStartFlags = 0x0; - - pOMXComponent->EmptyThisBuffer = &SEC_OMX_EmptyThisBuffer; - pOMXComponent->FillThisBuffer = &SEC_OMX_FillThisBuffer; - - ret = OMX_ErrorNone; -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_Port_Destructor(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - - FunctionIn(); - - int i = 0; - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - for (i = 0; i < ALL_PORT_NUM; i++) { - pSECPort = &pSECComponent->pSECPort[i]; - - SEC_OSAL_SemaphoreTerminate(pSECPort->loadedResource); - pSECPort->loadedResource = NULL; - SEC_OSAL_SemaphoreTerminate(pSECPort->unloadedResource); - pSECPort->unloadedResource = NULL; - SEC_OSAL_Free(pSECPort->bufferStateAllocate); - pSECPort->bufferStateAllocate = NULL; - SEC_OSAL_Free(pSECPort->bufferHeader); - pSECPort->bufferHeader = NULL; - - SEC_OSAL_QueueTerminate(&pSECPort->bufferQ); - } - SEC_OSAL_Free(pSECComponent->pSECPort); - pSECComponent->pSECPort = NULL; - ret = OMX_ErrorNone; -EXIT: - FunctionOut(); - - return ret; -} diff --git a/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h b/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h deleted file mode 100644 index f38226b..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Baseport.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * HyeYeon Chung (hyeon.chung@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_BASE_PORT -#define SEC_OMX_BASE_PORT - - -#include "OMX_Component.h" -#include "SEC_OMX_Def.h" -#include "SEC_OSAL_Queue.h" - - -#define BUFFER_STATE_ALLOCATED (1 << 0) -#define BUFFER_STATE_ASSIGNED (1 << 1) -#define HEADER_STATE_ALLOCATED (1 << 2) -#define BUFFER_STATE_FREE 0 - -#define MAX_BUFFER_NUM 20 - -#define INPUT_PORT_INDEX 0 -#define OUTPUT_PORT_INDEX 1 -#define ALL_PORT_INDEX -1 -#define ALL_PORT_NUM 2 - -typedef struct _SEC_OMX_BASEPORT -{ - OMX_BUFFERHEADERTYPE **bufferHeader; - OMX_U32 *bufferStateAllocate; - OMX_PARAM_PORTDEFINITIONTYPE portDefinition; - OMX_HANDLETYPE bufferSemID; - SEC_QUEUE bufferQ; - OMX_U32 assignedBufferNum; - OMX_STATETYPE portState; - OMX_HANDLETYPE loadedResource; - OMX_HANDLETYPE unloadedResource; - - OMX_BOOL bIsPortFlushed; - OMX_BOOL bIsPortDisabled; - OMX_MARKTYPE markType; - - /* Tunnel Info */ - OMX_HANDLETYPE tunneledComponent; - OMX_U32 tunneledPort; - OMX_U32 tunnelBufferNum; - OMX_BUFFERSUPPLIERTYPE bufferSupplier; - OMX_U32 tunnelFlags; - - OMX_VIDEO_CONTROLRATETYPE eControlRate; -} SEC_OMX_BASEPORT; - - -#ifdef __cplusplus -extern "C" { -#endif - -OMX_ERRORTYPE SEC_OMX_PortEnableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); -OMX_ERRORTYPE SEC_OMX_PortDisableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); -OMX_ERRORTYPE SEC_OMX_BufferFlushProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); -OMX_ERRORTYPE SEC_OMX_BufferFlushProcessNoEvent(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); - -#ifdef __cplusplus -}; -#endif - - -#endif diff --git a/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.c b/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.c deleted file mode 100644 index 41673ad..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.c +++ /dev/null @@ -1,383 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Resourcemanager.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include - -#include "SEC_OMX_Resourcemanager.h" -#include "SEC_OMX_Basecomponent.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_RM" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -#define MAX_RESOURCE_VIDEO 4 - -/* Max allowable video scheduler component instance */ -static SEC_OMX_RM_COMPONENT_LIST *gpVideoRMComponentList = NULL; -static SEC_OMX_RM_COMPONENT_LIST *gpVideoRMWaitingList = NULL; -static OMX_HANDLETYPE ghVideoRMComponentListMutex = NULL; - - -OMX_ERRORTYPE addElementList(SEC_OMX_RM_COMPONENT_LIST **ppList, OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_RM_COMPONENT_LIST *pTempComp = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (*ppList != NULL) { - pTempComp = *ppList; - while (pTempComp->pNext != NULL) { - pTempComp = pTempComp->pNext; - } - pTempComp->pNext = (SEC_OMX_RM_COMPONENT_LIST *)SEC_OSAL_Malloc(sizeof(SEC_OMX_RM_COMPONENT_LIST)); - if (pTempComp->pNext == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - ((SEC_OMX_RM_COMPONENT_LIST *)(pTempComp->pNext))->pNext = NULL; - ((SEC_OMX_RM_COMPONENT_LIST *)(pTempComp->pNext))->pOMXStandComp = pOMXComponent; - ((SEC_OMX_RM_COMPONENT_LIST *)(pTempComp->pNext))->groupPriority = pSECComponent->compPriority.nGroupPriority; - goto EXIT; - } else { - *ppList = (SEC_OMX_RM_COMPONENT_LIST *)SEC_OSAL_Malloc(sizeof(SEC_OMX_RM_COMPONENT_LIST)); - if (*ppList == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - pTempComp = *ppList; - pTempComp->pNext = NULL; - pTempComp->pOMXStandComp = pOMXComponent; - pTempComp->groupPriority = pSECComponent->compPriority.nGroupPriority; - } - -EXIT: - return ret; -} - -OMX_ERRORTYPE removeElementList(SEC_OMX_RM_COMPONENT_LIST **ppList, OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_RM_COMPONENT_LIST *pCurrComp = NULL; - SEC_OMX_RM_COMPONENT_LIST *pPrevComp = NULL; - OMX_BOOL bDetectComp = OMX_FALSE; - - if (*ppList == NULL) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - - pCurrComp = *ppList; - while (pCurrComp != NULL) { - if (pCurrComp->pOMXStandComp == pOMXComponent) { - if (*ppList == pCurrComp) { - *ppList = pCurrComp->pNext; - SEC_OSAL_Free(pCurrComp); - } else { - pPrevComp->pNext = pCurrComp->pNext; - SEC_OSAL_Free(pCurrComp); - } - bDetectComp = OMX_TRUE; - break; - } else { - pPrevComp = pCurrComp; - pCurrComp = pCurrComp->pNext; - } - } - - if (bDetectComp == OMX_FALSE) - ret = OMX_ErrorComponentNotFound; - else - ret = OMX_ErrorNone; - -EXIT: - return ret; -} - -int searchLowPriority(SEC_OMX_RM_COMPONENT_LIST *RMComp_list, int inComp_priority, SEC_OMX_RM_COMPONENT_LIST **outLowComp) -{ - int ret = 0; - SEC_OMX_RM_COMPONENT_LIST *pTempComp = NULL; - SEC_OMX_RM_COMPONENT_LIST *pCandidateComp = NULL; - - if (RMComp_list == NULL) - ret = -1; - - pTempComp = RMComp_list; - *outLowComp = 0; - - while (pTempComp != NULL) { - if (pTempComp->groupPriority > inComp_priority) { - if (pCandidateComp != NULL) { - if (pCandidateComp->groupPriority < pTempComp->groupPriority) - pCandidateComp = pTempComp; - } else { - pCandidateComp = pTempComp; - } - } - - pTempComp = pTempComp->pNext; - } - - *outLowComp = pCandidateComp; - if (pCandidateComp == NULL) - ret = 0; - else - ret = 1; - -EXIT: - return ret; -} - -OMX_ERRORTYPE removeComponent(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateIdle) { - (*(pSECComponent->pCallbacks->EventHandler)) - (pOMXComponent, pSECComponent->callbackData, - OMX_EventError, OMX_ErrorResourcesLost, 0, NULL); - ret = OMX_SendCommand(pOMXComponent, OMX_CommandStateSet, OMX_StateLoaded, NULL); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - } else if ((pSECComponent->currentState == OMX_StateExecuting) || (pSECComponent->currentState == OMX_StatePause)) { - /* Todo */ - } - - ret = OMX_ErrorNone; - -EXIT: - return ret; -} - - -OMX_ERRORTYPE SEC_OMX_ResourceManager_Init() -{ - FunctionIn(); - SEC_OSAL_MutexCreate(&ghVideoRMComponentListMutex); - FunctionOut(); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE SEC_OMX_ResourceManager_Deinit() -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_RM_COMPONENT_LIST *pCurrComponent; - SEC_OMX_RM_COMPONENT_LIST *pNextComponent; - - FunctionIn(); - - SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); - - if (gpVideoRMComponentList) { - pCurrComponent = gpVideoRMComponentList; - while (pCurrComponent != NULL) { - pNextComponent = pCurrComponent->pNext; - SEC_OSAL_Free(pCurrComponent); - pCurrComponent = pNextComponent; - } - gpVideoRMComponentList = NULL; - } - - if (gpVideoRMWaitingList) { - pCurrComponent = gpVideoRMWaitingList; - while (pCurrComponent != NULL) { - pNextComponent = pCurrComponent->pNext; - SEC_OSAL_Free(pCurrComponent); - pCurrComponent = pNextComponent; - } - gpVideoRMWaitingList = NULL; - } - SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); - - SEC_OSAL_MutexTerminate(ghVideoRMComponentListMutex); - ghVideoRMComponentListMutex = NULL; - - ret = OMX_ErrorNone; -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_Get_Resource(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_RM_COMPONENT_LIST *pComponentTemp = NULL; - SEC_OMX_RM_COMPONENT_LIST *pComponentCandidate = NULL; - int numElem = 0; - int lowCompDetect = 0; - - FunctionIn(); - - SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pComponentTemp = gpVideoRMComponentList; - if (pSECComponent->codecType == HW_VIDEO_CODEC) { - if (pComponentTemp != NULL) { - while (pComponentTemp) { - numElem++; - pComponentTemp = pComponentTemp->pNext; - } - } else { - numElem = 0; - } - if (numElem >= MAX_RESOURCE_VIDEO) { - lowCompDetect = searchLowPriority(gpVideoRMComponentList, pSECComponent->compPriority.nGroupPriority, &pComponentCandidate); - if (lowCompDetect <= 0) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } else { - ret = removeComponent(pComponentCandidate->pOMXStandComp); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } else { - ret = removeElementList(&gpVideoRMComponentList, pComponentCandidate->pOMXStandComp); - ret = addElementList(&gpVideoRMComponentList, pOMXComponent); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - } - } - } else { - ret = addElementList(&gpVideoRMComponentList, pOMXComponent); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - } - } - ret = OMX_ErrorNone; - -EXIT: - - SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_Release_Resource(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_RM_COMPONENT_LIST *pComponentTemp = NULL; - OMX_COMPONENTTYPE *pOMXWaitComponent = NULL; - int numElem = 0; - - FunctionIn(); - - SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pComponentTemp = gpVideoRMWaitingList; - if (pSECComponent->codecType == HW_VIDEO_CODEC) { - if (gpVideoRMComponentList == NULL) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - - ret = removeElementList(&gpVideoRMComponentList, pOMXComponent); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - while (pComponentTemp) { - numElem++; - pComponentTemp = pComponentTemp->pNext; - } - if (numElem > 0) { - pOMXWaitComponent = gpVideoRMWaitingList->pOMXStandComp; - removeElementList(&gpVideoRMWaitingList, pOMXWaitComponent); - ret = OMX_SendCommand(pOMXWaitComponent, OMX_CommandStateSet, OMX_StateIdle, NULL); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - } - } - -EXIT: - - SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_In_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->codecType == HW_VIDEO_CODEC) - ret = addElementList(&gpVideoRMWaitingList, pOMXComponent); - - SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_Out_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->codecType == HW_VIDEO_CODEC) - ret = removeElementList(&gpVideoRMWaitingList, pOMXComponent); - - SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); - - FunctionOut(); - - return ret; -} - diff --git a/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.h b/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.h deleted file mode 100644 index b958575..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Resourcemanager.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_RESOURCEMANAGER -#define SEC_OMX_RESOURCEMANAGER - - -#include "SEC_OMX_Def.h" -#include "OMX_Component.h" - - -struct SEC_OMX_RM_COMPONENT_LIST; -typedef struct _SEC_OMX_RM_COMPONENT_LIST -{ - OMX_COMPONENTTYPE *pOMXStandComp; - OMX_U32 groupPriority; - struct SEC_OMX_RM_COMPONENT_LIST *pNext; -} SEC_OMX_RM_COMPONENT_LIST; - - -#ifdef __cplusplus -extern "C" { -#endif - -OMX_ERRORTYPE SEC_OMX_ResourceManager_Init(); -OMX_ERRORTYPE SEC_OMX_ResourceManager_Deinit(); -OMX_ERRORTYPE SEC_OMX_Get_Resource(OMX_COMPONENTTYPE *pOMXComponent); -OMX_ERRORTYPE SEC_OMX_Release_Resource(OMX_COMPONENTTYPE *pOMXComponent); -OMX_ERRORTYPE SEC_OMX_In_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent); -OMX_ERRORTYPE SEC_OMX_Out_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent); - -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/Android.mk b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/Android.mk deleted file mode 100644 index 401449b..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/Android.mk +++ /dev/null @@ -1,20 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - SEC_OMX_Vdec.c - -LOCAL_MODULE := libSEC_OMX_Vdec.aries -LOCAL_ARM_MODE := arm -LOCAL_MODULE_TAGS := optional - -LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ - $(SEC_OMX_INC)/sec \ - $(SEC_OMX_TOP)/sec_osal \ - $(SEC_OMX_TOP)/sec_omx_core \ - $(SEC_OMX_COMPONENT)/common \ - $(SEC_OMX_COMPONENT)/video/dec - -LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include - -include $(BUILD_STATIC_LIBRARY) diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c deleted file mode 100644 index 48705c1..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c +++ /dev/null @@ -1,1355 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Vdec.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * HyeYeon Chung (hyeon.chung@samsung.com) - * Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include -#include "SEC_OMX_Macros.h" -#include "SEC_OSAL_Event.h" -#include "SEC_OMX_Vdec.h" -#include "SEC_OMX_Basecomponent.h" -#include "SEC_OSAL_Thread.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_VIDEO_DEC" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - -#define ONE_FRAME_OUTPUT /* only one frame output for Android */ -#define S5PC110_DECODE_OUT_DATA_BUFFER /* for Android s5pc110 0copy*/ - - -inline void SEC_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent) -{ - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - - if ((secOutputPort->portDefinition.format.video.nFrameWidth != - secInputPort->portDefinition.format.video.nFrameWidth) || - (secOutputPort->portDefinition.format.video.nFrameHeight != - secInputPort->portDefinition.format.video.nFrameHeight)) { - OMX_U32 width = 0, height = 0; - - secOutputPort->portDefinition.format.video.nFrameWidth = - secInputPort->portDefinition.format.video.nFrameWidth; - secOutputPort->portDefinition.format.video.nFrameHeight = - secInputPort->portDefinition.format.video.nFrameHeight; - width = secOutputPort->portDefinition.format.video.nStride = - secInputPort->portDefinition.format.video.nStride; - height = secOutputPort->portDefinition.format.video.nSliceHeight = - secInputPort->portDefinition.format.video.nSliceHeight; - - switch(secOutputPort->portDefinition.format.video.eColorFormat) { - case OMX_COLOR_FormatYUV420Planar: - case OMX_COLOR_FormatYUV420SemiPlanar: - if (width && height) - secOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2; - break; - default: - if (width && height) - secOutputPort->portDefinition.nBufferSize = width * height * 2; - break; - } - } - - return ; -} - -OMX_ERRORTYPE SEC_OMX_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 ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; - int i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - pSECPort = &pSECComponent->pSECPort[nPortIndex]; - if (nPortIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - if (pSECPort->portState != OMX_StateIdle) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); - if (temp_bufferHeader == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE)); - - for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { - if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { - pSECPort->bufferHeader[i] = temp_bufferHeader; - pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED); - INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE); - temp_bufferHeader->pBuffer = pBuffer; - temp_bufferHeader->nAllocLen = nSizeBytes; - temp_bufferHeader->pAppPrivate = pAppPrivate; - if ( nPortIndex == INPUT_PORT_INDEX) - temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX; - else - temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX; - - pSECPort->assignedBufferNum++; - if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) { - pSECPort->portDefinition.bPopulated = OMX_TRUE; - /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */ - SEC_OSAL_SemaphorePost(pSECPort->loadedResource); - /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */ - } - *ppBufferHdr = temp_bufferHeader; - ret = OMX_ErrorNone; - goto EXIT; - } - } - ret = OMX_ErrorInsufficientResources; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_AllocateBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN OMX_U32 nSizeBytes) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; - OMX_U8 *temp_buffer = NULL; - int i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - pSECPort = &pSECComponent->pSECPort[nPortIndex]; - if (nPortIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } -/* - if (pSECPort->portState != OMX_StateIdle ) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } -*/ - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - temp_buffer = SEC_OSAL_Malloc(sizeof(OMX_U8) * nSizeBytes); - if (temp_buffer == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - - temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); - if (temp_bufferHeader == NULL) { - SEC_OSAL_Free(temp_buffer); - temp_buffer = NULL; - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE)); - - for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { - if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { - pSECPort->bufferHeader[i] = temp_bufferHeader; - pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ALLOCATED | HEADER_STATE_ALLOCATED); - INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE); - temp_bufferHeader->pBuffer = temp_buffer; - temp_bufferHeader->nAllocLen = nSizeBytes; - temp_bufferHeader->pAppPrivate = pAppPrivate; - if ( nPortIndex == INPUT_PORT_INDEX) - temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX; - else - temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX; - pSECPort->assignedBufferNum++; - if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) { - pSECPort->portDefinition.bPopulated = OMX_TRUE; - /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */ - SEC_OSAL_SemaphorePost(pSECPort->loadedResource); - /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */ - } - *ppBuffer = temp_bufferHeader; - ret = OMX_ErrorNone; - goto EXIT; - } - } - ret = OMX_ErrorInsufficientResources; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_FreeBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; - OMX_U8 *temp_buffer = NULL; - int i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pSECPort = &pSECComponent->pSECPort[nPortIndex]; - - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - if ((pSECPort->portState != OMX_StateLoaded) && (pSECPort->portState != OMX_StateInvalid)) { - (*(pSECComponent->pCallbacks->EventHandler)) (pOMXComponent, - pSECComponent->callbackData, - (OMX_U32)OMX_EventError, - (OMX_U32)OMX_ErrorPortUnpopulated, - nPortIndex, NULL); - } - - for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { - if (((pSECPort->bufferStateAllocate[i] | BUFFER_STATE_FREE) != 0) && (pSECPort->bufferHeader[i] != NULL)) { - if (pSECPort->bufferHeader[i]->pBuffer == pBufferHdr->pBuffer) { - if (pSECPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) { - SEC_OSAL_Free(pSECPort->bufferHeader[i]->pBuffer); - pSECPort->bufferHeader[i]->pBuffer = NULL; - pBufferHdr->pBuffer = NULL; - } else if (pSECPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) { - ; /* None*/ - } - pSECPort->assignedBufferNum--; - if (pSECPort->bufferStateAllocate[i] & HEADER_STATE_ALLOCATED) { - SEC_OSAL_Free(pSECPort->bufferHeader[i]); - pSECPort->bufferHeader[i] = NULL; - pBufferHdr = NULL; - } - pSECPort->bufferStateAllocate[i] = BUFFER_STATE_FREE; - ret = OMX_ErrorNone; - goto EXIT; - } - } - } - -EXIT: - if (ret == OMX_ErrorNone) { - if ( pSECPort->assignedBufferNum == 0 ) { - SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->unloadedResource signal set"); - /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */ - SEC_OSAL_SemaphorePost(pSECPort->unloadedResource); - /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */ - pSECPort->portDefinition.bPopulated = OMX_FALSE; - } - } - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_AllocateTunnelBuffer(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; - OMX_U8 *temp_buffer = NULL; - OMX_U32 bufferSize = 0; - OMX_PARAM_PORTDEFINITIONTYPE portDefinition; - - ret = OMX_ErrorTunnelingUnsupported; -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OMX_FreeTunnelBuffer(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT* pSECPort = NULL; - OMX_BUFFERHEADERTYPE* temp_bufferHeader = NULL; - OMX_U8 *temp_buffer = NULL; - OMX_U32 bufferSize = 0; - - ret = OMX_ErrorTunnelingUnsupported; -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OMX_ComponentTunnelRequest( - OMX_IN OMX_HANDLETYPE hComp, - OMX_IN OMX_U32 nPort, - OMX_IN OMX_HANDLETYPE hTunneledComp, - OMX_IN OMX_U32 nTunneledPort, - OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - - ret = OMX_ErrorTunnelingUnsupported; -EXIT: - return ret; -} - -OMX_BOOL SEC_Check_BufferProcess_State(SEC_OMX_BASECOMPONENT *pSECComponent) -{ - if ((pSECComponent->currentState == OMX_StateExecuting) && - (pSECComponent->pSECPort[INPUT_PORT_INDEX].portState == OMX_StateIdle) && - (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portState == OMX_StateIdle) && - (pSECComponent->transientState != SEC_OMX_TransStateExecutingToIdle) && - (pSECComponent->transientState != SEC_OMX_TransStateIdleToExecuting)) { - return OMX_TRUE; - } else { - return OMX_FALSE; - } -} - -static OMX_ERRORTYPE SEC_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *secOMXInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - SEC_OMX_BASEPORT *secOMXOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; - OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; - - FunctionIn(); - - if (bufferHeader != NULL) { - if (secOMXInputPort->markType.hMarkTargetComponent != NULL ) { - bufferHeader->hMarkTargetComponent = secOMXInputPort->markType.hMarkTargetComponent; - bufferHeader->pMarkData = secOMXInputPort->markType.pMarkData; - secOMXInputPort->markType.hMarkTargetComponent = NULL; - secOMXInputPort->markType.pMarkData = NULL; - } - - if (bufferHeader->hMarkTargetComponent != NULL) { - if (bufferHeader->hMarkTargetComponent == pOMXComponent) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventMark, - 0, 0, bufferHeader->pMarkData); - } else { - pSECComponent->propagateMarkType.hMarkTargetComponent = bufferHeader->hMarkTargetComponent; - pSECComponent->propagateMarkType.pMarkData = bufferHeader->pMarkData; - } - } - - if (CHECK_PORT_TUNNELED(secOMXInputPort)) { - OMX_FillThisBuffer(secOMXInputPort->tunneledComponent, bufferHeader); - } else { - bufferHeader->nFilledLen = 0; - pSECComponent->pCallbacks->EmptyBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); - } - } - - if ((pSECComponent->currentState == OMX_StatePause) && - ((!CHECK_PORT_BEING_FLUSHED(secOMXInputPort) && !CHECK_PORT_BEING_FLUSHED(secOMXOutputPort)))) { - SEC_OSAL_SignalReset(pSECComponent->pauseEvent); - SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME); - } - - dataBuffer->dataValid = OMX_FALSE; - dataBuffer->dataLen = 0; - dataBuffer->remainDataLen = 0; - dataBuffer->usedDataLen = 0; - dataBuffer->bufferHeader = NULL; - dataBuffer->nFlags = 0; - dataBuffer->timeStamp = 0; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_InputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - SEC_OMX_DATABUFFER *dataBuffer = NULL; - SEC_OMX_MESSAGE* message = NULL; - SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; - - FunctionIn(); - - pSECPort= &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - dataBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; - - if (pSECComponent->currentState != OMX_StateExecuting) { - ret = OMX_ErrorUndefined; - goto EXIT; - } else { - SEC_OSAL_SemaphoreWait(pSECPort->bufferSemID); - SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex); - if (dataBuffer->dataValid != OMX_TRUE) { - message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ); - if (message == NULL) { - ret = OMX_ErrorUndefined; - SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); - goto EXIT; - } - - dataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData); - dataBuffer->allocSize = dataBuffer->bufferHeader->nAllocLen; - dataBuffer->dataLen = dataBuffer->bufferHeader->nFilledLen; - dataBuffer->remainDataLen = dataBuffer->dataLen; - dataBuffer->usedDataLen = 0; - dataBuffer->dataValid = OMX_TRUE; - dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; - dataBuffer->timeStamp = dataBuffer->bufferHeader->nTimeStamp; - - SEC_OSAL_Free(message); - - if (dataBuffer->allocSize <= dataBuffer->dataLen) - SEC_OSAL_Log(SEC_LOG_WARNING, "Input Buffer Full, Check input buffer size! allocSize:%d, dataLen:%d", dataBuffer->allocSize, dataBuffer->dataLen); - } - SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); - ret = OMX_ErrorNone; - } -EXIT: - FunctionOut(); - - return ret; -} - -static OMX_ERRORTYPE SEC_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *secOMXInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - SEC_OMX_BASEPORT *secOMXOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; - OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; - - FunctionIn(); - - if (bufferHeader != NULL) { - bufferHeader->nFilledLen = dataBuffer->remainDataLen; - bufferHeader->nOffset = 0; - bufferHeader->nFlags = dataBuffer->nFlags; - bufferHeader->nTimeStamp = dataBuffer->timeStamp; - - if (pSECComponent->propagateMarkType.hMarkTargetComponent != NULL) { - bufferHeader->hMarkTargetComponent = pSECComponent->propagateMarkType.hMarkTargetComponent; - bufferHeader->pMarkData = pSECComponent->propagateMarkType.pMarkData; - pSECComponent->propagateMarkType.hMarkTargetComponent = NULL; - pSECComponent->propagateMarkType.pMarkData = NULL; - } - - if (bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventBufferFlag, - OUTPUT_PORT_INDEX, - bufferHeader->nFlags, NULL); - } - - if (CHECK_PORT_TUNNELED(secOMXOutputPort)) { - OMX_EmptyThisBuffer(secOMXOutputPort->tunneledComponent, bufferHeader); - } else { - pSECComponent->pCallbacks->FillBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); - } - } - - if ((pSECComponent->currentState == OMX_StatePause) && - ((!CHECK_PORT_BEING_FLUSHED(secOMXInputPort) && !CHECK_PORT_BEING_FLUSHED(secOMXOutputPort)))) { - SEC_OSAL_SignalReset(pSECComponent->pauseEvent); - SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME); - } - - /* reset dataBuffer */ - dataBuffer->dataValid = OMX_FALSE; - dataBuffer->dataLen = 0; - dataBuffer->remainDataLen = 0; - dataBuffer->usedDataLen = 0; - dataBuffer->bufferHeader = NULL; - dataBuffer->nFlags = 0; - dataBuffer->timeStamp = 0; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OutputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - SEC_OMX_DATABUFFER *dataBuffer = NULL; - SEC_OMX_MESSAGE *message = NULL; - SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; - - FunctionIn(); - - pSECPort= &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - dataBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; - - if (pSECComponent->currentState != OMX_StateExecuting) { - ret = OMX_ErrorUndefined; - goto EXIT; - } else { - SEC_OSAL_SemaphoreWait(pSECPort->bufferSemID); - SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); - if (dataBuffer->dataValid != OMX_TRUE) { - message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ); - if (message == NULL) { - ret = OMX_ErrorUndefined; - SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); - goto EXIT; - } - - dataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData); - dataBuffer->allocSize = dataBuffer->bufferHeader->nAllocLen; - dataBuffer->dataLen = 0; //dataBuffer->bufferHeader->nFilledLen; - dataBuffer->remainDataLen = dataBuffer->dataLen; - dataBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset; - dataBuffer->dataValid =OMX_TRUE; - /* dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; */ - /* dataBuffer->nTimeStamp = dataBuffer->bufferHeader->nTimeStamp; */ -#ifdef S5PC110_DECODE_OUT_DATA_BUFFER - pSECComponent->processData[OUTPUT_PORT_INDEX].dataBuffer = dataBuffer->bufferHeader->pBuffer; - pSECComponent->processData[OUTPUT_PORT_INDEX].allocSize = dataBuffer->bufferHeader->nAllocLen; -#endif - SEC_OSAL_Free(message); - } - SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); - ret = OMX_ErrorNone; - } -EXIT: - FunctionOut(); - - return ret; - -} - -static OMX_ERRORTYPE SEC_BufferReset(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 portIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - /* SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[portIndex]; */ - SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[portIndex]; - /* OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; */ - - dataBuffer->dataValid = OMX_FALSE; - dataBuffer->dataLen = 0; - dataBuffer->remainDataLen = 0; - dataBuffer->usedDataLen = 0; - dataBuffer->bufferHeader = NULL; - dataBuffer->nFlags = 0; - dataBuffer->timeStamp = 0; - - return ret; -} - -static OMX_ERRORTYPE SEC_DataReset(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 portIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - /* SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[portIndex]; */ - /* SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[portIndex]; */ - /* OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; */ - SEC_OMX_DATA *processData = &pSECComponent->processData[portIndex]; - - processData->dataLen = 0; - processData->remainDataLen = 0; - processData->usedDataLen = 0; - processData->nFlags = 0; - processData->timeStamp = 0; - - return ret; -} - -OMX_BOOL SEC_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_BOOL ret = OMX_FALSE; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; - SEC_OMX_DATA *inputData = &pSECComponent->processData[INPUT_PORT_INDEX]; - OMX_U32 copySize = 0; - OMX_BYTE checkInputStream = NULL; - OMX_U32 checkInputStreamLen = 0; - OMX_U32 checkedSize = 0; - OMX_BOOL flagEOF = OMX_FALSE; - OMX_BOOL previousFrameEOF = OMX_FALSE; - - FunctionIn(); - - if (inputUseBuffer->dataValid == OMX_TRUE) { - checkInputStream = inputUseBuffer->bufferHeader->pBuffer + inputUseBuffer->usedDataLen; - checkInputStreamLen = inputUseBuffer->remainDataLen; - - if (inputData->dataLen == 0) { - previousFrameEOF = OMX_TRUE; - } else { - previousFrameEOF = OMX_FALSE; - } - if ((pSECComponent->bUseFlagEOF == OMX_TRUE) && - !(inputUseBuffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG)) { - flagEOF = OMX_TRUE; - checkedSize = checkInputStreamLen; - } else { - pSECComponent->bUseFlagEOF = OMX_FALSE; - checkedSize = pSECComponent->sec_checkInputFrame(checkInputStream, checkInputStreamLen, inputUseBuffer->nFlags, previousFrameEOF, &flagEOF); - } - - if (flagEOF == OMX_TRUE) { - copySize = checkedSize; - SEC_OSAL_Log(SEC_LOG_TRACE, "sec_checkInputFrame : OMX_TRUE"); - } else { - copySize = checkInputStreamLen; - SEC_OSAL_Log(SEC_LOG_TRACE, "sec_checkInputFrame : OMX_FALSE"); - } - - if (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) - pSECComponent->bSaveFlagEOS = OMX_TRUE; - - if (((inputData->allocSize) - (inputData->dataLen)) >= copySize) { - if (copySize > 0) - SEC_OSAL_Memcpy(inputData->dataBuffer + inputData->dataLen, checkInputStream, copySize); - - inputUseBuffer->dataLen -= copySize; - inputUseBuffer->remainDataLen -= copySize; - inputUseBuffer->usedDataLen += copySize; - - inputData->dataLen += copySize; - inputData->remainDataLen += copySize; - - if (previousFrameEOF == OMX_TRUE) { - inputData->timeStamp = inputUseBuffer->timeStamp; - inputData->nFlags = inputUseBuffer->nFlags; - } - - if (pSECComponent->bUseFlagEOF == OMX_TRUE) { - if (pSECComponent->bSaveFlagEOS == OMX_TRUE) { - inputData->nFlags |= OMX_BUFFERFLAG_EOS; - flagEOF = OMX_TRUE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - } else { - inputData->nFlags = (inputData->nFlags & (~OMX_BUFFERFLAG_EOS)); - } - } else { - if ((checkedSize == checkInputStreamLen) && (pSECComponent->bSaveFlagEOS == OMX_TRUE)) { - if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) && - ((inputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG) || - (inputData->dataLen == 0))) { - inputData->nFlags |= OMX_BUFFERFLAG_EOS; - flagEOF = OMX_TRUE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - } else if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) && - (!(inputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG)) && - (inputData->dataLen != 0)) { - inputData->nFlags = (inputData->nFlags & (~OMX_BUFFERFLAG_EOS)); - flagEOF = OMX_TRUE; - pSECComponent->bSaveFlagEOS = OMX_TRUE; - } - } else { - inputData->nFlags = (inputUseBuffer->nFlags & (~OMX_BUFFERFLAG_EOS)); - } - } - - if(((inputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) && - (inputData->dataLen <= 0) && (flagEOF == OMX_TRUE)) { - inputData->dataLen = inputData->previousDataLen; - inputData->remainDataLen = inputData->previousDataLen; - } - } else { - /*????????????????????????????????? Error ?????????????????????????????????*/ - SEC_DataReset(pOMXComponent, INPUT_PORT_INDEX); - flagEOF = OMX_FALSE; - } - - if (inputUseBuffer->remainDataLen == 0) - SEC_InputBufferReturn(pOMXComponent); - else - inputUseBuffer->dataValid = OMX_TRUE; - } - - if (flagEOF == OMX_TRUE) { - if (pSECComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) { - pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_TRUE; - pSECComponent->checkTimeStamp.startTimeStamp = inputData->timeStamp; - pSECComponent->checkTimeStamp.nStartFlags = inputData->nFlags; - pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE; - } - - ret = OMX_TRUE; - } else { - ret = OMX_FALSE; - } - - FunctionOut(); - - return ret; -} - -OMX_BOOL SEC_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_BOOL ret = OMX_FALSE; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; - SEC_OMX_DATA *outputData = &pSECComponent->processData[OUTPUT_PORT_INDEX]; - OMX_U32 copySize = 0; - - FunctionIn(); - - if (outputUseBuffer->dataValid == OMX_TRUE) { - if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE) { - if ((pSECComponent->checkTimeStamp.startTimeStamp == outputData->timeStamp) && - (pSECComponent->checkTimeStamp.nStartFlags == outputData->nFlags)){ - pSECComponent->checkTimeStamp.startTimeStamp = -19761123; - pSECComponent->checkTimeStamp.nStartFlags = 0x0; - pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE; - pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; - } else { - SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX); - - ret = OMX_TRUE; - goto EXIT; - } - } else if (pSECComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) { - SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX); - - ret = OMX_TRUE; - goto EXIT; - } - - if (outputData->remainDataLen <= (outputUseBuffer->allocSize - outputUseBuffer->dataLen)) { - copySize = outputData->remainDataLen; -#ifndef S5PC110_DECODE_OUT_DATA_BUFFER - if (copySize > 0) - SEC_OSAL_Memcpy((outputUseBuffer->bufferHeader->pBuffer + outputUseBuffer->dataLen), - (outputData->dataBuffer + outputData->usedDataLen), - copySize); -#endif - - outputUseBuffer->dataLen += copySize; - outputUseBuffer->remainDataLen += copySize; - outputUseBuffer->nFlags = outputData->nFlags; - outputUseBuffer->timeStamp = outputData->timeStamp; - - ret = OMX_TRUE; - - /* reset outputData */ - SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX); - -#ifdef ONE_FRAME_OUTPUT /* only one frame output for Android */ - if ((outputUseBuffer->remainDataLen > 0) || - (outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS)) - SEC_OutputBufferReturn(pOMXComponent); -#else - if ((outputUseBuffer->remainDataLen > 0) || - ((outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) { - SEC_OutputBufferReturn(pOMXComponent); - } else { - outputUseBuffer->dataValid = OMX_TRUE; - } -#endif - } else { - SEC_OSAL_Log(SEC_LOG_ERROR, "output buffer is smaller than decoded data size Out Length"); - - copySize = outputUseBuffer->allocSize - outputUseBuffer->dataLen; - -#ifndef S5PC110_DECODE_OUT_DATA_BUFFER - SEC_OSAL_Memcpy((outputUseBuffer->bufferHeader->pBuffer + outputUseBuffer->dataLen), - (outputData->dataBuffer + outputData->usedDataLen), - copySize); -#endif - outputUseBuffer->dataLen += copySize; - outputUseBuffer->remainDataLen += copySize; - outputUseBuffer->nFlags = 0; - outputUseBuffer->timeStamp = outputData->timeStamp; - - ret = OMX_FALSE; - - outputData->remainDataLen -= copySize; - outputData->usedDataLen += copySize; - - SEC_OutputBufferReturn(pOMXComponent); - } - } else { - ret = OMX_FALSE; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; - SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; - SEC_OMX_DATA *inputData = &pSECComponent->processData[INPUT_PORT_INDEX]; - SEC_OMX_DATA *outputData = &pSECComponent->processData[OUTPUT_PORT_INDEX]; - OMX_U32 copySize = 0; - - pSECComponent->remainOutputData = OMX_FALSE; - pSECComponent->reInputData = OMX_FALSE; - - FunctionIn(); - - while (!pSECComponent->bExitBufferProcessThread) { - SEC_OSAL_SleepMillisec(0); - - if (((pSECComponent->currentState == OMX_StatePause) || - (pSECComponent->currentState == OMX_StateIdle) || - (pSECComponent->transientState == SEC_OMX_TransStateLoadedToIdle) || - (pSECComponent->transientState == SEC_OMX_TransStateExecutingToIdle)) && - (pSECComponent->transientState != SEC_OMX_TransStateIdleToLoaded)&& - ((!CHECK_PORT_BEING_FLUSHED(secInputPort) && !CHECK_PORT_BEING_FLUSHED(secOutputPort)))) { - SEC_OSAL_SignalReset(pSECComponent->pauseEvent); - SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME); - } - - while (SEC_Check_BufferProcess_State(pSECComponent) && !pSECComponent->bExitBufferProcessThread) { - SEC_OSAL_SleepMillisec(0); - - SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); - if ((outputUseBuffer->dataValid != OMX_TRUE) && - (!CHECK_PORT_BEING_FLUSHED(secOutputPort))) { - SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); - ret = SEC_OutputBufferGetQueue(pSECComponent); - if ((ret == OMX_ErrorUndefined) || - (secInputPort->portState != OMX_StateIdle) || - (secOutputPort->portState != OMX_StateIdle)) { - break; - } - } else { - SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); - } - - if (pSECComponent->remainOutputData == OMX_FALSE) { - if (pSECComponent->reInputData == OMX_FALSE) { - SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex); - if ((SEC_Preprocessor_InputData(pOMXComponent) == OMX_FALSE) && - (!CHECK_PORT_BEING_FLUSHED(secInputPort))) { - SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); - ret = SEC_InputBufferGetQueue(pSECComponent); - break; - } - - SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); - } - - SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex); - SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); - ret = pSECComponent->sec_mfc_bufferProcess(pOMXComponent, inputData, outputData); - SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); - SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); - - if (ret == OMX_ErrorInputDataDecodeYet) - pSECComponent->reInputData = OMX_TRUE; - else - pSECComponent->reInputData = OMX_FALSE; - } - - SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); - - if (SEC_Postprocess_OutputData(pOMXComponent) == OMX_FALSE) - pSECComponent->remainOutputData = OMX_TRUE; - else - pSECComponent->remainOutputData = OMX_FALSE; - - SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); - } - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_VideoDecodeGetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR ComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - if (ComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - switch (nParamIndex) { - case OMX_IndexParamVideoInit: - { - OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure; - ret = SEC_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - portParam->nPorts = pSECComponent->portParam.nPorts; - portParam->nStartPortNumber = pSECComponent->portParam.nStartPortNumber; - ret = OMX_ErrorNone; - } - break; - case OMX_IndexParamVideoPortFormat: - { - OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = portFormat->nPortIndex; - OMX_U32 index = portFormat->nIndex; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; - OMX_U32 supportFormatNum = 0; /* supportFormatNum = N-1 */ - - ret = SEC_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((portIndex >= pSECComponent->portParam.nPorts)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - - if (portIndex == INPUT_PORT_INDEX) { - supportFormatNum = INPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1; - if (index > supportFormatNum) { - ret = OMX_ErrorNoMore; - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - portDefinition = &pSECPort->portDefinition; - - portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat; - portFormat->eColorFormat = portDefinition->format.video.eColorFormat; - portFormat->xFramerate = portDefinition->format.video.xFramerate; - } else if (portIndex == OUTPUT_PORT_INDEX) { - supportFormatNum = OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1; - if (index > supportFormatNum) { - ret = OMX_ErrorNoMore; - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - portDefinition = &pSECPort->portDefinition; - - switch (index) { - case supportFormat_1: - portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; - portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar; - portFormat->xFramerate = portDefinition->format.video.xFramerate; - break; - case supportFormat_2: - portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; - portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; - portFormat->xFramerate = portDefinition->format.video.xFramerate; - break; - case supportFormat_3: - portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; - portFormat->eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress; - portFormat->xFramerate = portDefinition->format.video.xFramerate; - break; - } - } - ret = OMX_ErrorNone; - } - break; - case OMX_IndexParamVideoBitrate: - { - OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure; - OMX_U32 portIndex = videoRateControl->nPortIndex; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; - - if ((portIndex != INPUT_PORT_INDEX)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } else { - pSECPort = &pSECComponent->pSECPort[portIndex]; - portDefinition = &pSECPort->portDefinition; - - videoRateControl->eControlRate = pSECPort->eControlRate; - videoRateControl->nTargetBitrate = portDefinition->format.video.nBitrate; - } - ret = OMX_ErrorNone; - } - break; - default: - { - ret = SEC_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure); - } - break; - } - -EXIT: - FunctionOut(); - - return ret; -} -OMX_ERRORTYPE SEC_OMX_VideoDecodeSetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR ComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - if (ComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - switch (nIndex) { - case OMX_IndexParamVideoPortFormat: - { - OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = portFormat->nPortIndex; - OMX_U32 index = portFormat->nIndex; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; - OMX_U32 supportFormatNum = 0; - - ret = SEC_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((portIndex >= pSECComponent->portParam.nPorts)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } else { - pSECPort = &pSECComponent->pSECPort[portIndex]; - portDefinition = &pSECPort->portDefinition; - - portDefinition->format.video.eColorFormat = portFormat->eColorFormat; - portDefinition->format.video.eCompressionFormat = portFormat->eCompressionFormat; - portDefinition->format.video.xFramerate = portFormat->xFramerate; - } - } - break; - case OMX_IndexParamVideoBitrate: - { - OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure; - OMX_U32 portIndex = videoRateControl->nPortIndex; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; - - if ((portIndex != INPUT_PORT_INDEX)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } else { - pSECPort = &pSECComponent->pSECPort[portIndex]; - portDefinition = &pSECPort->portDefinition; - - pSECPort->eControlRate = videoRateControl->eControlRate; - portDefinition->format.video.nBitrate = videoRateControl->nTargetBitrate; - } - ret = OMX_ErrorNone; - } - break; - default: - { - ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure); - } - break; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_VideoDecodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); - goto EXIT; - } - - ret = SEC_OMX_BaseComponent_Constructor(pOMXComponent); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); - goto EXIT; - } - - ret = SEC_OMX_Port_Constructor(pOMXComponent); - if (ret != OMX_ErrorNone) { - SEC_OMX_BaseComponent_Destructor(pOMXComponent); - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - - /* Input port */ - pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - pSECPort->portDefinition.nBufferCountActual = MAX_VIDEO_INPUTBUFFER_NUM; - pSECPort->portDefinition.nBufferCountMin = MAX_VIDEO_INPUTBUFFER_NUM; - pSECPort->portDefinition.nBufferSize = 0; - pSECPort->portDefinition.eDomain = OMX_PortDomainVideo; - - pSECPort->portDefinition.format.video.cMIMEType = SEC_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); - pSECPort->portDefinition.format.video.pNativeRender = 0; - pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; - - pSECPort->portDefinition.format.video.nFrameWidth = 0; - pSECPort->portDefinition.format.video.nFrameHeight= 0; - pSECPort->portDefinition.format.video.nStride = 0; - pSECPort->portDefinition.format.video.nSliceHeight = 0; - pSECPort->portDefinition.format.video.nBitrate = 64000; - pSECPort->portDefinition.format.video.xFramerate = (15 << 16); - pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; - pSECPort->portDefinition.format.video.pNativeWindow = NULL; - - /* Output port */ - pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - pSECPort->portDefinition.nBufferCountActual = MAX_VIDEO_OUTPUTBUFFER_NUM; - pSECPort->portDefinition.nBufferCountMin = MAX_VIDEO_OUTPUTBUFFER_NUM; - pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; - pSECPort->portDefinition.eDomain = OMX_PortDomainVideo; - - pSECPort->portDefinition.format.video.cMIMEType = SEC_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); - pSECPort->portDefinition.format.video.pNativeRender = 0; - pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; - - pSECPort->portDefinition.format.video.nFrameWidth = 0; - pSECPort->portDefinition.format.video.nFrameHeight= 0; - pSECPort->portDefinition.format.video.nStride = 0; - pSECPort->portDefinition.format.video.nSliceHeight = 0; - pSECPort->portDefinition.format.video.nBitrate = 64000; - pSECPort->portDefinition.format.video.xFramerate = (15 << 16); - pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; - pSECPort->portDefinition.format.video.pNativeWindow = NULL; - - pOMXComponent->UseBuffer = &SEC_OMX_UseBuffer; - pOMXComponent->AllocateBuffer = &SEC_OMX_AllocateBuffer; - pOMXComponent->FreeBuffer = &SEC_OMX_FreeBuffer; - pOMXComponent->ComponentTunnelRequest = &SEC_OMX_ComponentTunnelRequest; - - pSECComponent->sec_AllocateTunnelBuffer = &SEC_OMX_AllocateTunnelBuffer; - pSECComponent->sec_FreeTunnelBuffer = &SEC_OMX_FreeTunnelBuffer; - pSECComponent->sec_BufferProcess = &SEC_OMX_BufferProcess; - pSECComponent->sec_BufferReset = &SEC_BufferReset; - pSECComponent->sec_InputBufferReturn = &SEC_InputBufferReturn; - pSECComponent->sec_OutputBufferReturn = &SEC_OutputBufferReturn; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_VideoDecodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - int i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - for(i = 0; i < ALL_PORT_NUM; i++) { - pSECPort = &pSECComponent->pSECPort[i]; - SEC_OSAL_Free(pSECPort->portDefinition.format.video.cMIMEType); - pSECPort->portDefinition.format.video.cMIMEType = NULL; - } - - ret = SEC_OMX_Port_Destructor(pOMXComponent); - - ret = SEC_OMX_BaseComponent_Destructor(hComponent); - -EXIT: - FunctionOut(); - - return ret; -} diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h deleted file mode 100644 index b7f71da..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Vdec.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * HyeYeon Chung (hyeon.chung@samsung.com) - * Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_VIDEO_DECODE -#define SEC_OMX_VIDEO_DECODE - -#include "OMX_Component.h" -#include "SEC_OMX_Def.h" -#include "SEC_OSAL_Queue.h" -#include "SEC_OMX_Baseport.h" - -#define MAX_VIDEO_INPUTBUFFER_NUM 5 -#define MAX_VIDEO_OUTPUTBUFFER_NUM 2 - -#define DEFAULT_FRAME_WIDTH 176 -#define DEFAULT_FRAME_HEIGHT 144 - -#define DEFAULT_VIDEO_INPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT) * 2 -#define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2 - -#define DEFAULT_MFC_INPUT_BUFFER_SIZE 1024 * 1024 /*DEFAULT_VIDEO_INPUT_BUFFER_SIZE*/ - -#define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 1 -#define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX 3 - - -typedef struct -{ - void *pAddrY; - void *pAddrC; -} MFC_DEC_ADDR_INFO; - - -#ifdef __cplusplus -extern "C" { -#endif - -OMX_ERRORTYPE SEC_OMX_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 SEC_OMX_AllocateBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN OMX_U32 nSizeBytes); -OMX_ERRORTYPE SEC_OMX_FreeBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr); -OMX_ERRORTYPE SEC_OMX_AllocateTunnelBuffer( - SEC_OMX_BASEPORT *pOMXBasePort, - OMX_U32 nPortIndex); -OMX_ERRORTYPE SEC_OMX_FreeTunnelBuffer( - SEC_OMX_BASEPORT *pOMXBasePort, - OMX_U32 nPortIndex); -OMX_ERRORTYPE SEC_OMX_ComponentTunnelRequest( - OMX_IN OMX_HANDLETYPE hComp, - OMX_IN OMX_U32 nPort, - OMX_IN OMX_HANDLETYPE hTunneledComp, - OMX_IN OMX_U32 nTunneledPort, - OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup); -OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent); -OMX_ERRORTYPE SEC_OMX_VideoDecodeGetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR ComponentParameterStructure); -OMX_ERRORTYPE SEC_OMX_VideoDecodeSetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR ComponentParameterStructure); -OMX_ERRORTYPE SEC_OMX_VideoDecodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk deleted file mode 100644 index 2dadf50..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := \ - SEC_OMX_H264dec.c \ - library_register.c - -LOCAL_PRELINK_MODULE := false -LOCAL_MODULE := libOMX.SEC.AVC.Decoder.aries - -LOCAL_CFLAGS := - -LOCAL_ARM_MODE := arm - -LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec.aries libsecosal.aries libsecbasecomponent.aries libsecmfcdecapi.aries -LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils - -LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ - $(SEC_OMX_INC)/sec \ - $(SEC_OMX_TOP)/sec_osal \ - $(SEC_OMX_TOP)/sec_omx_core \ - $(SEC_OMX_COMPONENT)/common \ - $(SEC_OMX_COMPONENT)/video/dec \ - -LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include - -include $(BUILD_SHARED_LIBRARY) diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c deleted file mode 100644 index 5e73b7f..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c +++ /dev/null @@ -1,1191 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_H264dec.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include - -#include "SEC_OMX_Macros.h" -#include "SEC_OMX_Basecomponent.h" -#include "SEC_OMX_Baseport.h" -#include "SEC_OMX_Vdec.h" -#include "library_register.h" -#include "SEC_OMX_H264dec.h" -#include "SsbSipMfcApi.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_H264_DEC" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - -//#define ADD_SPS_PPS_I_FRAME -//#define FULL_FRAME_SEARCH - -/* H.264 Decoder Supported Levels & profiles */ -SEC_OMX_VIDEO_PROFILELEVEL supportedAVCProfileLevels[] ={ - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1b}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel11}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel12}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel2}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel21}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel22}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel3}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel31}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel32}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4}, - - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1b}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel11}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel12}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel13}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel2}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel21}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel22}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel3}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel31}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel32}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel4}, - - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1b}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel11}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel12}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel13}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel2}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel21}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel22}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel3}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel31}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel32}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4}}; - - -static int Check_H264_Frame(OMX_U8 *pInputStream, int buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame) -{ - OMX_U32 preFourByte = (OMX_U32)-1; - int accessUnitSize = 0; - int frameTypeBoundary = 0; - int nextNaluSize = 0; - int naluStart = 0; - - if (bPreviousFrameEOF == OMX_TRUE) - naluStart = 0; - else - naluStart = 1; - - while (1) { - int inputOneByte = 0; - - if (accessUnitSize == buffSize) - goto EXIT; - - inputOneByte = *(pInputStream++); - accessUnitSize += 1; - - if (preFourByte == 0x00000001 || (preFourByte << 8) == 0x00000100) { - int naluType = inputOneByte & 0x1F; - - SEC_OSAL_Log(SEC_LOG_TRACE, "NaluType : %d", naluType); - if (naluStart == 0) { -#ifdef ADD_SPS_PPS_I_FRAME - if (naluType == 1 || naluType == 5) -#else - if (naluType == 1 || naluType == 5 || naluType == 7 || naluType == 8) -#endif - naluStart = 1; - } else { -#ifdef OLD_DETECT - frameTypeBoundary = (8 - naluType) & (naluType - 10); //AUD(9) -#else - if (naluType == 9) - frameTypeBoundary = -2; -#endif - if (naluType == 1 || naluType == 5) { - if (accessUnitSize == buffSize) { - accessUnitSize--; - goto EXIT; - } - inputOneByte = *pInputStream++; - accessUnitSize += 1; - - if (inputOneByte >= 0x80) - frameTypeBoundary = -1; - } - if (frameTypeBoundary < 0) { - break; - } - } - - } - preFourByte = (preFourByte << 8) + inputOneByte; - } - - *pbEndOfFrame = OMX_TRUE; - nextNaluSize = -5; - if (frameTypeBoundary == -1) - nextNaluSize = -6; - if (preFourByte != 0x00000001) - nextNaluSize++; - return (accessUnitSize + nextNaluSize); - -EXIT: - *pbEndOfFrame = OMX_FALSE; - - return accessUnitSize; -} - -OMX_BOOL Check_H264_StartCode(OMX_U8 *pInputStream, OMX_U32 streamSize) -{ - if (streamSize < 4) { - return OMX_FALSE; - } else if ((pInputStream[0] == 0x00) && - (pInputStream[1] == 0x00) && - (pInputStream[2] == 0x00) && - (pInputStream[3] != 0x00) && - ((pInputStream[3] >> 3) == 0x00)) { - return OMX_TRUE; - } else if ((pInputStream[0] == 0x00) && - (pInputStream[1] == 0x00) && - (pInputStream[2] != 0x00) && - ((pInputStream[2] >> 3) == 0x00)) { - return OMX_TRUE; - } else { - return OMX_FALSE; - } -} - -OMX_ERRORTYPE SEC_MFC_H264Dec_GetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR pComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - switch (nParamIndex) { - case OMX_IndexParamVideoAvc: - { - OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL; - SEC_H264DEC_HANDLE *pH264Dec = NULL; - - ret = SEC_OMX_Check_SizeVersion(pDstAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstAVCComponent->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - pSrcAVCComponent = &pH264Dec->AVCComponent[pDstAVCComponent->nPortIndex]; - - SEC_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); - } - break; - case OMX_IndexParamStandardComponentRole: - { - OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure; - ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_H264_DEC_ROLE); - } - break; - case OMX_IndexParamVideoProfileLevelQuerySupported: - { - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure; - SEC_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL; - OMX_U32 maxProfileLevelNum = 0; - - ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pProfileLevel = supportedAVCProfileLevels; - maxProfileLevelNum = sizeof(supportedAVCProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL); - - if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) { - ret = OMX_ErrorNoMore; - goto EXIT; - } - - pProfileLevel += pDstProfileLevel->nProfileIndex; - pDstProfileLevel->eProfile = pProfileLevel->profile; - pDstProfileLevel->eLevel = pProfileLevel->level; - } - break; - case OMX_IndexParamVideoProfileLevelCurrent: - { - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure; - OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL; - SEC_H264DEC_HANDLE *pH264Dec = NULL; - - ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - pSrcAVCComponent = &pH264Dec->AVCComponent[pDstProfileLevel->nPortIndex]; - - pDstProfileLevel->eProfile = pSrcAVCComponent->eProfile; - pDstProfileLevel->eLevel = pSrcAVCComponent->eLevel; - } - break; - case OMX_IndexParamVideoErrorCorrection: - { - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; - SEC_H264DEC_HANDLE *pH264Dec = NULL; - - ret = SEC_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - pSrcErrorCorrectionType = &pH264Dec->errorCorrectionType[INPUT_PORT_INDEX]; - - pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; - pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; - pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; - pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; - pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; - } - break; - default: - ret = SEC_OMX_VideoDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); - break; - } -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_H264Dec_SetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - switch (nIndex) { - case OMX_IndexParamVideoAvc: - { - OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL; - OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure; - SEC_H264DEC_HANDLE *pH264Dec = NULL; - - ret = SEC_OMX_Check_SizeVersion(pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcAVCComponent->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - pDstAVCComponent = &pH264Dec->AVCComponent[pSrcAVCComponent->nPortIndex]; - - SEC_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); - } - break; - case OMX_IndexParamStandardComponentRole: - { - OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; - - ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_H264_DEC_ROLE)) { - pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; - } else { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - } - break; - case OMX_IndexParamPortDefinition: - { - OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)pComponentParameterStructure; - OMX_U32 portIndex = pPortDefinition->nPortIndex; - SEC_OMX_BASEPORT *pSECPort; - OMX_U32 width, height, size; - - if (portIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(pPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[portIndex]; - - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - if (pSECPort->portDefinition.bEnabled == OMX_TRUE) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - } - if(pPortDefinition->nBufferCountActual < pSECPort->portDefinition.nBufferCountMin) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - SEC_OSAL_Memcpy(&pSECPort->portDefinition, pPortDefinition, pPortDefinition->nSize); - - width = ((pSECPort->portDefinition.format.video.nFrameWidth + 15) & (~15)); - height = ((pSECPort->portDefinition.format.video.nFrameHeight + 15) & (~15)); - size = (width * height * 3) / 2; - pSECPort->portDefinition.format.video.nStride = width; - pSECPort->portDefinition.format.video.nSliceHeight = height; - pSECPort->portDefinition.nBufferSize = (size > pSECPort->portDefinition.nBufferSize) ? size : pSECPort->portDefinition.nBufferSize; - - if (portIndex == INPUT_PORT_INDEX) { - SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - pSECOutputPort->portDefinition.format.video.nFrameWidth = pSECPort->portDefinition.format.video.nFrameWidth; - pSECOutputPort->portDefinition.format.video.nFrameHeight = pSECPort->portDefinition.format.video.nFrameHeight; - pSECOutputPort->portDefinition.format.video.nStride = width; - pSECOutputPort->portDefinition.format.video.nSliceHeight = height; - if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) { - pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2; - } else if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV422Planar) { - pSECOutputPort->portDefinition.nBufferSize = width * height * 2; - } - } - } - break; - case OMX_IndexParamVideoProfileLevelCurrent: - { - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL; - SEC_H264DEC_HANDLE *pH264Dec = NULL; - - ret = SEC_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); - if (ret != OMX_ErrorNone) - goto EXIT; - - if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - - pDstAVCComponent = &pH264Dec->AVCComponent[pSrcProfileLevel->nPortIndex]; - pDstAVCComponent->eProfile = pSrcProfileLevel->eProfile; - pDstAVCComponent->eLevel = pSrcProfileLevel->eLevel; - } - break; - case OMX_IndexParamVideoErrorCorrection: - { - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; - SEC_H264DEC_HANDLE *pH264Dec = NULL; - - ret = SEC_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - pDstErrorCorrectionType = &pH264Dec->errorCorrectionType[INPUT_PORT_INDEX]; - - pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; - pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; - pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; - pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; - pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; - } - break; - default: - ret = SEC_OMX_VideoDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure); - break; - } -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_H264Dec_SetConfig( - OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pComponentConfigStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pComponentConfigStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - switch (nIndex) { - case OMX_IndexVendorThumbnailMode: - { - SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - - pH264Dec->hMFCH264Handle.bThumbnailMode = *((OMX_BOOL *)pComponentConfigStructure); - - ret = OMX_ErrorNone; - } - break; - default: - ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure); - break; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_H264Dec_GetExtensionIndex( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, - OMX_OUT OMX_INDEXTYPE *pIndexType) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if ((cParameterName == NULL) || (pIndexType == NULL)) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - if (SEC_OSAL_Strcmp(cParameterName, "OMX.SEC.index.ThumbnailMode") == 0) { - SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - - *pIndexType = OMX_IndexVendorThumbnailMode; - - ret = OMX_ErrorNone; - } else { - ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType); - } - -EXIT: - FunctionOut(); - - return ret; -} - - -OMX_ERRORTYPE SEC_MFC_H264Dec_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if ((hComponent == NULL) || (cRole == NULL)) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (nIndex == (MAX_COMPONENT_ROLE_NUM-1)) { - SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_H264_DEC_ROLE); - ret = OMX_ErrorNone; - } else { - ret = OMX_ErrorNoMore; - } - -EXIT: - FunctionOut(); - - return ret; -} - -/* MFC Init */ -OMX_ERRORTYPE SEC_MFC_H264Dec_Init(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_H264DEC_HANDLE *pH264Dec = NULL; - - OMX_PTR hMFCHandle = NULL; - OMX_PTR pStreamBuffer = NULL; - OMX_PTR pStreamPhyBuffer = NULL; - - pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - pH264Dec->hMFCH264Handle.bConfiguredMFC = OMX_FALSE; - pSECComponent->bUseFlagEOF = OMX_FALSE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - - /* MFC(Multi Function Codec) decoder and CMM(Codec Memory Management) driver open */ - hMFCHandle = (OMX_PTR)SsbSipMfcDecOpen(); - if (hMFCHandle == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - pH264Dec->hMFCH264Handle.hMFCHandle = hMFCHandle; - - /* Allocate decoder's input buffer */ - pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE); - if (pStreamBuffer == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - pH264Dec->hMFCH264Handle.pMFCStreamBuffer = pStreamBuffer; - pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = pStreamPhyBuffer; - pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pStreamBuffer; - pSECComponent->processData[INPUT_PORT_INDEX].allocSize = DEFAULT_MFC_INPUT_BUFFER_SIZE; - - SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); - SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); - pH264Dec->hMFCH264Handle.indexTimestamp = 0; - pSECComponent->getAllDelayBuffer = OMX_FALSE; - -EXIT: - return ret; -} - -/* MFC Terminate */ -OMX_ERRORTYPE SEC_MFC_H264Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_H264DEC_HANDLE *pH264Dec = NULL; - OMX_PTR hMFCHandle = NULL; - - FunctionIn(); - - pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; - - pH264Dec->hMFCH264Handle.pMFCStreamBuffer = NULL; - pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = NULL; - pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = NULL; - pSECComponent->processData[INPUT_PORT_INDEX].allocSize = 0; - - if (hMFCHandle != NULL) { - SsbSipMfcDecClose(hMFCHandle); - hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle = NULL; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - OMX_U32 oneFrameSize = pInputData->dataLen; - SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo; - OMX_S32 setConfVal = 0; - OMX_S32 returnCodec = 0; - int bufWidth; - int bufHeight; - - FunctionIn(); - - if (pH264Dec->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) { - SSBSIP_MFC_CODEC_TYPE eCodecType = H264_DEC; - - if ((oneFrameSize <= 0) && (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) { - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - ret = OMX_ErrorNone; - goto EXIT; - } - - setConfVal = 5; - SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &setConfVal); - - /* Default number in the driver is optimized */ - if (pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_TRUE) { - setConfVal = 0; - SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal); - } else { - setConfVal = 8; - SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal); - } - - returnCodec = SsbSipMfcDecInit(pH264Dec->hMFCH264Handle.hMFCHandle, eCodecType, oneFrameSize); - if (returnCodec == MFC_RET_OK) { - SSBSIP_MFC_IMG_RESOLUTION imgResol; - SSBSIP_MFC_CROP_INFORMATION cropInfo; - SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - - SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol); - SEC_OSAL_Log(SEC_LOG_TRACE, "set width height information : %d, %d", - secInputPort->portDefinition.format.video.nFrameWidth, - secInputPort->portDefinition.format.video.nFrameHeight); - SEC_OSAL_Log(SEC_LOG_TRACE, "mfc width height information : %d, %d", - imgResol.width, imgResol.height); - - SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_CROP_INFO, &cropInfo); - SEC_OSAL_Log(SEC_LOG_TRACE, "mfc crop_top crop_bottom crop_left crop_right : %d, %d, %d, %d", - cropInfo.crop_top_offset , cropInfo.crop_bottom_offset , - cropInfo.crop_left_offset , cropInfo.crop_right_offset); - - int actualWidth = imgResol.width - cropInfo.crop_left_offset - cropInfo.crop_right_offset; - int actualHeight = imgResol.height - cropInfo.crop_top_offset - cropInfo.crop_bottom_offset; - - /** Update Frame Size **/ - if((secInputPort->portDefinition.format.video.nFrameWidth != actualWidth) || - (secInputPort->portDefinition.format.video.nFrameHeight != actualHeight)) { - SEC_OSAL_Log(SEC_LOG_TRACE, "change width height information : OMX_EventPortSettingsChanged"); - /* change width and height information */ - secInputPort->portDefinition.format.video.nFrameWidth = actualWidth; - secInputPort->portDefinition.format.video.nFrameHeight = actualHeight; - secInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15)); - secInputPort->portDefinition.format.video.nSliceHeight = ((imgResol.height + 15) & (~15)); - - SEC_UpdateFrameSize(pOMXComponent); - - /** Send Port Settings changed call back */ - (*(pSECComponent->pCallbacks->EventHandler)) - (pOMXComponent, - pSECComponent->callbackData, - OMX_EventPortSettingsChanged, /* The command was completed */ - OMX_DirOutput, /* This is the port index */ - 0, - NULL); - } - - pH264Dec->hMFCH264Handle.bConfiguredMFC = OMX_TRUE; -#ifdef ADD_SPS_PPS_I_FRAME - ret = OMX_ErrorInputDataDecodeYet; -#else - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - - ret = OMX_ErrorNone; -#endif - goto EXIT; - } else { - ret = OMX_ErrorMFCInit; - goto EXIT; - } - } - -#ifndef FULL_FRAME_SEARCH - if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) && - (pSECComponent->bUseFlagEOF == OMX_FALSE)) { - pSECComponent->bUseFlagEOF = OMX_TRUE; - } -#endif - - pSECComponent->timeStamp[pH264Dec->hMFCH264Handle.indexTimestamp] = pInputData->timeStamp; - pSECComponent->nFlags[pH264Dec->hMFCH264Handle.indexTimestamp] = pInputData->nFlags; - SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pH264Dec->hMFCH264Handle.indexTimestamp)); - pH264Dec->hMFCH264Handle.indexTimestamp++; - if (pH264Dec->hMFCH264Handle.indexTimestamp >= MAX_TIMESTAMP) - pH264Dec->hMFCH264Handle.indexTimestamp = 0; - - if (Check_H264_StartCode(pInputData->dataBuffer, pInputData->dataLen) == OMX_TRUE) { - returnCodec = SsbSipMfcDecExe(pH264Dec->hMFCH264Handle.hMFCHandle, oneFrameSize); - } else { - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - returnCodec = MFC_RET_OK; - goto EXIT; - } - - if (returnCodec == MFC_RET_OK) { - SSBSIP_MFC_DEC_OUTBUF_STATUS status; - OMX_S32 indexTimestamp = 0; - - status = SsbSipMfcDecGetOutBuf(pH264Dec->hMFCH264Handle.hMFCHandle, &outputInfo); - bufWidth = (outputInfo.img_width + 15) & (~15); - bufHeight = (outputInfo.img_height + 15) & (~15); - - if ((SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) || - (((indexTimestamp < 0) || (indexTimestamp > MAX_TIMESTAMP)))) { - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - } else { - pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp]; - pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp]; - } - - if ((status == MFC_GETOUTBUF_DISPLAY_DECODING) || - (status == MFC_GETOUTBUF_DISPLAY_ONLY)) { - switch(pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) { - case OMX_COLOR_FormatYUV420Planar: - case OMX_COLOR_FormatYUV420SemiPlanar: - pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2; - break; - default: - pOutputData->dataLen = bufWidth * bufHeight * 2; - break; - } - } - if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS) - pOutputData->dataLen = 0; - - if ((status == MFC_GETOUTBUF_DISPLAY_ONLY) || - (pSECComponent->getAllDelayBuffer == OMX_TRUE)) { - ret = OMX_ErrorInputDataDecodeYet; - } - - if(status == MFC_GETOUTBUF_DECODING_ONLY) { - /* ret = OMX_ErrorInputDataDecodeYet; */ - ret = OMX_ErrorNone; - goto EXIT; - } - -#ifdef FULL_FRAME_SEARCH - if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS) && - (pSECComponent->bSaveFlagEOS == OMX_TRUE)) { - pInputData->nFlags |= OMX_BUFFERFLAG_EOS; - pSECComponent->getAllDelayBuffer = OMX_TRUE; - ret = OMX_ErrorInputDataDecodeYet; - } else -#endif - - if ((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { - pInputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS)); - pSECComponent->getAllDelayBuffer = OMX_TRUE; - ret = OMX_ErrorInputDataDecodeYet; - } else if ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { - pSECComponent->getAllDelayBuffer = OMX_FALSE; - ret = OMX_ErrorNone; - } - } else { - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - switch(pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) { - case OMX_COLOR_FormatYUV420Planar: - case OMX_COLOR_FormatYUV420SemiPlanar: - pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2; - break; - default: - pOutputData->dataLen = bufWidth * bufHeight * 2; - break; - } - - if ((pSECComponent->bSaveFlagEOS == OMX_TRUE) || - (pSECComponent->getAllDelayBuffer == OMX_TRUE) || - (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) { - pOutputData->nFlags |= OMX_BUFFERFLAG_EOS; - pSECComponent->getAllDelayBuffer = OMX_FALSE; - pOutputData->dataLen = 0; - } - - /* ret = OMX_ErrorUndefined; */ /* ????? */ - ret = OMX_ErrorNone; - goto EXIT; - } - - /** Fill Output Buffer **/ - if (pOutputData->dataLen > 0) - { - int frameSize = bufWidth * bufHeight; - void *pOutBuf = (void *)pOutputData->dataBuffer; - -#ifdef USE_SAMSUNG_COLORFORMAT - SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - - if ((pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_FALSE) && - (pSECOutputPort->portDefinition.format.video.eColorFormat == SEC_OMX_COLOR_FormatNV12PhysicalAddress)) - -#else - if (pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_FALSE) -#endif - { - /* if use Post copy address structure */ - SEC_OSAL_Memcpy(pOutBuf, &frameSize, sizeof(frameSize)); - SEC_OSAL_Memcpy(pOutBuf + sizeof(frameSize), &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr)); - SEC_OSAL_Memcpy(pOutBuf + sizeof(frameSize) + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr)); - SEC_OSAL_Memcpy(pOutBuf + sizeof(frameSize) + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr)); - SEC_OSAL_Memcpy(pOutBuf + sizeof(frameSize) + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr)); - } else { - SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420 out for ThumbnailMode"); - Y_tile_to_linear_4x2( - (unsigned char *)pOutBuf, - (unsigned char *)outputInfo.YVirAddr, - bufWidth, bufHeight); - CbCr_tile_to_linear_4x2( - ((unsigned char *)pOutBuf) + frameSize, - (unsigned char *)outputInfo.CVirAddr, - bufWidth, bufHeight); - } - } - -EXIT: - FunctionOut(); - - return ret; -} - -/* MFC Decode */ -OMX_ERRORTYPE SEC_MFC_H264Dec_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - OMX_BOOL endOfFrame = OMX_FALSE; - - FunctionIn(); - - if ((!CHECK_PORT_ENABLED(pSECInputPort)) || (!CHECK_PORT_ENABLED(pSECOutputPort)) || - (!CHECK_PORT_POPULATED(pSECInputPort)) || (!CHECK_PORT_POPULATED(pSECOutputPort))) { - ret = OMX_ErrorNone; - goto EXIT; - } - if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) { - ret = OMX_ErrorNone; - goto EXIT; - } - - ret = SEC_MFC_H264_Decode(pOMXComponent, pInputData, pOutputData); - if (ret != OMX_ErrorNone) { - if (ret == OMX_ErrorInputDataDecodeYet) { - pOutputData->usedDataLen = 0; - pOutputData->remainDataLen = pOutputData->dataLen; - } else { - pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, ret, 0, NULL); - } - } else { - pInputData->previousDataLen = pInputData->dataLen; - pInputData->usedDataLen += pInputData->dataLen; - pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen; - pInputData->dataLen -= pInputData->usedDataLen; - pInputData->usedDataLen = 0; - - pOutputData->usedDataLen = 0; - pOutputData->remainDataLen = pOutputData->dataLen; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - SEC_H264DEC_HANDLE *pH264Dec = NULL; - int i = 0; - - FunctionIn(); - - if ((hComponent == NULL) || (componentName == NULL)) { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); - goto EXIT; - } - if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_H264_DEC, componentName) != 0) { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__); - goto EXIT; - } - - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_VideoDecodeComponentInit(pOMXComponent); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pSECComponent->codecType = HW_VIDEO_CODEC; - - pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); - if (pSECComponent->componentName == NULL) { - SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent); - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - SEC_OSAL_Memset(pSECComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); - - pH264Dec = SEC_OSAL_Malloc(sizeof(SEC_H264DEC_HANDLE)); - if (pH264Dec == NULL) { - SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent); - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - SEC_OSAL_Memset(pH264Dec, 0, sizeof(SEC_H264DEC_HANDLE)); - pSECComponent->hCodecHandle = (OMX_HANDLETYPE)pH264Dec; - - SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_H264_DEC); - /* Set componentVersion */ - pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; - pSECComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; - pSECComponent->componentVersion.s.nRevision = REVISION_NUMBER; - pSECComponent->componentVersion.s.nStep = STEP_NUMBER; - /* Set specVersion */ - pSECComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; - pSECComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; - pSECComponent->specVersion.s.nRevision = REVISION_NUMBER; - pSECComponent->specVersion.s.nStep = STEP_NUMBER; - - /* Android CapabilityFlags */ - pSECComponent->capabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_FALSE; - pSECComponent->capabilityFlags.iOMXComponentSupportsPartialFrames = OMX_FALSE; - pSECComponent->capabilityFlags.iOMXComponentUsesNALStartCodes = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentUsesFullAVCFrames = OMX_TRUE; - - /* Input port */ - pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; - pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; - pSECPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ - pSECPort->portDefinition.format.video.nSliceHeight = 0; - pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; - SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/avc"); - pSECPort->portDefinition.format.video.pNativeRender = 0; - pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; - pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; - pSECPort->portDefinition.bEnabled = OMX_TRUE; - - /* Output port */ - pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; - pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; - pSECPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ - pSECPort->portDefinition.format.video.nSliceHeight = 0; - pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; - SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); - pSECPort->portDefinition.format.video.pNativeRender = 0; - pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; - pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar; - pSECPort->portDefinition.bEnabled = OMX_TRUE; - - for(i = 0; i < ALL_PORT_NUM; i++) { - INIT_SET_SIZE_VERSION(&pH264Dec->AVCComponent[i], OMX_VIDEO_PARAM_AVCTYPE); - pH264Dec->AVCComponent[i].nPortIndex = i; - pH264Dec->AVCComponent[i].eProfile = OMX_VIDEO_AVCProfileBaseline; - pH264Dec->AVCComponent[i].eLevel = OMX_VIDEO_AVCLevel4; - } - - pOMXComponent->GetParameter = &SEC_MFC_H264Dec_GetParameter; - pOMXComponent->SetParameter = &SEC_MFC_H264Dec_SetParameter; - pOMXComponent->SetConfig = &SEC_MFC_H264Dec_SetConfig; - pOMXComponent->GetExtensionIndex = &SEC_MFC_H264Dec_GetExtensionIndex; - pOMXComponent->ComponentRoleEnum = &SEC_MFC_H264Dec_ComponentRoleEnum; - pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit; - - pSECComponent->sec_mfc_componentInit = &SEC_MFC_H264Dec_Init; - pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_H264Dec_Terminate; - pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_H264Dec_bufferProcess; - pSECComponent->sec_checkInputFrame = &Check_H264_Frame; - - pSECComponent->currentState = OMX_StateLoaded; - - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_H264DEC_HANDLE *pH264Dec = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - SEC_OSAL_Free(pSECComponent->componentName); - pSECComponent->componentName = NULL; - - pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; - if (pH264Dec != NULL) { - SEC_OSAL_Free(pH264Dec); - pH264Dec = pSECComponent->hCodecHandle = NULL; - } - - ret = SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent); - if(ret != OMX_ErrorNone) { - goto EXIT; - } - - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.h b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.h deleted file mode 100644 index b1374fb..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_H264dec.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_H264_DEC_COMPONENT -#define SEC_OMX_H264_DEC_COMPONENT - -#include "SEC_OMX_Def.h" -#include "OMX_Component.h" -#include "OMX_Video.h" - - -typedef struct _SEC_MFC_H264DEC_HANDLE -{ - OMX_HANDLETYPE hMFCHandle; - OMX_PTR pMFCStreamBuffer; - OMX_PTR pMFCStreamPhyBuffer; - OMX_U32 indexTimestamp; - OMX_BOOL bConfiguredMFC; - OMX_BOOL bThumbnailMode; -} SEC_MFC_H264DEC_HANDLE; - -typedef struct _SEC_H264DEC_HANDLE -{ - /* OMX Codec specific */ - OMX_VIDEO_PARAM_AVCTYPE AVCComponent[ALL_PORT_NUM]; - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE errorCorrectionType[ALL_PORT_NUM]; - - /* SEC MFC Codec specific */ - SEC_MFC_H264DEC_HANDLE hMFCH264Handle; -} SEC_H264DEC_HANDLE; - -#ifdef __cplusplus -extern "C" { -#endif - -OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName); -OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent); - -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c deleted file mode 100644 index f7bcf25..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 library_register.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include -#include - -#include "SEC_OSAL_Memory.h" -#include "SEC_OSAL_ETC.h" -#include "library_register.h" -#include "SEC_OSAL_Log.h" - - -OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents) -{ - FunctionIn(); - - if (secComponents == NULL) - goto EXIT; - - /* component 1 - video decoder H.264 */ - SEC_OSAL_Strcpy(secComponents[0]->componentName, SEC_OMX_COMPOMENT_H264_DEC); - SEC_OSAL_Strcpy(secComponents[0]->roles[0], SEC_OMX_COMPOMENT_H264_DEC_ROLE); - secComponents[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM; - -EXIT: - FunctionOut(); - - return MAX_COMPONENT_NUM; -} - diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h deleted file mode 100644 index cdbfaa4..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 library_register.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_H264_REG -#define SEC_OMX_H264_REG - -#include "SEC_OMX_Def.h" -#include "OMX_Component.h" -#include "SEC_OMX_Component_Register.h" - - -#define OSCL_EXPORT_REF __attribute__((visibility("default"))) -#define MAX_COMPONENT_NUM 1 -#define MAX_COMPONENT_ROLE_NUM 1 - -/* H.264 */ -#define SEC_OMX_COMPOMENT_H264_DEC "OMX.SEC.AVC.Decoder" -#define SEC_OMX_COMPOMENT_H264_DEC_ROLE "video_decoder.avc" - - -#ifdef __cplusplus -extern "C" { -#endif - -OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents); - -#ifdef __cplusplus -}; -#endif - -#endif - diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk deleted file mode 100644 index a3a3c0c..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := \ - SEC_OMX_Mpeg4dec.c \ - library_register.c - -LOCAL_PRELINK_MODULE := false -LOCAL_MODULE := libOMX.SEC.M4V.Decoder.aries - -LOCAL_CFLAGS := - -LOCAL_ARM_MODE := arm - -LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec.aries libsecosal.aries libsecbasecomponent.aries libsecmfcdecapi.aries -LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils - -LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ - $(SEC_OMX_INC)/sec \ - $(SEC_OMX_TOP)/sec_osal \ - $(SEC_OMX_TOP)/sec_omx_core \ - $(SEC_OMX_COMPONENT)/common \ - $(SEC_OMX_COMPONENT)/video/dec - -LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include - -include $(BUILD_SHARED_LIBRARY) diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c deleted file mode 100644 index 5074214..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c +++ /dev/null @@ -1,1399 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Mpeg4dec.c - * @brief - * @author Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include - -#include "SEC_OMX_Macros.h" -#include "SEC_OMX_Basecomponent.h" -#include "SEC_OMX_Baseport.h" -#include "SEC_OMX_Vdec.h" -#include "library_register.h" -#include "SEC_OMX_Mpeg4dec.h" -#include "SsbSipMfcApi.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_MPEG4_DEC" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - -//#define FULL_FRAME_SEARCH - -/* MPEG4 Decoder Supported Levels & profiles */ -SEC_OMX_VIDEO_PROFILELEVEL supportedMPEG4ProfileLevels[] ={ - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0b}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level2}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level3}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4a}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level5}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0b}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level1}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level2}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level3}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4a}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level5}}; - -/* H.263 Decoder Supported Levels & profiles */ -SEC_OMX_VIDEO_PROFILELEVEL supportedH263ProfileLevels[] = { - /* Baseline (Profile 0) */ - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level10}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level20}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level30}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level40}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level45}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level50}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level60}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level70}, - /* Profile 1 */ - {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level10}, - {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level20}, - {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level30}, - {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level40}, - {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level45}, - {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level50}, - {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level60}, - {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level70}, - /* Profile 2 */ - {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level10}, - {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level20}, - {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level30}, - {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level40}, - {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level45}, - {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level50}, - {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level60}, - {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level70}, - /* Profile 3, restricted up to SD resolution */ - {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level10}, - {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level20}, - {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level30}, - {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level40}, - {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level45}, - {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level50}, - {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level60}, - {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level70}}; - -static OMX_HANDLETYPE ghMFCHandle = NULL; -static OMX_BOOL gbFIMV1 = OMX_FALSE; - -static int Check_Mpeg4_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame) -{ - int len, readStream; - unsigned startCode; - OMX_BOOL bFrameStart; - - len = 0; - bFrameStart = OMX_FALSE; - - if (flag & OMX_BUFFERFLAG_CODECCONFIG) { - if (*pInputStream == 0x03) { /* FIMV1 */ - if (ghMFCHandle != NULL) { - BitmapInfoHhr *pInfoHeader; - SSBSIP_MFC_IMG_RESOLUTION imgResolution; - - pInfoHeader = (BitmapInfoHhr *)(pInputStream + 1); - imgResolution.width = pInfoHeader->BiWidth; - imgResolution.height = pInfoHeader->BiHeight; - SsbSipMfcDecSetConfig(ghMFCHandle, MFC_DEC_SETCONF_FIMV1_WIDTH_HEIGHT, &imgResolution); - - SEC_OSAL_Log(SEC_LOG_TRACE, "width(%d), height(%d)", imgResolution.width, imgResolution.height); - gbFIMV1 = OMX_TRUE; - *pbEndOfFrame = OMX_TRUE; - return buffSize; - } - } - } - - if (gbFIMV1) { - *pbEndOfFrame = OMX_TRUE; - return buffSize; - } - - if (bPreviousFrameEOF == OMX_FALSE) - bFrameStart = OMX_TRUE; - - startCode = 0xFFFFFFFF; - if (bFrameStart == OMX_FALSE) { - /* find VOP start code */ - while(startCode != 0x1B6) { - readStream = *(pInputStream + len); - startCode = (startCode << 8) | readStream; - len++; - if (len > buffSize) - goto EXIT; - } - } - - /* find next VOP start code */ - startCode = 0xFFFFFFFF; - while ((startCode != 0x1B6)) { - readStream = *(pInputStream + len); - startCode = (startCode << 8) | readStream; - len++; - if (len > buffSize) - goto EXIT; - } - - *pbEndOfFrame = OMX_TRUE; - - SEC_OSAL_Log(SEC_LOG_TRACE, "1. Check_Mpeg4_Frame returned EOF = %d, len = %d, buffSize = %d", *pbEndOfFrame, len - 4, buffSize); - - return len - 4; - -EXIT : - *pbEndOfFrame = OMX_FALSE; - - SEC_OSAL_Log(SEC_LOG_TRACE, "2. Check_Mpeg4_Frame returned EOF = %d, len = %d, buffSize = %d", *pbEndOfFrame, len - 1, buffSize); - - return --len; -} - -static int Check_H263_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame) -{ - int len, readStream; - unsigned startCode; - OMX_BOOL bFrameStart = 0; - - len = 0; - bFrameStart = OMX_FALSE; - - if (bPreviousFrameEOF == OMX_FALSE) - bFrameStart = OMX_TRUE; - - startCode = 0xFFFFFFFF; - if (bFrameStart == OMX_FALSE) { - /* find PSC(Picture Start Code) : 0000 0000 0000 0000 1000 00 */ - while (((startCode << 8 >> 10) != 0x20)) { - readStream = *(pInputStream + len); - startCode = (startCode << 8) | readStream; - len++; - if (len > buffSize) - goto EXIT; - } - } - - /* find next PSC */ - startCode = 0xFFFFFFFF; - while (((startCode << 8 >> 10) != 0x20)) { - readStream = *(pInputStream + len); - startCode = (startCode << 8) | readStream; - len++; - if (len > buffSize) - goto EXIT; - } - - *pbEndOfFrame = OMX_TRUE; - - SEC_OSAL_Log(SEC_LOG_TRACE, "1. Check_H263_Frame returned EOF = %d, len = %d, iBuffSize = %d", *pbEndOfFrame, len - 3, buffSize); - - return len - 3; - -EXIT : - - *pbEndOfFrame = OMX_FALSE; - - SEC_OSAL_Log(SEC_LOG_TRACE, "2. Check_H263_Frame returned EOF = %d, len = %d, iBuffSize = %d", *pbEndOfFrame, len - 1, buffSize); - - return --len; -} - -OMX_BOOL Check_Stream_PrefixCode(OMX_U8 *pInputStream, OMX_U32 streamSize, CODEC_TYPE codecType) -{ - switch (codecType) { - case CODEC_TYPE_MPEG4: - if (gbFIMV1) { - return OMX_TRUE; - } else { - if (streamSize < 3) { - return OMX_FALSE; - } else if ((pInputStream[0] == 0x00) && - (pInputStream[1] == 0x00) && - (pInputStream[2] == 0x01)) { - return OMX_TRUE; - } else { - return OMX_FALSE; - } - } - break; - case CODEC_TYPE_H263: - if (streamSize > 0) - return OMX_TRUE; - else - return OMX_FALSE; - default: - SEC_OSAL_Log(SEC_LOG_WARNING, "%s: undefined codec type (%d)", __FUNCTION__, codecType); - return OMX_FALSE; - } -} - -OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR pComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - switch (nParamIndex) { - case OMX_IndexParamVideoMpeg4: - { - OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL; - SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; - ret = SEC_OMX_Check_SizeVersion(pDstMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstMpeg4Param->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - pSrcMpeg4Param = &pMpeg4Dec->mpeg4Component[pDstMpeg4Param->nPortIndex]; - - SEC_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); - } - break; - case OMX_IndexParamVideoH263: - { - OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL; - SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; - ret = SEC_OMX_Check_SizeVersion(pDstH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstH263Param->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - pSrcH263Param = &pMpeg4Dec->h263Component[pDstH263Param->nPortIndex]; - - SEC_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); - } - break; - case OMX_IndexParamStandardComponentRole: - { - OMX_S32 codecType; - OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure; - - ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - codecType = ((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType; - if (codecType == CODEC_TYPE_MPEG4) - SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_MPEG4_DEC_ROLE); - else - SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_H263_DEC_ROLE); - } - break; - case OMX_IndexParamVideoProfileLevelQuerySupported: - { - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; - SEC_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL; - OMX_U32 maxProfileLevelNum = 0; - OMX_S32 codecType; - - ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - codecType = ((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType; - if (codecType == CODEC_TYPE_MPEG4) { - pProfileLevel = supportedMPEG4ProfileLevels; - maxProfileLevelNum = sizeof(supportedMPEG4ProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL); - } else { - pProfileLevel = supportedH263ProfileLevels; - maxProfileLevelNum = sizeof(supportedH263ProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL); - } - - if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) { - ret = OMX_ErrorNoMore; - goto EXIT; - } - - pProfileLevel += pDstProfileLevel->nProfileIndex; - pDstProfileLevel->eProfile = pProfileLevel->profile; - pDstProfileLevel->eLevel = pProfileLevel->level; - } - break; - case OMX_IndexParamVideoProfileLevelCurrent: - { - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL; - OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL; - SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; - OMX_S32 codecType; - - ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - codecType = pMpeg4Dec->hMFCMpeg4Handle.codecType; - if (codecType == CODEC_TYPE_MPEG4) { - pSrcMpeg4Param = &pMpeg4Dec->mpeg4Component[pDstProfileLevel->nPortIndex]; - pDstProfileLevel->eProfile = pSrcMpeg4Param->eProfile; - pDstProfileLevel->eLevel = pSrcMpeg4Param->eLevel; - } else { - pSrcH263Param = &pMpeg4Dec->h263Component[pDstProfileLevel->nPortIndex]; - pDstProfileLevel->eProfile = pSrcH263Param->eProfile; - pDstProfileLevel->eLevel = pSrcH263Param->eLevel; - } - } - break; - case OMX_IndexParamVideoErrorCorrection: - { - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; - SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; - - ret = SEC_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - pSrcErrorCorrectionType = &pMpeg4Dec->errorCorrectionType[INPUT_PORT_INDEX]; - - pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; - pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; - pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; - pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; - pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; - } - break; - default: - ret = SEC_OMX_VideoDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); - break; - } -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - switch (nIndex) { - case OMX_IndexParamVideoMpeg4: - { - OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL; - OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure; - SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; - - ret = SEC_OMX_Check_SizeVersion(pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcMpeg4Param->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - pDstMpeg4Param = &pMpeg4Dec->mpeg4Component[pSrcMpeg4Param->nPortIndex]; - - SEC_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); - } - break; - case OMX_IndexParamVideoH263: - { - OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL; - OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure; - SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; - - ret = SEC_OMX_Check_SizeVersion(pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcH263Param->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - pDstH263Param = &pMpeg4Dec->h263Component[pSrcH263Param->nPortIndex]; - - SEC_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); - } - break; - case OMX_IndexParamStandardComponentRole: - { - OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; - - ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_MPEG4_DEC_ROLE)) { - pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; - //((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_MPEG4; - } else if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_H263_DEC_ROLE)) { - pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; - //((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_H263; - } else { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - } - break; - case OMX_IndexParamPortDefinition: - { - OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)pComponentParameterStructure; - OMX_U32 portIndex = pPortDefinition->nPortIndex; - SEC_OMX_BASEPORT *pSECPort; - OMX_U32 width, height, size; - - if (portIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - ret = SEC_OMX_Check_SizeVersion(pPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[portIndex]; - - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - if (pSECPort->portDefinition.bEnabled == OMX_TRUE) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - } - if (pPortDefinition->nBufferCountActual < pSECPort->portDefinition.nBufferCountMin) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - SEC_OSAL_Memcpy(&pSECPort->portDefinition, pPortDefinition, pPortDefinition->nSize); - - width = ((pSECPort->portDefinition.format.video.nFrameWidth + 15) & (~15)); - height = ((pSECPort->portDefinition.format.video.nFrameHeight + 15) & (~15)); - size = (width * height * 3) / 2; - pSECPort->portDefinition.format.video.nStride = width; - pSECPort->portDefinition.format.video.nSliceHeight = height; - pSECPort->portDefinition.nBufferSize = (size > pSECPort->portDefinition.nBufferSize) ? size : pSECPort->portDefinition.nBufferSize; - - if (portIndex == INPUT_PORT_INDEX) { - SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - pSECOutputPort->portDefinition.format.video.nFrameWidth = pSECPort->portDefinition.format.video.nFrameWidth; - pSECOutputPort->portDefinition.format.video.nFrameHeight = pSECPort->portDefinition.format.video.nFrameHeight; - pSECOutputPort->portDefinition.format.video.nStride = width; - pSECOutputPort->portDefinition.format.video.nSliceHeight = height; - if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) { - pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2; - } else if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV422Planar) { - pSECOutputPort->portDefinition.nBufferSize = width * height * 2; - } - } - } - break; - case OMX_IndexParamVideoProfileLevelCurrent: - { - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL; - OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL; - SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; - OMX_S32 codecType; - - ret = SEC_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - codecType = pMpeg4Dec->hMFCMpeg4Handle.codecType; - if (codecType == CODEC_TYPE_MPEG4) { - /* - * To do: Check validity of profile & level parameters - */ - - pDstMpeg4Param = &pMpeg4Dec->mpeg4Component[pSrcProfileLevel->nPortIndex]; - pDstMpeg4Param->eProfile = pSrcProfileLevel->eProfile; - pDstMpeg4Param->eLevel = pSrcProfileLevel->eLevel; - } else { - /* - * To do: Check validity of profile & level parameters - */ - - pDstH263Param = &pMpeg4Dec->h263Component[pSrcProfileLevel->nPortIndex]; - pDstH263Param->eProfile = pSrcProfileLevel->eProfile; - pDstH263Param->eLevel = pSrcProfileLevel->eLevel; - } - } - break; - case OMX_IndexParamVideoErrorCorrection: - { - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; - SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; - - ret = SEC_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - pDstErrorCorrectionType = &pMpeg4Dec->errorCorrectionType[INPUT_PORT_INDEX]; - - pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; - pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; - pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; - pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; - pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; - } - break; - default: - ret = SEC_OMX_VideoDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure); - break; - } -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetConfig( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentConfigStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pComponentConfigStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - switch (nIndex) { - case OMX_IndexVendorThumbnailMode: - { - SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - - pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode = *((OMX_BOOL *)pComponentConfigStructure); - } - break; - default: - ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure); - break; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetExtensionIndex( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, - OMX_OUT OMX_INDEXTYPE *pIndexType) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if ((cParameterName == NULL) || (pIndexType == NULL)) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - if (SEC_OSAL_Strcmp(cParameterName, "OMX.SEC.index.ThumbnailMode") == 0) { - SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - - *pIndexType = OMX_IndexVendorThumbnailMode; - - ret = OMX_ErrorNone; - } else { - ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType); - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_ComponentRoleEnum( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_U8 *cRole, - OMX_IN OMX_U32 nIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - OMX_S32 codecType; - - FunctionIn(); - - if ((hComponent == NULL) || (cRole == NULL)) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (nIndex != (MAX_COMPONENT_ROLE_NUM - 1)) { - ret = OMX_ErrorNoMore; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - codecType = ((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType; - if (codecType == CODEC_TYPE_MPEG4) - SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_MPEG4_DEC_ROLE); - else - SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_H263_DEC_ROLE); - -EXIT: - FunctionOut(); - - return ret; -} - -/* MFC Init */ -OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_Init(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; - OMX_HANDLETYPE hMFCHandle = NULL; - OMX_PTR pStreamBuffer = NULL; - OMX_PTR pStreamPhyBuffer = NULL; - - FunctionIn(); - - pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFC = OMX_FALSE; - pSECComponent->bUseFlagEOF = OMX_FALSE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - - /* MFC(Multi Format Codec) decoder and CMM(Codec Memory Management) driver open */ - hMFCHandle = SsbSipMfcDecOpen(); - if (hMFCHandle == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - ghMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle = hMFCHandle; - - /* Allocate decoder's input buffer */ - pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE); - if (pStreamBuffer == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = pStreamBuffer; - pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = pStreamPhyBuffer; - pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pStreamBuffer; - pSECComponent->processData[INPUT_PORT_INDEX].allocSize = DEFAULT_MFC_INPUT_BUFFER_SIZE; - - SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); - SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); - pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp = 0; - pSECComponent->getAllDelayBuffer = OMX_FALSE; - -EXIT: - FunctionOut(); - - return ret; -} - -/* MFC Terminate */ -OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; - OMX_HANDLETYPE hMFCHandle = NULL; - - FunctionIn(); - - pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; - - pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = NULL; - pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = NULL; - pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = NULL; - pSECComponent->processData[INPUT_PORT_INDEX].allocSize = 0; - - if (hMFCHandle != NULL) { - SsbSipMfcDecClose(hMFCHandle); - pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle = NULL; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - OMX_HANDLETYPE hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; - OMX_U32 oneFrameSize = pInputData->dataLen; - SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo; - OMX_S32 configValue; - OMX_S32 returnCodec; - int bufWidth; - int bufHeight; - - FunctionIn(); - - if (pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFC == OMX_FALSE) { - SSBSIP_MFC_CODEC_TYPE MFCCodecType; - if (pMpeg4Dec->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) { - if (gbFIMV1) - MFCCodecType = FIMV1_DEC; - else - MFCCodecType = MPEG4_DEC; - } else { - MFCCodecType = H263_DEC; - } - - if ((oneFrameSize <= 0) && (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) { - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - ret = OMX_ErrorNone; - goto EXIT; - } - - /* Set the number of extra buffer to prevent tearing */ - configValue = 5; - SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &configValue); - - /* Set mpeg4 deblocking filter enable */ - configValue = 1; - SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_POST_ENABLE, &configValue); - - if (pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_TRUE) { - configValue = 0; // the number that you want to delay - SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &configValue); - } - - returnCodec = SsbSipMfcDecInit(hMFCHandle, MFCCodecType, oneFrameSize); - if (returnCodec == MFC_RET_OK) { - SSBSIP_MFC_IMG_RESOLUTION imgResol; - SEC_OMX_BASEPORT *pInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - - if (SsbSipMfcDecGetConfig(hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol) != MFC_RET_OK) { - ret = OMX_ErrorMFCInit; - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcDecGetConfig failed", __FUNCTION__); - goto EXIT; - } - - /** Update Frame Size **/ - if ((pInputPort->portDefinition.format.video.nFrameWidth != imgResol.width) || - (pInputPort->portDefinition.format.video.nFrameHeight != imgResol.height)) { - /* change width and height information */ - pInputPort->portDefinition.format.video.nFrameWidth = imgResol.width; - pInputPort->portDefinition.format.video.nFrameHeight = imgResol.height; - pInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15)); - pInputPort->portDefinition.format.video.nSliceHeight = ((imgResol.height + 15) & (~15)); - - SEC_UpdateFrameSize(pOMXComponent); - - /* Send Port Settings changed call back */ - (*(pSECComponent->pCallbacks->EventHandler)) - (pOMXComponent, - pSECComponent->callbackData, - OMX_EventPortSettingsChanged, // The command was completed - OMX_DirOutput, // This is the port index - 0, - NULL); - } - - SEC_OSAL_Log(SEC_LOG_TRACE, "nFrameWidth(%d) nFrameHeight(%d), nStride(%d), nSliceHeight(%d)", - pInputPort->portDefinition.format.video.nFrameWidth, pInputPort->portDefinition.format.video.nFrameHeight, - pInputPort->portDefinition.format.video.nStride, pInputPort->portDefinition.format.video.nSliceHeight); - - pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFC = OMX_TRUE; - if (pMpeg4Dec->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) { - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - ret = OMX_ErrorNone; - } else { - pOutputData->dataLen = 0; - ret = OMX_ErrorInputDataDecodeYet; - } - goto EXIT; - } else { - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcDecInit failed", __FUNCTION__); - ret = OMX_ErrorMFCInit; /* OMX_ErrorUndefined */ - goto EXIT; - } - } - -#ifndef FULL_FRAME_SEARCH - if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) && - (pSECComponent->bUseFlagEOF == OMX_FALSE)) { - pSECComponent->bUseFlagEOF = OMX_TRUE; - } -#endif - - pSECComponent->timeStamp[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp; - pSECComponent->nFlags[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags; - SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp)); - pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp++; - if (pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp >= MAX_TIMESTAMP) - pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp = 0; - - if (Check_Stream_PrefixCode(pInputData->dataBuffer, pInputData->dataLen, pMpeg4Dec->hMFCMpeg4Handle.codecType) == OMX_TRUE) { - returnCodec = SsbSipMfcDecExe(hMFCHandle, oneFrameSize); - } else { - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - returnCodec = MFC_RET_OK; - goto EXIT; - } - - if (returnCodec == MFC_RET_OK) { - SSBSIP_MFC_DEC_OUTBUF_STATUS status; - OMX_S32 indexTimestamp = 0; - - status = SsbSipMfcDecGetOutBuf(hMFCHandle, &outputInfo); - bufWidth = (outputInfo.img_width + 15) & (~15); - bufHeight = (outputInfo.img_height + 15) & (~15); - - if ((SsbSipMfcDecGetConfig(hMFCHandle, MFC_DEC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) || - (((indexTimestamp < 0) || (indexTimestamp > MAX_TIMESTAMP)))) { - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - } else { - pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp]; - pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp]; - } - - if ((status == MFC_GETOUTBUF_DISPLAY_DECODING) || - (status == MFC_GETOUTBUF_DISPLAY_ONLY)) { - switch(pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) { - case OMX_COLOR_FormatYUV420Planar: - case OMX_COLOR_FormatYUV420SemiPlanar: - pOutputData->dataLen = (bufWidth * bufHeight * 3) /2; - break; - default: - pOutputData->dataLen = bufWidth * bufHeight * 2; - break; - } - } - if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS) - pOutputData->dataLen = 0; - - if ((status == MFC_GETOUTBUF_DISPLAY_ONLY) || - (pSECComponent->getAllDelayBuffer == OMX_TRUE)) { - ret = OMX_ErrorInputDataDecodeYet; - } - - if (status == MFC_GETOUTBUF_DECODING_ONLY) { - /* ret = OMX_ErrorInputDataDecodeYet; */ - ret = OMX_ErrorNone; - goto EXIT; - } - -#ifdef FULL_FRAME_SEARCH - if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS) && - (pSECComponent->bSaveFlagEOS == OMX_TRUE)) { - pInputData->nFlags |= OMX_BUFFERFLAG_EOS; - pSECComponent->getAllDelayBuffer = OMX_TRUE; - ret = OMX_ErrorInputDataDecodeYet; - } else -#endif - - if ((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { - pInputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS)); - pSECComponent->getAllDelayBuffer = OMX_TRUE; - ret = OMX_ErrorInputDataDecodeYet; - } else if ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { - pSECComponent->getAllDelayBuffer = OMX_FALSE; - ret = OMX_ErrorNone; - } - } else { - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - switch(pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) { - case OMX_COLOR_FormatYUV420Planar: - case OMX_COLOR_FormatYUV420SemiPlanar: - pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2; - break; - default: - pOutputData->dataLen = bufWidth * bufHeight * 2; - break; - } - - if ((pSECComponent->bSaveFlagEOS == OMX_TRUE) || - (pSECComponent->getAllDelayBuffer == OMX_TRUE) || - (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) { - pOutputData->nFlags |= OMX_BUFFERFLAG_EOS; - pSECComponent->getAllDelayBuffer = OMX_FALSE; - pOutputData->dataLen = 0; - } - - /* ret = OMX_ErrorUndefined; */ /* ????? */ - ret = OMX_ErrorNone; - goto EXIT; - } - - /** Fill Output Buffer **/ - if (pOutputData->dataLen > 0) - { - int frameSize = bufWidth * bufHeight; - void *pOutputBuf = (void *)pOutputData->dataBuffer; - -#ifdef USE_SAMSUNG_COLORFORMAT - SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - - if ((pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_FALSE) && - (pSECOutputPort->portDefinition.format.video.eColorFormat == SEC_OMX_COLOR_FormatNV12PhysicalAddress)) - -#else - if (pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_FALSE) -#endif - { - /* if use Post copy address structure */ - SEC_OSAL_Memcpy(pOutputBuf, &frameSize, sizeof(frameSize)); - SEC_OSAL_Memcpy(pOutputBuf + sizeof(frameSize), &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr)); - SEC_OSAL_Memcpy(pOutputBuf + sizeof(frameSize) + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr)); - SEC_OSAL_Memcpy(pOutputBuf + sizeof(frameSize) + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr)); - SEC_OSAL_Memcpy(pOutputBuf + sizeof(frameSize) + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr)); - } else { - SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420 out for ThumbnailMode"); - Y_tile_to_linear_4x2( - (unsigned char *)pOutputBuf, - (unsigned char *)outputInfo.YVirAddr, - bufWidth, bufHeight); - CbCr_tile_to_linear_4x2( - ((unsigned char *)pOutputBuf) + frameSize, - (unsigned char *)outputInfo.CVirAddr, - bufWidth, bufHeight); - } - } - -EXIT: - FunctionOut(); - - return ret; -} - -/* MFC Decode */ -OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - SEC_OMX_BASEPORT *pInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - SEC_OMX_BASEPORT *pOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - OMX_BOOL bCheckPrefix = OMX_FALSE; - - FunctionIn(); - - if ((!CHECK_PORT_ENABLED(pInputPort)) || (!CHECK_PORT_ENABLED(pOutputPort)) || - (!CHECK_PORT_POPULATED(pInputPort)) || (!CHECK_PORT_POPULATED(pOutputPort))) { - ret = OMX_ErrorNone; - goto EXIT; - } - if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) { - ret = OMX_ErrorNone; - goto EXIT; - } - - ret = SEC_MFC_Mpeg4_Decode(pOMXComponent, pInputData, pOutputData); - if (ret != OMX_ErrorNone) { - if (ret == OMX_ErrorInputDataDecodeYet) { - pOutputData->usedDataLen = 0; - pOutputData->remainDataLen = pOutputData->dataLen; - } else { - pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, ret, 0, NULL); - } - } else { - pInputData->previousDataLen = pInputData->dataLen; - pInputData->usedDataLen += pInputData->dataLen; - pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen; - pInputData->dataLen -= pInputData->usedDataLen; - pInputData->usedDataLen = 0; - - pOutputData->usedDataLen = 0; - pOutputData->remainDataLen = pOutputData->dataLen; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; - OMX_S32 codecType = -1; - int i = 0; - - FunctionIn(); - - if ((hComponent == NULL) || (componentName == NULL)) { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: parameters are null, ret: %X", __FUNCTION__, ret); - goto EXIT; - } - if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_MPEG4_DEC, componentName) == 0) { - codecType = CODEC_TYPE_MPEG4; - } else if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_H263_DEC, componentName) == 0) { - codecType = CODEC_TYPE_H263; - } else { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName(%s) error, ret: %X", __FUNCTION__, ret); - goto EXIT; - } - - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_VideoDecodeComponentInit(pOMXComponent); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_OMX_VideoDecodeComponentInit error, ret: %X", __FUNCTION__, ret); - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pSECComponent->codecType = HW_VIDEO_CODEC; - - pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); - if (pSECComponent->componentName == NULL) { - SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent); - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName alloc error, ret: %X", __FUNCTION__, ret); - goto EXIT; - } - SEC_OSAL_Memset(pSECComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); - - pMpeg4Dec = SEC_OSAL_Malloc(sizeof(SEC_MPEG4_HANDLE)); - if (pMpeg4Dec == NULL) { - SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent); - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_MPEG4_HANDLE alloc error, ret: %X", __FUNCTION__, ret); - goto EXIT; - } - SEC_OSAL_Memset(pMpeg4Dec, 0, sizeof(SEC_MPEG4_HANDLE)); - pSECComponent->hCodecHandle = (OMX_HANDLETYPE)pMpeg4Dec; - pMpeg4Dec->hMFCMpeg4Handle.codecType = codecType; - - if (codecType == CODEC_TYPE_MPEG4) - SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_MPEG4_DEC); - else - SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_H263_DEC); - - /* Set componentVersion */ - pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; - pSECComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; - pSECComponent->componentVersion.s.nRevision = REVISION_NUMBER; - pSECComponent->componentVersion.s.nStep = STEP_NUMBER; - /* Set specVersion */ - pSECComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; - pSECComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; - pSECComponent->specVersion.s.nRevision = REVISION_NUMBER; - pSECComponent->specVersion.s.nStep = STEP_NUMBER; - - /* Android CapabilityFlags */ - pSECComponent->capabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_FALSE; - pSECComponent->capabilityFlags.iOMXComponentSupportsPartialFrames = OMX_FALSE; - pSECComponent->capabilityFlags.iOMXComponentUsesNALStartCodes = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentUsesFullAVCFrames = OMX_TRUE; - - /* Input port */ - pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; - pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; - pSECPort->portDefinition.format.video.nStride = 0; - pSECPort->portDefinition.format.video.nSliceHeight = 0; - pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; - if (codecType == CODEC_TYPE_MPEG4) { - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; - SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/mpeg4"); - } else { - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; - SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/h263"); - } - pSECPort->portDefinition.format.video.pNativeRender = 0; - pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; - pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; - pSECPort->portDefinition.bEnabled = OMX_TRUE; - - /* Output port */ - pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; - pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; - pSECPort->portDefinition.format.video.nStride = 0; - pSECPort->portDefinition.format.video.nSliceHeight = 0; - pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; - SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); - pSECPort->portDefinition.format.video.pNativeRender = 0; - pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; - pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar; - pSECPort->portDefinition.bEnabled = OMX_TRUE; - - if (codecType == CODEC_TYPE_MPEG4) { - for(i = 0; i < ALL_PORT_NUM; i++) { - INIT_SET_SIZE_VERSION(&pMpeg4Dec->mpeg4Component[i], OMX_VIDEO_PARAM_MPEG4TYPE); - pMpeg4Dec->mpeg4Component[i].nPortIndex = i; - pMpeg4Dec->mpeg4Component[i].eProfile = OMX_VIDEO_MPEG4ProfileSimple; - pMpeg4Dec->mpeg4Component[i].eLevel = OMX_VIDEO_MPEG4Level3; - } - } else { - for(i = 0; i < ALL_PORT_NUM; i++) { - INIT_SET_SIZE_VERSION(&pMpeg4Dec->h263Component[i], OMX_VIDEO_PARAM_H263TYPE); - pMpeg4Dec->h263Component[i].nPortIndex = i; - pMpeg4Dec->h263Component[i].eProfile = OMX_VIDEO_H263ProfileBaseline | OMX_VIDEO_H263ProfileISWV2; - pMpeg4Dec->h263Component[i].eLevel = OMX_VIDEO_H263Level45; - } - } - - pOMXComponent->GetParameter = &SEC_MFC_Mpeg4Dec_GetParameter; - pOMXComponent->SetParameter = &SEC_MFC_Mpeg4Dec_SetParameter; - pOMXComponent->SetConfig = &SEC_MFC_Mpeg4Dec_SetConfig; - pOMXComponent->GetExtensionIndex = &SEC_MFC_Mpeg4Dec_GetExtensionIndex; - pOMXComponent->ComponentRoleEnum = &SEC_MFC_Mpeg4Dec_ComponentRoleEnum; - pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit; - - pSECComponent->sec_mfc_componentInit = &SEC_MFC_Mpeg4Dec_Init; - pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_Mpeg4Dec_Terminate; - pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_Mpeg4Dec_bufferProcess; - if (codecType == CODEC_TYPE_MPEG4) - pSECComponent->sec_checkInputFrame = &Check_Mpeg4_Frame; - else - pSECComponent->sec_checkInputFrame = &Check_H263_Frame; - - pSECComponent->currentState = OMX_StateLoaded; - - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - SEC_OSAL_Free(pSECComponent->componentName); - pSECComponent->componentName = NULL; - - pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; - if (pMpeg4Dec != NULL) { - SEC_OSAL_Free(pMpeg4Dec); - pSECComponent->hCodecHandle = NULL; - } - - ret = SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h deleted file mode 100644 index 25170b8..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Mpeg4dec.h - * @brief - * @author Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_MPEG4_DEC_COMPONENT -#define SEC_OMX_MPEG4_DEC_COMPONENT - -#include "SEC_OMX_Def.h" -#include "OMX_Component.h" - - -typedef enum _CODEC_TYPE -{ - CODEC_TYPE_H263, - CODEC_TYPE_MPEG4 -} CODEC_TYPE; - -/* - * This structure is the same as BitmapInfoHhr struct in pv_avifile_typedefs.h file - */ -typedef struct _BitmapInfoHhr -{ - OMX_U32 BiSize; - OMX_U32 BiWidth; - OMX_U32 BiHeight; - OMX_U16 BiPlanes; - OMX_U16 BiBitCount; - OMX_U32 BiCompression; - OMX_U32 BiSizeImage; - OMX_U32 BiXPelsPerMeter; - OMX_U32 BiYPelsPerMeter; - OMX_U32 BiClrUsed; - OMX_U32 BiClrImportant; -} BitmapInfoHhr; - -typedef struct _SEC_MFC_MPEG4_HANDLE -{ - OMX_HANDLETYPE hMFCHandle; - OMX_PTR pMFCStreamBuffer; - OMX_PTR pMFCStreamPhyBuffer; - OMX_U32 indexTimestamp; - OMX_BOOL bConfiguredMFC; - OMX_BOOL bThumbnailMode; - CODEC_TYPE codecType; -} SEC_MFC_MPEG4_HANDLE; - -typedef struct _SEC_MPEG4_HANDLE -{ - /* OMX Codec specific */ - OMX_VIDEO_PARAM_H263TYPE h263Component[ALL_PORT_NUM]; - OMX_VIDEO_PARAM_MPEG4TYPE mpeg4Component[ALL_PORT_NUM]; - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE errorCorrectionType[ALL_PORT_NUM]; - - /* SEC MFC Codec specific */ - SEC_MFC_MPEG4_HANDLE hMFCMpeg4Handle; -} SEC_MPEG4_HANDLE; - -#ifdef __cplusplus -extern "C" { -#endif - -OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName); - OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent); - -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c deleted file mode 100644 index 89b856d..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 library_register.c - * @brief - * @author Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include -#include - -#include "SEC_OSAL_Memory.h" -#include "SEC_OSAL_ETC.h" -#include "library_register.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_MPEG4_DEC" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent) -{ - FunctionIn(); - - if (ppSECComponent == NULL) - goto EXIT; - - /* component 1 - video decoder MPEG4 */ - SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPOMENT_MPEG4_DEC); - SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPOMENT_MPEG4_DEC_ROLE); - ppSECComponent[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM; - - /* component 2 - video decoder H.263 */ - SEC_OSAL_Strcpy(ppSECComponent[1]->componentName, SEC_OMX_COMPOMENT_H263_DEC); - SEC_OSAL_Strcpy(ppSECComponent[1]->roles[0], SEC_OMX_COMPOMENT_H263_DEC_ROLE); - ppSECComponent[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM; - -EXIT: - FunctionOut(); - return MAX_COMPONENT_NUM; -} - diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h b/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h deleted file mode 100644 index e9bcfe8..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 library_register.h - * @brief - * @author Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_MPEG4_DEC_REG -#define SEC_OMX_MPEG4_DEC_REG - -#include "SEC_OMX_Def.h" -#include "OMX_Component.h" -#include "SEC_OMX_Component_Register.h" - - -#define OSCL_EXPORT_REF __attribute__((visibility("default"))) -#define MAX_COMPONENT_NUM 2 -#define MAX_COMPONENT_ROLE_NUM 1 - -/* MPEG4 */ -#define SEC_OMX_COMPOMENT_MPEG4_DEC "OMX.SEC.MPEG4.Decoder" -#define SEC_OMX_COMPOMENT_MPEG4_DEC_ROLE "video_decoder.mpeg4" - -/* H.263 */ -#define SEC_OMX_COMPOMENT_H263_DEC "OMX.SEC.H263.Decoder" -#define SEC_OMX_COMPOMENT_H263_DEC_ROLE "video_decoder.h263" - - -#ifdef __cplusplus -extern "C" { -#endif - -OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent); - -#ifdef __cplusplus -}; -#endif - -#endif - diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/Android.mk b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/Android.mk deleted file mode 100644 index e9ca8e7..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/Android.mk +++ /dev/null @@ -1,20 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - SEC_OMX_Venc.c - -LOCAL_MODULE := libSEC_OMX_Venc.aries -LOCAL_ARM_MODE := arm -LOCAL_MODULE_TAGS := optional - -LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ - $(SEC_OMX_INC)/sec \ - $(SEC_OMX_TOP)/sec_osal \ - $(SEC_OMX_TOP)/sec_omx_core \ - $(SEC_OMX_COMPONENT)/common \ - $(SEC_OMX_COMPONENT)/video/dec - -LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include - -include $(BUILD_STATIC_LIBRARY) diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c deleted file mode 100644 index eff5dec..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c +++ /dev/null @@ -1,1411 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Venc.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include -#include "SEC_OMX_Macros.h" -#include "SEC_OSAL_Event.h" -#include "SEC_OMX_Venc.h" -#include "SEC_OMX_Basecomponent.h" -#include "SEC_OSAL_Thread.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_VIDEO_ENC" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - -#define ONE_FRAME_OUTPUT /* only one frame output for Android */ -#define S5PC110_ENCODE_IN_DATA_BUFFER /* for Android s5pc110 0copy*/ - - -inline void SEC_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent) -{ - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - - if ((secOutputPort->portDefinition.format.video.nFrameWidth != - secInputPort->portDefinition.format.video.nFrameWidth) || - (secOutputPort->portDefinition.format.video.nFrameHeight != - secInputPort->portDefinition.format.video.nFrameHeight)) { - OMX_U32 width = 0, height = 0; - - secOutputPort->portDefinition.format.video.nFrameWidth = - secInputPort->portDefinition.format.video.nFrameWidth; - secOutputPort->portDefinition.format.video.nFrameHeight = - secInputPort->portDefinition.format.video.nFrameHeight; - width = secOutputPort->portDefinition.format.video.nStride = - secInputPort->portDefinition.format.video.nStride; - height = secOutputPort->portDefinition.format.video.nSliceHeight = - secInputPort->portDefinition.format.video.nSliceHeight; - - switch(secOutputPort->portDefinition.format.video.eColorFormat) { - case OMX_COLOR_FormatYUV420Planar: - case OMX_COLOR_FormatYUV420SemiPlanar: - if (width && height) - secOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2; - break; - default: - if (width && height) - secOutputPort->portDefinition.nBufferSize = width * height * 2; - break; - } - } - - return ; -} - -OMX_ERRORTYPE SEC_OMX_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 ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; - int i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - pSECPort = &pSECComponent->pSECPort[nPortIndex]; - if (nPortIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - if (pSECPort->portState != OMX_StateIdle) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); - if (temp_bufferHeader == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE)); - - for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { - if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { - pSECPort->bufferHeader[i] = temp_bufferHeader; - pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED); - INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE); - temp_bufferHeader->pBuffer = pBuffer; - temp_bufferHeader->nAllocLen = nSizeBytes; - temp_bufferHeader->pAppPrivate = pAppPrivate; - if (nPortIndex == INPUT_PORT_INDEX) - temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX; - else - temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX; - - pSECPort->assignedBufferNum++; - if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) { - pSECPort->portDefinition.bPopulated = OMX_TRUE; - /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */ - SEC_OSAL_SemaphorePost(pSECPort->loadedResource); - /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */ - } - *ppBufferHdr = temp_bufferHeader; - ret = OMX_ErrorNone; - goto EXIT; - } - } - ret = OMX_ErrorInsufficientResources; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_AllocateBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN OMX_U32 nSizeBytes) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; - OMX_U8 *temp_buffer = NULL; - int i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - pSECPort = &pSECComponent->pSECPort[nPortIndex]; - if (nPortIndex >= pSECComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } -/* - if (pSECPort->portState != OMX_StateIdle ) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } -*/ - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - temp_buffer = SEC_OSAL_Malloc(sizeof(OMX_U8) * nSizeBytes); - if (temp_buffer == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - - temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); - if (temp_bufferHeader == NULL) { - SEC_OSAL_Free(temp_buffer); - temp_buffer = NULL; - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE)); - - for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { - if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { - pSECPort->bufferHeader[i] = temp_bufferHeader; - pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ALLOCATED | HEADER_STATE_ALLOCATED); - INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE); - temp_bufferHeader->pBuffer = temp_buffer; - temp_bufferHeader->nAllocLen = nSizeBytes; - temp_bufferHeader->pAppPrivate = pAppPrivate; - if (nPortIndex == INPUT_PORT_INDEX) - temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX; - else - temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX; - pSECPort->assignedBufferNum++; - if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) { - pSECPort->portDefinition.bPopulated = OMX_TRUE; - /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */ - SEC_OSAL_SemaphorePost(pSECPort->loadedResource); - /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */ - } - *ppBuffer = temp_bufferHeader; - ret = OMX_ErrorNone; - goto EXIT; - } - } - ret = OMX_ErrorInsufficientResources; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_FreeBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; - OMX_U8 *temp_buffer = NULL; - int i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pSECPort = &pSECComponent->pSECPort[nPortIndex]; - - if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - if ((pSECPort->portState != OMX_StateLoaded) && (pSECPort->portState != OMX_StateInvalid)) { - (*(pSECComponent->pCallbacks->EventHandler)) (pOMXComponent, - pSECComponent->callbackData, - (OMX_U32)OMX_EventError, - (OMX_U32)OMX_ErrorPortUnpopulated, - nPortIndex, NULL); - } - - for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { - if (((pSECPort->bufferStateAllocate[i] | BUFFER_STATE_FREE) != 0) && (pSECPort->bufferHeader[i] != NULL)) { - if (pSECPort->bufferHeader[i]->pBuffer == pBufferHdr->pBuffer) { - if (pSECPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) { - SEC_OSAL_Free(pSECPort->bufferHeader[i]->pBuffer); - pSECPort->bufferHeader[i]->pBuffer = NULL; - pBufferHdr->pBuffer = NULL; - } else if (pSECPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) { - ; /* None*/ - } - pSECPort->assignedBufferNum--; - if (pSECPort->bufferStateAllocate[i] & HEADER_STATE_ALLOCATED) { - SEC_OSAL_Free(pSECPort->bufferHeader[i]); - pSECPort->bufferHeader[i] = NULL; - pBufferHdr = NULL; - } - pSECPort->bufferStateAllocate[i] = BUFFER_STATE_FREE; - ret = OMX_ErrorNone; - goto EXIT; - } - } - } - -EXIT: - if (ret == OMX_ErrorNone) { - if (pSECPort->assignedBufferNum == 0 ) { - SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->unloadedResource signal set"); - /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */ - SEC_OSAL_SemaphorePost(pSECPort->unloadedResource); - /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */ - pSECPort->portDefinition.bPopulated = OMX_FALSE; - } - } - - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_AllocateTunnelBuffer(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; - OMX_U8 *temp_buffer = NULL; - OMX_U32 bufferSize = 0; - OMX_PARAM_PORTDEFINITIONTYPE portDefinition; - - ret = OMX_ErrorTunnelingUnsupported; -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OMX_FreeTunnelBuffer(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT* pSECPort = NULL; - OMX_BUFFERHEADERTYPE* temp_bufferHeader = NULL; - OMX_U8 *temp_buffer = NULL; - OMX_U32 bufferSize = 0; - OMX_PARAM_PORTDEFINITIONTYPE portDefinition; - - ret = OMX_ErrorTunnelingUnsupported; -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OMX_ComponentTunnelRequest( - OMX_IN OMX_HANDLETYPE hComp, - OMX_IN OMX_U32 nPort, - OMX_IN OMX_HANDLETYPE hTunneledComp, - OMX_IN OMX_U32 nTunneledPort, - OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - - ret = OMX_ErrorTunnelingUnsupported; -EXIT: - return ret; -} - -OMX_BOOL SEC_Check_BufferProcess_State(SEC_OMX_BASECOMPONENT *pSECComponent) -{ - if ((pSECComponent->currentState == OMX_StateExecuting) && - (pSECComponent->pSECPort[INPUT_PORT_INDEX].portState == OMX_StateIdle) && - (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portState == OMX_StateIdle) && - (pSECComponent->transientState != SEC_OMX_TransStateExecutingToIdle) && - (pSECComponent->transientState != SEC_OMX_TransStateIdleToExecuting)) - return OMX_TRUE; - else - return OMX_FALSE; -} - -static OMX_ERRORTYPE SEC_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *secOMXInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - SEC_OMX_BASEPORT *secOMXOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; - OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; - - FunctionIn(); - - if (bufferHeader != NULL) { - if (secOMXInputPort->markType.hMarkTargetComponent != NULL ) { - bufferHeader->hMarkTargetComponent = secOMXInputPort->markType.hMarkTargetComponent; - bufferHeader->pMarkData = secOMXInputPort->markType.pMarkData; - secOMXInputPort->markType.hMarkTargetComponent = NULL; - secOMXInputPort->markType.pMarkData = NULL; - } - - if (bufferHeader->hMarkTargetComponent != NULL) { - if (bufferHeader->hMarkTargetComponent == pOMXComponent) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventMark, - 0, 0, bufferHeader->pMarkData); - } else { - pSECComponent->propagateMarkType.hMarkTargetComponent = bufferHeader->hMarkTargetComponent; - pSECComponent->propagateMarkType.pMarkData = bufferHeader->pMarkData; - } - } - - if (CHECK_PORT_TUNNELED(secOMXInputPort)) { - OMX_FillThisBuffer(secOMXInputPort->tunneledComponent, bufferHeader); - } else { - bufferHeader->nFilledLen = 0; - pSECComponent->pCallbacks->EmptyBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); - } - } - - if ((pSECComponent->currentState == OMX_StatePause) && - ((!CHECK_PORT_BEING_FLUSHED(secOMXInputPort) && !CHECK_PORT_BEING_FLUSHED(secOMXOutputPort)))) { - SEC_OSAL_SignalReset(pSECComponent->pauseEvent); - SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME); - } - - dataBuffer->dataValid = OMX_FALSE; - dataBuffer->dataLen = 0; - dataBuffer->remainDataLen = 0; - dataBuffer->usedDataLen = 0; - dataBuffer->bufferHeader = NULL; - dataBuffer->nFlags = 0; - dataBuffer->timeStamp = 0; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_InputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - SEC_OMX_DATABUFFER *dataBuffer = NULL; - SEC_OMX_MESSAGE* message = NULL; - SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; - - FunctionIn(); - - pSECPort= &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - dataBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; - - if (pSECComponent->currentState != OMX_StateExecuting) { - ret = OMX_ErrorUndefined; - goto EXIT; - } else { - SEC_OSAL_SemaphoreWait(pSECPort->bufferSemID); - SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex); - if (dataBuffer->dataValid != OMX_TRUE) { - message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ); - if (message == NULL) { - ret = OMX_ErrorUndefined; - SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); - goto EXIT; - } - - dataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData); - dataBuffer->allocSize = dataBuffer->bufferHeader->nAllocLen; - dataBuffer->dataLen = dataBuffer->bufferHeader->nFilledLen; - dataBuffer->remainDataLen = dataBuffer->dataLen; - dataBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset; - dataBuffer->dataValid = OMX_TRUE; - dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; - dataBuffer->timeStamp = dataBuffer->bufferHeader->nTimeStamp; -#ifdef S5PC110_ENCODE_IN_DATA_BUFFER - pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = dataBuffer->bufferHeader->pBuffer; - pSECComponent->processData[INPUT_PORT_INDEX].allocSize = dataBuffer->bufferHeader->nAllocLen; -#endif - SEC_OSAL_Free(message); - } - SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); - ret = OMX_ErrorNone; - } -EXIT: - FunctionOut(); - - return ret; -} - -static OMX_ERRORTYPE SEC_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *secOMXInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - SEC_OMX_BASEPORT *secOMXOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; - OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; - - FunctionIn(); - - if (bufferHeader != NULL) { - bufferHeader->nFilledLen = dataBuffer->remainDataLen; - bufferHeader->nOffset = 0; - bufferHeader->nFlags = dataBuffer->nFlags; - bufferHeader->nTimeStamp = dataBuffer->timeStamp; - - if (pSECComponent->propagateMarkType.hMarkTargetComponent != NULL) { - bufferHeader->hMarkTargetComponent = pSECComponent->propagateMarkType.hMarkTargetComponent; - bufferHeader->pMarkData = pSECComponent->propagateMarkType.pMarkData; - pSECComponent->propagateMarkType.hMarkTargetComponent = NULL; - pSECComponent->propagateMarkType.pMarkData = NULL; - } - - if (bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) { - pSECComponent->pCallbacks->EventHandler(pOMXComponent, - pSECComponent->callbackData, - OMX_EventBufferFlag, - OUTPUT_PORT_INDEX, - bufferHeader->nFlags, NULL); - } - - if (CHECK_PORT_TUNNELED(secOMXOutputPort)) { - OMX_EmptyThisBuffer(secOMXOutputPort->tunneledComponent, bufferHeader); - } else { - pSECComponent->pCallbacks->FillBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); - } - } - - if ((pSECComponent->currentState == OMX_StatePause) && - ((!CHECK_PORT_BEING_FLUSHED(secOMXInputPort) && !CHECK_PORT_BEING_FLUSHED(secOMXOutputPort)))) { - SEC_OSAL_SignalReset(pSECComponent->pauseEvent); - SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME); - } - - /* reset dataBuffer */ - dataBuffer->dataValid = OMX_FALSE; - dataBuffer->dataLen = 0; - dataBuffer->remainDataLen = 0; - dataBuffer->usedDataLen = 0; - dataBuffer->bufferHeader = NULL; - dataBuffer->nFlags = 0; - dataBuffer->timeStamp = 0; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OutputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASEPORT *pSECPort = NULL; - SEC_OMX_DATABUFFER *dataBuffer = NULL; - SEC_OMX_MESSAGE *message = NULL; - SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; - - FunctionIn(); - - pSECPort= &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - dataBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; - - if (pSECComponent->currentState != OMX_StateExecuting) { - ret = OMX_ErrorUndefined; - goto EXIT; - } else { - SEC_OSAL_SemaphoreWait(pSECPort->bufferSemID); - SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); - if (dataBuffer->dataValid != OMX_TRUE) { - message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ); - if (message == NULL) { - ret = OMX_ErrorUndefined; - SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); - goto EXIT; - } - - dataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData); - dataBuffer->allocSize = dataBuffer->bufferHeader->nAllocLen; - dataBuffer->dataLen = 0; //dataBuffer->bufferHeader->nFilledLen; - dataBuffer->remainDataLen = dataBuffer->dataLen; - dataBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset; - dataBuffer->dataValid =OMX_TRUE; - /* dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; */ - /* dataBuffer->nTimeStamp = dataBuffer->bufferHeader->nTimeStamp; */ - SEC_OSAL_Free(message); - } - SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); - ret = OMX_ErrorNone; - } -EXIT: - FunctionOut(); - - return ret; - -} - -static OMX_ERRORTYPE SEC_BufferReset(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 portIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - /* SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[portIndex]; */ - SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[portIndex]; - /* OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; */ - - dataBuffer->dataValid = OMX_FALSE; - dataBuffer->dataLen = 0; - dataBuffer->remainDataLen = 0; - dataBuffer->usedDataLen = 0; - dataBuffer->bufferHeader = NULL; - dataBuffer->nFlags = 0; - dataBuffer->timeStamp = 0; - - return ret; -} - -static OMX_ERRORTYPE SEC_DataReset(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 portIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - /* SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[portIndex]; */ - /* SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[portIndex]; */ - /* OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; */ - SEC_OMX_DATA *processData = &pSECComponent->processData[portIndex]; - - processData->dataLen = 0; - processData->remainDataLen = 0; - processData->usedDataLen = 0; - processData->nFlags = 0; - processData->timeStamp = 0; - - return ret; -} - -OMX_BOOL SEC_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_BOOL ret = OMX_FALSE; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; - SEC_OMX_DATA *inputData = &pSECComponent->processData[INPUT_PORT_INDEX]; - OMX_U32 copySize = 0; - OMX_BYTE checkInputStream = NULL; - OMX_U32 checkInputStreamLen = 0; - OMX_U32 checkedSize = 0; - OMX_BOOL flagEOS = OMX_FALSE; - OMX_BOOL flagEOF = OMX_FALSE; - OMX_BOOL previousFrameEOF = OMX_FALSE; - - if (inputUseBuffer->dataValid == OMX_TRUE) { - checkInputStream = inputUseBuffer->bufferHeader->pBuffer + inputUseBuffer->usedDataLen; - checkInputStreamLen = inputUseBuffer->remainDataLen; - - if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) && - (pSECComponent->bUseFlagEOF == OMX_FALSE)) { - pSECComponent->bUseFlagEOF = OMX_TRUE; - } - - if (inputData->dataLen == 0) { - previousFrameEOF = OMX_TRUE; - } else { - previousFrameEOF = OMX_FALSE; - } - if (pSECComponent->bUseFlagEOF == OMX_TRUE) { - flagEOF = OMX_TRUE; - checkedSize = checkInputStreamLen; - if (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) { - flagEOS = OMX_TRUE; - } - } else { - SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - int width = pSECPort->portDefinition.format.video.nFrameWidth; - int height = pSECPort->portDefinition.format.video.nFrameHeight; - int oneFrameSize = 0; - - if (pSECPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar) - oneFrameSize = (width * height * 3) / 2; - else if (pSECPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) - oneFrameSize = (width * height * 3) / 2; - else if (pSECPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV422Planar) - oneFrameSize = width * height * 2; - - if (previousFrameEOF == OMX_TRUE) { - if (checkInputStreamLen >= oneFrameSize) { - checkedSize = oneFrameSize; - flagEOF = OMX_TRUE; - } else { - flagEOF = OMX_FALSE; - } - } else { - if (checkInputStreamLen >= (oneFrameSize - inputData->dataLen)) { - checkedSize = oneFrameSize - inputData->dataLen; - flagEOF = OMX_TRUE; - } else { - flagEOF = OMX_FALSE; - } - } - - if ((flagEOF == OMX_FALSE) && (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS)) { - flagEOF = OMX_TRUE; - flagEOS = OMX_TRUE; - } - } - - if (flagEOF == OMX_TRUE) { - copySize = checkedSize; - SEC_OSAL_Log(SEC_LOG_TRACE, "sec_checkInputFrame : OMX_TRUE"); - } else { - copySize = checkInputStreamLen; - SEC_OSAL_Log(SEC_LOG_TRACE, "sec_checkInputFrame : OMX_FALSE"); - } - - if (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) - pSECComponent->bSaveFlagEOS = OMX_TRUE; - - if (((inputData->allocSize) - (inputData->dataLen)) >= copySize) { - SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - -#ifndef S5PC110_ENCODE_IN_DATA_BUFFER - if (copySize > 0) { - SEC_OSAL_Memcpy(inputData->dataBuffer + inputData->dataLen, checkInputStream, copySize); - } -#else - if (pSECPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) { - if (flagEOF == OMX_TRUE) { - OMX_U32 width, height; - - width = pSECPort->portDefinition.format.video.nFrameWidth; - height = pSECPort->portDefinition.format.video.nFrameHeight; - - SEC_OSAL_Log(SEC_LOG_TRACE, "inputData->specificBufferHeader.YVirAddr : 0x%x", inputData->specificBufferHeader.YVirAddr); - SEC_OSAL_Log(SEC_LOG_TRACE, "inputData->specificBufferHeader.CVirAddr : 0x%x", inputData->specificBufferHeader.CVirAddr); - - SEC_OSAL_Log(SEC_LOG_TRACE, "width:%d, height:%d, Ysize:%d", width, height, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height))); - SEC_OSAL_Log(SEC_LOG_TRACE, "width:%d, height:%d, Csize:%d", width, height, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2))); - - SEC_OSAL_Memcpy(inputData->specificBufferHeader.YVirAddr, checkInputStream, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height))); - SEC_OSAL_Memcpy(inputData->specificBufferHeader.CVirAddr, checkInputStream + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)), ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2))); - } - } -#endif - inputUseBuffer->dataLen -= copySize; - inputUseBuffer->remainDataLen -= copySize; - inputUseBuffer->usedDataLen += copySize; - - inputData->dataLen += copySize; - inputData->remainDataLen += copySize; - - if (previousFrameEOF == OMX_TRUE) { - inputData->timeStamp = inputUseBuffer->timeStamp; - inputData->nFlags = inputUseBuffer->nFlags; - } - - if (pSECComponent->bUseFlagEOF == OMX_TRUE) { - if (pSECComponent->bSaveFlagEOS == OMX_TRUE) { - inputData->nFlags |= OMX_BUFFERFLAG_EOS; - flagEOF = OMX_TRUE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - } - } else { - if ((checkedSize == checkInputStreamLen) && (pSECComponent->bSaveFlagEOS == OMX_TRUE)) { - inputData->nFlags |= OMX_BUFFERFLAG_EOS; - flagEOF = OMX_TRUE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - } else { - inputData->nFlags = (inputUseBuffer->nFlags & (~OMX_BUFFERFLAG_EOS)); - } - } - } else { - /*????????????????????????????????? Error ?????????????????????????????????*/ - SEC_DataReset(pOMXComponent, INPUT_PORT_INDEX); - flagEOF = OMX_FALSE; - } - - if (inputUseBuffer->remainDataLen == 0) { -#ifdef S5PC110_ENCODE_IN_DATA_BUFFER - if(flagEOF == OMX_FALSE) -#endif - SEC_InputBufferReturn(pOMXComponent); - } else { - inputUseBuffer->dataValid = OMX_TRUE; - } - } - - if (flagEOF == OMX_TRUE) { - if (pSECComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) { - pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_TRUE; - pSECComponent->checkTimeStamp.startTimeStamp = inputData->timeStamp; - pSECComponent->checkTimeStamp.nStartFlags = inputData->nFlags; - pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE; - } - - ret = OMX_TRUE; - } else { - ret = OMX_FALSE; - } - return ret; -} - -OMX_BOOL SEC_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_BOOL ret = OMX_FALSE; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; - SEC_OMX_DATA *outputData = &pSECComponent->processData[OUTPUT_PORT_INDEX]; - OMX_U32 copySize = 0; - - if (outputUseBuffer->dataValid == OMX_TRUE) { - if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE) { - if (pSECComponent->checkTimeStamp.startTimeStamp == outputData->timeStamp){ - pSECComponent->checkTimeStamp.startTimeStamp = -19761123; - pSECComponent->checkTimeStamp.nStartFlags = 0x0; - pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE; - pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; - } else { - SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX); - - ret = OMX_TRUE; - goto EXIT; - } - } else if (pSECComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) { - SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX); - - ret = OMX_TRUE; - goto EXIT; - } - - if (outputData->remainDataLen <= (outputUseBuffer->allocSize - outputUseBuffer->dataLen)) { - copySize = outputData->remainDataLen; - if (copySize > 0) - SEC_OSAL_Memcpy((outputUseBuffer->bufferHeader->pBuffer + outputUseBuffer->dataLen), - (outputData->dataBuffer + outputData->usedDataLen), - copySize); - - outputUseBuffer->dataLen += copySize; - outputUseBuffer->remainDataLen += copySize; - outputUseBuffer->nFlags = outputData->nFlags; - outputUseBuffer->timeStamp = outputData->timeStamp; - - ret = OMX_TRUE; - - /* reset outputData */ - SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX); - -#ifdef ONE_FRAME_OUTPUT /* only one frame output for Android */ - if ((outputUseBuffer->remainDataLen > 0) || - (outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS)) - SEC_OutputBufferReturn(pOMXComponent); -#else - if ((outputUseBuffer->remainDataLen > 0) || - ((outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) { - SEC_OutputBufferReturn(pOMXComponent); - } else { - outputUseBuffer->dataValid = OMX_TRUE; - } -#endif - } else { - SEC_OSAL_Log(SEC_LOG_ERROR, "output buffer is smaller than encoded data size Out Length"); - - copySize = outputUseBuffer->allocSize - outputUseBuffer->dataLen; - - SEC_OSAL_Memcpy((outputUseBuffer->bufferHeader->pBuffer + outputUseBuffer->dataLen), - (outputData->dataBuffer + outputData->usedDataLen), - copySize); - - outputUseBuffer->dataLen += copySize; - outputUseBuffer->remainDataLen += copySize; - outputUseBuffer->nFlags = 0; - outputUseBuffer->timeStamp = outputData->timeStamp; - - ret = OMX_FALSE; - - outputData->remainDataLen -= copySize; - outputData->usedDataLen += copySize; - - SEC_OutputBufferReturn(pOMXComponent); - } - } else { - ret = OMX_FALSE; - } - -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; - SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; - SEC_OMX_DATA *inputData = &pSECComponent->processData[INPUT_PORT_INDEX]; - SEC_OMX_DATA *outputData = &pSECComponent->processData[OUTPUT_PORT_INDEX]; - OMX_U32 copySize = 0; - - pSECComponent->remainOutputData = OMX_FALSE; - pSECComponent->reInputData = OMX_FALSE; - - FunctionIn(); - - while (!pSECComponent->bExitBufferProcessThread) { - SEC_OSAL_SleepMillisec(0); - - if (((pSECComponent->currentState == OMX_StatePause) || - (pSECComponent->currentState == OMX_StateIdle) || - (pSECComponent->transientState == SEC_OMX_TransStateLoadedToIdle) || - (pSECComponent->transientState == SEC_OMX_TransStateExecutingToIdle)) && - (pSECComponent->transientState != SEC_OMX_TransStateIdleToLoaded)&& - ((!CHECK_PORT_BEING_FLUSHED(secInputPort) && !CHECK_PORT_BEING_FLUSHED(secOutputPort)))) { - SEC_OSAL_SignalReset(pSECComponent->pauseEvent); - SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME); - } - - while (SEC_Check_BufferProcess_State(pSECComponent) && !pSECComponent->bExitBufferProcessThread) { - SEC_OSAL_SleepMillisec(0); - - SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); - if ((outputUseBuffer->dataValid != OMX_TRUE) && - (!CHECK_PORT_BEING_FLUSHED(secOutputPort))) { - SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); - ret = SEC_OutputBufferGetQueue(pSECComponent); - if ((ret == OMX_ErrorUndefined) || - (secInputPort->portState != OMX_StateIdle) || - (secOutputPort->portState != OMX_StateIdle)) { - break; - } - } else { - SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); - } - - if (pSECComponent->remainOutputData == OMX_FALSE) { - if (pSECComponent->reInputData == OMX_FALSE) { - SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex); - if ((SEC_Preprocessor_InputData(pOMXComponent) == OMX_FALSE) && - (!CHECK_PORT_BEING_FLUSHED(secInputPort))) { - SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); - ret = SEC_InputBufferGetQueue(pSECComponent); - break; - } - - SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); - } - - SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex); - SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); - ret = pSECComponent->sec_mfc_bufferProcess(pOMXComponent, inputData, outputData); -#ifdef S5PC110_ENCODE_IN_DATA_BUFFER - if (inputUseBuffer->remainDataLen == 0) - SEC_InputBufferReturn(pOMXComponent); - else - inputUseBuffer->dataValid = OMX_TRUE; -#endif - SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); - SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); - - if (ret == OMX_ErrorInputDataEncodeYet) - pSECComponent->reInputData = OMX_TRUE; - else - pSECComponent->reInputData = OMX_FALSE; - } - - SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); - - if (SEC_Postprocess_OutputData(pOMXComponent) == OMX_FALSE) - pSECComponent->remainOutputData = OMX_TRUE; - else - pSECComponent->remainOutputData = OMX_FALSE; - - SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); - } - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_VideoEncodeGetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR ComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - if (ComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - switch (nParamIndex) { - case OMX_IndexParamVideoInit: - { - OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure; - ret = SEC_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - portParam->nPorts = pSECComponent->portParam.nPorts; - portParam->nStartPortNumber = pSECComponent->portParam.nStartPortNumber; - ret = OMX_ErrorNone; - } - break; - case OMX_IndexParamVideoPortFormat: - { - OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = portFormat->nPortIndex; - OMX_U32 index = portFormat->nIndex; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; - OMX_U32 supportFormatNum = 0; - - ret = SEC_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((portIndex >= pSECComponent->portParam.nPorts)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - - if (portIndex == INPUT_PORT_INDEX) { - supportFormatNum = INPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1; - if (index > supportFormatNum) { - ret = OMX_ErrorNoMore; - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - portDefinition = &pSECPort->portDefinition; - - switch (index) { - case supportFormat_1: - portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; - portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar; - portFormat->xFramerate = portDefinition->format.video.xFramerate; - break; - case supportFormat_2: - portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; - portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; - portFormat->xFramerate = portDefinition->format.video.xFramerate; - break; - case supportFormat_3: - portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; - portFormat->eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress; - portFormat->xFramerate = portDefinition->format.video.xFramerate; - break; - } - } else if (portIndex == OUTPUT_PORT_INDEX) { - supportFormatNum = OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1; - if (index > supportFormatNum) { - ret = OMX_ErrorNoMore; - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - portDefinition = &pSECPort->portDefinition; - - portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat; - portFormat->eColorFormat = portDefinition->format.video.eColorFormat; - portFormat->xFramerate = portDefinition->format.video.xFramerate; - } - ret = OMX_ErrorNone; - } - break; - case OMX_IndexParamVideoBitrate: - { - OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure; - OMX_U32 portIndex = videoRateControl->nPortIndex; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; - - if ((portIndex != OUTPUT_PORT_INDEX)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } else { - pSECPort = &pSECComponent->pSECPort[portIndex]; - portDefinition = &pSECPort->portDefinition; - - videoRateControl->eControlRate = pSECPort->eControlRate; - videoRateControl->nTargetBitrate = portDefinition->format.video.nBitrate; - } - ret = OMX_ErrorNone; - } - break; - default: - { - ret = SEC_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure); - } - break; - } - -EXIT: - FunctionOut(); - - return ret; -} -OMX_ERRORTYPE SEC_OMX_VideoEncodeSetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR ComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - if (ComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - switch (nIndex) { - case OMX_IndexParamVideoPortFormat: - { - OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = portFormat->nPortIndex; - OMX_U32 index = portFormat->nIndex; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; - OMX_U32 supportFormatNum = 0; - - ret = SEC_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((portIndex >= pSECComponent->portParam.nPorts)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } else { - pSECPort = &pSECComponent->pSECPort[portIndex]; - portDefinition = &pSECPort->portDefinition; - - portDefinition->format.video.eColorFormat = portFormat->eColorFormat; - portDefinition->format.video.eCompressionFormat = portFormat->eCompressionFormat; - portDefinition->format.video.xFramerate = portFormat->xFramerate; - } - } - break; - case OMX_IndexParamVideoBitrate: - { - OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure; - OMX_U32 portIndex = videoRateControl->nPortIndex; - SEC_OMX_BASEPORT *pSECPort = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; - - if ((portIndex != OUTPUT_PORT_INDEX)) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } else { - pSECPort = &pSECComponent->pSECPort[portIndex]; - portDefinition = &pSECPort->portDefinition; - - pSECPort->eControlRate = videoRateControl->eControlRate; - portDefinition->format.video.nBitrate = videoRateControl->nTargetBitrate; - } - ret = OMX_ErrorNone; - } - break; - case OMX_IndexParamPortDefinition: - { - OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = - (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure; - ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pPortDefinition->nPortIndex == INPUT_PORT_INDEX) { - SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - OMX_U32 width = pSECInputPort->portDefinition.format.video.nFrameWidth; - OMX_U32 height = pSECInputPort->portDefinition.format.video.nFrameHeight; - SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - pSECOutputPort->portDefinition.format.video.nFrameWidth = width; - pSECOutputPort->portDefinition.format.video.nFrameHeight = height; - pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2; - SEC_OSAL_Log(SEC_LOG_TRACE, "pSECOutputPort->portDefinition.nBufferSize: %d", - pSECOutputPort->portDefinition.nBufferSize); - } - } - break; - default: - { - ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure); - } - break; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_VideoEncodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); - goto EXIT; - } - - ret = SEC_OMX_BaseComponent_Constructor(pOMXComponent); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); - goto EXIT; - } - - ret = SEC_OMX_Port_Constructor(pOMXComponent); - if (ret != OMX_ErrorNone) { - SEC_OMX_BaseComponent_Destructor(pOMXComponent); - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - - /* Input port */ - pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - pSECPort->portDefinition.nBufferCountActual = MAX_VIDEO_INPUTBUFFER_NUM; - pSECPort->portDefinition.nBufferCountMin = MAX_VIDEO_INPUTBUFFER_NUM; - pSECPort->portDefinition.nBufferSize = 0; - pSECPort->portDefinition.eDomain = OMX_PortDomainVideo; - - pSECPort->portDefinition.format.video.cMIMEType = SEC_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); - pSECPort->portDefinition.format.video.pNativeRender = 0; - pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; - - pSECPort->portDefinition.format.video.nFrameWidth = 0; - pSECPort->portDefinition.format.video.nFrameHeight= 0; - pSECPort->portDefinition.format.video.nStride = 0; - pSECPort->portDefinition.format.video.nSliceHeight = 0; - pSECPort->portDefinition.format.video.nBitrate = 64000; - pSECPort->portDefinition.format.video.xFramerate = (15 << 16); - pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; - pSECPort->portDefinition.format.video.pNativeWindow = NULL; - - /* Output port */ - pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - pSECPort->portDefinition.nBufferCountActual = MAX_VIDEO_OUTPUTBUFFER_NUM; - pSECPort->portDefinition.nBufferCountMin = MAX_VIDEO_OUTPUTBUFFER_NUM; - pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; - pSECPort->portDefinition.eDomain = OMX_PortDomainVideo; - - pSECPort->portDefinition.format.video.cMIMEType = SEC_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); - pSECPort->portDefinition.format.video.pNativeRender = 0; - pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; - - pSECPort->portDefinition.format.video.nFrameWidth = 0; - pSECPort->portDefinition.format.video.nFrameHeight= 0; - pSECPort->portDefinition.format.video.nStride = 0; - pSECPort->portDefinition.format.video.nSliceHeight = 0; - pSECPort->portDefinition.format.video.nBitrate = 64000; - pSECPort->portDefinition.format.video.xFramerate = (15 << 16); - pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; - pSECPort->portDefinition.format.video.pNativeWindow = NULL; - - pOMXComponent->UseBuffer = &SEC_OMX_UseBuffer; - pOMXComponent->AllocateBuffer = &SEC_OMX_AllocateBuffer; - pOMXComponent->FreeBuffer = &SEC_OMX_FreeBuffer; - pOMXComponent->ComponentTunnelRequest = &SEC_OMX_ComponentTunnelRequest; - - pSECComponent->sec_AllocateTunnelBuffer = &SEC_OMX_AllocateTunnelBuffer; - pSECComponent->sec_FreeTunnelBuffer = &SEC_OMX_FreeTunnelBuffer; - pSECComponent->sec_BufferProcess = &SEC_OMX_BufferProcess; - pSECComponent->sec_BufferReset = &SEC_BufferReset; - pSECComponent->sec_InputBufferReturn = &SEC_InputBufferReturn; - pSECComponent->sec_OutputBufferReturn = &SEC_OutputBufferReturn; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_VideoEncodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - int i = 0; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - for(i = 0; i < ALL_PORT_NUM; i++) { - pSECPort = &pSECComponent->pSECPort[i]; - SEC_OSAL_Free(pSECPort->portDefinition.format.video.cMIMEType); - pSECPort->portDefinition.format.video.cMIMEType = NULL; - } - - ret = SEC_OMX_Port_Destructor(pOMXComponent); - - ret = SEC_OMX_BaseComponent_Destructor(hComponent); - -EXIT: - FunctionOut(); - - return ret; -} diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.h b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.h deleted file mode 100644 index 93d2800..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Venc.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_VIDEO_ENCODE -#define SEC_OMX_VIDEO_ENCODE - -#include "OMX_Component.h" -#include "SEC_OMX_Def.h" -#include "SEC_OSAL_Queue.h" -#include "SEC_OMX_Baseport.h" - -#define MAX_VIDEO_INPUTBUFFER_NUM 5 -#define MAX_VIDEO_OUTPUTBUFFER_NUM 4 - -#define DEFAULT_FRAME_WIDTH 176 -#define DEFAULT_FRAME_HEIGHT 144 - -#define DEFAULT_VIDEO_INPUT_BUFFER_SIZE ALIGN_TO_8KB(ALIGN_TO_128B(DEFAULT_FRAME_WIDTH) * ALIGN_TO_32B(DEFAULT_FRAME_HEIGHT)) \ - + ALIGN_TO_8KB(ALIGN_TO_128B(DEFAULT_FRAME_WIDTH) * ALIGN_TO_32B(DEFAULT_FRAME_HEIGHT / 2)) - /* (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2 */ -#define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE DEFAULT_VIDEO_INPUT_BUFFER_SIZE - -#define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 3 -#define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX 1 - - -typedef struct -{ - void *pAddrY; - void *pAddrC; -} MFC_ENC_ADDR_INFO; - - -#ifdef __cplusplus -extern "C" { -#endif - -OMX_ERRORTYPE SEC_OMX_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 SEC_OMX_AllocateBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN OMX_U32 nSizeBytes); -OMX_ERRORTYPE SEC_OMX_FreeBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr); -OMX_ERRORTYPE SEC_OMX_AllocateTunnelBuffer( - SEC_OMX_BASEPORT *pOMXBasePort, - OMX_U32 nPortIndex); -OMX_ERRORTYPE SEC_OMX_FreeTunnelBuffer( - SEC_OMX_BASEPORT *pOMXBasePort, - OMX_U32 nPortIndex); -OMX_ERRORTYPE SEC_OMX_ComponentTunnelRequest( - OMX_IN OMX_HANDLETYPE hComp, - OMX_IN OMX_U32 nPort, - OMX_IN OMX_HANDLETYPE hTunneledComp, - OMX_IN OMX_U32 nTunneledPort, - OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup); -OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent); -OMX_ERRORTYPE SEC_OMX_VideoEncodeGetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR ComponentParameterStructure); -OMX_ERRORTYPE SEC_OMX_VideoEncodeSetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR ComponentParameterStructure); -OMX_ERRORTYPE SEC_OMX_VideoEncodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk deleted file mode 100644 index 0a469d4..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := \ - SEC_OMX_H264enc.c \ - library_register.c - -LOCAL_PRELINK_MODULE := false -LOCAL_MODULE := libOMX.SEC.AVC.Encoder.aries - -LOCAL_CFLAGS := - -LOCAL_ARM_MODE := arm - -LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc.aries libsecosal.aries libsecbasecomponent.aries libsecmfcencapi.aries -LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils - -LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ - $(SEC_OMX_INC)/sec \ - $(SEC_OMX_TOP)/sec_osal \ - $(SEC_OMX_TOP)/sec_omx_core \ - $(SEC_OMX_COMPONENT)/common \ - $(SEC_OMX_COMPONENT)/video/enc \ - -LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include - -include $(BUILD_SHARED_LIBRARY) diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c deleted file mode 100644 index 239649e..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c +++ /dev/null @@ -1,1029 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_H264enc.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include - -#include "SEC_OMX_Macros.h" -#include "SEC_OMX_Basecomponent.h" -#include "SEC_OMX_Baseport.h" -#include "SEC_OMX_Venc.h" -#include "library_register.h" -#include "SEC_OMX_H264enc.h" -#include "SsbSipMfcApi.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_H264_ENC" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -/* H.264 Encoder Supported Levels & profiles */ -SEC_OMX_VIDEO_PROFILELEVEL supportedAVCProfileLevels[] ={ - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1b}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel11}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel12}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel2}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel21}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel22}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel3}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel31}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel32}, - {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4}, - - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1b}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel11}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel12}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel13}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel2}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel21}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel22}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel3}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel31}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel32}, - {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel4}, - - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1b}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel11}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel12}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel13}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel2}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel21}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel22}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel3}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel31}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel32}, - {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4}}; - - -OMX_U32 OMXAVCProfileToProfileIDC(OMX_VIDEO_AVCPROFILETYPE profile) -{ - OMX_U32 ret = 0; //default OMX_VIDEO_AVCProfileMain - - if (profile == OMX_VIDEO_AVCProfileMain) - ret = 0; - else if (profile == OMX_VIDEO_AVCProfileHigh) - ret = 1; - else if (profile == OMX_VIDEO_AVCProfileBaseline) - ret = 2; - - return ret; -} - -OMX_U32 OMXAVCLevelToLevelIDC(OMX_VIDEO_AVCLEVELTYPE level) -{ - OMX_U32 ret = 40; //default OMX_VIDEO_AVCLevel4 - - if (level == OMX_VIDEO_AVCLevel1) - ret = 10; - else if (level == OMX_VIDEO_AVCLevel1b) - ret = 9; - else if (level == OMX_VIDEO_AVCLevel11) - ret = 11; - else if (level == OMX_VIDEO_AVCLevel12) - ret = 12; - else if (level == OMX_VIDEO_AVCLevel13) - ret = 13; - else if (level == OMX_VIDEO_AVCLevel2) - ret = 20; - else if (level == OMX_VIDEO_AVCLevel21) - ret = 21; - else if (level == OMX_VIDEO_AVCLevel22) - ret = 22; - else if (level == OMX_VIDEO_AVCLevel3) - ret = 30; - else if (level == OMX_VIDEO_AVCLevel31) - ret = 31; - else if (level == OMX_VIDEO_AVCLevel32) - ret = 32; - else if (level == OMX_VIDEO_AVCLevel4) - ret = 40; - - return ret; -} - -OMX_U8 *FindDelimiter(OMX_U8 *pBuffer, OMX_U32 size) -{ - int i; - - for (i = 0; i < size - 3; i++) { - if ((pBuffer[i] == 0x00) && - (pBuffer[i+1] == 0x00) && - (pBuffer[i+2] == 0x00) && - (pBuffer[i+3] == 0x01)) - return (pBuffer + i); - } - - return NULL; -} - -void H264PrintParams(SSBSIP_MFC_ENC_H264_PARAM h264Arg) -{ - SEC_OSAL_Log(SEC_LOG_TRACE, "SourceWidth : %d\n", h264Arg.SourceWidth); - SEC_OSAL_Log(SEC_LOG_TRACE, "SourceHeight : %d\n", h264Arg.SourceHeight); - SEC_OSAL_Log(SEC_LOG_TRACE, "ProfileIDC : %d\n", h264Arg.ProfileIDC); - SEC_OSAL_Log(SEC_LOG_TRACE, "LevelIDC : %d\n", h264Arg.LevelIDC); - SEC_OSAL_Log(SEC_LOG_TRACE, "IDRPeriod : %d\n", h264Arg.IDRPeriod); - SEC_OSAL_Log(SEC_LOG_TRACE, "NumberReferenceFrames : %d\n", h264Arg.NumberReferenceFrames); - SEC_OSAL_Log(SEC_LOG_TRACE, "NumberRefForPframes : %d\n", h264Arg.NumberRefForPframes); - SEC_OSAL_Log(SEC_LOG_TRACE, "SliceMode : %d\n", h264Arg.SliceMode); - SEC_OSAL_Log(SEC_LOG_TRACE, "SliceArgument : %d\n", h264Arg.SliceArgument); - SEC_OSAL_Log(SEC_LOG_TRACE, "NumberBFrames : %d\n", h264Arg.NumberBFrames); - SEC_OSAL_Log(SEC_LOG_TRACE, "LoopFilterDisable : %d\n", h264Arg.LoopFilterDisable); - SEC_OSAL_Log(SEC_LOG_TRACE, "LoopFilterAlphaC0Offset : %d\n", h264Arg.LoopFilterAlphaC0Offset); - SEC_OSAL_Log(SEC_LOG_TRACE, "LoopFilterBetaOffset : %d\n", h264Arg.LoopFilterBetaOffset); - SEC_OSAL_Log(SEC_LOG_TRACE, "SymbolMode : %d\n", h264Arg.SymbolMode); - SEC_OSAL_Log(SEC_LOG_TRACE, "PictureInterlace : %d\n", h264Arg.PictureInterlace); - SEC_OSAL_Log(SEC_LOG_TRACE, "Transform8x8Mode : %d\n", h264Arg.Transform8x8Mode); - SEC_OSAL_Log(SEC_LOG_TRACE, "RandomIntraMBRefresh : %d\n", h264Arg.RandomIntraMBRefresh); - SEC_OSAL_Log(SEC_LOG_TRACE, "PadControlOn : %d\n", h264Arg.PadControlOn); - SEC_OSAL_Log(SEC_LOG_TRACE, "LumaPadVal : %d\n", h264Arg.LumaPadVal); - SEC_OSAL_Log(SEC_LOG_TRACE, "CbPadVal : %d\n", h264Arg.CbPadVal); - SEC_OSAL_Log(SEC_LOG_TRACE, "CrPadVal : %d\n", h264Arg.CrPadVal); - SEC_OSAL_Log(SEC_LOG_TRACE, "EnableFRMRateControl : %d\n", h264Arg.EnableFRMRateControl); - SEC_OSAL_Log(SEC_LOG_TRACE, "EnableMBRateControl : %d\n", h264Arg.EnableMBRateControl); - SEC_OSAL_Log(SEC_LOG_TRACE, "FrameRate : %d\n", h264Arg.FrameRate); - SEC_OSAL_Log(SEC_LOG_TRACE, "Bitrate : %d\n", h264Arg.Bitrate); - SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp : %d\n", h264Arg.FrameQp); - SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMax : %d\n", h264Arg.QSCodeMax); - SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMin : %d\n", h264Arg.QSCodeMin); - SEC_OSAL_Log(SEC_LOG_TRACE, "CBRPeriodRf : %d\n", h264Arg.CBRPeriodRf); - SEC_OSAL_Log(SEC_LOG_TRACE, "DarkDisable : %d\n", h264Arg.DarkDisable); - SEC_OSAL_Log(SEC_LOG_TRACE, "SmoothDisable : %d\n", h264Arg.SmoothDisable); - SEC_OSAL_Log(SEC_LOG_TRACE, "StaticDisable : %d\n", h264Arg.StaticDisable); - SEC_OSAL_Log(SEC_LOG_TRACE, "ActivityDisable : %d\n", h264Arg.ActivityDisable); -} - -void Set_H264ENC_Param(SSBSIP_MFC_ENC_H264_PARAM *pH264Arg, SEC_OMX_BASECOMPONENT *pSECComponent) -{ - SEC_OMX_BASEPORT *pSECInputPort = NULL; - SEC_OMX_BASEPORT *pSECOutputPort = NULL; - SEC_H264ENC_HANDLE *pH264Enc = NULL; - - pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; - pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - - pH264Arg->codecType = H264_ENC; - pH264Arg->SourceWidth = pSECOutputPort->portDefinition.format.video.nFrameWidth; - pH264Arg->SourceHeight = pSECOutputPort->portDefinition.format.video.nFrameHeight; - pH264Arg->IDRPeriod = pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames + 1; - pH264Arg->SliceMode = 0; - pH264Arg->RandomIntraMBRefresh = 0; - pH264Arg->EnableFRMRateControl = 1; // 0: Disable, 1: Frame level RC - pH264Arg->Bitrate = pSECOutputPort->portDefinition.format.video.nBitrate; - pH264Arg->FrameQp = 20; - pH264Arg->FrameQp_P = 20; - pH264Arg->QSCodeMax = 30; - pH264Arg->QSCodeMin = 10; - pH264Arg->CBRPeriodRf = 100; - pH264Arg->PadControlOn = 0; // 0: disable, 1: enable - pH264Arg->LumaPadVal = 0; - pH264Arg->CbPadVal = 0; - pH264Arg->CrPadVal = 0; - - pH264Arg->ProfileIDC = OMXAVCProfileToProfileIDC(pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].eProfile); //0; //(OMX_VIDEO_AVCProfileMain) - pH264Arg->LevelIDC = OMXAVCLevelToLevelIDC(pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].eLevel); //40; //(OMX_VIDEO_AVCLevel4) - pH264Arg->FrameQp_B = 20; - pH264Arg->FrameRate = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16; - pH264Arg->SliceArgument = 0; // Slice mb/byte size number - pH264Arg->NumberBFrames = 0; // 0 ~ 2 - pH264Arg->NumberReferenceFrames = 1; - pH264Arg->NumberRefForPframes = 1; - pH264Arg->LoopFilterDisable = 1; // 1: Loop Filter Disable, 0: Filter Enable - pH264Arg->LoopFilterAlphaC0Offset = 0; - pH264Arg->LoopFilterBetaOffset = 0; - pH264Arg->SymbolMode = 0; // 0: CAVLC, 1: CABAC - pH264Arg->PictureInterlace = 0; - pH264Arg->Transform8x8Mode = 0; // 0: 4x4, 1: allow 8x8 - pH264Arg->EnableMBRateControl = 0; // 0: Disable, 1:MB level RC - pH264Arg->DarkDisable = 1; - pH264Arg->SmoothDisable = 1; - pH264Arg->StaticDisable = 1; - pH264Arg->ActivityDisable = 1; - - SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->eControlRate: 0x%x", pSECOutputPort->eControlRate); - switch (pSECOutputPort->eControlRate) { - case OMX_Video_ControlRateDisable: - /* TBD */ - break; - case OMX_Video_ControlRateVariable: - /* TBD */ - break; - default: - break; - } - - H264PrintParams(*pH264Arg); -} - -OMX_ERRORTYPE SEC_MFC_H264Enc_GetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR pComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - switch (nParamIndex) { - case OMX_IndexParamVideoAvc: - { - OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL; - SEC_H264ENC_HANDLE *pH264Enc = NULL; - - ret = SEC_OMX_Check_SizeVersion(pDstAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstAVCComponent->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; - pSrcAVCComponent = &pH264Enc->AVCComponent[pDstAVCComponent->nPortIndex]; - - SEC_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); - } - break; - case OMX_IndexParamStandardComponentRole: - { - OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure; - ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_H264_ENC_ROLE); - } - break; - case OMX_IndexParamVideoProfileLevelQuerySupported: - { - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure; - SEC_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL; - OMX_U32 maxProfileLevelNum = 0; - - ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pProfileLevel = supportedAVCProfileLevels; - maxProfileLevelNum = sizeof(supportedAVCProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL); - - if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) { - ret = OMX_ErrorNoMore; - goto EXIT; - } - - pProfileLevel += pDstProfileLevel->nProfileIndex; - pDstProfileLevel->eProfile = pProfileLevel->profile; - pDstProfileLevel->eLevel = pProfileLevel->level; - } - break; - case OMX_IndexParamVideoProfileLevelCurrent: - { - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure; - OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL; - SEC_H264ENC_HANDLE *pH264Enc = NULL; - - ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; - pSrcAVCComponent = &pH264Enc->AVCComponent[pDstProfileLevel->nPortIndex]; - - pDstProfileLevel->eProfile = pSrcAVCComponent->eProfile; - pDstProfileLevel->eLevel = pSrcAVCComponent->eLevel; - } - break; - case OMX_IndexParamVideoErrorCorrection: - { - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; - SEC_H264ENC_HANDLE *pH264Enc = NULL; - - ret = SEC_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; - pSrcErrorCorrectionType = &pH264Enc->errorCorrectionType[OUTPUT_PORT_INDEX]; - - pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; - pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; - pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; - pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; - pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; - } - break; - default: - ret = SEC_OMX_VideoEncodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); - break; - } -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_H264Enc_SetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - switch (nIndex) { - case OMX_IndexParamVideoAvc: - { - OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL; - OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure; - SEC_H264ENC_HANDLE *pH264Enc = NULL; - - ret = SEC_OMX_Check_SizeVersion(pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcAVCComponent->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; - pDstAVCComponent = &pH264Enc->AVCComponent[pSrcAVCComponent->nPortIndex]; - - SEC_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); - } - break; - case OMX_IndexParamStandardComponentRole: - { - OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; - - ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_H264_ENC_ROLE)) { - pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; - } else { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - } - break; - case OMX_IndexParamVideoProfileLevelCurrent: - { - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL; - SEC_H264ENC_HANDLE *pH264Enc = NULL; - - ret = SEC_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; - - pDstAVCComponent = &pH264Enc->AVCComponent[pSrcProfileLevel->nPortIndex]; - pDstAVCComponent->eProfile = pSrcProfileLevel->eProfile; - pDstAVCComponent->eLevel = pSrcProfileLevel->eLevel; - } - break; - case OMX_IndexParamVideoErrorCorrection: - { - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; - SEC_H264ENC_HANDLE *pH264Enc = NULL; - - ret = SEC_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; - pDstErrorCorrectionType = &pH264Enc->errorCorrectionType[OUTPUT_PORT_INDEX]; - - pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; - pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; - pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; - pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; - pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; - } - break; - default: - ret = SEC_OMX_VideoEncodeSetParameter(hComponent, nIndex, pComponentParameterStructure); - break; - } -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_H264Enc_SetConfig( - OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pComponentConfigStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pComponentConfigStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - switch (nIndex) { - default: - ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure); - break; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_H264Enc_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if ((hComponent == NULL) || (cRole == NULL)) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (nIndex == (MAX_COMPONENT_ROLE_NUM-1)) { - SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_H264_ENC_ROLE); - ret = OMX_ErrorNone; - } else { - ret = OMX_ErrorNoMore; - } - -EXIT: - FunctionOut(); - - return ret; -} - -/* MFC Init */ -OMX_ERRORTYPE SEC_MFC_H264Enc_Init(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_H264ENC_HANDLE *pH264Enc = NULL; - OMX_PTR hMFCHandle = NULL; - OMX_S32 returnCodec = 0; - - FunctionIn(); - - pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; - pH264Enc->hMFCH264Handle.bConfiguredMFC = OMX_FALSE; - pSECComponent->bUseFlagEOF = OMX_FALSE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - - /* MFC(Multi Function Codec) encoder and CMM(Codec Memory Management) driver open */ - hMFCHandle = (OMX_PTR)SsbSipMfcEncOpen(); - if (hMFCHandle == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - pH264Enc->hMFCH264Handle.hMFCHandle = hMFCHandle; - - Set_H264ENC_Param(&(pH264Enc->hMFCH264Handle.mfcVideoAvc), pSECComponent); - - returnCodec = SsbSipMfcEncInit(hMFCHandle, &(pH264Enc->hMFCH264Handle.mfcVideoAvc)); - if (returnCodec != MFC_RET_OK) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - - /* Allocate encoder's input buffer */ - returnCodec = SsbSipMfcEncGetInBuf(hMFCHandle, &(pH264Enc->hMFCH264Handle.inputInfo)); - if (returnCodec != MFC_RET_OK) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - - SEC_OSAL_Log(SEC_LOG_TRACE, "pH264Enc->hMFCH264Handle.inputInfo.YVirAddr : 0x%x", pH264Enc->hMFCH264Handle.inputInfo.YVirAddr); - SEC_OSAL_Log(SEC_LOG_TRACE, "pH264Enc->hMFCH264Handle.inputInfo.CVirAddr : 0x%x", pH264Enc->hMFCH264Handle.inputInfo.CVirAddr); - - pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YPhyAddr = pH264Enc->hMFCH264Handle.inputInfo.YPhyAddr; - pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CPhyAddr = pH264Enc->hMFCH264Handle.inputInfo.CPhyAddr; - pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YVirAddr = pH264Enc->hMFCH264Handle.inputInfo.YVirAddr; - pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CVirAddr = pH264Enc->hMFCH264Handle.inputInfo.CVirAddr; - pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YSize = pH264Enc->hMFCH264Handle.inputInfo.YSize; - pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CSize = pH264Enc->hMFCH264Handle.inputInfo.CSize; - - SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); - SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); - pH264Enc->hMFCH264Handle.indexTimestamp = 0; - -EXIT: - FunctionOut(); - - return ret; -} - -/* MFC Terminate */ -OMX_ERRORTYPE SEC_MFC_H264Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_H264ENC_HANDLE *pH264Enc = NULL; - OMX_PTR hMFCHandle = NULL; - - FunctionIn(); - - pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; - hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; - - if (hMFCHandle != NULL) { - SsbSipMfcEncClose(hMFCHandle); - hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle = NULL; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_H264_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_H264ENC_HANDLE *pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; - SSBSIP_MFC_ENC_INPUT_INFO *pInputInfo = &pH264Enc->hMFCH264Handle.inputInfo; - SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo; - SEC_OMX_BASEPORT *pSECPort = NULL; - MFC_ENC_ADDR_INFO addrInfo; - OMX_U32 oneFrameSize = pInputData->dataLen; - OMX_S32 returnCodec = 0; - - FunctionIn(); - - if (pH264Enc->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) { - returnCodec = SsbSipMfcEncGetOutBuf(pH264Enc->hMFCH264Handle.hMFCHandle, &outputInfo); - if (returnCodec != MFC_RET_OK) - { - SEC_OSAL_Log(SEC_LOG_TRACE, "%s - SsbSipMfcEncGetOutBuf Failed\n", __func__); - ret = OMX_ErrorUndefined; - goto EXIT; - } else { - char *p = NULL; - int iSpsSize = 0; - int iPpsSize = 0; - - p = FindDelimiter((OMX_U8 *)outputInfo.StrmVirAddr + 4, outputInfo.headerSize - 4); - - iSpsSize = (unsigned int)p - (unsigned int)outputInfo.StrmVirAddr; - pH264Enc->hMFCH264Handle.headerData.pHeaderSPS = (OMX_PTR)outputInfo.StrmVirAddr; - pH264Enc->hMFCH264Handle.headerData.SPSLen = iSpsSize; - - iPpsSize = outputInfo.headerSize - iSpsSize; - pH264Enc->hMFCH264Handle.headerData.pHeaderPPS = outputInfo.StrmVirAddr + iSpsSize; - pH264Enc->hMFCH264Handle.headerData.PPSLen = iPpsSize; - } - - /* SEC_OSAL_Memcpy((void*)(pOutputData->dataBuffer), (const void*)(outputInfo.StrmVirAddr), outputInfo.headerSize); */ - pOutputData->dataBuffer = outputInfo.StrmVirAddr; - pOutputData->allocSize = outputInfo.headerSize; - pOutputData->dataLen = outputInfo.headerSize; - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG; - pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; - - pH264Enc->hMFCH264Handle.bConfiguredMFC = OMX_TRUE; - - ret = OMX_ErrorNone; - goto EXIT; - } - - if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) && - (pSECComponent->bUseFlagEOF == OMX_FALSE)) { - pSECComponent->bUseFlagEOF = OMX_TRUE; - } - - pSECComponent->timeStamp[pH264Enc->hMFCH264Handle.indexTimestamp] = pInputData->timeStamp; - pSECComponent->nFlags[pH264Enc->hMFCH264Handle.indexTimestamp] = pInputData->nFlags; - SsbSipMfcEncSetConfig(pH264Enc->hMFCH264Handle.hMFCHandle, MFC_ENC_SETCONF_FRAME_TAG, &(pH264Enc->hMFCH264Handle.indexTimestamp)); - pH264Enc->hMFCH264Handle.indexTimestamp++; - if (pH264Enc->hMFCH264Handle.indexTimestamp >= MAX_TIMESTAMP) - pH264Enc->hMFCH264Handle.indexTimestamp = 0; - - if (oneFrameSize <= 0) { - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - - ret = OMX_ErrorNone; - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - if (pSECPort->portDefinition.format.video.eColorFormat == SEC_OMX_COLOR_FormatNV12PhysicalAddress) { -#define USE_FIMC_FRAME_BUFFER -#ifdef USE_FIMC_FRAME_BUFFER - SEC_OSAL_Memcpy(&addrInfo.pAddrY, pInputData->dataBuffer, sizeof(addrInfo.pAddrY)); - SEC_OSAL_Memcpy(&addrInfo.pAddrC, pInputData->dataBuffer + sizeof(addrInfo.pAddrY), sizeof(addrInfo.pAddrC)); - pInputInfo->YPhyAddr = addrInfo.pAddrY; - pInputInfo->CPhyAddr = addrInfo.pAddrC; - ret = SsbSipMfcEncSetInBuf(pH264Enc->hMFCH264Handle.hMFCHandle, pInputInfo); - if (ret != MFC_RET_OK) { - SEC_OSAL_Log(SEC_LOG_TRACE, "Error : SsbSipMfcEncSetInBuf() \n"); - ret = OMX_ErrorUndefined; - goto EXIT; - } -#else - OMX_U32 width, height; - - width = pSECPort->portDefinition.format.video.nFrameWidth; - height = pSECPort->portDefinition.format.video.nFrameHeight; - - SEC_OSAL_Memcpy(pInputInfo->YVirAddr, pInputData->dataBuffer, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height))); - SEC_OSAL_Memcpy(pInputInfo->CVirAddr, pInputData->dataBuffer + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)), ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2))); -#endif - } - - returnCodec = SsbSipMfcEncExe(pH264Enc->hMFCH264Handle.hMFCHandle); - if (returnCodec == MFC_RET_OK) { - OMX_S32 indexTimestamp = 0; - - returnCodec = SsbSipMfcEncGetOutBuf(pH264Enc->hMFCH264Handle.hMFCHandle, &outputInfo); - if ((SsbSipMfcEncGetConfig(pH264Enc->hMFCH264Handle.hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) || - (((indexTimestamp < 0) || (indexTimestamp > MAX_TIMESTAMP)))){ - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - } else { - pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp]; - pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp]; - } - - if (returnCodec == MFC_RET_OK) { - /** Fill Output Buffer **/ - pOutputData->dataBuffer = outputInfo.StrmVirAddr; - pOutputData->allocSize = outputInfo.dataSize; - pOutputData->dataLen = outputInfo.dataSize; - pOutputData->usedDataLen = 0; - - pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; - if (outputInfo.frameType == MFC_FRAME_TYPE_I_FRAME) - pOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; - - SEC_OSAL_Log(SEC_LOG_TRACE, "MFC Encode OK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - - ret = OMX_ErrorNone; - } - } - - if (returnCodec != MFC_RET_OK) { - SEC_OSAL_Log(SEC_LOG_ERROR, "In %s : SsbSipMfcEncExe OR SsbSipMfcEncGetOutBuf Failed!!!\n", __func__); - ret = OMX_ErrorUndefined; - } - -EXIT: - FunctionOut(); - - return ret; -} - -/* MFC Encode */ -OMX_ERRORTYPE SEC_MFC_H264Enc_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_H264ENC_HANDLE *pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; - SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - OMX_BOOL endOfFrame = OMX_FALSE; - OMX_BOOL flagEOS = OMX_FALSE; - - FunctionIn(); - - if ((!CHECK_PORT_ENABLED(pSECInputPort)) || (!CHECK_PORT_ENABLED(pSECOutputPort)) || - (!CHECK_PORT_POPULATED(pSECInputPort)) || (!CHECK_PORT_POPULATED(pSECOutputPort))) { - ret = OMX_ErrorNone; - goto EXIT; - } - if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) { - ret = OMX_ErrorNone; - goto EXIT; - } - - ret = SEC_MFC_H264_Encode(pOMXComponent, pInputData, pOutputData); - if (ret != OMX_ErrorNone) { - pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, ret, 0, NULL); - } else { - pInputData->usedDataLen += pInputData->dataLen; - pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen; - pInputData->dataLen -= pInputData->usedDataLen; - pInputData->usedDataLen = 0; - - /* pOutputData->usedDataLen = 0; */ - pOutputData->remainDataLen = pOutputData->dataLen - pOutputData->usedDataLen; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - SEC_H264ENC_HANDLE *pH264Enc = NULL; - int i = 0; - - FunctionIn(); - - if ((hComponent == NULL) || (componentName == NULL)) { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); - goto EXIT; - } - if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_H264_ENC, componentName) != 0) { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__); - goto EXIT; - } - - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_VideoEncodeComponentInit(pOMXComponent); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pSECComponent->codecType = HW_VIDEO_CODEC; - - pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); - if (pSECComponent->componentName == NULL) { - SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent); - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - SEC_OSAL_Memset(pSECComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); - - pH264Enc = SEC_OSAL_Malloc(sizeof(SEC_H264ENC_HANDLE)); - if (pH264Enc == NULL) { - SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent); - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); - goto EXIT; - } - SEC_OSAL_Memset(pH264Enc, 0, sizeof(SEC_H264ENC_HANDLE)); - pSECComponent->hCodecHandle = (OMX_HANDLETYPE)pH264Enc; - - SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_H264_ENC); - /* Set componentVersion */ - pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; - pSECComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; - pSECComponent->componentVersion.s.nRevision = REVISION_NUMBER; - pSECComponent->componentVersion.s.nStep = STEP_NUMBER; - /* Set specVersion */ - pSECComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; - pSECComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; - pSECComponent->specVersion.s.nRevision = REVISION_NUMBER; - pSECComponent->specVersion.s.nStep = STEP_NUMBER; - - /* Android CapabilityFlags */ - pSECComponent->capabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_FALSE; - pSECComponent->capabilityFlags.iOMXComponentSupportsPartialFrames = OMX_FALSE; - pSECComponent->capabilityFlags.iOMXComponentUsesNALStartCodes = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentUsesFullAVCFrames = OMX_TRUE; - - /* Input port */ - pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; - pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; - pSECPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ - pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; - SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); - pSECPort->portDefinition.format.video.eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress; - pSECPort->portDefinition.bEnabled = OMX_TRUE; - - /* Output port */ - pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; - pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; - pSECPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ - pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; - SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/avc"); - pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; - pSECPort->portDefinition.bEnabled = OMX_TRUE; - - for(i = 0; i < ALL_PORT_NUM; i++) { - INIT_SET_SIZE_VERSION(&pH264Enc->AVCComponent[i], OMX_VIDEO_PARAM_AVCTYPE); - pH264Enc->AVCComponent[i].nPortIndex = i; - pH264Enc->AVCComponent[i].eProfile = OMX_VIDEO_AVCProfileBaseline; - pH264Enc->AVCComponent[i].eLevel = OMX_VIDEO_AVCLevel31; - } - - pOMXComponent->GetParameter = &SEC_MFC_H264Enc_GetParameter; - pOMXComponent->SetParameter = &SEC_MFC_H264Enc_SetParameter; - pOMXComponent->SetConfig = &SEC_MFC_H264Enc_SetConfig; - pOMXComponent->ComponentRoleEnum = &SEC_MFC_H264Enc_ComponentRoleEnum; - pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit; - - pSECComponent->sec_mfc_componentInit = &SEC_MFC_H264Enc_Init; - pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_H264Enc_Terminate; - pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_H264Enc_bufferProcess; - pSECComponent->sec_checkInputFrame = NULL; - - pSECComponent->currentState = OMX_StateLoaded; - - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_H264ENC_HANDLE *pH264Dec = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - SEC_OSAL_Free(pSECComponent->componentName); - pSECComponent->componentName = NULL; - - pH264Dec = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; - if (pH264Dec != NULL) { - SEC_OSAL_Free(pH264Dec); - pH264Dec = pSECComponent->hCodecHandle = NULL; - } - - ret = SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.h b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.h deleted file mode 100644 index 80f6260..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_H264enc.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_H264_ENC_COMPONENT -#define SEC_OMX_H264_ENC_COMPONENT - -#include "SEC_OMX_Def.h" -#include "OMX_Component.h" -#include "OMX_Video.h" -#include "SsbSipMfcApi.h" - - -typedef struct _EXTRA_DATA -{ - OMX_PTR pHeaderSPS; - OMX_U32 SPSLen; - OMX_PTR pHeaderPPS; - OMX_U32 PPSLen; -} EXTRA_DATA; - -typedef struct _SEC_MFC_H264ENC_HANDLE -{ - OMX_HANDLETYPE hMFCHandle; - SSBSIP_MFC_ENC_H264_PARAM mfcVideoAvc; - SSBSIP_MFC_ENC_INPUT_INFO inputInfo; -/* SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo; */ - OMX_U32 indexTimestamp; - OMX_BOOL bConfiguredMFC; - EXTRA_DATA headerData; -} SEC_MFC_H264ENC_HANDLE; - -typedef struct _SEC_H264ENC_HANDLE -{ - /* OMX Codec specific */ - OMX_VIDEO_PARAM_AVCTYPE AVCComponent[ALL_PORT_NUM]; - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE errorCorrectionType[ALL_PORT_NUM]; - - /* SEC MFC Codec specific */ - SEC_MFC_H264ENC_HANDLE hMFCH264Handle; -} SEC_H264ENC_HANDLE; - -#ifdef __cplusplus -extern "C" { -#endif - -OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName); -OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent); - -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c deleted file mode 100644 index ee1ea0a..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 library_register.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include -#include - -#include "SEC_OSAL_Memory.h" -#include "SEC_OSAL_ETC.h" -#include "library_register.h" -#include "SEC_OSAL_Log.h" - - -OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents) -{ - FunctionIn(); - - if (secComponents == NULL) - goto EXIT; - - /* component 1 - video decoder H.264 */ - SEC_OSAL_Strcpy(secComponents[0]->componentName, SEC_OMX_COMPOMENT_H264_ENC); - SEC_OSAL_Strcpy(secComponents[0]->roles[0], SEC_OMX_COMPOMENT_H264_ENC_ROLE); - secComponents[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM; - -EXIT: - FunctionOut(); - - return MAX_COMPONENT_NUM; -} - diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.h b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.h deleted file mode 100644 index 71397ef..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 library_register.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_H264_REG -#define SEC_OMX_H264_REG - -#include "SEC_OMX_Def.h" -#include "OMX_Component.h" -#include "SEC_OMX_Component_Register.h" - - -#define OSCL_EXPORT_REF __attribute__((visibility("default"))) -#define MAX_COMPONENT_NUM 1 -#define MAX_COMPONENT_ROLE_NUM 1 - -/* H.264 */ -#define SEC_OMX_COMPOMENT_H264_ENC "OMX.SEC.AVC.Encoder" -#define SEC_OMX_COMPOMENT_H264_ENC_ROLE "video_encoder.avc" - - -#ifdef __cplusplus -extern "C" { -#endif - -OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents); - -#ifdef __cplusplus -}; -#endif - -#endif - diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk deleted file mode 100644 index 979c34a..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := \ - SEC_OMX_Mpeg4enc.c \ - library_register.c - -LOCAL_PRELINK_MODULE := false -LOCAL_MODULE := libOMX.SEC.M4V.Encoder.aries - -LOCAL_CFLAGS := - -LOCAL_ARM_MODE := arm - -LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc.aries libsecosal.aries libsecbasecomponent.aries libsecmfcencapi.aries -LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils - -LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ - $(SEC_OMX_INC)/sec \ - $(SEC_OMX_TOP)/sec_osal \ - $(SEC_OMX_TOP)/sec_omx_core \ - $(SEC_OMX_COMPONENT)/common \ - $(SEC_OMX_COMPONENT)/video/enc - -LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include - -include $(BUILD_SHARED_LIBRARY) diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c deleted file mode 100644 index 0596c25..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c +++ /dev/null @@ -1,1205 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Mpeg4enc.c - * @brief - * @author Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - - -#include -#include -#include - -#include "SEC_OMX_Macros.h" -#include "SEC_OMX_Basecomponent.h" -#include "SEC_OMX_Baseport.h" -#include "SEC_OMX_Venc.h" -#include "library_register.h" -#include "SEC_OMX_Mpeg4enc.h" -#include "SsbSipMfcApi.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_MPEG4_ENC" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -/* MPEG4 Encoder Supported Levels & profiles */ -SEC_OMX_VIDEO_PROFILELEVEL supportedMPEG4ProfileLevels[] ={ - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0b}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level2}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level3}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4a}, - {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level5}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0b}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level1}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level2}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level3}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4a}, - {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level5}}; - -/* H.263 Encoder Supported Levels & profiles */ -SEC_OMX_VIDEO_PROFILELEVEL supportedH263ProfileLevels[] = { - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level10}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level20}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level30}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level40}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level45}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level50}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level60}, - {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level70}}; - -OMX_U32 OMXMpeg4ProfileToMFCProfile(OMX_VIDEO_MPEG4PROFILETYPE profile) -{ - OMX_U32 ret; - - switch (profile) { - case OMX_VIDEO_MPEG4ProfileSimple: - ret = 0; - break; - case OMX_VIDEO_MPEG4ProfileAdvancedSimple: - ret = 1; - break; - default: - ret = 0; - }; - - return ret; -} -OMX_U32 OMXMpeg4LevelToMFCLevel(OMX_VIDEO_MPEG4LEVELTYPE level) -{ - OMX_U32 ret; - - switch (level) { - case OMX_VIDEO_MPEG4Level0: - ret = 0; - break; - case OMX_VIDEO_MPEG4Level0b: - ret = 9; - break; - case OMX_VIDEO_MPEG4Level1: - ret = 1; - break; - case OMX_VIDEO_MPEG4Level2: - ret = 2; - break; - case OMX_VIDEO_MPEG4Level3: - ret = 3; - break; - case OMX_VIDEO_MPEG4Level4: - case OMX_VIDEO_MPEG4Level4a: - ret = 4; - break; - case OMX_VIDEO_MPEG4Level5: - ret = 5; - break; - default: - ret = 0; - }; - - return ret; -} - -void Mpeg4PrintParams(SSBSIP_MFC_ENC_MPEG4_PARAM mpeg4Param) -{ - SEC_OSAL_Log(SEC_LOG_TRACE, "SourceWidth : %d\n", mpeg4Param.SourceWidth); - SEC_OSAL_Log(SEC_LOG_TRACE, "SourceHeight : %d\n", mpeg4Param.SourceHeight); - SEC_OSAL_Log(SEC_LOG_TRACE, "IDRPeriod : %d\n", mpeg4Param.IDRPeriod); - SEC_OSAL_Log(SEC_LOG_TRACE, "SliceMode : %d\n", mpeg4Param.SliceMode); - SEC_OSAL_Log(SEC_LOG_TRACE, "RandomIntraMBRefresh : %d\n", mpeg4Param.RandomIntraMBRefresh); - SEC_OSAL_Log(SEC_LOG_TRACE, "EnableFRMRateControl : %d\n", mpeg4Param.EnableFRMRateControl); - SEC_OSAL_Log(SEC_LOG_TRACE, "Bitrate : %d\n", mpeg4Param.Bitrate); - SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp : %d\n", mpeg4Param.FrameQp); - SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp_P : %d\n", mpeg4Param.FrameQp_P); - SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMax : %d\n", mpeg4Param.QSCodeMax); - SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMin : %d\n", mpeg4Param.QSCodeMin); - SEC_OSAL_Log(SEC_LOG_TRACE, "CBRPeriodRf : %d\n", mpeg4Param.CBRPeriodRf); - SEC_OSAL_Log(SEC_LOG_TRACE, "PadControlOn : %d\n", mpeg4Param.PadControlOn); - SEC_OSAL_Log(SEC_LOG_TRACE, "LumaPadVal : %d\n", mpeg4Param.LumaPadVal); - SEC_OSAL_Log(SEC_LOG_TRACE, "CbPadVal : %d\n", mpeg4Param.CbPadVal); - SEC_OSAL_Log(SEC_LOG_TRACE, "CrPadVal : %d\n", mpeg4Param.CrPadVal); - - /* MPEG4 specific parameters */ - SEC_OSAL_Log(SEC_LOG_TRACE, "ProfileIDC : %d\n", mpeg4Param.ProfileIDC); - SEC_OSAL_Log(SEC_LOG_TRACE, "LevelIDC : %d\n", mpeg4Param.LevelIDC); - SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp_B : %d\n", mpeg4Param.FrameQp_B); - SEC_OSAL_Log(SEC_LOG_TRACE, "TimeIncreamentRes : %d\n", mpeg4Param.TimeIncreamentRes); - SEC_OSAL_Log(SEC_LOG_TRACE, "VopTimeIncreament : %d\n", mpeg4Param.VopTimeIncreament); - SEC_OSAL_Log(SEC_LOG_TRACE, "SliceArgument : %d\n", mpeg4Param.SliceArgument); - SEC_OSAL_Log(SEC_LOG_TRACE, "NumberBFrames : %d\n", mpeg4Param.NumberBFrames); - SEC_OSAL_Log(SEC_LOG_TRACE, "DisableQpelME : %d\n", mpeg4Param.DisableQpelME); -} - -void H263PrintParams(SSBSIP_MFC_ENC_H263_PARAM h263Param) -{ - SEC_OSAL_Log(SEC_LOG_TRACE, "SourceWidth : %d\n", h263Param.SourceWidth); - SEC_OSAL_Log(SEC_LOG_TRACE, "SourceHeight : %d\n", h263Param.SourceHeight); - SEC_OSAL_Log(SEC_LOG_TRACE, "IDRPeriod : %d\n", h263Param.IDRPeriod); - SEC_OSAL_Log(SEC_LOG_TRACE, "SliceMode : %d\n", h263Param.SliceMode); - SEC_OSAL_Log(SEC_LOG_TRACE, "RandomIntraMBRefresh : %d\n", h263Param.RandomIntraMBRefresh); - SEC_OSAL_Log(SEC_LOG_TRACE, "EnableFRMRateControl : %d\n", h263Param.EnableFRMRateControl); - SEC_OSAL_Log(SEC_LOG_TRACE, "Bitrate : %d\n", h263Param.Bitrate); - SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp : %d\n", h263Param.FrameQp); - SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp_P : %d\n", h263Param.FrameQp_P); - SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMax : %d\n", h263Param.QSCodeMax); - SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMin : %d\n", h263Param.QSCodeMin); - SEC_OSAL_Log(SEC_LOG_TRACE, "CBRPeriodRf : %d\n", h263Param.CBRPeriodRf); - SEC_OSAL_Log(SEC_LOG_TRACE, "PadControlOn : %d\n", h263Param.PadControlOn); - SEC_OSAL_Log(SEC_LOG_TRACE, "LumaPadVal : %d\n", h263Param.LumaPadVal); - SEC_OSAL_Log(SEC_LOG_TRACE, "CbPadVal : %d\n", h263Param.CbPadVal); - SEC_OSAL_Log(SEC_LOG_TRACE, "CrPadVal : %d\n", h263Param.CrPadVal); - - /* H.263 specific parameters */ - SEC_OSAL_Log(SEC_LOG_TRACE, "FrameRate : %d\n", h263Param.FrameRate); -} - -void Set_Mpeg4Enc_Param(SSBSIP_MFC_ENC_MPEG4_PARAM *pMpeg4Param, SEC_OMX_BASECOMPONENT *pSECComponent) -{ - SEC_OMX_BASEPORT *pSECInputPort = NULL; - SEC_OMX_BASEPORT *pSECOutputPort = NULL; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - - pMpeg4Param->codecType = MPEG4_ENC; - pMpeg4Param->SourceWidth = pSECOutputPort->portDefinition.format.video.nFrameWidth; - pMpeg4Param->SourceHeight = pSECOutputPort->portDefinition.format.video.nFrameHeight; - pMpeg4Param->IDRPeriod = pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1; - pMpeg4Param->SliceMode = 0; - pMpeg4Param->RandomIntraMBRefresh = 0; - pMpeg4Param->EnableFRMRateControl = 1; /* 0: disable, 1: enable */ - pMpeg4Param->Bitrate = pSECOutputPort->portDefinition.format.video.nBitrate; - pMpeg4Param->FrameQp = 20; - pMpeg4Param->FrameQp_P = 20; - pMpeg4Param->QSCodeMax = 30; - pMpeg4Param->QSCodeMin = 10; - pMpeg4Param->CBRPeriodRf = 10; - pMpeg4Param->PadControlOn = 0; /* 0: Use boundary pixel, 1: Use the below setting value */ - pMpeg4Param->LumaPadVal = 0; - pMpeg4Param->CbPadVal = 0; - pMpeg4Param->CrPadVal = 0; - - pMpeg4Param->ProfileIDC = OMXMpeg4ProfileToMFCProfile(pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].eProfile); - pMpeg4Param->LevelIDC = OMXMpeg4LevelToMFCLevel(pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].eLevel); - pMpeg4Param->FrameQp_B = 20; - pMpeg4Param->TimeIncreamentRes = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16; - pMpeg4Param->VopTimeIncreament = 1; - pMpeg4Param->SliceArgument = 0; /* MB number or byte number */ - pMpeg4Param->NumberBFrames = 0; /* 0(not used) ~ 2 */ - pMpeg4Param->DisableQpelME = 1; - - SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->eControlRate: 0x%x", pSECOutputPort->eControlRate); - switch (pSECOutputPort->eControlRate) { - case OMX_Video_ControlRateDisable: - /* TBD */ - break; - case OMX_Video_ControlRateVariable: - /* TBD */ - break; - default: - break; - } - - Mpeg4PrintParams(*pMpeg4Param); -} - -void Set_H263Enc_Param(SSBSIP_MFC_ENC_H263_PARAM *pH263Param, SEC_OMX_BASECOMPONENT *pSECComponent) -{ - SEC_OMX_BASEPORT *pSECInputPort = NULL; - SEC_OMX_BASEPORT *pSECOutputPort = NULL; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - - pH263Param->codecType = H263_ENC; - pH263Param->SourceWidth = pSECOutputPort->portDefinition.format.video.nFrameWidth; - pH263Param->SourceHeight = pSECOutputPort->portDefinition.format.video.nFrameHeight; - pH263Param->IDRPeriod = pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1; - pH263Param->SliceMode = 0; - pH263Param->RandomIntraMBRefresh = 0; - pH263Param->EnableFRMRateControl = 1; /* 0: disable, 1: enable */ - pH263Param->Bitrate = pSECOutputPort->portDefinition.format.video.nBitrate; - pH263Param->FrameQp = 20; - pH263Param->FrameQp_P = 20; - pH263Param->QSCodeMax = 30; - pH263Param->QSCodeMin = 10; - pH263Param->CBRPeriodRf = 10; - pH263Param->PadControlOn = 0; /* 0: Use boundary pixel, 1: Use the below setting value */ - pH263Param->LumaPadVal = 0; - pH263Param->CbPadVal = 0; - pH263Param->CrPadVal = 0; - - pH263Param->FrameRate = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16; - - SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->eControlRate: 0x%x", pSECOutputPort->eControlRate); - switch (pSECOutputPort->eControlRate) { - case OMX_Video_ControlRateDisable: - /* TBD */ - break; - case OMX_Video_ControlRateVariable: - /* TBD */ - break; - default: - break; - } - - H263PrintParams(*pH263Param); -} - -OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_GetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR pComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - switch (nParamIndex) { - case OMX_IndexParamVideoMpeg4: - { - OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - - ret = SEC_OMX_Check_SizeVersion(pDstMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstMpeg4Param->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - pSrcMpeg4Param = &pMpeg4Enc->mpeg4Component[pDstMpeg4Param->nPortIndex]; - - SEC_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); - } - break; - case OMX_IndexParamVideoH263: - { - OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - - ret = SEC_OMX_Check_SizeVersion(pDstH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstH263Param->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - pSrcH263Param = &pMpeg4Enc->h263Component[pDstH263Param->nPortIndex]; - - SEC_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); - } - break; - case OMX_IndexParamStandardComponentRole: - { - OMX_S32 codecType; - OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure; - - ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - codecType = ((SEC_MPEG4ENC_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType; - if (codecType == CODEC_TYPE_MPEG4) - SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_MPEG4_ENC_ROLE); - else - SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_H263_ENC_ROLE); - } - break; - case OMX_IndexParamVideoProfileLevelQuerySupported: - { - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; - SEC_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL; - OMX_U32 maxProfileLevelNum = 0; - OMX_S32 codecType; - - ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - codecType = ((SEC_MPEG4ENC_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType; - if (codecType == CODEC_TYPE_MPEG4) { - pProfileLevel = supportedMPEG4ProfileLevels; - maxProfileLevelNum = sizeof(supportedMPEG4ProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL); - } else { - pProfileLevel = supportedH263ProfileLevels; - maxProfileLevelNum = sizeof(supportedH263ProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL); - } - - if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) { - ret = OMX_ErrorNoMore; - goto EXIT; - } - - pProfileLevel += pDstProfileLevel->nProfileIndex; - pDstProfileLevel->eProfile = pProfileLevel->profile; - pDstProfileLevel->eLevel = pProfileLevel->level; - } - break; - case OMX_IndexParamVideoProfileLevelCurrent: - { - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL; - OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - OMX_S32 codecType; - - ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - codecType = pMpeg4Enc->hMFCMpeg4Handle.codecType; - if (codecType == CODEC_TYPE_MPEG4) { - pSrcMpeg4Param = &pMpeg4Enc->mpeg4Component[pDstProfileLevel->nPortIndex]; - pDstProfileLevel->eProfile = pSrcMpeg4Param->eProfile; - pDstProfileLevel->eLevel = pSrcMpeg4Param->eLevel; - } else { - pSrcH263Param = &pMpeg4Enc->h263Component[pDstProfileLevel->nPortIndex]; - pDstProfileLevel->eProfile = pSrcH263Param->eProfile; - pDstProfileLevel->eLevel = pSrcH263Param->eLevel; - } - } - break; - case OMX_IndexParamVideoErrorCorrection: - { - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - - ret = SEC_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pDstErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - pSrcErrorCorrectionType = &pMpeg4Enc->errorCorrectionType[OUTPUT_PORT_INDEX]; - - pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; - pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; - pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; - pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; - pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; - } - break; - default: - ret = SEC_OMX_VideoEncodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); - break; - } -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_SetParameter( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentParameterStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pComponentParameterStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - switch (nIndex) { - case OMX_IndexParamVideoMpeg4: - { - OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL; - OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - - ret = SEC_OMX_Check_SizeVersion(pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcMpeg4Param->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - pDstMpeg4Param = &pMpeg4Enc->mpeg4Component[pSrcMpeg4Param->nPortIndex]; - - SEC_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); - } - break; - case OMX_IndexParamVideoH263: - { - OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL; - OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - - ret = SEC_OMX_Check_SizeVersion(pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcH263Param->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - pDstH263Param = &pMpeg4Enc->h263Component[pSrcH263Param->nPortIndex]; - - SEC_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); - } - break; - case OMX_IndexParamStandardComponentRole: - { - OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; - - ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { - ret = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_MPEG4_ENC_ROLE)) { - pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; - //((SEC_MPEG4ENC_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_MPEG4; - } else if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_H263_ENC_ROLE)) { - pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; - //((SEC_MPEG4ENC_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_H263; - } else { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - } - break; - case OMX_IndexParamVideoProfileLevelCurrent: - { - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL; - OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - OMX_S32 codecType; - - ret = SEC_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - codecType = pMpeg4Enc->hMFCMpeg4Handle.codecType; - if (codecType == CODEC_TYPE_MPEG4) { - /* - * To do: Check validity of profile & level parameters - */ - - pDstMpeg4Param = &pMpeg4Enc->mpeg4Component[pSrcProfileLevel->nPortIndex]; - pDstMpeg4Param->eProfile = pSrcProfileLevel->eProfile; - pDstMpeg4Param->eLevel = pSrcProfileLevel->eLevel; - } else { - /* - * To do: Check validity of profile & level parameters - */ - - pDstH263Param = &pMpeg4Enc->h263Component[pSrcProfileLevel->nPortIndex]; - pDstH263Param->eProfile = pSrcProfileLevel->eProfile; - pDstH263Param->eLevel = pSrcProfileLevel->eLevel; - } - } - break; - case OMX_IndexParamVideoErrorCorrection: - { - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - - ret = SEC_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - if (pSrcErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - pDstErrorCorrectionType = &pMpeg4Enc->errorCorrectionType[OUTPUT_PORT_INDEX]; - - pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; - pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; - pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; - pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; - pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; - } - break; - default: - ret = SEC_OMX_VideoEncodeSetParameter(hComponent, nIndex, pComponentParameterStructure); - break; - } -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_SetConfig( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentConfigStructure) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - - FunctionIn(); - - if (hComponent == NULL || pComponentConfigStructure == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid) { - ret = OMX_ErrorInvalidState; - goto EXIT; - } - - switch (nIndex) { - default: - ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure); - break; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_ComponentRoleEnum( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_U8 *cRole, - OMX_IN OMX_U32 nIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - OMX_S32 codecType; - - FunctionIn(); - - if ((hComponent == NULL) || (cRole == NULL)) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (nIndex != (MAX_COMPONENT_ROLE_NUM - 1)) { - ret = OMX_ErrorNoMore; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - if (pOMXComponent->pComponentPrivate == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pSECComponent->currentState == OMX_StateInvalid ) { - ret = OMX_StateInvalid; - goto EXIT; - } - - codecType = ((SEC_MPEG4ENC_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType; - if (codecType == CODEC_TYPE_MPEG4) - SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_MPEG4_ENC_ROLE); - else - SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_H263_ENC_ROLE); - -EXIT: - FunctionOut(); - - return ret; -} - -/* MFC Init */ -OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_Init(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *pSECPort = NULL; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - OMX_HANDLETYPE hMFCHandle = NULL; - OMX_S32 returnCodec = 0; - - FunctionIn(); - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC = OMX_FALSE; - pSECComponent->bUseFlagEOF = OMX_FALSE; - pSECComponent->bSaveFlagEOS = OMX_FALSE; - - /* MFC(Multi Format Codec) encoder and CMM(Codec Memory Management) driver open */ - hMFCHandle = SsbSipMfcEncOpen(); - if (hMFCHandle == NULL) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle = hMFCHandle; - - /* set MFC ENC VIDEO PARAM and initialize MFC encoder instance */ - if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) { - Set_Mpeg4Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.mpeg4MFCParam), pSECComponent); - returnCodec = SsbSipMfcEncInit(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.mpeg4MFCParam)); - } else { - Set_H263Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam), pSECComponent); - returnCodec = SsbSipMfcEncInit(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam)); - } - if (returnCodec != MFC_RET_OK) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - - /* allocate encoder's input buffer */ - returnCodec = SsbSipMfcEncGetInBuf(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.inputInfo)); - if (returnCodec != MFC_RET_OK) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - - pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YPhyAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YPhyAddr; - pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CPhyAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CPhyAddr; - pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YVirAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr; - pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CVirAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr; - pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YSize = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YSize; - pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CSize = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CSize; - - SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); - SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); - pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp = 0; - -EXIT: - FunctionOut(); - - return ret; -} - -/* MFC Terminate */ -OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - OMX_HANDLETYPE hMFCHandle = NULL; - - FunctionIn(); - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; - - if (hMFCHandle != NULL) { - SsbSipMfcEncClose(hMFCHandle); - pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle = NULL; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_MFC_Mpeg4_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - OMX_HANDLETYPE hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; - SSBSIP_MFC_ENC_INPUT_INFO *pInputInfo = &(pMpeg4Enc->hMFCMpeg4Handle.inputInfo); - SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo; - SEC_OMX_BASEPORT *pSECPort = NULL; - MFC_ENC_ADDR_INFO addrInfo; - OMX_U32 oneFrameSize = pInputData->dataLen; - OMX_S32 returnCodec = 0; - - FunctionIn(); - - if (pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC == OMX_FALSE) { - returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo); - if (returnCodec != MFC_RET_OK) - { - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, returnCodec); - ret = OMX_ErrorUndefined; - goto EXIT; - } - - pOutputData->dataBuffer = outputInfo.StrmVirAddr; - pOutputData->allocSize = outputInfo.headerSize; - pOutputData->dataLen = outputInfo.headerSize; - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG; - pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; - - pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC = OMX_TRUE; - - if (pOutputData->dataLen > 0) { - ret = OMX_ErrorNone; - goto EXIT; - } else { - ret = OMX_ErrorInputDataEncodeYet; - goto EXIT; - } - } - - if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) && - (pSECComponent->bUseFlagEOF == OMX_FALSE)) { - pSECComponent->bUseFlagEOF = OMX_TRUE; - } - - pSECComponent->timeStamp[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp; - pSECComponent->nFlags[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags; - SsbSipMfcEncSetConfig(hMFCHandle, MFC_ENC_SETCONF_FRAME_TAG, &(pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp)); - pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp++; - if (pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp >= MAX_TIMESTAMP) - pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp = 0; - - if (oneFrameSize <= 0) { - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - - ret = OMX_ErrorNone; - goto EXIT; - } - - pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - if (pSECPort->portDefinition.format.video.eColorFormat == SEC_OMX_COLOR_FormatNV12PhysicalAddress) { - /* input data from Real camera */ -#define USE_FIMC_FRAME_BUFFER -#ifdef USE_FIMC_FRAME_BUFFER - SEC_OSAL_Memcpy(&addrInfo.pAddrY, pInputData->dataBuffer, sizeof(addrInfo.pAddrY)); - SEC_OSAL_Memcpy(&addrInfo.pAddrC, pInputData->dataBuffer + sizeof(addrInfo.pAddrY), sizeof(addrInfo.pAddrC)); - pInputInfo->YPhyAddr = addrInfo.pAddrY; - pInputInfo->CPhyAddr = addrInfo.pAddrC; - returnCodec = SsbSipMfcEncSetInBuf(hMFCHandle, pInputInfo); - if (returnCodec != MFC_RET_OK) { - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncSetInBuf failed, ret:%d", __FUNCTION__, returnCodec); - ret = OMX_ErrorUndefined; - goto EXIT; - } -#else - OMX_U32 width, height; - - width = pSECPort->portDefinition.format.video.nFrameWidth; - height = pSECPort->portDefinition.format.video.nFrameHeight; - - SEC_OSAL_Memcpy(pInputInfo->YVirAddr, pInputData->dataBuffer, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height))); - SEC_OSAL_Memcpy(pInputInfo->CVirAddr, pInputData->dataBuffer + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)), ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2))); -#endif - } - - returnCodec = SsbSipMfcEncExe(hMFCHandle); - if (returnCodec == MFC_RET_OK) { - OMX_S32 indexTimestamp = 0; - - returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo); - - if ((SsbSipMfcEncGetConfig(hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) || - (((indexTimestamp < 0) || (indexTimestamp > MAX_TIMESTAMP)))) { - pOutputData->timeStamp = pInputData->timeStamp; - pOutputData->nFlags = pInputData->nFlags; - } else { - pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp]; - pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp]; - } - - if (returnCodec == MFC_RET_OK) { - /** Fill Output Buffer **/ - pOutputData->dataBuffer = outputInfo.StrmVirAddr; - pOutputData->allocSize = outputInfo.dataSize; - pOutputData->dataLen = outputInfo.dataSize; - pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; - if (outputInfo.frameType == MFC_FRAME_TYPE_I_FRAME) - pOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; - - ret = OMX_ErrorNone; - } else { - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, returnCodec); - ret = OMX_ErrorUndefined; - } - } else { - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncExe failed, ret:%d", __FUNCTION__, returnCodec); - ret = OMX_ErrorUndefined; - } - -EXIT: - FunctionOut(); - - return ret; -} - -/* MFC Encode */ -OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - SEC_OMX_BASEPORT *pInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - SEC_OMX_BASEPORT *pOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - - FunctionIn(); - - if ((!CHECK_PORT_ENABLED(pInputPort)) || (!CHECK_PORT_ENABLED(pOutputPort)) || - (!CHECK_PORT_POPULATED(pInputPort)) || (!CHECK_PORT_POPULATED(pOutputPort))) { - goto EXIT; - } - if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) { - goto EXIT; - } - - ret = SEC_MFC_Mpeg4_Encode(pOMXComponent, pInputData, pOutputData); - if (ret != OMX_ErrorNone) { - if (ret == OMX_ErrorInputDataEncodeYet) { - pOutputData->usedDataLen = 0; - pOutputData->remainDataLen = pOutputData->dataLen; - } else { - pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, - pSECComponent->callbackData, - OMX_EventError, ret, 0, NULL); - } - } else { - pInputData->usedDataLen += pInputData->dataLen; - pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen; - pInputData->dataLen -= pInputData->usedDataLen; - pInputData->usedDataLen = 0; - - pOutputData->usedDataLen = 0; - pOutputData->remainDataLen = pOutputData->dataLen; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_OMX_BASEPORT *pSECPort = NULL; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - OMX_S32 codecType = -1; - int i = 0; - - FunctionIn(); - - if ((hComponent == NULL) || (componentName == NULL)) { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: parameters are null, ret: %X", __FUNCTION__, ret); - goto EXIT; - } - if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_MPEG4_ENC, componentName) == 0) { - codecType = CODEC_TYPE_MPEG4; - } else if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_H263_ENC, componentName) == 0) { - codecType = CODEC_TYPE_H263; - } else { - ret = OMX_ErrorBadParameter; - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName(%s) error, ret: %X", __FUNCTION__, componentName, ret); - goto EXIT; - } - - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - ret = SEC_OMX_VideoEncodeComponentInit(pOMXComponent); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_OMX_VideoDecodeComponentInit error, ret: %X", __FUNCTION__, ret); - goto EXIT; - } - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pSECComponent->codecType = HW_VIDEO_CODEC; - - pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); - if (pSECComponent->componentName == NULL) { - SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent); - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName alloc error, ret: %X", __FUNCTION__, ret); - goto EXIT; - } - SEC_OSAL_Memset(pSECComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); - - pMpeg4Enc = SEC_OSAL_Malloc(sizeof(SEC_MPEG4ENC_HANDLE)); - if (pMpeg4Enc == NULL) { - SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent); - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_MPEG4ENC_HANDLE alloc error, ret: %X", __FUNCTION__, ret); - goto EXIT; - } - SEC_OSAL_Memset(pMpeg4Enc, 0, sizeof(SEC_MPEG4ENC_HANDLE)); - pSECComponent->hCodecHandle = (OMX_HANDLETYPE)pMpeg4Enc; - pMpeg4Enc->hMFCMpeg4Handle.codecType = codecType; - - if (codecType == CODEC_TYPE_MPEG4) - SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_MPEG4_ENC); - else - SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_H263_ENC); - - /* Set componentVersion */ - pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; - pSECComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; - pSECComponent->componentVersion.s.nRevision = REVISION_NUMBER; - pSECComponent->componentVersion.s.nStep = STEP_NUMBER; - /* Set specVersion */ - pSECComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; - pSECComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; - pSECComponent->specVersion.s.nRevision = REVISION_NUMBER; - pSECComponent->specVersion.s.nStep = STEP_NUMBER; - - /* Android CapabilityFlags */ - pSECComponent->capabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_FALSE; - pSECComponent->capabilityFlags.iOMXComponentSupportsPartialFrames = OMX_FALSE; - pSECComponent->capabilityFlags.iOMXComponentUsesNALStartCodes = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE; - pSECComponent->capabilityFlags.iOMXComponentUsesFullAVCFrames = OMX_TRUE; - - /* Input port */ - pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; - pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; - pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; - pSECPort->portDefinition.format.video.nBitrate = 64000; - pSECPort->portDefinition.format.video.xFramerate= (15 << 16); - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; - pSECPort->portDefinition.format.video.pNativeRender = 0; - pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; - SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); - pSECPort->portDefinition.format.video.eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress;//OMX_COLOR_FormatYUV420SemiPlanar; - pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; - pSECPort->portDefinition.bEnabled = OMX_TRUE; - - /* Output port */ - pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; - pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; - pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; - pSECPort->portDefinition.format.video.nBitrate = 64000; - pSECPort->portDefinition.format.video.xFramerate= (15 << 16); - if (codecType == CODEC_TYPE_MPEG4) { - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; - SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/mpeg4"); - } else { - pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; - SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); - SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/h263"); - } - pSECPort->portDefinition.format.video.pNativeRender = 0; - pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; - pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; - pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; - pSECPort->portDefinition.bEnabled = OMX_TRUE; - - if (codecType == CODEC_TYPE_MPEG4) { - for(i = 0; i < ALL_PORT_NUM; i++) { - INIT_SET_SIZE_VERSION(&pMpeg4Enc->mpeg4Component[i], OMX_VIDEO_PARAM_MPEG4TYPE); - pMpeg4Enc->mpeg4Component[i].nPortIndex = i; - pMpeg4Enc->mpeg4Component[i].eProfile = OMX_VIDEO_MPEG4ProfileSimple; - pMpeg4Enc->mpeg4Component[i].eLevel = OMX_VIDEO_MPEG4Level4; - - pMpeg4Enc->mpeg4Component[i].nPFrames = 10; - pMpeg4Enc->mpeg4Component[i].nBFrames = 0; /* No support for B frames */ - pMpeg4Enc->mpeg4Component[i].nMaxPacketSize = 256; /* Default value */ - pMpeg4Enc->mpeg4Component[i].nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP; - pMpeg4Enc->mpeg4Component[i].bGov = OMX_FALSE; - - } - } else { - for(i = 0; i < ALL_PORT_NUM; i++) { - INIT_SET_SIZE_VERSION(&pMpeg4Enc->h263Component[i], OMX_VIDEO_PARAM_H263TYPE); - pMpeg4Enc->h263Component[i].nPortIndex = i; - pMpeg4Enc->h263Component[i].eProfile = OMX_VIDEO_H263ProfileBaseline; - pMpeg4Enc->h263Component[i].eLevel = OMX_VIDEO_H263Level45; - - pMpeg4Enc->h263Component[i].nPFrames = 20; - pMpeg4Enc->h263Component[i].nBFrames = 0; /* No support for B frames */ - pMpeg4Enc->h263Component[i].bPLUSPTYPEAllowed = OMX_FALSE; - pMpeg4Enc->h263Component[i].nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP; - pMpeg4Enc->h263Component[i].bForceRoundingTypeToZero = OMX_TRUE; - pMpeg4Enc->h263Component[i].nPictureHeaderRepetition = 0; - pMpeg4Enc->h263Component[i].nGOBHeaderInterval = 0; - } - } - - pOMXComponent->GetParameter = &SEC_MFC_Mpeg4Enc_GetParameter; - pOMXComponent->SetParameter = &SEC_MFC_Mpeg4Enc_SetParameter; - pOMXComponent->SetConfig = &SEC_MFC_Mpeg4Enc_SetConfig; - pOMXComponent->ComponentRoleEnum = &SEC_MFC_Mpeg4Enc_ComponentRoleEnum; - pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit; - - pSECComponent->sec_mfc_componentInit = &SEC_MFC_Mpeg4Enc_Init; - pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_Mpeg4Enc_Terminate; - pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_Mpeg4Enc_bufferProcess; - pSECComponent->sec_checkInputFrame = NULL; - - pSECComponent->currentState = OMX_StateLoaded; - - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - SEC_OMX_BASECOMPONENT *pSECComponent = NULL; - SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; - - FunctionIn(); - - if (hComponent == NULL) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; - pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - - SEC_OSAL_Free(pSECComponent->componentName); - pSECComponent->componentName = NULL; - - pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; - if (pMpeg4Enc != NULL) { - SEC_OSAL_Free(pMpeg4Enc); - pMpeg4Enc = pSECComponent->hCodecHandle = NULL; - } - - ret = SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.h b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.h deleted file mode 100644 index d4f9038..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Mpeg4enc.h - * @brief - * @author Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_MPEG4_ENC_COMPONENT -#define SEC_OMX_MPEG4_ENC_COMPONENT - -#include "SEC_OMX_Def.h" -#include "OMX_Component.h" -#include "SsbSipMfcApi.h" - - -typedef enum _CODEC_TYPE -{ - CODEC_TYPE_H263, - CODEC_TYPE_MPEG4 -} CODEC_TYPE; - -typedef struct _SEC_MFC_MPEG4ENC_HANDLE -{ - OMX_HANDLETYPE hMFCHandle; - SSBSIP_MFC_ENC_MPEG4_PARAM mpeg4MFCParam; - SSBSIP_MFC_ENC_H263_PARAM h263MFCParam; - SSBSIP_MFC_ENC_INPUT_INFO inputInfo; - OMX_U32 indexTimestamp; - OMX_BOOL bConfiguredMFC; - CODEC_TYPE codecType; -} SEC_MFC_MPEG4ENC_HANDLE; - -typedef struct _SEC_MPEG4ENC_HANDLE -{ - /* OMX Codec specific */ - OMX_VIDEO_PARAM_H263TYPE h263Component[ALL_PORT_NUM]; - OMX_VIDEO_PARAM_MPEG4TYPE mpeg4Component[ALL_PORT_NUM]; - OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE errorCorrectionType[ALL_PORT_NUM]; - - /* SEC MFC Codec specific */ - SEC_MFC_MPEG4ENC_HANDLE hMFCMpeg4Handle; -} SEC_MPEG4ENC_HANDLE; - - -#ifdef __cplusplus -extern "C" { -#endif - - -OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName); - OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent); - -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c deleted file mode 100644 index 20e4eb8..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 library_register.c - * @brief - * @author Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - - -#include -#include -#include -#include - -#include "SEC_OSAL_Memory.h" -#include "SEC_OSAL_ETC.h" -#include "library_register.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_MPEG4_ENC" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent) -{ - FunctionIn(); - - if (ppSECComponent == NULL) - goto EXIT; - - /* component 1 - video encoder MPEG4 */ - SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPOMENT_MPEG4_ENC); - SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPOMENT_MPEG4_ENC_ROLE); - ppSECComponent[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM; - - /* component 2 - video encoder H.263 */ - SEC_OSAL_Strcpy(ppSECComponent[1]->componentName, SEC_OMX_COMPOMENT_H263_ENC); - SEC_OSAL_Strcpy(ppSECComponent[1]->roles[0], SEC_OMX_COMPOMENT_H263_ENC_ROLE); - ppSECComponent[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM; - -EXIT: - FunctionOut(); - return MAX_COMPONENT_NUM; -} - diff --git a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.h b/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.h deleted file mode 100644 index 3b23011..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 library_register.h - * @brief - * @author Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_MPEG4_ENC_REG -#define SEC_OMX_MPEG4_ENC_REG - -#include "SEC_OMX_Def.h" -#include "OMX_Component.h" -#include "SEC_OMX_Component_Register.h" - - -#define OSCL_EXPORT_REF __attribute__((visibility("default"))) -#define MAX_COMPONENT_NUM 2 -#define MAX_COMPONENT_ROLE_NUM 1 - -/* MPEG4 */ -#define SEC_OMX_COMPOMENT_MPEG4_ENC "OMX.SEC.MPEG4.Encoder" -#define SEC_OMX_COMPOMENT_MPEG4_ENC_ROLE "video_encoder.mpeg4" - -/* H.263 */ -#define SEC_OMX_COMPOMENT_H263_ENC "OMX.SEC.H263.Encoder" -#define SEC_OMX_COMPOMENT_H263_ENC_ROLE "video_encoder.h263" - - -#ifdef __cplusplus -extern "C" { -#endif - -OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent); - -#ifdef __cplusplus -}; -#endif - -#endif - diff --git a/aries/sec_mm/sec_omx/sec_omx_core/Android.mk b/aries/sec_mm/sec_omx/sec_omx_core/Android.mk deleted file mode 100644 index cb01274..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_core/Android.mk +++ /dev/null @@ -1,25 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := SEC_OMX_Component_Register.c \ - SEC_OMX_Core.c - -LOCAL_PRELINK_MODULE := false -LOCAL_MODULE := libSEC_OMX_Core.aries - -LOCAL_CFLAGS := - -LOCAL_ARM_MODE := arm - -LOCAL_STATIC_LIBRARIES := libsecosal.aries libsecbasecomponent.aries -LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils - -LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ - $(SEC_OMX_INC)/sec \ - $(SEC_OMX_TOP)/sec_osal \ - $(SEC_OMX_TOP)/sec_omx_component/common - -include $(BUILD_SHARED_LIBRARY) - diff --git a/aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.c b/aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.c deleted file mode 100644 index 1464397..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Component_Register.c - * @brief SEC OpenMAX IL Component Register - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "OMX_Component.h" -#include "SEC_OSAL_Memory.h" -#include "SEC_OSAL_ETC.h" -#include "SEC_OSAL_Library.h" -#include "SEC_OMX_Component_Register.h" -#include "SEC_OMX_Macros.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_COMP_REGS" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -#define REGISTRY_FILENAME "secomxregistry" - - -OMX_ERRORTYPE SEC_OMX_Component_Register(SEC_OMX_COMPONENT_REGLIST **compList, OMX_U32 *compNum) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - int componentNum = 0, roleNum = 0, totalCompNum = 0; - int read; - char *omxregistryfile = NULL; - char *line = NULL; - char *libName; - FILE *omxregistryfp; - size_t len; - OMX_HANDLETYPE soHandle; - const char *errorMsg; - int (*SEC_OMX_COMPONENT_Library_Register)(SECRegisterComponentType **secComponents); - SECRegisterComponentType **secComponentsTemp; - SEC_OMX_COMPONENT_REGLIST *componentList; - - FunctionIn(); - - omxregistryfile = SEC_OSAL_Malloc(strlen("/system/etc/") + strlen(REGISTRY_FILENAME) + 2); - SEC_OSAL_Strcpy(omxregistryfile, "/system/etc/"); - SEC_OSAL_Strcat(omxregistryfile, REGISTRY_FILENAME); - - omxregistryfp = fopen(omxregistryfile, "r"); - if (omxregistryfp == NULL) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - SEC_OSAL_Free(omxregistryfile); - - fseek(omxregistryfp, 0, 0); - componentList = (SEC_OMX_COMPONENT_REGLIST *)SEC_OSAL_Malloc(sizeof(SEC_OMX_COMPONENT_REGLIST) * MAX_OMX_COMPONENT_NUM); - SEC_OSAL_Memset(componentList, 0, sizeof(SEC_OMX_COMPONENT_REGLIST) * MAX_OMX_COMPONENT_NUM); - libName = SEC_OSAL_Malloc(MAX_OMX_COMPONENT_LIBNAME_SIZE); - - while ((read = getline(&line, &len, omxregistryfp)) != -1) { - if ((*line == 'l') && (*(line + 1) == 'i') && (*(line + 2) == 'b') && - (*(line + 3) == 'O') && (*(line + 4) == 'M') && (*(line + 5) == 'X')) { - SEC_OSAL_Memset(libName, 0, MAX_OMX_COMPONENT_LIBNAME_SIZE); - SEC_OSAL_Strncpy(libName, line, SEC_OSAL_Strlen(line)-1); - SEC_OSAL_Log(SEC_LOG_TRACE, "libName : %s", libName); - - if ((soHandle = SEC_OSAL_dlopen(libName, RTLD_NOW)) != NULL) { - SEC_OSAL_dlerror(); /* clear error*/ - if ((SEC_OMX_COMPONENT_Library_Register = SEC_OSAL_dlsym(soHandle, "SEC_OMX_COMPONENT_Library_Register")) != NULL) { - int i = 0, j = 0; - - componentNum = (*SEC_OMX_COMPONENT_Library_Register)(NULL); - secComponentsTemp = (SECRegisterComponentType **)SEC_OSAL_Malloc(sizeof(SECRegisterComponentType*) * componentNum); - for (i = 0; i < componentNum; i++) { - secComponentsTemp[i] = SEC_OSAL_Malloc(sizeof(SECRegisterComponentType)); - SEC_OSAL_Memset(secComponentsTemp[i], 0, sizeof(SECRegisterComponentType)); - } - (*SEC_OMX_COMPONENT_Library_Register)(secComponentsTemp); - - for (i = 0; i < componentNum; i++) { - SEC_OSAL_Strcpy(componentList[totalCompNum].component.componentName, secComponentsTemp[i]->componentName); - for (j = 0; j < secComponentsTemp[i]->totalRoleNum; j++) - SEC_OSAL_Strcpy(componentList[totalCompNum].component.roles[j], secComponentsTemp[i]->roles[j]); - componentList[totalCompNum].component.totalRoleNum = secComponentsTemp[i]->totalRoleNum; - - SEC_OSAL_Strcpy(componentList[totalCompNum].libName, libName); - - totalCompNum++; - } - for (i = 0; i < componentNum; i++) { - SEC_OSAL_Free(secComponentsTemp[i]); - } - - SEC_OSAL_Free(secComponentsTemp); - } else { - if ((errorMsg = SEC_OSAL_dlerror()) != NULL) - SEC_OSAL_Log(SEC_LOG_WARNING, "dlsym failed: %s", errorMsg); - } - SEC_OSAL_dlclose(soHandle); - } else { - SEC_OSAL_Log(SEC_LOG_WARNING, "dlopen failed: %s", SEC_OSAL_dlerror()); - } - } else { - /* not a component name line. skip */ - continue; - } - } - - SEC_OSAL_Free(libName); - fclose(omxregistryfp); - - *compList = componentList; - *compNum = totalCompNum; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_Component_Unregister(SEC_OMX_COMPONENT_REGLIST *componentList) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - - SEC_OSAL_Memset(componentList, 0, sizeof(SEC_OMX_COMPONENT_REGLIST) * MAX_OMX_COMPONENT_NUM); - SEC_OSAL_Free(componentList); - -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OMX_ComponentAPICheck(OMX_COMPONENTTYPE component) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - - if ((NULL == component.GetComponentVersion) || - (NULL == component.SendCommand) || - (NULL == component.GetParameter) || - (NULL == component.SetParameter) || - (NULL == component.GetConfig) || - (NULL == component.SetConfig) || - (NULL == component.GetExtensionIndex) || - (NULL == component.GetState) || - (NULL == component.ComponentTunnelRequest) || - (NULL == component.UseBuffer) || - (NULL == component.AllocateBuffer) || - (NULL == component.FreeBuffer) || - (NULL == component.EmptyThisBuffer) || - (NULL == component.FillThisBuffer) || - (NULL == component.SetCallbacks) || - (NULL == component.ComponentDeInit) || - (NULL == component.UseEGLImage) || - (NULL == component.ComponentRoleEnum)) - ret = OMX_ErrorInvalidComponent; - else - ret = OMX_ErrorNone; - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_ComponentLoad(SEC_OMX_COMPONENT *sec_component) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_HANDLETYPE libHandle; - OMX_COMPONENTTYPE *pOMXComponent; - - FunctionIn(); - - OMX_ERRORTYPE (*SEC_OMX_ComponentInit)(OMX_HANDLETYPE hComponent, OMX_STRING componentName); - - libHandle = SEC_OSAL_dlopen(sec_component->libName, RTLD_NOW); - if (!libHandle) { - ret = OMX_ErrorInvalidComponentName; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInvalidComponentName, Line:%d", __LINE__); - goto EXIT; - } - - SEC_OMX_ComponentInit = SEC_OSAL_dlsym(libHandle, "SEC_OMX_ComponentInit"); - if (!SEC_OMX_ComponentInit) { - SEC_OSAL_dlclose(libHandle); - ret = OMX_ErrorInvalidComponent; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInvalidComponent, Line:%d", __LINE__); - goto EXIT; - } - - pOMXComponent = (OMX_COMPONENTTYPE *)SEC_OSAL_Malloc(sizeof(OMX_COMPONENTTYPE)); - INIT_SET_SIZE_VERSION(pOMXComponent, OMX_COMPONENTTYPE); - ret = (*SEC_OMX_ComponentInit)((OMX_HANDLETYPE)pOMXComponent, sec_component->componentName); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Free(pOMXComponent); - SEC_OSAL_dlclose(libHandle); - ret = OMX_ErrorInvalidComponent; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInvalidComponent, Line:%d", __LINE__); - goto EXIT; - } else { - if (SEC_OMX_ComponentAPICheck(*pOMXComponent) != OMX_ErrorNone) { - SEC_OSAL_Free(pOMXComponent); - SEC_OSAL_dlclose(libHandle); - if (NULL != pOMXComponent->ComponentDeInit) - pOMXComponent->ComponentDeInit(pOMXComponent); - ret = OMX_ErrorInvalidComponent; - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInvalidComponent, Line:%d", __LINE__); - goto EXIT; - } - sec_component->libHandle = libHandle; - sec_component->pOMXComponent = pOMXComponent; - ret = OMX_ErrorNone; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OMX_ComponentUnload(SEC_OMX_COMPONENT *sec_component) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - - FunctionIn(); - - if (!sec_component) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - pOMXComponent = sec_component->pOMXComponent; - if (pOMXComponent != NULL) { - pOMXComponent->ComponentDeInit(pOMXComponent); - SEC_OSAL_Free(pOMXComponent); - sec_component->pOMXComponent = NULL; - } - - if (sec_component->libHandle != NULL) { - SEC_OSAL_dlclose(sec_component->libHandle); - sec_component->libHandle = NULL; - } - -EXIT: - FunctionOut(); - - return ret; -} diff --git a/aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.h b/aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.h deleted file mode 100644 index 66580bd..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Component_Register.h - * @brief SEC OpenMAX IL Component Register - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_COMPONENT_REG -#define SEC_OMX_COMPONENT_REG - -#include "SEC_OMX_Def.h" -#include "OMX_Types.h" -#include "OMX_Core.h" -#include "OMX_Component.h" - - -typedef struct _SECRegisterComponentType -{ - OMX_U8 componentName[MAX_OMX_COMPONENT_NAME_SIZE]; - OMX_U8 roles[MAX_OMX_COMPONENT_ROLE_NUM][MAX_OMX_COMPONENT_ROLE_SIZE]; - OMX_U32 totalRoleNum; -} SECRegisterComponentType; - -typedef struct _SEC_OMX_COMPONENT_REGLIST -{ - SECRegisterComponentType component; - OMX_U8 libName[MAX_OMX_COMPONENT_LIBNAME_SIZE]; -} SEC_OMX_COMPONENT_REGLIST; - -struct SEC_OMX_COMPONENT; -typedef struct _SEC_OMX_COMPONENT -{ - OMX_U8 componentName[MAX_OMX_COMPONENT_NAME_SIZE]; - OMX_U8 libName[MAX_OMX_COMPONENT_LIBNAME_SIZE]; - OMX_HANDLETYPE libHandle; - OMX_COMPONENTTYPE *pOMXComponent; - struct SEC_OMX_COMPONENT *nextOMXComp; -} SEC_OMX_COMPONENT; - - -#ifdef __cplusplus -extern "C" { -#endif - - -OMX_ERRORTYPE SEC_OMX_Component_Register(SEC_OMX_COMPONENT_REGLIST **compList, OMX_U32 *compNum); -OMX_ERRORTYPE SEC_OMX_Component_Unregister(SEC_OMX_COMPONENT_REGLIST *componentList); -OMX_ERRORTYPE SEC_OMX_ComponentLoad(SEC_OMX_COMPONENT *sec_component); -OMX_ERRORTYPE SEC_OMX_ComponentUnload(SEC_OMX_COMPONENT *sec_component); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.c b/aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.c deleted file mode 100644 index fe84d8d..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Core.c - * @brief SEC OpenMAX IL Core - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * HyeYeon Chung (hyeon.chung@samsung.com) - * Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include - -#include "SEC_OMX_Core.h" -#include "SEC_OMX_Component_Register.h" -#include "SEC_OSAL_Memory.h" -#include "SEC_OMX_Resourcemanager.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_OMX_CORE" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -static int gInitialized = 0; -static int gComponentNum = 0; - -static SEC_OMX_COMPONENT_REGLIST *gComponentList = NULL; -static SEC_OMX_COMPONENT *gLoadComponentList = NULL; -static OMX_HANDLETYPE ghLoadComponentListMutex = NULL; - - -OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_Init(void) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - - FunctionIn(); - - if (gInitialized == 0) { - if (SEC_OMX_Component_Register(&gComponentList, &gComponentNum)) { - ret = OMX_ErrorInsufficientResources; - SEC_OSAL_Log(SEC_LOG_ERROR, "SEC_OMX_Init : %s", "OMX_ErrorInsufficientResources"); - goto EXIT; - } - - SEC_OMX_ResourceManager_Init(); - - SEC_OSAL_MutexCreate(&ghLoadComponentListMutex); - - gInitialized = 1; - SEC_OSAL_Log(SEC_LOG_TRACE, "SEC_OMX_Init : %s", "OMX_ErrorNone"); - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_Deinit(void) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - - FunctionIn(); - - SEC_OSAL_MutexTerminate(ghLoadComponentListMutex); - ghLoadComponentListMutex = NULL; - - SEC_OMX_ResourceManager_Deinit(); - - if (OMX_ErrorNone != SEC_OMX_Component_Unregister(gComponentList)) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - gComponentList = NULL; - gComponentNum = 0; - gInitialized = 0; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_ComponentNameEnum( - OMX_OUT OMX_STRING cComponentName, - OMX_IN OMX_U32 nNameLength, - OMX_IN OMX_U32 nIndex) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - - FunctionIn(); - - if (nIndex >= gComponentNum) { - ret = OMX_ErrorNoMore; - goto EXIT; - } - - sprintf(cComponentName, "%s", gComponentList[nIndex].component.componentName); - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_GetHandle( - OMX_OUT OMX_HANDLETYPE *pHandle, - OMX_IN OMX_STRING cComponentName, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_CALLBACKTYPE *pCallBacks) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_COMPONENT *loadComponent; - SEC_OMX_COMPONENT *currentComponent; - int i = 0; - - FunctionIn(); - - if (gInitialized != 1) { - ret = OMX_ErrorNotReady; - goto EXIT; - } - - if ((pHandle == NULL) || (cComponentName == NULL) || (pCallBacks == NULL)) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - SEC_OSAL_Log(SEC_LOG_TRACE, "ComponentName : %s", cComponentName); - - for (i = 0; i < gComponentNum; i++) { - if (SEC_OSAL_Strcmp(cComponentName, gComponentList[i].component.componentName) == 0) { - loadComponent = SEC_OSAL_Malloc(sizeof(SEC_OMX_COMPONENT)); - SEC_OSAL_Memset(loadComponent, 0, sizeof(SEC_OMX_COMPONENT)); - - SEC_OSAL_Strcpy(loadComponent->libName, gComponentList[i].libName); - SEC_OSAL_Strcpy(loadComponent->componentName, gComponentList[i].component.componentName); - ret = SEC_OMX_ComponentLoad(loadComponent); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Free(loadComponent); - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); - goto EXIT; - } - - ret = loadComponent->pOMXComponent->SetCallbacks(loadComponent->pOMXComponent, pCallBacks, pAppData); - if (ret != OMX_ErrorNone) { - SEC_OMX_ComponentUnload(loadComponent); - SEC_OSAL_Free(loadComponent); - SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); - goto EXIT; - } - - SEC_OSAL_MutexLock(ghLoadComponentListMutex); - if (gLoadComponentList == NULL) { - gLoadComponentList = loadComponent; - } else { - currentComponent = gLoadComponentList; - while (currentComponent->nextOMXComp != NULL) { - currentComponent = currentComponent->nextOMXComp; - } - currentComponent->nextOMXComp = loadComponent; - } - SEC_OSAL_MutexUnlock(ghLoadComponentListMutex); - - *pHandle = loadComponent->pOMXComponent; - ret = OMX_ErrorNone; - SEC_OSAL_Log(SEC_LOG_TRACE, "SEC_OMX_GetHandle : %s", "OMX_ErrorNone"); - goto EXIT; - } - } - - ret = OMX_ErrorComponentNotFound; - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_OMX_COMPONENT *currentComponent; - SEC_OMX_COMPONENT *deleteComponent; - - FunctionIn(); - - if (gInitialized != 1) { - ret = OMX_ErrorNotReady; - goto EXIT; - } - - if (!hComponent) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - SEC_OSAL_MutexLock(ghLoadComponentListMutex); - currentComponent = gLoadComponentList; - if (gLoadComponentList->pOMXComponent == hComponent) { - deleteComponent = gLoadComponentList; - gLoadComponentList = gLoadComponentList->nextOMXComp; - } else { - while ((currentComponent != NULL) && (((SEC_OMX_COMPONENT *)(currentComponent->nextOMXComp))->pOMXComponent != hComponent)) - currentComponent = currentComponent->nextOMXComp; - - if (((SEC_OMX_COMPONENT *)(currentComponent->nextOMXComp))->pOMXComponent == hComponent) { - deleteComponent = currentComponent->nextOMXComp; - currentComponent->nextOMXComp = deleteComponent->nextOMXComp; - } else if (currentComponent == NULL) { - ret = OMX_ErrorComponentNotFound; - SEC_OSAL_MutexUnlock(ghLoadComponentListMutex); - goto EXIT; - } - } - SEC_OSAL_MutexUnlock(ghLoadComponentListMutex); - - SEC_OMX_ComponentUnload(deleteComponent); - SEC_OSAL_Free(deleteComponent); - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_SetupTunnel( - OMX_IN OMX_HANDLETYPE hOutput, - OMX_IN OMX_U32 nPortOutput, - OMX_IN OMX_HANDLETYPE hInput, - OMX_IN OMX_U32 nPortInput) -{ - OMX_ERRORTYPE ret = OMX_ErrorNotImplemented; - -EXIT: - return ret; -} - -OMX_API OMX_ERRORTYPE SEC_OMX_GetContentPipe( - OMX_OUT OMX_HANDLETYPE *hPipe, - OMX_IN OMX_STRING szURI) -{ - OMX_ERRORTYPE ret = OMX_ErrorNotImplemented; - -EXIT: - return ret; -} - -OMX_API OMX_ERRORTYPE SEC_OMX_GetComponentsOfRole ( - OMX_IN OMX_STRING role, - OMX_INOUT OMX_U32 *pNumComps, - OMX_INOUT OMX_U8 **compNames) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - int max_role_num = 0; - OMX_STRING RoleString[MAX_OMX_COMPONENT_ROLE_SIZE]; - int i = 0, j = 0; - - FunctionIn(); - - if (gInitialized != 1) { - ret = OMX_ErrorNotReady; - goto EXIT; - } - - *pNumComps = 0; - - for (i = 0; i < MAX_OMX_COMPONENT_NUM; i++) { - max_role_num = gComponentList[i].component.totalRoleNum; - - for (j = 0; j < max_role_num; j++) { - if (SEC_OSAL_Strcmp(gComponentList[i].component.roles[j], role) == 0) { - if (compNames != NULL) { - SEC_OSAL_Strcpy((OMX_STRING)compNames[*pNumComps], gComponentList[i].component.componentName); - } - *pNumComps = (*pNumComps + 1); - } - } - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_API OMX_ERRORTYPE SEC_OMX_GetRolesOfComponent ( - OMX_IN OMX_STRING compName, - OMX_INOUT OMX_U32 *pNumRoles, - OMX_OUT OMX_U8 **roles) -{ - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_BOOL detectComp = OMX_FALSE; - int compNum = 0, totalRoleNum = 0; - int i = 0; - - FunctionIn(); - - if (gInitialized != 1) { - ret = OMX_ErrorNotReady; - goto EXIT; - } - - for (i = 0; i < MAX_OMX_COMPONENT_NUM; i++) { - if (gComponentList != NULL) { - if (SEC_OSAL_Strcmp(gComponentList[i].component.componentName, compName) == 0) { - *pNumRoles = totalRoleNum = gComponentList[i].component.totalRoleNum; - compNum = i; - detectComp = OMX_TRUE; - break; - } - } else { - ret = OMX_ErrorUndefined; - goto EXIT; - } - } - - if (detectComp == OMX_FALSE) { - *pNumRoles = 0; - ret = OMX_ErrorComponentNotFound; - goto EXIT; - } - - if (roles != NULL) { - for (i = 0; i < totalRoleNum; i++) { - SEC_OSAL_Strcpy(roles[i], gComponentList[compNum].component.roles[i]); - } - } - -EXIT: - FunctionOut(); - - return ret; -} diff --git a/aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.h b/aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.h deleted file mode 100644 index 87f561c..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Core.h - * @brief SEC OpenMAX IL Core - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * HyeYeon Chung (hyeon.chung@samsung.com) - * Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_CORE -#define SEC_OMX_CORE - -#include "SEC_OMX_Def.h" -#include "OMX_Types.h" -#include "OMX_Core.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -SEC_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_Init(void); -SEC_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_Deinit(void); -SEC_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_ComponentNameEnum( - OMX_OUT OMX_STRING cComponentName, - OMX_IN OMX_U32 nNameLength, - OMX_IN OMX_U32 nIndex); -SEC_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_GetHandle( - OMX_OUT OMX_HANDLETYPE *pHandle, - OMX_IN OMX_STRING cComponentName, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_CALLBACKTYPE *pCallBacks); -SEC_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_FreeHandle( - OMX_IN OMX_HANDLETYPE hComponent); -SEC_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_SetupTunnel( - OMX_IN OMX_HANDLETYPE hOutput, - OMX_IN OMX_U32 nPortOutput, - OMX_IN OMX_HANDLETYPE hInput, - OMX_IN OMX_U32 nPortInput); -SEC_EXPORT_REF OMX_API OMX_ERRORTYPE SEC_OMX_GetContentPipe( - OMX_OUT OMX_HANDLETYPE *hPipe, - OMX_IN OMX_STRING szURI); -SEC_EXPORT_REF OMX_API OMX_ERRORTYPE SEC_OMX_GetComponentsOfRole( - OMX_IN OMX_STRING role, - OMX_INOUT OMX_U32 *pNumComps, - OMX_INOUT OMX_U8 **compNames); -SEC_EXPORT_REF OMX_API OMX_ERRORTYPE SEC_OMX_GetRolesOfComponent( - OMX_IN OMX_STRING compName, - OMX_INOUT OMX_U32 *pNumRoles, - OMX_OUT OMX_U8 **roles); - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/aries/sec_mm/sec_omx/sec_omx_core/secomxregistry b/aries/sec_mm/sec_omx/sec_omx_core/secomxregistry deleted file mode 100644 index cc762e6..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_core/secomxregistry +++ /dev/null @@ -1,4 +0,0 @@ -libOMX.SEC.AVC.Decoder.aries.so -libOMX.SEC.M4V.Decoder.aries.so -libOMX.SEC.AVC.Encoder.aries.so -libOMX.SEC.M4V.Encoder.aries.so diff --git a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Audio.h b/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Audio.h deleted file mode 100644 index 04f1a99..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Audio.h +++ /dev/null @@ -1,1311 +0,0 @@ -/* - * Copyright (c) 2008 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. - * - */ - -/** @file OMX_Audio.h - OpenMax IL version 1.1.2 - * The structures needed by Audio components to exchange - * parameters and configuration data with the componenmilts. - */ - -#ifndef OMX_Audio_h -#define OMX_Audio_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 - -/** @defgroup midi MIDI - * @ingroup audio - */ - -/** @defgroup effects Audio effects - * @ingroup audio - */ - -/** @defgroup audio OpenMAX IL Audio Domain - * Structures for OpenMAX IL Audio domain - * @{ - */ - -/** Enumeration used to define the possible audio codings. - * If "OMX_AUDIO_CodingUnused" is selected, the coding selection must - * be done in a vendor specific way. Since this is for an audio - * processing element this enum is relevant. However, for another - * type of component other enums would be in this area. - */ -typedef enum OMX_AUDIO_CODINGTYPE { - OMX_AUDIO_CodingUnused = 0, /**< Placeholder value when coding is N/A */ - OMX_AUDIO_CodingAutoDetect, /**< auto detection of audio format */ - OMX_AUDIO_CodingPCM, /**< Any variant of PCM coding */ - OMX_AUDIO_CodingADPCM, /**< Any variant of ADPCM encoded data */ - OMX_AUDIO_CodingAMR, /**< Any variant of AMR encoded data */ - OMX_AUDIO_CodingGSMFR, /**< Any variant of GSM fullrate (i.e. GSM610) */ - OMX_AUDIO_CodingGSMEFR, /**< Any variant of GSM Enhanced Fullrate encoded data*/ - OMX_AUDIO_CodingGSMHR, /**< Any variant of GSM Halfrate encoded data */ - OMX_AUDIO_CodingPDCFR, /**< Any variant of PDC Fullrate encoded data */ - OMX_AUDIO_CodingPDCEFR, /**< Any variant of PDC Enhanced Fullrate encoded data */ - OMX_AUDIO_CodingPDCHR, /**< Any variant of PDC Halfrate encoded data */ - OMX_AUDIO_CodingTDMAFR, /**< Any variant of TDMA Fullrate encoded data (TIA/EIA-136-420) */ - OMX_AUDIO_CodingTDMAEFR, /**< Any variant of TDMA Enhanced Fullrate encoded data (TIA/EIA-136-410) */ - OMX_AUDIO_CodingQCELP8, /**< Any variant of QCELP 8kbps encoded data */ - OMX_AUDIO_CodingQCELP13, /**< Any variant of QCELP 13kbps encoded data */ - OMX_AUDIO_CodingEVRC, /**< Any variant of EVRC encoded data */ - OMX_AUDIO_CodingSMV, /**< Any variant of SMV encoded data */ - OMX_AUDIO_CodingG711, /**< Any variant of G.711 encoded data */ - OMX_AUDIO_CodingG723, /**< Any variant of G.723 dot 1 encoded data */ - OMX_AUDIO_CodingG726, /**< Any variant of G.726 encoded data */ - OMX_AUDIO_CodingG729, /**< Any variant of G.729 encoded data */ - OMX_AUDIO_CodingAAC, /**< Any variant of AAC encoded data */ - OMX_AUDIO_CodingMP3, /**< Any variant of MP3 encoded data */ - OMX_AUDIO_CodingSBC, /**< Any variant of SBC encoded data */ - OMX_AUDIO_CodingVORBIS, /**< Any variant of VORBIS encoded data */ - OMX_AUDIO_CodingWMA, /**< Any variant of WMA encoded data */ - OMX_AUDIO_CodingRA, /**< Any variant of RA encoded data */ - OMX_AUDIO_CodingMIDI, /**< Any variant of MIDI encoded data */ - OMX_AUDIO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_CodingMax = 0x7FFFFFFF -} OMX_AUDIO_CODINGTYPE; - - -/** The PortDefinition structure is used to define all of the parameters - * necessary for the compliant component to setup an input or an output audio - * path. If additional information is needed to define the parameters of the - * port (such as frequency), additional structures must be sent such as the - * OMX_AUDIO_PARAM_PCMMODETYPE structure to supply the extra parameters for the port. - */ -typedef struct OMX_AUDIO_PORTDEFINITIONTYPE { - OMX_STRING cMIMEType; /**< MIME type of data for the port */ - OMX_NATIVE_DEVICETYPE pNativeRender; /** < platform specific reference - for an output device, - otherwise this field is 0 */ - OMX_BOOL bFlagErrorConcealment; /**< Turns on error concealment if it is - supported by the OMX component */ - OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this - port (e.g. PCM, AMR, MP3, etc) */ -} OMX_AUDIO_PORTDEFINITIONTYPE; - - -/** Port format parameter. This structure is used to enumerate - * the various data input/output format supported by the port. - */ -typedef struct OMX_AUDIO_PARAM_PORTFORMATTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Indicates which port to set */ - OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */ - OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this port (e.g. PCM, AMR, MP3, etc) */ -} OMX_AUDIO_PARAM_PORTFORMATTYPE; - - -/** PCM mode type */ -typedef enum OMX_AUDIO_PCMMODETYPE { - OMX_AUDIO_PCMModeLinear = 0, /**< Linear PCM encoded data */ - OMX_AUDIO_PCMModeALaw, /**< A law PCM encoded data (G.711) */ - OMX_AUDIO_PCMModeMULaw, /**< Mu law PCM encoded data (G.711) */ - OMX_AUDIO_PCMModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_PCMModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_PCMModeMax = 0x7FFFFFFF -} OMX_AUDIO_PCMMODETYPE; - - -typedef enum OMX_AUDIO_CHANNELTYPE { - OMX_AUDIO_ChannelNone = 0x0, /**< Unused or empty */ - OMX_AUDIO_ChannelLF = 0x1, /**< Left front */ - OMX_AUDIO_ChannelRF = 0x2, /**< Right front */ - OMX_AUDIO_ChannelCF = 0x3, /**< Center front */ - OMX_AUDIO_ChannelLS = 0x4, /**< Left surround */ - OMX_AUDIO_ChannelRS = 0x5, /**< Right surround */ - OMX_AUDIO_ChannelLFE = 0x6, /**< Low frequency effects */ - OMX_AUDIO_ChannelCS = 0x7, /**< Back surround */ - OMX_AUDIO_ChannelLR = 0x8, /**< Left rear. */ - OMX_AUDIO_ChannelRR = 0x9, /**< Right rear. */ - OMX_AUDIO_ChannelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_ChannelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_ChannelMax = 0x7FFFFFFF -} OMX_AUDIO_CHANNELTYPE; - -#define OMX_AUDIO_MAXCHANNELS 16 /**< maximum number distinct audio channels that a buffer may contain */ -#define OMX_MIN_PCMPAYLOAD_MSEC 5 /**< Minimum audio buffer payload size for uncompressed (PCM) audio */ - -/** PCM format description */ -typedef struct OMX_AUDIO_PARAM_PCMMODETYPE { - OMX_U32 nSize; /**< Size of this structure, in Bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels (e.g. 2 for stereo) */ - OMX_NUMERICALDATATYPE eNumData; /**< indicates PCM data as signed or unsigned */ - OMX_ENDIANTYPE eEndian; /**< indicates PCM data as little or big endian */ - OMX_BOOL bInterleaved; /**< True for normal interleaved data; false for - non-interleaved data (e.g. block data) */ - OMX_U32 nBitPerSample; /**< Bit per sample */ - OMX_U32 nSamplingRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ - OMX_AUDIO_PCMMODETYPE ePCMMode; /**< PCM mode enumeration */ - OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMap[i] */ - -} OMX_AUDIO_PARAM_PCMMODETYPE; - - -/** Audio channel mode. This is used by both AAC and MP3, although the names are more appropriate - * for the MP3. For example, JointStereo for MP3 is CouplingChannels for AAC. - */ -typedef enum OMX_AUDIO_CHANNELMODETYPE { - OMX_AUDIO_ChannelModeStereo = 0, /**< 2 channels, the bitrate allocation between those - two channels changes accordingly to each channel information */ - OMX_AUDIO_ChannelModeJointStereo, /**< mode that takes advantage of what is common between - 2 channels for higher compression gain */ - OMX_AUDIO_ChannelModeDual, /**< 2 mono-channels, each channel is encoded with half - the bitrate of the overall bitrate */ - OMX_AUDIO_ChannelModeMono, /**< Mono channel mode */ - OMX_AUDIO_ChannelModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_ChannelModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_ChannelModeMax = 0x7FFFFFFF -} OMX_AUDIO_CHANNELMODETYPE; - - -typedef enum OMX_AUDIO_MP3STREAMFORMATTYPE { - OMX_AUDIO_MP3StreamFormatMP1Layer3 = 0, /**< MP3 Audio MPEG 1 Layer 3 Stream format */ - OMX_AUDIO_MP3StreamFormatMP2Layer3, /**< MP3 Audio MPEG 2 Layer 3 Stream format */ - OMX_AUDIO_MP3StreamFormatMP2_5Layer3, /**< MP3 Audio MPEG2.5 Layer 3 Stream format */ - OMX_AUDIO_MP3StreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_MP3StreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_MP3StreamFormatMax = 0x7FFFFFFF -} OMX_AUDIO_MP3STREAMFORMATTYPE; - -/** MP3 params */ -typedef struct OMX_AUDIO_PARAM_MP3TYPE { - 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_U32 nChannels; /**< Number of channels */ - OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable - rate or unknown bit rates */ - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ - OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should - limit the audio signal. Use 0 to let encoder decide */ - OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */ - OMX_AUDIO_MP3STREAMFORMATTYPE eFormat; /**< MP3 stream format */ -} OMX_AUDIO_PARAM_MP3TYPE; - - -typedef enum OMX_AUDIO_AACSTREAMFORMATTYPE { - OMX_AUDIO_AACStreamFormatMP2ADTS = 0, /**< AAC Audio Data Transport Stream 2 format */ - OMX_AUDIO_AACStreamFormatMP4ADTS, /**< AAC Audio Data Transport Stream 4 format */ - OMX_AUDIO_AACStreamFormatMP4LOAS, /**< AAC Low Overhead Audio Stream format */ - OMX_AUDIO_AACStreamFormatMP4LATM, /**< AAC Low overhead Audio Transport Multiplex */ - OMX_AUDIO_AACStreamFormatADIF, /**< AAC Audio Data Interchange Format */ - OMX_AUDIO_AACStreamFormatMP4FF, /**< AAC inside MPEG-4/ISO File Format */ - OMX_AUDIO_AACStreamFormatRAW, /**< AAC Raw Format */ - OMX_AUDIO_AACStreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_AACStreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_AACStreamFormatMax = 0x7FFFFFFF -} OMX_AUDIO_AACSTREAMFORMATTYPE; - - -/** AAC mode type. Note that the term profile is used with the MPEG-2 - * standard and the term object type and profile is used with MPEG-4 */ -typedef enum OMX_AUDIO_AACPROFILETYPE{ - OMX_AUDIO_AACObjectNull = 0, /**< Null, not used */ - OMX_AUDIO_AACObjectMain = 1, /**< AAC Main object */ - OMX_AUDIO_AACObjectLC, /**< AAC Low Complexity object (AAC profile) */ - OMX_AUDIO_AACObjectSSR, /**< AAC Scalable Sample Rate object */ - OMX_AUDIO_AACObjectLTP, /**< AAC Long Term Prediction object */ - OMX_AUDIO_AACObjectHE, /**< AAC High Efficiency (object type SBR, HE-AAC profile) */ - OMX_AUDIO_AACObjectScalable, /**< AAC Scalable object */ - OMX_AUDIO_AACObjectERLC = 17, /**< ER AAC Low Complexity object (Error Resilient AAC-LC) */ - OMX_AUDIO_AACObjectLD = 23, /**< AAC Low Delay object (Error Resilient) */ - OMX_AUDIO_AACObjectHE_PS = 29, /**< AAC High Efficiency with Parametric Stereo coding (HE-AAC v2, object type PS) */ - OMX_AUDIO_AACObjectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_AACObjectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_AACObjectMax = 0x7FFFFFFF -} OMX_AUDIO_AACPROFILETYPE; - - -/** AAC tool usage (for nAACtools in OMX_AUDIO_PARAM_AACPROFILETYPE). - * Required for encoder configuration and optional as decoder info output. - * For MP3, OMX_AUDIO_CHANNELMODETYPE is sufficient. */ -#define OMX_AUDIO_AACToolNone 0x00000000 /**< no AAC tools allowed (encoder config) or active (decoder info output) */ -#define OMX_AUDIO_AACToolMS 0x00000001 /**< MS: Mid/side joint coding tool allowed or active */ -#define OMX_AUDIO_AACToolIS 0x00000002 /**< IS: Intensity stereo tool allowed or active */ -#define OMX_AUDIO_AACToolTNS 0x00000004 /**< TNS: Temporal Noise Shaping tool allowed or active */ -#define OMX_AUDIO_AACToolPNS 0x00000008 /**< PNS: MPEG-4 Perceptual Noise substitution tool allowed or active */ -#define OMX_AUDIO_AACToolLTP 0x00000010 /**< LTP: MPEG-4 Long Term Prediction tool allowed or active */ -#define OMX_AUDIO_AACToolAll 0x7FFFFFFF /**< all AAC tools allowed or active (*/ - -/** MPEG-4 AAC error resilience (ER) tool usage (for nAACERtools in OMX_AUDIO_PARAM_AACPROFILETYPE). - * Required for ER encoder configuration and optional as decoder info output */ -#define OMX_AUDIO_AACERNone 0x00000000 /**< no AAC ER tools allowed/used */ -#define OMX_AUDIO_AACERVCB11 0x00000001 /**< VCB11: Virtual Code Books for AAC section data */ -#define OMX_AUDIO_AACERRVLC 0x00000002 /**< RVLC: Reversible Variable Length Coding */ -#define OMX_AUDIO_AACERHCR 0x00000004 /**< HCR: Huffman Codeword Reordering */ -#define OMX_AUDIO_AACERAll 0x7FFFFFFF /**< all AAC ER tools allowed/used */ - - -/** AAC params */ -typedef struct OMX_AUDIO_PARAM_AACPROFILETYPE { - OMX_U32 nSize; /**< Size of this structure, in Bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels */ - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ - OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable - rate or unknown bit rates */ - OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should - limit the audio signal. Use 0 to let encoder decide */ - OMX_U32 nFrameLength; /**< Frame length (in audio samples per channel) of the codec. - Can be 1024 or 960 (AAC-LC), 2048 (HE-AAC), 480 or 512 (AAC-LD). - Use 0 to let encoder decide */ - OMX_U32 nAACtools; /**< AAC tool usage */ - OMX_U32 nAACERtools; /**< MPEG-4 AAC error resilience tool usage */ - OMX_AUDIO_AACPROFILETYPE eAACProfile; /**< AAC profile enumeration */ - OMX_AUDIO_AACSTREAMFORMATTYPE eAACStreamFormat; /**< AAC stream format enumeration */ - OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */ -} OMX_AUDIO_PARAM_AACPROFILETYPE; - - -/** VORBIS params */ -typedef struct OMX_AUDIO_PARAM_VORBISTYPE { - 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_U32 nChannels; /**< Number of channels */ - OMX_U32 nBitRate; /**< Bit rate of the encoded data data. Use 0 for variable - rate or unknown bit rates. Encoding is set to the - bitrate closest to specified value (in bps) */ - OMX_U32 nMinBitRate; /**< Sets minimum bitrate (in bps). */ - OMX_U32 nMaxBitRate; /**< Sets maximum bitrate (in bps). */ - - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ - OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should - limit the audio signal. Use 0 to let encoder decide */ - OMX_S32 nQuality; /**< Sets encoding quality to n, between -1 (low) and 10 (high). - In the default mode of operation, teh quality level is 3. - Normal quality range is 0 - 10. */ - OMX_BOOL bManaged; /**< Set bitrate management mode. This turns off the - normal VBR encoding, but allows hard or soft bitrate - constraints to be enforced by the encoder. This mode can - be slower, and may also be lower quality. It is - primarily useful for streaming. */ - OMX_BOOL bDownmix; /**< Downmix input from stereo to mono (has no effect on - non-stereo streams). Useful for lower-bitrate encoding. */ -} OMX_AUDIO_PARAM_VORBISTYPE; - - -/** WMA Version */ -typedef enum OMX_AUDIO_WMAFORMATTYPE { - OMX_AUDIO_WMAFormatUnused = 0, /**< format unused or unknown */ - OMX_AUDIO_WMAFormat7, /**< Windows Media Audio format 7 */ - OMX_AUDIO_WMAFormat8, /**< Windows Media Audio format 8 */ - OMX_AUDIO_WMAFormat9, /**< Windows Media Audio format 9 */ - OMX_AUDIO_WMAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_WMAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_WMAFormatMax = 0x7FFFFFFF -} OMX_AUDIO_WMAFORMATTYPE; - - -/** WMA Profile */ -typedef enum OMX_AUDIO_WMAPROFILETYPE { - OMX_AUDIO_WMAProfileUnused = 0, /**< profile unused or unknown */ - OMX_AUDIO_WMAProfileL1, /**< Windows Media audio version 9 profile L1 */ - OMX_AUDIO_WMAProfileL2, /**< Windows Media audio version 9 profile L2 */ - OMX_AUDIO_WMAProfileL3, /**< Windows Media audio version 9 profile L3 */ - OMX_AUDIO_WMAProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_WMAProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_WMAProfileMax = 0x7FFFFFFF -} OMX_AUDIO_WMAPROFILETYPE; - - -/** WMA params */ -typedef struct OMX_AUDIO_PARAM_WMATYPE { - 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_U16 nChannels; /**< Number of channels */ - OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable - rate or unknown bit rates */ - OMX_AUDIO_WMAFORMATTYPE eFormat; /**< Version of WMA stream / data */ - OMX_AUDIO_WMAPROFILETYPE eProfile; /**< Profile of WMA stream / data */ - OMX_U32 nSamplingRate; /**< Sampling rate of the source data */ - OMX_U16 nBlockAlign; /**< is the block alignment, or block size, in bytes of the audio codec */ - OMX_U16 nEncodeOptions; /**< WMA Type-specific data */ - OMX_U32 nSuperBlockAlign; /**< WMA Type-specific data */ -} OMX_AUDIO_PARAM_WMATYPE; - -/** - * RealAudio format - */ -typedef enum OMX_AUDIO_RAFORMATTYPE { - OMX_AUDIO_RAFormatUnused = 0, /**< Format unused or unknown */ - OMX_AUDIO_RA8, /**< RealAudio 8 codec */ - OMX_AUDIO_RA9, /**< RealAudio 9 codec */ - OMX_AUDIO_RA10_AAC, /**< MPEG-4 AAC codec for bitrates of more than 128kbps */ - OMX_AUDIO_RA10_CODEC, /**< RealAudio codec for bitrates less than 128 kbps */ - OMX_AUDIO_RA10_LOSSLESS, /**< RealAudio Lossless */ - OMX_AUDIO_RA10_MULTICHANNEL, /**< RealAudio Multichannel */ - OMX_AUDIO_RA10_VOICE, /**< RealAudio Voice for bitrates below 15 kbps */ - OMX_AUDIO_RAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_RAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_RAFormatMax = 0x7FFFFFFF -} OMX_AUDIO_RAFORMATTYPE; - -/** RA (Real Audio) params */ -typedef struct OMX_AUDIO_PARAM_RATYPE { - OMX_U32 nSize; /**< Size of this structure, in Bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port that this structure applies to */ - OMX_U32 nChannels; /**< Number of channels */ - OMX_U32 nSamplingRate; /**< is the sampling rate of the source data */ - OMX_U32 nBitsPerFrame; /**< is the value for bits per frame */ - OMX_U32 nSamplePerFrame; /**< is the value for samples per frame */ - OMX_U32 nCouplingQuantBits; /**< is the number of coupling quantization bits in the stream */ - OMX_U32 nCouplingStartRegion; /**< is the coupling start region in the stream */ - OMX_U32 nNumRegions; /**< is the number of regions value */ - OMX_AUDIO_RAFORMATTYPE eFormat; /**< is the RealAudio audio format */ -} OMX_AUDIO_PARAM_RATYPE; - - -/** SBC Allocation Method Type */ -typedef enum OMX_AUDIO_SBCALLOCMETHODTYPE { - OMX_AUDIO_SBCAllocMethodLoudness, /**< Loudness allocation method */ - OMX_AUDIO_SBCAllocMethodSNR, /**< SNR allocation method */ - OMX_AUDIO_SBCAllocMethodKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_SBCAllocMethodVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_SBCAllocMethodMax = 0x7FFFFFFF -} OMX_AUDIO_SBCALLOCMETHODTYPE; - - -/** SBC params */ -typedef struct OMX_AUDIO_PARAM_SBCTYPE { - 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_U32 nChannels; /**< Number of channels */ - OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable - rate or unknown bit rates */ - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ - OMX_U32 nBlocks; /**< Number of blocks */ - OMX_U32 nSubbands; /**< Number of subbands */ - OMX_U32 nBitPool; /**< Bitpool value */ - OMX_BOOL bEnableBitrate; /**< Use bitrate value instead of bitpool */ - OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */ - OMX_AUDIO_SBCALLOCMETHODTYPE eSBCAllocType; /**< SBC Allocation method type */ -} OMX_AUDIO_PARAM_SBCTYPE; - - -/** ADPCM stream format parameters */ -typedef struct OMX_AUDIO_PARAM_ADPCMTYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_U32 nBitsPerSample; /**< Number of bits in each sample */ - OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for - variable or unknown sampling rate. */ -} OMX_AUDIO_PARAM_ADPCMTYPE; - - -/** G723 rate */ -typedef enum OMX_AUDIO_G723RATE { - OMX_AUDIO_G723ModeUnused = 0, /**< AMRNB Mode unused / unknown */ - OMX_AUDIO_G723ModeLow, /**< 5300 bps */ - OMX_AUDIO_G723ModeHigh, /**< 6300 bps */ - OMX_AUDIO_G723ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_G723ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_G723ModeMax = 0x7FFFFFFF -} OMX_AUDIO_G723RATE; - - -/** G723 - Sample rate must be 8 KHz */ -typedef struct OMX_AUDIO_PARAM_G723TYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_AUDIO_G723RATE eBitRate; /**< todo: Should this be moved to a config? */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ - OMX_BOOL bPostFilter; /**< Enable Post Filter */ -} OMX_AUDIO_PARAM_G723TYPE; - - -/** ITU G726 (ADPCM) rate */ -typedef enum OMX_AUDIO_G726MODE { - OMX_AUDIO_G726ModeUnused = 0, /**< G726 Mode unused / unknown */ - OMX_AUDIO_G726Mode16, /**< 16 kbps */ - OMX_AUDIO_G726Mode24, /**< 24 kbps */ - OMX_AUDIO_G726Mode32, /**< 32 kbps, most common rate, also G721 */ - OMX_AUDIO_G726Mode40, /**< 40 kbps */ - OMX_AUDIO_G726ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_G726ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_G726ModeMax = 0x7FFFFFFF -} OMX_AUDIO_G726MODE; - - -/** G.726 stream format parameters - must be at 8KHz */ -typedef struct OMX_AUDIO_PARAM_G726TYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_AUDIO_G726MODE eG726Mode; -} OMX_AUDIO_PARAM_G726TYPE; - - -/** G729 coder type */ -typedef enum OMX_AUDIO_G729TYPE { - OMX_AUDIO_G729 = 0, /**< ITU G.729 encoded data */ - OMX_AUDIO_G729A, /**< ITU G.729 annex A encoded data */ - OMX_AUDIO_G729B, /**< ITU G.729 with annex B encoded data */ - OMX_AUDIO_G729AB, /**< ITU G.729 annexes A and B encoded data */ - OMX_AUDIO_G729KhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_G729VendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_G729Max = 0x7FFFFFFF -} OMX_AUDIO_G729TYPE; - - -/** G729 stream format parameters - fixed 6KHz sample rate */ -typedef struct OMX_AUDIO_PARAM_G729TYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_AUDIO_G729TYPE eBitType; -} OMX_AUDIO_PARAM_G729TYPE; - - -/** AMR Frame format */ -typedef enum OMX_AUDIO_AMRFRAMEFORMATTYPE { - OMX_AUDIO_AMRFrameFormatConformance = 0, /**< Frame Format is AMR Conformance - (Standard) Format */ - OMX_AUDIO_AMRFrameFormatIF1, /**< Frame Format is AMR Interface - Format 1 */ - OMX_AUDIO_AMRFrameFormatIF2, /**< Frame Format is AMR Interface - Format 2*/ - OMX_AUDIO_AMRFrameFormatFSF, /**< Frame Format is AMR File Storage - Format */ - OMX_AUDIO_AMRFrameFormatRTPPayload, /**< Frame Format is AMR Real-Time - Transport Protocol Payload Format */ - OMX_AUDIO_AMRFrameFormatITU, /**< Frame Format is ITU Format (added at Motorola request) */ - OMX_AUDIO_AMRFrameFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_AMRFrameFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_AMRFrameFormatMax = 0x7FFFFFFF -} OMX_AUDIO_AMRFRAMEFORMATTYPE; - - -/** AMR band mode */ -typedef enum OMX_AUDIO_AMRBANDMODETYPE { - OMX_AUDIO_AMRBandModeUnused = 0, /**< AMRNB Mode unused / unknown */ - OMX_AUDIO_AMRBandModeNB0, /**< AMRNB Mode 0 = 4750 bps */ - OMX_AUDIO_AMRBandModeNB1, /**< AMRNB Mode 1 = 5150 bps */ - OMX_AUDIO_AMRBandModeNB2, /**< AMRNB Mode 2 = 5900 bps */ - OMX_AUDIO_AMRBandModeNB3, /**< AMRNB Mode 3 = 6700 bps */ - OMX_AUDIO_AMRBandModeNB4, /**< AMRNB Mode 4 = 7400 bps */ - OMX_AUDIO_AMRBandModeNB5, /**< AMRNB Mode 5 = 7950 bps */ - OMX_AUDIO_AMRBandModeNB6, /**< AMRNB Mode 6 = 10200 bps */ - OMX_AUDIO_AMRBandModeNB7, /**< AMRNB Mode 7 = 12200 bps */ - OMX_AUDIO_AMRBandModeWB0, /**< AMRWB Mode 0 = 6600 bps */ - OMX_AUDIO_AMRBandModeWB1, /**< AMRWB Mode 1 = 8850 bps */ - OMX_AUDIO_AMRBandModeWB2, /**< AMRWB Mode 2 = 12650 bps */ - OMX_AUDIO_AMRBandModeWB3, /**< AMRWB Mode 3 = 14250 bps */ - OMX_AUDIO_AMRBandModeWB4, /**< AMRWB Mode 4 = 15850 bps */ - OMX_AUDIO_AMRBandModeWB5, /**< AMRWB Mode 5 = 18250 bps */ - OMX_AUDIO_AMRBandModeWB6, /**< AMRWB Mode 6 = 19850 bps */ - OMX_AUDIO_AMRBandModeWB7, /**< AMRWB Mode 7 = 23050 bps */ - OMX_AUDIO_AMRBandModeWB8, /**< AMRWB Mode 8 = 23850 bps */ - OMX_AUDIO_AMRBandModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_AMRBandModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_AMRBandModeMax = 0x7FFFFFFF -} OMX_AUDIO_AMRBANDMODETYPE; - - -/** AMR Discontinuous Transmission mode */ -typedef enum OMX_AUDIO_AMRDTXMODETYPE { - OMX_AUDIO_AMRDTXModeOff = 0, /**< AMR Discontinuous Transmission Mode is disabled */ - OMX_AUDIO_AMRDTXModeOnVAD1, /**< AMR Discontinuous Transmission Mode using - Voice Activity Detector 1 (VAD1) is enabled */ - OMX_AUDIO_AMRDTXModeOnVAD2, /**< AMR Discontinuous Transmission Mode using - Voice Activity Detector 2 (VAD2) is enabled */ - OMX_AUDIO_AMRDTXModeOnAuto, /**< The codec will automatically select between - Off, VAD1 or VAD2 modes */ - - OMX_AUDIO_AMRDTXasEFR, /**< DTX as EFR instead of AMR standard (3GPP 26.101, frame type =8,9,10) */ - - OMX_AUDIO_AMRDTXModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_AMRDTXModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_AMRDTXModeMax = 0x7FFFFFFF -} OMX_AUDIO_AMRDTXMODETYPE; - - -/** AMR params */ -typedef struct OMX_AUDIO_PARAM_AMRTYPE { - 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_U32 nChannels; /**< Number of channels */ - OMX_U32 nBitRate; /**< Bit rate read only field */ - OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode; /**< AMR Band Mode enumeration */ - OMX_AUDIO_AMRDTXMODETYPE eAMRDTXMode; /**< AMR DTX Mode enumeration */ - OMX_AUDIO_AMRFRAMEFORMATTYPE eAMRFrameFormat; /**< AMR frame format enumeration */ -} OMX_AUDIO_PARAM_AMRTYPE; - - -/** GSM_FR (ETSI 06.10, 3GPP 46.010) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_GSMFRTYPE { - 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_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_GSMFRTYPE; - - -/** GSM-HR (ETSI 06.20, 3GPP 46.020) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_GSMHRTYPE { - 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_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_GSMHRTYPE; - - -/** GSM-EFR (ETSI 06.60, 3GPP 46.060) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_GSMEFRTYPE { - 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_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_GSMEFRTYPE; - - -/** TDMA FR (TIA/EIA-136-420, VSELP 7.95kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_TDMAFRTYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_TDMAFRTYPE; - - -/** TDMA EFR (TIA/EIA-136-410, ACELP 7.4kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_TDMAEFRTYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_TDMAEFRTYPE; - - -/** PDC FR ( RCR-27, VSELP 6.7kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_PDCFRTYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_PDCFRTYPE; - - -/** PDC EFR ( RCR-27, ACELP 6.7kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_PDCEFRTYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_PDCEFRTYPE; - -/** PDC HR ( RCR-27, PSI-CELP 3.45kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_PDCHRTYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ - OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ -} OMX_AUDIO_PARAM_PDCHRTYPE; - - -/** CDMA Rate types */ -typedef enum OMX_AUDIO_CDMARATETYPE { - OMX_AUDIO_CDMARateBlank = 0, /**< CDMA encoded frame is blank */ - OMX_AUDIO_CDMARateFull, /**< CDMA encoded frame in full rate */ - OMX_AUDIO_CDMARateHalf, /**< CDMA encoded frame in half rate */ - OMX_AUDIO_CDMARateQuarter, /**< CDMA encoded frame in quarter rate */ - OMX_AUDIO_CDMARateEighth, /**< CDMA encoded frame in eighth rate (DTX)*/ - OMX_AUDIO_CDMARateErasure, /**< CDMA erasure frame */ - OMX_AUDIO_CDMARateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_CDMARateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_CDMARateMax = 0x7FFFFFFF -} OMX_AUDIO_CDMARATETYPE; - - -/** QCELP8 (TIA/EIA-96, up to 8kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_QCELP8TYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable - rate or unknown bit rates */ - OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */ - OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */ - OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */ -} OMX_AUDIO_PARAM_QCELP8TYPE; - - -/** QCELP13 ( CDMA, EIA/TIA-733, 13.3kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_QCELP13TYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */ - OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */ - OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */ -} OMX_AUDIO_PARAM_QCELP13TYPE; - - -/** EVRC ( CDMA, EIA/TIA-127, RCELP up to 8.55kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_EVRCTYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_AUDIO_CDMARATETYPE eCDMARate; /**< actual Frame rate */ - OMX_BOOL bRATE_REDUCon; /**< RATE_REDUCtion is requested for this frame */ - OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */ - OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */ - OMX_BOOL bHiPassFilter; /**< Enable encoder's High Pass Filter */ - OMX_BOOL bNoiseSuppressor; /**< Enable encoder's noise suppressor pre-processing */ - OMX_BOOL bPostFilter; /**< Enable decoder's post Filter */ -} OMX_AUDIO_PARAM_EVRCTYPE; - - -/** SMV ( up to 8.55kbps coder) stream format parameters */ -typedef struct OMX_AUDIO_PARAM_SMVTYPE { - 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_U32 nChannels; /**< Number of channels in the data stream (not - necessarily the same as the number of channels - to be rendered. */ - OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */ - OMX_BOOL bRATE_REDUCon; /**< RATE_REDUCtion is requested for this frame */ - OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 ??*/ - OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 ??*/ - OMX_BOOL bHiPassFilter; /**< Enable encoder's High Pass Filter ??*/ - OMX_BOOL bNoiseSuppressor; /**< Enable encoder's noise suppressor pre-processing */ - OMX_BOOL bPostFilter; /**< Enable decoder's post Filter ??*/ -} OMX_AUDIO_PARAM_SMVTYPE; - - -/** MIDI Format - * @ingroup midi - */ -typedef enum OMX_AUDIO_MIDIFORMATTYPE -{ - OMX_AUDIO_MIDIFormatUnknown = 0, /**< MIDI Format unknown or don't care */ - OMX_AUDIO_MIDIFormatSMF0, /**< Standard MIDI File Type 0 */ - OMX_AUDIO_MIDIFormatSMF1, /**< Standard MIDI File Type 1 */ - OMX_AUDIO_MIDIFormatSMF2, /**< Standard MIDI File Type 2 */ - OMX_AUDIO_MIDIFormatSPMIDI, /**< SP-MIDI */ - OMX_AUDIO_MIDIFormatXMF0, /**< eXtensible Music Format type 0 */ - OMX_AUDIO_MIDIFormatXMF1, /**< eXtensible Music Format type 1 */ - OMX_AUDIO_MIDIFormatMobileXMF, /**< Mobile XMF (eXtensible Music Format type 2) */ - OMX_AUDIO_MIDIFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_MIDIFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_MIDIFormatMax = 0x7FFFFFFF -} OMX_AUDIO_MIDIFORMATTYPE; - - -/** MIDI params - * @ingroup midi - */ -typedef struct OMX_AUDIO_PARAM_MIDITYPE { - 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_U32 nFileSize; /**< size of the MIDI file in bytes, where the entire - MIDI file passed in, otherwise if 0x0, the MIDI data - is merged and streamed (instead of passed as an - entire MIDI file) */ - OMX_BU32 sMaxPolyphony; /**< Specifies the maximum simultaneous polyphonic - voices. A value of zero indicates that the default - polyphony of the device is used */ - OMX_BOOL bLoadDefaultSound; /**< Whether to load default sound - bank at initialization */ - OMX_AUDIO_MIDIFORMATTYPE eMidiFormat; /**< Version of the MIDI file */ -} OMX_AUDIO_PARAM_MIDITYPE; - - -/** Type of the MIDI sound bank - * @ingroup midi - */ -typedef enum OMX_AUDIO_MIDISOUNDBANKTYPE { - OMX_AUDIO_MIDISoundBankUnused = 0, /**< unused/unknown soundbank type */ - OMX_AUDIO_MIDISoundBankDLS1, /**< DLS version 1 */ - OMX_AUDIO_MIDISoundBankDLS2, /**< DLS version 2 */ - OMX_AUDIO_MIDISoundBankMobileDLSBase, /**< Mobile DLS, using the base functionality */ - OMX_AUDIO_MIDISoundBankMobileDLSPlusOptions, /**< Mobile DLS, using the specification-defined optional feature set */ - OMX_AUDIO_MIDISoundBankKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_MIDISoundBankVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_MIDISoundBankMax = 0x7FFFFFFF -} OMX_AUDIO_MIDISOUNDBANKTYPE; - - -/** Bank Layout describes how bank MSB & LSB are used in the DLS instrument definitions sound bank - * @ingroup midi - */ -typedef enum OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE { - OMX_AUDIO_MIDISoundBankLayoutUnused = 0, /**< unused/unknown soundbank type */ - OMX_AUDIO_MIDISoundBankLayoutGM, /**< GS layout (based on bank MSB 0x00) */ - OMX_AUDIO_MIDISoundBankLayoutGM2, /**< General MIDI 2 layout (using MSB 0x78/0x79, LSB 0x00) */ - OMX_AUDIO_MIDISoundBankLayoutUser, /**< Does not conform to any bank numbering standards */ - OMX_AUDIO_MIDISoundBankLayoutKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_MIDISoundBankLayoutVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_MIDISoundBankLayoutMax = 0x7FFFFFFF -} OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE; - - -/** MIDI params to load/unload user soundbank - * @ingroup midi - */ -typedef struct OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE { - 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_U32 nDLSIndex; /**< DLS file index to be loaded */ - OMX_U32 nDLSSize; /**< Size in bytes */ - OMX_PTR pDLSData; /**< Pointer to DLS file data */ - OMX_AUDIO_MIDISOUNDBANKTYPE eMidiSoundBank; /**< Midi sound bank type enumeration */ - OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE eMidiSoundBankLayout; /**< Midi sound bank layout enumeration */ -} OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE; - - -/** Structure for Live MIDI events and MIP messages. - * (MIP = Maximum Instantaneous Polyphony; part of the SP-MIDI standard.) - * @ingroup midi - */ -typedef struct OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE { - 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_U32 nMidiEventSize; /**< Size of immediate MIDI events or MIP message in bytes */ - OMX_U8 nMidiEvents[1]; /**< MIDI event array to be rendered immediately, or an - array for the MIP message buffer, where the size is - indicated by nMidiEventSize */ -} OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE; - - -/** MIDI sound bank/ program pair in a given channel - * @ingroup midi - */ -typedef struct OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE { - 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_U32 nChannel; /**< Valid channel values range from 1 to 16 */ - OMX_U16 nIDProgram; /**< Valid program ID range is 1 to 128 */ - OMX_U16 nIDSoundBank; /**< Sound bank ID */ - OMX_U32 nUserSoundBankIndex;/**< User soundbank index, easier to access soundbanks - by index if multiple banks are present */ -} OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE; - - -/** MIDI control - * @ingroup midi - */ -typedef struct OMX_AUDIO_CONFIG_MIDICONTROLTYPE { - 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_BS32 sPitchTransposition; /**< Pitch transposition in semitones, stored as Q22.10 - format based on JAVA MMAPI (JSR-135) requirement */ - OMX_BU32 sPlayBackRate; /**< Relative playback rate, stored as Q14.17 fixed-point - number based on JSR-135 requirement */ - OMX_BU32 sTempo ; /**< Tempo in beats per minute (BPM), stored as Q22.10 - fixed-point number based on JSR-135 requirement */ - OMX_U32 nMaxPolyphony; /**< Specifies the maximum simultaneous polyphonic - voices. A value of zero indicates that the default - polyphony of the device is used */ - OMX_U32 nNumRepeat; /**< Number of times to repeat playback */ - OMX_U32 nStopTime; /**< Time in milliseconds to indicate when playback - will stop automatically. Set to zero if not used */ - OMX_U16 nChannelMuteMask; /**< 16 bit mask for channel mute status */ - OMX_U16 nChannelSoloMask; /**< 16 bit mask for channel solo status */ - OMX_U32 nTrack0031MuteMask; /**< 32 bit mask for track mute status. Note: This is for tracks 0-31 */ - OMX_U32 nTrack3263MuteMask; /**< 32 bit mask for track mute status. Note: This is for tracks 32-63 */ - OMX_U32 nTrack0031SoloMask; /**< 32 bit mask for track solo status. Note: This is for tracks 0-31 */ - OMX_U32 nTrack3263SoloMask; /**< 32 bit mask for track solo status. Note: This is for tracks 32-63 */ - -} OMX_AUDIO_CONFIG_MIDICONTROLTYPE; - - -/** MIDI Playback States - * @ingroup midi - */ -typedef enum OMX_AUDIO_MIDIPLAYBACKSTATETYPE { - OMX_AUDIO_MIDIPlayBackStateUnknown = 0, /**< Unknown state or state does not map to - other defined states */ - OMX_AUDIO_MIDIPlayBackStateClosedEngaged, /**< No MIDI resource is currently open. - The MIDI engine is currently processing - MIDI events. */ - OMX_AUDIO_MIDIPlayBackStateParsing, /**< A MIDI resource is open and is being - primed. The MIDI engine is currently - processing MIDI events. */ - OMX_AUDIO_MIDIPlayBackStateOpenEngaged, /**< A MIDI resource is open and primed but - not playing. The MIDI engine is currently - processing MIDI events. The transition to - this state is only possible from the - OMX_AUDIO_MIDIPlayBackStatePlaying state, - when the 'playback head' reaches the end - of media data or the playback stops due - to stop time set.*/ - OMX_AUDIO_MIDIPlayBackStatePlaying, /**< A MIDI resource is open and currently - playing. The MIDI engine is currently - processing MIDI events.*/ - OMX_AUDIO_MIDIPlayBackStatePlayingPartially, /**< Best-effort playback due to SP-MIDI/DLS - resource constraints */ - OMX_AUDIO_MIDIPlayBackStatePlayingSilently, /**< Due to system resource constraints and - SP-MIDI content constraints, there is - no audible MIDI content during playback - currently. The situation may change if - resources are freed later.*/ - OMX_AUDIO_MIDIPlayBackStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_MIDIPlayBackStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_MIDIPlayBackStateMax = 0x7FFFFFFF -} OMX_AUDIO_MIDIPLAYBACKSTATETYPE; - - -/** MIDI status - * @ingroup midi - */ -typedef struct OMX_AUDIO_CONFIG_MIDISTATUSTYPE { - 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_U16 nNumTracks; /**< Number of MIDI tracks in the file, read only field. - NOTE: May not return a meaningful value until the entire - file is parsed and buffered. */ - OMX_U32 nDuration; /**< The length of the currently open MIDI resource - in milliseconds. NOTE: May not return a meaningful value - until the entire file is parsed and buffered. */ - OMX_U32 nPosition; /**< Current Position of the MIDI resource being played - in milliseconds */ - OMX_BOOL bVibra; /**< Does Vibra track exist? NOTE: May not return a meaningful - value until the entire file is parsed and buffered. */ - OMX_U32 nNumMetaEvents; /**< Total number of MIDI Meta Events in the currently - open MIDI resource. NOTE: May not return a meaningful value - until the entire file is parsed and buffered. */ - OMX_U32 nNumActiveVoices; /**< Number of active voices in the currently playing - MIDI resource. NOTE: May not return a meaningful value until - the entire file is parsed and buffered. */ - OMX_AUDIO_MIDIPLAYBACKSTATETYPE eMIDIPlayBackState; /**< MIDI playback state enumeration, read only field */ -} OMX_AUDIO_CONFIG_MIDISTATUSTYPE; - - -/** MIDI Meta Event structure one per Meta Event. - * MIDI Meta Events are like audio metadata, except that they are interspersed - * with the MIDI content throughout the file and are not localized in the header. - * As such, it is necessary to retrieve information about these Meta Events from - * the engine, as it encounters these Meta Events within the MIDI content. - * For example, SMF files can have up to 14 types of MIDI Meta Events (copyright, - * author, default tempo, etc.) scattered throughout the file. - * @ingroup midi - */ -typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE{ - 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_U32 nIndex; /**< Index of Meta Event */ - OMX_U8 nMetaEventType; /**< Meta Event Type, 7bits (i.e. 0 - 127) */ - OMX_U32 nMetaEventSize; /**< size of the Meta Event in bytes */ - OMX_U32 nTrack; /**< track number for the meta event */ - OMX_U32 nPosition; /**< Position of the meta-event in milliseconds */ -} OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE; - - -/** MIDI Meta Event Data structure - one per Meta Event. - * @ingroup midi - */ -typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE{ - 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_U32 nIndex; /**< Index of Meta Event */ - OMX_U32 nMetaEventSize; /**< size of the Meta Event in bytes */ - OMX_U8 nData[1]; /**< array of one or more bytes of meta data - as indicated by the nMetaEventSize field */ -} OMX_AUDIO_CONFIG__MIDIMETAEVENTDATATYPE; - - -/** Audio Volume adjustment for a port */ -typedef struct OMX_AUDIO_CONFIG_VOLUMETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port index indicating which port to - set. Select the input port to set - just that port's volume. Select the - output port to adjust the master - volume. */ - OMX_BOOL bLinear; /**< Is the volume to be set in linear (0.100) - or logarithmic scale (mB) */ - OMX_BS32 sVolume; /**< Volume linear setting in the 0..100 range, OR - Volume logarithmic setting for this port. The values - for volume are in mB (millibels = 1/100 dB) relative - to a gain of 1 (e.g. the output is the same as the - input level). Values are in mB from nMax - (maximum volume) to nMin mB (typically negative). - Since the volume is "voltage" - and not a "power", it takes a setting of - -600 mB to decrease the volume by 1/2. If - a component cannot accurately set the - volume to the requested value, it must - set the volume to the closest value BELOW - the requested value. When getting the - volume setting, the current actual volume - must be returned. */ -} OMX_AUDIO_CONFIG_VOLUMETYPE; - - -/** Audio Volume adjustment for a channel */ -typedef struct OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port index indicating which port to - set. Select the input port to set - just that port's volume. Select the - output port to adjust the master - volume. */ - OMX_U32 nChannel; /**< channel to select from 0 to N-1, - using OMX_ALL to apply volume settings - to all channels */ - OMX_BOOL bLinear; /**< Is the volume to be set in linear (0.100) or - logarithmic scale (mB) */ - OMX_BS32 sVolume; /**< Volume linear setting in the 0..100 range, OR - Volume logarithmic setting for this port. - The values for volume are in mB - (millibels = 1/100 dB) relative to a gain - of 1 (e.g. the output is the same as the - input level). Values are in mB from nMax - (maximum volume) to nMin mB (typically negative). - Since the volume is "voltage" - and not a "power", it takes a setting of - -600 mB to decrease the volume by 1/2. If - a component cannot accurately set the - volume to the requested value, it must - set the volume to the closest value BELOW - the requested value. When getting the - volume setting, the current actual volume - must be returned. */ - OMX_BOOL bIsMIDI; /**< TRUE if nChannel refers to a MIDI channel, - FALSE otherwise */ -} OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE; - - -/** Audio balance setting */ -typedef struct OMX_AUDIO_CONFIG_BALANCETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port index indicating which port to - set. Select the input port to set - just that port's balance. Select the - output port to adjust the master - balance. */ - OMX_S32 nBalance; /**< balance setting for this port - (-100 to 100, where -100 indicates - all left, and no right */ -} OMX_AUDIO_CONFIG_BALANCETYPE; - - -/** Audio Port mute */ -typedef struct OMX_AUDIO_CONFIG_MUTETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port index indicating which port to - set. Select the input port to set - just that port's mute. Select the - output port to adjust the master - mute. */ - OMX_BOOL bMute; /**< Mute setting for this port */ -} OMX_AUDIO_CONFIG_MUTETYPE; - - -/** Audio Channel mute */ -typedef struct OMX_AUDIO_CONFIG_CHANNELMUTETYPE { - 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_U32 nChannel; /**< channel to select from 0 to N-1, - using OMX_ALL to apply mute settings - to all channels */ - OMX_BOOL bMute; /**< Mute setting for this channel */ - OMX_BOOL bIsMIDI; /**< TRUE if nChannel refers to a MIDI channel, - FALSE otherwise */ -} OMX_AUDIO_CONFIG_CHANNELMUTETYPE; - - - -/** Enable / Disable for loudness control, which boosts bass and to a - * smaller extent high end frequencies to compensate for hearing - * ability at the extreme ends of the audio spectrum - */ -typedef struct OMX_AUDIO_CONFIG_LOUDNESSTYPE { - 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_BOOL bLoudness; /**< Enable/disable for loudness */ -} OMX_AUDIO_CONFIG_LOUDNESSTYPE; - - -/** Enable / Disable for bass, which controls low frequencies - */ -typedef struct OMX_AUDIO_CONFIG_BASSTYPE { - 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_BOOL bEnable; /**< Enable/disable for bass control */ - OMX_S32 nBass; /**< bass setting for the port, as a - continuous value from -100 to 100 - (0 means no change in bass level)*/ -} OMX_AUDIO_CONFIG_BASSTYPE; - - -/** Enable / Disable for treble, which controls high frequencies tones - */ -typedef struct OMX_AUDIO_CONFIG_TREBLETYPE { - 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_BOOL bEnable; /**< Enable/disable for treble control */ - OMX_S32 nTreble; /**< treble setting for the port, as a - continuous value from -100 to 100 - (0 means no change in treble level) */ -} OMX_AUDIO_CONFIG_TREBLETYPE; - - -/** An equalizer is typically used for two reasons: to compensate for an - * sub-optimal frequency response of a system to make it sound more natural - * or to create intentionally some unnatural coloring to the sound to create - * an effect. - * @ingroup effects - */ -typedef struct OMX_AUDIO_CONFIG_EQUALIZERTYPE { - 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_BOOL bEnable; /**< Enable/disable for equalizer */ - OMX_BU32 sBandIndex; /**< Band number to be set. Upper Limit is - N-1, where N is the number of bands, lower limit is 0 */ - OMX_BU32 sCenterFreq; /**< Center frequecies in Hz. This is a - read only element and is used to determine - the lower, center and upper frequency of - this band. */ - OMX_BS32 sBandLevel; /**< band level in millibels */ -} OMX_AUDIO_CONFIG_EQUALIZERTYPE; - - -/** Stereo widening mode type - * @ingroup effects - */ -typedef enum OMX_AUDIO_STEREOWIDENINGTYPE { - OMX_AUDIO_StereoWideningHeadphones, /**< Stereo widening for loudspeakers */ - OMX_AUDIO_StereoWideningLoudspeakers, /**< Stereo widening for closely spaced loudspeakers */ - OMX_AUDIO_StereoWideningKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_StereoWideningVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_StereoWideningMax = 0x7FFFFFFF -} OMX_AUDIO_STEREOWIDENINGTYPE; - - -/** Control for stereo widening, which is a special 2-channel - * case of the audio virtualizer effect. For example, for 5.1-channel - * output, it translates to virtual surround sound. - * @ingroup effects - */ -typedef struct OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE { - 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_BOOL bEnable; /**< Enable/disable for stereo widening control */ - OMX_AUDIO_STEREOWIDENINGTYPE eWideningType; /**< Stereo widening algorithm type */ - OMX_U32 nStereoWidening; /**< stereo widening setting for the port, - as a continuous value from 0 to 100 */ -} OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE; - - -/** The chorus effect (or ``choralizer'') is any signal processor which makes - * one sound source (such as a voice) sound like many such sources singing - * (or playing) in unison. Since performance in unison is never exact, chorus - * effects simulate this by making independently modified copies of the input - * signal. Modifications may include (1) delay, (2) frequency shift, and - * (3) amplitude modulation. - * @ingroup effects - */ -typedef struct OMX_AUDIO_CONFIG_CHORUSTYPE { - 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_BOOL bEnable; /**< Enable/disable for chorus */ - OMX_BU32 sDelay; /**< average delay in milliseconds */ - OMX_BU32 sModulationRate; /**< rate of modulation in millihertz */ - OMX_U32 nModulationDepth; /**< depth of modulation as a percentage of - delay (i.e. 0 to 100) */ - OMX_BU32 nFeedback; /**< Feedback from chorus output to input in percentage */ -} OMX_AUDIO_CONFIG_CHORUSTYPE; - - -/** Reverberation is part of the reflected sound that follows the early - * reflections. In a typical room, this consists of a dense succession of - * echoes whose energy decays exponentially. The reverberation effect structure - * as defined here includes both (early) reflections as well as (late) reverberations. - * @ingroup effects - */ -typedef struct OMX_AUDIO_CONFIG_REVERBERATIONTYPE { - 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_BOOL bEnable; /**< Enable/disable for reverberation control */ - OMX_BS32 sRoomLevel; /**< Intensity level for the whole room effect - (i.e. both early reflections and late - reverberation) in millibels */ - OMX_BS32 sRoomHighFreqLevel; /**< Attenuation at high frequencies - relative to the intensity at low - frequencies in millibels */ - OMX_BS32 sReflectionsLevel; /**< Intensity level of early reflections - (relative to room value), in millibels */ - OMX_BU32 sReflectionsDelay; /**< Delay time of the first reflection relative - to the direct path, in milliseconds */ - OMX_BS32 sReverbLevel; /**< Intensity level of late reverberation - relative to room level, in millibels */ - OMX_BU32 sReverbDelay; /**< Time delay from the first early reflection - to the beginning of the late reverberation - section, in milliseconds */ - OMX_BU32 sDecayTime; /**< Late reverberation decay time at low - frequencies, in milliseconds */ - OMX_BU32 nDecayHighFreqRatio; /**< Ratio of high frequency decay time relative - to low frequency decay time in percent */ - OMX_U32 nDensity; /**< Modal density in the late reverberation decay, - in percent (i.e. 0 - 100) */ - OMX_U32 nDiffusion; /**< Echo density in the late reverberation decay, - in percent (i.e. 0 - 100) */ - OMX_BU32 sReferenceHighFreq; /**< Reference high frequency in Hertz. This is - the frequency used as the reference for all - the high-frequency settings above */ - -} OMX_AUDIO_CONFIG_REVERBERATIONTYPE; - - -/** Possible settings for the Echo Cancelation structure to use - * @ingroup effects - */ -typedef enum OMX_AUDIO_ECHOCANTYPE { - OMX_AUDIO_EchoCanOff = 0, /**< Echo Cancellation is disabled */ - OMX_AUDIO_EchoCanNormal, /**< Echo Cancellation normal operation - - echo from plastics and face */ - OMX_AUDIO_EchoCanHFree, /**< Echo Cancellation optimized for - Hands Free operation */ - OMX_AUDIO_EchoCanCarKit, /**< Echo Cancellation optimized for - Car Kit (longer echo) */ - OMX_AUDIO_EchoCanKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_AUDIO_EchoCanVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_AUDIO_EchoCanMax = 0x7FFFFFFF -} OMX_AUDIO_ECHOCANTYPE; - - -/** Enable / Disable for echo cancelation, which removes undesired echo's - * from the audio - * @ingroup effects - */ -typedef struct OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE { - 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_AUDIO_ECHOCANTYPE eEchoCancelation; /**< Echo cancelation settings */ -} OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE; - - -/** Enable / Disable for noise reduction, which undesired noise from - * the audio - * @ingroup effects - */ -typedef struct OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE { - 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_BOOL bNoiseReduction; /**< Enable/disable for noise reduction */ -} OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE; - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ - diff --git a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Component.h b/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Component.h deleted file mode 100644 index d595640..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Component.h +++ /dev/null @@ -1,579 +0,0 @@ -/* - * Copyright (c) 2008 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_Component.h - OpenMax IL version 1.1.2 - * The OMX_Component header file contains the definitions used to define - * the public interface of a component. This header file is intended to - * be used by both the application and the component. - */ - -#ifndef OMX_Component_h -#define OMX_Component_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 -#include -#include -#include - -/** @ingroup comp */ -typedef enum OMX_PORTDOMAINTYPE { - OMX_PortDomainAudio, - OMX_PortDomainVideo, - OMX_PortDomainImage, - OMX_PortDomainOther, - OMX_PortDomainKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_PortDomainVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_PortDomainMax = 0x7ffffff -} OMX_PORTDOMAINTYPE; - -/** @ingroup comp */ -typedef struct OMX_PARAM_PORTDEFINITIONTYPE { - OMX_U32 nSize; /**< Size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Port number the structure applies to */ - OMX_DIRTYPE eDir; /**< Direction (input or output) of this port */ - OMX_U32 nBufferCountActual; /**< The actual number of buffers allocated on this port */ - OMX_U32 nBufferCountMin; /**< The minimum number of buffers this port requires */ - OMX_U32 nBufferSize; /**< Size, in bytes, for buffers to be used for this channel */ - OMX_BOOL bEnabled; /**< Ports default to enabled and are enabled/disabled by - OMX_CommandPortEnable/OMX_CommandPortDisable. - When disabled a port is unpopulated. A disabled port - is not populated with buffers on a transition to IDLE. */ - OMX_BOOL bPopulated; /**< Port is populated with all of its buffers as indicated by - nBufferCountActual. A disabled port is always unpopulated. - An enabled port is populated on a transition to OMX_StateIdle - and unpopulated on a transition to loaded. */ - OMX_PORTDOMAINTYPE eDomain; /**< Domain of the port. Determines the contents of metadata below. */ - union { - OMX_AUDIO_PORTDEFINITIONTYPE audio; - OMX_VIDEO_PORTDEFINITIONTYPE video; - OMX_IMAGE_PORTDEFINITIONTYPE image; - OMX_OTHER_PORTDEFINITIONTYPE other; - } format; - OMX_BOOL bBuffersContiguous; - OMX_U32 nBufferAlignment; -} OMX_PARAM_PORTDEFINITIONTYPE; - -/** @ingroup comp */ -typedef struct OMX_PARAM_U32TYPE { - OMX_U32 nSize; /**< Size of this structure, in Bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< port that this structure applies to */ - OMX_U32 nU32; /**< U32 value */ -} OMX_PARAM_U32TYPE; - -/** @ingroup rpm */ -typedef enum OMX_SUSPENSIONPOLICYTYPE { - OMX_SuspensionDisabled, /**< No suspension; v1.0 behavior */ - OMX_SuspensionEnabled, /**< Suspension allowed */ - OMX_SuspensionPolicyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_SuspensionPolicyStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_SuspensionPolicyMax = 0x7fffffff -} OMX_SUSPENSIONPOLICYTYPE; - -/** @ingroup rpm */ -typedef struct OMX_PARAM_SUSPENSIONPOLICYTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_SUSPENSIONPOLICYTYPE ePolicy; -} OMX_PARAM_SUSPENSIONPOLICYTYPE; - -/** @ingroup rpm */ -typedef enum OMX_SUSPENSIONTYPE { - OMX_NotSuspended, /**< component is not suspended */ - OMX_Suspended, /**< component is suspended */ - OMX_SuspensionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_SuspensionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_SuspendMax = 0x7FFFFFFF -} OMX_SUSPENSIONTYPE; - -/** @ingroup rpm */ -typedef struct OMX_PARAM_SUSPENSIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_SUSPENSIONTYPE eType; -} OMX_PARAM_SUSPENSIONTYPE ; - -typedef struct OMX_CONFIG_BOOLEANTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bEnabled; -} OMX_CONFIG_BOOLEANTYPE; - -/* Parameter specifying the content uri to use. */ -/** @ingroup cp */ -typedef struct OMX_PARAM_CONTENTURITYPE -{ - OMX_U32 nSize; /**< size of the structure in bytes, including - actual URI name */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U8 contentURI[1]; /**< The URI name */ -} OMX_PARAM_CONTENTURITYPE; - -/* Parameter specifying the pipe to use. */ -/** @ingroup cp */ -typedef struct OMX_PARAM_CONTENTPIPETYPE -{ - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_HANDLETYPE hPipe; /**< The pipe handle*/ -} OMX_PARAM_CONTENTPIPETYPE; - -/** @ingroup rpm */ -typedef struct OMX_RESOURCECONCEALMENTTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_BOOL bResourceConcealmentForbidden; /**< disallow the use of resource concealment - methods (like degrading algorithm quality to - lower resource consumption or functional bypass) - on a component as a resolution to resource conflicts. */ -} OMX_RESOURCECONCEALMENTTYPE; - - -/** @ingroup metadata */ -typedef enum OMX_METADATACHARSETTYPE { - OMX_MetadataCharsetUnknown = 0, - OMX_MetadataCharsetASCII, - OMX_MetadataCharsetBinary, - OMX_MetadataCharsetCodePage1252, - OMX_MetadataCharsetUTF8, - OMX_MetadataCharsetJavaConformantUTF8, - OMX_MetadataCharsetUTF7, - OMX_MetadataCharsetImapUTF7, - OMX_MetadataCharsetUTF16LE, - OMX_MetadataCharsetUTF16BE, - OMX_MetadataCharsetGB12345, - OMX_MetadataCharsetHZGB2312, - OMX_MetadataCharsetGB2312, - OMX_MetadataCharsetGB18030, - OMX_MetadataCharsetGBK, - OMX_MetadataCharsetBig5, - OMX_MetadataCharsetISO88591, - OMX_MetadataCharsetISO88592, - OMX_MetadataCharsetISO88593, - OMX_MetadataCharsetISO88594, - OMX_MetadataCharsetISO88595, - OMX_MetadataCharsetISO88596, - OMX_MetadataCharsetISO88597, - OMX_MetadataCharsetISO88598, - OMX_MetadataCharsetISO88599, - OMX_MetadataCharsetISO885910, - OMX_MetadataCharsetISO885913, - OMX_MetadataCharsetISO885914, - OMX_MetadataCharsetISO885915, - OMX_MetadataCharsetShiftJIS, - OMX_MetadataCharsetISO2022JP, - OMX_MetadataCharsetISO2022JP1, - OMX_MetadataCharsetISOEUCJP, - OMX_MetadataCharsetSMS7Bit, - OMX_MetadataCharsetKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_MetadataCharsetVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_MetadataCharsetTypeMax= 0x7FFFFFFF -} OMX_METADATACHARSETTYPE; - -/** @ingroup metadata */ -typedef enum OMX_METADATASCOPETYPE -{ - OMX_MetadataScopeAllLevels, - OMX_MetadataScopeTopLevel, - OMX_MetadataScopePortLevel, - OMX_MetadataScopeNodeLevel, - OMX_MetadataScopeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_MetadataScopeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_MetadataScopeTypeMax = 0x7fffffff -} OMX_METADATASCOPETYPE; - -/** @ingroup metadata */ -typedef enum OMX_METADATASEARCHMODETYPE -{ - OMX_MetadataSearchValueSizeByIndex, - OMX_MetadataSearchItemByIndex, - OMX_MetadataSearchNextItemByKey, - OMX_MetadataSearchKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_MetadataSearchVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_MetadataSearchTypeMax = 0x7fffffff -} OMX_METADATASEARCHMODETYPE; -/** @ingroup metadata */ -typedef struct OMX_CONFIG_METADATAITEMCOUNTTYPE -{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_METADATASCOPETYPE eScopeMode; - OMX_U32 nScopeSpecifier; - OMX_U32 nMetadataItemCount; -} OMX_CONFIG_METADATAITEMCOUNTTYPE; - -/** @ingroup metadata */ -typedef struct OMX_CONFIG_METADATAITEMTYPE -{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_METADATASCOPETYPE eScopeMode; - OMX_U32 nScopeSpecifier; - OMX_U32 nMetadataItemIndex; - OMX_METADATASEARCHMODETYPE eSearchMode; - OMX_METADATACHARSETTYPE eKeyCharset; - OMX_U8 nKeySizeUsed; - OMX_U8 nKey[128]; - OMX_METADATACHARSETTYPE eValueCharset; - OMX_STRING sLanguageCountry; - OMX_U32 nValueMaxSize; - OMX_U32 nValueSizeUsed; - OMX_U8 nValue[1]; -} OMX_CONFIG_METADATAITEMTYPE; - -/* @ingroup metadata */ -typedef struct OMX_CONFIG_CONTAINERNODECOUNTTYPE -{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bAllKeys; - OMX_U32 nParentNodeID; - OMX_U32 nNumNodes; -} OMX_CONFIG_CONTAINERNODECOUNTTYPE; - -/** @ingroup metadata */ -typedef struct OMX_CONFIG_CONTAINERNODEIDTYPE -{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bAllKeys; - OMX_U32 nParentNodeID; - OMX_U32 nNodeIndex; - OMX_U32 nNodeID; - OMX_STRING cNodeName; - OMX_BOOL bIsLeafType; -} OMX_CONFIG_CONTAINERNODEIDTYPE; - -/** @ingroup metadata */ -typedef struct OMX_PARAM_METADATAFILTERTYPE -{ - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bAllKeys; /* if true then this structure refers to all keys and - * the three key fields below are ignored */ - OMX_METADATACHARSETTYPE eKeyCharset; - OMX_U32 nKeySizeUsed; - OMX_U8 nKey [128]; - OMX_U32 nLanguageCountrySizeUsed; - OMX_U8 nLanguageCountry[128]; - OMX_BOOL bEnabled; /* if true then key is part of filter (e.g. - * retained for query later). If false then - * key is not part of filter */ -} OMX_PARAM_METADATAFILTERTYPE; - -/** The OMX_HANDLETYPE structure defines the component handle. The component - * handle is used to access all of the component's public methods and also - * contains pointers to the component's private data area. The component - * handle is initialized by the OMX core (with help from the component) - * during the process of loading the component. After the component is - * successfully loaded, the application can safely access any of the - * component's public functions (although some may return an error because - * the state is inappropriate for the access). - * - * @ingroup comp - */ -typedef struct OMX_COMPONENTTYPE -{ - /** The size of this structure, in bytes. It is the responsibility - of the allocator of this structure to fill in this value. Since - this structure is allocated by the GetHandle function, this - function will fill in this value. */ - OMX_U32 nSize; - - /** nVersion is the version of the OMX specification that the structure - is built against. It is the responsibility of the creator of this - structure to initialize this value and every user of this structure - should verify that it knows how to use the exact version of - this structure found herein. */ - OMX_VERSIONTYPE nVersion; - - /** pComponentPrivate is a pointer to the component private data area. - This member is allocated and initialized by the component when the - component is first loaded. The application should not access this - data area. */ - OMX_PTR pComponentPrivate; - - /** pApplicationPrivate is a pointer that is a parameter to the - OMX_GetHandle method, and contains an application private value - provided by the IL client. This application private data is - returned to the IL Client by OMX in all callbacks */ - OMX_PTR pApplicationPrivate; - - /** refer to OMX_GetComponentVersion in OMX_core.h or the OMX IL - specification for details on the GetComponentVersion method. - */ - OMX_ERRORTYPE (*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); - - /** refer to OMX_SendCommand in OMX_core.h or the OMX IL - specification for details on the SendCommand method. - */ - OMX_ERRORTYPE (*SendCommand)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_COMMANDTYPE Cmd, - OMX_IN OMX_U32 nParam1, - OMX_IN OMX_PTR pCmdData); - - /** refer to OMX_GetParameter in OMX_core.h or the OMX IL - specification for details on the GetParameter method. - */ - OMX_ERRORTYPE (*GetParameter)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR pComponentParameterStructure); - - - /** refer to OMX_SetParameter in OMX_core.h or the OMX IL - specification for details on the SetParameter method. - */ - OMX_ERRORTYPE (*SetParameter)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentParameterStructure); - - - /** refer to OMX_GetConfig in OMX_core.h or the OMX IL - specification for details on the GetConfig method. - */ - OMX_ERRORTYPE (*GetConfig)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_INOUT OMX_PTR pComponentConfigStructure); - - - /** refer to OMX_SetConfig in OMX_core.h or the OMX IL - specification for details on the SetConfig method. - */ - OMX_ERRORTYPE (*SetConfig)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentConfigStructure); - - - /** refer to OMX_GetExtensionIndex in OMX_core.h or the OMX IL - specification for details on the GetExtensionIndex method. - */ - OMX_ERRORTYPE (*GetExtensionIndex)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, - OMX_OUT OMX_INDEXTYPE* pIndexType); - - - /** refer to OMX_GetState in OMX_core.h or the OMX IL - specification for details on the GetState method. - */ - OMX_ERRORTYPE (*GetState)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_STATETYPE* pState); - - - /** The ComponentTunnelRequest method will interact with another OMX - component to determine if tunneling is possible and to setup the - tunneling. The return codes for this method can be used to - determine if tunneling is not possible, or if tunneling is not - supported. - - Base profile components (i.e. non-interop) do not support this - method and should return OMX_ErrorNotImplemented - - The interop profile component MUST support tunneling to another - interop profile component with a compatible port parameters. - A component may also support proprietary communication. - - If proprietary communication is supported the negotiation of - proprietary communication is done outside of OMX in a vendor - specific way. It is only required that the proper result be - returned and the details of how the setup is done is left - to the component implementation. - - When this method is invoked when nPort in an output port, the - component will: - 1. Populate the pTunnelSetup structure with the output port's - requirements and constraints for the tunnel. - - When this method is invoked when nPort in an input port, the - component will: - 1. Query the necessary parameters from the output port to - determine if the ports are compatible for tunneling - 2. If the ports are compatible, the component should store - the tunnel step provided by the output port - 3. Determine which port (either input or output) is the buffer - supplier, and call OMX_SetParameter on the output port to - indicate this selection. - - The component will return from this call within 5 msec. - - @param [in] hComp - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle method. - @param [in] nPort - nPort is used to select the port on the component to be used - for tunneling. - @param [in] hTunneledComp - Handle of the component to tunnel with. This is the component - handle returned by the call to the OMX_GetHandle method. When - this parameter is 0x0 the component should setup the port for - communication with the application / IL Client. - @param [in] nPortOutput - nPortOutput is used indicate the port the component should - tunnel with. - @param [in] pTunnelSetup - Pointer to the tunnel setup structure. When nPort is an output port - the component should populate the fields of this structure. When - When nPort is an input port the component should review the setup - provided by the component with the output port. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup tun - */ - - OMX_ERRORTYPE (*ComponentTunnelRequest)( - OMX_IN OMX_HANDLETYPE hComp, - OMX_IN OMX_U32 nPort, - OMX_IN OMX_HANDLETYPE hTunneledComp, - OMX_IN OMX_U32 nTunneledPort, - OMX_INOUT OMX_TUNNELSETUPTYPE* pTunnelSetup); - - /** refer to OMX_UseBuffer in OMX_core.h or the OMX IL - specification for details on the UseBuffer method. - @ingroup buf - */ - OMX_ERRORTYPE (*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); - - /** refer to OMX_AllocateBuffer in OMX_core.h or the OMX IL - specification for details on the AllocateBuffer method. - @ingroup buf - */ - OMX_ERRORTYPE (*AllocateBuffer)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE** ppBuffer, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN OMX_U32 nSizeBytes); - - /** refer to OMX_FreeBuffer in OMX_core.h or the OMX IL - specification for details on the FreeBuffer method. - @ingroup buf - */ - OMX_ERRORTYPE (*FreeBuffer)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); - - /** refer to OMX_EmptyThisBuffer in OMX_core.h or the OMX IL - specification for details on the EmptyThisBuffer method. - @ingroup buf - */ - OMX_ERRORTYPE (*EmptyThisBuffer)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); - - /** refer to OMX_FillThisBuffer in OMX_core.h or the OMX IL - specification for details on the FillThisBuffer method. - @ingroup buf - */ - OMX_ERRORTYPE (*FillThisBuffer)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); - - /** The SetCallbacks method is used by the core to specify the callback - structure from the application to the component. This is a blocking - call. The component will return from this call within 5 msec. - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the GetHandle function. - @param [in] pCallbacks - pointer to an OMX_CALLBACKTYPE structure used to provide the - callback information to the component - @param [in] pAppData - pointer to an application defined value. It is anticipated that - the application will pass a pointer to a data structure or a "this - pointer" in this area to allow the callback (in the application) - to determine the context of the call - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - */ - OMX_ERRORTYPE (*SetCallbacks)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_CALLBACKTYPE* pCallbacks, - OMX_IN OMX_PTR pAppData); - - /** ComponentDeInit method is used to deinitialize the component - providing a means to free any resources allocated at component - initialization. NOTE: After this call the component handle is - not valid for further use. - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the GetHandle function. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - */ - OMX_ERRORTYPE (*ComponentDeInit)( - OMX_IN OMX_HANDLETYPE hComponent); - - /** @ingroup buf */ - OMX_ERRORTYPE (*UseEGLImage)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN void* eglImage); - - OMX_ERRORTYPE (*ComponentRoleEnum)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_U8 *cRole, - OMX_IN OMX_U32 nIndex); - -} OMX_COMPONENTTYPE; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ diff --git a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_ContentPipe.h b/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_ContentPipe.h deleted file mode 100644 index 5f6310c..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_ContentPipe.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2008 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_ContentPipe.h - OpenMax IL version 1.1.2 - * The OMX_ContentPipe header file contains the definitions used to define - * the public interface for content piples. This header file is intended to - * be used by the component. - */ - -#ifndef OMX_CONTENTPIPE_H -#define OMX_CONTENTPIPE_H - -#ifndef KD_EACCES -/* OpenKODE error codes. CPResult values may be zero (indicating success - or one of the following values) */ -#define KD_EACCES (1) -#define KD_EADDRINUSE (2) -#define KD_EAGAIN (5) -#define KD_EBADF (7) -#define KD_EBUSY (8) -#define KD_ECONNREFUSED (9) -#define KD_ECONNRESET (10) -#define KD_EDEADLK (11) -#define KD_EDESTADDRREQ (12) -#define KD_ERANGE (35) -#define KD_EEXIST (13) -#define KD_EFBIG (14) -#define KD_EHOSTUNREACH (15) -#define KD_EINVAL (17) -#define KD_EIO (18) -#define KD_EISCONN (20) -#define KD_EISDIR (21) -#define KD_EMFILE (22) -#define KD_ENAMETOOLONG (23) -#define KD_ENOENT (24) -#define KD_ENOMEM (25) -#define KD_ENOSPC (26) -#define KD_ENOSYS (27) -#define KD_ENOTCONN (28) -#define KD_EPERM (33) -#define KD_ETIMEDOUT (36) -#define KD_EILSEQ (19) -#endif - -/** Map types from OMX standard types only here so interface is as generic as possible. */ -typedef OMX_U32 CPresult; -typedef char * CPstring; -typedef void * CPhandle; -typedef OMX_U32 CPuint; -typedef OMX_S32 CPint; -typedef char CPbyte; -typedef OMX_BOOL CPbool; - -/** enumeration of origin types used in the CP_PIPETYPE's Seek function - * @ingroup cp - */ -typedef enum CP_ORIGINTYPE { - CP_OriginBegin, - CP_OriginCur, - CP_OriginEnd, - CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - CP_OriginVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - CP_OriginMax = 0X7FFFFFFF -} CP_ORIGINTYPE; - -/** enumeration of contact access types used in the CP_PIPETYPE's Open function - * @ingroup cp - */ -typedef enum CP_ACCESSTYPE { - CP_AccessRead, - CP_AccessWrite, - CP_AccessReadWrite , - CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - CP_AccessVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - CP_AccessMax = 0X7FFFFFFF -} CP_ACCESSTYPE; - -/** enumeration of results returned by the CP_PIPETYPE's CheckAvailableBytes function - * @ingroup cp - */ -typedef enum CP_CHECKBYTESRESULTTYPE -{ - CP_CheckBytesOk, /**< There are at least the request number - of bytes available */ - CP_CheckBytesNotReady, /**< The pipe is still retrieving bytes - and presently lacks sufficient bytes. - Client will be called when they are - sufficient bytes are available. */ - CP_CheckBytesInsufficientBytes , /**< The pipe has retrieved all bytes - but those available are less than those - requested */ - CP_CheckBytesAtEndOfStream, /**< The pipe has reached the end of stream - and no more bytes are available. */ - CP_CheckBytesOutOfBuffers, /**< All read/write buffers are currently in use. */ - CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - CP_CheckBytesVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - CP_CheckBytesMax = 0X7FFFFFFF -} CP_CHECKBYTESRESULTTYPE; - -/** enumeration of content pipe events sent to the client callback. - * @ingroup cp - */ -typedef enum CP_EVENTTYPE{ - CP_BytesAvailable, /** bytes requested in a CheckAvailableBytes call are now available*/ - CP_Overflow, /** enumeration of content pipe events sent to the client callback*/ - CP_PipeDisconnected , /** enumeration of content pipe events sent to the client callback*/ - CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - CP_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - CP_EventMax = 0X7FFFFFFF -} CP_EVENTTYPE; - -/** content pipe definition - * @ingroup cp - */ -typedef struct CP_PIPETYPE -{ - /** Open a content stream for reading or writing. */ - CPresult (*Open)( CPhandle* hContent, CPstring szURI, CP_ACCESSTYPE eAccess ); - - /** Close a content stream. */ - CPresult (*Close)( CPhandle hContent ); - - /** Create a content source and open it for writing. */ - CPresult (*Create)( CPhandle *hContent, CPstring szURI ); - - /** Check the that specified number of bytes are available for reading or writing (depending on access type).*/ - CPresult (*CheckAvailableBytes)( CPhandle hContent, CPuint nBytesRequested, CP_CHECKBYTESRESULTTYPE *eResult ); - - /** Seek to certain position in the content relative to the specified origin. */ - CPresult (*SetPosition)( CPhandle hContent, CPint nOffset, CP_ORIGINTYPE eOrigin); - - /** Retrieve the current position relative to the start of the content. */ - CPresult (*GetPosition)( CPhandle hContent, CPuint *pPosition); - - /** Retrieve data of the specified size from the content stream (advance content pointer by size of data). - Note: pipe client provides pointer. This function is appropriate for small high frequency reads. */ - CPresult (*Read)( CPhandle hContent, CPbyte *pData, CPuint nSize); - - /** Retrieve a buffer allocated by the pipe that contains the requested number of bytes. - Buffer contains the next block of bytes, as specified by nSize, of the content. nSize also - returns the size of the block actually read. Content pointer advances the by the returned size. - Note: pipe provides pointer. This function is appropriate for large reads. The client must call - ReleaseReadBuffer when done with buffer. - - In some cases the requested block may not reside in contiguous memory within the - pipe implementation. For instance if the pipe leverages a circular buffer then the requested - block may straddle the boundary of the circular buffer. By default a pipe implementation - performs a copy in this case to provide the block to the pipe client in one contiguous buffer. - If, however, the client sets bForbidCopy, then the pipe returns only those bytes preceding the memory - boundary. Here the client may retrieve the data in segments over successive calls. */ - CPresult (*ReadBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint *nSize, CPbool bForbidCopy); - - /** Release a buffer obtained by ReadBuffer back to the pipe. */ - CPresult (*ReleaseReadBuffer)(CPhandle hContent, CPbyte *pBuffer); - - /** Write data of the specified size to the content (advance content pointer by size of data). - Note: pipe client provides pointer. This function is appropriate for small high frequency writes. */ - CPresult (*Write)( CPhandle hContent, CPbyte *data, CPuint nSize); - - /** Retrieve a buffer allocated by the pipe used to write data to the content. - Client will fill buffer with output data. Note: pipe provides pointer. This function is appropriate - for large writes. The client must call WriteBuffer when done it has filled the buffer with data.*/ - CPresult (*GetWriteBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint nSize); - - /** Deliver a buffer obtained via GetWriteBuffer to the pipe. Pipe will write the - the contents of the buffer to content and advance content pointer by the size of the buffer */ - CPresult (*WriteBuffer)( CPhandle hContent, CPbyte *pBuffer, CPuint nFilledSize); - - /** Register a per-handle client callback with the content pipe. */ - CPresult (*RegisterCallback)( CPhandle hContent, CPresult (*ClientCallback)(CP_EVENTTYPE eEvent, CPuint iParam)); - -} CP_PIPETYPE; - -#endif - diff --git a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Core.h b/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Core.h deleted file mode 100644 index a076f2f..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Core.h +++ /dev/null @@ -1,1431 +0,0 @@ -/* - * Copyright (c) 2008 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_Core.h - OpenMax IL version 1.1.2 - * The OMX_Core header file contains the definitions used by both the - * application and the component to access common items. - */ - -#ifndef OMX_Core_h -#define OMX_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 - - -/** The OMX_COMMANDTYPE enumeration is used to specify the action in the - * OMX_SendCommand macro. - * @ingroup core - */ -typedef enum OMX_COMMANDTYPE -{ - OMX_CommandStateSet, /**< Change the component state */ - OMX_CommandFlush, /**< Flush the data queue(s) of a component */ - OMX_CommandPortDisable, /**< Disable a port on a component. */ - OMX_CommandPortEnable, /**< Enable a port on a component. */ - OMX_CommandMarkBuffer, /**< Mark a component/buffer for observation */ - OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_CommandMax = 0X7FFFFFFF -} OMX_COMMANDTYPE; - - - -/** The OMX_STATETYPE enumeration is used to indicate or change the component - * state. This enumeration reflects the current state of the component when - * used with the OMX_GetState macro or becomes the parameter in a state change - * command when used with the OMX_SendCommand macro. - * - * The component will be in the Loaded state after the component is initially - * loaded into memory. In the Loaded state, the component is not allowed to - * allocate or hold resources other than to build it's internal parameter - * and configuration tables. The application will send one or more - * SetParameters/GetParameters and SetConfig/GetConfig commands to the - * component and the component will record each of these parameter and - * configuration changes for use later. When the application sends the - * Idle command, the component will acquire the resources needed for the - * specified configuration and will transition to the idle state if the - * allocation is successful. If the component cannot successfully - * transition to the idle state for any reason, the state of the component - * shall be fully rolled back to the Loaded state (e.g. all allocated - * resources shall be released). When the component receives the command - * to go to the Executing state, it shall begin processing buffers by - * sending all input buffers it holds to the application. While - * the component is in the Idle state, the application may also send the - * Pause command. If the component receives the pause command while in the - * Idle state, the component shall send all input buffers it holds to the - * application, but shall not begin processing buffers. This will allow the - * application to prefill buffers. - * - * @ingroup comp - */ - -typedef enum OMX_STATETYPE -{ - OMX_StateInvalid, /**< component has detected that it's internal data - structures are corrupted to the point that - it cannot determine it's state properly */ - OMX_StateLoaded, /**< component has been loaded but has not completed - initialization. The OMX_SetParameter macro - and the OMX_GetParameter macro are the only - valid macros allowed to be sent to the - component in this state. */ - OMX_StateIdle, /**< component initialization has been completed - successfully and the component is ready to - to start. */ - OMX_StateExecuting, /**< component has accepted the start command and - is processing data (if data is available) */ - OMX_StatePause, /**< component has received pause command */ - OMX_StateWaitForResources, /**< component is waiting for resources, either after - preemption or before it gets the resources requested. - See specification for complete details. */ - OMX_StateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_StateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_StateMax = 0X7FFFFFFF -} OMX_STATETYPE; - -/** The OMX_ERRORTYPE enumeration defines the standard OMX Errors. These - * errors should cover most of the common failure cases. However, - * vendors are free to add additional error messages of their own as - * long as they follow these rules: - * 1. Vendor error messages shall be in the range of 0x90000000 to - * 0x9000FFFF. - * 2. Vendor error messages shall be defined in a header file provided - * with the component. No error messages are allowed that are - * not defined. - */ -typedef enum OMX_ERRORTYPE -{ - OMX_ErrorNone = 0, - - /** There were insufficient resources to perform the requested operation */ - OMX_ErrorInsufficientResources = (OMX_S32) 0x80001000, - - /** There was an error, but the cause of the error could not be determined */ - OMX_ErrorUndefined = (OMX_S32) 0x80001001, - - /** The component name string was not valid */ - OMX_ErrorInvalidComponentName = (OMX_S32) 0x80001002, - - /** No component with the specified name string was found */ - OMX_ErrorComponentNotFound = (OMX_S32) 0x80001003, - - /** The component specified did not have a "OMX_ComponentInit" or - "OMX_ComponentDeInit entry point */ - OMX_ErrorInvalidComponent = (OMX_S32) 0x80001004, - - /** One or more parameters were not valid */ - OMX_ErrorBadParameter = (OMX_S32) 0x80001005, - - /** The requested function is not implemented */ - OMX_ErrorNotImplemented = (OMX_S32) 0x80001006, - - /** The buffer was emptied before the next buffer was ready */ - OMX_ErrorUnderflow = (OMX_S32) 0x80001007, - - /** The buffer was not available when it was needed */ - OMX_ErrorOverflow = (OMX_S32) 0x80001008, - - /** The hardware failed to respond as expected */ - OMX_ErrorHardware = (OMX_S32) 0x80001009, - - /** The component is in the state OMX_StateInvalid */ - OMX_ErrorInvalidState = (OMX_S32) 0x8000100A, - - /** Stream is found to be corrupt */ - OMX_ErrorStreamCorrupt = (OMX_S32) 0x8000100B, - - /** Ports being connected are not compatible */ - OMX_ErrorPortsNotCompatible = (OMX_S32) 0x8000100C, - - /** Resources allocated to an idle component have been - lost resulting in the component returning to the loaded state */ - OMX_ErrorResourcesLost = (OMX_S32) 0x8000100D, - - /** No more indicies can be enumerated */ - OMX_ErrorNoMore = (OMX_S32) 0x8000100E, - - /** The component detected a version mismatch */ - OMX_ErrorVersionMismatch = (OMX_S32) 0x8000100F, - - /** The component is not ready to return data at this time */ - OMX_ErrorNotReady = (OMX_S32) 0x80001010, - - /** There was a timeout that occurred */ - OMX_ErrorTimeout = (OMX_S32) 0x80001011, - - /** This error occurs when trying to transition into the state you are already in */ - OMX_ErrorSameState = (OMX_S32) 0x80001012, - - /** Resources allocated to an executing or paused component have been - preempted, causing the component to return to the idle state */ - OMX_ErrorResourcesPreempted = (OMX_S32) 0x80001013, - - /** A non-supplier port sends this error to the IL client (via the EventHandler callback) - during the allocation of buffers (on a transition from the LOADED to the IDLE state or - on a port restart) when it deems that it has waited an unusually long time for the supplier - to send it an allocated buffer via a UseBuffer call. */ - OMX_ErrorPortUnresponsiveDuringAllocation = (OMX_S32) 0x80001014, - - /** A non-supplier port sends this error to the IL client (via the EventHandler callback) - during the deallocation of buffers (on a transition from the IDLE to LOADED state or - on a port stop) when it deems that it has waited an unusually long time for the supplier - to request the deallocation of a buffer header via a FreeBuffer call. */ - OMX_ErrorPortUnresponsiveDuringDeallocation = (OMX_S32) 0x80001015, - - /** A supplier port sends this error to the IL client (via the EventHandler callback) - during the stopping of a port (either on a transition from the IDLE to LOADED - state or a port stop) when it deems that it has waited an unusually long time for - the non-supplier to return a buffer via an EmptyThisBuffer or FillThisBuffer call. */ - OMX_ErrorPortUnresponsiveDuringStop = (OMX_S32) 0x80001016, - - /** Attempting a state transtion that is not allowed */ - OMX_ErrorIncorrectStateTransition = (OMX_S32) 0x80001017, - - /* Attempting a command that is not allowed during the present state. */ - OMX_ErrorIncorrectStateOperation = (OMX_S32) 0x80001018, - - /** The values encapsulated in the parameter or config structure are not supported. */ - OMX_ErrorUnsupportedSetting = (OMX_S32) 0x80001019, - - /** The parameter or config indicated by the given index is not supported. */ - OMX_ErrorUnsupportedIndex = (OMX_S32) 0x8000101A, - - /** The port index supplied is incorrect. */ - OMX_ErrorBadPortIndex = (OMX_S32) 0x8000101B, - - /** The port has lost one or more of its buffers and it thus unpopulated. */ - OMX_ErrorPortUnpopulated = (OMX_S32) 0x8000101C, - - /** Component suspended due to temporary loss of resources */ - OMX_ErrorComponentSuspended = (OMX_S32) 0x8000101D, - - /** Component suspended due to an inability to acquire dynamic resources */ - OMX_ErrorDynamicResourcesUnavailable = (OMX_S32) 0x8000101E, - - /** When the macroblock error reporting is enabled the component returns new error - for every frame that has errors */ - OMX_ErrorMbErrorsInFrame = (OMX_S32) 0x8000101F, - - /** A component reports this error when it cannot parse or determine the format of an input stream. */ - OMX_ErrorFormatNotDetected = (OMX_S32) 0x80001020, - - /** The content open operation failed. */ - OMX_ErrorContentPipeOpenFailed = (OMX_S32) 0x80001021, - - /** The content creation operation failed. */ - OMX_ErrorContentPipeCreationFailed = (OMX_S32) 0x80001022, - - /** Separate table information is being used */ - OMX_ErrorSeperateTablesUsed = (OMX_S32) 0x80001023, - - /** Tunneling is unsupported by the component*/ - OMX_ErrorTunnelingUnsupported = (OMX_S32) 0x80001024, - - OMX_ErrorKhronosExtensions = (OMX_S32)0x8F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_ErrorVendorStartUnused = (OMX_S32)0x90000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_ErrorMax = 0x7FFFFFFF -} OMX_ERRORTYPE; - -/** @ingroup core */ -typedef OMX_ERRORTYPE (* OMX_COMPONENTINITTYPE)(OMX_IN OMX_HANDLETYPE hComponent); - -/** @ingroup core */ -typedef struct OMX_COMPONENTREGISTERTYPE -{ - const char * pName; /* Component name, 128 byte limit (including '\0') applies */ - OMX_COMPONENTINITTYPE pInitialize; /* Component instance initialization function */ -} OMX_COMPONENTREGISTERTYPE; - -/** @ingroup core */ -extern OMX_COMPONENTREGISTERTYPE OMX_ComponentRegistered[]; - -/** @ingroup rpm */ -typedef struct OMX_PRIORITYMGMTTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nGroupPriority; /**< Priority of the component group */ - OMX_U32 nGroupID; /**< ID of the component group */ -} OMX_PRIORITYMGMTTYPE; - -/* Component name and Role names are limited to 128 characters including the terminating '\0'. */ -#define OMX_MAX_STRINGNAME_SIZE 128 - -/** @ingroup comp */ -typedef struct OMX_PARAM_COMPONENTROLETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U8 cRole[OMX_MAX_STRINGNAME_SIZE]; /**< name of standard component which defines component role */ -} OMX_PARAM_COMPONENTROLETYPE; - -/** End of Stream Buffer Flag: - * - * A component sets EOS when it has no more data to emit on a particular - * output port. Thus an output port shall set EOS on the last buffer it - * emits. A component's determination of when an output port should - * cease sending data is implemenation specific. - * @ingroup buf - */ - -#define OMX_BUFFERFLAG_EOS 0x00000001 - -/** Start Time Buffer Flag: - * - * The source of a stream (e.g. a demux component) sets the STARTTIME - * flag on the buffer that contains the starting timestamp for the - * stream. The starting timestamp corresponds to the first data that - * should be displayed at startup or after a seek. - * The first timestamp of the stream is not necessarily the start time. - * For instance, in the case of a seek to a particular video frame, - * the target frame may be an interframe. Thus the first buffer of - * the stream will be the intra-frame preceding the target frame and - * the starttime will occur with the target frame (with any other - * required frames required to reconstruct the target intervening). - * - * The STARTTIME flag is directly associated with the buffer's - * timestamp ' thus its association to buffer data and its - * propagation is identical to the timestamp's. - * - * When a Sync Component client receives a buffer with the - * STARTTIME flag it shall perform a SetConfig on its sync port - * using OMX_ConfigTimeClientStartTime and passing the buffer's - * timestamp. - * - * @ingroup buf - */ - -#define OMX_BUFFERFLAG_STARTTIME 0x00000002 - - - -/** Decode Only Buffer Flag: - * - * The source of a stream (e.g. a demux component) sets the DECODEONLY - * flag on any buffer that should shall be decoded but should not be - * displayed. This flag is used, for instance, when a source seeks to - * a target interframe that requires the decode of frames preceding the - * target to facilitate the target's reconstruction. In this case the - * source would emit the frames preceding the target downstream - * but mark them as decode only. - * - * The DECODEONLY is associated with buffer data and propagated in a - * manner identical to the buffer timestamp. - * - * A component that renders data should ignore all buffers with - * the DECODEONLY flag set. - * - * @ingroup buf - */ - -#define OMX_BUFFERFLAG_DECODEONLY 0x00000004 - - -/* Data Corrupt Flag: This flag is set when the IL client believes the data in the associated buffer is corrupt - * @ingroup buf - */ - -#define OMX_BUFFERFLAG_DATACORRUPT 0x00000008 - -/* End of Frame: The buffer contains exactly one end of frame and no data - * occurs after the end of frame. This flag is an optional hint. The absence - * of this flag does not imply the absence of an end of frame within the buffer. - * @ingroup buf -*/ -#define OMX_BUFFERFLAG_ENDOFFRAME 0x00000010 - -/* Sync Frame Flag: This flag is set when the buffer content contains a coded sync frame ' - * a frame that has no dependency on any other frame information - * @ingroup buf - */ -#define OMX_BUFFERFLAG_SYNCFRAME 0x00000020 - -/* Extra data present flag: there is extra data appended to the data stream - * residing in the buffer - * @ingroup buf - */ -#define OMX_BUFFERFLAG_EXTRADATA 0x00000040 - -/** Codec Config Buffer Flag: -* OMX_BUFFERFLAG_CODECCONFIG is an optional flag that is set by an -* output port when all bytes in the buffer form part or all of a set of -* codec specific configuration data. Examples include SPS/PPS nal units -* for OMX_VIDEO_CodingAVC or AudioSpecificConfig data for -* OMX_AUDIO_CodingAAC. Any component that for a given stream sets -* OMX_BUFFERFLAG_CODECCONFIG shall not mix codec configuration bytes -* with frame data in the same buffer, and shall send all buffers -* containing codec configuration bytes before any buffers containing -* frame data that those configurations bytes describe. -* If the stream format for a particular codec has a frame specific -* header at the start of each frame, for example OMX_AUDIO_CodingMP3 or -* OMX_AUDIO_CodingAAC in ADTS mode, then these shall be presented as -* normal without setting OMX_BUFFERFLAG_CODECCONFIG. - * @ingroup buf - */ -#define OMX_BUFFERFLAG_CODECCONFIG 0x00000080 - - - -/** @ingroup buf */ -typedef struct OMX_BUFFERHEADERTYPE -{ - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U8* pBuffer; /**< Pointer to actual block of memory - that is acting as the buffer */ - OMX_U32 nAllocLen; /**< size of the buffer allocated, in bytes */ - OMX_U32 nFilledLen; /**< number of bytes currently in the - buffer */ - OMX_U32 nOffset; /**< start offset of valid data in bytes from - the start of the buffer */ - OMX_PTR pAppPrivate; /**< pointer to any data the application - wants to associate with this buffer */ - OMX_PTR pPlatformPrivate; /**< pointer to any data the platform - wants to associate with this buffer */ - OMX_PTR pInputPortPrivate; /**< pointer to any data the input port - wants to associate with this buffer */ - OMX_PTR pOutputPortPrivate; /**< pointer to any data the output port - wants to associate with this buffer */ - OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will generate a - mark event upon processing this buffer. */ - OMX_PTR pMarkData; /**< Application specific data associated with - the mark sent on a mark event to disambiguate - this mark from others. */ - OMX_U32 nTickCount; /**< Optional entry that the component and - application can update with a tick count - when they access the component. This - value should be in microseconds. Since - this is a value relative to an arbitrary - starting point, this value cannot be used - to determine absolute time. This is an - optional entry and not all components - will update it.*/ - OMX_TICKS nTimeStamp; /**< Timestamp corresponding to the sample - starting at the first logical sample - boundary in the buffer. Timestamps of - successive samples within the buffer may - be inferred by adding the duration of the - of the preceding buffer to the timestamp - of the preceding buffer.*/ - OMX_U32 nFlags; /**< buffer specific flags */ - OMX_U32 nOutputPortIndex; /**< The index of the output port (if any) using - this buffer */ - OMX_U32 nInputPortIndex; /**< The index of the input port (if any) using - this buffer */ -} OMX_BUFFERHEADERTYPE; - -/** The OMX_EXTRADATATYPE enumeration is used to define the - * possible extra data payload types. - * NB: this enum is binary backwards compatible with the previous - * OMX_EXTRADATA_QUANT define. This should be replaced with - * OMX_ExtraDataQuantization. - */ -typedef enum OMX_EXTRADATATYPE -{ - OMX_ExtraDataNone = 0, /**< Indicates that no more extra data sections follow */ - OMX_ExtraDataQuantization, /**< The data payload contains quantization data */ - OMX_ExtraDataKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_ExtraDataVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_ExtraDataMax = 0x7FFFFFFF -} OMX_EXTRADATATYPE; - - -typedef struct OMX_OTHER_EXTRADATATYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_EXTRADATATYPE eType; /* Extra Data type */ - OMX_U32 nDataSize; /* Size of the supporting data to follow */ - OMX_U8 data[1]; /* Supporting data hint */ -} OMX_OTHER_EXTRADATATYPE; - -/** @ingroup comp */ -typedef struct OMX_PORT_PARAM_TYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPorts; /**< The number of ports for this component */ - OMX_U32 nStartPortNumber; /** first port number for this type of port */ -} OMX_PORT_PARAM_TYPE; - -/** @ingroup comp */ -typedef enum OMX_EVENTTYPE -{ - OMX_EventCmdComplete, /**< component has sucessfully completed a command */ - OMX_EventError, /**< component has detected an error condition */ - OMX_EventMark, /**< component has detected a buffer mark */ - OMX_EventPortSettingsChanged, /**< component is reported a port settings change */ - OMX_EventBufferFlag, /**< component has detected an EOS */ - OMX_EventResourcesAcquired, /**< component has been granted resources and is - automatically starting the state change from - OMX_StateWaitForResources to OMX_StateIdle. */ - OMX_EventComponentResumed, /**< Component resumed due to reacquisition of resources */ - OMX_EventDynamicResourcesAvailable, /**< Component has acquired previously unavailable dynamic resources */ - OMX_EventPortFormatDetected, /**< Component has detected a supported format. */ - OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_EventMax = 0x7FFFFFFF -} OMX_EVENTTYPE; - -typedef struct OMX_CALLBACKTYPE -{ - /** The EventHandler method is used to notify the application when an - event of interest occurs. Events are defined in the OMX_EVENTTYPE - enumeration. Please see that enumeration for details of what will - be returned for each type of event. Callbacks should not return - an error to the component, so if an error occurs, the application - shall handle it internally. This is a blocking call. - - The application should return from this call within 5 msec to avoid - blocking the component for an excessively long period of time. - - @param hComponent - handle of the component to access. This is the component - handle returned by the call to the GetHandle function. - @param pAppData - pointer to an application defined value that was provided in the - pAppData parameter to the OMX_GetHandle method for the component. - This application defined value is provided so that the application - can have a component specific context when receiving the callback. - @param eEvent - Event that the component wants to notify the application about. - @param nData1 - nData will be the OMX_ERRORTYPE for an error event and will be - an OMX_COMMANDTYPE for a command complete event and OMX_INDEXTYPE for a OMX_PortSettingsChanged event. - @param nData2 - nData2 will hold further information related to the event. Can be OMX_STATETYPE for - a OMX_CommandStateSet command or port index for a OMX_PortSettingsChanged event. - Default value is 0 if not used. ) - @param pEventData - Pointer to additional event-specific data (see spec for meaning). - */ - - OMX_ERRORTYPE (*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); - - /** The EmptyBufferDone method is used to return emptied buffers from an - input port back to the application for reuse. This is a blocking call - so the application should not attempt to refill the buffers during this - call, but should queue them and refill them in another thread. There - is no error return, so the application shall handle any errors generated - internally. - - The application should return from this call within 5 msec. - - @param hComponent - handle of the component to access. This is the component - handle returned by the call to the GetHandle function. - @param pAppData - pointer to an application defined value that was provided in the - pAppData parameter to the OMX_GetHandle method for the component. - This application defined value is provided so that the application - can have a component specific context when receiving the callback. - @param pBuffer - pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer - or AllocateBuffer indicating the buffer that was emptied. - @ingroup buf - */ - OMX_ERRORTYPE (*EmptyBufferDone)( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); - - /** The FillBufferDone method is used to return filled buffers from an - output port back to the application for emptying and then reuse. - This is a blocking call so the application should not attempt to - empty the buffers during this call, but should queue the buffers - and empty them in another thread. There is no error return, so - the application shall handle any errors generated internally. The - application shall also update the buffer header to indicate the - number of bytes placed into the buffer. - - The application should return from this call within 5 msec. - - @param hComponent - handle of the component to access. This is the component - handle returned by the call to the GetHandle function. - @param pAppData - pointer to an application defined value that was provided in the - pAppData parameter to the OMX_GetHandle method for the component. - This application defined value is provided so that the application - can have a component specific context when receiving the callback. - @param pBuffer - pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer - or AllocateBuffer indicating the buffer that was filled. - @ingroup buf - */ - OMX_ERRORTYPE (*FillBufferDone)( - OMX_OUT OMX_HANDLETYPE hComponent, - OMX_OUT OMX_PTR pAppData, - OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer); - -} OMX_CALLBACKTYPE; - -/** The OMX_BUFFERSUPPLIERTYPE enumeration is used to dictate port supplier - preference when tunneling between two ports. - @ingroup tun buf -*/ -typedef enum OMX_BUFFERSUPPLIERTYPE -{ - OMX_BufferSupplyUnspecified = 0x0, /**< port supplying the buffers is unspecified, - or don't care */ - OMX_BufferSupplyInput, /**< input port supplies the buffers */ - OMX_BufferSupplyOutput, /**< output port supplies the buffers */ - OMX_BufferSupplyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_BufferSupplyVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_BufferSupplyMax = 0x7FFFFFFF -} OMX_BUFFERSUPPLIERTYPE; - - -/** buffer supplier parameter - * @ingroup tun - */ -typedef struct OMX_PARAM_BUFFERSUPPLIERTYPE { - 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_BUFFERSUPPLIERTYPE eBufferSupplier; /**< buffer supplier */ -} OMX_PARAM_BUFFERSUPPLIERTYPE; - - -/**< indicates that buffers received by an input port of a tunnel - may not modify the data in the buffers - @ingroup tun - */ -#define OMX_PORTTUNNELFLAG_READONLY 0x00000001 - - -/** The OMX_TUNNELSETUPTYPE structure is used to pass data from an output - port to an input port as part the two ComponentTunnelRequest calls - resulting from a OMX_SetupTunnel call from the IL Client. - @ingroup tun - */ -typedef struct OMX_TUNNELSETUPTYPE -{ - OMX_U32 nTunnelFlags; /**< bit flags for tunneling */ - OMX_BUFFERSUPPLIERTYPE eSupplier; /**< supplier preference */ -} OMX_TUNNELSETUPTYPE; - -/* OMX Component headers is included to enable the core to use - macros for functions into the component for OMX release 1.0. - Developers should not access any structures or data from within - the component header directly */ -/* TO BE REMOVED - #include */ - -/** GetComponentVersion will return information about the component. - This is a blocking call. This macro will go directly from the - application to the component (via a core macro). The - component will return from this call within 5 msec. - @param [in] hComponent - handle of component to execute the command - @param [out] pComponentName - pointer to an empty string of length 128 bytes. The component - will write its name into this string. The name will be - terminated by a single zero byte. The name of a component will - be 127 bytes or less to leave room for the trailing zero byte. - An example of a valid component name is "OMX.ABC.ChannelMixer\0". - @param [out] pComponentVersion - pointer to an OMX Version structure that the component will fill - in. The component will fill in a value that indicates the - component version. NOTE: the component version is NOT the same - as the OMX Specification version (found in all structures). The - component version is defined by the vendor of the component and - its value is entirely up to the component vendor. - @param [out] pSpecVersion - pointer to an OMX Version structure that the component will fill - in. The SpecVersion is the version of the specification that the - component was built against. Please note that this value may or - may not match the structure's version. For example, if the - component was built against the 2.0 specification, but the - application (which creates the structure is built against the - 1.0 specification the versions would be different. - @param [out] pComponentUUID - pointer to the UUID of the component which will be filled in by - the component. The UUID is a unique identifier that is set at - RUN time for the component and is unique to each instantion of - the component. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_GetComponentVersion( \ - hComponent, \ - pComponentName, \ - pComponentVersion, \ - pSpecVersion, \ - pComponentUUID) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetComponentVersion( \ - hComponent, \ - pComponentName, \ - pComponentVersion, \ - pSpecVersion, \ - pComponentUUID) /* Macro End */ - - -/** Send a command to the component. This call is a non-blocking call. - The component should check the parameters and then queue the command - to the component thread to be executed. The component thread shall - send the EventHandler() callback at the conclusion of the command. - This macro will go directly from the application to the component (via - a core macro). The component will return from this call within 5 msec. - - When the command is "OMX_CommandStateSet" the component will queue a - state transition to the new state idenfied in nParam. - - When the command is "OMX_CommandFlush", to flush a port's buffer queues, - the command will force the component to return all buffers NOT CURRENTLY - BEING PROCESSED to the application, in the order in which the buffers - were received. - - When the command is "OMX_CommandPortDisable" or - "OMX_CommandPortEnable", the component's port (given by the value of - nParam) will be stopped or restarted. - - When the command "OMX_CommandMarkBuffer" is used to mark a buffer, the - pCmdData will point to a OMX_MARKTYPE structure containing the component - handle of the component to examine the buffer chain for the mark. nParam1 - contains the index of the port on which the buffer mark is applied. - - Specification text for more details. - - @param [in] hComponent - handle of component to execute the command - @param [in] Cmd - Command for the component to execute - @param [in] nParam - Parameter for the command to be executed. When Cmd has the value - OMX_CommandStateSet, value is a member of OMX_STATETYPE. When Cmd has - the value OMX_CommandFlush, value of nParam indicates which port(s) - to flush. -1 is used to flush all ports a single port index will - only flush that port. When Cmd has the value "OMX_CommandPortDisable" - or "OMX_CommandPortEnable", the component's port is given by - the value of nParam. When Cmd has the value "OMX_CommandMarkBuffer" - the components pot is given by the value of nParam. - @param [in] pCmdData - Parameter pointing to the OMX_MARKTYPE structure when Cmd has the value - "OMX_CommandMarkBuffer". - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_SendCommand( \ - hComponent, \ - Cmd, \ - nParam, \ - pCmdData) \ - ((OMX_COMPONENTTYPE*)hComponent)->SendCommand( \ - hComponent, \ - Cmd, \ - nParam, \ - pCmdData) /* Macro End */ - - -/** The OMX_GetParameter macro will get one of the current parameter - settings from the component. This macro cannot only be invoked when - the component is in the OMX_StateInvalid state. The nParamIndex - parameter is used to indicate which structure is being requested from - the component. The application shall allocate the correct structure - and shall fill in the structure size and version information before - invoking this macro. When the parameter applies to a port, the - caller shall fill in the appropriate nPortIndex value indicating the - port on which the parameter applies. If the component has not had - any settings changed, then the component should return a set of - valid DEFAULT parameters for the component. This is a blocking - call. - - The component should return from this call within 20 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] nParamIndex - Index of the structure to be filled. This value is from the - OMX_INDEXTYPE enumeration. - @param [in,out] pComponentParameterStructure - Pointer to application allocated structure to be filled by the - component. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_GetParameter( \ - hComponent, \ - nParamIndex, \ - pComponentParameterStructure) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetParameter( \ - hComponent, \ - nParamIndex, \ - pComponentParameterStructure) /* Macro End */ - - -/** The OMX_SetParameter macro will send an initialization parameter - structure to a component. Each structure shall be sent one at a time, - in a separate invocation of the macro. This macro can only be - invoked when the component is in the OMX_StateLoaded state, or the - port is disabled (when the parameter applies to a port). The - nParamIndex parameter is used to indicate which structure is being - passed to the component. The application shall allocate the - correct structure and shall fill in the structure size and version - information (as well as the actual data) before invoking this macro. - The application is free to dispose of this structure after the call - as the component is required to copy any data it shall retain. This - is a blocking call. - - The component should return from this call within 20 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] nIndex - Index of the structure to be sent. This value is from the - OMX_INDEXTYPE enumeration. - @param [in] pComponentParameterStructure - pointer to application allocated structure to be used for - initialization by the component. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_SetParameter( \ - hComponent, \ - nParamIndex, \ - pComponentParameterStructure) \ - ((OMX_COMPONENTTYPE*)hComponent)->SetParameter( \ - hComponent, \ - nParamIndex, \ - pComponentParameterStructure) /* Macro End */ - - -/** The OMX_GetConfig macro will get one of the configuration structures - from a component. This macro can be invoked anytime after the - component has been loaded. The nParamIndex call parameter is used to - indicate which structure is being requested from the component. The - application shall allocate the correct structure and shall fill in the - structure size and version information before invoking this macro. - If the component has not had this configuration parameter sent before, - then the component should return a set of valid DEFAULT values for the - component. This is a blocking call. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] nIndex - Index of the structure to be filled. This value is from the - OMX_INDEXTYPE enumeration. - @param [in,out] pComponentConfigStructure - pointer to application allocated structure to be filled by the - component. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp -*/ -#define OMX_GetConfig( \ - hComponent, \ - nConfigIndex, \ - pComponentConfigStructure) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetConfig( \ - hComponent, \ - nConfigIndex, \ - pComponentConfigStructure) /* Macro End */ - - -/** The OMX_SetConfig macro will send one of the configuration - structures to a component. Each structure shall be sent one at a time, - each in a separate invocation of the macro. This macro can be invoked - anytime after the component has been loaded. The application shall - allocate the correct structure and shall fill in the structure size - and version information (as well as the actual data) before invoking - this macro. The application is free to dispose of this structure after - the call as the component is required to copy any data it shall retain. - This is a blocking call. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] nConfigIndex - Index of the structure to be sent. This value is from the - OMX_INDEXTYPE enumeration above. - @param [in] pComponentConfigStructure - pointer to application allocated structure to be used for - initialization by the component. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_SetConfig( \ - hComponent, \ - nConfigIndex, \ - pComponentConfigStructure) \ - ((OMX_COMPONENTTYPE*)hComponent)->SetConfig( \ - hComponent, \ - nConfigIndex, \ - pComponentConfigStructure) /* Macro End */ - - -/** The OMX_GetExtensionIndex macro will invoke a component to translate - a vendor specific configuration or parameter string into an OMX - structure index. There is no requirement for the vendor to support - this command for the indexes already found in the OMX_INDEXTYPE - enumeration (this is done to save space in small components). The - component shall support all vendor supplied extension indexes not found - in the master OMX_INDEXTYPE enumeration. This is a blocking call. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the GetHandle function. - @param [in] cParameterName - OMX_STRING that shall be less than 128 characters long including - the trailing null byte. This is the string that will get - translated by the component into a configuration index. - @param [out] pIndexType - a pointer to a OMX_INDEXTYPE to receive the index value. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_GetExtensionIndex( \ - hComponent, \ - cParameterName, \ - pIndexType) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetExtensionIndex( \ - hComponent, \ - cParameterName, \ - pIndexType) /* Macro End */ - - -/** The OMX_GetState macro will invoke the component to get the current - state of the component and place the state value into the location - pointed to by pState. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [out] pState - pointer to the location to receive the state. The value returned - is one of the OMX_STATETYPE members - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp - */ -#define OMX_GetState( \ - hComponent, \ - pState) \ - ((OMX_COMPONENTTYPE*)hComponent)->GetState( \ - hComponent, \ - pState) /* Macro End */ - - -/** The OMX_UseBuffer macro will request that the component use - a buffer (and allocate its own buffer header) already allocated - by another component, or by the IL Client. This is a blocking - call. - - The component should return from this call within 20 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [out] ppBuffer - pointer to an OMX_BUFFERHEADERTYPE structure used to receive the - pointer to the buffer header - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp buf - */ - -#define OMX_UseBuffer( \ - hComponent, \ - ppBufferHdr, \ - nPortIndex, \ - pAppPrivate, \ - nSizeBytes, \ - pBuffer) \ - ((OMX_COMPONENTTYPE*)hComponent)->UseBuffer( \ - hComponent, \ - ppBufferHdr, \ - nPortIndex, \ - pAppPrivate, \ - nSizeBytes, \ - pBuffer) - - -/** The OMX_AllocateBuffer macro will request that the component allocate - a new buffer and buffer header. The component will allocate the - buffer and the buffer header and return a pointer to the buffer - header. This is a blocking call. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [out] ppBuffer - pointer to an OMX_BUFFERHEADERTYPE structure used to receive - the pointer to the buffer header - @param [in] nPortIndex - nPortIndex is used to select the port on the component the buffer will - be used with. The port can be found by using the nPortIndex - value as an index into the Port Definition array of the component. - @param [in] pAppPrivate - pAppPrivate is used to initialize the pAppPrivate member of the - buffer header structure. - @param [in] nSizeBytes - size of the buffer to allocate. Used when bAllocateNew is true. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp buf - */ -#define OMX_AllocateBuffer( \ - hComponent, \ - ppBuffer, \ - nPortIndex, \ - pAppPrivate, \ - nSizeBytes) \ - ((OMX_COMPONENTTYPE*)hComponent)->AllocateBuffer( \ - hComponent, \ - ppBuffer, \ - nPortIndex, \ - pAppPrivate, \ - nSizeBytes) /* Macro End */ - - -/** The OMX_FreeBuffer macro will release a buffer header from the component - which was allocated using either OMX_AllocateBuffer or OMX_UseBuffer. If - the component allocated the buffer (see the OMX_UseBuffer macro) then - the component shall free the buffer and buffer header. This is a - blocking call. - - The component should return from this call within 20 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] nPortIndex - nPortIndex is used to select the port on the component the buffer will - be used with. - @param [in] pBuffer - pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer - or AllocateBuffer. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp buf - */ -#define OMX_FreeBuffer( \ - hComponent, \ - nPortIndex, \ - pBuffer) \ - ((OMX_COMPONENTTYPE*)hComponent)->FreeBuffer( \ - hComponent, \ - nPortIndex, \ - pBuffer) /* Macro End */ - - -/** The OMX_EmptyThisBuffer macro will send a buffer full of data to an - input port of a component. The buffer will be emptied by the component - and returned to the application via the EmptyBufferDone call back. - This is a non-blocking call in that the component will record the buffer - and return immediately and then empty the buffer, later, at the proper - time. As expected, this macro may be invoked only while the component - is in the OMX_StateExecuting. If nPortIndex does not specify an input - port, the component shall return an error. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] pBuffer - pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer - or AllocateBuffer. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp buf - */ -#define OMX_EmptyThisBuffer( \ - hComponent, \ - pBuffer) \ - ((OMX_COMPONENTTYPE*)hComponent)->EmptyThisBuffer( \ - hComponent, \ - pBuffer) /* Macro End */ - - -/** The OMX_FillThisBuffer macro will send an empty buffer to an - output port of a component. The buffer will be filled by the component - and returned to the application via the FillBufferDone call back. - This is a non-blocking call in that the component will record the buffer - and return immediately and then fill the buffer, later, at the proper - time. As expected, this macro may be invoked only while the component - is in the OMX_ExecutingState. If nPortIndex does not specify an output - port, the component shall return an error. - - The component should return from this call within 5 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [in] pBuffer - pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer - or AllocateBuffer. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp buf - */ -#define OMX_FillThisBuffer( \ - hComponent, \ - pBuffer) \ - ((OMX_COMPONENTTYPE*)hComponent)->FillThisBuffer( \ - hComponent, \ - pBuffer) /* Macro End */ - - - -/** The OMX_UseEGLImage macro will request that the component use - a EGLImage provided by EGL (and allocate its own buffer header) - This is a blocking call. - - The component should return from this call within 20 msec. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the OMX_GetHandle function. - @param [out] ppBuffer - pointer to an OMX_BUFFERHEADERTYPE structure used to receive the - pointer to the buffer header. Note that the memory location used - for this buffer is NOT visible to the IL Client. - @param [in] nPortIndex - nPortIndex is used to select the port on the component the buffer will - be used with. The port can be found by using the nPortIndex - value as an index into the Port Definition array of the component. - @param [in] pAppPrivate - pAppPrivate is used to initialize the pAppPrivate member of the - buffer header structure. - @param [in] eglImage - eglImage contains the handle of the EGLImage to use as a buffer on the - specified port. The component is expected to validate properties of - the EGLImage against the configuration of the port to ensure the component - can use the EGLImage as a buffer. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup comp buf - */ -#define OMX_UseEGLImage( \ - hComponent, \ - ppBufferHdr, \ - nPortIndex, \ - pAppPrivate, \ - eglImage) \ - ((OMX_COMPONENTTYPE*)hComponent)->UseEGLImage( \ - hComponent, \ - ppBufferHdr, \ - nPortIndex, \ - pAppPrivate, \ - eglImage) - -/** The OMX_Init method is used to initialize the OMX core. It shall be the - first call made into OMX and it should only be executed one time without - an interviening OMX_Deinit call. - - The core should return from this call within 20 msec. - - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Init(void); - - -/** The OMX_Deinit method is used to deinitialize the OMX core. It shall be - the last call made into OMX. In the event that the core determines that - thare are components loaded when this call is made, the core may return - with an error rather than try to unload the components. - - The core should return from this call within 20 msec. - - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Deinit(void); - - -/** The OMX_ComponentNameEnum method will enumerate through all the names of - recognised valid components in the system. This function is provided - as a means to detect all the components in the system run-time. There is - no strict ordering to the enumeration order of component names, although - each name will only be enumerated once. If the OMX core supports run-time - installation of new components, it is only requried to detect newly - installed components when the first call to enumerate component names - is made (i.e. when nIndex is 0x0). - - The core should return from this call in 20 msec. - - @param [out] cComponentName - pointer to a null terminated string with the component name. The - names of the components are strings less than 127 bytes in length - plus the trailing null for a maximum size of 128 bytes. An example - of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0". Names are - assigned by the vendor, but shall start with "OMX." and then have - the Vendor designation next. - @param [in] nNameLength - number of characters in the cComponentName string. With all - component name strings restricted to less than 128 characters - (including the trailing null) it is recomended that the caller - provide a input string for the cComponentName of 128 characters. - @param [in] nIndex - number containing the enumeration index for the component. - Multiple calls to OMX_ComponentNameEnum with increasing values - of nIndex will enumerate through the component names in the - system until OMX_ErrorNoMore is returned. The value of nIndex - is 0 to (N-1), where N is the number of valid installed components - in the system. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. When the value of nIndex exceeds the number of - components in the system minus 1, OMX_ErrorNoMore will be - returned. Otherwise the appropriate OMX error will be returned. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum( - OMX_OUT OMX_STRING cComponentName, - OMX_IN OMX_U32 nNameLength, - OMX_IN OMX_U32 nIndex); - - -/** The OMX_GetHandle method will locate the component specified by the - component name given, load that component into memory and then invoke - the component's methods to create an instance of the component. - - The core should return from this call within 20 msec. - - @param [out] pHandle - pointer to an OMX_HANDLETYPE pointer to be filled in by this method. - @param [in] cComponentName - pointer to a null terminated string with the component name. The - names of the components are strings less than 127 bytes in length - plus the trailing null for a maximum size of 128 bytes. An example - of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0". Names are - assigned by the vendor, but shall start with "OMX." and then have - the Vendor designation next. - @param [in] pAppData - pointer to an application defined value that will be returned - during callbacks so that the application can identify the source - of the callback. - @param [in] pCallBacks - pointer to a OMX_CALLBACKTYPE structure that will be passed to the - component to initialize it with. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle( - OMX_OUT OMX_HANDLETYPE* pHandle, - OMX_IN OMX_STRING cComponentName, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_CALLBACKTYPE* pCallBacks); - - -/** The OMX_FreeHandle method will free a handle allocated by the OMX_GetHandle - method. If the component reference count goes to zero, the component will - be unloaded from memory. - - The core should return from this call within 20 msec when the component is - in the OMX_StateLoaded state. - - @param [in] hComponent - Handle of the component to be accessed. This is the component - handle returned by the call to the GetHandle function. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle( - OMX_IN OMX_HANDLETYPE hComponent); - - - -/** The OMX_SetupTunnel method will handle the necessary calls to the components - to setup the specified tunnel the two components. NOTE: This is - an actual method (not a #define macro). This method will make calls into - the component ComponentTunnelRequest method to do the actual tunnel - connection. - - The ComponentTunnelRequest method on both components will be called. - This method shall not be called unless the component is in the - OMX_StateLoaded state except when the ports used for the tunnel are - disabled. In this case, the component may be in the OMX_StateExecuting, - OMX_StatePause, or OMX_StateIdle states. - - The core should return from this call within 20 msec. - - @param [in] hOutput - Handle of the component to be accessed. Also this is the handle - of the component whose port, specified in the nPortOutput parameter - will be used the source for the tunnel. This is the component handle - returned by the call to the OMX_GetHandle function. There is a - requirement that hOutput be the source for the data when - tunelling (i.e. nPortOutput is an output port). If 0x0, the component - specified in hInput will have it's port specified in nPortInput - setup for communication with the application / IL client. - @param [in] nPortOutput - nPortOutput is used to select the source port on component to be - used in the tunnel. - @param [in] hInput - This is the component to setup the tunnel with. This is the handle - of the component whose port, specified in the nPortInput parameter - will be used the destination for the tunnel. This is the component handle - returned by the call to the OMX_GetHandle function. There is a - requirement that hInput be the destination for the data when - tunelling (i.e. nPortInut is an input port). If 0x0, the component - specified in hOutput will have it's port specified in nPortPOutput - setup for communication with the application / IL client. - @param [in] nPortInput - nPortInput is used to select the destination port on component to be - used in the tunnel. - @return OMX_ERRORTYPE - If the command successfully executes, the return code will be - OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. - When OMX_ErrorNotImplemented is returned, one or both components is - a non-interop component and does not support tunneling. - - On failure, the ports of both components are setup for communication - with the application / IL Client. - @ingroup core tun - */ -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); - -/** @ingroup cp */ -OMX_API OMX_ERRORTYPE OMX_GetContentPipe( - OMX_OUT OMX_HANDLETYPE *hPipe, - OMX_IN OMX_STRING szURI); - -/** The OMX_GetComponentsOfRole method will return the number of components that support the given - role and (if the compNames field is non-NULL) the names of those components. The call will fail if - an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the - client should: - * first call this function with the compNames field NULL to determine the number of component names - * second call this function with the compNames field pointing to an array of names allocated - according to the number returned by the first call. - - The core should return from this call within 5 msec. - - @param [in] role - This is generic standard component name consisting only of component class - name and the type within that class (e.g. 'audio_decoder.aac'). - @param [inout] pNumComps - This is used both as input and output. - - If compNames is NULL, the input is ignored and the output specifies how many components support - the given role. - - If compNames is not NULL, on input it bounds the size of the input structure and - on output, it specifies the number of components string names listed within the compNames parameter. - @param [inout] compNames - If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings which accepts - a list of the names of all physical components that implement the specified standard component name. - Each name is NULL terminated. numComps indicates the number of names. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole ( - OMX_IN OMX_STRING role, - OMX_INOUT OMX_U32 *pNumComps, - OMX_INOUT OMX_U8 **compNames); - -/** The OMX_GetRolesOfComponent method will return the number of roles supported by the given - component and (if the roles field is non-NULL) the names of those roles. The call will fail if - an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the - client should: - * first call this function with the roles field NULL to determine the number of role names - * second call this function with the roles field pointing to an array of names allocated - according to the number returned by the first call. - - The core should return from this call within 5 msec. - - @param [in] compName - This is the name of the component being queried about. - @param [inout] pNumRoles - This is used both as input and output. - - If roles is NULL, the input is ignored and the output specifies how many roles the component supports. - - If compNames is not NULL, on input it bounds the size of the input structure and - on output, it specifies the number of roles string names listed within the roles parameter. - @param [out] roles - If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings - which accepts a list of the names of all standard components roles implemented on the - specified component name. numComps indicates the number of names. - @ingroup core - */ -OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent ( - OMX_IN OMX_STRING compName, - OMX_INOUT OMX_U32 *pNumRoles, - OMX_OUT OMX_U8 **roles); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ - diff --git a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_IVCommon.h b/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_IVCommon.h deleted file mode 100644 index 4c4995c..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_IVCommon.h +++ /dev/null @@ -1,920 +0,0 @@ -/** - * Copyright (c) 2008 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. - * - */ - -/** - * @file OMX_IVCommon.h - OpenMax IL version 1.1.2 - * The structures needed by Video and Image components to exchange - * parameters and configuration data with the components. - */ -#ifndef OMX_IVCommon_h -#define OMX_IVCommon_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 - -/** @defgroup iv OpenMAX IL Imaging and Video Domain - * Common structures for OpenMAX IL Imaging and Video domains - * @{ - */ - - -/** - * Enumeration defining possible uncompressed image/video formats. - * - * ENUMS: - * Unused : Placeholder value when format is N/A - * Monochrome : black and white - * 8bitRGB332 : Red 7:5, Green 4:2, Blue 1:0 - * 12bitRGB444 : Red 11:8, Green 7:4, Blue 3:0 - * 16bitARGB4444 : Alpha 15:12, Red 11:8, Green 7:4, Blue 3:0 - * 16bitARGB1555 : Alpha 15, Red 14:10, Green 9:5, Blue 4:0 - * 16bitRGB565 : Red 15:11, Green 10:5, Blue 4:0 - * 16bitBGR565 : Blue 15:11, Green 10:5, Red 4:0 - * 18bitRGB666 : Red 17:12, Green 11:6, Blue 5:0 - * 18bitARGB1665 : Alpha 17, Red 16:11, Green 10:5, Blue 4:0 - * 19bitARGB1666 : Alpha 18, Red 17:12, Green 11:6, Blue 5:0 - * 24bitRGB888 : Red 24:16, Green 15:8, Blue 7:0 - * 24bitBGR888 : Blue 24:16, Green 15:8, Red 7:0 - * 24bitARGB1887 : Alpha 23, Red 22:15, Green 14:7, Blue 6:0 - * 25bitARGB1888 : Alpha 24, Red 23:16, Green 15:8, Blue 7:0 - * 32bitBGRA8888 : Blue 31:24, Green 23:16, Red 15:8, Alpha 7:0 - * 32bitARGB8888 : Alpha 31:24, Red 23:16, Green 15:8, Blue 7:0 - * YUV411Planar : U,Y are subsampled by a factor of 4 horizontally - * YUV411PackedPlanar : packed per payload in planar slices - * YUV420Planar : Three arrays Y,U,V. - * YUV420PackedPlanar : packed per payload in planar slices - * YUV420SemiPlanar : Two arrays, one is all Y, the other is U and V - * YUV422Planar : Three arrays Y,U,V. - * YUV422PackedPlanar : packed per payload in planar slices - * YUV422SemiPlanar : Two arrays, one is all Y, the other is U and V - * YCbYCr : Organized as 16bit YUYV (i.e. YCbYCr) - * YCrYCb : Organized as 16bit YVYU (i.e. YCrYCb) - * CbYCrY : Organized as 16bit UYVY (i.e. CbYCrY) - * CrYCbY : Organized as 16bit VYUY (i.e. CrYCbY) - * YUV444Interleaved : Each pixel contains equal parts YUV - * RawBayer8bit : SMIA camera output format - * RawBayer10bit : SMIA camera output format - * RawBayer8bitcompressed : SMIA camera output format - */ -typedef enum OMX_COLOR_FORMATTYPE { - OMX_COLOR_FormatUnused, - OMX_COLOR_FormatMonochrome, - OMX_COLOR_Format8bitRGB332, - OMX_COLOR_Format12bitRGB444, - OMX_COLOR_Format16bitARGB4444, - OMX_COLOR_Format16bitARGB1555, - OMX_COLOR_Format16bitRGB565, - OMX_COLOR_Format16bitBGR565, - OMX_COLOR_Format18bitRGB666, - OMX_COLOR_Format18bitARGB1665, - OMX_COLOR_Format19bitARGB1666, - OMX_COLOR_Format24bitRGB888, - OMX_COLOR_Format24bitBGR888, - OMX_COLOR_Format24bitARGB1887, - OMX_COLOR_Format25bitARGB1888, - OMX_COLOR_Format32bitBGRA8888, - OMX_COLOR_Format32bitARGB8888, - OMX_COLOR_FormatYUV411Planar, - OMX_COLOR_FormatYUV411PackedPlanar, - OMX_COLOR_FormatYUV420Planar, - OMX_COLOR_FormatYUV420PackedPlanar, - OMX_COLOR_FormatYUV420SemiPlanar, - OMX_COLOR_FormatYUV422Planar, - OMX_COLOR_FormatYUV422PackedPlanar, - OMX_COLOR_FormatYUV422SemiPlanar, - OMX_COLOR_FormatYCbYCr, - OMX_COLOR_FormatYCrYCb, - OMX_COLOR_FormatCbYCrY, - OMX_COLOR_FormatCrYCbY, - OMX_COLOR_FormatYUV444Interleaved, - OMX_COLOR_FormatRawBayer8bit, - OMX_COLOR_FormatRawBayer10bit, - OMX_COLOR_FormatRawBayer8bitcompressed, - OMX_COLOR_FormatL2, - OMX_COLOR_FormatL4, - OMX_COLOR_FormatL8, - OMX_COLOR_FormatL16, - OMX_COLOR_FormatL24, - OMX_COLOR_FormatL32, - OMX_COLOR_FormatYUV420PackedSemiPlanar, - OMX_COLOR_FormatYUV422PackedSemiPlanar, - OMX_COLOR_Format18BitBGR666, - OMX_COLOR_Format24BitARGB6666, - OMX_COLOR_Format24BitABGR6666, - OMX_COLOR_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_COLOR_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_COLOR_FormatMax = 0x7FFFFFFF -} OMX_COLOR_FORMATTYPE; - - -/** - * Defines the matrix for conversion from RGB to YUV or vice versa. - * iColorMatrix should be initialized with the fixed point values - * used in converting between formats. - */ -typedef struct OMX_CONFIG_COLORCONVERSIONTYPE { - 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_S32 xColorMatrix[3][3]; /**< Stored in signed Q16 format */ - OMX_S32 xColorOffset[4]; /**< Stored in signed Q16 format */ -}OMX_CONFIG_COLORCONVERSIONTYPE; - - -/** - * Structure defining percent to scale each frame dimension. For example: - * To make the width 50% larger, use fWidth = 1.5 and to make the width - * 1/2 the original size, use fWidth = 0.5 - */ -typedef struct OMX_CONFIG_SCALEFACTORTYPE { - 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_S32 xWidth; /**< Fixed point value stored as Q16 */ - OMX_S32 xHeight; /**< Fixed point value stored as Q16 */ -}OMX_CONFIG_SCALEFACTORTYPE; - - -/** - * Enumeration of possible image filter types - */ -typedef enum OMX_IMAGEFILTERTYPE { - OMX_ImageFilterNone, - OMX_ImageFilterNoise, - OMX_ImageFilterEmboss, - OMX_ImageFilterNegative, - OMX_ImageFilterSketch, - OMX_ImageFilterOilPaint, - OMX_ImageFilterHatch, - OMX_ImageFilterGpen, - OMX_ImageFilterAntialias, - OMX_ImageFilterDeRing, - OMX_ImageFilterSolarize, - OMX_ImageFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_ImageFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_ImageFilterMax = 0x7FFFFFFF -} OMX_IMAGEFILTERTYPE; - - -/** - * Image filter configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eImageFilter : Image filter type enumeration - */ -typedef struct OMX_CONFIG_IMAGEFILTERTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_IMAGEFILTERTYPE eImageFilter; -} OMX_CONFIG_IMAGEFILTERTYPE; - - -/** - * Customized U and V for color enhancement - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bColorEnhancement : Enable/disable color enhancement - * nCustomizedU : Practical values: 16-240, range: 0-255, value set for - * U component - * nCustomizedV : Practical values: 16-240, range: 0-255, value set for - * V component - */ -typedef struct OMX_CONFIG_COLORENHANCEMENTTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bColorEnhancement; - OMX_U8 nCustomizedU; - OMX_U8 nCustomizedV; -} OMX_CONFIG_COLORENHANCEMENTTYPE; - - -/** - * Define color key and color key mask - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nARGBColor : 32bit Alpha, Red, Green, Blue Color - * nARGBMask : 32bit Mask for Alpha, Red, Green, Blue channels - */ -typedef struct OMX_CONFIG_COLORKEYTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nARGBColor; - OMX_U32 nARGBMask; -} OMX_CONFIG_COLORKEYTYPE; - - -/** - * List of color blend types for pre/post processing - * - * ENUMS: - * None : No color blending present - * AlphaConstant : Function is (alpha_constant * src) + - * (1 - alpha_constant) * dst) - * AlphaPerPixel : Function is (alpha * src) + (1 - alpha) * dst) - * Alternate : Function is alternating pixels from src and dst - * And : Function is (src & dst) - * Or : Function is (src | dst) - * Invert : Function is ~src - */ -typedef enum OMX_COLORBLENDTYPE { - OMX_ColorBlendNone, - OMX_ColorBlendAlphaConstant, - OMX_ColorBlendAlphaPerPixel, - OMX_ColorBlendAlternate, - OMX_ColorBlendAnd, - OMX_ColorBlendOr, - OMX_ColorBlendInvert, - OMX_ColorBlendKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_ColorBlendVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_ColorBlendMax = 0x7FFFFFFF -} OMX_COLORBLENDTYPE; - - -/** - * Color blend configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nRGBAlphaConstant : Constant global alpha values when global alpha is used - * eColorBlend : Color blend type enumeration - */ -typedef struct OMX_CONFIG_COLORBLENDTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nRGBAlphaConstant; - OMX_COLORBLENDTYPE eColorBlend; -} OMX_CONFIG_COLORBLENDTYPE; - - -/** - * Hold frame dimension - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nWidth : Frame width in pixels - * nHeight : Frame height in pixels - */ -typedef struct OMX_FRAMESIZETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nWidth; - OMX_U32 nHeight; -} OMX_FRAMESIZETYPE; - - -/** - * Rotation configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nRotation : +/- integer rotation value - */ -typedef struct OMX_CONFIG_ROTATIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_S32 nRotation; -} OMX_CONFIG_ROTATIONTYPE; - - -/** - * Possible mirroring directions for pre/post processing - * - * ENUMS: - * None : No mirroring - * Vertical : Vertical mirroring, flip on X axis - * Horizontal : Horizontal mirroring, flip on Y axis - * Both : Both vertical and horizontal mirroring - */ -typedef enum OMX_MIRRORTYPE { - OMX_MirrorNone = 0, - OMX_MirrorVertical, - OMX_MirrorHorizontal, - OMX_MirrorBoth, - OMX_MirrorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_MirrorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_MirrorMax = 0x7FFFFFFF -} OMX_MIRRORTYPE; - - -/** - * Mirroring configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eMirror : Mirror type enumeration - */ -typedef struct OMX_CONFIG_MIRRORTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_MIRRORTYPE eMirror; -} OMX_CONFIG_MIRRORTYPE; - - -/** - * Position information only - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nX : X coordinate for the point - * nY : Y coordinate for the point - */ -typedef struct OMX_CONFIG_POINTTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_S32 nX; - OMX_S32 nY; -} OMX_CONFIG_POINTTYPE; - - -/** - * Frame size plus position - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nLeft : X Coordinate of the top left corner of the rectangle - * nTop : Y Coordinate of the top left corner of the rectangle - * nWidth : Width of the rectangle - * nHeight : Height of the rectangle - */ -typedef struct OMX_CONFIG_RECTTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_S32 nLeft; - OMX_S32 nTop; - OMX_U32 nWidth; - OMX_U32 nHeight; -} OMX_CONFIG_RECTTYPE; - - -/** - * Deblocking state; it is required to be set up before starting the codec - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bDeblocking : Enable/disable deblocking mode - */ -typedef struct OMX_PARAM_DEBLOCKINGTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bDeblocking; -} OMX_PARAM_DEBLOCKINGTYPE; - - -/** - * Stabilization state - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bStab : Enable/disable frame stabilization state - */ -typedef struct OMX_CONFIG_FRAMESTABTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bStab; -} OMX_CONFIG_FRAMESTABTYPE; - - -/** - * White Balance control type - * - * STRUCT MEMBERS: - * SunLight : Referenced in JSR-234 - * Flash : Optimal for device's integrated flash - */ -typedef enum OMX_WHITEBALCONTROLTYPE { - OMX_WhiteBalControlOff = 0, - OMX_WhiteBalControlAuto, - OMX_WhiteBalControlSunLight, - OMX_WhiteBalControlCloudy, - OMX_WhiteBalControlShade, - OMX_WhiteBalControlTungsten, - OMX_WhiteBalControlFluorescent, - OMX_WhiteBalControlIncandescent, - OMX_WhiteBalControlFlash, - OMX_WhiteBalControlHorizon, - OMX_WhiteBalControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_WhiteBalControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_WhiteBalControlMax = 0x7FFFFFFF -} OMX_WHITEBALCONTROLTYPE; - - -/** - * White Balance control configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eWhiteBalControl : White balance enumeration - */ -typedef struct OMX_CONFIG_WHITEBALCONTROLTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_WHITEBALCONTROLTYPE eWhiteBalControl; -} OMX_CONFIG_WHITEBALCONTROLTYPE; - - -/** - * Exposure control type - */ -typedef enum OMX_EXPOSURECONTROLTYPE { - OMX_ExposureControlOff = 0, - OMX_ExposureControlAuto, - OMX_ExposureControlNight, - OMX_ExposureControlBackLight, - OMX_ExposureControlSpotLight, - OMX_ExposureControlSports, - OMX_ExposureControlSnow, - OMX_ExposureControlBeach, - OMX_ExposureControlLargeAperture, - OMX_ExposureControlSmallApperture, - OMX_ExposureControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_ExposureControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_ExposureControlMax = 0x7FFFFFFF -} OMX_EXPOSURECONTROLTYPE; - - -/** - * White Balance control configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eExposureControl : Exposure control enumeration - */ -typedef struct OMX_CONFIG_EXPOSURECONTROLTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_EXPOSURECONTROLTYPE eExposureControl; -} OMX_CONFIG_EXPOSURECONTROLTYPE; - - -/** - * Defines sensor supported mode. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nFrameRate : Single shot mode is indicated by a 0 - * bOneShot : Enable for single shot, disable for streaming - * sFrameSize : Framesize - */ -typedef struct OMX_PARAM_SENSORMODETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nFrameRate; - OMX_BOOL bOneShot; - OMX_FRAMESIZETYPE sFrameSize; -} OMX_PARAM_SENSORMODETYPE; - - -/** - * Defines contrast level - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nContrast : Values allowed for contrast -100 to 100, zero means no change - */ -typedef struct OMX_CONFIG_CONTRASTTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_S32 nContrast; -} OMX_CONFIG_CONTRASTTYPE; - - -/** - * Defines brightness level - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nBrightness : 0-100% - */ -typedef struct OMX_CONFIG_BRIGHTNESSTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nBrightness; -} OMX_CONFIG_BRIGHTNESSTYPE; - - -/** - * Defines backlight level configuration for a video sink, e.g. LCD panel - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nBacklight : Values allowed for backlight 0-100% - * nTimeout : Number of milliseconds before backlight automatically turns - * off. A value of 0x0 disables backight timeout - */ -typedef struct OMX_CONFIG_BACKLIGHTTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nBacklight; - OMX_U32 nTimeout; -} OMX_CONFIG_BACKLIGHTTYPE; - - -/** - * Defines setting for Gamma - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nGamma : Values allowed for gamma -100 to 100, zero means no change - */ -typedef struct OMX_CONFIG_GAMMATYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_S32 nGamma; -} OMX_CONFIG_GAMMATYPE; - - -/** - * Define for setting saturation - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nSaturation : Values allowed for saturation -100 to 100, zero means - * no change - */ -typedef struct OMX_CONFIG_SATURATIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_S32 nSaturation; -} OMX_CONFIG_SATURATIONTYPE; - - -/** - * Define for setting Lightness - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nLightness : Values allowed for lightness -100 to 100, zero means no - * change - */ -typedef struct OMX_CONFIG_LIGHTNESSTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_S32 nLightness; -} OMX_CONFIG_LIGHTNESSTYPE; - - -/** - * Plane blend configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Index of input port associated with the plane. - * nDepth : Depth of the plane in relation to the screen. Higher - * numbered depths are "behind" lower number depths. - * This number defaults to the Port Index number. - * nAlpha : Transparency blending component for the entire plane. - * See blending modes for more detail. - */ -typedef struct OMX_CONFIG_PLANEBLENDTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nDepth; - OMX_U32 nAlpha; -} OMX_CONFIG_PLANEBLENDTYPE; - - -/** - * Define interlace type - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bEnable : Enable control variable for this functionality - * (see below) - * nInterleavePortIndex : Index of input or output port associated with - * the interleaved plane. - * pPlanarPortIndexes[4] : Index of input or output planar ports. - */ -typedef struct OMX_PARAM_INTERLEAVETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnable; - OMX_U32 nInterleavePortIndex; -} OMX_PARAM_INTERLEAVETYPE; - - -/** - * Defines the picture effect used for an input picture - */ -typedef enum OMX_TRANSITIONEFFECTTYPE { - OMX_EffectNone, - OMX_EffectFadeFromBlack, - OMX_EffectFadeToBlack, - OMX_EffectUnspecifiedThroughConstantColor, - OMX_EffectDissolve, - OMX_EffectWipe, - OMX_EffectUnspecifiedMixOfTwoScenes, - OMX_EffectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_EffectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_EffectMax = 0x7FFFFFFF -} OMX_TRANSITIONEFFECTTYPE; - - -/** - * Structure used to configure current transition effect - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eEffect : Effect to enable - */ -typedef struct OMX_CONFIG_TRANSITIONEFFECTTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_TRANSITIONEFFECTTYPE eEffect; -} OMX_CONFIG_TRANSITIONEFFECTTYPE; - - -/** - * Defines possible data unit types for encoded video data. The data unit - * types are used both for encoded video input for playback as well as - * encoded video output from recording. - */ -typedef enum OMX_DATAUNITTYPE { - OMX_DataUnitCodedPicture, - OMX_DataUnitVideoSegment, - OMX_DataUnitSeveralSegments, - OMX_DataUnitArbitraryStreamSection, - OMX_DataUnitKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_DataUnitVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_DataUnitMax = 0x7FFFFFFF -} OMX_DATAUNITTYPE; - - -/** - * Defines possible encapsulation types for coded video data unit. The - * encapsulation information is used both for encoded video input for - * playback as well as encoded video output from recording. - */ -typedef enum OMX_DATAUNITENCAPSULATIONTYPE { - OMX_DataEncapsulationElementaryStream, - OMX_DataEncapsulationGenericPayload, - OMX_DataEncapsulationRtpPayload, - OMX_DataEncapsulationKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_DataEncapsulationVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_DataEncapsulationMax = 0x7FFFFFFF -} OMX_DATAUNITENCAPSULATIONTYPE; - - -/** - * Structure used to configure the type of being decoded/encoded - */ -typedef struct OMX_PARAM_DATAUNITTYPE { - 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_DATAUNITTYPE eUnitType; - OMX_DATAUNITENCAPSULATIONTYPE eEncapsulationType; -} OMX_PARAM_DATAUNITTYPE; - - -/** - * Defines dither types - */ -typedef enum OMX_DITHERTYPE { - OMX_DitherNone, - OMX_DitherOrdered, - OMX_DitherErrorDiffusion, - OMX_DitherOther, - OMX_DitherKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_DitherVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_DitherMax = 0x7FFFFFFF -} OMX_DITHERTYPE; - - -/** - * Structure used to configure current type of dithering - */ -typedef struct OMX_CONFIG_DITHERTYPE { - 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_DITHERTYPE eDither; /**< Type of dithering to use */ -} OMX_CONFIG_DITHERTYPE; - -typedef struct OMX_CONFIG_CAPTUREMODETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; /**< Port that this structure applies to */ - OMX_BOOL bContinuous; /**< If true then ignore frame rate and emit capture - * data as fast as possible (otherwise obey port's frame rate). */ - OMX_BOOL bFrameLimited; /**< If true then terminate capture after the port emits the - * specified number of frames (otherwise the port does not - * terminate the capture until instructed to do so by the client). - * Even if set, the client may manually terminate the capture prior - * to reaching the limit. */ - OMX_U32 nFrameLimit; /**< Limit on number of frames emitted during a capture (only - * valid if bFrameLimited is set). */ -} OMX_CONFIG_CAPTUREMODETYPE; - -typedef enum OMX_METERINGTYPE { - - OMX_MeteringModeAverage, /**< Center-weighted average metering. */ - OMX_MeteringModeSpot, /**< Spot (partial) metering. */ - OMX_MeteringModeMatrix, /**< Matrix or evaluative metering. */ - - OMX_MeteringKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_MeteringVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_EVModeMax = 0x7fffffff -} OMX_METERINGTYPE; - -typedef struct OMX_CONFIG_EXPOSUREVALUETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_METERINGTYPE eMetering; - OMX_S32 xEVCompensation; /**< Fixed point value stored as Q16 */ - OMX_U32 nApertureFNumber; /**< e.g. nApertureFNumber = 2 implies "f/2" - Q16 format */ - OMX_BOOL bAutoAperture; /**< Whether aperture number is defined automatically */ - OMX_U32 nShutterSpeedMsec; /**< Shutterspeed in milliseconds */ - OMX_BOOL bAutoShutterSpeed; /**< Whether shutter speed is defined automatically */ - OMX_U32 nSensitivity; /**< e.g. nSensitivity = 100 implies "ISO 100" */ - OMX_BOOL bAutoSensitivity; /**< Whether sensitivity is defined automatically */ -} OMX_CONFIG_EXPOSUREVALUETYPE; - -/** - * Focus region configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bCenter : Use center region as focus region of interest - * bLeft : Use left region as focus region of interest - * bRight : Use right region as focus region of interest - * bTop : Use top region as focus region of interest - * bBottom : Use bottom region as focus region of interest - * bTopLeft : Use top left region as focus region of interest - * bTopRight : Use top right region as focus region of interest - * bBottomLeft : Use bottom left region as focus region of interest - * bBottomRight : Use bottom right region as focus region of interest - */ -typedef struct OMX_CONFIG_FOCUSREGIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bCenter; - OMX_BOOL bLeft; - OMX_BOOL bRight; - OMX_BOOL bTop; - OMX_BOOL bBottom; - OMX_BOOL bTopLeft; - OMX_BOOL bTopRight; - OMX_BOOL bBottomLeft; - OMX_BOOL bBottomRight; -} OMX_CONFIG_FOCUSREGIONTYPE; - -/** - * Focus Status type - */ -typedef enum OMX_FOCUSSTATUSTYPE { - OMX_FocusStatusOff = 0, - OMX_FocusStatusRequest, - OMX_FocusStatusReached, - OMX_FocusStatusUnableToReach, - OMX_FocusStatusLost, - OMX_FocusStatusKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_FocusStatusVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_FocusStatusMax = 0x7FFFFFFF -} OMX_FOCUSSTATUSTYPE; - -/** - * Focus status configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eFocusStatus : Specifies the focus status - * bCenterStatus : Use center region as focus region of interest - * bLeftStatus : Use left region as focus region of interest - * bRightStatus : Use right region as focus region of interest - * bTopStatus : Use top region as focus region of interest - * bBottomStatus : Use bottom region as focus region of interest - * bTopLeftStatus : Use top left region as focus region of interest - * bTopRightStatus : Use top right region as focus region of interest - * bBottomLeftStatus : Use bottom left region as focus region of interest - * bBottomRightStatus : Use bottom right region as focus region of interest - */ -typedef struct OMX_PARAM_FOCUSSTATUSTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_FOCUSSTATUSTYPE eFocusStatus; - OMX_BOOL bCenterStatus; - OMX_BOOL bLeftStatus; - OMX_BOOL bRightStatus; - OMX_BOOL bTopStatus; - OMX_BOOL bBottomStatus; - OMX_BOOL bTopLeftStatus; - OMX_BOOL bTopRightStatus; - OMX_BOOL bBottomLeftStatus; - OMX_BOOL bBottomRightStatus; -} OMX_PARAM_FOCUSSTATUSTYPE; - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ diff --git a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Image.h b/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Image.h deleted file mode 100644 index a6d4666..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Image.h +++ /dev/null @@ -1,328 +0,0 @@ -/** - * Copyright (c) 2008 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. - */ - -/** - * @file OMX_Image.h - OpenMax IL version 1.1.2 - * The structures needed by Image components to exchange parameters and - * configuration data with the components. - */ -#ifndef OMX_Image_h -#define OMX_Image_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 - -/** @defgroup imaging OpenMAX IL Imaging Domain - * @ingroup iv - * Structures for OpenMAX IL Imaging domain - * @{ - */ - -/** - * Enumeration used to define the possible image compression coding. - */ -typedef enum OMX_IMAGE_CODINGTYPE { - OMX_IMAGE_CodingUnused, /**< Value when format is N/A */ - OMX_IMAGE_CodingAutoDetect, /**< Auto detection of image format */ - OMX_IMAGE_CodingJPEG, /**< JPEG/JFIF image format */ - OMX_IMAGE_CodingJPEG2K, /**< JPEG 2000 image format */ - OMX_IMAGE_CodingEXIF, /**< EXIF image format */ - OMX_IMAGE_CodingTIFF, /**< TIFF image format */ - OMX_IMAGE_CodingGIF, /**< Graphics image format */ - OMX_IMAGE_CodingPNG, /**< PNG image format */ - OMX_IMAGE_CodingLZW, /**< LZW image format */ - OMX_IMAGE_CodingBMP, /**< Windows Bitmap format */ - OMX_IMAGE_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_IMAGE_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_IMAGE_CodingMax = 0x7FFFFFFF -} OMX_IMAGE_CODINGTYPE; - - -/** - * Data structure used to define an image path. The number of image paths - * for input and output will vary by type of the image component. - * - * Input (aka Source) : Zero Inputs, one Output, - * Splitter : One Input, 2 or more Outputs, - * Processing Element : One Input, one output, - * Mixer : 2 or more inputs, one output, - * Output (aka Sink) : One Input, zero outputs. - * - * The PortDefinition structure is used to define all of the parameters - * necessary for the compliant component to setup an input or an output - * image path. If additional vendor specific data is required, it should - * be transmitted to the component using the CustomCommand function. - * Compliant components will prepopulate this structure with optimal - * values during the OMX_GetParameter() command. - * - * STRUCT MEMBERS: - * cMIMEType : MIME type of data for the port - * pNativeRender : Platform specific reference for a display if a - * sync, otherwise this field is 0 - * nFrameWidth : Width of frame to be used on port if - * uncompressed format is used. Use 0 for - * unknown, don't care or variable - * nFrameHeight : Height of frame to be used on port if - * uncompressed format is used. Use 0 for - * unknown, don't care or variable - * nStride : Number of bytes per span of an image (i.e. - * indicates the number of bytes to get from - * span N to span N+1, where negative stride - * indicates the image is bottom up - * nSliceHeight : Height used when encoding in slices - * bFlagErrorConcealment : Turns on error concealment if it is supported by - * the OMX component - * eCompressionFormat : Compression format used in this instance of - * the component. When OMX_IMAGE_CodingUnused is - * specified, eColorFormat is valid - * eColorFormat : Decompressed format used by this component - * pNativeWindow : Platform specific reference for a window object if a - * display sink , otherwise this field is 0x0. - */ -typedef struct OMX_IMAGE_PORTDEFINITIONTYPE { - OMX_STRING cMIMEType; - OMX_NATIVE_DEVICETYPE pNativeRender; - OMX_U32 nFrameWidth; - OMX_U32 nFrameHeight; - OMX_S32 nStride; - OMX_U32 nSliceHeight; - OMX_BOOL bFlagErrorConcealment; - OMX_IMAGE_CODINGTYPE eCompressionFormat; - OMX_COLOR_FORMATTYPE eColorFormat; - OMX_NATIVE_WINDOWTYPE pNativeWindow; -} OMX_IMAGE_PORTDEFINITIONTYPE; - - -/** - * Port format parameter. This structure is used to enumerate the various - * data input/output format supported by the port. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Indicates which port to set - * nIndex : Indicates the enumeration index for the format from - * 0x0 to N-1 - * eCompressionFormat : Compression format used in this instance of the - * component. When OMX_IMAGE_CodingUnused is specified, - * eColorFormat is valid - * eColorFormat : Decompressed format used by this component - */ -typedef struct OMX_IMAGE_PARAM_PORTFORMATTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nIndex; - OMX_IMAGE_CODINGTYPE eCompressionFormat; - OMX_COLOR_FORMATTYPE eColorFormat; -} OMX_IMAGE_PARAM_PORTFORMATTYPE; - - -/** - * Flash control type - * - * ENUMS - * Torch : Flash forced constantly on - */ -typedef enum OMX_IMAGE_FLASHCONTROLTYPE { - OMX_IMAGE_FlashControlOn = 0, - OMX_IMAGE_FlashControlOff, - OMX_IMAGE_FlashControlAuto, - OMX_IMAGE_FlashControlRedEyeReduction, - OMX_IMAGE_FlashControlFillin, - OMX_IMAGE_FlashControlTorch, - OMX_IMAGE_FlashControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_IMAGE_FlashControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_IMAGE_FlashControlMax = 0x7FFFFFFF -} OMX_IMAGE_FLASHCONTROLTYPE; - - -/** - * Flash control configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eFlashControl : Flash control type - */ -typedef struct OMX_IMAGE_PARAM_FLASHCONTROLTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_IMAGE_FLASHCONTROLTYPE eFlashControl; -} OMX_IMAGE_PARAM_FLASHCONTROLTYPE; - - -/** - * Focus control type - */ -typedef enum OMX_IMAGE_FOCUSCONTROLTYPE { - OMX_IMAGE_FocusControlOn = 0, - OMX_IMAGE_FocusControlOff, - OMX_IMAGE_FocusControlAuto, - OMX_IMAGE_FocusControlAutoLock, - OMX_IMAGE_FocusControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_IMAGE_FocusControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_IMAGE_FocusControlMax = 0x7FFFFFFF -} OMX_IMAGE_FOCUSCONTROLTYPE; - - -/** - * Focus control configuration - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eFocusControl : Focus control - * nFocusSteps : Focus can take on values from 0 mm to infinity. - * Interest is only in number of steps over this range. - * nFocusStepIndex : Current focus step index - */ -typedef struct OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_IMAGE_FOCUSCONTROLTYPE eFocusControl; - OMX_U32 nFocusSteps; - OMX_U32 nFocusStepIndex; -} OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE; - - -/** - * Q Factor for JPEG compression, which controls the tradeoff between image - * quality and size. Q Factor provides a more simple means of controlling - * JPEG compression quality, without directly programming Quantization - * tables for chroma and luma - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nQFactor : JPEG Q factor value in the range of 1-100. A factor of 1 - * produces the smallest, worst quality images, and a factor - * of 100 produces the largest, best quality images. A - * typical default is 75 for small good quality images - */ -typedef struct OMX_IMAGE_PARAM_QFACTORTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nQFactor; -} OMX_IMAGE_PARAM_QFACTORTYPE; - -/** - * Quantization table type - */ - -typedef enum OMX_IMAGE_QUANTIZATIONTABLETYPE { - OMX_IMAGE_QuantizationTableLuma = 0, - OMX_IMAGE_QuantizationTableChroma, - OMX_IMAGE_QuantizationTableChromaCb, - OMX_IMAGE_QuantizationTableChromaCr, - OMX_IMAGE_QuantizationTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_IMAGE_QuantizationTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_IMAGE_QuantizationTableMax = 0x7FFFFFFF -} OMX_IMAGE_QUANTIZATIONTABLETYPE; - -/** - * JPEG quantization tables are used to determine DCT compression for - * YUV data, as an alternative to specifying Q factor, providing exact - * control of compression - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eQuantizationTable : Quantization table type - * nQuantizationMatrix[64] : JPEG quantization table of coefficients stored - * in increasing columns then by rows of data (i.e. - * row 1, ... row 8). Quantization values are in - * the range 0-255 and stored in linear order - * (i.e. the component will zig-zag the - * quantization table data if required internally) - */ -typedef struct OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_IMAGE_QUANTIZATIONTABLETYPE eQuantizationTable; - OMX_U8 nQuantizationMatrix[64]; -} OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE; - - -/** - * Huffman table type, the same Huffman table is applied for chroma and - * luma component - */ -typedef enum OMX_IMAGE_HUFFMANTABLETYPE { - OMX_IMAGE_HuffmanTableAC = 0, - OMX_IMAGE_HuffmanTableDC, - OMX_IMAGE_HuffmanTableACLuma, - OMX_IMAGE_HuffmanTableACChroma, - OMX_IMAGE_HuffmanTableDCLuma, - OMX_IMAGE_HuffmanTableDCChroma, - OMX_IMAGE_HuffmanTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_IMAGE_HuffmanTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_IMAGE_HuffmanTableMax = 0x7FFFFFFF -} OMX_IMAGE_HUFFMANTABLETYPE; - -/** - * JPEG Huffman table - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eHuffmanTable : Huffman table type - * nNumberOfHuffmanCodeOfLength[16] : 0-16, number of Huffman codes of each - * possible length - * nHuffmanTable[256] : 0-255, the size used for AC and DC - * HuffmanTable are 16 and 162 - */ -typedef struct OMX_IMAGE_PARAM_HUFFMANTTABLETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_IMAGE_HUFFMANTABLETYPE eHuffmanTable; - OMX_U8 nNumberOfHuffmanCodeOfLength[16]; - OMX_U8 nHuffmanTable[256]; -}OMX_IMAGE_PARAM_HUFFMANTTABLETYPE; - -/** @} */ -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ diff --git a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Index.h b/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Index.h deleted file mode 100644 index 44d4ea7..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Index.h +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (c) 2008 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. - * - */ - -/** @file OMX_Index.h - OpenMax IL version 1.1.2 - * The OMX_Index header file contains the definitions for both applications - * and components . - */ - - -#ifndef OMX_Index_h -#define OMX_Index_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 - - -/** The OMX_INDEXTYPE enumeration is used to select a structure when either - * getting or setting parameters and/or configuration data. Each entry in - * this enumeration maps to an OMX specified structure. When the - * OMX_GetParameter, OMX_SetParameter, OMX_GetConfig or OMX_SetConfig methods - * are used, the second parameter will always be an entry from this enumeration - * and the third entry will be the structure shown in the comments for the entry. - * For example, if the application is initializing a cropping function, the - * OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop as the second parameter - * and would send a pointer to an initialized OMX_RECTTYPE structure as the - * third parameter. - * - * The enumeration entries named with the OMX_Config prefix are sent using - * the OMX_SetConfig command and the enumeration entries named with the - * OMX_PARAM_ prefix are sent using the OMX_SetParameter command. - */ -typedef enum OMX_INDEXTYPE { - - OMX_IndexComponentStartUnused = 0x01000000, - OMX_IndexParamPriorityMgmt, /**< reference: OMX_PRIORITYMGMTTYPE */ - OMX_IndexParamAudioInit, /**< reference: OMX_PORT_PARAM_TYPE */ - OMX_IndexParamImageInit, /**< reference: OMX_PORT_PARAM_TYPE */ - OMX_IndexParamVideoInit, /**< reference: OMX_PORT_PARAM_TYPE */ - OMX_IndexParamOtherInit, /**< reference: OMX_PORT_PARAM_TYPE */ - OMX_IndexParamNumAvailableStreams, /**< reference: OMX_PARAM_U32TYPE */ - OMX_IndexParamActiveStream, /**< reference: OMX_PARAM_U32TYPE */ - OMX_IndexParamSuspensionPolicy, /**< reference: OMX_PARAM_SUSPENSIONPOLICYTYPE */ - OMX_IndexParamComponentSuspended, /**< reference: OMX_PARAM_SUSPENSIONTYPE */ - OMX_IndexConfigCapturing, /**< reference: OMX_CONFIG_BOOLEANTYPE */ - OMX_IndexConfigCaptureMode, /**< reference: OMX_CONFIG_CAPTUREMODETYPE */ - OMX_IndexAutoPauseAfterCapture, /**< reference: OMX_CONFIG_BOOLEANTYPE */ - OMX_IndexParamContentURI, /**< reference: OMX_PARAM_CONTENTURITYPE */ - OMX_IndexParamCustomContentPipe, /**< reference: OMX_PARAM_CONTENTPIPETYPE */ - OMX_IndexParamDisableResourceConcealment, /**< reference: OMX_RESOURCECONCEALMENTTYPE */ - OMX_IndexConfigMetadataItemCount, /**< reference: OMX_CONFIG_METADATAITEMCOUNTTYPE */ - OMX_IndexConfigContainerNodeCount, /**< reference: OMX_CONFIG_CONTAINERNODECOUNTTYPE */ - OMX_IndexConfigMetadataItem, /**< reference: OMX_CONFIG_METADATAITEMTYPE */ - OMX_IndexConfigCounterNodeID, /**< reference: OMX_CONFIG_CONTAINERNODEIDTYPE */ - OMX_IndexParamMetadataFilterType, /**< reference: OMX_PARAM_METADATAFILTERTYPE */ - OMX_IndexParamMetadataKeyFilter, /**< reference: OMX_PARAM_METADATAFILTERTYPE */ - OMX_IndexConfigPriorityMgmt, /**< reference: OMX_PRIORITYMGMTTYPE */ - OMX_IndexParamStandardComponentRole, /**< reference: OMX_PARAM_COMPONENTROLETYPE */ - - OMX_IndexPortStartUnused = 0x02000000, - OMX_IndexParamPortDefinition, /**< reference: OMX_PARAM_PORTDEFINITIONTYPE */ - OMX_IndexParamCompBufferSupplier, /**< reference: OMX_PARAM_BUFFERSUPPLIERTYPE */ - OMX_IndexReservedStartUnused = 0x03000000, - - /* Audio parameters and configurations */ - OMX_IndexAudioStartUnused = 0x04000000, - OMX_IndexParamAudioPortFormat, /**< reference: OMX_AUDIO_PARAM_PORTFORMATTYPE */ - OMX_IndexParamAudioPcm, /**< reference: OMX_AUDIO_PARAM_PCMMODETYPE */ - OMX_IndexParamAudioAac, /**< reference: OMX_AUDIO_PARAM_AACPROFILETYPE */ - OMX_IndexParamAudioRa, /**< reference: OMX_AUDIO_PARAM_RATYPE */ - OMX_IndexParamAudioMp3, /**< reference: OMX_AUDIO_PARAM_MP3TYPE */ - OMX_IndexParamAudioAdpcm, /**< reference: OMX_AUDIO_PARAM_ADPCMTYPE */ - OMX_IndexParamAudioG723, /**< reference: OMX_AUDIO_PARAM_G723TYPE */ - OMX_IndexParamAudioG729, /**< reference: OMX_AUDIO_PARAM_G729TYPE */ - OMX_IndexParamAudioAmr, /**< reference: OMX_AUDIO_PARAM_AMRTYPE */ - OMX_IndexParamAudioWma, /**< reference: OMX_AUDIO_PARAM_WMATYPE */ - OMX_IndexParamAudioSbc, /**< reference: OMX_AUDIO_PARAM_SBCTYPE */ - OMX_IndexParamAudioMidi, /**< reference: OMX_AUDIO_PARAM_MIDITYPE */ - OMX_IndexParamAudioGsm_FR, /**< reference: OMX_AUDIO_PARAM_GSMFRTYPE */ - OMX_IndexParamAudioMidiLoadUserSound, /**< reference: OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE */ - OMX_IndexParamAudioG726, /**< reference: OMX_AUDIO_PARAM_G726TYPE */ - OMX_IndexParamAudioGsm_EFR, /**< reference: OMX_AUDIO_PARAM_GSMEFRTYPE */ - OMX_IndexParamAudioGsm_HR, /**< reference: OMX_AUDIO_PARAM_GSMHRTYPE */ - OMX_IndexParamAudioPdc_FR, /**< reference: OMX_AUDIO_PARAM_PDCFRTYPE */ - OMX_IndexParamAudioPdc_EFR, /**< reference: OMX_AUDIO_PARAM_PDCEFRTYPE */ - OMX_IndexParamAudioPdc_HR, /**< reference: OMX_AUDIO_PARAM_PDCHRTYPE */ - OMX_IndexParamAudioTdma_FR, /**< reference: OMX_AUDIO_PARAM_TDMAFRTYPE */ - OMX_IndexParamAudioTdma_EFR, /**< reference: OMX_AUDIO_PARAM_TDMAEFRTYPE */ - OMX_IndexParamAudioQcelp8, /**< reference: OMX_AUDIO_PARAM_QCELP8TYPE */ - OMX_IndexParamAudioQcelp13, /**< reference: OMX_AUDIO_PARAM_QCELP13TYPE */ - OMX_IndexParamAudioEvrc, /**< reference: OMX_AUDIO_PARAM_EVRCTYPE */ - OMX_IndexParamAudioSmv, /**< reference: OMX_AUDIO_PARAM_SMVTYPE */ - OMX_IndexParamAudioVorbis, /**< reference: OMX_AUDIO_PARAM_VORBISTYPE */ - - OMX_IndexConfigAudioMidiImmediateEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE */ - OMX_IndexConfigAudioMidiControl, /**< reference: OMX_AUDIO_CONFIG_MIDICONTROLTYPE */ - OMX_IndexConfigAudioMidiSoundBankProgram, /**< reference: OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE */ - OMX_IndexConfigAudioMidiStatus, /**< reference: OMX_AUDIO_CONFIG_MIDISTATUSTYPE */ - OMX_IndexConfigAudioMidiMetaEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE */ - OMX_IndexConfigAudioMidiMetaEventData, /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE */ - OMX_IndexConfigAudioVolume, /**< reference: OMX_AUDIO_CONFIG_VOLUMETYPE */ - OMX_IndexConfigAudioBalance, /**< reference: OMX_AUDIO_CONFIG_BALANCETYPE */ - OMX_IndexConfigAudioChannelMute, /**< reference: OMX_AUDIO_CONFIG_CHANNELMUTETYPE */ - OMX_IndexConfigAudioMute, /**< reference: OMX_AUDIO_CONFIG_MUTETYPE */ - OMX_IndexConfigAudioLoudness, /**< reference: OMX_AUDIO_CONFIG_LOUDNESSTYPE */ - OMX_IndexConfigAudioEchoCancelation, /**< reference: OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE */ - OMX_IndexConfigAudioNoiseReduction, /**< reference: OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE */ - OMX_IndexConfigAudioBass, /**< reference: OMX_AUDIO_CONFIG_BASSTYPE */ - OMX_IndexConfigAudioTreble, /**< reference: OMX_AUDIO_CONFIG_TREBLETYPE */ - OMX_IndexConfigAudioStereoWidening, /**< reference: OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE */ - OMX_IndexConfigAudioChorus, /**< reference: OMX_AUDIO_CONFIG_CHORUSTYPE */ - OMX_IndexConfigAudioEqualizer, /**< reference: OMX_AUDIO_CONFIG_EQUALIZERTYPE */ - OMX_IndexConfigAudioReverberation, /**< reference: OMX_AUDIO_CONFIG_REVERBERATIONTYPE */ - OMX_IndexConfigAudioChannelVolume, /**< reference: OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE */ - - /* Image specific parameters and configurations */ - OMX_IndexImageStartUnused = 0x05000000, - OMX_IndexParamImagePortFormat, /**< reference: OMX_IMAGE_PARAM_PORTFORMATTYPE */ - OMX_IndexParamFlashControl, /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */ - OMX_IndexConfigFocusControl, /**< reference: OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE */ - OMX_IndexParamQFactor, /**< reference: OMX_IMAGE_PARAM_QFACTORTYPE */ - OMX_IndexParamQuantizationTable, /**< reference: OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE */ - OMX_IndexParamHuffmanTable, /**< reference: OMX_IMAGE_PARAM_HUFFMANTTABLETYPE */ - OMX_IndexConfigFlashControl, /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */ - - /* Video specific parameters and configurations */ - OMX_IndexVideoStartUnused = 0x06000000, - OMX_IndexParamVideoPortFormat, /**< reference: OMX_VIDEO_PARAM_PORTFORMATTYPE */ - OMX_IndexParamVideoQuantization, /**< reference: OMX_VIDEO_PARAM_QUANTIZATIONTYPE */ - OMX_IndexParamVideoFastUpdate, /**< reference: OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE */ - OMX_IndexParamVideoBitrate, /**< reference: OMX_VIDEO_PARAM_BITRATETYPE */ - OMX_IndexParamVideoMotionVector, /**< reference: OMX_VIDEO_PARAM_MOTIONVECTORTYPE */ - OMX_IndexParamVideoIntraRefresh, /**< reference: OMX_VIDEO_PARAM_INTRAREFRESHTYPE */ - OMX_IndexParamVideoErrorCorrection, /**< reference: OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE */ - OMX_IndexParamVideoVBSMC, /**< reference: OMX_VIDEO_PARAM_VBSMCTYPE */ - OMX_IndexParamVideoMpeg2, /**< reference: OMX_VIDEO_PARAM_MPEG2TYPE */ - OMX_IndexParamVideoMpeg4, /**< reference: OMX_VIDEO_PARAM_MPEG4TYPE */ - OMX_IndexParamVideoWmv, /**< reference: OMX_VIDEO_PARAM_WMVTYPE */ - OMX_IndexParamVideoRv, /**< reference: OMX_VIDEO_PARAM_RVTYPE */ - OMX_IndexParamVideoAvc, /**< reference: OMX_VIDEO_PARAM_AVCTYPE */ - OMX_IndexParamVideoH263, /**< reference: OMX_VIDEO_PARAM_H263TYPE */ - OMX_IndexParamVideoProfileLevelQuerySupported, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */ - OMX_IndexParamVideoProfileLevelCurrent, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */ - OMX_IndexConfigVideoBitrate, /**< reference: OMX_VIDEO_CONFIG_BITRATETYPE */ - OMX_IndexConfigVideoFramerate, /**< reference: OMX_CONFIG_FRAMERATETYPE */ - OMX_IndexConfigVideoIntraVOPRefresh, /**< reference: OMX_CONFIG_INTRAREFRESHVOPTYPE */ - OMX_IndexConfigVideoIntraMBRefresh, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */ - OMX_IndexConfigVideoMBErrorReporting, /**< reference: OMX_CONFIG_MBERRORREPORTINGTYPE */ - OMX_IndexParamVideoMacroblocksPerFrame, /**< reference: OMX_PARAM_MACROBLOCKSTYPE */ - OMX_IndexConfigVideoMacroBlockErrorMap, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */ - OMX_IndexParamVideoSliceFMO, /**< reference: OMX_VIDEO_PARAM_AVCSLICEFMO */ - OMX_IndexConfigVideoAVCIntraPeriod, /**< reference: OMX_VIDEO_CONFIG_AVCINTRAPERIOD */ - OMX_IndexConfigVideoNalSize, /**< reference: OMX_VIDEO_CONFIG_NALSIZE */ - - /* Image & Video common Configurations */ - OMX_IndexCommonStartUnused = 0x07000000, - OMX_IndexParamCommonDeblocking, /**< reference: OMX_PARAM_DEBLOCKINGTYPE */ - OMX_IndexParamCommonSensorMode, /**< reference: OMX_PARAM_SENSORMODETYPE */ - OMX_IndexParamCommonInterleave, /**< reference: OMX_PARAM_INTERLEAVETYPE */ - OMX_IndexConfigCommonColorFormatConversion, /**< reference: OMX_CONFIG_COLORCONVERSIONTYPE */ - OMX_IndexConfigCommonScale, /**< reference: OMX_CONFIG_SCALEFACTORTYPE */ - OMX_IndexConfigCommonImageFilter, /**< reference: OMX_CONFIG_IMAGEFILTERTYPE */ - OMX_IndexConfigCommonColorEnhancement, /**< reference: OMX_CONFIG_COLORENHANCEMENTTYPE */ - OMX_IndexConfigCommonColorKey, /**< reference: OMX_CONFIG_COLORKEYTYPE */ - OMX_IndexConfigCommonColorBlend, /**< reference: OMX_CONFIG_COLORBLENDTYPE */ - OMX_IndexConfigCommonFrameStabilisation,/**< reference: OMX_CONFIG_FRAMESTABTYPE */ - OMX_IndexConfigCommonRotate, /**< reference: OMX_CONFIG_ROTATIONTYPE */ - OMX_IndexConfigCommonMirror, /**< reference: OMX_CONFIG_MIRRORTYPE */ - OMX_IndexConfigCommonOutputPosition, /**< reference: OMX_CONFIG_POINTTYPE */ - OMX_IndexConfigCommonInputCrop, /**< reference: OMX_CONFIG_RECTTYPE */ - OMX_IndexConfigCommonOutputCrop, /**< reference: OMX_CONFIG_RECTTYPE */ - OMX_IndexConfigCommonDigitalZoom, /**< reference: OMX_CONFIG_SCALEFACTORTYPE */ - OMX_IndexConfigCommonOpticalZoom, /**< reference: OMX_CONFIG_SCALEFACTORTYPE*/ - OMX_IndexConfigCommonWhiteBalance, /**< reference: OMX_CONFIG_WHITEBALCONTROLTYPE */ - OMX_IndexConfigCommonExposure, /**< reference: OMX_CONFIG_EXPOSURECONTROLTYPE */ - OMX_IndexConfigCommonContrast, /**< reference: OMX_CONFIG_CONTRASTTYPE */ - OMX_IndexConfigCommonBrightness, /**< reference: OMX_CONFIG_BRIGHTNESSTYPE */ - OMX_IndexConfigCommonBacklight, /**< reference: OMX_CONFIG_BACKLIGHTTYPE */ - OMX_IndexConfigCommonGamma, /**< reference: OMX_CONFIG_GAMMATYPE */ - OMX_IndexConfigCommonSaturation, /**< reference: OMX_CONFIG_SATURATIONTYPE */ - OMX_IndexConfigCommonLightness, /**< reference: OMX_CONFIG_LIGHTNESSTYPE */ - OMX_IndexConfigCommonExclusionRect, /**< reference: OMX_CONFIG_RECTTYPE */ - OMX_IndexConfigCommonDithering, /**< reference: OMX_CONFIG_DITHERTYPE */ - OMX_IndexConfigCommonPlaneBlend, /**< reference: OMX_CONFIG_PLANEBLENDTYPE */ - OMX_IndexConfigCommonExposureValue, /**< reference: OMX_CONFIG_EXPOSUREVALUETYPE */ - OMX_IndexConfigCommonOutputSize, /**< reference: OMX_FRAMESIZETYPE */ - OMX_IndexParamCommonExtraQuantData, /**< reference: OMX_OTHER_EXTRADATATYPE */ - OMX_IndexConfigCommonFocusRegion, /**< reference: OMX_CONFIG_FOCUSREGIONTYPE */ - OMX_IndexConfigCommonFocusStatus, /**< reference: OMX_PARAM_FOCUSSTATUSTYPE */ - OMX_IndexConfigCommonTransitionEffect, /**< reference: OMX_CONFIG_TRANSITIONEFFECTTYPE */ - - /* Reserved Configuration range */ - OMX_IndexOtherStartUnused = 0x08000000, - OMX_IndexParamOtherPortFormat, /**< reference: OMX_OTHER_PARAM_PORTFORMATTYPE */ - OMX_IndexConfigOtherPower, /**< reference: OMX_OTHER_CONFIG_POWERTYPE */ - OMX_IndexConfigOtherStats, /**< reference: OMX_OTHER_CONFIG_STATSTYPE */ - - - /* Reserved Time range */ - OMX_IndexTimeStartUnused = 0x09000000, - OMX_IndexConfigTimeScale, /**< reference: OMX_TIME_CONFIG_SCALETYPE */ - OMX_IndexConfigTimeClockState, /**< reference: OMX_TIME_CONFIG_CLOCKSTATETYPE */ - OMX_IndexConfigTimeActiveRefClock, /**< reference: OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE */ - OMX_IndexConfigTimeCurrentMediaTime, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */ - OMX_IndexConfigTimeCurrentWallTime, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */ - OMX_IndexConfigTimeCurrentAudioReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */ - OMX_IndexConfigTimeCurrentVideoReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */ - OMX_IndexConfigTimeMediaTimeRequest, /**< reference: OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE (write only) */ - OMX_IndexConfigTimeClientStartTime, /** - - -/** - * Enumeration of possible data types which match to multiple domains or no - * domain at all. For types which are vendor specific, a value above - * OMX_OTHER_VENDORTSTART should be used. - */ -typedef enum OMX_OTHER_FORMATTYPE { - OMX_OTHER_FormatTime = 0, /**< Transmission of various timestamps, elapsed time, - time deltas, etc */ - OMX_OTHER_FormatPower, /**< Perhaps used for enabling/disabling power - management, setting clocks? */ - OMX_OTHER_FormatStats, /**< Could be things such as frame rate, frames - dropped, etc */ - OMX_OTHER_FormatBinary, /**< Arbitrary binary data */ - OMX_OTHER_FormatVendorReserved = 1000, /**< Starting value for vendor specific - formats */ - - OMX_OTHER_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_OTHER_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_OTHER_FormatMax = 0x7FFFFFFF -} OMX_OTHER_FORMATTYPE; - -/** - * Enumeration of seek modes. - */ -typedef enum OMX_TIME_SEEKMODETYPE { - OMX_TIME_SeekModeFast = 0, /**< Prefer seeking to an approximation - * of the requested seek position over - * the actual seek position if it - * results in a faster seek. */ - OMX_TIME_SeekModeAccurate, /**< Prefer seeking to the actual seek - * position over an approximation - * of the requested seek position even - * if it results in a slower seek. */ - OMX_TIME_SeekModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_TIME_SeekModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_TIME_SeekModeMax = 0x7FFFFFFF -} OMX_TIME_SEEKMODETYPE; - -/* Structure representing the seekmode of the component */ -typedef struct OMX_TIME_CONFIG_SEEKMODETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_TIME_SEEKMODETYPE eType; /**< The seek mode */ -} OMX_TIME_CONFIG_SEEKMODETYPE; - -/** Structure representing a time stamp used with the following configs - * on the Clock Component (CC): - * - * OMX_IndexConfigTimeCurrentWallTime: query of the CC’s current wall - * time - * OMX_IndexConfigTimeCurrentMediaTime: query of the CC’s current media - * time - * OMX_IndexConfigTimeCurrentAudioReference and - * OMX_IndexConfigTimeCurrentVideoReference: audio/video reference - * clock sending SC its reference time - * OMX_IndexConfigTimeClientStartTime: a Clock Component client sends - * this structure to the Clock Component via a SetConfig on its - * client port when it receives a buffer with - * OMX_BUFFERFLAG_STARTTIME set. It must use the timestamp - * specified by that buffer for nStartTimestamp. - * - * It’s also used with the following config on components in general: - * - * OMX_IndexConfigTimePosition: IL client querying component position - * (GetConfig) or commanding a component to seek to the given location - * (SetConfig) - */ -typedef struct OMX_TIME_CONFIG_TIMESTAMPTYPE { - 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_TICKS nTimestamp; /**< timestamp .*/ -} OMX_TIME_CONFIG_TIMESTAMPTYPE; - -/** Enumeration of possible reference clocks to the media time. */ -typedef enum OMX_TIME_UPDATETYPE { - OMX_TIME_UpdateRequestFulfillment, /**< Update is the fulfillment of a media time request. */ - OMX_TIME_UpdateScaleChanged, /**< Update was generated because the scale chagned. */ - OMX_TIME_UpdateClockStateChanged, /**< Update was generated because the clock state changed. */ - OMX_TIME_UpdateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_TIME_UpdateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_TIME_UpdateMax = 0x7FFFFFFF -} OMX_TIME_UPDATETYPE; - -/** Enumeration of possible reference clocks to the media time. */ -typedef enum OMX_TIME_REFCLOCKTYPE { - OMX_TIME_RefClockNone, /**< Use no references. */ - OMX_TIME_RefClockAudio, /**< Use references sent through OMX_IndexConfigTimeCurrentAudioReference */ - OMX_TIME_RefClockVideo, /**< Use references sent through OMX_IndexConfigTimeCurrentVideoReference */ - OMX_TIME_RefClockKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_TIME_RefClockVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_TIME_RefClockMax = 0x7FFFFFFF -} OMX_TIME_REFCLOCKTYPE; - -/** Enumeration of clock states. */ -typedef enum OMX_TIME_CLOCKSTATE { - OMX_TIME_ClockStateRunning, /**< Clock running. */ - OMX_TIME_ClockStateWaitingForStartTime, /**< Clock waiting until the - * prescribed clients emit their - * start time. */ - OMX_TIME_ClockStateStopped, /**< Clock stopped. */ - OMX_TIME_ClockStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_TIME_ClockStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_TIME_ClockStateMax = 0x7FFFFFFF -} OMX_TIME_CLOCKSTATE; - -/** Structure representing a media time request to the clock component. - * - * A client component sends this structure to the Clock Component via a SetConfig - * on its client port to specify a media timestamp the Clock Component - * should emit. The Clock Component should fulfill the request by sending a - * OMX_TIME_MEDIATIMETYPE when its media clock matches the requested - * timestamp. - * - * The client may require a media time request be fulfilled slightly - * earlier than the media time specified. In this case the client specifies - * an offset which is equal to the difference between wall time corresponding - * to the requested media time and the wall time when it will be - * fulfilled. - * - * A client component may uses these requests and the OMX_TIME_MEDIATIMETYPE to - * time events according to timestamps. If a client must perform an operation O at - * a time T (e.g. deliver a video frame at its corresponding timestamp), it makes a - * media time request at T (perhaps specifying an offset to ensure the request fulfillment - * is a little early). When the clock component passes the resulting OMX_TIME_MEDIATIMETYPE - * structure back to the client component, the client may perform operation O (perhaps having - * to wait a slight amount more time itself as specified by the return values). - */ - -typedef struct OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE { - 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_PTR pClientPrivate; /**< Client private data to disabiguate this media time - * from others (e.g. the number of the frame to deliver). - * Duplicated in the media time structure that fulfills - * this request. A value of zero is reserved for time scale - * updates. */ - OMX_TICKS nMediaTimestamp; /**< Media timestamp requested.*/ - OMX_TICKS nOffset; /**< Amount of wall clock time by which this - * request should be fulfilled early */ -} OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE; - -/**< Structure sent from the clock component client either when fulfilling - * a media time request or when the time scale has changed. - * - * In the former case the Clock Component fills this structure and times its emission - * to a client component (via the client port) according to the corresponding media - * time request sent by the client. The Clock Component should time the emission to occur - * when the requested timestamp matches the Clock Component's media time but also the - * prescribed offset early. - * - * Upon scale changes the clock component clears the nClientPrivate data, sends the current - * media time and sets the nScale to the new scale via the client port. It emits a - * OMX_TIME_MEDIATIMETYPE to all clients independent of any requests. This allows clients to - * alter processing to accomodate scaling. For instance a video component might skip inter-frames - * in the case of extreme fastforward. Likewise an audio component might add or remove samples - * from an audio frame to scale audio data. - * - * It is expected that some clock components may not be able to fulfill requests - * at exactly the prescribed time. This is acceptable so long as the request is - * fulfilled at least as early as described and not later. This structure provides - * fields the client may use to wait for the remaining time. - * - * The client may use either the nOffset or nWallTimeAtMedia fields to determine the - * wall time until the nMediaTimestamp actually occurs. In the latter case the - * client can get a more accurate value for offset by getting the current wall - * from the cloc component and subtracting it from nWallTimeAtMedia. - */ - -typedef struct OMX_TIME_MEDIATIMETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nClientPrivate; /**< Client private data to disabiguate this media time - * from others. Copied from the media time request. - * A value of zero is reserved for time scale updates. */ - OMX_TIME_UPDATETYPE eUpdateType; /**< Reason for the update */ - OMX_TICKS nMediaTimestamp; /**< Media time requested. If no media time was - * requested then this is the current media time. */ - OMX_TICKS nOffset; /**< Amount of wall clock time by which this - * request was actually fulfilled early */ - - OMX_TICKS nWallTimeAtMediaTime; /**< Wall time corresponding to nMediaTimeStamp. - * A client may compare this value to current - * media time obtained from the Clock Component to determine - * the wall time until the media timestamp is really - * current. */ - OMX_S32 xScale; /**< Current media time scale in Q16 format. */ - OMX_TIME_CLOCKSTATE eState; /* Seeking Change. Added 7/12.*/ - /**< State of the media time. */ -} OMX_TIME_MEDIATIMETYPE; - -/** Structure representing the current media time scale factor. Applicable only to clock - * component, other components see scale changes via OMX_TIME_MEDIATIMETYPE buffers sent via - * the clock component client ports. Upon recieving this config the clock component changes - * the rate by which the media time increases or decreases effectively implementing trick modes. - */ -typedef struct OMX_TIME_CONFIG_SCALETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_S32 xScale; /**< This is a value in Q16 format which is used for - * scaling the media time */ -} OMX_TIME_CONFIG_SCALETYPE; - -/** Bits used to identify a clock port. Used in OMX_TIME_CONFIG_CLOCKSTATETYPE’s nWaitMask field */ -#define OMX_CLOCKPORT0 0x00000001 -#define OMX_CLOCKPORT1 0x00000002 -#define OMX_CLOCKPORT2 0x00000004 -#define OMX_CLOCKPORT3 0x00000008 -#define OMX_CLOCKPORT4 0x00000010 -#define OMX_CLOCKPORT5 0x00000020 -#define OMX_CLOCKPORT6 0x00000040 -#define OMX_CLOCKPORT7 0x00000080 - -/** Structure representing the current mode of the media clock. - * IL Client uses this config to change or query the mode of the - * media clock of the clock component. Applicable only to clock - * component. - * - * On a SetConfig if eState is OMX_TIME_ClockStateRunning media time - * starts immediately at the prescribed start time. If - * OMX_TIME_ClockStateWaitingForStartTime the Clock Component ignores - * the given nStartTime and waits for all clients specified in the - * nWaitMask to send starttimes (via - * OMX_IndexConfigTimeClientStartTime). The Clock Component then starts - * the media clock using the earliest start time supplied. */ -typedef struct OMX_TIME_CONFIG_CLOCKSTATETYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version - * information */ - OMX_TIME_CLOCKSTATE eState; /**< State of the media time. */ - OMX_TICKS nStartTime; /**< Start time of the media time. */ - OMX_TICKS nOffset; /**< Time to offset the media time by - * (e.g. preroll). Media time will be - * reported to be nOffset ticks earlier. - */ - OMX_U32 nWaitMask; /**< Mask of OMX_CLOCKPORT values. */ -} OMX_TIME_CONFIG_CLOCKSTATETYPE; - -/** Structure representing the reference clock currently being used to - * compute media time. IL client uses this config to change or query the - * clock component's active reference clock */ -typedef struct OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_TIME_REFCLOCKTYPE eClock; /**< Reference clock used to compute media time */ -} OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE; - -/** Descriptor for setting specifics of power type. - * Note: this structure is listed for backwards compatibility. */ -typedef struct OMX_OTHER_CONFIG_POWERTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_BOOL bEnablePM; /**< Flag to enable Power Management */ -} OMX_OTHER_CONFIG_POWERTYPE; - - -/** Descriptor for setting specifics of stats type. - * Note: this structure is listed for backwards compatibility. */ -typedef struct OMX_OTHER_CONFIG_STATSTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - /* what goes here */ -} OMX_OTHER_CONFIG_STATSTYPE; - - -/** - * The PortDefinition structure is used to define all of the parameters - * necessary for the compliant component to setup an input or an output other - * path. - */ -typedef struct OMX_OTHER_PORTDEFINITIONTYPE { - OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */ -} OMX_OTHER_PORTDEFINITIONTYPE; - -/** Port format parameter. This structure is used to enumerate - * the various data input/output format supported by the port. - */ -typedef struct OMX_OTHER_PARAM_PORTFORMATTYPE { - OMX_U32 nSize; /**< size of the structure in bytes */ - OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ - OMX_U32 nPortIndex; /**< Indicates which port to set */ - OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */ - OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */ -} OMX_OTHER_PARAM_PORTFORMATTYPE; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ diff --git a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Types.h b/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Types.h deleted file mode 100644 index 31be916..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Types.h +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Copyright (c) 2008 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_Types.h - OpenMax IL version 1.1.2 - * The OMX_Types header file contains the primitive type definitions used by - * the core, the application and the component. This file may need to be - * modified to be used on systems that do not have "char" set to 8 bits, - * "short" set to 16 bits and "long" set to 32 bits. - */ - -#ifndef OMX_Types_h -#define OMX_Types_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** The OMX_API and OMX_APIENTRY are platform specific definitions used - * to declare OMX function prototypes. They are modified to meet the - * requirements for a particular platform */ -#ifdef __SYMBIAN32__ -# ifdef __OMX_EXPORTS -# define OMX_API __declspec(dllexport) -# else -# ifdef _WIN32 -# define OMX_API __declspec(dllexport) -# else -# define OMX_API __declspec(dllimport) -# endif -# endif -#else -# ifdef _WIN32 -# ifdef __OMX_EXPORTS -# define OMX_API __declspec(dllexport) -# else -# define OMX_API __declspec(dllimport) -# endif -# else -# ifdef __OMX_EXPORTS -# define OMX_API -# else -# define OMX_API extern -# endif -# endif -#endif - -#ifndef OMX_APIENTRY -#define OMX_APIENTRY -#endif - -/** OMX_IN is used to identify inputs to an OMX function. This designation - will also be used in the case of a pointer that points to a parameter - that is used as an output. */ -#ifndef OMX_IN -#define OMX_IN -#endif - -/** OMX_OUT is used to identify outputs from an OMX function. This - designation will also be used in the case of a pointer that points - to a parameter that is used as an input. */ -#ifndef OMX_OUT -#define OMX_OUT -#endif - - -/** OMX_INOUT is used to identify parameters that may be either inputs or - outputs from an OMX function at the same time. This designation will - also be used in the case of a pointer that points to a parameter that - is used both as an input and an output. */ -#ifndef OMX_INOUT -#define OMX_INOUT -#endif - -/** OMX_ALL is used to as a wildcard to select all entities of the same type - * when specifying the index, or referring to a object by an index. (i.e. - * use OMX_ALL to indicate all N channels). When used as a port index - * for a config or parameter this OMX_ALL denotes that the config or - * parameter applies to the entire component not just one port. */ -#define OMX_ALL 0xFFFFFFFF - -/** In the following we define groups that help building doxygen documentation */ - -/** @defgroup core OpenMAX IL core - * Functions and structure related to the OMX IL core - */ - - /** @defgroup comp OpenMAX IL component - * Functions and structure related to the OMX IL component - */ - -/** @defgroup rpm Resource and Policy Management - * Structures for resource and policy management of components - */ - -/** @defgroup buf Buffer Management - * Buffer handling functions and structures - */ - -/** @defgroup tun Tunneling - * @ingroup core comp - * Structures and functions to manage tunnels among component ports - */ - -/** @defgroup cp Content Pipes - * @ingroup core - */ - - /** @defgroup metadata Metadata handling - * - */ - -/** OMX_U8 is an 8 bit unsigned quantity that is byte aligned */ -typedef unsigned char OMX_U8; - -/** OMX_S8 is an 8 bit signed quantity that is byte aligned */ -typedef signed char OMX_S8; - -/** OMX_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */ -typedef unsigned short OMX_U16; - -/** OMX_S16 is a 16 bit signed quantity that is 16 bit word aligned */ -typedef signed short OMX_S16; - -/** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */ -typedef unsigned long OMX_U32; - -/** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */ -typedef signed long OMX_S32; - - -/* Users with compilers that cannot accept the "long long" designation should - define the OMX_SKIP64BIT macro. It should be noted that this may cause - some components to fail to compile if the component was written to require - 64 bit integral types. However, these components would NOT compile anyway - since the compiler does not support the way the component was written. -*/ -#ifndef OMX_SKIP64BIT -#ifdef __SYMBIAN32__ -/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ -typedef unsigned long long OMX_U64; - -/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */ -typedef signed long long OMX_S64; - -#elif defined(WIN32) - -/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ -typedef unsigned __int64 OMX_U64; - -/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */ -typedef signed __int64 OMX_S64; - -#else /* WIN32 */ - -/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ -typedef unsigned long long OMX_U64; - -/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */ -typedef signed long long OMX_S64; - -#endif /* WIN32 */ -#endif - - -/** The OMX_BOOL type is intended to be used to represent a true or a false - value when passing parameters to and from the OMX core and components. The - OMX_BOOL is a 32 bit quantity and is aligned on a 32 bit word boundary. - */ -typedef enum OMX_BOOL { - OMX_FALSE = 0, - OMX_TRUE = !OMX_FALSE, - OMX_BOOL_MAX = 0x7FFFFFFF -} OMX_BOOL; - -/** The OMX_PTR type is intended to be used to pass pointers between the OMX - applications and the OMX Core and components. This is a 32 bit pointer and - is aligned on a 32 bit boundary. - */ -typedef void* OMX_PTR; - -/** The OMX_STRING type is intended to be used to pass "C" type strings between - the application and the core and component. The OMX_STRING type is a 32 - bit pointer to a zero terminated string. The pointer is word aligned and - the string is byte aligned. - */ -typedef char* OMX_STRING; - -/** The OMX_BYTE type is intended to be used to pass arrays of bytes such as - buffers between the application and the component and core. The OMX_BYTE - type is a 32 bit pointer to a zero terminated string. The pointer is word - aligned and the string is byte aligned. - */ -typedef unsigned char* OMX_BYTE; - -/** OMX_UUIDTYPE is a very long unique identifier to uniquely identify - at runtime. This identifier should be generated by a component in a way - that guarantees that every instance of the identifier running on the system - is unique. */ -typedef unsigned char OMX_UUIDTYPE[128]; - -/** The OMX_DIRTYPE enumeration is used to indicate if a port is an input or - an output port. This enumeration is common across all component types. - */ -typedef enum OMX_DIRTYPE -{ - OMX_DirInput, /**< Port is an input port */ - OMX_DirOutput, /**< Port is an output port */ - OMX_DirMax = 0x7FFFFFFF -} OMX_DIRTYPE; - -/** The OMX_ENDIANTYPE enumeration is used to indicate the bit ordering - for numerical data (i.e. big endian, or little endian). - */ -typedef enum OMX_ENDIANTYPE -{ - OMX_EndianBig, /**< big endian */ - OMX_EndianLittle, /**< little endian */ - OMX_EndianMax = 0x7FFFFFFF -} OMX_ENDIANTYPE; - - -/** The OMX_NUMERICALDATATYPE enumeration is used to indicate if data - is signed or unsigned - */ -typedef enum OMX_NUMERICALDATATYPE -{ - OMX_NumericalDataSigned, /**< signed data */ - OMX_NumericalDataUnsigned, /**< unsigned data */ - OMX_NumercialDataMax = 0x7FFFFFFF -} OMX_NUMERICALDATATYPE; - - -/** Unsigned bounded value type */ -typedef struct OMX_BU32 { - OMX_U32 nValue; /**< actual value */ - OMX_U32 nMin; /**< minimum for value (i.e. nValue >= nMin) */ - OMX_U32 nMax; /**< maximum for value (i.e. nValue <= nMax) */ -} OMX_BU32; - - -/** Signed bounded value type */ -typedef struct OMX_BS32 { - OMX_S32 nValue; /**< actual value */ - OMX_S32 nMin; /**< minimum for value (i.e. nValue >= nMin) */ - OMX_S32 nMax; /**< maximum for value (i.e. nValue <= nMax) */ -} OMX_BS32; - - -/** Structure representing some time or duration in microseconds. This structure - * must be interpreted as a signed 64 bit value. The quantity is signed to accommodate - * negative deltas and preroll scenarios. The quantity is represented in microseconds - * to accomodate high resolution timestamps (e.g. DVD presentation timestamps based - * on a 90kHz clock) and to allow more accurate and synchronized delivery (e.g. - * individual audio samples delivered at 192 kHz). The quantity is 64 bit to - * accommodate a large dynamic range (signed 32 bit values would allow only for plus - * or minus 35 minutes). - * - * Implementations with limited precision may convert the signed 64 bit value to - * a signed 32 bit value internally but risk loss of precision. - */ -#ifndef OMX_SKIP64BIT -typedef OMX_S64 OMX_TICKS; -#else -typedef struct OMX_TICKS -{ - OMX_U32 nLowPart; /** low bits of the signed 64 bit tick value */ - OMX_U32 nHighPart; /** high bits of the signed 64 bit tick value */ -} OMX_TICKS; -#endif -#define OMX_TICKS_PER_SECOND 1000000 - -/** Define the public interface for the OMX Handle. The core will not use - this value internally, but the application should only use this value. - */ -typedef void* OMX_HANDLETYPE; - -typedef struct OMX_MARKTYPE -{ - OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will - generate a mark event upon - processing the mark. */ - OMX_PTR pMarkData; /**< Application specific data associated with - the mark sent on a mark event to disambiguate - this mark from others. */ -} OMX_MARKTYPE; - - -/** OMX_NATIVE_DEVICETYPE is used to map a OMX video port to the - * platform & operating specific object used to reference the display - * or can be used by a audio port for native audio rendering */ -typedef void* OMX_NATIVE_DEVICETYPE; - -/** OMX_NATIVE_WINDOWTYPE is used to map a OMX video port to the - * platform & operating specific object used to reference the window */ -typedef void* OMX_NATIVE_WINDOWTYPE; - -/** The OMX_VERSIONTYPE union is used to specify the version for - a structure or component. For a component, the version is entirely - specified by the component vendor. Components doing the same function - from different vendors may or may not have the same version. For - structures, the version shall be set by the entity that allocates the - structure. For structures specified in the OMX 1.1 specification, the - value of the version shall be set to 1.1.0.0 in all cases. Access to the - OMX_VERSIONTYPE can be by a single 32 bit access (e.g. by nVersion) or - by accessing one of the structure elements to, for example, check only - the Major revision. - */ -typedef union OMX_VERSIONTYPE -{ - struct - { - OMX_U8 nVersionMajor; /**< Major version accessor element */ - OMX_U8 nVersionMinor; /**< Minor version accessor element */ - OMX_U8 nRevision; /**< Revision version accessor element */ - OMX_U8 nStep; /**< Step version accessor element */ - } s; - OMX_U32 nVersion; /**< 32 bit value to make accessing the - version easily done in a single word - size copy/compare operation */ -} OMX_VERSIONTYPE; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ diff --git a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Video.h b/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Video.h deleted file mode 100644 index 163e450..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Video.h +++ /dev/null @@ -1,1060 +0,0 @@ -/** - * Copyright (c) 2008 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. - * - */ - -/** - * @file OMX_Video.h - OpenMax IL version 1.1.2 - * The structures is needed by Video components to exchange parameters - * and configuration data with OMX components. - */ -#ifndef OMX_Video_h -#define OMX_Video_h - -/** @defgroup video OpenMAX IL Video Domain - * @ingroup iv - * Structures for OpenMAX IL Video domain - * @{ - */ - -#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 - - -/** - * Enumeration used to define the possible video compression codings. - * NOTE: This essentially refers to file extensions. If the coding is - * being used to specify the ENCODE type, then additional work - * must be done to configure the exact flavor of the compression - * to be used. For decode cases where the user application can - * not differentiate between MPEG-4 and H.264 bit streams, it is - * up to the codec to handle this. - */ -typedef enum OMX_VIDEO_CODINGTYPE { - OMX_VIDEO_CodingUnused, /**< Value when coding is N/A */ - OMX_VIDEO_CodingAutoDetect, /**< Autodetection of coding type */ - OMX_VIDEO_CodingMPEG2, /**< AKA: H.262 */ - OMX_VIDEO_CodingH263, /**< H.263 */ - OMX_VIDEO_CodingMPEG4, /**< MPEG-4 */ - OMX_VIDEO_CodingWMV, /**< all versions of Windows Media Video */ - OMX_VIDEO_CodingRV, /**< all versions of Real Video */ - OMX_VIDEO_CodingAVC, /**< H.264/AVC */ - OMX_VIDEO_CodingMJPEG, /**< Motion JPEG */ - OMX_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_CodingMax = 0x7FFFFFFF -} OMX_VIDEO_CODINGTYPE; - - -/** - * Data structure used to define a video path. The number of Video paths for - * input and output will vary by type of the Video component. - * - * Input (aka Source) : zero Inputs, one Output, - * Splitter : one Input, 2 or more Outputs, - * Processing Element : one Input, one output, - * Mixer : 2 or more inputs, one output, - * Output (aka Sink) : one Input, zero outputs. - * - * The PortDefinition structure is used to define all of the parameters - * necessary for the compliant component to setup an input or an output video - * path. If additional vendor specific data is required, it should be - * transmitted to the component using the CustomCommand function. Compliant - * components will prepopulate this structure with optimal values during the - * GetDefaultInitParams command. - * - * STRUCT MEMBERS: - * cMIMEType : MIME type of data for the port - * pNativeRender : Platform specific reference for a display if a - * sync, otherwise this field is 0 - * nFrameWidth : Width of frame to be used on channel if - * uncompressed format is used. Use 0 for unknown, - * don't care or variable - * nFrameHeight : Height of frame to be used on channel if - * uncompressed format is used. Use 0 for unknown, - * don't care or variable - * nStride : Number of bytes per span of an image - * (i.e. indicates the number of bytes to get - * from span N to span N+1, where negative stride - * indicates the image is bottom up - * nSliceHeight : Height used when encoding in slices - * nBitrate : Bit rate of frame to be used on channel if - * compressed format is used. Use 0 for unknown, - * don't care or variable - * xFramerate : Frame rate to be used on channel if uncompressed - * format is used. Use 0 for unknown, don't care or - * variable. Units are Q16 frames per second. - * bFlagErrorConcealment : Turns on error concealment if it is supported by - * the OMX component - * eCompressionFormat : Compression format used in this instance of the - * component. When OMX_VIDEO_CodingUnused is - * specified, eColorFormat is used - * eColorFormat : Decompressed format used by this component - * pNativeWindow : Platform specific reference for a window object if a - * display sink , otherwise this field is 0x0. - */ -typedef struct OMX_VIDEO_PORTDEFINITIONTYPE { - OMX_STRING cMIMEType; - OMX_NATIVE_DEVICETYPE pNativeRender; - OMX_U32 nFrameWidth; - OMX_U32 nFrameHeight; - OMX_S32 nStride; - OMX_U32 nSliceHeight; - OMX_U32 nBitrate; - OMX_U32 xFramerate; - OMX_BOOL bFlagErrorConcealment; - OMX_VIDEO_CODINGTYPE eCompressionFormat; - OMX_COLOR_FORMATTYPE eColorFormat; - OMX_NATIVE_WINDOWTYPE pNativeWindow; -} OMX_VIDEO_PORTDEFINITIONTYPE; - -/** - * Port format parameter. This structure is used to enumerate the various - * data input/output format supported by the port. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Indicates which port to set - * nIndex : Indicates the enumeration index for the format from - * 0x0 to N-1 - * eCompressionFormat : Compression format used in this instance of the - * component. When OMX_VIDEO_CodingUnused is specified, - * eColorFormat is used - * eColorFormat : Decompressed format used by this component - * xFrameRate : Indicates the video frame rate in Q16 format - */ -typedef struct OMX_VIDEO_PARAM_PORTFORMATTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nIndex; - OMX_VIDEO_CODINGTYPE eCompressionFormat; - OMX_COLOR_FORMATTYPE eColorFormat; - OMX_U32 xFramerate; -} OMX_VIDEO_PARAM_PORTFORMATTYPE; - - -/** - * This is a structure for configuring video compression quantization - * parameter values. Codecs may support different QP values for different - * frame types. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version info - * nPortIndex : Port that this structure applies to - * nQpI : QP value to use for index frames - * nQpP : QP value to use for P frames - * nQpB : QP values to use for bidirectional frames - */ -typedef struct OMX_VIDEO_PARAM_QUANTIZATIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nQpI; - OMX_U32 nQpP; - OMX_U32 nQpB; -} OMX_VIDEO_PARAM_QUANTIZATIONTYPE; - - -/** - * Structure for configuration of video fast update parameters. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version info - * nPortIndex : Port that this structure applies to - * bEnableVFU : Enable/Disable video fast update - * nFirstGOB : Specifies the number of the first macroblock row - * nFirstMB : specifies the first MB relative to the specified first GOB - * nNumMBs : Specifies the number of MBs to be refreshed from nFirstGOB - * and nFirstMB - */ -typedef struct OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnableVFU; - OMX_U32 nFirstGOB; - OMX_U32 nFirstMB; - OMX_U32 nNumMBs; -} OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE; - - -/** - * Enumeration of possible bitrate control types - */ -typedef enum OMX_VIDEO_CONTROLRATETYPE { - OMX_Video_ControlRateDisable, - OMX_Video_ControlRateVariable, - OMX_Video_ControlRateConstant, - OMX_Video_ControlRateVariableSkipFrames, - OMX_Video_ControlRateConstantSkipFrames, - OMX_Video_ControlRateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_Video_ControlRateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_Video_ControlRateMax = 0x7FFFFFFF -} OMX_VIDEO_CONTROLRATETYPE; - - -/** - * Structure for configuring bitrate mode of a codec. - * - * STRUCT MEMBERS: - * nSize : Size of the struct in bytes - * nVersion : OMX spec version info - * nPortIndex : Port that this struct applies to - * eControlRate : Control rate type enum - * nTargetBitrate : Target bitrate to encode with - */ -typedef struct OMX_VIDEO_PARAM_BITRATETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_CONTROLRATETYPE eControlRate; - OMX_U32 nTargetBitrate; -} OMX_VIDEO_PARAM_BITRATETYPE; - - -/** - * Enumeration of possible motion vector (MV) types - */ -typedef enum OMX_VIDEO_MOTIONVECTORTYPE { - OMX_Video_MotionVectorPixel, - OMX_Video_MotionVectorHalfPel, - OMX_Video_MotionVectorQuarterPel, - OMX_Video_MotionVectorEighthPel, - OMX_Video_MotionVectorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_Video_MotionVectorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_Video_MotionVectorMax = 0x7FFFFFFF -} OMX_VIDEO_MOTIONVECTORTYPE; - - -/** - * Structure for configuring the number of motion vectors used as well - * as their accuracy. - * - * STRUCT MEMBERS: - * nSize : Size of the struct in bytes - * nVersion : OMX spec version info - * nPortIndex : port that this structure applies to - * eAccuracy : Enumerated MV accuracy - * bUnrestrictedMVs : Allow unrestricted MVs - * bFourMV : Allow use of 4 MVs - * sXSearchRange : Search range in horizontal direction for MVs - * sYSearchRange : Search range in vertical direction for MVs - */ -typedef struct OMX_VIDEO_PARAM_MOTIONVECTORTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_MOTIONVECTORTYPE eAccuracy; - OMX_BOOL bUnrestrictedMVs; - OMX_BOOL bFourMV; - OMX_S32 sXSearchRange; - OMX_S32 sYSearchRange; -} OMX_VIDEO_PARAM_MOTIONVECTORTYPE; - - -/** - * Enumeration of possible methods to use for Intra Refresh - */ -typedef enum OMX_VIDEO_INTRAREFRESHTYPE { - OMX_VIDEO_IntraRefreshCyclic, - OMX_VIDEO_IntraRefreshAdaptive, - OMX_VIDEO_IntraRefreshBoth, - OMX_VIDEO_IntraRefreshKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_IntraRefreshVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_IntraRefreshMax = 0x7FFFFFFF -} OMX_VIDEO_INTRAREFRESHTYPE; - - -/** - * Structure for configuring intra refresh mode - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eRefreshMode : Cyclic, Adaptive, or Both - * nAirMBs : Number of intra macroblocks to refresh in a frame when - * AIR is enabled - * nAirRef : Number of times a motion marked macroblock has to be - * intra coded - * nCirMBs : Number of consecutive macroblocks to be coded as "intra" - * when CIR is enabled - */ -typedef struct OMX_VIDEO_PARAM_INTRAREFRESHTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_INTRAREFRESHTYPE eRefreshMode; - OMX_U32 nAirMBs; - OMX_U32 nAirRef; - OMX_U32 nCirMBs; -} OMX_VIDEO_PARAM_INTRAREFRESHTYPE; - - -/** - * Structure for enabling various error correction methods for video - * compression. - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * bEnableHEC : Enable/disable header extension codes (HEC) - * bEnableResync : Enable/disable resynchronization markers - * nResynchMarkerSpacing : Resynch markers interval (in bits) to be - * applied in the stream - * bEnableDataPartitioning : Enable/disable data partitioning - * bEnableRVLC : Enable/disable reversible variable length - * coding - */ -typedef struct OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnableHEC; - OMX_BOOL bEnableResync; - OMX_U32 nResynchMarkerSpacing; - OMX_BOOL bEnableDataPartitioning; - OMX_BOOL bEnableRVLC; -} OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE; - - -/** - * Configuration of variable block-size motion compensation (VBSMC) - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * b16x16 : Enable inter block search 16x16 - * b16x8 : Enable inter block search 16x8 - * b8x16 : Enable inter block search 8x16 - * b8x8 : Enable inter block search 8x8 - * b8x4 : Enable inter block search 8x4 - * b4x8 : Enable inter block search 4x8 - * b4x4 : Enable inter block search 4x4 - */ -typedef struct OMX_VIDEO_PARAM_VBSMCTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL b16x16; - OMX_BOOL b16x8; - OMX_BOOL b8x16; - OMX_BOOL b8x8; - OMX_BOOL b8x4; - OMX_BOOL b4x8; - OMX_BOOL b4x4; -} OMX_VIDEO_PARAM_VBSMCTYPE; - - -/** - * H.263 profile types, each profile indicates support for various - * performance bounds and different annexes. - * - * ENUMS: - * Baseline : Baseline Profile: H.263 (V1), no optional modes - * H320 Coding : H.320 Coding Efficiency Backward Compatibility - * Profile: H.263+ (V2), includes annexes I, J, L.4 - * and T - * BackwardCompatible : Backward Compatibility Profile: H.263 (V1), - * includes annex F - * ISWV2 : Interactive Streaming Wireless Profile: H.263+ - * (V2), includes annexes I, J, K and T - * ISWV3 : Interactive Streaming Wireless Profile: H.263++ - * (V3), includes profile 3 and annexes V and W.6.3.8 - * HighCompression : Conversational High Compression Profile: H.263++ - * (V3), includes profiles 1 & 2 and annexes D and U - * Internet : Conversational Internet Profile: H.263++ (V3), - * includes profile 5 and annex K - * Interlace : Conversational Interlace Profile: H.263++ (V3), - * includes profile 5 and annex W.6.3.11 - * HighLatency : High Latency Profile: H.263++ (V3), includes - * profile 6 and annexes O.1 and P.5 - */ -typedef enum OMX_VIDEO_H263PROFILETYPE { - OMX_VIDEO_H263ProfileBaseline = 0x01, - OMX_VIDEO_H263ProfileH320Coding = 0x02, - OMX_VIDEO_H263ProfileBackwardCompatible = 0x04, - OMX_VIDEO_H263ProfileISWV2 = 0x08, - OMX_VIDEO_H263ProfileISWV3 = 0x10, - OMX_VIDEO_H263ProfileHighCompression = 0x20, - OMX_VIDEO_H263ProfileInternet = 0x40, - OMX_VIDEO_H263ProfileInterlace = 0x80, - OMX_VIDEO_H263ProfileHighLatency = 0x100, - OMX_VIDEO_H263ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_H263ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_H263ProfileMax = 0x7FFFFFFF -} OMX_VIDEO_H263PROFILETYPE; - - -/** - * H.263 level types, each level indicates support for various frame sizes, - * bit rates, decoder frame rates. - */ -typedef enum OMX_VIDEO_H263LEVELTYPE { - OMX_VIDEO_H263Level10 = 0x01, - OMX_VIDEO_H263Level20 = 0x02, - OMX_VIDEO_H263Level30 = 0x04, - OMX_VIDEO_H263Level40 = 0x08, - OMX_VIDEO_H263Level45 = 0x10, - OMX_VIDEO_H263Level50 = 0x20, - OMX_VIDEO_H263Level60 = 0x40, - OMX_VIDEO_H263Level70 = 0x80, - OMX_VIDEO_H263LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_H263LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_H263LevelMax = 0x7FFFFFFF -} OMX_VIDEO_H263LEVELTYPE; - - -/** - * Specifies the picture type. These values should be OR'd to signal all - * pictures types which are allowed. - * - * ENUMS: - * Generic Picture Types: I, P and B - * H.263 Specific Picture Types: SI and SP - * H.264 Specific Picture Types: EI and EP - * MPEG-4 Specific Picture Types: S - */ -typedef enum OMX_VIDEO_PICTURETYPE { - OMX_VIDEO_PictureTypeI = 0x01, - OMX_VIDEO_PictureTypeP = 0x02, - OMX_VIDEO_PictureTypeB = 0x04, - OMX_VIDEO_PictureTypeSI = 0x08, - OMX_VIDEO_PictureTypeSP = 0x10, - OMX_VIDEO_PictureTypeEI = 0x11, - OMX_VIDEO_PictureTypeEP = 0x12, - OMX_VIDEO_PictureTypeS = 0x14, - OMX_VIDEO_PictureTypeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_PictureTypeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_PictureTypeMax = 0x7FFFFFFF -} OMX_VIDEO_PICTURETYPE; - - -/** - * H.263 Params - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nPFrames : Number of P frames between each I frame - * nBFrames : Number of B frames between each I frame - * eProfile : H.263 profile(s) to use - * eLevel : H.263 level(s) to use - * bPLUSPTYPEAllowed : Indicating that it is allowed to use PLUSPTYPE - * (specified in the 1998 version of H.263) to - * indicate custom picture sizes or clock - * frequencies - * nAllowedPictureTypes : Specifies the picture types allowed in the - * bitstream - * bForceRoundingTypeToZero : value of the RTYPE bit (bit 6 of MPPTYPE) is - * not constrained. It is recommended to change - * the value of the RTYPE bit for each reference - * picture in error-free communication - * nPictureHeaderRepetition : Specifies the frequency of picture header - * repetition - * nGOBHeaderInterval : Specifies the interval of non-empty GOB - * headers in units of GOBs - */ -typedef struct OMX_VIDEO_PARAM_H263TYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nPFrames; - OMX_U32 nBFrames; - OMX_VIDEO_H263PROFILETYPE eProfile; - OMX_VIDEO_H263LEVELTYPE eLevel; - OMX_BOOL bPLUSPTYPEAllowed; - OMX_U32 nAllowedPictureTypes; - OMX_BOOL bForceRoundingTypeToZero; - OMX_U32 nPictureHeaderRepetition; - OMX_U32 nGOBHeaderInterval; -} OMX_VIDEO_PARAM_H263TYPE; - - -/** - * MPEG-2 profile types, each profile indicates support for various - * performance bounds and different annexes. - */ -typedef enum OMX_VIDEO_MPEG2PROFILETYPE { - OMX_VIDEO_MPEG2ProfileSimple = 0, /**< Simple Profile */ - OMX_VIDEO_MPEG2ProfileMain, /**< Main Profile */ - OMX_VIDEO_MPEG2Profile422, /**< 4:2:2 Profile */ - OMX_VIDEO_MPEG2ProfileSNR, /**< SNR Profile */ - OMX_VIDEO_MPEG2ProfileSpatial, /**< Spatial Profile */ - OMX_VIDEO_MPEG2ProfileHigh, /**< High Profile */ - OMX_VIDEO_MPEG2ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_MPEG2ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_MPEG2ProfileMax = 0x7FFFFFFF -} OMX_VIDEO_MPEG2PROFILETYPE; - - -/** - * MPEG-2 level types, each level indicates support for various frame - * sizes, bit rates, decoder frame rates. No need - */ -typedef enum OMX_VIDEO_MPEG2LEVELTYPE { - OMX_VIDEO_MPEG2LevelLL = 0, /**< Low Level */ - OMX_VIDEO_MPEG2LevelML, /**< Main Level */ - OMX_VIDEO_MPEG2LevelH14, /**< High 1440 */ - OMX_VIDEO_MPEG2LevelHL, /**< High Level */ - OMX_VIDEO_MPEG2LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_MPEG2LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_MPEG2LevelMax = 0x7FFFFFFF -} OMX_VIDEO_MPEG2LEVELTYPE; - - -/** - * MPEG-2 params - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nPFrames : Number of P frames between each I frame - * nBFrames : Number of B frames between each I frame - * eProfile : MPEG-2 profile(s) to use - * eLevel : MPEG-2 levels(s) to use - */ -typedef struct OMX_VIDEO_PARAM_MPEG2TYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nPFrames; - OMX_U32 nBFrames; - OMX_VIDEO_MPEG2PROFILETYPE eProfile; - OMX_VIDEO_MPEG2LEVELTYPE eLevel; -} OMX_VIDEO_PARAM_MPEG2TYPE; - - -/** - * MPEG-4 profile types, each profile indicates support for various - * performance bounds and different annexes. - * - * ENUMS: - * - Simple Profile, Levels 1-3 - * - Simple Scalable Profile, Levels 1-2 - * - Core Profile, Levels 1-2 - * - Main Profile, Levels 2-4 - * - N-bit Profile, Level 2 - * - Scalable Texture Profile, Level 1 - * - Simple Face Animation Profile, Levels 1-2 - * - Simple Face and Body Animation (FBA) Profile, Levels 1-2 - * - Basic Animated Texture Profile, Levels 1-2 - * - Hybrid Profile, Levels 1-2 - * - Advanced Real Time Simple Profiles, Levels 1-4 - * - Core Scalable Profile, Levels 1-3 - * - Advanced Coding Efficiency Profile, Levels 1-4 - * - Advanced Core Profile, Levels 1-2 - * - Advanced Scalable Texture, Levels 2-3 - */ -typedef enum OMX_VIDEO_MPEG4PROFILETYPE { - OMX_VIDEO_MPEG4ProfileSimple = 0x01, - OMX_VIDEO_MPEG4ProfileSimpleScalable = 0x02, - OMX_VIDEO_MPEG4ProfileCore = 0x04, - OMX_VIDEO_MPEG4ProfileMain = 0x08, - OMX_VIDEO_MPEG4ProfileNbit = 0x10, - OMX_VIDEO_MPEG4ProfileScalableTexture = 0x20, - OMX_VIDEO_MPEG4ProfileSimpleFace = 0x40, - OMX_VIDEO_MPEG4ProfileSimpleFBA = 0x80, - OMX_VIDEO_MPEG4ProfileBasicAnimated = 0x100, - OMX_VIDEO_MPEG4ProfileHybrid = 0x200, - OMX_VIDEO_MPEG4ProfileAdvancedRealTime = 0x400, - OMX_VIDEO_MPEG4ProfileCoreScalable = 0x800, - OMX_VIDEO_MPEG4ProfileAdvancedCoding = 0x1000, - OMX_VIDEO_MPEG4ProfileAdvancedCore = 0x2000, - OMX_VIDEO_MPEG4ProfileAdvancedScalable = 0x4000, - OMX_VIDEO_MPEG4ProfileAdvancedSimple = 0x8000, - OMX_VIDEO_MPEG4ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_MPEG4ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_MPEG4ProfileMax = 0x7FFFFFFF -} OMX_VIDEO_MPEG4PROFILETYPE; - - -/** - * MPEG-4 level types, each level indicates support for various frame - * sizes, bit rates, decoder frame rates. No need - */ -typedef enum OMX_VIDEO_MPEG4LEVELTYPE { - OMX_VIDEO_MPEG4Level0 = 0x01, /**< Level 0 */ - OMX_VIDEO_MPEG4Level0b = 0x02, /**< Level 0b */ - OMX_VIDEO_MPEG4Level1 = 0x04, /**< Level 1 */ - OMX_VIDEO_MPEG4Level2 = 0x08, /**< Level 2 */ - OMX_VIDEO_MPEG4Level3 = 0x10, /**< Level 3 */ - OMX_VIDEO_MPEG4Level4 = 0x20, /**< Level 4 */ - OMX_VIDEO_MPEG4Level4a = 0x40, /**< Level 4a */ - OMX_VIDEO_MPEG4Level5 = 0x80, /**< Level 5 */ - OMX_VIDEO_MPEG4LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_MPEG4LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_MPEG4LevelMax = 0x7FFFFFFF -} OMX_VIDEO_MPEG4LEVELTYPE; - - -/** - * MPEG-4 configuration. This structure handles configuration options - * which are specific to MPEG4 algorithms - * - * 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 (H263+ - * Annex K). Put zero if not used - * bSVH : Enable Short Video Header mode - * bGov : Flag to enable GOV - * nPFrames : Number of P frames between each I frame (also called - * GOV period) - * nBFrames : Number of B frames between each I frame - * nIDCVLCThreshold : Value of intra DC VLC threshold - * bACPred : Flag to use ac prediction - * nMaxPacketSize : Maximum size of packet in bytes. - * nTimeIncRes : Used to pass VOP time increment resolution for MPEG4. - * Interpreted as described in MPEG4 standard. - * eProfile : MPEG-4 profile(s) to use. - * eLevel : MPEG-4 level(s) to use. - * nAllowedPictureTypes : Specifies the picture types allowed in the bitstream - * nHeaderExtension : Specifies the number of consecutive video packet - * headers within a VOP - * bReversibleVLC : Specifies whether reversible variable length coding - * is in use - */ -typedef struct OMX_VIDEO_PARAM_MPEG4TYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nSliceHeaderSpacing; - OMX_BOOL bSVH; - OMX_BOOL bGov; - OMX_U32 nPFrames; - OMX_U32 nBFrames; - OMX_U32 nIDCVLCThreshold; - OMX_BOOL bACPred; - OMX_U32 nMaxPacketSize; - OMX_U32 nTimeIncRes; - OMX_VIDEO_MPEG4PROFILETYPE eProfile; - OMX_VIDEO_MPEG4LEVELTYPE eLevel; - OMX_U32 nAllowedPictureTypes; - OMX_U32 nHeaderExtension; - OMX_BOOL bReversibleVLC; -} OMX_VIDEO_PARAM_MPEG4TYPE; - - -/** - * WMV Versions - */ -typedef enum OMX_VIDEO_WMVFORMATTYPE { - OMX_VIDEO_WMVFormatUnused = 0x01, /**< Format unused or unknown */ - OMX_VIDEO_WMVFormat7 = 0x02, /**< Windows Media Video format 7 */ - OMX_VIDEO_WMVFormat8 = 0x04, /**< Windows Media Video format 8 */ - OMX_VIDEO_WMVFormat9 = 0x08, /**< Windows Media Video format 9 */ - OMX_VIDEO_WMFFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_WMFFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_WMVFormatMax = 0x7FFFFFFF -} OMX_VIDEO_WMVFORMATTYPE; - - -/** - * WMV Params - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eFormat : Version of WMV stream / data - */ -typedef struct OMX_VIDEO_PARAM_WMVTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_WMVFORMATTYPE eFormat; -} OMX_VIDEO_PARAM_WMVTYPE; - - -/** - * Real Video Version - */ -typedef enum OMX_VIDEO_RVFORMATTYPE { - OMX_VIDEO_RVFormatUnused = 0, /**< Format unused or unknown */ - OMX_VIDEO_RVFormat8, /**< Real Video format 8 */ - OMX_VIDEO_RVFormat9, /**< Real Video format 9 */ - OMX_VIDEO_RVFormatG2, /**< Real Video Format G2 */ - OMX_VIDEO_RVFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_RVFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_RVFormatMax = 0x7FFFFFFF -} OMX_VIDEO_RVFORMATTYPE; - - -/** - * Real Video Params - * - * STUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * eFormat : Version of RV stream / data - * nBitsPerPixel : Bits per pixel coded in the frame - * nPaddedWidth : Padded width in pixel of a video frame - * nPaddedHeight : Padded Height in pixels of a video frame - * nFrameRate : Rate of video in frames per second - * nBitstreamFlags : Flags which internal information about the bitstream - * nBitstreamVersion : Bitstream version - * nMaxEncodeFrameSize: Max encoded frame size - * bEnablePostFilter : Turn on/off post filter - * bEnableTemporalInterpolation : Turn on/off temporal interpolation - * bEnableLatencyMode : When enabled, the decoder does not display a decoded - * frame until it has detected that no enhancement layer - * frames or dependent B frames will be coming. This - * detection usually occurs when a subsequent non-B - * frame is encountered - */ -typedef struct OMX_VIDEO_PARAM_RVTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_VIDEO_RVFORMATTYPE eFormat; - OMX_U16 nBitsPerPixel; - OMX_U16 nPaddedWidth; - OMX_U16 nPaddedHeight; - OMX_U32 nFrameRate; - OMX_U32 nBitstreamFlags; - OMX_U32 nBitstreamVersion; - OMX_U32 nMaxEncodeFrameSize; - OMX_BOOL bEnablePostFilter; - OMX_BOOL bEnableTemporalInterpolation; - OMX_BOOL bEnableLatencyMode; -} OMX_VIDEO_PARAM_RVTYPE; - - -/** - * AVC profile types, each profile indicates support for various - * performance bounds and different annexes. - */ -typedef enum OMX_VIDEO_AVCPROFILETYPE { - OMX_VIDEO_AVCProfileBaseline = 0x01, /**< Baseline profile */ - OMX_VIDEO_AVCProfileMain = 0x02, /**< Main profile */ - OMX_VIDEO_AVCProfileExtended = 0x04, /**< Extended profile */ - OMX_VIDEO_AVCProfileHigh = 0x08, /**< High profile */ - OMX_VIDEO_AVCProfileHigh10 = 0x10, /**< High 10 profile */ - OMX_VIDEO_AVCProfileHigh422 = 0x20, /**< High 4:2:2 profile */ - OMX_VIDEO_AVCProfileHigh444 = 0x40, /**< High 4:4:4 profile */ - OMX_VIDEO_AVCProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_AVCProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_AVCProfileMax = 0x7FFFFFFF -} OMX_VIDEO_AVCPROFILETYPE; - - -/** - * AVC level types, each level indicates support for various frame sizes, - * bit rates, decoder frame rates. No need - */ -typedef enum OMX_VIDEO_AVCLEVELTYPE { - OMX_VIDEO_AVCLevel1 = 0x01, /**< Level 1 */ - OMX_VIDEO_AVCLevel1b = 0x02, /**< Level 1b */ - OMX_VIDEO_AVCLevel11 = 0x04, /**< Level 1.1 */ - OMX_VIDEO_AVCLevel12 = 0x08, /**< Level 1.2 */ - OMX_VIDEO_AVCLevel13 = 0x10, /**< Level 1.3 */ - OMX_VIDEO_AVCLevel2 = 0x20, /**< Level 2 */ - OMX_VIDEO_AVCLevel21 = 0x40, /**< Level 2.1 */ - OMX_VIDEO_AVCLevel22 = 0x80, /**< Level 2.2 */ - OMX_VIDEO_AVCLevel3 = 0x100, /**< Level 3 */ - OMX_VIDEO_AVCLevel31 = 0x200, /**< Level 3.1 */ - OMX_VIDEO_AVCLevel32 = 0x400, /**< Level 3.2 */ - OMX_VIDEO_AVCLevel4 = 0x800, /**< Level 4 */ - OMX_VIDEO_AVCLevel41 = 0x1000, /**< Level 4.1 */ - OMX_VIDEO_AVCLevel42 = 0x2000, /**< Level 4.2 */ - OMX_VIDEO_AVCLevel5 = 0x4000, /**< Level 5 */ - OMX_VIDEO_AVCLevel51 = 0x8000, /**< Level 5.1 */ - OMX_VIDEO_AVCLevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_AVCLevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_AVCLevelMax = 0x7FFFFFFF -} OMX_VIDEO_AVCLEVELTYPE; - - -/** - * AVC loop filter modes - * - * OMX_VIDEO_AVCLoopFilterEnable : Enable - * OMX_VIDEO_AVCLoopFilterDisable : Disable - * OMX_VIDEO_AVCLoopFilterDisableSliceBoundary : Disabled on slice boundaries - */ -typedef enum OMX_VIDEO_AVCLOOPFILTERTYPE { - OMX_VIDEO_AVCLoopFilterEnable = 0, - OMX_VIDEO_AVCLoopFilterDisable, - OMX_VIDEO_AVCLoopFilterDisableSliceBoundary, - OMX_VIDEO_AVCLoopFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_AVCLoopFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_AVCLoopFilterMax = 0x7FFFFFFF -} OMX_VIDEO_AVCLOOPFILTERTYPE; - - -/** - * AVC 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_VIDEO_PARAM_AVCTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nSliceHeaderSpacing; - OMX_U32 nPFrames; - OMX_U32 nBFrames; - OMX_BOOL bUseHadamard; - OMX_U32 nRefFrames; - OMX_U32 nRefIdx10ActiveMinus1; - OMX_U32 nRefIdx11ActiveMinus1; - OMX_BOOL bEnableUEP; - OMX_BOOL bEnableFMO; - OMX_BOOL bEnableASO; - OMX_BOOL bEnableRS; - OMX_VIDEO_AVCPROFILETYPE eProfile; - OMX_VIDEO_AVCLEVELTYPE eLevel; - 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_AVCLOOPFILTERTYPE eLoopFilterMode; -} OMX_VIDEO_PARAM_AVCTYPE; - -typedef struct OMX_VIDEO_PARAM_PROFILELEVELTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 eProfile; /**< type is OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263PROFILETYPE, - or OMX_VIDEO_MPEG4PROFILETYPE depending on context */ - OMX_U32 eLevel; /**< type is OMX_VIDEO_AVCLEVELTYPE, OMX_VIDEO_H263LEVELTYPE, - or OMX_VIDEO_MPEG4PROFILETYPE depending on context */ - OMX_U32 nProfileIndex; /**< Used to query for individual profile support information, - This parameter is valid only for - OMX_IndexParamVideoProfileLevelQuerySupported index, - For all other indices this parameter is to be ignored. */ -} OMX_VIDEO_PARAM_PROFILELEVELTYPE; - -/** - * Structure for dynamically configuring bitrate mode of a codec. - * - * STRUCT MEMBERS: - * nSize : Size of the struct in bytes - * nVersion : OMX spec version info - * nPortIndex : Port that this struct applies to - * nEncodeBitrate : Target average bitrate to be generated in bps - */ -typedef struct OMX_VIDEO_CONFIG_BITRATETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nEncodeBitrate; -} OMX_VIDEO_CONFIG_BITRATETYPE; - -/** - * Defines Encoder Frame Rate setting - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * xEncodeFramerate : Encoding framerate represented in Q16 format - */ -typedef struct OMX_CONFIG_FRAMERATETYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 xEncodeFramerate; /* Q16 format */ -} OMX_CONFIG_FRAMERATETYPE; - -typedef struct OMX_CONFIG_INTRAREFRESHVOPTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL IntraRefreshVOP; -} OMX_CONFIG_INTRAREFRESHVOPTYPE; - -typedef struct OMX_CONFIG_MACROBLOCKERRORMAPTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nErrMapSize; /* Size of the Error Map in bytes */ - OMX_U8 ErrMap[1]; /* Error map hint */ -} OMX_CONFIG_MACROBLOCKERRORMAPTYPE; - -typedef struct OMX_CONFIG_MBERRORREPORTINGTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnabled; -} OMX_CONFIG_MBERRORREPORTINGTYPE; - -typedef struct OMX_PARAM_MACROBLOCKSTYPE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nMacroblocks; -} OMX_PARAM_MACROBLOCKSTYPE; - -/** - * AVC Slice Mode modes - * - * OMX_VIDEO_SLICEMODE_AVCDefault : Normal frame encoding, one slice per frame - * OMX_VIDEO_SLICEMODE_AVCMBSlice : NAL mode, number of MBs per frame - * OMX_VIDEO_SLICEMODE_AVCByteSlice : NAL mode, number of bytes per frame - */ -typedef enum OMX_VIDEO_AVCSLICEMODETYPE { - OMX_VIDEO_SLICEMODE_AVCDefault = 0, - OMX_VIDEO_SLICEMODE_AVCMBSlice, - OMX_VIDEO_SLICEMODE_AVCByteSlice, - OMX_VIDEO_SLICEMODE_AVCKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ - OMX_VIDEO_SLICEMODE_AVCVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ - OMX_VIDEO_SLICEMODE_AVCLevelMax = 0x7FFFFFFF -} OMX_VIDEO_AVCSLICEMODETYPE; - -/** - * AVC FMO Slice Mode Params - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nNumSliceGroups : Specifies the number of slice groups - * nSliceGroupMapType : Specifies the type of slice groups - * eSliceMode : Specifies the type of slice - */ -typedef struct OMX_VIDEO_PARAM_AVCSLICEFMO { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U8 nNumSliceGroups; - OMX_U8 nSliceGroupMapType; - OMX_VIDEO_AVCSLICEMODETYPE eSliceMode; -} OMX_VIDEO_PARAM_AVCSLICEFMO; - -/** - * AVC IDR Period Configs - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nIDRPeriod : Specifies periodicity of IDR frames - * nPFrames : Specifies internal of coding Intra frames - */ -typedef struct OMX_VIDEO_CONFIG_AVCINTRAPERIOD { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nIDRPeriod; - OMX_U32 nPFrames; -} OMX_VIDEO_CONFIG_AVCINTRAPERIOD; - -/** - * AVC NAL Size Configs - * - * STRUCT MEMBERS: - * nSize : Size of the structure in bytes - * nVersion : OMX specification version information - * nPortIndex : Port that this structure applies to - * nNaluBytes : Specifies the NAL unit size - */ -typedef struct OMX_VIDEO_CONFIG_NALSIZE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nNaluBytes; -} OMX_VIDEO_CONFIG_NALSIZE; - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -/* File EOF */ - diff --git a/aries/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h b/aries/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h deleted file mode 100644 index 10dd94d..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Def.h - * @brief SEC_OMX specific define - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_DEF -#define SEC_OMX_DEF - -#include "OMX_Types.h" -#include "OMX_IVCommon.h" - -#define VERSIONMAJOR_NUMBER 1 -#define VERSIONMINOR_NUMBER 0 -#define REVISION_NUMBER 0 -#define STEP_NUMBER 0 - - -#define MAX_OMX_COMPONENT_NUM 20 -#define MAX_OMX_COMPONENT_ROLE_NUM 10 -#define MAX_OMX_COMPONENT_NAME_SIZE OMX_MAX_STRINGNAME_SIZE -#define MAX_OMX_COMPONENT_ROLE_SIZE OMX_MAX_STRINGNAME_SIZE -#define MAX_OMX_COMPONENT_LIBNAME_SIZE OMX_MAX_STRINGNAME_SIZE * 2 -#define MAX_OMX_MIMETYPE_SIZE OMX_MAX_STRINGNAME_SIZE - -#define MAX_TIMESTAMP 16 -#define MAX_FLAGS 16 - - -typedef enum _SEC_CODEC_TYPE -{ - SW_CODEC, - HW_VIDEO_CODEC, - HW_AUDIO_CODEC -} SEC_CODEC_TYPE; - -typedef struct _SEC_OMX_PRIORITYMGMTTYPE -{ - OMX_U32 nGroupPriority; /* the value 0 represents the highest priority */ - /* for a group of components */ - OMX_U32 nGroupID; -} SEC_OMX_PRIORITYMGMTTYPE; - -typedef enum _SEC_OMX_INDEXTYPE -{ - OMX_IndexVendorThumbnailMode = 0x7F000001, - OMX_COMPONENT_CAPABILITY_TYPE_INDEX = 0xFF7A347 /*for Android*/ -} SEC_OMX_INDEXTYPE; - -typedef enum _SEC_OMX_ERRORTYPE -{ - OMX_ErrorNoEOF = 0x90000001, - OMX_ErrorInputDataDecodeYet, - OMX_ErrorInputDataEncodeYet, - OMX_ErrorMFCInit -} SEC_OMX_ERRORTYPE; - -typedef enum _SEC_OMX_COMMANDTYPE -{ - SEC_OMX_CommandComponentDeInit = 0x7F000001, - SEC_OMX_CommandEmptyBuffer, - SEC_OMX_CommandFillBuffer -} SEC_OMX_COMMANDTYPE; - -typedef enum _SEC_OMX_TRANS_STATETYPE { - SEC_OMX_TransStateInvalid, - SEC_OMX_TransStateLoadedToIdle, - SEC_OMX_TransStateIdleToExecuting, - SEC_OMX_TransStateExecutingToIdle, - SEC_OMX_TransStateIdleToLoaded, - SEC_OMX_TransStateMax = 0X7FFFFFFF -} SEC_OMX_TRANS_STATETYPE; - -typedef enum _SEC_OMX_COLOR_FORMATTYPE { -#ifndef USE_SAMSUNG_COLORFORMAT - SEC_OMX_COLOR_FormatNV12PhysicalAddress = OMX_COLOR_FormatYUV420SemiPlanar -#else - SEC_OMX_COLOR_FormatNV12PhysicalAddress = 0x7F000001 /**< Reserved region for introducing Vendor Extensions */ -#endif -}SEC_OMX_COLOR_FORMATTYPE; - -typedef enum _SEC_OMX_SUPPORTFORMAT_TYPE -{ - supportFormat_1 = 0x00, - supportFormat_2, - supportFormat_3, - supportFormat_4 -} SEC_OMX_SUPPORTFORMAT_TYPE; - - -/* for Android */ -typedef struct _OMXComponentCapabilityFlagsType -{ - /* OMX COMPONENT CAPABILITY RELATED MEMBERS */ - OMX_BOOL iIsOMXComponentMultiThreaded; - OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc; - OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc; - OMX_BOOL iOMXComponentSupportsMovableInputBuffers; - OMX_BOOL iOMXComponentSupportsPartialFrames; - OMX_BOOL iOMXComponentUsesNALStartCodes; - OMX_BOOL iOMXComponentCanHandleIncompleteFrames; - OMX_BOOL iOMXComponentUsesFullAVCFrames; -} OMXComponentCapabilityFlagsType; - -typedef struct _SEC_OMX_VIDEO_PROFILELEVEL -{ - OMX_S32 profile; - OMX_S32 level; -} SEC_OMX_VIDEO_PROFILELEVEL; - - -#ifndef __OMX_EXPORTS -#define __OMX_EXPORTS -#define SEC_EXPORT_REF __attribute__((visibility("default"))) -#define SEC_IMPORT_REF __attribute__((visibility("default"))) -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h b/aries/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h deleted file mode 100644 index b3bfda6..0000000 --- a/aries/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OMX_Macros.h - * @brief Macros - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OMX_MACROS -#define SEC_OMX_MACROS - -#include "SEC_OMX_Def.h" -#include "SEC_OSAL_Memory.h" - - -/* - * MACROS - */ -#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5) -#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7) -#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13) - -#define INIT_SET_SIZE_VERSION(_struct_, _structType_) \ - do { \ - SEC_OSAL_Memset((_struct_), 0, sizeof(_structType_)); \ - (_struct_)->nSize = sizeof(_structType_); \ - (_struct_)->nVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; \ - (_struct_)->nVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; \ - (_struct_)->nVersion.s.nRevision = REVISION_NUMBER; \ - (_struct_)->nVersion.s.nStep = STEP_NUMBER; \ - } while (0) - -/* - * Port Specific - */ -#define SEC_TUNNEL_ESTABLISHED 0x0001 -#define SEC_TUNNEL_IS_SUPPLIER 0x0002 - -#define CHECK_PORT_BEING_FLUSHED(port) (port->bIsPortFlushed == OMX_TRUE) -#define CHECK_PORT_BEING_DISABLED(port) (port->bIsPortDisabled == OMX_TRUE) -#define CHECK_PORT_ENABLED(port) (port->portDefinition.bEnabled == OMX_TRUE) -#define CHECK_PORT_POPULATED(port) (port->portDefinition.bPopulated == OMX_TRUE) -#define CHECK_PORT_TUNNELED(port) (port->tunnelFlags & SEC_TUNNEL_ESTABLISHED) -#define CHECK_PORT_BUFFER_SUPPLIER(port) (port->tunnelFlags & SEC_TUNNEL_IS_SUPPLIER) - -#endif diff --git a/aries/sec_mm/sec_omx/sec_osal/Android.mk b/aries/sec_mm/sec_omx/sec_osal/Android.mk deleted file mode 100644 index b474876..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := optional - -LOCAL_SRC_FILES := \ - SEC_OSAL_Event.c \ - SEC_OSAL_Queue.c \ - SEC_OSAL_ETC.c \ - SEC_OSAL_Mutex.c \ - SEC_OSAL_Thread.c \ - SEC_OSAL_Memory.c \ - SEC_OSAL_Semaphore.c \ - SEC_OSAL_Library.c \ - SEC_OSAL_Log.c - -LOCAL_PRELINK_MODULE := false -LOCAL_MODULE := libsecosal.aries - -LOCAL_CFLAGS := - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libcutils libutils - -LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ - $(SEC_OMX_INC)/sec \ - $(SEC_OMX_TOP)/sec_osal - -include $(BUILD_STATIC_LIBRARY) diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.c b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.c deleted file mode 100644 index 66f8355..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_ETC.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include - -#include "SEC_OSAL_Memory.h" -#include "SEC_OSAL_ETC.h" - - -#ifndef HAVE_GETLINE -ssize_t getline(char **ppLine, size_t *pLen, FILE *pStream) -{ - char *pCurrentPointer = NULL; - size_t const chunk = 512; - - size_t defaultBufferSize = chunk + 1; - size_t retSize = 0; - - if (*ppLine == NULL) { - *ppLine = (char *)malloc(defaultBufferSize); - if (*ppLine == NULL) { - retSize = -1; - goto EXIT; - } - *pLen = defaultBufferSize; - } - else { - if (*pLen < defaultBufferSize) { - *ppLine = (char *)realloc(*ppLine, defaultBufferSize); - if (*ppLine == NULL) { - retSize = -1; - goto EXIT; - } - *pLen = defaultBufferSize; - } - } - - while (1) { - size_t i; - size_t j = 0; - size_t readByte = 0; - - pCurrentPointer = *ppLine + readByte; - - i = fread(pCurrentPointer, 1, chunk, pStream); - if (i < chunk && ferror(pStream)) { - retSize = -1; - goto EXIT; - } - while (j < i) { - ++j; - if (*pCurrentPointer++ == (char)'\n') { - *pCurrentPointer = '\0'; - if (j != i) { - if (fseek(pStream, j - i, SEEK_CUR)) { - retSize = -1; - goto EXIT; - } - if (feof(pStream)) - clearerr(pStream); - } - readByte += j; - retSize = readByte; - goto EXIT; - } - } - - readByte += j; - if (feof(pStream)) { - if (readByte) { - retSize = readByte; - goto EXIT; - } - if (!i) { - retSize = -1; - goto EXIT; - } - } - - i = ((readByte + (chunk * 2)) / chunk) * chunk; - if (i != *pLen) { - *ppLine = (char *)realloc(*ppLine, i); - if (*ppLine == NULL) { - retSize = -1; - goto EXIT; - } - *pLen = i; - } - } - -EXIT: - return retSize; -} -#endif /* HAVE_GETLINE */ - -OMX_PTR SEC_OSAL_Strcpy(OMX_PTR dest, OMX_PTR src) -{ - return strcpy(dest, src); -} - -OMX_PTR SEC_OSAL_Strncpy(OMX_PTR dest, OMX_PTR src, size_t num) -{ - return strncpy(dest, src, num); -} - -OMX_S32 SEC_OSAL_Strcmp(OMX_PTR str1, OMX_PTR str2) -{ - return strcmp(str1, str2); -} - -OMX_PTR SEC_OSAL_Strcat(OMX_PTR dest, OMX_PTR src) -{ - return strcat(dest, src); -} - -size_t SEC_OSAL_Strlen(const char *str) -{ - return strlen(str); -} diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.h b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.h deleted file mode 100644 index 6c6ede7..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_ETC.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OSAL_ETC -#define SEC_OSAL_ETC - -#include "OMX_Types.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -OMX_PTR SEC_OSAL_Strcpy(OMX_PTR dest, OMX_PTR src); -OMX_PTR SEC_OSAL_Strncpy(OMX_PTR dest, OMX_PTR src, size_t num); -OMX_S32 SEC_OSAL_Strcmp(OMX_PTR str1, OMX_PTR str2); -OMX_PTR SEC_OSAL_Strcat(OMX_PTR dest, OMX_PTR src); -size_t SEC_OSAL_Strlen(const char *str); -ssize_t getline(char **ppLine, size_t *len, FILE *stream); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.c b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.c deleted file mode 100644 index 51b3ca2..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Event.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - - -#include -#include -#include -#include -#include - -#include "SEC_OSAL_Memory.h" -#include "SEC_OSAL_Mutex.h" -#include "SEC_OSAL_Event.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_OSAL_EVENT" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -OMX_ERRORTYPE SEC_OSAL_SignalCreate(OMX_HANDLETYPE *eventHandle) -{ - SEC_OSAL_THREADEVENT *event; - OMX_ERRORTYPE ret = OMX_ErrorNone; - - event = (SEC_OSAL_THREADEVENT *)SEC_OSAL_Malloc(sizeof(SEC_OSAL_THREADEVENT)); - if (!event) { - ret = OMX_ErrorInsufficientResources; - goto EXIT; - } - - SEC_OSAL_Memset(event, 0, sizeof(SEC_OSAL_THREADEVENT)); - event->signal = OMX_FALSE; - - ret = SEC_OSAL_MutexCreate(&event->mutex); - if (ret != OMX_ErrorNone) { - SEC_OSAL_Free(event); - goto EXIT; - } - - if (pthread_cond_init(&event->condition, NULL)) { - SEC_OSAL_MutexTerminate(event->mutex); - SEC_OSAL_Free(event); - ret = OMX_ErrorUndefined; - goto EXIT; - } - - *eventHandle = (OMX_HANDLETYPE)event; - ret = OMX_ErrorNone; - -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OSAL_SignalTerminate(OMX_HANDLETYPE eventHandle) -{ - SEC_OSAL_THREADEVENT *event = (SEC_OSAL_THREADEVENT *)eventHandle; - OMX_ERRORTYPE ret = OMX_ErrorNone; - - if (!event) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - ret = SEC_OSAL_MutexLock(event->mutex); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - if (pthread_cond_destroy(&event->condition)) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - - ret = SEC_OSAL_MutexUnlock(event->mutex); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - - ret = SEC_OSAL_MutexTerminate(event->mutex); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - - SEC_OSAL_Free(event); - -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OSAL_SignalReset(OMX_HANDLETYPE eventHandle) -{ - SEC_OSAL_THREADEVENT *event = (SEC_OSAL_THREADEVENT *)eventHandle; - OMX_ERRORTYPE ret = OMX_ErrorNone; - - if (!event) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - ret = SEC_OSAL_MutexLock(event->mutex); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - event->signal = OMX_FALSE; - - SEC_OSAL_MutexUnlock(event->mutex); - -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OSAL_SignalSet(OMX_HANDLETYPE eventHandle) -{ - SEC_OSAL_THREADEVENT *event = (SEC_OSAL_THREADEVENT *)eventHandle; - OMX_ERRORTYPE ret = OMX_ErrorNone; - - if (!event) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - ret = SEC_OSAL_MutexLock(event->mutex); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - event->signal = OMX_TRUE; - pthread_cond_signal(&event->condition); - - SEC_OSAL_MutexUnlock(event->mutex); - -EXIT: - return ret; -} - -OMX_ERRORTYPE SEC_OSAL_SignalWait(OMX_HANDLETYPE eventHandle, OMX_U32 ms) -{ - SEC_OSAL_THREADEVENT *event = (SEC_OSAL_THREADEVENT *)eventHandle; - OMX_ERRORTYPE ret = OMX_ErrorNone; - struct timespec timeout; - struct timeval now; - int funcret = 0; - OMX_U32 tv_us; - - FunctionIn(); - - if (!event) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - gettimeofday(&now, NULL); - - tv_us = now.tv_usec + ms * 1000; - timeout.tv_sec = now.tv_sec + tv_us / 1000000; - timeout.tv_nsec = (tv_us % 1000000) * 1000; - - ret = SEC_OSAL_MutexLock(event->mutex); - if (ret != OMX_ErrorNone) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - - if (ms == 0) { - if (!event->signal) - ret = OMX_ErrorTimeout; - } else if (ms == DEF_MAX_WAIT_TIME) { - while (!event->signal) - pthread_cond_wait(&event->condition, (pthread_mutex_t *)(event->mutex)); - ret = OMX_ErrorNone; - } else { - while (!event->signal) { - funcret = pthread_cond_timedwait(&event->condition, (pthread_mutex_t *)(event->mutex), &timeout); - if ((!event->signal) && (funcret == ETIMEDOUT)) { - ret = OMX_ErrorTimeout; - break; - } - } - } - - SEC_OSAL_MutexUnlock(event->mutex); - -EXIT: - FunctionOut(); - - return ret; -} diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.h b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.h deleted file mode 100644 index 640d2cc..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Event.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OSAL_EVENT -#define SEC_OSAL_EVENT - -#include -#include "OMX_Types.h" -#include "OMX_Core.h" - - -#define DEF_MAX_WAIT_TIME 0xFFFFFFFF - -typedef struct _SEC_OSAL_THREADEVENT -{ - OMX_BOOL signal; - OMX_HANDLETYPE mutex; - pthread_cond_t condition; -} SEC_OSAL_THREADEVENT; - - -#ifdef __cplusplus -extern "C" { -#endif - - -OMX_ERRORTYPE SEC_OSAL_SignalCreate(OMX_HANDLETYPE *eventHandle); -OMX_ERRORTYPE SEC_OSAL_SignalTerminate(OMX_HANDLETYPE eventHandle); -OMX_ERRORTYPE SEC_OSAL_SignalReset(OMX_HANDLETYPE eventHandle); -OMX_ERRORTYPE SEC_OSAL_SignalSet(OMX_HANDLETYPE eventHandle); -OMX_ERRORTYPE SEC_OSAL_SignalWait(OMX_HANDLETYPE eventHandle, OMX_U32 ms); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.c b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.c deleted file mode 100644 index 06ac712..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Library.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - - -#include -#include -#include -#include - -#include "SEC_OSAL_Library.h" - - -void *SEC_OSAL_dlopen(const char *filename, int flag) -{ - return dlopen(filename, flag); -} - -void *SEC_OSAL_dlsym(void *handle, const char *symbol) -{ - return dlsym(handle, symbol); -} - -int SEC_OSAL_dlclose(void *handle) -{ - return dlclose(handle); -} - -const char *SEC_OSAL_dlerror(void) -{ - return dlerror(); -} diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.h b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.h deleted file mode 100644 index 687cecd..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Library.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OSAL_LIBRARY -#define SEC_OSAL_LIBRARY - -#include "OMX_Types.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -void *SEC_OSAL_dlopen(const char *filename, int flag); -void *SEC_OSAL_dlsym(void *handle, const char *symbol); -int SEC_OSAL_dlclose(void *handle); -const char *SEC_OSAL_dlerror(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.c b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.c deleted file mode 100644 index bae4974..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Log.c - * @brief - * @author Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include - -#include "SEC_OSAL_Log.h" - - -void _SEC_OSAL_Log(SEC_LOG_LEVEL logLevel, const char *tag, const char *msg, ...) -{ - va_list argptr; - - va_start(argptr, msg); - - switch (logLevel) { - case SEC_LOG_TRACE: - __android_log_vprint(ANDROID_LOG_DEBUG, tag, msg, argptr); - break; - case SEC_LOG_WARNING: - __android_log_vprint(ANDROID_LOG_WARN, tag, msg, argptr); - break; - case SEC_LOG_ERROR: - __android_log_vprint(ANDROID_LOG_ERROR, tag, msg, argptr); - break; - default: - __android_log_vprint(ANDROID_LOG_VERBOSE, tag, msg, argptr); - } - - va_end(argptr); -} diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.h b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.h deleted file mode 100644 index 2f8a6ce..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Log.h - * @brief - * @author Yunji Kim (yunji.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - * 2010.8.27 : Add trace function - */ - -#ifndef SEC_OSAL_LOG -#define SEC_OSAL_LOG - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef SEC_LOG_OFF -#define SEC_LOG -#endif - -#ifndef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_LOG" -#endif - -#ifdef SEC_TRACE_ON -#define SEC_TRACE -#endif - -typedef enum _LOG_LEVEL -{ - SEC_LOG_TRACE, - SEC_LOG_WARNING, - SEC_LOG_ERROR -} SEC_LOG_LEVEL; - -#ifdef SEC_LOG -#define SEC_OSAL_Log(a, ...) ((void)_SEC_OSAL_Log(a, SEC_LOG_TAG, __VA_ARGS__)) -#else -#define SEC_OSAL_Log(a, ...) \ - do { \ - if (a == SEC_LOG_ERROR) \ - ((void)_SEC_OSAL_Log(a, SEC_LOG_TAG, __VA_ARGS__)); \ - } while (0) -#endif - -#ifdef SEC_TRACE -#define FunctionIn() _SEC_OSAL_Log(SEC_LOG_TRACE, SEC_LOG_TAG, "%s In , Line: %d", __FUNCTION__, __LINE__) -#define FunctionOut() _SEC_OSAL_Log(SEC_LOG_TRACE, SEC_LOG_TAG, "%s Out , Line: %d", __FUNCTION__, __LINE__) -#else -#define FunctionIn() ((void *)0) -#define FunctionOut() ((void *)0) -#endif - -extern void _SEC_OSAL_Log(SEC_LOG_LEVEL logLevel, const char *tag, const char *msg, ...); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.c b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.c deleted file mode 100644 index 3579d92..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Memory.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include - -#include "SEC_OSAL_Memory.h" - -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -static int mem_cnt = 0; - -OMX_PTR SEC_OSAL_Malloc(OMX_U32 size) -{ - mem_cnt++; - SEC_OSAL_Log(SEC_LOG_TRACE, "alloc count: %d", mem_cnt); - - return (OMX_PTR)malloc(size); -} - -void SEC_OSAL_Free(OMX_PTR addr) -{ - mem_cnt--; - SEC_OSAL_Log(SEC_LOG_TRACE, "free count: %d", mem_cnt); - - if (addr) - free(addr); - - return; -} - -OMX_PTR SEC_OSAL_Memset(OMX_PTR dest, OMX_S32 c, OMX_S32 n) -{ - return memset(dest, c, n); -} - -OMX_PTR SEC_OSAL_Memcpy(OMX_PTR dest, OMX_PTR src, OMX_S32 n) -{ - return memcpy(dest, src, n); -} - -OMX_PTR SEC_OSAL_Memmove(OMX_PTR dest, OMX_PTR src, OMX_S32 n) -{ - return memmove(dest, src, n); -} diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.h b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.h deleted file mode 100644 index 3a12838..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Memory.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OSAL_MEMORY -#define SEC_OSAL_MEMORY - -#include "OMX_Types.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -OMX_PTR SEC_OSAL_Malloc(OMX_U32 size); -void SEC_OSAL_Free(OMX_PTR addr); -OMX_PTR SEC_OSAL_Memset(OMX_PTR dest, OMX_S32 c, OMX_S32 n); -OMX_PTR SEC_OSAL_Memcpy(OMX_PTR dest, OMX_PTR src, OMX_S32 n); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.c b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.c deleted file mode 100644 index 146809c..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Mutex.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include -#include - -#include "SEC_OSAL_Memory.h" -#include "SEC_OSAL_Mutex.h" - - -OMX_ERRORTYPE SEC_OSAL_MutexCreate(OMX_HANDLETYPE *mutexHandle) -{ - pthread_mutex_t *mutex; - - mutex = (pthread_mutex_t *)SEC_OSAL_Malloc(sizeof(pthread_mutex_t)); - if (!mutex) - return OMX_ErrorInsufficientResources; - - if (pthread_mutex_init(mutex, NULL) != 0) - return OMX_ErrorUndefined; - - *mutexHandle = (OMX_HANDLETYPE)mutex; - return OMX_ErrorNone; -} - -OMX_ERRORTYPE SEC_OSAL_MutexTerminate(OMX_HANDLETYPE mutexHandle) -{ - pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle; - - if (mutex == NULL) - return OMX_ErrorBadParameter; - - if (pthread_mutex_destroy(mutex) != 0) - return OMX_ErrorUndefined; - - SEC_OSAL_Free(mutex); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE SEC_OSAL_MutexLock(OMX_HANDLETYPE mutexHandle) -{ - pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle; - int result; - - if (mutex == NULL) - return OMX_ErrorBadParameter; - - if (pthread_mutex_lock(mutex) != 0) - return OMX_ErrorUndefined; - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE SEC_OSAL_MutexUnlock(OMX_HANDLETYPE mutexHandle) -{ - pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle; - int result; - - if (mutex == NULL) - return OMX_ErrorBadParameter; - - if (pthread_mutex_unlock(mutex) != 0) - return OMX_ErrorUndefined; - - return OMX_ErrorNone; -} diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.h b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.h deleted file mode 100644 index 70dcd9d..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Mutex.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create -*/ - -#ifndef SEC_OSAL_MUTEX -#define SEC_OSAL_MUTEX - -#include "OMX_Types.h" -#include "OMX_Core.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -OMX_ERRORTYPE SEC_OSAL_MutexCreate(OMX_HANDLETYPE *mutexHandle); -OMX_ERRORTYPE SEC_OSAL_MutexTerminate(OMX_HANDLETYPE mutexHandle); -OMX_ERRORTYPE SEC_OSAL_MutexLock(OMX_HANDLETYPE mutexHandle); -OMX_ERRORTYPE SEC_OSAL_MutexUnlock(OMX_HANDLETYPE mutexHandle); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.c b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.c deleted file mode 100644 index 7a6c024..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Queue.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - - -#include -#include -#include - -#include "SEC_OSAL_Memory.h" -#include "SEC_OSAL_Mutex.h" -#include "SEC_OSAL_Queue.h" - - -OMX_ERRORTYPE SEC_OSAL_QueueCreate(SEC_QUEUE *queueHandle) -{ - int i = 0; - SEC_QElem *newqelem = NULL; - SEC_QElem *currentqelem = NULL; - SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle; - - OMX_ERRORTYPE ret = OMX_ErrorNone; - - if (!queue) - return OMX_ErrorBadParameter; - - ret = SEC_OSAL_MutexCreate(&queue->qMutex); - if (ret != OMX_ErrorNone) - return ret; - - queue->first = (SEC_QElem *)SEC_OSAL_Malloc(sizeof(SEC_QElem)); - if (queue->first == NULL) - return OMX_ErrorInsufficientResources; - - SEC_OSAL_Memset(queue->first, 0, sizeof(SEC_QElem)); - currentqelem = queue->last = queue->first; - queue->numElem = 0; - - for (i = 0; i < (MAX_QUEUE_ELEMENTS - 2); i++) { - newqelem = (SEC_QElem *)SEC_OSAL_Malloc(sizeof(SEC_QElem)); - if (newqelem == NULL) { - while (queue->first != NULL) { - currentqelem = queue->first->qNext; - SEC_OSAL_Free((OMX_PTR)queue->first); - queue->first = currentqelem; - } - return OMX_ErrorInsufficientResources; - } else { - SEC_OSAL_Memset(newqelem, 0, sizeof(SEC_QElem)); - currentqelem->qNext = newqelem; - currentqelem = newqelem; - } - } - - currentqelem->qNext = queue->first; - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE SEC_OSAL_QueueTerminate(SEC_QUEUE *queueHandle) -{ - int i = 0; - SEC_QElem *currentqelem = NULL; - SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle; - OMX_ERRORTYPE ret = OMX_ErrorNone; - - if (!queue) - return OMX_ErrorBadParameter; - - for ( i = 0; i < (MAX_QUEUE_ELEMENTS - 2); i++) { - currentqelem = queue->first->qNext; - SEC_OSAL_Free(queue->first); - queue->first = currentqelem; - } - - if(queue->first) { - SEC_OSAL_Free(queue->first); - queue->first = NULL; - } - - ret = SEC_OSAL_MutexTerminate(queue->qMutex); - - return ret; -} - -int SEC_OSAL_Queue(SEC_QUEUE *queueHandle, void *data) -{ - SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle; - if (queue == NULL) - return -1; - - SEC_OSAL_MutexLock(queue->qMutex); - - if ((queue->last->data != NULL) || (queue->numElem >= MAX_QUEUE_ELEMENTS)) { - SEC_OSAL_MutexUnlock(queue->qMutex); - return -1; - } - queue->last->data = data; - queue->last = queue->last->qNext; - queue->numElem++; - - SEC_OSAL_MutexUnlock(queue->qMutex); - return 0; -} - -void *SEC_OSAL_Dequeue(SEC_QUEUE *queueHandle) -{ - void *data = NULL; - SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle; - if (queue == NULL) - return NULL; - - SEC_OSAL_MutexLock(queue->qMutex); - - if ((queue->first->data == NULL) || (queue->numElem <= 0)) { - SEC_OSAL_MutexUnlock(queue->qMutex); - return NULL; - } - data = queue->first->data; - queue->first->data = NULL; - queue->first = queue->first->qNext; - queue->numElem--; - - SEC_OSAL_MutexUnlock(queue->qMutex); - return data; -} - -int SEC_OSAL_GetElemNum(SEC_QUEUE *queueHandle) -{ - int ElemNum = 0; - SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle; - if (queue == NULL) - return -1; - - SEC_OSAL_MutexLock(queue->qMutex); - ElemNum = queue->numElem; - SEC_OSAL_MutexUnlock(queue->qMutex); - return ElemNum; -} - -int SEC_OSAL_SetElemNum(SEC_QUEUE *queueHandle, int ElemNum) -{ - SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle; - if (queue == NULL) - return -1; - - SEC_OSAL_MutexLock(queue->qMutex); - queue->numElem = ElemNum; - SEC_OSAL_MutexUnlock(queue->qMutex); - return ElemNum; -} - diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h deleted file mode 100644 index 68910cc..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Queue.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OSAL_QUEUE -#define SEC_OSAL_QUEUE - -#include "OMX_Types.h" -#include "OMX_Core.h" - - -#define MAX_QUEUE_ELEMENTS 10 - -struct SEC_QElem; -typedef struct _SEC_QElem -{ - void *data; - struct SEC_QElem *qNext; -} SEC_QElem; - -typedef struct _SEC_QUEUE -{ - SEC_QElem *first; - SEC_QElem *last; - int numElem; - OMX_HANDLETYPE qMutex; -} SEC_QUEUE; - - -#ifdef __cplusplus -extern "C" { -#endif - -OMX_ERRORTYPE SEC_OSAL_QueueCreate(SEC_QUEUE *queueHandle); -OMX_ERRORTYPE SEC_OSAL_QueueTerminate(SEC_QUEUE *queueHandle); -int SEC_OSAL_Queue(SEC_QUEUE *queueHandle, void *data); -void *SEC_OSAL_Dequeue(SEC_QUEUE *queueHandle); -int SEC_OSAL_GetElemNum(SEC_QUEUE *queueHandle); -int SEC_OSAL_SetElemNum(SEC_QUEUE *queueHandle, int ElemNum); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c deleted file mode 100644 index 17a29a0..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Semaphore.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include -#include -#include - -#include "SEC_OSAL_Memory.h" -#include "SEC_OSAL_Semaphore.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_LOG_SEMA" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -OMX_ERRORTYPE SEC_OSAL_SemaphoreCreate(OMX_HANDLETYPE *semaphoreHandle) -{ - sem_t *sema; - - sema = (sem_t *)SEC_OSAL_Malloc(sizeof(sema)); - if (!sema) - return OMX_ErrorInsufficientResources; - - if (sem_init(sema, 0, 0) != 0) - return OMX_ErrorUndefined; - - *semaphoreHandle = (OMX_HANDLETYPE)sema; - return OMX_ErrorNone; -} - -OMX_ERRORTYPE SEC_OSAL_SemaphoreTerminate(OMX_HANDLETYPE semaphoreHandle) -{ - sem_t *sema = (sem_t *)semaphoreHandle; - - if (sema == NULL) - return OMX_ErrorBadParameter; - - if (sem_destroy(sema) != 0) - return OMX_ErrorUndefined; - - SEC_OSAL_Free(sema); - return OMX_ErrorNone; -} - -OMX_ERRORTYPE SEC_OSAL_SemaphoreWait(OMX_HANDLETYPE semaphoreHandle) -{ - sem_t *sema = (sem_t *)semaphoreHandle; - - FunctionIn(); - - if (sema == NULL) - return OMX_ErrorBadParameter; - - if (sem_wait(sema) != 0) - return OMX_ErrorUndefined; - - FunctionOut(); - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE SEC_OSAL_SemaphorePost(OMX_HANDLETYPE semaphoreHandle) -{ - sem_t *sema = (sem_t *)semaphoreHandle; - - FunctionIn(); - - if (sema == NULL) - return OMX_ErrorBadParameter; - - if (sem_post(sema) != 0) - return OMX_ErrorUndefined; - - FunctionOut(); - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE SEC_OSAL_Set_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 val) -{ - sem_t *sema = (sem_t *)semaphoreHandle; - - if (sema == NULL) - return OMX_ErrorBadParameter; - - if (sem_init(sema, 0, val) != 0) - return OMX_ErrorUndefined; - - return OMX_ErrorNone; -} - -OMX_ERRORTYPE SEC_OSAL_Get_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 *val) -{ - sem_t *sema = (sem_t *)semaphoreHandle; - OMX_U32 semaVal = 0; - - if (sema == NULL) - return OMX_ErrorBadParameter; - - if (sem_getvalue(sema, &semaVal) != 0) - return OMX_ErrorUndefined; - - *val = semaVal; - - return OMX_ErrorNone; -} diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.h b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.h deleted file mode 100644 index f23d3d6..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Semaphore.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OSAL_SEMAPHORE -#define SEC_OSAL_SEMAPHORE - -#include "OMX_Types.h" -#include "OMX_Core.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -OMX_ERRORTYPE SEC_OSAL_SemaphoreCreate(OMX_HANDLETYPE *semaphoreHandle); -OMX_ERRORTYPE SEC_OSAL_SemaphoreTerminate(OMX_HANDLETYPE semaphoreHandle); -OMX_ERRORTYPE SEC_OSAL_SemaphoreWait(OMX_HANDLETYPE semaphoreHandle); -OMX_ERRORTYPE SEC_OSAL_SemaphorePost(OMX_HANDLETYPE semaphoreHandle); -OMX_ERRORTYPE SEC_OSAL_Set_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 val); -OMX_ERRORTYPE SEC_OSAL_Get_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 *val); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c deleted file mode 100644 index d488885..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Thread.c - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#include -#include -#include -#include -#include -#include - -#include "SEC_OSAL_Memory.h" -#include "SEC_OSAL_Thread.h" - -#undef SEC_LOG_TAG -#define SEC_LOG_TAG "SEC_LOG_THREAD" -#define SEC_LOG_OFF -#include "SEC_OSAL_Log.h" - - -typedef struct _SEC_THREAD_HANDLE_TYPE -{ - pthread_t pthread; - pthread_attr_t attr; - struct sched_param schedparam; - int stack_size; -} SEC_THREAD_HANDLE_TYPE; - - -OMX_ERRORTYPE SEC_OSAL_ThreadCreate(OMX_HANDLETYPE *threadHandle, OMX_PTR function_name, OMX_PTR argument) -{ - FunctionIn(); - - int result = 0; - int detach_ret = 0; - SEC_THREAD_HANDLE_TYPE *thread; - OMX_ERRORTYPE ret = OMX_ErrorNone; - - thread = SEC_OSAL_Malloc(sizeof(SEC_THREAD_HANDLE_TYPE)); - SEC_OSAL_Memset(thread, 0, sizeof(SEC_THREAD_HANDLE_TYPE)); - - pthread_attr_init(&thread->attr); - if (thread->stack_size != 0) - pthread_attr_setstacksize(&thread->attr, thread->stack_size); - - /* set priority */ - if (thread->schedparam.sched_priority != 0) - pthread_attr_setschedparam(&thread->attr, &thread->schedparam); - - detach_ret = pthread_attr_setdetachstate(&thread->attr, PTHREAD_CREATE_JOINABLE); - if (detach_ret != 0) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - - result = pthread_create(&thread->pthread, &thread->attr, function_name, (void *)argument); - /* pthread_setschedparam(thread->pthread, SCHED_RR, &thread->schedparam); */ - - switch (result) { - case 0: - *threadHandle = (OMX_HANDLETYPE)thread; - ret = OMX_ErrorNone; - break; - case EAGAIN: - *threadHandle = NULL; - ret = OMX_ErrorInsufficientResources; - break; - default: - *threadHandle = NULL; - ret = OMX_ErrorUndefined; - break; - } - -EXIT: - FunctionOut(); - - return ret; -} - -OMX_ERRORTYPE SEC_OSAL_ThreadTerminate(OMX_HANDLETYPE threadHandle) -{ - FunctionIn(); - - OMX_ERRORTYPE ret = OMX_ErrorNone; - SEC_THREAD_HANDLE_TYPE *thread = (SEC_THREAD_HANDLE_TYPE *)threadHandle; - - if (!thread) { - ret = OMX_ErrorBadParameter; - goto EXIT; - } - if (pthread_join(thread->pthread, NULL) != 0) { - ret = OMX_ErrorUndefined; - goto EXIT; - } - - SEC_OSAL_Free(thread); - ret = OMX_ErrorNone; - -EXIT: - FunctionOut(); - - return ret; - -} - -OMX_ERRORTYPE SEC_OSAL_ThreadCancle(OMX_HANDLETYPE threadHandle) -{ - SEC_THREAD_HANDLE_TYPE *thread = (SEC_THREAD_HANDLE_TYPE *)threadHandle; - - if (!thread) - return OMX_ErrorBadParameter; - - /* thread_cancel(thread->pthread); */ - pthread_exit(thread->pthread); - pthread_join(thread->pthread, NULL); - - SEC_OSAL_Free(thread); - return OMX_ErrorNone; -} - -void SEC_OSAL_TheadExit(void *value_ptr) -{ - pthread_exit(value_ptr); - return; -} - -void SEC_OSAL_SleepMillisec(OMX_U32 ms) -{ - usleep(ms * 1000); - return; -} diff --git a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h b/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h deleted file mode 100644 index b932aef..0000000 --- a/aries/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Copyright 2010 Samsung Electronics S.LSI Co. LTD - * - * 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 SEC_OSAL_Thread.h - * @brief - * @author SeungBeom Kim (sbcrux.kim@samsung.com) - * @version 1.0 - * @history - * 2010.7.15 : Create - */ - -#ifndef SEC_OSAL_THREAD -#define SEC_OSAL_THREAD - -#include "OMX_Types.h" -#include "OMX_Core.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -OMX_ERRORTYPE SEC_OSAL_ThreadCreate(OMX_HANDLETYPE *threadHandle, OMX_PTR function_name, OMX_PTR argument); -OMX_ERRORTYPE SEC_OSAL_ThreadTerminate(OMX_HANDLETYPE threadHandle); -OMX_ERRORTYPE SEC_OSAL_ThreadCancle(OMX_HANDLETYPE threadHandle); -void SEC_OSAL_TheadExit(void *value_ptr); -void SEC_OSAL_SleepMillisec(OMX_U32 ms); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/aries/shbootimg.mk b/aries/shbootimg.mk deleted file mode 100644 index 4d44f92..0000000 --- a/aries/shbootimg.mk +++ /dev/null @@ -1,8 +0,0 @@ -INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img -$(INSTALLED_BOOTIMAGE_TARGET): device/samsung/common/aries/mkshbootimg.py \ - $(TARGET_RECOVERY_COMPRESSED_INITRAMFS) \ - $(BUILT_COMPRESSED_INITRAMFS_TARGET) \ - $(TARGET_PREBUILT_KERNEL) - $(call pretty,"Boot image: $@") - $(hide) ./device/samsung/common/aries/mkshbootimg.py $@ $(TARGET_PREBUILT_KERNEL) $(BUILT_COMPRESSED_INITRAMFS_TARGET) $(TARGET_RECOVERY_COMPRESSED_INITRAMFS) - diff --git a/bmlutils/Android.mk b/bmlutils/Android.mk new file mode 100644 index 0000000..cb7ec37 --- /dev/null +++ b/bmlutils/Android.mk @@ -0,0 +1,11 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE := bmlwrite +LOCAL_MODULE_TAGS := eng +LOCAL_MODULE_PATH := releasetools/kernel-tools +LOCAL_SRC_FILES := bmlwrite.c +LOCAL_FORCE_STATIC_EXECUTABLE := true +LOCAL_STATIC_LIBRARIES += libstdc++ libc +include $(BUILD_EXECUTABLE) + diff --git a/bmlutils/bmlwrite.c b/bmlutils/bmlwrite.c new file mode 100644 index 0000000..74860c6 --- /dev/null +++ b/bmlutils/bmlwrite.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include + +#define BML_UNLOCK_ALL 0x8A29 ///< unlock all partition RO -> RW + +int main(int argc, char** argv) { + char buf[4096]; + int dstfd, srcfd, bytes_read, bytes_written, total_read = 0; + if (argc != 3) + return 1; + if (argv[1][0] == '-' && argv[1][1] == 0) + srcfd = 0; + else { + srcfd = open(argv[1], O_RDONLY | O_LARGEFILE); + if (srcfd < 0) + return 2; + } + dstfd = open(argv[2], O_RDWR | O_LARGEFILE); + if (dstfd < 0) + return 3; + if (ioctl(dstfd, BML_UNLOCK_ALL, 0)) + return 4; + do { + total_read += bytes_read = read(srcfd, buf, 4096); + if (!bytes_read) + break; + if (bytes_read < 4096) + memset(&buf[bytes_read], 0, 4096 - bytes_read); + if (write(dstfd, buf, 4096) < 4096) + return 5; + } while(bytes_read == 4096); + return 0; +} diff --git a/include/s3c_bc.h b/include/s3c_bc.h new file mode 100755 index 0000000..e8ea490 --- /dev/null +++ b/include/s3c_bc.h @@ -0,0 +1,63 @@ +/*!**************************************************************************** +@File s3c_bc.h + +@Title s3c_bc kernel driver parameters + +@Author Imagination Technologies + Samsung Electronics Co. LTD + +@Date 03/03/2010 + +@Copyright 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. + +@Platform Generic + +@Description s3c_bc kernel driver parameters + +@DoxygenVer + +******************************************************************************/ + +/****************************************************************************** +Modifications :- +$Log: s3c_bc.h $ +******************************************************************************/ +#ifndef __S3C_BC_H__ +#define __S3C_BC_H__ + +#include + +#define S3C_BC_DEVICE_NAME "s3c_bc" + +#define S3C_BC_DEVICE_ID 0 +#define S3C_BC_DEVICE_BUFFER_COUNT 4 /* TODO: Modify this accordingly. */ + +#define S3C_BC_DEVICE_PHYS_PAGE_SIZE 0x1000 /* 4KB */ + +typedef struct S3C_BC_ioctl_package_TAG +{ + int inputparam; + int outputparam; +} S3C_BC_ioctl_package, *PS3C_BC_ioctl_package; + +/*!< Nov 2006: according to ioctl-number.txt 'g' wasn't in use. */ +#define S3C_BC_IOC_GID 'g' + +#define S3C_BC_IOWR(INDEX) _IOWR(S3C_BC_IOC_GID, INDEX, S3C_BC_ioctl_package) + +#define S3C_BC_ioctl_get_physical_base_address S3C_BC_IOWR(0) + +#endif /* __S3C_BC__H__ */ +/****************************************************************************** + End of file (s3c_bc.h) +******************************************************************************/ diff --git a/include/s3c_mem.h b/include/s3c_mem.h new file mode 100755 index 0000000..d51398a --- /dev/null +++ b/include/s3c_mem.h @@ -0,0 +1,56 @@ +/* + * Copyright@ Samsung Electronics Co. LTD + * + * 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 _S3C_MEM_COMMON_H_ +#define _S3C_MEM_COMMON_H_ + +#define MEM_IOCTL_MAGIC 'M' + +#define S3C_MEM_ALLOC _IOWR(MEM_IOCTL_MAGIC, 310, struct s3c_mem_alloc) +#define S3C_MEM_FREE _IOWR(MEM_IOCTL_MAGIC, 311, struct s3c_mem_alloc) + +#define S3C_MEM_SHARE_ALLOC _IOWR(MEM_IOCTL_MAGIC, 314, struct s3c_mem_alloc) +#define S3C_MEM_SHARE_FREE _IOWR(MEM_IOCTL_MAGIC, 315, struct s3c_mem_alloc) + +#define S3C_MEM_CACHEABLE_ALLOC _IOWR(MEM_IOCTL_MAGIC, 316, struct s3c_mem_alloc) +#define S3C_MEM_CACHEABLE_SHARE_ALLOC _IOWR(MEM_IOCTL_MAGIC, 317, struct s3c_mem_alloc) + +#define S3C_MEM_DMA_COPY _IOWR(MEM_IOCTL_MAGIC, 318, struct s3c_mem_dma_param) +#define S3C_MEM_DMA_SET _IOWR(MEM_IOCTL_MAGIC, 319, struct s3c_mem_dma_param) + +#define S3C_MEM_CACHE_INV _IOWR(MEM_IOCTL_MAGIC, 330, struct s3c_mem_dma_param) + + +struct s3c_mem_alloc { + int size; + unsigned int vir_addr; + unsigned int phy_addr; +}; + +struct s3c_mem_dma_param { + int size; + unsigned int src_addr; + unsigned int dst_addr; + int cfg; +}; + +#if 0 +typedef struct _s3c_mem_t{ + int dev_fd; + struct s3c_mem_alloc mem_alloc_info; +}s3c_mem_t; +#endif +#endif // _S3C_MEM_COMMON_H_ diff --git a/include/s5p_fimc.h b/include/s5p_fimc.h new file mode 100755 index 0000000..d2c760c --- /dev/null +++ b/include/s5p_fimc.h @@ -0,0 +1,153 @@ +/* + * Copyright@ Samsung Electronics Co. LTD + * + * 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 _S5P_FIMC_H_ +#define _S5P_FIMC_H_ + +#include + +/* + * G E N E R A L S + * +*/ +#define MIN(x, y) ((x < y) ? x : y) + +/* + * P I X E L F O R M A T G U I D E + * + * The 'x' means 'DO NOT CARE' + * The '*' means 'FIMC SPECIFIC' + * For some fimc formats, we couldn't find equivalent format in the V4L2 FOURCC. + * + * FIMC TYPE PLANES ORDER V4L2_PIX_FMT + * --------------------------------------------------------- + * RGB565 x x V4L2_PIX_FMT_RGB565 + * RGB888 x x V4L2_PIX_FMT_RGB24 + * YUV420 2 LSB_CBCR V4L2_PIX_FMT_NV12 + * YUV420 2 LSB_CRCB V4L2_PIX_FMT_NV21 + * YUV420 2 MSB_CBCR V4L2_PIX_FMT_NV21X* + * YUV420 2 MSB_CRCB V4L2_PIX_FMT_NV12X* + * YUV420 3 x V4L2_PIX_FMT_YUV420 + * YUV422 1 YCBYCR V4L2_PIX_FMT_YUYV + * YUV422 1 YCRYCB V4L2_PIX_FMT_YVYU + * YUV422 1 CBYCRY V4L2_PIX_FMT_UYVY + * YUV422 1 CRYCBY V4L2_PIX_FMT_VYUY* + * YUV422 2 LSB_CBCR V4L2_PIX_FMT_NV16* + * YUV422 2 LSB_CRCB V4L2_PIX_FMT_NV61* + * YUV422 2 MSB_CBCR V4L2_PIX_FMT_NV16X* + * YUV422 2 MSB_CRCB V4L2_PIX_FMT_NV61X* + * YUV422 3 x V4L2_PIX_FMT_YUV422P + * +*/ + +/* + * V 4 L 2 F I M C E X T E N S I O N S + * +*/ +#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') + +/* FOURCC for FIMC specific */ +#define V4L2_PIX_FMT_NV12X v4l2_fourcc('N', '1', '2', 'X') +#define V4L2_PIX_FMT_NV21X v4l2_fourcc('N', '2', '1', 'X') +#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') +#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') +#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') +#define V4L2_PIX_FMT_NV16X v4l2_fourcc('N', '1', '6', 'X') +#define V4L2_PIX_FMT_NV61X v4l2_fourcc('N', '6', '1', 'X') + +#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */ + +/* CID extensions */ +#define V4L2_CID_ROTATION (V4L2_CID_PRIVATE_BASE + 0) +#define V4L2_CID_RESERVED_MEM_BASE_ADDR (V4L2_CID_PRIVATE_BASE + 20) +#define V4L2_CID_FIMC_VERSION (V4L2_CID_PRIVATE_BASE + 21) +/* + * U S E R D E F I N E D T Y P E S + * +*/ + +typedef unsigned int dma_addr_t; + +struct fimc_buf { + dma_addr_t base[3]; + size_t length[3]; +}; + +struct fimc_buffer { + void *virt_addr; + void *phys_addr; + size_t length; +}; + +struct yuv_fmt_list { + const char *name; + const char *desc; + unsigned int fmt; + int bpp; + int planes; +}; + +struct img_offset { + int y_h; + int y_v; + int cb_h; + int cb_v; + int cr_h; + int cr_v; +}; + +//------------ STRUCT ---------------------------------------------------------// + +typedef struct +{ + unsigned int full_width; // Source Image Full Width (Virtual screen size) + unsigned int full_height; // Source Image Full Height (Virtual screen size) + unsigned int start_x; // Source Image Start width offset + unsigned int start_y; // Source Image Start height offset + unsigned int width; // Source Image Width + unsigned int height; // Source Image Height + unsigned int buf_addr_phy_rgb_y; // Base Address of the Source Image (RGB or Y): Physical Address + unsigned int buf_addr_phy_cb; // Base Address of the Source Image (CB Component) : Physical Address + unsigned int buf_addr_phy_cr; // Base Address of the Source Image (CR Component) : Physical Address + unsigned int color_space; // Color Space of the Source Image +} s5p_fimc_img_info; + +typedef struct +{ + s5p_fimc_img_info src; + s5p_fimc_img_info dst; +} s5p_fimc_params_t; + +typedef struct _s5p_fimc_t { + int dev_fd; + struct fimc_buffer out_buf; + + s5p_fimc_params_t params; + + int use_ext_out_mem; + unsigned int hw_ver; +}s5p_fimc_t; + +//------------------------ functions for v4l2 ------------------------------// +int fimc_v4l2_set_src(int fd, unsigned int hw_ver, s5p_fimc_img_info *src); +int fimc_v4l2_set_dst(int fd, s5p_fimc_img_info *dst, int rotation, unsigned int addr); +int fimc_v4l2_stream_on(int fd, enum v4l2_buf_type type); +int fimc_v4l2_queue(int fd, struct fimc_buf *fimc_buf); +int fimc_v4l2_dequeue(int fd); +int fimc_v4l2_stream_off(int fd); +int fimc_v4l2_clr_buf(int fd); +int fimc_handle_oneshot(int fd, struct fimc_buf *fimc_buf); +#endif diff --git a/include/videodev2_samsung.h b/include/videodev2_samsung.h new file mode 100755 index 0000000..0a7d7c3 --- /dev/null +++ b/include/videodev2_samsung.h @@ -0,0 +1,633 @@ +/* + * Video for Linux Two header file for samsung + * + * Copyright (C) 2009, Samsung Electronics + * + * This header file contains several v4l2 APIs to be proposed to v4l2 + * community and until bein accepted, will be used restrictly in Samsung's + * camera interface driver FIMC. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Alternatively, 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 __LINUX_VIDEODEV2_SAMSUNG_H +#define __LINUX_VIDEODEV2_SAMSUNG_H + +/* Values for 'capabilities' field */ +/* Object detection device */ +#define V4L2_CAP_OBJ_RECOGNITION 0x10000000 +/* strobe control */ +#define V4L2_CAP_STROBE 0x20000000 + +#define V4L2_CID_FOCUS_MODE (V4L2_CID_CAMERA_CLASS_BASE + 17) +/* Focus Methods */ +enum v4l2_focus_mode { + V4L2_FOCUS_MODE_AUTO = 0, + V4L2_FOCUS_MODE_MACRO = 1, + V4L2_FOCUS_MODE_MANUAL = 2, + V4L2_FOCUS_MODE_LASTP = 2, +}; + +#define V4L2_CID_ZOOM_MODE (V4L2_CID_CAMERA_CLASS_BASE + 18) +/* Zoom Methods */ +enum v4l2_zoom_mode { + V4L2_ZOOM_MODE_CONTINUOUS = 0, + V4L2_ZOOM_MODE_OPTICAL = 1, + V4L2_ZOOM_MODE_DIGITAL = 2, + V4L2_ZOOM_MODE_LASTP = 2, +}; + +/* Exposure Methods */ +#define V4L2_CID_PHOTOMETRY (V4L2_CID_CAMERA_CLASS_BASE + 19) +enum v4l2_photometry_mode { + V4L2_PHOTOMETRY_MULTISEG = 0, /*Multi Segment */ + V4L2_PHOTOMETRY_CWA = 1, /*Centre Weighted Average */ + V4L2_PHOTOMETRY_SPOT = 2, + V4L2_PHOTOMETRY_AFSPOT = 3, /*Spot metering on focused point */ + V4L2_PHOTOMETRY_LASTP = V4L2_PHOTOMETRY_AFSPOT, +}; + +/* Manual exposure control items menu type: iris, shutter, iso */ +#define V4L2_CID_CAM_APERTURE (V4L2_CID_CAMERA_CLASS_BASE + 20) +#define V4L2_CID_CAM_SHUTTER (V4L2_CID_CAMERA_CLASS_BASE + 21) +#define V4L2_CID_CAM_ISO (V4L2_CID_CAMERA_CLASS_BASE + 22) + +/* Following CIDs are menu type */ +#define V4L2_CID_SCENEMODE (V4L2_CID_CAMERA_CLASS_BASE + 23) +#define V4L2_CID_CAM_STABILIZE (V4L2_CID_CAMERA_CLASS_BASE + 24) +#define V4L2_CID_CAM_MULTISHOT (V4L2_CID_CAMERA_CLASS_BASE + 25) + +/* Control dynamic range */ +#define V4L2_CID_CAM_DR (V4L2_CID_CAMERA_CLASS_BASE + 26) + +/* White balance preset control */ +#define V4L2_CID_WHITE_BALANCE_PRESET (V4L2_CID_CAMERA_CLASS_BASE + 27) + +/* CID extensions */ +#define V4L2_CID_ROTATION (V4L2_CID_PRIVATE_BASE + 0) +#define V4L2_CID_PADDR_Y (V4L2_CID_PRIVATE_BASE + 1) +#define V4L2_CID_PADDR_CB (V4L2_CID_PRIVATE_BASE + 2) +#define V4L2_CID_PADDR_CR (V4L2_CID_PRIVATE_BASE + 3) +#define V4L2_CID_PADDR_CBCR (V4L2_CID_PRIVATE_BASE + 4) +#define V4L2_CID_OVERLAY_AUTO (V4L2_CID_PRIVATE_BASE + 5) +#define V4L2_CID_OVERLAY_VADDR0 (V4L2_CID_PRIVATE_BASE + 6) +#define V4L2_CID_OVERLAY_VADDR1 (V4L2_CID_PRIVATE_BASE + 7) +#define V4L2_CID_OVERLAY_VADDR2 (V4L2_CID_PRIVATE_BASE + 8) +#define V4L2_CID_OVLY_MODE (V4L2_CID_PRIVATE_BASE + 9) +#define V4L2_CID_DST_INFO (V4L2_CID_PRIVATE_BASE + 10) +#define V4L2_CID_IMAGE_EFFECT_FN (V4L2_CID_PRIVATE_BASE + 16) +#define V4L2_CID_IMAGE_EFFECT_APPLY (V4L2_CID_PRIVATE_BASE + 17) +#define V4L2_CID_IMAGE_EFFECT_CB (V4L2_CID_PRIVATE_BASE + 18) +#define V4L2_CID_IMAGE_EFFECT_CR (V4L2_CID_PRIVATE_BASE + 19) +#define V4L2_CID_RESERVED_MEM_BASE_ADDR (V4L2_CID_PRIVATE_BASE + 20) +#define V4L2_CID_FIMC_VERSION (V4L2_CID_PRIVATE_BASE + 21) + +#define V4L2_CID_STREAM_PAUSE (V4L2_CID_PRIVATE_BASE + 53) + +/* CID Extensions for camera sensor operations */ +#define V4L2_CID_CAM_PREVIEW_ONOFF (V4L2_CID_PRIVATE_BASE + 64) +#define V4L2_CID_CAM_CAPTURE (V4L2_CID_PRIVATE_BASE + 65) +#define V4L2_CID_CAM_JPEG_MEMSIZE (V4L2_CID_PRIVATE_BASE + 66) + +#define V4L2_CID_CAM_DATE_INFO_YEAR (V4L2_CID_PRIVATE_BASE + 14) +#define V4L2_CID_CAM_DATE_INFO_MONTH (V4L2_CID_PRIVATE_BASE + 15) +#define V4L2_CID_CAM_DATE_INFO_DATE (V4L2_CID_PRIVATE_BASE + 22) +#define V4L2_CID_CAM_SENSOR_VER (V4L2_CID_PRIVATE_BASE + 23) +#define V4L2_CID_CAM_FW_MINOR_VER (V4L2_CID_PRIVATE_BASE + 24) +#define V4L2_CID_CAM_FW_MAJOR_VER (V4L2_CID_PRIVATE_BASE + 25) +#define V4L2_CID_CAM_PRM_MINOR_VER (V4L2_CID_PRIVATE_BASE + 26) +#define V4L2_CID_CAM_PRM_MAJOR_VER (V4L2_CID_PRIVATE_BASE + 27) +#define V4L2_CID_CAM_FW_VER (V4L2_CID_PRIVATE_BASE + 28) +#define V4L2_CID_CAM_SET_FW_ADDR (V4L2_CID_PRIVATE_BASE + 29) +#define V4L2_CID_CAM_SET_FW_SIZE (V4L2_CID_PRIVATE_BASE + 30) +#define V4L2_CID_CAM_UPDATE_FW (V4L2_CID_PRIVATE_BASE + 31) +#define V4L2_CID_CAM_JPEG_MAIN_SIZE (V4L2_CID_PRIVATE_BASE + 32) +#define V4L2_CID_CAM_JPEG_MAIN_OFFSET (V4L2_CID_PRIVATE_BASE + 33) +#define V4L2_CID_CAM_JPEG_THUMB_SIZE (V4L2_CID_PRIVATE_BASE + 34) +#define V4L2_CID_CAM_JPEG_THUMB_OFFSET (V4L2_CID_PRIVATE_BASE + 35) +#define V4L2_CID_CAM_JPEG_POSTVIEW_OFFSET (V4L2_CID_PRIVATE_BASE + 36) +#define V4L2_CID_CAM_JPEG_QUALITY (V4L2_CID_PRIVATE_BASE + 37) +#define V4L2_CID_CAM_SENSOR_MAKER (V4L2_CID_PRIVATE_BASE + 38) +#define V4L2_CID_CAM_SENSOR_OPTICAL (V4L2_CID_PRIVATE_BASE + 39) +#define V4L2_CID_CAM_AF_VER_LOW (V4L2_CID_PRIVATE_BASE + 40) +#define V4L2_CID_CAM_AF_VER_HIGH (V4L2_CID_PRIVATE_BASE + 41) +#define V4L2_CID_CAM_GAMMA_RG_LOW (V4L2_CID_PRIVATE_BASE + 42) +#define V4L2_CID_CAM_GAMMA_RG_HIGH (V4L2_CID_PRIVATE_BASE + 43) +#define V4L2_CID_CAM_GAMMA_BG_LOW (V4L2_CID_PRIVATE_BASE + 44) +#define V4L2_CID_CAM_GAMMA_BG_HIGH (V4L2_CID_PRIVATE_BASE + 45) +#define V4L2_CID_CAM_DUMP_FW (V4L2_CID_PRIVATE_BASE + 46) +#define V4L2_CID_CAM_GET_DUMP_SIZE (V4L2_CID_PRIVATE_BASE + 47) +#define V4L2_CID_CAMERA_VT_MODE (V4L2_CID_PRIVATE_BASE + 48) +#define V4L2_CID_CAMERA_VGA_BLUR (V4L2_CID_PRIVATE_BASE + 49) +#define V4L2_CID_CAMERA_CAPTURE (V4L2_CID_PRIVATE_BASE + 50) + +#define V4L2_CID_MAIN_SW_DATE_INFO_YEAR (V4L2_CID_PRIVATE_BASE + 54) +#define V4L2_CID_MAIN_SW_DATE_INFO_MONTH (V4L2_CID_PRIVATE_BASE + 55) +#define V4L2_CID_MAIN_SW_DATE_INFO_DATE (V4L2_CID_PRIVATE_BASE + 56) +#define V4L2_CID_MAIN_SW_FW_MINOR_VER (V4L2_CID_PRIVATE_BASE + 57) +#define V4L2_CID_MAIN_SW_FW_MAJOR_VER (V4L2_CID_PRIVATE_BASE + 58) +#define V4L2_CID_MAIN_SW_PRM_MINOR_VER (V4L2_CID_PRIVATE_BASE + 59) +#define V4L2_CID_MAIN_SW_PRM_MAJOR_VER (V4L2_CID_PRIVATE_BASE + 60) + +enum v4l2_blur { + BLUR_LEVEL_0 = 0, + BLUR_LEVEL_1, + BLUR_LEVEL_2, + BLUR_LEVEL_3, + BLUR_LEVEL_MAX, +}; + +#define V4L2_CID_CAMERA_SCENE_MODE (V4L2_CID_PRIVATE_BASE + 70) +enum v4l2_scene_mode { + SCENE_MODE_BASE, + SCENE_MODE_NONE, + SCENE_MODE_PORTRAIT, + SCENE_MODE_NIGHTSHOT, + SCENE_MODE_BACK_LIGHT, + SCENE_MODE_LANDSCAPE, + SCENE_MODE_SPORTS, + SCENE_MODE_PARTY_INDOOR, + SCENE_MODE_BEACH_SNOW, + SCENE_MODE_SUNSET, + SCENE_MODE_DUST_DAWN, + SCENE_MODE_FALL_COLOR, + SCENE_MODE_FIREWORKS, + SCENE_MODE_TEXT, + SCENE_MODE_CANDLE_LIGHT, + SCENE_MODE_MAX, +}; + +#define V4L2_CID_CAMERA_FLASH_MODE (V4L2_CID_PRIVATE_BASE + 71) +enum v4l2_flash_mode { + FLASH_MODE_BASE, + FLASH_MODE_OFF, + FLASH_MODE_AUTO, + FLASH_MODE_ON, + FLASH_MODE_TORCH, + FLASH_MODE_MAX, +}; + +#define V4L2_CID_CAMERA_BRIGHTNESS (V4L2_CID_PRIVATE_BASE + 72) +enum v4l2_ev_mode { + EV_MINUS_4 = 0, + EV_MINUS_3, + EV_MINUS_2, + EV_MINUS_1, + EV_DEFAULT, + EV_PLUS_1, + EV_PLUS_2, + EV_PLUS_3, + EV_PLUS_4, + EV_MAX, +}; + +#define V4L2_CID_CAMERA_WHITE_BALANCE (V4L2_CID_PRIVATE_BASE + 73) +enum v4l2_wb_mode { + WHITE_BALANCE_BASE = 0, + WHITE_BALANCE_AUTO, + WHITE_BALANCE_SUNNY, + WHITE_BALANCE_CLOUDY, + WHITE_BALANCE_TUNGSTEN, + WHITE_BALANCE_FLUORESCENT, + WHITE_BALANCE_MAX, +}; + +#define V4L2_CID_CAMERA_EFFECT (V4L2_CID_PRIVATE_BASE + 74) +enum v4l2_effect_mode { + IMAGE_EFFECT_BASE = 0, + IMAGE_EFFECT_NONE, + IMAGE_EFFECT_BNW, + IMAGE_EFFECT_SEPIA, + IMAGE_EFFECT_AQUA, + IMAGE_EFFECT_ANTIQUE, + IMAGE_EFFECT_NEGATIVE, + IMAGE_EFFECT_SHARPEN, + IMAGE_EFFECT_MAX, +}; + +#define V4L2_CID_CAMERA_ISO (V4L2_CID_PRIVATE_BASE + 75) +enum v4l2_iso_mode { + ISO_AUTO = 0, + ISO_50, + ISO_100, + ISO_200, + ISO_400, + ISO_800, + ISO_1600, + ISO_SPORTS, + ISO_NIGHT, + ISO_MOVIE, + ISO_MAX, +}; + +#define V4L2_CID_CAMERA_METERING (V4L2_CID_PRIVATE_BASE + 76) +enum v4l2_metering_mode { + METERING_BASE = 0, + METERING_MATRIX, + METERING_CENTER, + METERING_SPOT, + METERING_MAX, +}; + +#define V4L2_CID_CAMERA_CONTRAST (V4L2_CID_PRIVATE_BASE + 77) +enum v4l2_contrast_mode { + CONTRAST_MINUS_2 = 0, + CONTRAST_MINUS_1, + CONTRAST_DEFAULT, + CONTRAST_PLUS_1, + CONTRAST_PLUS_2, + CONTRAST_MAX, +}; + +#define V4L2_CID_CAMERA_SATURATION (V4L2_CID_PRIVATE_BASE + 78) +enum v4l2_saturation_mode { + SATURATION_MINUS_2 = 0, + SATURATION_MINUS_1, + SATURATION_DEFAULT, + SATURATION_PLUS_1, + SATURATION_PLUS_2, + SATURATION_MAX, +}; + +#define V4L2_CID_CAMERA_SHARPNESS (V4L2_CID_PRIVATE_BASE + 79) +enum v4l2_sharpness_mode { + SHARPNESS_MINUS_2 = 0, + SHARPNESS_MINUS_1, + SHARPNESS_DEFAULT, + SHARPNESS_PLUS_1, + SHARPNESS_PLUS_2, + SHARPNESS_MAX, +}; + +#define V4L2_CID_CAMERA_WDR (V4L2_CID_PRIVATE_BASE + 80) +enum v4l2_wdr_mode { + WDR_OFF, + WDR_ON, + WDR_MAX, +}; + +#define V4L2_CID_CAMERA_ANTI_SHAKE (V4L2_CID_PRIVATE_BASE + 81) +enum v4l2_anti_shake_mode { + ANTI_SHAKE_OFF, + ANTI_SHAKE_STILL_ON, + ANTI_SHAKE_MOVIE_ON, + ANTI_SHAKE_MAX, +}; + +#define V4L2_CID_CAMERA_TOUCH_AF_START_STOP (V4L2_CID_PRIVATE_BASE + 82) +enum v4l2_touch_af { + TOUCH_AF_STOP = 0, + TOUCH_AF_START, + TOUCH_AF_MAX, +}; + +#define V4L2_CID_CAMERA_SMART_AUTO (V4L2_CID_PRIVATE_BASE + 83) +enum v4l2_smart_auto { + SMART_AUTO_OFF = 0, + SMART_AUTO_ON, + SMART_AUTO_MAX, +}; + +#define V4L2_CID_CAMERA_VINTAGE_MODE (V4L2_CID_PRIVATE_BASE + 84) +enum v4l2_vintage_mode { + VINTAGE_MODE_BASE, + VINTAGE_MODE_OFF, + VINTAGE_MODE_NORMAL, + VINTAGE_MODE_WARM, + VINTAGE_MODE_COOL, + VINTAGE_MODE_BNW, + VINTAGE_MODE_MAX, +}; + +#define V4L2_CID_CAMERA_JPEG_QUALITY (V4L2_CID_PRIVATE_BASE + 85) +#define V4L2_CID_CAMERA_GPS_LATITUDE (V4L2_CID_CAMERA_CLASS_BASE + 30) +#define V4L2_CID_CAMERA_GPS_LONGITUDE (V4L2_CID_CAMERA_CLASS_BASE + 31) +#define V4L2_CID_CAMERA_GPS_TIMESTAMP (V4L2_CID_CAMERA_CLASS_BASE + 32) +#define V4L2_CID_CAMERA_GPS_ALTITUDE (V4L2_CID_CAMERA_CLASS_BASE + 33) +#define V4L2_CID_CAMERA_EXIF_TIME_INFO (V4L2_CID_CAMERA_CLASS_BASE + 34) +#define V4L2_CID_CAMERA_ZOOM (V4L2_CID_PRIVATE_BASE + 90) +enum v4l2_zoom_level { + ZOOM_LEVEL_0 = 0, + ZOOM_LEVEL_1, + ZOOM_LEVEL_2, + ZOOM_LEVEL_3, + ZOOM_LEVEL_4, + ZOOM_LEVEL_5, + ZOOM_LEVEL_6, + ZOOM_LEVEL_7, + ZOOM_LEVEL_8, + ZOOM_LEVEL_9, + ZOOM_LEVEL_10, + ZOOM_LEVEL_11, + ZOOM_LEVEL_12, + ZOOM_LEVEL_MAX, +}; + +#define V4L2_CID_CAMERA_FACE_DETECTION (V4L2_CID_PRIVATE_BASE + 91) +enum v4l2_face_detection { + FACE_DETECTION_OFF = 0, + FACE_DETECTION_ON, + FACE_DETECTION_NOLINE, + FACE_DETECTION_ON_BEAUTY, + FACE_DETECTION_MAX, +}; + +#define V4L2_CID_CAMERA_SMART_AUTO_STATUS (V4L2_CID_PRIVATE_BASE + 92) +enum v4l2_smart_auto_status { + SMART_AUTO_STATUS_AUTO = 0, + SMART_AUTO_STATUS_LANDSCAPE, + SMART_AUTO_STATUS_PORTRAIT, + SMART_AUTO_STATUS_MACRO, + SMART_AUTO_STATUS_NIGHT, + SMART_AUTO_STATUS_PORTRAIT_NIGHT, + SMART_AUTO_STATUS_BACKLIT, + SMART_AUTO_STATUS_PORTRAIT_BACKLIT, + SMART_AUTO_STATUS_ANTISHAKE, + SMART_AUTO_STATUS_PORTRAIT_ANTISHAKE, + SMART_AUTO_STATUS_MAX, +}; + +#define V4L2_CID_CAMERA_SET_AUTO_FOCUS (V4L2_CID_PRIVATE_BASE + 93) +enum v4l2_auto_focus { + AUTO_FOCUS_OFF = 0, + AUTO_FOCUS_ON, + AUTO_FOCUS_MAX, +}; + +#define V4L2_CID_CAMERA_BEAUTY_SHOT (V4L2_CID_PRIVATE_BASE + 94) +enum v4l2_beauty_shot { + BEAUTY_SHOT_OFF = 0, + BEAUTY_SHOT_ON, + BEAUTY_SHOT_MAX, +}; + +#define V4L2_CID_CAMERA_AEAWB_LOCK_UNLOCK (V4L2_CID_PRIVATE_BASE + 95) +enum v4l2_ae_awb_lockunlock { + AE_UNLOCK_AWB_UNLOCK = 0, + AE_LOCK_AWB_UNLOCK, + AE_UNLOCK_AWB_LOCK, + AE_LOCK_AWB_LOCK, + AE_AWB_MAX +}; + +#define V4L2_CID_CAMERA_FACEDETECT_LOCKUNLOCK (V4L2_CID_PRIVATE_BASE + 96) +enum v4l2_face_lock { + FACE_LOCK_OFF = 0, + FACE_LOCK_ON, + FIRST_FACE_TRACKING, + FACE_LOCK_MAX, +}; + +#define V4L2_CID_CAMERA_OBJECT_POSITION_X (V4L2_CID_PRIVATE_BASE + 97) +#define V4L2_CID_CAMERA_OBJECT_POSITION_Y (V4L2_CID_PRIVATE_BASE + 98) +#define V4L2_CID_CAMERA_FOCUS_MODE (V4L2_CID_PRIVATE_BASE + 99) +enum v4l2_focusmode { + FOCUS_MODE_AUTO = 0, + FOCUS_MODE_MACRO, + FOCUS_MODE_FACEDETECT, + FOCUS_MODE_AUTO_DEFAULT, + FOCUS_MODE_MACRO_DEFAULT, + FOCUS_MODE_FACEDETECT_DEFAULT, + FOCUS_MODE_INFINITY, + FOCUS_MODE_MAX, +}; + +#define V4L2_CID_CAMERA_OBJ_TRACKING_STATUS (V4L2_CID_PRIVATE_BASE + 100) +enum v4l2_obj_tracking_status { + OBJECT_TRACKING_STATUS_BASE, + OBJECT_TRACKING_STATUS_PROGRESSING, + OBJECT_TRACKING_STATUS_SUCCESS, + OBJECT_TRACKING_STATUS_FAIL, + OBJECT_TRACKING_STATUS_MISSING, + OBJECT_TRACKING_STATUS_MAX, +}; + +#define V4L2_CID_CAMERA_OBJ_TRACKING_START_STOP (V4L2_CID_PRIVATE_BASE + 101) +enum v4l2_ot_start_stop { + OT_STOP = 0, + OT_START, + OT_MAX, +}; + +#define V4L2_CID_CAMERA_CAF_START_STOP (V4L2_CID_PRIVATE_BASE + 102) +enum v4l2_caf_start_stop { + CAF_STOP = 0, + CAF_START, + CAF_MAX, +}; + +#define V4L2_CID_CAMERA_AUTO_FOCUS_RESULT (V4L2_CID_PRIVATE_BASE + 103) +#define V4L2_CID_CAMERA_FRAME_RATE (V4L2_CID_PRIVATE_BASE + 104) +enum v4l2_frame_rate { + FRAME_RATE_AUTO = 0, + FRAME_RATE_7 = 7, + FRAME_RATE_15 = 15, + FRAME_RATE_30 = 30, + FRAME_RATE_60 = 60, + FRAME_RATE_120 = 120, + FRAME_RATE_MAX +}; + +#define V4L2_CID_CAMERA_ANTI_BANDING (V4L2_CID_PRIVATE_BASE + 105) +enum v4l2_anti_banding { + ANTI_BANDING_AUTO = 0, + ANTI_BANDING_50HZ = 1, + ANTI_BANDING_60HZ = 2, + ANTI_BANDING_OFF = 3, +}; + +#define V4L2_CID_CAMERA_SET_GAMMA (V4L2_CID_PRIVATE_BASE + 106) +enum v4l2_gamma_mode { + GAMMA_OFF = 0, + GAMMA_ON = 1, + GAMMA_MAX, +}; + +#define V4L2_CID_CAMERA_SET_SLOW_AE (V4L2_CID_PRIVATE_BASE + 107) +enum v4l2_slow_ae_mode { + SLOW_AE_OFF, + SLOW_AE_ON, + SLOW_AE_MAX, +}; + +#define V4L2_CID_CAMERA_BATCH_REFLECTION (V4L2_CID_PRIVATE_BASE + 108) +#define V4L2_CID_CAMERA_EXIF_ORIENTATION (V4L2_CID_PRIVATE_BASE + 109) + +#define V4L2_CID_CAMERA_RESET (V4L2_CID_PRIVATE_BASE + 111) +#define V4L2_CID_CAMERA_CHECK_DATALINE (V4L2_CID_PRIVATE_BASE + 112) +#define V4L2_CID_CAMERA_CHECK_DATALINE_STOP (V4L2_CID_PRIVATE_BASE + 113) +#define V4L2_CID_CAMERA_GET_ISO (V4L2_CID_PRIVATE_BASE + 114) +#define V4L2_CID_CAMERA_GET_SHT_TIME (V4L2_CID_PRIVATE_BASE + 115) +#define V4L2_CID_CAMERA_SENSOR_MODE (V4L2_CID_PRIVATE_BASE + 116) +#define V4L2_CID_ESD_INT (V4L2_CID_PRIVATE_BASE + 117) +#define V4L2_CID_CAMERA_GET_FLASH_ONOFF (V4L2_CID_PRIVATE_BASE + 118) +#define V4L2_CID_CAMERA_RETURN_FOCUS (V4L2_CID_PRIVATE_BASE + 119) + +/* Pixel format FOURCC depth Description */ +/* 12 Y/CbCr 4:2:0 64x32 macroblocks */ +#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2') + +/* + * * V4L2 extention for digital camera + * */ +/* Strobe flash light */ +enum v4l2_strobe_control { + /* turn off the flash light */ + V4L2_STROBE_CONTROL_OFF = 0, + /* turn on the flash light */ + V4L2_STROBE_CONTROL_ON = 1, + /* act guide light before splash */ + V4L2_STROBE_CONTROL_AFGUIDE = 2, + /* charge the flash light */ + V4L2_STROBE_CONTROL_CHARGE = 3, +}; + +enum v4l2_strobe_conf { + V4L2_STROBE_OFF = 0, /* Always off */ + V4L2_STROBE_ON = 1, /* Always splashes */ + /* Auto control presets */ + V4L2_STROBE_AUTO = 2, + V4L2_STROBE_REDEYE_REDUCTION = 3, + V4L2_STROBE_SLOW_SYNC = 4, + V4L2_STROBE_FRONT_CURTAIN = 5, + V4L2_STROBE_REAR_CURTAIN = 6, + /* Extra manual control presets */ + /* keep turned on until turning off */ + V4L2_STROBE_PERMANENT = 7, + V4L2_STROBE_EXTERNAL = 8, +}; + +enum v4l2_strobe_status { + V4L2_STROBE_STATUS_OFF = 0, + /* while processing configurations */ + V4L2_STROBE_STATUS_BUSY = 1, + V4L2_STROBE_STATUS_ERR = 2, + V4L2_STROBE_STATUS_CHARGING = 3, + V4L2_STROBE_STATUS_CHARGED = 4, +}; + +/* capabilities field */ +/* No strobe supported */ +#define V4L2_STROBE_CAP_NONE 0x0000 +/* Always flash off mode */ +#define V4L2_STROBE_CAP_OFF 0x0001 +/* Always use flash light mode */ +#define V4L2_STROBE_CAP_ON 0x0002 +/* Flashlight works automatic */ +#define V4L2_STROBE_CAP_AUTO 0x0004 +/* Red-eye reduction */ +#define V4L2_STROBE_CAP_REDEYE 0x0008 +/* Slow sync */ +#define V4L2_STROBE_CAP_SLOWSYNC 0x0010 +/* Front curtain */ +#define V4L2_STROBE_CAP_FRONT_CURTAIN 0x0020 +/* Rear curtain */ +#define V4L2_STROBE_CAP_REAR_CURTAIN 0x0040 +/* keep turned on until turning off */ +#define V4L2_STROBE_CAP_PERMANENT 0x0080 +/* use external strobe */ +#define V4L2_STROBE_CAP_EXTERNAL 0x0100 + +/* Set mode and Get status */ +struct v4l2_strobe { + /* off/on/charge:0/1/2 */ + enum v4l2_strobe_control control; + /* supported strobe capabilities */ + __u32 capabilities; + enum v4l2_strobe_conf mode; + enum v4l2_strobe_status status; /* read only */ + /* default is 0 and range of value varies from each models */ + __u32 flash_ev; + __u32 reserved[4]; +}; + +#define VIDIOC_S_STROBE _IOWR('V', 83, struct v4l2_strobe) +#define VIDIOC_G_STROBE _IOR('V', 84, struct v4l2_strobe) + +/* Object recognition and collateral actions */ +enum v4l2_recog_mode { + V4L2_RECOGNITION_MODE_OFF = 0, + V4L2_RECOGNITION_MODE_ON = 1, + V4L2_RECOGNITION_MODE_LOCK = 2, +}; + +enum v4l2_recog_action { + V4L2_RECOGNITION_ACTION_NONE = 0, /* only recognition */ + V4L2_RECOGNITION_ACTION_BLINK = 1, /* Capture on blinking */ + V4L2_RECOGNITION_ACTION_SMILE = 2, /* Capture on smiling */ +}; + +enum v4l2_recog_pattern { + V4L2_RECOG_PATTERN_FACE = 0, /* Face */ + V4L2_RECOG_PATTERN_HUMAN = 1, /* Human */ + V4L2_RECOG_PATTERN_CHAR = 2, /* Character */ +}; + +struct v4l2_recog_rect { + enum v4l2_recog_pattern p; /* detected pattern */ + struct v4l2_rect o; /* detected area */ + __u32 reserved[4]; +}; + +struct v4l2_recog_data { + __u8 detect_cnt; /* detected object counter */ + struct v4l2_rect o; /* detected area */ + __u32 reserved[4]; +}; + +struct v4l2_recognition { + enum v4l2_recog_mode mode; + + /* Which pattern to detect */ + enum v4l2_recog_pattern pattern; + + /* How many object to detect */ + __u8 obj_num; + + /* select detected object */ + __u32 detect_idx; + + /* read only :Get object coordination */ + struct v4l2_recog_data data; + + enum v4l2_recog_action action; + __u32 reserved[4]; +}; + +#define VIDIOC_S_RECOGNITION _IOWR('V', 85, struct v4l2_recognition) +#define VIDIOC_G_RECOGNITION _IOR('V', 86, struct v4l2_recognition) + +/* We use this struct as the v4l2_streamparm raw_data for + * VIDIOC_G_PARM and VIDIOC_S_PARM + */ +struct sec_cam_parm { + struct v4l2_captureparm capture; + int contrast; + int effects; + int brightness; + int flash_mode; + int focus_mode; + int iso; + int metering; + int saturation; + int scene_mode; + int sharpness; + int white_balance; +}; + +#endif /* __LINUX_VIDEODEV2_SAMSUNG_H */ diff --git a/libaudio/Android.mk b/libaudio/Android.mk new file mode 100644 index 0000000..43f2ad8 --- /dev/null +++ b/libaudio/Android.mk @@ -0,0 +1,49 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_SRC_FILES:= aplay.c alsa_pcm.c alsa_mixer.c +LOCAL_MODULE:= aplay +LOCAL_SHARED_LIBRARIES:= libc libcutils +LOCAL_MODULE_TAGS:= debug +include $(BUILD_EXECUTABLE) + +include $(CLEAR_VARS) +LOCAL_SRC_FILES:= arec.c alsa_pcm.c +LOCAL_MODULE:= arec +LOCAL_SHARED_LIBRARIES:= libc libcutils +LOCAL_MODULE_TAGS:= debug +include $(BUILD_EXECUTABLE) + +include $(CLEAR_VARS) +LOCAL_SRC_FILES:= amix.c alsa_mixer.c +LOCAL_MODULE:= amix +LOCAL_SHARED_LIBRARIES := libc libcutils +LOCAL_MODULE_TAGS:= debug +include $(BUILD_EXECUTABLE) + +include $(CLEAR_VARS) +LOCAL_SRC_FILES:= AudioHardware.cpp alsa_mixer.c alsa_pcm.c +LOCAL_MODULE:= libaudio +LOCAL_STATIC_LIBRARIES:= libaudiointerface +LOCAL_SHARED_LIBRARIES:= libc libcutils libutils libmedia libhardware_legacy +ifeq ($(BOARD_HAVE_BLUETOOTH),true) + LOCAL_SHARED_LIBRARIES += liba2dp +endif + +ifeq ($(TARGET_SIMULATOR),true) + LOCAL_LDLIBS += -ldl +else + LOCAL_SHARED_LIBRARIES += libdl +endif + +include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_SRC_FILES:= AudioPolicyManager.cpp +LOCAL_MODULE:= libaudiopolicy +LOCAL_STATIC_LIBRARIES:= libaudiopolicybase +LOCAL_SHARED_LIBRARIES:= libc libcutils libutils libmedia +ifeq ($(BOARD_HAVE_BLUETOOTH),true) + LOCAL_CFLAGS += -DWITH_A2DP +endif +include $(BUILD_SHARED_LIBRARY) diff --git a/libaudio/AudioHardware.cpp b/libaudio/AudioHardware.cpp new file mode 100644 index 0000000..45f0a2d --- /dev/null +++ b/libaudio/AudioHardware.cpp @@ -0,0 +1,2127 @@ +/* +** Copyright 2010, The Android Open-Source Project +** +** 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 + +//#define LOG_NDEBUG 0 + +#define LOG_TAG "AudioHardware" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "AudioHardware.h" +#include +#include + +extern "C" { +#include "alsa_audio.h" +} + + +namespace android { + +const uint32_t AudioHardware::inputSamplingRates[] = { + 8000, 11025, 16000, 22050, 44100 +}; + +// trace driver operations for dump +// +#define DRIVER_TRACE + +enum { + DRV_NONE, + DRV_PCM_OPEN, + DRV_PCM_CLOSE, + DRV_PCM_WRITE, + DRV_PCM_READ, + DRV_MIXER_OPEN, + DRV_MIXER_CLOSE, + DRV_MIXER_GET, + DRV_MIXER_SEL +}; + +#ifdef DRIVER_TRACE +#define TRACE_DRIVER_IN(op) mDriverOp = op; +#define TRACE_DRIVER_OUT mDriverOp = DRV_NONE; +#else +#define TRACE_DRIVER_IN(op) +#define TRACE_DRIVER_OUT +#endif + +// ---------------------------------------------------------------------------- + +const char *AudioHardware::inputPathNameDefault = "Default"; +const char *AudioHardware::inputPathNameCamcorder = "Camcorder"; +const char *AudioHardware::inputPathNameVoiceRecognition = "Voice Recognition"; +const char *AudioHardware::inputPathNameVoiceCommunication = "Voice Communication"; + +AudioHardware::AudioHardware() : + mInit(false), + mMicMute(false), + mPcm(NULL), + mMixer(NULL), + mPcmOpenCnt(0), + mMixerOpenCnt(0), + mInCallAudioMode(false), + mInputSource(AUDIO_SOURCE_DEFAULT), + mBluetoothNrec(true), + mTTYMode(TTY_MODE_OFF), + mSecRilLibHandle(NULL), + mRilClient(0), + mActivatedCP(false), + mDriverOp(DRV_NONE) +{ + loadRILD(); + mInit = true; +} + +AudioHardware::~AudioHardware() +{ + for (size_t index = 0; index < mInputs.size(); index++) { + closeInputStream(mInputs[index].get()); + } + mInputs.clear(); + closeOutputStream((AudioStreamOut*)mOutput.get()); + + if (mMixer) { + TRACE_DRIVER_IN(DRV_MIXER_CLOSE) + mixer_close(mMixer); + TRACE_DRIVER_OUT + } + if (mPcm) { + TRACE_DRIVER_IN(DRV_PCM_CLOSE) + pcm_close(mPcm); + TRACE_DRIVER_OUT + } + + if (mSecRilLibHandle) { + if (disconnectRILD(mRilClient) != RIL_CLIENT_ERR_SUCCESS) + LOGE("Disconnect_RILD() error"); + + if (closeClientRILD(mRilClient) != RIL_CLIENT_ERR_SUCCESS) + LOGE("CloseClient_RILD() error"); + + mRilClient = 0; + + dlclose(mSecRilLibHandle); + mSecRilLibHandle = NULL; + } + + mInit = false; +} + +status_t AudioHardware::initCheck() +{ + return mInit ? NO_ERROR : NO_INIT; +} + +void AudioHardware::loadRILD(void) +{ + mSecRilLibHandle = dlopen("libsecril-client.so", RTLD_NOW); + + if (mSecRilLibHandle) { + LOGV("libsecril-client.so is loaded"); + + openClientRILD = (HRilClient (*)(void)) + dlsym(mSecRilLibHandle, "OpenClient_RILD"); + disconnectRILD = (int (*)(HRilClient)) + dlsym(mSecRilLibHandle, "Disconnect_RILD"); + closeClientRILD = (int (*)(HRilClient)) + dlsym(mSecRilLibHandle, "CloseClient_RILD"); + isConnectedRILD = (int (*)(HRilClient)) + dlsym(mSecRilLibHandle, "isConnected_RILD"); + connectRILD = (int (*)(HRilClient)) + dlsym(mSecRilLibHandle, "Connect_RILD"); + setCallVolume = (int (*)(HRilClient, SoundType, int)) + dlsym(mSecRilLibHandle, "SetCallVolume"); + setCallAudioPath = (int (*)(HRilClient, AudioPath)) + dlsym(mSecRilLibHandle, "SetCallAudioPath"); + setCallClockSync = (int (*)(HRilClient, SoundClockCondition)) + dlsym(mSecRilLibHandle, "SetCallClockSync"); + + if (!openClientRILD || !disconnectRILD || !closeClientRILD || + !isConnectedRILD || !connectRILD || + !setCallVolume || !setCallAudioPath || !setCallClockSync) { + LOGE("Can't load all functions from libsecril-client.so"); + + dlclose(mSecRilLibHandle); + mSecRilLibHandle = NULL; + } else { + mRilClient = openClientRILD(); + if (!mRilClient) { + LOGE("OpenClient_RILD() error"); + + dlclose(mSecRilLibHandle); + mSecRilLibHandle = NULL; + } + } + } else { + LOGE("Can't load libsecril-client.so"); + } +} + +status_t AudioHardware::connectRILDIfRequired(void) +{ + if (!mSecRilLibHandle) { + LOGE("connectIfRequired() lib is not loaded"); + return INVALID_OPERATION; + } + + if (isConnectedRILD(mRilClient)) { + return OK; + } + + if (connectRILD(mRilClient) != RIL_CLIENT_ERR_SUCCESS) { + LOGE("Connect_RILD() error"); + return INVALID_OPERATION; + } + + return OK; +} + +AudioStreamOut* AudioHardware::openOutputStream( + uint32_t devices, int *format, uint32_t *channels, + uint32_t *sampleRate, status_t *status) +{ + sp out; + status_t rc; + + { // scope for the lock + Mutex::Autolock lock(mLock); + + // only one output stream allowed + if (mOutput != 0) { + if (status) { + *status = INVALID_OPERATION; + } + return NULL; + } + + out = new AudioStreamOutALSA(); + + rc = out->set(this, devices, format, channels, sampleRate); + if (rc == NO_ERROR) { + mOutput = out; + } + } + + if (rc != NO_ERROR) { + if (out != 0) { + out.clear(); + } + } + if (status) { + *status = rc; + } + + return out.get(); +} + +void AudioHardware::closeOutputStream(AudioStreamOut* out) { + sp spOut; + { + Mutex::Autolock lock(mLock); + if (mOutput == 0 || mOutput.get() != out) { + LOGW("Attempt to close invalid output stream"); + return; + } + spOut = mOutput; + mOutput.clear(); + } + spOut.clear(); +} + +AudioStreamIn* AudioHardware::openInputStream( + uint32_t devices, int *format, uint32_t *channels, + uint32_t *sampleRate, status_t *status, + AudioSystem::audio_in_acoustics acoustic_flags) +{ + // check for valid input source + if (!AudioSystem::isInputDevice((AudioSystem::audio_devices)devices)) { + if (status) { + *status = BAD_VALUE; + } + return NULL; + } + + status_t rc = NO_ERROR; + sp in; + + { // scope for the lock + Mutex::Autolock lock(mLock); + + in = new AudioStreamInALSA(); + rc = in->set(this, devices, format, channels, sampleRate, acoustic_flags); + if (rc == NO_ERROR) { + mInputs.add(in); + } + } + + if (rc != NO_ERROR) { + if (in != 0) { + in.clear(); + } + } + if (status) { + *status = rc; + } + + LOGV("AudioHardware::openInputStream()%p", in.get()); + return in.get(); +} + +void AudioHardware::closeInputStream(AudioStreamIn* in) { + + sp spIn; + { + Mutex::Autolock lock(mLock); + + ssize_t index = mInputs.indexOf((AudioStreamInALSA *)in); + if (index < 0) { + LOGW("Attempt to close invalid input stream"); + return; + } + spIn = mInputs[index]; + mInputs.removeAt(index); + } + LOGV("AudioHardware::closeInputStream()%p", in); + spIn.clear(); +} + + +status_t AudioHardware::setMode(int mode) +{ + sp spOut; + sp spIn; + status_t status; + + // Mutex acquisition order is always out -> in -> hw + AutoMutex lock(mLock); + + spOut = mOutput; + while (spOut != 0) { + if (!spOut->checkStandby()) { + int cnt = spOut->prepareLock(); + mLock.unlock(); + spOut->lock(); + mLock.lock(); + // make sure that another thread did not change output state while the + // mutex is released + if ((spOut == mOutput) && (cnt == spOut->standbyCnt())) { + break; + } + spOut->unlock(); + spOut = mOutput; + } else { + spOut.clear(); + } + } + // spOut is not 0 here only if the output is active + + spIn = getActiveInput_l(); + while (spIn != 0) { + int cnt = spIn->prepareLock(); + mLock.unlock(); + spIn->lock(); + mLock.lock(); + // make sure that another thread did not change input state while the + // mutex is released + if ((spIn == getActiveInput_l()) && (cnt == spIn->standbyCnt())) { + break; + } + spIn->unlock(); + spIn = getActiveInput_l(); + } + // spIn is not 0 here only if the input is active + + int prevMode = mMode; + status = AudioHardwareBase::setMode(mode); + LOGV("setMode() : new %d, old %d", mMode, prevMode); + if (status == NO_ERROR) { + // activate call clock in radio when entering in call or ringtone mode + if (prevMode == AudioSystem::MODE_NORMAL) + { + if ((!mActivatedCP) && (mSecRilLibHandle) && (connectRILDIfRequired() == OK)) { + setCallClockSync(mRilClient, SOUND_CLOCK_START); + mActivatedCP = true; + } + } + + if (mMode == AudioSystem::MODE_IN_CALL && !mInCallAudioMode) { + if (spOut != 0) { + LOGV("setMode() in call force output standby"); + spOut->doStandby_l(); + } + if (spIn != 0) { + LOGV("setMode() in call force input standby"); + spIn->doStandby_l(); + } + + LOGV("setMode() openPcmOut_l()"); + openPcmOut_l(); + openMixer_l(); + setInputSource_l(AUDIO_SOURCE_DEFAULT); + mInCallAudioMode = true; + } + if (mMode == AudioSystem::MODE_NORMAL && mInCallAudioMode) { + setInputSource_l(mInputSource); + if (mMixer != NULL) { + TRACE_DRIVER_IN(DRV_MIXER_GET) + struct mixer_ctl *ctl= mixer_get_control(mMixer, "Playback Path", 0); + TRACE_DRIVER_OUT + if (ctl != NULL) { + LOGV("setMode() reset Playback Path to RCV"); + TRACE_DRIVER_IN(DRV_MIXER_SEL) + mixer_ctl_select(ctl, "RCV"); + TRACE_DRIVER_OUT + } + } + LOGV("setMode() closePcmOut_l()"); + closeMixer_l(); + closePcmOut_l(); + + if (spOut != 0) { + LOGV("setMode() off call force output standby"); + spOut->doStandby_l(); + } + if (spIn != 0) { + LOGV("setMode() off call force input standby"); + spIn->doStandby_l(); + } + + mInCallAudioMode = false; + } + + if (mMode == AudioSystem::MODE_NORMAL) { + if(mActivatedCP) + mActivatedCP = false; + } + } + + if (spIn != 0) { + spIn->unlock(); + } + if (spOut != 0) { + spOut->unlock(); + } + + return status; +} + +status_t AudioHardware::setMicMute(bool state) +{ + LOGV("setMicMute(%d) mMicMute %d", state, mMicMute); + sp spIn; + { + AutoMutex lock(mLock); + if (mMicMute != state) { + mMicMute = state; + // in call mute is handled by RIL + if (mMode != AudioSystem::MODE_IN_CALL) { + spIn = getActiveInput_l(); + } + } + } + + if (spIn != 0) { + spIn->standby(); + } + + return NO_ERROR; +} + +status_t AudioHardware::getMicMute(bool* state) +{ + *state = mMicMute; + return NO_ERROR; +} + +status_t AudioHardware::setParameters(const String8& keyValuePairs) +{ + AudioParameter param = AudioParameter(keyValuePairs); + String8 value; + String8 key; + const char BT_NREC_KEY[] = "bt_headset_nrec"; + const char BT_NREC_VALUE_ON[] = "on"; + const char TTY_MODE_KEY[] = "tty_mode"; + const char TTY_MODE_VALUE_OFF[] = "tty_off"; + const char TTY_MODE_VALUE_VCO[] = "tty_vco"; + const char TTY_MODE_VALUE_HCO[] = "tty_hco"; + const char TTY_MODE_VALUE_FULL[] = "tty_full"; + + key = String8(BT_NREC_KEY); + if (param.get(key, value) == NO_ERROR) { + if (value == BT_NREC_VALUE_ON) { + mBluetoothNrec = true; + } else { + mBluetoothNrec = false; + LOGD("Turning noise reduction and echo cancellation off for BT " + "headset"); + } + param.remove(String8(BT_NREC_KEY)); + } + + key = String8(TTY_MODE_KEY); + if (param.get(key, value) == NO_ERROR) { + int ttyMode; + if (value == TTY_MODE_VALUE_OFF) { + ttyMode = TTY_MODE_OFF; + } else if (value == TTY_MODE_VALUE_VCO) { + ttyMode = TTY_MODE_VCO; + } else if (value == TTY_MODE_VALUE_HCO) { + ttyMode = TTY_MODE_HCO; + } else if (value == TTY_MODE_VALUE_FULL) { + ttyMode = TTY_MODE_FULL; + } else { + return BAD_VALUE; + } + + if (ttyMode != mTTYMode) { + LOGV("new tty mode %d", ttyMode); + mTTYMode = ttyMode; + if (mOutput != 0 && mMode == AudioSystem::MODE_IN_CALL) { + setIncallPath_l(mOutput->device()); + } + } + param.remove(String8(TTY_MODE_KEY)); + } + + return NO_ERROR; +} + +String8 AudioHardware::getParameters(const String8& keys) +{ + AudioParameter request = AudioParameter(keys); + AudioParameter reply = AudioParameter(); + + LOGV("getParameters() %s", keys.string()); + + return reply.toString(); +} + +size_t AudioHardware::getInputBufferSize(uint32_t sampleRate, int format, int channelCount) +{ + if (format != AudioSystem::PCM_16_BIT) { + LOGW("getInputBufferSize bad format: %d", format); + return 0; + } + if (channelCount < 1 || channelCount > 2) { + LOGW("getInputBufferSize bad channel count: %d", channelCount); + return 0; + } + if (sampleRate != 8000 && sampleRate != 11025 && sampleRate != 16000 && + sampleRate != 22050 && sampleRate != 44100) { + LOGW("getInputBufferSize bad sample rate: %d", sampleRate); + return 0; + } + + return AudioStreamInALSA::getBufferSize(sampleRate, channelCount); +} + + +status_t AudioHardware::setVoiceVolume(float volume) +{ + LOGD("### setVoiceVolume"); + + AutoMutex lock(mLock); + if ( (AudioSystem::MODE_IN_CALL == mMode) && (mSecRilLibHandle) && + (connectRILDIfRequired() == OK) ) { + + uint32_t device = AudioSystem::DEVICE_OUT_EARPIECE; + if (mOutput != 0) { + device = mOutput->device(); + } + int int_volume = (int)(volume * 5); + SoundType type; + + LOGD("### route(%d) call volume(%f)", device, volume); + switch (device) { + case AudioSystem::DEVICE_OUT_EARPIECE: + LOGD("### earpiece call volume"); + type = SOUND_TYPE_VOICE; + break; + + case AudioSystem::DEVICE_OUT_SPEAKER: + LOGD("### speaker call volume"); + type = SOUND_TYPE_SPEAKER; + break; + + case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO: + case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET: + case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT: + LOGD("### bluetooth call volume"); + type = SOUND_TYPE_BTVOICE; + break; + + case AudioSystem::DEVICE_OUT_WIRED_HEADSET: + case AudioSystem::DEVICE_OUT_WIRED_HEADPHONE: // Use receive path with 3 pole headset. + LOGD("### headset call volume"); + type = SOUND_TYPE_HEADSET; + break; + + default: + LOGW("### Call volume setting error!!!0x%08x \n", device); + type = SOUND_TYPE_VOICE; + break; + } + setCallVolume(mRilClient, type, int_volume); + } + + return NO_ERROR; +} + +status_t AudioHardware::setMasterVolume(float volume) +{ + LOGV("Set master volume to %f.\n", volume); + // We return an error code here to let the audioflinger do in-software + // volume on top of the maximum volume that we set through the SND API. + // return error - software mixer will handle it + return -1; +} + +static const int kDumpLockRetries = 50; +static const int kDumpLockSleep = 20000; + +static bool tryLock(Mutex& mutex) +{ + bool locked = false; + for (int i = 0; i < kDumpLockRetries; ++i) { + if (mutex.tryLock() == NO_ERROR) { + locked = true; + break; + } + usleep(kDumpLockSleep); + } + return locked; +} + +status_t AudioHardware::dump(int fd, const Vector& args) +{ + const size_t SIZE = 256; + char buffer[SIZE]; + String8 result; + + bool locked = tryLock(mLock); + if (!locked) { + snprintf(buffer, SIZE, "\n\tAudioHardware maybe deadlocked\n"); + } else { + mLock.unlock(); + } + + snprintf(buffer, SIZE, "\tInit %s\n", (mInit) ? "OK" : "Failed"); + result.append(buffer); + snprintf(buffer, SIZE, "\tMic Mute %s\n", (mMicMute) ? "ON" : "OFF"); + result.append(buffer); + snprintf(buffer, SIZE, "\tmPcm: %p\n", mPcm); + result.append(buffer); + snprintf(buffer, SIZE, "\tmPcmOpenCnt: %d\n", mPcmOpenCnt); + result.append(buffer); + snprintf(buffer, SIZE, "\tmMixer: %p\n", mMixer); + result.append(buffer); + snprintf(buffer, SIZE, "\tmMixerOpenCnt: %d\n", mMixerOpenCnt); + result.append(buffer); + snprintf(buffer, SIZE, "\tIn Call Audio Mode %s\n", + (mInCallAudioMode) ? "ON" : "OFF"); + result.append(buffer); + snprintf(buffer, SIZE, "\tInput source %d\n", mInputSource); + result.append(buffer); + snprintf(buffer, SIZE, "\tmSecRilLibHandle: %p\n", mSecRilLibHandle); + result.append(buffer); + snprintf(buffer, SIZE, "\tmRilClient: %p\n", mRilClient); + result.append(buffer); + snprintf(buffer, SIZE, "\tCP %s\n", + (mActivatedCP) ? "Activated" : "Deactivated"); + result.append(buffer); + snprintf(buffer, SIZE, "\tmDriverOp: %d\n", mDriverOp); + result.append(buffer); + + snprintf(buffer, SIZE, "\n\tmOutput %p dump:\n", mOutput.get()); + result.append(buffer); + write(fd, result.string(), result.size()); + if (mOutput != 0) { + mOutput->dump(fd, args); + } + + snprintf(buffer, SIZE, "\n\t%d inputs opened:\n", mInputs.size()); + write(fd, buffer, strlen(buffer)); + for (size_t i = 0; i < mInputs.size(); i++) { + snprintf(buffer, SIZE, "\t- input %d dump:\n", i); + write(fd, buffer, strlen(buffer)); + mInputs[i]->dump(fd, args); + } + + return NO_ERROR; +} + +status_t AudioHardware::setIncallPath_l(uint32_t device) +{ + LOGV("setIncallPath_l: device %x", device); + + // Setup sound path for CP clocking + if ((mSecRilLibHandle) && + (connectRILDIfRequired() == OK)) { + + if (mMode == AudioSystem::MODE_IN_CALL) { + LOGD("### incall mode route (%d)", device); + AudioPath path; + switch(device){ + case AudioSystem::DEVICE_OUT_EARPIECE: + LOGD("### incall mode earpiece route"); + path = SOUND_AUDIO_PATH_HANDSET; + break; + + case AudioSystem::DEVICE_OUT_SPEAKER: + LOGD("### incall mode speaker route"); + path = SOUND_AUDIO_PATH_SPEAKER; + break; + + case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO: + case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET: + case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT: + LOGD("### incall mode bluetooth route %s NR", mBluetoothNrec ? "" : "NO"); + if (mBluetoothNrec) { + path = SOUND_AUDIO_PATH_BLUETOOTH; + } else { + path = SOUND_AUDIO_PATH_BLUETOOTH_NO_NR; + } + break; + + case AudioSystem::DEVICE_OUT_WIRED_HEADPHONE : + LOGD("### incall mode headphone route"); + path = SOUND_AUDIO_PATH_HEADPHONE; + break; + case AudioSystem::DEVICE_OUT_WIRED_HEADSET : + LOGD("### incall mode headset route"); + path = SOUND_AUDIO_PATH_HEADSET; + break; + default: + LOGW("### incall mode Error!! route = [%d]", device); + path = SOUND_AUDIO_PATH_HANDSET; + break; + } + + setCallAudioPath(mRilClient, path); + + if (mMixer != NULL) { + TRACE_DRIVER_IN(DRV_MIXER_GET) + struct mixer_ctl *ctl= mixer_get_control(mMixer, "Voice Call Path", 0); + TRACE_DRIVER_OUT + LOGE_IF(ctl == NULL, "setIncallPath_l() could not get mixer ctl"); + if (ctl != NULL) { + LOGV("setIncallPath_l() Voice Call Path, (%x)", device); + TRACE_DRIVER_IN(DRV_MIXER_SEL) + mixer_ctl_select(ctl, getVoiceRouteFromDevice(device)); + TRACE_DRIVER_OUT + } + } + } + } + return NO_ERROR; +} + +struct pcm *AudioHardware::openPcmOut_l() +{ + LOGD("openPcmOut_l() mPcmOpenCnt: %d", mPcmOpenCnt); + if (mPcmOpenCnt++ == 0) { + if (mPcm != NULL) { + LOGE("openPcmOut_l() mPcmOpenCnt == 0 and mPcm == %p\n", mPcm); + mPcmOpenCnt--; + return NULL; + } + unsigned flags = PCM_OUT; + + flags |= (AUDIO_HW_OUT_PERIOD_MULT - 1) << PCM_PERIOD_SZ_SHIFT; + flags |= (AUDIO_HW_OUT_PERIOD_CNT - PCM_PERIOD_CNT_MIN) << PCM_PERIOD_CNT_SHIFT; + + TRACE_DRIVER_IN(DRV_PCM_OPEN) + mPcm = pcm_open(flags); + TRACE_DRIVER_OUT + if (!pcm_ready(mPcm)) { + LOGE("openPcmOut_l() cannot open pcm_out driver: %s\n", pcm_error(mPcm)); + TRACE_DRIVER_IN(DRV_PCM_CLOSE) + pcm_close(mPcm); + TRACE_DRIVER_OUT + mPcmOpenCnt--; + mPcm = NULL; + } + } + return mPcm; +} + +void AudioHardware::closePcmOut_l() +{ + LOGD("closePcmOut_l() mPcmOpenCnt: %d", mPcmOpenCnt); + if (mPcmOpenCnt == 0) { + LOGE("closePcmOut_l() mPcmOpenCnt == 0"); + return; + } + + if (--mPcmOpenCnt == 0) { + TRACE_DRIVER_IN(DRV_PCM_CLOSE) + pcm_close(mPcm); + TRACE_DRIVER_OUT + mPcm = NULL; + } +} + +struct mixer *AudioHardware::openMixer_l() +{ + LOGV("openMixer_l() mMixerOpenCnt: %d", mMixerOpenCnt); + if (mMixerOpenCnt++ == 0) { + if (mMixer != NULL) { + LOGE("openMixer_l() mMixerOpenCnt == 0 and mMixer == %p\n", mMixer); + mMixerOpenCnt--; + return NULL; + } + TRACE_DRIVER_IN(DRV_MIXER_OPEN) + mMixer = mixer_open(); + TRACE_DRIVER_OUT + if (mMixer == NULL) { + LOGE("openMixer_l() cannot open mixer"); + mMixerOpenCnt--; + return NULL; + } + } + return mMixer; +} + +void AudioHardware::closeMixer_l() +{ + LOGV("closeMixer_l() mMixerOpenCnt: %d", mMixerOpenCnt); + if (mMixerOpenCnt == 0) { + LOGE("closeMixer_l() mMixerOpenCnt == 0"); + return; + } + + if (--mMixerOpenCnt == 0) { + TRACE_DRIVER_IN(DRV_MIXER_CLOSE) + mixer_close(mMixer); + TRACE_DRIVER_OUT + mMixer = NULL; + } +} + +const char *AudioHardware::getOutputRouteFromDevice(uint32_t device) +{ + switch (device) { + case AudioSystem::DEVICE_OUT_EARPIECE: + return "RCV"; + case AudioSystem::DEVICE_OUT_SPEAKER: + if (mMode == AudioSystem::MODE_RINGTONE) return "RING_SPK"; + else return "SPK"; + case AudioSystem::DEVICE_OUT_WIRED_HEADPHONE: + if (mMode == AudioSystem::MODE_RINGTONE) return "RING_NO_MIC"; + else return "HP_NO_MIC"; + case AudioSystem::DEVICE_OUT_WIRED_HEADSET: + if (mMode == AudioSystem::MODE_RINGTONE) return "RING_HP"; + else return "HP"; + case (AudioSystem::DEVICE_OUT_SPEAKER|AudioSystem::DEVICE_OUT_WIRED_HEADPHONE): + case (AudioSystem::DEVICE_OUT_SPEAKER|AudioSystem::DEVICE_OUT_WIRED_HEADSET): + if (mMode == AudioSystem::MODE_RINGTONE) return "RING_SPK_HP"; + else return "SPK_HP"; + case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO: + case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET: + case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT: + return "BT"; + default: + return "OFF"; + } +} + +const char *AudioHardware::getVoiceRouteFromDevice(uint32_t device) +{ + switch (device) { + case AudioSystem::DEVICE_OUT_EARPIECE: + return "RCV"; + case AudioSystem::DEVICE_OUT_SPEAKER: + return "SPK"; + case AudioSystem::DEVICE_OUT_WIRED_HEADPHONE: + case AudioSystem::DEVICE_OUT_WIRED_HEADSET: + switch (mTTYMode) { + case TTY_MODE_VCO: + return "TTY_VCO"; + case TTY_MODE_HCO: + return "TTY_HCO"; + case TTY_MODE_FULL: + return "TTY_FULL"; + case TTY_MODE_OFF: + default: + if (device == AudioSystem::DEVICE_OUT_WIRED_HEADPHONE) { + return "HP_NO_MIC"; + } else { + return "HP"; + } + } + case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO: + case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET: + case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT: + return "BT"; + default: + return "OFF"; + } +} + +const char *AudioHardware::getInputRouteFromDevice(uint32_t device) +{ + if (mMicMute) { + return "MIC OFF"; + } + + switch (device) { + case AudioSystem::DEVICE_IN_BUILTIN_MIC: + return "Main Mic"; + case AudioSystem::DEVICE_IN_WIRED_HEADSET: + return "Hands Free Mic"; + case AudioSystem::DEVICE_IN_BLUETOOTH_SCO_HEADSET: + return "BT Sco Mic"; + default: + return "MIC OFF"; + } +} + +uint32_t AudioHardware::getInputSampleRate(uint32_t sampleRate) +{ + uint32_t i; + uint32_t prevDelta; + uint32_t delta; + + for (i = 0, prevDelta = 0xFFFFFFFF; i < sizeof(inputSamplingRates)/sizeof(uint32_t); i++, prevDelta = delta) { + delta = abs(sampleRate - inputSamplingRates[i]); + if (delta > prevDelta) break; + } + // i is always > 0 here + return inputSamplingRates[i-1]; +} + +// getActiveInput_l() must be called with mLock held +sp AudioHardware::getActiveInput_l() +{ + sp< AudioHardware::AudioStreamInALSA> spIn; + + for (size_t i = 0; i < mInputs.size(); i++) { + // return first input found not being in standby mode + // as only one input can be in this state + if (!mInputs[i]->checkStandby()) { + spIn = mInputs[i]; + break; + } + } + + return spIn; +} + +status_t AudioHardware::setInputSource_l(audio_source source) +{ + LOGV("setInputSource_l(%d)", source); + if (source != mInputSource) { + if ((source == AUDIO_SOURCE_DEFAULT) || (mMode != AudioSystem::MODE_IN_CALL)) { + if (mMixer) { + TRACE_DRIVER_IN(DRV_MIXER_GET) + struct mixer_ctl *ctl= mixer_get_control(mMixer, "Input Source", 0); + TRACE_DRIVER_OUT + if (ctl == NULL) { + return NO_INIT; + } + const char* sourceName; + switch (source) { + case AUDIO_SOURCE_DEFAULT: // intended fall-through + case AUDIO_SOURCE_MIC: + sourceName = inputPathNameDefault; + break; + case AUDIO_SOURCE_VOICE_COMMUNICATION: + sourceName = inputPathNameVoiceCommunication; + break; + case AUDIO_SOURCE_CAMCORDER: + sourceName = inputPathNameCamcorder; + break; + case AUDIO_SOURCE_VOICE_RECOGNITION: + sourceName = inputPathNameVoiceRecognition; + break; + case AUDIO_SOURCE_VOICE_UPLINK: // intended fall-through + case AUDIO_SOURCE_VOICE_DOWNLINK: // intended fall-through + case AUDIO_SOURCE_VOICE_CALL: // intended fall-through + default: + return NO_INIT; + } + LOGV("mixer_ctl_select, Input Source, (%s)", sourceName); + TRACE_DRIVER_IN(DRV_MIXER_SEL) + mixer_ctl_select(ctl, sourceName); + TRACE_DRIVER_OUT + } + } + mInputSource = source; + } + + return NO_ERROR; +} + + +//------------------------------------------------------------------------------ +// AudioStreamOutALSA +//------------------------------------------------------------------------------ + +AudioHardware::AudioStreamOutALSA::AudioStreamOutALSA() : + mHardware(0), mPcm(0), mMixer(0), mRouteCtl(0), + mStandby(true), mDevices(0), mChannels(AUDIO_HW_OUT_CHANNELS), + mSampleRate(AUDIO_HW_OUT_SAMPLERATE), mBufferSize(AUDIO_HW_OUT_PERIOD_BYTES), + mDriverOp(DRV_NONE), mStandbyCnt(0), mSleepReq(false) +{ +} + +status_t AudioHardware::AudioStreamOutALSA::set( + AudioHardware* hw, uint32_t devices, int *pFormat, + uint32_t *pChannels, uint32_t *pRate) +{ + int lFormat = pFormat ? *pFormat : 0; + uint32_t lChannels = pChannels ? *pChannels : 0; + uint32_t lRate = pRate ? *pRate : 0; + + mHardware = hw; + mDevices = devices; + + // fix up defaults + if (lFormat == 0) lFormat = format(); + if (lChannels == 0) lChannels = channels(); + if (lRate == 0) lRate = sampleRate(); + + // check values + if ((lFormat != format()) || + (lChannels != channels()) || + (lRate != sampleRate())) { + if (pFormat) *pFormat = format(); + if (pChannels) *pChannels = channels(); + if (pRate) *pRate = sampleRate(); + return BAD_VALUE; + } + + if (pFormat) *pFormat = lFormat; + if (pChannels) *pChannels = lChannels; + if (pRate) *pRate = lRate; + + mChannels = lChannels; + mSampleRate = lRate; + mBufferSize = AUDIO_HW_OUT_PERIOD_BYTES; + + return NO_ERROR; +} + +AudioHardware::AudioStreamOutALSA::~AudioStreamOutALSA() +{ + standby(); +} + +ssize_t AudioHardware::AudioStreamOutALSA::write(const void* buffer, size_t bytes) +{ + // LOGV("AudioStreamOutALSA::write(%p, %u)", buffer, bytes); + status_t status = NO_INIT; + const uint8_t* p = static_cast(buffer); + int ret; + + if (mHardware == NULL) return NO_INIT; + + if (mSleepReq) { + // 10ms are always shorter than the time to reconfigure the audio path + // which is the only condition when mSleepReq would be true. + usleep(10000); + } + + { // scope for the lock + + AutoMutex lock(mLock); + + if (mStandby) { + AutoMutex hwLock(mHardware->lock()); + + LOGD("AudioHardware pcm playback is exiting standby."); + acquire_wake_lock (PARTIAL_WAKE_LOCK, "AudioOutLock"); + + sp spIn = mHardware->getActiveInput_l(); + while (spIn != 0) { + int cnt = spIn->prepareLock(); + mHardware->lock().unlock(); + // Mutex acquisition order is always out -> in -> hw + spIn->lock(); + mHardware->lock().lock(); + // make sure that another thread did not change input state + // while the mutex is released + if ((spIn == mHardware->getActiveInput_l()) && + (cnt == spIn->standbyCnt())) { + LOGV("AudioStreamOutALSA::write() force input standby"); + spIn->close_l(); + break; + } + spIn->unlock(); + spIn = mHardware->getActiveInput_l(); + } + // spIn is not 0 here only if the input was active and has been + // closed above + + // open output before input + open_l(); + + if (spIn != 0) { + if (spIn->open_l() != NO_ERROR) { + spIn->doStandby_l(); + } + spIn->unlock(); + } + if (mPcm == NULL) { + release_wake_lock("AudioOutLock"); + goto Error; + } + mStandby = false; + } + + TRACE_DRIVER_IN(DRV_PCM_WRITE) + ret = pcm_write(mPcm,(void*) p, bytes); + TRACE_DRIVER_OUT + + if (ret == 0) { + return bytes; + } + LOGW("write error: %d", errno); + status = -errno; + } +Error: + + standby(); + + // Simulate audio output timing in case of error + usleep((((bytes * 1000) / frameSize()) * 1000) / sampleRate()); + + return status; +} + +status_t AudioHardware::AudioStreamOutALSA::standby() +{ + if (mHardware == NULL) return NO_INIT; + + AutoMutex lock(mLock); + + { // scope for the AudioHardware lock + AutoMutex hwLock(mHardware->lock()); + + doStandby_l(); + } + + return NO_ERROR; +} + +void AudioHardware::AudioStreamOutALSA::doStandby_l() +{ + mStandbyCnt++; + + if (!mStandby) { + LOGD("AudioHardware pcm playback is going to standby."); + release_wake_lock("AudioOutLock"); + mStandby = true; + } + + close_l(); +} + +void AudioHardware::AudioStreamOutALSA::close_l() +{ + if (mMixer) { + mHardware->closeMixer_l(); + mMixer = NULL; + mRouteCtl = NULL; + } + if (mPcm) { + mHardware->closePcmOut_l(); + mPcm = NULL; + } +} + +status_t AudioHardware::AudioStreamOutALSA::open_l() +{ + LOGV("open pcm_out driver"); + mPcm = mHardware->openPcmOut_l(); + if (mPcm == NULL) { + return NO_INIT; + } + + mMixer = mHardware->openMixer_l(); + if (mMixer) { + LOGV("open playback normal"); + TRACE_DRIVER_IN(DRV_MIXER_GET) + mRouteCtl = mixer_get_control(mMixer, "Playback Path", 0); + TRACE_DRIVER_OUT + } + if (mHardware->mode() != AudioSystem::MODE_IN_CALL) { + const char *route = mHardware->getOutputRouteFromDevice(mDevices); + LOGV("write() wakeup setting route %s", route); + if (mRouteCtl) { + TRACE_DRIVER_IN(DRV_MIXER_SEL) + mixer_ctl_select(mRouteCtl, route); + TRACE_DRIVER_OUT + } + } + return NO_ERROR; +} + +status_t AudioHardware::AudioStreamOutALSA::dump(int fd, const Vector& args) +{ + const size_t SIZE = 256; + char buffer[SIZE]; + String8 result; + + bool locked = tryLock(mLock); + if (!locked) { + snprintf(buffer, SIZE, "\n\t\tAudioStreamOutALSA maybe deadlocked\n"); + } else { + mLock.unlock(); + } + + snprintf(buffer, SIZE, "\t\tmHardware: %p\n", mHardware); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmPcm: %p\n", mPcm); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmMixer: %p\n", mMixer); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmRouteCtl: %p\n", mRouteCtl); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tStandby %s\n", (mStandby) ? "ON" : "OFF"); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmDevices: 0x%08x\n", mDevices); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmChannels: 0x%08x\n", mChannels); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmSampleRate: %d\n", mSampleRate); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmBufferSize: %d\n", mBufferSize); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmDriverOp: %d\n", mDriverOp); + result.append(buffer); + + ::write(fd, result.string(), result.size()); + + return NO_ERROR; +} + +bool AudioHardware::AudioStreamOutALSA::checkStandby() +{ + return mStandby; +} + +status_t AudioHardware::AudioStreamOutALSA::setParameters(const String8& keyValuePairs) +{ + AudioParameter param = AudioParameter(keyValuePairs); + status_t status = NO_ERROR; + int device; + LOGD("AudioStreamOutALSA::setParameters() %s", keyValuePairs.string()); + + if (mHardware == NULL) return NO_INIT; + + { + AutoMutex lock(mLock); + + if (param.getInt(String8(AudioParameter::keyRouting), device) == NO_ERROR) + { + if (device != 0) { + AutoMutex hwLock(mHardware->lock()); + + if (mDevices != (uint32_t)device) { + mDevices = (uint32_t)device; + if (mHardware->mode() != AudioSystem::MODE_IN_CALL) { + doStandby_l(); + } + } + if (mHardware->mode() == AudioSystem::MODE_IN_CALL) { + mHardware->setIncallPath_l(device); + } + } + param.remove(String8(AudioParameter::keyRouting)); + } + } + + if (param.size()) { + status = BAD_VALUE; + } + + + return status; + +} + +String8 AudioHardware::AudioStreamOutALSA::getParameters(const String8& keys) +{ + AudioParameter param = AudioParameter(keys); + String8 value; + String8 key = String8(AudioParameter::keyRouting); + + if (param.get(key, value) == NO_ERROR) { + param.addInt(key, (int)mDevices); + } + + LOGV("AudioStreamOutALSA::getParameters() %s", param.toString().string()); + return param.toString(); +} + +status_t AudioHardware::AudioStreamOutALSA::getRenderPosition(uint32_t *dspFrames) +{ + //TODO + return INVALID_OPERATION; +} + +int AudioHardware::AudioStreamOutALSA::prepareLock() +{ + // request sleep next time write() is called so that caller can acquire + // mLock + mSleepReq = true; + return mStandbyCnt; +} + +void AudioHardware::AudioStreamOutALSA::lock() +{ + mLock.lock(); + mSleepReq = false; +} + +void AudioHardware::AudioStreamOutALSA::unlock() { + mLock.unlock(); +} + +//------------------------------------------------------------------------------ +// AudioStreamInALSA +//------------------------------------------------------------------------------ + +AudioHardware::AudioStreamInALSA::AudioStreamInALSA() : + mHardware(0), mPcm(0), mMixer(0), mRouteCtl(0), + mStandby(true), mDevices(0), mChannels(AUDIO_HW_IN_CHANNELS), mChannelCount(1), + mSampleRate(AUDIO_HW_IN_SAMPLERATE), mBufferSize(AUDIO_HW_IN_PERIOD_BYTES), + mDownSampler(NULL), mReadStatus(NO_ERROR), mDriverOp(DRV_NONE), + mStandbyCnt(0), mSleepReq(false) +{ +} + +status_t AudioHardware::AudioStreamInALSA::set( + AudioHardware* hw, uint32_t devices, int *pFormat, + uint32_t *pChannels, uint32_t *pRate, AudioSystem::audio_in_acoustics acoustics) +{ + if (pFormat == 0 || *pFormat != AUDIO_HW_IN_FORMAT) { + *pFormat = AUDIO_HW_IN_FORMAT; + return BAD_VALUE; + } + if (pRate == 0) { + return BAD_VALUE; + } + uint32_t rate = AudioHardware::getInputSampleRate(*pRate); + if (rate != *pRate) { + *pRate = rate; + return BAD_VALUE; + } + + if (pChannels == 0 || (*pChannels != AudioSystem::CHANNEL_IN_MONO && + *pChannels != AudioSystem::CHANNEL_IN_STEREO)) { + *pChannels = AUDIO_HW_IN_CHANNELS; + return BAD_VALUE; + } + + mHardware = hw; + + LOGV("AudioStreamInALSA::set(%d, %d, %u)", *pFormat, *pChannels, *pRate); + + mBufferSize = getBufferSize(*pRate, AudioSystem::popCount(*pChannels)); + mDevices = devices; + mChannels = *pChannels; + mChannelCount = AudioSystem::popCount(mChannels); + mSampleRate = rate; + if (mSampleRate != AUDIO_HW_OUT_SAMPLERATE) { + mDownSampler = new AudioHardware::DownSampler(mSampleRate, + mChannelCount, + AUDIO_HW_IN_PERIOD_SZ, + this); + status_t status = mDownSampler->initCheck(); + if (status != NO_ERROR) { + delete mDownSampler; + LOGW("AudioStreamInALSA::set() downsampler init failed: %d", status); + return status; + } + + mPcmIn = new int16_t[AUDIO_HW_IN_PERIOD_SZ * mChannelCount]; + } + return NO_ERROR; +} + +AudioHardware::AudioStreamInALSA::~AudioStreamInALSA() +{ + standby(); + if (mDownSampler != NULL) { + delete mDownSampler; + if (mPcmIn != NULL) { + delete[] mPcmIn; + } + } +} + +ssize_t AudioHardware::AudioStreamInALSA::read(void* buffer, ssize_t bytes) +{ + // LOGV("AudioStreamInALSA::read(%p, %u)", buffer, bytes); + status_t status = NO_INIT; + int ret; + + if (mHardware == NULL) return NO_INIT; + + if (mSleepReq) { + // 10ms are always shorter than the time to reconfigure the audio path + // which is the only condition when mSleepReq would be true. + usleep(10000); + } + + { // scope for the lock + AutoMutex lock(mLock); + + if (mStandby) { + AutoMutex hwLock(mHardware->lock()); + + LOGD("AudioHardware pcm capture is exiting standby."); + acquire_wake_lock (PARTIAL_WAKE_LOCK, "AudioInLock"); + + sp spOut = mHardware->output(); + while (spOut != 0) { + if (!spOut->checkStandby()) { + int cnt = spOut->prepareLock(); + mHardware->lock().unlock(); + mLock.unlock(); + // Mutex acquisition order is always out -> in -> hw + spOut->lock(); + mLock.lock(); + mHardware->lock().lock(); + // make sure that another thread did not change output state + // while the mutex is released + if ((spOut == mHardware->output()) && (cnt == spOut->standbyCnt())) { + LOGV("AudioStreamInALSA::read() force output standby"); + spOut->close_l(); + break; + } + spOut->unlock(); + spOut = mHardware->output(); + } else { + spOut.clear(); + } + } + // spOut is not 0 here only if the output was active and has been + // closed above + + // open output before input + if (spOut != 0) { + if (spOut->open_l() != NO_ERROR) { + spOut->doStandby_l(); + } + spOut->unlock(); + } + + open_l(); + + if (mPcm == NULL) { + release_wake_lock("AudioInLock"); + goto Error; + } + mStandby = false; + } + + + if (mDownSampler != NULL) { + size_t frames = bytes / frameSize(); + size_t framesIn = 0; + mReadStatus = 0; + do { + size_t outframes = frames - framesIn; + mDownSampler->resample( + (int16_t *)buffer + (framesIn * mChannelCount), + &outframes); + framesIn += outframes; + } while ((framesIn < frames) && mReadStatus == 0); + ret = mReadStatus; + bytes = framesIn * frameSize(); + } else { + TRACE_DRIVER_IN(DRV_PCM_READ) + ret = pcm_read(mPcm, buffer, bytes); + TRACE_DRIVER_OUT + } + + if (ret == 0) { + return bytes; + } + + LOGW("read error: %d", ret); + status = ret; + } + +Error: + + standby(); + + // Simulate audio output timing in case of error + usleep((((bytes * 1000) / frameSize()) * 1000) / sampleRate()); + + return status; +} + +status_t AudioHardware::AudioStreamInALSA::standby() +{ + if (mHardware == NULL) return NO_INIT; + + AutoMutex lock(mLock); + + { // scope for AudioHardware lock + AutoMutex hwLock(mHardware->lock()); + + doStandby_l(); + } + return NO_ERROR; +} + +void AudioHardware::AudioStreamInALSA::doStandby_l() +{ + mStandbyCnt++; + + if (!mStandby) { + LOGD("AudioHardware pcm capture is going to standby."); + release_wake_lock("AudioInLock"); + mStandby = true; + } + close_l(); +} + +void AudioHardware::AudioStreamInALSA::close_l() +{ + if (mMixer) { + mHardware->closeMixer_l(); + mMixer = NULL; + mRouteCtl = NULL; + } + + if (mPcm) { + TRACE_DRIVER_IN(DRV_PCM_CLOSE) + pcm_close(mPcm); + TRACE_DRIVER_OUT + mPcm = NULL; + } +} + +status_t AudioHardware::AudioStreamInALSA::open_l() +{ + unsigned flags = PCM_IN; + if (mChannels == AudioSystem::CHANNEL_IN_MONO) { + flags |= PCM_MONO; + } + flags |= (AUDIO_HW_IN_PERIOD_MULT - 1) << PCM_PERIOD_SZ_SHIFT; + flags |= (AUDIO_HW_IN_PERIOD_CNT - PCM_PERIOD_CNT_MIN) + << PCM_PERIOD_CNT_SHIFT; + + LOGV("open pcm_in driver"); + TRACE_DRIVER_IN(DRV_PCM_OPEN) + mPcm = pcm_open(flags); + TRACE_DRIVER_OUT + if (!pcm_ready(mPcm)) { + LOGE("cannot open pcm_in driver: %s\n", pcm_error(mPcm)); + TRACE_DRIVER_IN(DRV_PCM_CLOSE) + pcm_close(mPcm); + TRACE_DRIVER_OUT + mPcm = NULL; + return NO_INIT; + } + + if (mDownSampler != NULL) { + mInPcmInBuf = 0; + mDownSampler->reset(); + } + + mMixer = mHardware->openMixer_l(); + if (mMixer) { + TRACE_DRIVER_IN(DRV_MIXER_GET) + mRouteCtl = mixer_get_control(mMixer, "Capture MIC Path", 0); + TRACE_DRIVER_OUT + } + + if (mHardware->mode() != AudioSystem::MODE_IN_CALL) { + const char *route = mHardware->getInputRouteFromDevice(mDevices); + LOGV("read() wakeup setting route %s", route); + if (mRouteCtl) { + TRACE_DRIVER_IN(DRV_MIXER_SEL) + mixer_ctl_select(mRouteCtl, route); + TRACE_DRIVER_OUT + } + } + + return NO_ERROR; +} + +status_t AudioHardware::AudioStreamInALSA::dump(int fd, const Vector& args) +{ + const size_t SIZE = 256; + char buffer[SIZE]; + String8 result; + + bool locked = tryLock(mLock); + if (!locked) { + snprintf(buffer, SIZE, "\n\t\tAudioStreamInALSA maybe deadlocked\n"); + } else { + mLock.unlock(); + } + + snprintf(buffer, SIZE, "\t\tmHardware: %p\n", mHardware); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmPcm: %p\n", mPcm); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmMixer: %p\n", mMixer); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tStandby %s\n", (mStandby) ? "ON" : "OFF"); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmDevices: 0x%08x\n", mDevices); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmChannels: 0x%08x\n", mChannels); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmSampleRate: %d\n", mSampleRate); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmBufferSize: %d\n", mBufferSize); + result.append(buffer); + snprintf(buffer, SIZE, "\t\tmDriverOp: %d\n", mDriverOp); + result.append(buffer); + write(fd, result.string(), result.size()); + + return NO_ERROR; +} + +bool AudioHardware::AudioStreamInALSA::checkStandby() +{ + return mStandby; +} + +status_t AudioHardware::AudioStreamInALSA::setParameters(const String8& keyValuePairs) +{ + AudioParameter param = AudioParameter(keyValuePairs); + status_t status = NO_ERROR; + int value; + + LOGD("AudioStreamInALSA::setParameters() %s", keyValuePairs.string()); + + if (mHardware == NULL) return NO_INIT; + + { + AutoMutex lock(mLock); + + if (param.getInt(String8(AudioParameter::keyInputSource), value) == NO_ERROR) { + AutoMutex hwLock(mHardware->lock()); + + mHardware->openMixer_l(); + mHardware->setInputSource_l((audio_source)value); + mHardware->closeMixer_l(); + + param.remove(String8(AudioParameter::keyInputSource)); + } + + if (param.getInt(String8(AudioParameter::keyRouting), value) == NO_ERROR) + { + if (value != 0) { + AutoMutex hwLock(mHardware->lock()); + + if (mDevices != (uint32_t)value) { + mDevices = (uint32_t)value; + if (mHardware->mode() != AudioSystem::MODE_IN_CALL) { + doStandby_l(); + } + } + } + param.remove(String8(AudioParameter::keyRouting)); + } + } + + + if (param.size()) { + status = BAD_VALUE; + } + + return status; + +} + +String8 AudioHardware::AudioStreamInALSA::getParameters(const String8& keys) +{ + AudioParameter param = AudioParameter(keys); + String8 value; + String8 key = String8(AudioParameter::keyRouting); + + if (param.get(key, value) == NO_ERROR) { + param.addInt(key, (int)mDevices); + } + + LOGV("AudioStreamInALSA::getParameters() %s", param.toString().string()); + return param.toString(); +} + +status_t AudioHardware::AudioStreamInALSA::getNextBuffer(AudioHardware::BufferProvider::Buffer* buffer) +{ + if (mPcm == NULL) { + buffer->raw = NULL; + buffer->frameCount = 0; + mReadStatus = NO_INIT; + return NO_INIT; + } + + if (mInPcmInBuf == 0) { + TRACE_DRIVER_IN(DRV_PCM_READ) + mReadStatus = pcm_read(mPcm,(void*) mPcmIn, AUDIO_HW_IN_PERIOD_SZ * frameSize()); + TRACE_DRIVER_OUT + if (mReadStatus != 0) { + buffer->raw = NULL; + buffer->frameCount = 0; + return mReadStatus; + } + mInPcmInBuf = AUDIO_HW_IN_PERIOD_SZ; + } + + buffer->frameCount = (buffer->frameCount > mInPcmInBuf) ? mInPcmInBuf : buffer->frameCount; + buffer->i16 = mPcmIn + (AUDIO_HW_IN_PERIOD_SZ - mInPcmInBuf) * mChannelCount; + + return mReadStatus; +} + +void AudioHardware::AudioStreamInALSA::releaseBuffer(Buffer* buffer) +{ + mInPcmInBuf -= buffer->frameCount; +} + +size_t AudioHardware::AudioStreamInALSA::getBufferSize(uint32_t sampleRate, int channelCount) +{ + size_t ratio; + + switch (sampleRate) { + case 8000: + case 11025: + ratio = 4; + break; + case 16000: + case 22050: + ratio = 2; + break; + case 44100: + default: + ratio = 1; + break; + } + + return (AUDIO_HW_IN_PERIOD_SZ*channelCount*sizeof(int16_t)) / ratio ; +} + +int AudioHardware::AudioStreamInALSA::prepareLock() +{ + // request sleep next time read() is called so that caller can acquire + // mLock + mSleepReq = true; + return mStandbyCnt; +} + +void AudioHardware::AudioStreamInALSA::lock() +{ + mLock.lock(); + mSleepReq = false; +} + +void AudioHardware::AudioStreamInALSA::unlock() { + mLock.unlock(); +} + +//------------------------------------------------------------------------------ +// DownSampler +//------------------------------------------------------------------------------ + +/* + * 2.30 fixed point FIR filter coefficients for conversion 44100 -> 22050. + * (Works equivalently for 22010 -> 11025 or any other halving, of course.) + * + * Transition band from about 18 kHz, passband ripple < 0.1 dB, + * stopband ripple at about -55 dB, linear phase. + * + * Design and display in MATLAB or Octave using: + * + * filter = fir1(19, 0.5); filter = round(filter * 2**30); freqz(filter * 2**-30); + */ +static const int32_t filter_22khz_coeff[] = { + 2089257, 2898328, -5820678, -10484531, + 19038724, 30542725, -50469415, -81505260, + 152544464, 478517512, 478517512, 152544464, + -81505260, -50469415, 30542725, 19038724, + -10484531, -5820678, 2898328, 2089257, +}; +#define NUM_COEFF_22KHZ (sizeof(filter_22khz_coeff) / sizeof(filter_22khz_coeff[0])) +#define OVERLAP_22KHZ (NUM_COEFF_22KHZ - 2) + +/* + * Convolution of signals A and reverse(B). (In our case, the filter response + * is symmetric, so the reversing doesn't matter.) + * A is taken to be in 0.16 fixed-point, and B is taken to be in 2.30 fixed-point. + * The answer will be in 16.16 fixed-point, unclipped. + * + * This function would probably be the prime candidate for SIMD conversion if + * you want more speed. + */ +int32_t fir_convolve(const int16_t* a, const int32_t* b, int num_samples) +{ + int32_t sum = 1 << 13; + for (int i = 0; i < num_samples; ++i) { + sum += a[i] * (b[i] >> 16); + } + return sum >> 14; +} + +/* Clip from 16.16 fixed-point to 0.16 fixed-point. */ +int16_t clip(int32_t x) +{ + if (x < -32768) { + return -32768; + } else if (x > 32767) { + return 32767; + } else { + return x; + } +} + +/* + * Convert a chunk from 44 kHz to 22 kHz. Will update num_samples_in and num_samples_out + * accordingly, since it may leave input samples in the buffer due to overlap. + * + * Input and output are taken to be in 0.16 fixed-point. + */ +void resample_2_1(int16_t* input, int16_t* output, int* num_samples_in, int* num_samples_out) +{ + if (*num_samples_in < (int)NUM_COEFF_22KHZ) { + *num_samples_out = 0; + return; + } + + int odd_smp = *num_samples_in & 0x1; + int num_samples = *num_samples_in - odd_smp - OVERLAP_22KHZ; + + for (int i = 0; i < num_samples; i += 2) { + output[i / 2] = clip(fir_convolve(input + i, filter_22khz_coeff, NUM_COEFF_22KHZ)); + } + + memmove(input, input + num_samples, (OVERLAP_22KHZ + odd_smp) * sizeof(*input)); + *num_samples_out = num_samples / 2; + *num_samples_in = OVERLAP_22KHZ + odd_smp; +} + +/* + * 2.30 fixed point FIR filter coefficients for conversion 22050 -> 16000, + * or 11025 -> 8000. + * + * Transition band from about 14 kHz, passband ripple < 0.1 dB, + * stopband ripple at about -50 dB, linear phase. + * + * Design and display in MATLAB or Octave using: + * + * filter = fir1(23, 16000 / 22050); filter = round(filter * 2**30); freqz(filter * 2**-30); + */ +static const int32_t filter_16khz_coeff[] = { + 2057290, -2973608, 1880478, 4362037, + -14639744, 18523609, -1609189, -38502470, + 78073125, -68353935, -59103896, 617555440, + 617555440, -59103896, -68353935, 78073125, + -38502470, -1609189, 18523609, -14639744, + 4362037, 1880478, -2973608, 2057290, +}; +#define NUM_COEFF_16KHZ (sizeof(filter_16khz_coeff) / sizeof(filter_16khz_coeff[0])) +#define OVERLAP_16KHZ (NUM_COEFF_16KHZ - 1) + +/* + * Convert a chunk from 22 kHz to 16 kHz. Will update num_samples_in and + * num_samples_out accordingly, since it may leave input samples in the buffer + * due to overlap. + * + * This implementation is rather ad-hoc; it first low-pass filters the data + * into a temporary buffer, and then converts chunks of 441 input samples at a + * time into 320 output samples by simple linear interpolation. A better + * implementation would use a polyphase filter bank to do these two operations + * in one step. + * + * Input and output are taken to be in 0.16 fixed-point. + */ + +#define RESAMPLE_16KHZ_SAMPLES_IN 441 +#define RESAMPLE_16KHZ_SAMPLES_OUT 320 + +void resample_441_320(int16_t* input, int16_t* output, int* num_samples_in, int* num_samples_out) +{ + const int num_blocks = (*num_samples_in - OVERLAP_16KHZ) / RESAMPLE_16KHZ_SAMPLES_IN; + if (num_blocks < 1) { + *num_samples_out = 0; + return; + } + + for (int i = 0; i < num_blocks; ++i) { + uint32_t tmp[RESAMPLE_16KHZ_SAMPLES_IN]; + for (int j = 0; j < RESAMPLE_16KHZ_SAMPLES_IN; ++j) { + tmp[j] = fir_convolve(input + i * RESAMPLE_16KHZ_SAMPLES_IN + j, + filter_16khz_coeff, + NUM_COEFF_16KHZ); + } + + const float step_float = (float)RESAMPLE_16KHZ_SAMPLES_IN / (float)RESAMPLE_16KHZ_SAMPLES_OUT; + const uint32_t step = (uint32_t)(step_float * 32768.0f + 0.5f); // 17.15 fixed point + + uint32_t in_sample_num = 0; // 17.15 fixed point + for (int j = 0; j < RESAMPLE_16KHZ_SAMPLES_OUT; ++j, in_sample_num += step) { + const uint32_t whole = in_sample_num >> 15; + const uint32_t frac = (in_sample_num & 0x7fff); // 0.15 fixed point + const int32_t s1 = tmp[whole]; + const int32_t s2 = tmp[whole + 1]; + *output++ = clip(s1 + (((s2 - s1) * (int32_t)frac) >> 15)); + } + + } + + const int samples_consumed = num_blocks * RESAMPLE_16KHZ_SAMPLES_IN; + memmove(input, input + samples_consumed, (*num_samples_in - samples_consumed) * sizeof(*input)); + *num_samples_in -= samples_consumed; + *num_samples_out = RESAMPLE_16KHZ_SAMPLES_OUT * num_blocks; +} + + +AudioHardware::DownSampler::DownSampler(uint32_t outSampleRate, + uint32_t channelCount, + uint32_t frameCount, + AudioHardware::BufferProvider* provider) + : mStatus(NO_INIT), mProvider(provider), mSampleRate(outSampleRate), + mChannelCount(channelCount), mFrameCount(frameCount), + mInLeft(NULL), mInRight(NULL), mTmpLeft(NULL), mTmpRight(NULL), + mTmp2Left(NULL), mTmp2Right(NULL), mOutLeft(NULL), mOutRight(NULL) + +{ + LOGV("AudioHardware::DownSampler() cstor %p SR %d channels %d frames %d", + this, mSampleRate, mChannelCount, mFrameCount); + + if (mSampleRate != 8000 && mSampleRate != 11025 && mSampleRate != 16000 && + mSampleRate != 22050) { + LOGW("AudioHardware::DownSampler cstor: bad sampling rate: %d", mSampleRate); + return; + } + + mInLeft = new int16_t[mFrameCount]; + mInRight = new int16_t[mFrameCount]; + mTmpLeft = new int16_t[mFrameCount]; + mTmpRight = new int16_t[mFrameCount]; + mTmp2Left = new int16_t[mFrameCount]; + mTmp2Right = new int16_t[mFrameCount]; + mOutLeft = new int16_t[mFrameCount]; + mOutRight = new int16_t[mFrameCount]; + + mStatus = NO_ERROR; +} + +AudioHardware::DownSampler::~DownSampler() +{ + if (mInLeft) delete[] mInLeft; + if (mInRight) delete[] mInRight; + if (mTmpLeft) delete[] mTmpLeft; + if (mTmpRight) delete[] mTmpRight; + if (mTmp2Left) delete[] mTmp2Left; + if (mTmp2Right) delete[] mTmp2Right; + if (mOutLeft) delete[] mOutLeft; + if (mOutRight) delete[] mOutRight; +} + +void AudioHardware::DownSampler::reset() +{ + mInInBuf = 0; + mInTmpBuf = 0; + mInTmp2Buf = 0; + mOutBufPos = 0; + mInOutBuf = 0; +} + + +int AudioHardware::DownSampler::resample(int16_t* out, size_t *outFrameCount) +{ + if (mStatus != NO_ERROR) { + return mStatus; + } + + if (out == NULL || outFrameCount == NULL) { + return BAD_VALUE; + } + + int16_t *outLeft = mTmp2Left; + int16_t *outRight = mTmp2Left; + if (mSampleRate == 22050) { + outLeft = mTmpLeft; + outRight = mTmpRight; + } else if (mSampleRate == 8000){ + outLeft = mOutLeft; + outRight = mOutRight; + } + + int outFrames = 0; + int remaingFrames = *outFrameCount; + + if (mInOutBuf) { + int frames = (remaingFrames > mInOutBuf) ? mInOutBuf : remaingFrames; + + for (int i = 0; i < frames; ++i) { + out[i] = outLeft[mOutBufPos + i]; + } + if (mChannelCount == 2) { + for (int i = 0; i < frames; ++i) { + out[i * 2] = outLeft[mOutBufPos + i]; + out[i * 2 + 1] = outRight[mOutBufPos + i]; + } + } + remaingFrames -= frames; + mInOutBuf -= frames; + mOutBufPos += frames; + outFrames += frames; + } + + while (remaingFrames) { + LOGW_IF((mInOutBuf != 0), "mInOutBuf should be 0 here"); + + AudioHardware::BufferProvider::Buffer buf; + buf.frameCount = mFrameCount - mInInBuf; + int ret = mProvider->getNextBuffer(&buf); + if (buf.raw == NULL) { + *outFrameCount = outFrames; + return ret; + } + + for (size_t i = 0; i < buf.frameCount; ++i) { + mInLeft[i + mInInBuf] = buf.i16[i]; + } + if (mChannelCount == 2) { + for (size_t i = 0; i < buf.frameCount; ++i) { + mInLeft[i + mInInBuf] = buf.i16[i * 2]; + mInRight[i + mInInBuf] = buf.i16[i * 2 + 1]; + } + } + mInInBuf += buf.frameCount; + mProvider->releaseBuffer(&buf); + + /* 44010 -> 22050 */ + { + int samples_in_left = mInInBuf; + int samples_out_left; + resample_2_1(mInLeft, mTmpLeft + mInTmpBuf, &samples_in_left, &samples_out_left); + + if (mChannelCount == 2) { + int samples_in_right = mInInBuf; + int samples_out_right; + resample_2_1(mInRight, mTmpRight + mInTmpBuf, &samples_in_right, &samples_out_right); + } + + mInInBuf = samples_in_left; + mInTmpBuf += samples_out_left; + mInOutBuf = samples_out_left; + } + + if (mSampleRate == 11025 || mSampleRate == 8000) { + /* 22050 - > 11025 */ + int samples_in_left = mInTmpBuf; + int samples_out_left; + resample_2_1(mTmpLeft, mTmp2Left + mInTmp2Buf, &samples_in_left, &samples_out_left); + + if (mChannelCount == 2) { + int samples_in_right = mInTmpBuf; + int samples_out_right; + resample_2_1(mTmpRight, mTmp2Right + mInTmp2Buf, &samples_in_right, &samples_out_right); + } + + + mInTmpBuf = samples_in_left; + mInTmp2Buf += samples_out_left; + mInOutBuf = samples_out_left; + + if (mSampleRate == 8000) { + /* 11025 -> 8000*/ + int samples_in_left = mInTmp2Buf; + int samples_out_left; + resample_441_320(mTmp2Left, mOutLeft, &samples_in_left, &samples_out_left); + + if (mChannelCount == 2) { + int samples_in_right = mInTmp2Buf; + int samples_out_right; + resample_441_320(mTmp2Right, mOutRight, &samples_in_right, &samples_out_right); + } + + mInTmp2Buf = samples_in_left; + mInOutBuf = samples_out_left; + } else { + mInTmp2Buf = 0; + } + + } else if (mSampleRate == 16000) { + /* 22050 -> 16000*/ + int samples_in_left = mInTmpBuf; + int samples_out_left; + resample_441_320(mTmpLeft, mTmp2Left, &samples_in_left, &samples_out_left); + + if (mChannelCount == 2) { + int samples_in_right = mInTmpBuf; + int samples_out_right; + resample_441_320(mTmpRight, mTmp2Right, &samples_in_right, &samples_out_right); + } + + mInTmpBuf = samples_in_left; + mInOutBuf = samples_out_left; + } else { + mInTmpBuf = 0; + } + + int frames = (remaingFrames > mInOutBuf) ? mInOutBuf : remaingFrames; + + for (int i = 0; i < frames; ++i) { + out[outFrames + i] = outLeft[i]; + } + if (mChannelCount == 2) { + for (int i = 0; i < frames; ++i) { + out[(outFrames + i) * 2] = outLeft[i]; + out[(outFrames + i) * 2 + 1] = outRight[i]; + } + } + remaingFrames -= frames; + outFrames += frames; + mOutBufPos = frames; + mInOutBuf -= frames; + } + + return 0; +} + + + + + + + +//------------------------------------------------------------------------------ +// Factory +//------------------------------------------------------------------------------ + +extern "C" AudioHardwareInterface* createAudioHardware(void) { + return new AudioHardware(); +} + +}; // namespace android diff --git a/libaudio/AudioHardware.h b/libaudio/AudioHardware.h new file mode 100644 index 0000000..a23e6c9 --- /dev/null +++ b/libaudio/AudioHardware.h @@ -0,0 +1,367 @@ +/* +** Copyright 2008, The Android Open-Source Project +** +** 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_AUDIO_HARDWARE_H +#define ANDROID_AUDIO_HARDWARE_H + +#include +#include + +#include +#include + +#include +#include + +#include "secril-client.h" + +extern "C" { + struct pcm; + struct mixer; + struct mixer_ctl; +}; + +namespace android { + +// TODO: determine actual audio DSP and hardware latency +// Additionnal latency introduced by audio DSP and hardware in ms +#define AUDIO_HW_OUT_LATENCY_MS 0 +// Default audio output sample rate +#define AUDIO_HW_OUT_SAMPLERATE 44100 +// Default audio output channel mask +#define AUDIO_HW_OUT_CHANNELS (AudioSystem::CHANNEL_OUT_STEREO) +// Default audio output sample format +#define AUDIO_HW_OUT_FORMAT (AudioSystem::PCM_16_BIT) +// Kernel pcm out buffer size in frames at 44.1kHz +#define AUDIO_HW_OUT_PERIOD_MULT 8 // (8 * 128 = 1024 frames) +#define AUDIO_HW_OUT_PERIOD_SZ (PCM_PERIOD_SZ_MIN * AUDIO_HW_OUT_PERIOD_MULT) +#define AUDIO_HW_OUT_PERIOD_CNT 4 +// Default audio output buffer size in bytes +#define AUDIO_HW_OUT_PERIOD_BYTES (AUDIO_HW_OUT_PERIOD_SZ * 2 * sizeof(int16_t)) + +// Default audio input sample rate +#define AUDIO_HW_IN_SAMPLERATE 8000 +// Default audio input channel mask +#define AUDIO_HW_IN_CHANNELS (AudioSystem::CHANNEL_IN_MONO) +// Default audio input sample format +#define AUDIO_HW_IN_FORMAT (AudioSystem::PCM_16_BIT) +// Number of buffers in audio driver for input +#define AUDIO_HW_NUM_IN_BUF 2 +// Kernel pcm in buffer size in frames at 44.1kHz (before resampling) +#define AUDIO_HW_IN_PERIOD_MULT 16 // (16 * 128 = 2048 frames) +#define AUDIO_HW_IN_PERIOD_SZ (PCM_PERIOD_SZ_MIN * AUDIO_HW_IN_PERIOD_MULT) +#define AUDIO_HW_IN_PERIOD_CNT 2 +// Default audio input buffer size in bytes (8kHz mono) +#define AUDIO_HW_IN_PERIOD_BYTES ((AUDIO_HW_IN_PERIOD_SZ*sizeof(int16_t))/8) + + +class AudioHardware : public AudioHardwareBase +{ + class AudioStreamOutALSA; + class AudioStreamInALSA; +public: + + // input path names used to translate from input sources to driver paths + static const char *inputPathNameDefault; + static const char *inputPathNameCamcorder; + static const char *inputPathNameVoiceRecognition; + static const char *inputPathNameVoiceCommunication; + + AudioHardware(); + virtual ~AudioHardware(); + virtual status_t initCheck(); + + virtual status_t setVoiceVolume(float volume); + virtual status_t setMasterVolume(float volume); + + virtual status_t setMode(int mode); + + virtual status_t setMicMute(bool state); + virtual status_t getMicMute(bool* state); + + virtual status_t setParameters(const String8& keyValuePairs); + virtual String8 getParameters(const String8& keys); + + virtual AudioStreamOut* openOutputStream( + uint32_t devices, int *format=0, uint32_t *channels=0, + uint32_t *sampleRate=0, status_t *status=0); + + virtual AudioStreamIn* openInputStream( + uint32_t devices, int *format, uint32_t *channels, + uint32_t *sampleRate, status_t *status, + AudioSystem::audio_in_acoustics acoustics); + + virtual void closeOutputStream(AudioStreamOut* out); + virtual void closeInputStream(AudioStreamIn* in); + + virtual size_t getInputBufferSize( + uint32_t sampleRate, int format, int channelCount); + + int mode() { return mMode; } + const char *getOutputRouteFromDevice(uint32_t device); + const char *getInputRouteFromDevice(uint32_t device); + const char *getVoiceRouteFromDevice(uint32_t device); + + status_t setIncallPath_l(uint32_t device); + + status_t setInputSource_l(audio_source source); + + static uint32_t getInputSampleRate(uint32_t sampleRate); + sp getActiveInput_l(); + + Mutex& lock() { return mLock; } + + struct pcm *openPcmOut_l(); + void closePcmOut_l(); + + struct mixer *openMixer_l(); + void closeMixer_l(); + + sp output() { return mOutput; } + +protected: + virtual status_t dump(int fd, const Vector& args); + +private: + + enum tty_modes { + TTY_MODE_OFF, + TTY_MODE_VCO, + TTY_MODE_HCO, + TTY_MODE_FULL + }; + + bool mInit; + bool mMicMute; + sp mOutput; + SortedVector < sp > mInputs; + Mutex mLock; + struct pcm* mPcm; + struct mixer* mMixer; + uint32_t mPcmOpenCnt; + uint32_t mMixerOpenCnt; + bool mInCallAudioMode; + + audio_source mInputSource; + bool mBluetoothNrec; + int mTTYMode; + + void* mSecRilLibHandle; + HRilClient mRilClient; + bool mActivatedCP; + HRilClient (*openClientRILD) (void); + int (*disconnectRILD) (HRilClient); + int (*closeClientRILD) (HRilClient); + int (*isConnectedRILD) (HRilClient); + int (*connectRILD) (HRilClient); + int (*setCallVolume) (HRilClient, SoundType, int); + int (*setCallAudioPath)(HRilClient, AudioPath); + int (*setCallClockSync)(HRilClient, SoundClockCondition); + void loadRILD(void); + status_t connectRILDIfRequired(void); + + // trace driver operations for dump + int mDriverOp; + + static uint32_t checkInputSampleRate(uint32_t sampleRate); + static const uint32_t inputSamplingRates[]; + + class AudioStreamOutALSA : public AudioStreamOut, public RefBase + { + public: + AudioStreamOutALSA(); + virtual ~AudioStreamOutALSA(); + status_t set(AudioHardware* mHardware, + uint32_t devices, + int *pFormat, + uint32_t *pChannels, + uint32_t *pRate); + virtual uint32_t sampleRate() + const { return mSampleRate; } + virtual size_t bufferSize() + const { return mBufferSize; } + virtual uint32_t channels() + const { return mChannels; } + virtual int format() + const { return AUDIO_HW_OUT_FORMAT; } + virtual uint32_t latency() + const { return (1000 * AUDIO_HW_OUT_PERIOD_CNT * + (bufferSize()/frameSize()))/sampleRate() + + AUDIO_HW_OUT_LATENCY_MS; } + virtual status_t setVolume(float left, float right) + { return INVALID_OPERATION; } + virtual ssize_t write(const void* buffer, size_t bytes); + virtual status_t standby(); + bool checkStandby(); + + virtual status_t dump(int fd, const Vector& args); + virtual status_t setParameters(const String8& keyValuePairs); + virtual String8 getParameters(const String8& keys); + uint32_t device() { return mDevices; } + virtual status_t getRenderPosition(uint32_t *dspFrames); + + void doStandby_l(); + void close_l(); + status_t open_l(); + int standbyCnt() { return mStandbyCnt; } + + int prepareLock(); + void lock(); + void unlock(); + + private: + + Mutex mLock; + AudioHardware* mHardware; + struct pcm *mPcm; + struct mixer *mMixer; + struct mixer_ctl *mRouteCtl; + const char *next_route; + bool mStandby; + uint32_t mDevices; + uint32_t mChannels; + uint32_t mSampleRate; + size_t mBufferSize; + // trace driver operations for dump + int mDriverOp; + int mStandbyCnt; + bool mSleepReq; + }; + + class DownSampler; + + class BufferProvider + { + public: + + struct Buffer { + union { + void* raw; + short* i16; + int8_t* i8; + }; + size_t frameCount; + }; + + virtual ~BufferProvider() {} + + virtual status_t getNextBuffer(Buffer* buffer) = 0; + virtual void releaseBuffer(Buffer* buffer) = 0; + }; + + class DownSampler { + public: + DownSampler(uint32_t outSampleRate, + uint32_t channelCount, + uint32_t frameCount, + BufferProvider* provider); + + virtual ~DownSampler(); + + void reset(); + status_t initCheck() { return mStatus; } + int resample(int16_t* out, size_t *outFrameCount); + + private: + status_t mStatus; + BufferProvider* mProvider; + uint32_t mSampleRate; + uint32_t mChannelCount; + uint32_t mFrameCount; + int16_t *mInLeft; + int16_t *mInRight; + int16_t *mTmpLeft; + int16_t *mTmpRight; + int16_t *mTmp2Left; + int16_t *mTmp2Right; + int16_t *mOutLeft; + int16_t *mOutRight; + int mInInBuf; + int mInTmpBuf; + int mInTmp2Buf; + int mOutBufPos; + int mInOutBuf; + }; + + + class AudioStreamInALSA : public AudioStreamIn, public BufferProvider, public RefBase + { + + public: + AudioStreamInALSA(); + virtual ~AudioStreamInALSA(); + status_t set(AudioHardware* hw, + uint32_t devices, + int *pFormat, + uint32_t *pChannels, + uint32_t *pRate, + AudioSystem::audio_in_acoustics acoustics); + virtual size_t bufferSize() const { return mBufferSize; } + virtual uint32_t channels() const { return mChannels; } + virtual int format() const { return AUDIO_HW_IN_FORMAT; } + virtual uint32_t sampleRate() const { return mSampleRate; } + virtual status_t setGain(float gain) { return INVALID_OPERATION; } + virtual ssize_t read(void* buffer, ssize_t bytes); + virtual status_t dump(int fd, const Vector& args); + virtual status_t standby(); + bool checkStandby(); + virtual status_t setParameters(const String8& keyValuePairs); + virtual String8 getParameters(const String8& keys); + virtual unsigned int getInputFramesLost() const { return 0; } + uint32_t device() { return mDevices; } + void doStandby_l(); + void close_l(); + status_t open_l(); + int standbyCnt() { return mStandbyCnt; } + + static size_t getBufferSize(uint32_t sampleRate, int channelCount); + + // BufferProvider + virtual status_t getNextBuffer(BufferProvider::Buffer* buffer); + virtual void releaseBuffer(BufferProvider::Buffer* buffer); + + int prepareLock(); + void lock(); + void unlock(); + + private: + Mutex mLock; + AudioHardware* mHardware; + struct pcm *mPcm; + struct mixer *mMixer; + struct mixer_ctl *mRouteCtl; + const char *next_route; + bool mStandby; + uint32_t mDevices; + uint32_t mChannels; + uint32_t mChannelCount; + uint32_t mSampleRate; + size_t mBufferSize; + DownSampler *mDownSampler; + status_t mReadStatus; + size_t mInPcmInBuf; + int16_t *mPcmIn; + // trace driver operations for dump + int mDriverOp; + int mStandbyCnt; + bool mSleepReq; + }; + +}; + +}; // namespace android + +#endif diff --git a/libaudio/AudioPolicyManager.cpp b/libaudio/AudioPolicyManager.cpp new file mode 100644 index 0000000..c53d1e9 --- /dev/null +++ b/libaudio/AudioPolicyManager.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * 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. + */ + +#define LOG_TAG "AudioPolicyManager" +//#define LOG_NDEBUG 0 +#include +#include "AudioPolicyManager.h" +#include + +namespace android { + + + +// ---------------------------------------------------------------------------- +// AudioPolicyManager for crespo platform +// Common audio policy manager code is implemented in AudioPolicyManagerBase class +// ---------------------------------------------------------------------------- + +// --- class factory + + +extern "C" AudioPolicyInterface* createAudioPolicyManager(AudioPolicyClientInterface *clientInterface) +{ + return new AudioPolicyManager(clientInterface); +} + +extern "C" void destroyAudioPolicyManager(AudioPolicyInterface *interface) +{ + delete interface; +} + + +}; // namespace android diff --git a/libaudio/AudioPolicyManager.h b/libaudio/AudioPolicyManager.h new file mode 100644 index 0000000..03141e5 --- /dev/null +++ b/libaudio/AudioPolicyManager.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * 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 + + +namespace android { + +class AudioPolicyManager: public AudioPolicyManagerBase +{ + +public: + AudioPolicyManager(AudioPolicyClientInterface *clientInterface) + : AudioPolicyManagerBase(clientInterface) {} + + virtual ~AudioPolicyManager() {} + +protected: + // true is current platform implements a back microphone + virtual bool hasBackMicrophone() const { return false; } +#ifdef WITH_A2DP + // true is current platform supports duplication of notifications and ringtones over A2DP output + virtual bool a2dpUsedForSonification() const { return true; } +#endif + +}; +}; diff --git a/libaudio/alsa_audio.h b/libaudio/alsa_audio.h new file mode 100644 index 0000000..3cb86d9 --- /dev/null +++ b/libaudio/alsa_audio.h @@ -0,0 +1,77 @@ +/* +** Copyright 2010, The Android Open-Source Project +** +** 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 _AUDIO_H_ +#define _AUDIO_H_ + +struct pcm; + +#define PCM_OUT 0x00000000 +#define PCM_IN 0x10000000 + +#define PCM_STEREO 0x00000000 +#define PCM_MONO 0x01000000 + +#define PCM_44100HZ 0x00000000 +#define PCM_48000HZ 0x00100000 +#define PCM_8000HZ 0x00200000 +#define PCM_RATE_MASK 0x00F00000 + +#define PCM_PERIOD_CNT_MIN 2 +#define PCM_PERIOD_CNT_SHIFT 16 +#define PCM_PERIOD_CNT_MASK (0xF << PCM_PERIOD_CNT_SHIFT) +#define PCM_PERIOD_SZ_MIN 128 +#define PCM_PERIOD_SZ_SHIFT 12 +#define PCM_PERIOD_SZ_MASK (0xF << PCM_PERIOD_SZ_SHIFT) + +/* Acquire/release a pcm channel. + * Returns non-zero on error + */ +struct pcm *pcm_open(unsigned flags); +int pcm_close(struct pcm *pcm); +int pcm_ready(struct pcm *pcm); + +/* Returns a human readable reason for the last error. */ +const char *pcm_error(struct pcm *pcm); + +/* Returns the buffer size (int bytes) that should be used for pcm_write. + * This will be 1/2 of the actual fifo size. + */ +unsigned pcm_buffer_size(struct pcm *pcm); + +/* Write data to the fifo. + * Will start playback on the first write or on a write that + * occurs after a fifo underrun. + */ +int pcm_write(struct pcm *pcm, void *data, unsigned count); +int pcm_read(struct pcm *pcm, void *data, unsigned count); + +struct mixer; +struct mixer_ctl; + +struct mixer *mixer_open(void); +void mixer_close(struct mixer *mixer); +void mixer_dump(struct mixer *mixer); + +struct mixer_ctl *mixer_get_control(struct mixer *mixer, + const char *name, unsigned index); +struct mixer_ctl *mixer_get_nth_control(struct mixer *mixer, unsigned n); + +int mixer_ctl_set(struct mixer_ctl *ctl, unsigned percent); +int mixer_ctl_select(struct mixer_ctl *ctl, const char *value); +void mixer_ctl_print(struct mixer_ctl *ctl); + +#endif diff --git a/libaudio/alsa_mixer.c b/libaudio/alsa_mixer.c new file mode 100644 index 0000000..3036ef8 --- /dev/null +++ b/libaudio/alsa_mixer.c @@ -0,0 +1,371 @@ +/* +** Copyright 2010, The Android Open-Source Project +** +** 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 +#define __force +#define __bitwise +#define __user +#include "asound.h" + +#include "alsa_audio.h" + +static const char *elem_iface_name(snd_ctl_elem_iface_t n) +{ + switch (n) { + case SNDRV_CTL_ELEM_IFACE_CARD: return "CARD"; + case SNDRV_CTL_ELEM_IFACE_HWDEP: return "HWDEP"; + case SNDRV_CTL_ELEM_IFACE_MIXER: return "MIXER"; + case SNDRV_CTL_ELEM_IFACE_PCM: return "PCM"; + case SNDRV_CTL_ELEM_IFACE_RAWMIDI: return "MIDI"; + case SNDRV_CTL_ELEM_IFACE_TIMER: return "TIMER"; + case SNDRV_CTL_ELEM_IFACE_SEQUENCER: return "SEQ"; + default: return "???"; + } +} + +static const char *elem_type_name(snd_ctl_elem_type_t n) +{ + switch (n) { + case SNDRV_CTL_ELEM_TYPE_NONE: return "NONE"; + case SNDRV_CTL_ELEM_TYPE_BOOLEAN: return "BOOL"; + case SNDRV_CTL_ELEM_TYPE_INTEGER: return "INT32"; + case SNDRV_CTL_ELEM_TYPE_ENUMERATED: return "ENUM"; + case SNDRV_CTL_ELEM_TYPE_BYTES: return "BYTES"; + case SNDRV_CTL_ELEM_TYPE_IEC958: return "IEC958"; + case SNDRV_CTL_ELEM_TYPE_INTEGER64: return "INT64"; + default: return "???"; + } +} + + +struct mixer_ctl { + struct mixer *mixer; + struct snd_ctl_elem_info *info; + char **ename; +}; + +struct mixer { + int fd; + struct snd_ctl_elem_info *info; + struct mixer_ctl *ctl; + unsigned count; +}; + +void mixer_close(struct mixer *mixer) +{ + unsigned n,m; + + if (mixer->fd >= 0) + close(mixer->fd); + + if (mixer->ctl) { + for (n = 0; n < mixer->count; n++) { + if (mixer->ctl[n].ename) { + unsigned max = mixer->ctl[n].info->value.enumerated.items; + for (m = 0; m < max; m++) + free(mixer->ctl[n].ename[m]); + free(mixer->ctl[n].ename); + } + } + free(mixer->ctl); + } + + if (mixer->info) + free(mixer->info); + + free(mixer); +} + +struct mixer *mixer_open(void) +{ + struct snd_ctl_elem_list elist; + struct snd_ctl_elem_info tmp; + struct snd_ctl_elem_id *eid = NULL; + struct mixer *mixer = NULL; + unsigned n, m; + int fd; + + fd = open("/dev/snd/controlC0", O_RDWR); + if (fd < 0) + return 0; + + memset(&elist, 0, sizeof(elist)); + if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_LIST, &elist) < 0) + goto fail; + + mixer = calloc(1, sizeof(*mixer)); + if (!mixer) + goto fail; + + mixer->ctl = calloc(elist.count, sizeof(struct mixer_ctl)); + mixer->info = calloc(elist.count, sizeof(struct snd_ctl_elem_info)); + if (!mixer->ctl || !mixer->info) + goto fail; + + eid = calloc(elist.count, sizeof(struct snd_ctl_elem_id)); + if (!eid) + goto fail; + + mixer->count = elist.count; + mixer->fd = fd; + elist.space = mixer->count; + elist.pids = eid; + if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_LIST, &elist) < 0) + goto fail; + + for (n = 0; n < mixer->count; n++) { + struct snd_ctl_elem_info *ei = mixer->info + n; + ei->id.numid = eid[n].numid; + if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_INFO, ei) < 0) + goto fail; + mixer->ctl[n].info = ei; + mixer->ctl[n].mixer = mixer; + if (ei->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED) { + char **enames = calloc(ei->value.enumerated.items, sizeof(char*)); + if (!enames) + goto fail; + mixer->ctl[n].ename = enames; + for (m = 0; m < ei->value.enumerated.items; m++) { + memset(&tmp, 0, sizeof(tmp)); + tmp.id.numid = ei->id.numid; + tmp.value.enumerated.item = m; + if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_INFO, &tmp) < 0) + goto fail; + enames[m] = strdup(tmp.value.enumerated.name); + if (!enames[m]) + goto fail; + } + } + } + + free(eid); + return mixer; + +fail: + if (eid) + free(eid); + if (mixer) + mixer_close(mixer); + else if (fd >= 0) + close(fd); + return 0; +} + +void mixer_dump(struct mixer *mixer) +{ + unsigned n, m; + + printf(" id iface dev sub idx num perms type name\n"); + for (n = 0; n < mixer->count; n++) { + struct snd_ctl_elem_info *ei = mixer->info + n; + + printf("%4d %5s %3d %3d %3d %3d %c%c%c%c%c%c%c%c%c %-6s %s", + ei->id.numid, elem_iface_name(ei->id.iface), + ei->id.device, ei->id.subdevice, ei->id.index, + ei->count, + (ei->access & SNDRV_CTL_ELEM_ACCESS_READ) ? 'r' : ' ', + (ei->access & SNDRV_CTL_ELEM_ACCESS_WRITE) ? 'w' : ' ', + (ei->access & SNDRV_CTL_ELEM_ACCESS_VOLATILE) ? 'V' : ' ', + (ei->access & SNDRV_CTL_ELEM_ACCESS_TIMESTAMP) ? 'T' : ' ', + (ei->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) ? 'R' : ' ', + (ei->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) ? 'W' : ' ', + (ei->access & SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND) ? 'C' : ' ', + (ei->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE) ? 'I' : ' ', + (ei->access & SNDRV_CTL_ELEM_ACCESS_LOCK) ? 'L' : ' ', + elem_type_name(ei->type), + ei->id.name); + switch (ei->type) { + case SNDRV_CTL_ELEM_TYPE_INTEGER: + printf(ei->value.integer.step ? + " { %ld-%ld, %ld }\n" : " { %ld-%ld }", + ei->value.integer.min, + ei->value.integer.max, + ei->value.integer.step); + break; + case SNDRV_CTL_ELEM_TYPE_INTEGER64: + printf(ei->value.integer64.step ? + " { %lld-%lld, %lld }\n" : " { %lld-%lld }", + ei->value.integer64.min, + ei->value.integer64.max, + ei->value.integer64.step); + break; + case SNDRV_CTL_ELEM_TYPE_ENUMERATED: { + unsigned m; + printf(" { %s=0", mixer->ctl[n].ename[0]); + for (m = 1; m < ei->value.enumerated.items; m++) + printf(", %s=%d", mixer->ctl[n].ename[m],m); + printf(" }"); + break; + } + } + printf("\n"); + } +} + +struct mixer_ctl *mixer_get_control(struct mixer *mixer, + const char *name, unsigned index) +{ + unsigned n; + for (n = 0; n < mixer->count; n++) { + if (mixer->info[n].id.index == index) { + if (!strcmp(name, (char*) mixer->info[n].id.name)) { + return mixer->ctl + n; + } + } + } + return 0; +} + +struct mixer_ctl *mixer_get_nth_control(struct mixer *mixer, unsigned n) +{ + if (n < mixer->count) + return mixer->ctl + n; + return 0; +} + +void mixer_ctl_print(struct mixer_ctl *ctl) +{ + struct snd_ctl_elem_value ev; + unsigned n; + + memset(&ev, 0, sizeof(ev)); + ev.id.numid = ctl->info->id.numid; + if (ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev)) + return; + printf("%s:", ctl->info->id.name); + + switch (ctl->info->type) { + case SNDRV_CTL_ELEM_TYPE_BOOLEAN: + for (n = 0; n < ctl->info->count; n++) + printf(" %s", ev.value.integer.value[n] ? "ON" : "OFF"); + break; + case SNDRV_CTL_ELEM_TYPE_INTEGER: { + for (n = 0; n < ctl->info->count; n++) + printf(" %ld", ev.value.integer.value[n]); + break; + } + case SNDRV_CTL_ELEM_TYPE_INTEGER64: + for (n = 0; n < ctl->info->count; n++) + printf(" %lld", ev.value.integer64.value[n]); + break; + case SNDRV_CTL_ELEM_TYPE_ENUMERATED: + for (n = 0; n < ctl->info->count; n++) { + unsigned v = ev.value.enumerated.item[n]; + printf(" %d (%s)", v, + (v < ctl->info->value.enumerated.items) ? ctl->ename[v] : "???"); + } + break; + default: + printf(" ???"); + } + printf("\n"); +} + +static long scale_int(struct snd_ctl_elem_info *ei, unsigned _percent) +{ + long percent; + long range; + + if (_percent > 100) + percent = 100; + else + percent = (long) _percent; + + range = (ei->value.integer.max - ei->value.integer.min); + + return ei->value.integer.min + (range * percent) / 100LL; +} + +static long long scale_int64(struct snd_ctl_elem_info *ei, unsigned _percent) +{ + long long percent; + long long range; + + if (_percent > 100) + percent = 100; + else + percent = (long) _percent; + + range = (ei->value.integer.max - ei->value.integer.min) * 100LL; + + return ei->value.integer.min + (range / percent); +} + +int mixer_ctl_set(struct mixer_ctl *ctl, unsigned percent) +{ + struct snd_ctl_elem_value ev; + unsigned n; + + memset(&ev, 0, sizeof(ev)); + ev.id.numid = ctl->info->id.numid; + switch (ctl->info->type) { + case SNDRV_CTL_ELEM_TYPE_BOOLEAN: + for (n = 0; n < ctl->info->count; n++) + ev.value.integer.value[n] = !!percent; + break; + case SNDRV_CTL_ELEM_TYPE_INTEGER: { + long value = scale_int(ctl->info, percent); + for (n = 0; n < ctl->info->count; n++) + ev.value.integer.value[n] = value; + break; + } + case SNDRV_CTL_ELEM_TYPE_INTEGER64: { + long long value = scale_int64(ctl->info, percent); + for (n = 0; n < ctl->info->count; n++) + ev.value.integer64.value[n] = value; + break; + } + default: + errno = EINVAL; + return -1; + } + + return ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev); +} + +int mixer_ctl_select(struct mixer_ctl *ctl, const char *value) +{ + unsigned n, max; + struct snd_ctl_elem_value ev; + + if (ctl->info->type != SNDRV_CTL_ELEM_TYPE_ENUMERATED) { + errno = EINVAL; + return -1; + } + + max = ctl->info->value.enumerated.items; + for (n = 0; n < max; n++) { + if (!strcmp(value, ctl->ename[n])) { + memset(&ev, 0, sizeof(ev)); + ev.value.enumerated.item[0] = n; + ev.id.numid = ctl->info->id.numid; + if (ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev) < 0) + return -1; + return 0; + } + } + + errno = EINVAL; + return -1; +} diff --git a/libaudio/alsa_pcm.c b/libaudio/alsa_pcm.c new file mode 100644 index 0000000..5673391 --- /dev/null +++ b/libaudio/alsa_pcm.c @@ -0,0 +1,405 @@ +/* +** Copyright 2010, The Android Open-Source Project +** +** 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. +*/ + +#define LOG_TAG "alsa_pcm" +//#define LOG_NDEBUG 0 +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "alsa_audio.h" + +#define __force +#define __bitwise +#define __user +#include "asound.h" + +#define DEBUG 0 + +/* alsa parameter manipulation cruft */ + +#define PARAM_MAX SNDRV_PCM_HW_PARAM_LAST_INTERVAL + +static inline int param_is_mask(int p) +{ + return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) && + (p <= SNDRV_PCM_HW_PARAM_LAST_MASK); +} + +static inline int param_is_interval(int p) +{ + return (p >= SNDRV_PCM_HW_PARAM_FIRST_INTERVAL) && + (p <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL); +} + +static inline struct snd_interval *param_to_interval(struct snd_pcm_hw_params *p, int n) +{ + return &(p->intervals[n - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]); +} + +static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p, int n) +{ + return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]); +} + +static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned bit) +{ + if (bit >= SNDRV_MASK_MAX) + return; + if (param_is_mask(n)) { + struct snd_mask *m = param_to_mask(p, n); + m->bits[0] = 0; + m->bits[1] = 0; + m->bits[bit >> 5] |= (1 << (bit & 31)); + } +} + +static void param_set_min(struct snd_pcm_hw_params *p, int n, unsigned val) +{ + if (param_is_interval(n)) { + struct snd_interval *i = param_to_interval(p, n); + i->min = val; + } +} + +static void param_set_max(struct snd_pcm_hw_params *p, int n, unsigned val) +{ + if (param_is_interval(n)) { + struct snd_interval *i = param_to_interval(p, n); + i->max = val; + } +} + +static void param_set_int(struct snd_pcm_hw_params *p, int n, unsigned val) +{ + if (param_is_interval(n)) { + struct snd_interval *i = param_to_interval(p, n); + i->min = val; + i->max = val; + i->integer = 1; + } +} + +static void param_init(struct snd_pcm_hw_params *p) +{ + int n; + memset(p, 0, sizeof(*p)); + for (n = SNDRV_PCM_HW_PARAM_FIRST_MASK; + n <= SNDRV_PCM_HW_PARAM_LAST_MASK; n++) { + struct snd_mask *m = param_to_mask(p, n); + m->bits[0] = ~0; + m->bits[1] = ~0; + } + for (n = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; + n <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; n++) { + struct snd_interval *i = param_to_interval(p, n); + i->min = 0; + i->max = ~0; + } +} + +/* debugging gunk */ + +#if DEBUG +static const char *param_name[PARAM_MAX+1] = { + [SNDRV_PCM_HW_PARAM_ACCESS] = "access", + [SNDRV_PCM_HW_PARAM_FORMAT] = "format", + [SNDRV_PCM_HW_PARAM_SUBFORMAT] = "subformat", + + [SNDRV_PCM_HW_PARAM_SAMPLE_BITS] = "sample_bits", + [SNDRV_PCM_HW_PARAM_FRAME_BITS] = "frame_bits", + [SNDRV_PCM_HW_PARAM_CHANNELS] = "channels", + [SNDRV_PCM_HW_PARAM_RATE] = "rate", + [SNDRV_PCM_HW_PARAM_PERIOD_TIME] = "period_time", + [SNDRV_PCM_HW_PARAM_PERIOD_SIZE] = "period_size", + [SNDRV_PCM_HW_PARAM_PERIOD_BYTES] = "period_bytes", + [SNDRV_PCM_HW_PARAM_PERIODS] = "periods", + [SNDRV_PCM_HW_PARAM_BUFFER_TIME] = "buffer_time", + [SNDRV_PCM_HW_PARAM_BUFFER_SIZE] = "buffer_size", + [SNDRV_PCM_HW_PARAM_BUFFER_BYTES] = "buffer_bytes", + [SNDRV_PCM_HW_PARAM_TICK_TIME] = "tick_time", +}; + +static void param_dump(struct snd_pcm_hw_params *p) +{ + int n; + + for (n = SNDRV_PCM_HW_PARAM_FIRST_MASK; + n <= SNDRV_PCM_HW_PARAM_LAST_MASK; n++) { + struct snd_mask *m = param_to_mask(p, n); + LOGV("%s = %08x%08x\n", param_name[n], + m->bits[1], m->bits[0]); + } + for (n = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; + n <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; n++) { + struct snd_interval *i = param_to_interval(p, n); + LOGV("%s = (%d,%d) omin=%d omax=%d int=%d empty=%d\n", + param_name[n], i->min, i->max, i->openmin, + i->openmax, i->integer, i->empty); + } + LOGV("info = %08x\n", p->info); + LOGV("msbits = %d\n", p->msbits); + LOGV("rate = %d/%d\n", p->rate_num, p->rate_den); + LOGV("fifo = %d\n", (int) p->fifo_size); +} + +static void info_dump(struct snd_pcm_info *info) +{ + LOGV("device = %d\n", info->device); + LOGV("subdevice = %d\n", info->subdevice); + LOGV("stream = %d\n", info->stream); + LOGV("card = %d\n", info->card); + LOGV("id = '%s'\n", info->id); + LOGV("name = '%s'\n", info->name); + LOGV("subname = '%s'\n", info->subname); + LOGV("dev_class = %d\n", info->dev_class); + LOGV("dev_subclass = %d\n", info->dev_subclass); + LOGV("subdevices_count = %d\n", info->subdevices_count); + LOGV("subdevices_avail = %d\n", info->subdevices_avail); +} +#else +static void param_dump(struct snd_pcm_hw_params *p) {} +static void info_dump(struct snd_pcm_info *info) {} +#endif + +#define PCM_ERROR_MAX 128 + +struct pcm { + int fd; + unsigned flags; + int running:1; + int underruns; + unsigned buffer_size; + char error[PCM_ERROR_MAX]; +}; + +unsigned pcm_buffer_size(struct pcm *pcm) +{ + return pcm->buffer_size; +} + +const char* pcm_error(struct pcm *pcm) +{ + return pcm->error; +} + +static int oops(struct pcm *pcm, int e, const char *fmt, ...) +{ + va_list ap; + int sz; + + va_start(ap, fmt); + vsnprintf(pcm->error, PCM_ERROR_MAX, fmt, ap); + va_end(ap); + sz = strlen(pcm->error); + + if (errno) + snprintf(pcm->error + sz, PCM_ERROR_MAX - sz, + ": %s", strerror(e)); + return -1; +} + +int pcm_write(struct pcm *pcm, void *data, unsigned count) +{ + struct snd_xferi x; + + if (pcm->flags & PCM_IN) + return -EINVAL; + + x.buf = data; + x.frames = (pcm->flags & PCM_MONO) ? (count / 2) : (count / 4); + + for (;;) { + if (!pcm->running) { + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_PREPARE)) + return oops(pcm, errno, "cannot prepare channel"); + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &x)) + return oops(pcm, errno, "cannot write initial data"); + pcm->running = 1; + return 0; + } + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &x)) { + pcm->running = 0; + if (errno == EPIPE) { + /* we failed to make our window -- try to restart */ + pcm->underruns++; + continue; + } + return oops(pcm, errno, "cannot write stream data"); + } + return 0; + } +} + +int pcm_read(struct pcm *pcm, void *data, unsigned count) +{ + struct snd_xferi x; + + if (!(pcm->flags & PCM_IN)) + return -EINVAL; + + x.buf = data; + x.frames = (pcm->flags & PCM_MONO) ? (count / 2) : (count / 4); + +// LOGV("read() %d frames", x.frames); + for (;;) { + if (!pcm->running) { + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_PREPARE)) + return oops(pcm, errno, "cannot prepare channel"); + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_START)) + return oops(pcm, errno, "cannot start channel"); + pcm->running = 1; + } + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_READI_FRAMES, &x)) { + pcm->running = 0; + if (errno == EPIPE) { + /* we failed to make our window -- try to restart */ + pcm->underruns++; + continue; + } + return oops(pcm, errno, "cannot read stream data"); + } +// LOGV("read() got %d frames", x.frames); + return 0; + } +} + +static struct pcm bad_pcm = { + .fd = -1, +}; + +int pcm_close(struct pcm *pcm) +{ + if (pcm == &bad_pcm) + return 0; + + if (pcm->fd >= 0) + close(pcm->fd); + pcm->running = 0; + pcm->buffer_size = 0; + pcm->fd = -1; + return 0; +} + +struct pcm *pcm_open(unsigned flags) +{ + const char *dname; + struct pcm *pcm; + struct snd_pcm_info info; + struct snd_pcm_hw_params params; + struct snd_pcm_sw_params sparams; + unsigned period_sz; + unsigned period_cnt; + + LOGV("pcm_open(0x%08x)",flags); + + pcm = calloc(1, sizeof(struct pcm)); + if (!pcm) + return &bad_pcm; + + if (flags & PCM_IN) { + dname = "/dev/snd/pcmC0D0c"; + } else { + dname = "/dev/snd/pcmC0D0p"; + } + + LOGV("pcm_open() period sz multiplier %d", + ((flags & PCM_PERIOD_SZ_MASK) >> PCM_PERIOD_SZ_SHIFT) + 1); + period_sz = 128 * (((flags & PCM_PERIOD_SZ_MASK) >> PCM_PERIOD_SZ_SHIFT) + 1); + LOGV("pcm_open() period cnt %d", + ((flags & PCM_PERIOD_CNT_MASK) >> PCM_PERIOD_CNT_SHIFT) + PCM_PERIOD_CNT_MIN); + period_cnt = ((flags & PCM_PERIOD_CNT_MASK) >> PCM_PERIOD_CNT_SHIFT) + PCM_PERIOD_CNT_MIN; + + pcm->flags = flags; + pcm->fd = open(dname, O_RDWR); + if (pcm->fd < 0) { + oops(pcm, errno, "cannot open device '%s'"); + return pcm; + } + + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_INFO, &info)) { + oops(pcm, errno, "cannot get info - %s"); + goto fail; + } + info_dump(&info); + + LOGV("pcm_open() period_cnt %d period_sz %d channels %d", + period_cnt, period_sz, (flags & PCM_MONO) ? 1 : 2); + + param_init(¶ms); + param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_ACCESS, + SNDRV_PCM_ACCESS_RW_INTERLEAVED); + param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_FORMAT, + SNDRV_PCM_FORMAT_S16_LE); + param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_SUBFORMAT, + SNDRV_PCM_SUBFORMAT_STD); + param_set_min(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, period_sz); + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, 16); + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_FRAME_BITS, + (flags & PCM_MONO) ? 16 : 32); + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_CHANNELS, + (flags & PCM_MONO) ? 1 : 2); + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_PERIODS, period_cnt); + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_RATE, 44100); + + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_HW_PARAMS, ¶ms)) { + oops(pcm, errno, "cannot set hw params"); + goto fail; + } + param_dump(¶ms); + + memset(&sparams, 0, sizeof(sparams)); + sparams.tstamp_mode = SNDRV_PCM_TSTAMP_NONE; + sparams.period_step = 1; + sparams.avail_min = 1; + sparams.start_threshold = period_cnt * period_sz; + sparams.stop_threshold = period_cnt * period_sz; + sparams.xfer_align = period_sz / 2; /* needed for old kernels */ + sparams.silence_size = 0; + sparams.silence_threshold = 0; + + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sparams)) { + oops(pcm, errno, "cannot set sw params"); + goto fail; + } + + pcm->buffer_size = period_cnt * period_sz; + pcm->underruns = 0; + return pcm; + +fail: + close(pcm->fd); + pcm->fd = -1; + return pcm; +} + +int pcm_ready(struct pcm *pcm) +{ + return pcm->fd >= 0; +} diff --git a/libaudio/amix.c b/libaudio/amix.c new file mode 100644 index 0000000..d978caa --- /dev/null +++ b/libaudio/amix.c @@ -0,0 +1,78 @@ +/* +** Copyright 2010, The Android Open-Source Project +** +** 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 "alsa_audio.h" + + +struct mixer_ctl *get_ctl(struct mixer *mixer, char *name) +{ + char *p; + unsigned idx = 0; + + if (isdigit(name[0])) + return mixer_get_nth_control(mixer, atoi(name) - 1); + + p = strrchr(name, '#'); + if (p) { + *p++ = 0; + idx = atoi(p); + } + + return mixer_get_control(mixer, name, idx); +} + +int main(int argc, char **argv) +{ + struct mixer *mixer; + struct mixer_ctl *ctl; + int r; + + mixer = mixer_open(); + if (!mixer) + return -1; + + if (argc == 1) { + mixer_dump(mixer); + return 0; + } + + ctl = get_ctl(mixer, argv[1]); + argc -= 2; + argv += 2; + + if (!ctl) { + fprintf(stderr,"can't find control\n"); + return -1; + } + + if (argc) { + if (isdigit(argv[0][0])) + r = mixer_ctl_set(ctl, atoi(argv[0])); + else + r = mixer_ctl_select(ctl, argv[0]); + if (r) + fprintf(stderr,"oops: %s\n", strerror(errno)); + } else { + mixer_ctl_print(ctl); + } + return 0; +} diff --git a/libaudio/aplay.c b/libaudio/aplay.c new file mode 100644 index 0000000..0ac0ac0 --- /dev/null +++ b/libaudio/aplay.c @@ -0,0 +1,140 @@ +/* +** Copyright 2010, The Android Open-Source Project +** +** 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 "alsa_audio.h" + +#define ID_RIFF 0x46464952 +#define ID_WAVE 0x45564157 +#define ID_FMT 0x20746d66 +#define ID_DATA 0x61746164 + +#define FORMAT_PCM 1 + +struct wav_header { + uint32_t riff_id; + uint32_t riff_sz; + uint32_t riff_fmt; + uint32_t fmt_id; + uint32_t fmt_sz; + uint16_t audio_format; + uint16_t num_channels; + uint32_t sample_rate; + uint32_t byte_rate; /* sample_rate * num_channels * bps / 8 */ + uint16_t block_align; /* num_channels * bps / 8 */ + uint16_t bits_per_sample; + uint32_t data_id; + uint32_t data_sz; +}; + +int play_file(unsigned rate, unsigned channels, int fd, unsigned count) +{ + struct pcm *pcm; + struct mixer *mixer; + struct pcm_ctl *ctl = NULL; + unsigned bufsize; + char *data; + unsigned flags = PCM_OUT; + + if (channels == 1) + flags |= PCM_MONO; + else + flags |= PCM_STEREO; + + pcm = pcm_open(flags); + if (!pcm_ready(pcm)) { + pcm_close(pcm); + return -1; + } + + mixer = mixer_open(); + if (mixer) + ctl = mixer_get_control(mixer,"Playback Path", 0); + + bufsize = pcm_buffer_size(pcm); + data = malloc(bufsize); + if (!data) { + fprintf(stderr,"could not allocate %d bytes\n", count); + return -1; + } + + while (read(fd, data, bufsize) == bufsize) { + if (pcm_write(pcm, data, bufsize)) + break; + + /* HACK: remove */ + if (ctl) { + //mixer_ctl_select(ctl, "SPK"); + ctl = 0; + } + } + pcm_close(pcm); + return 0; +} + +int play_wav(const char *fn) +{ + struct wav_header hdr; + unsigned rate, channels; + int fd; + fd = open(fn, O_RDONLY); + if (fd < 0) { + fprintf(stderr, "aplay: cannot open '%s'\n", fn); + return -1; + } + if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) { + fprintf(stderr, "aplay: cannot read header\n"); + return -1; + } + fprintf(stderr,"aplay: %d ch, %d hz, %d bit, %s\n", + hdr.num_channels, hdr.sample_rate, hdr.bits_per_sample, + hdr.audio_format == FORMAT_PCM ? "PCM" : "unknown"); + + if ((hdr.riff_id != ID_RIFF) || + (hdr.riff_fmt != ID_WAVE) || + (hdr.fmt_id != ID_FMT)) { + fprintf(stderr, "aplay: '%s' is not a riff/wave file\n", fn); + return -1; + } + if ((hdr.audio_format != FORMAT_PCM) || + (hdr.fmt_sz != 16)) { + fprintf(stderr, "aplay: '%s' is not pcm format\n", fn); + return -1; + } + if (hdr.bits_per_sample != 16) { + fprintf(stderr, "aplay: '%s' is not 16bit per sample\n", fn); + return -1; + } + + return play_file(hdr.sample_rate, hdr.num_channels, fd, hdr.data_sz); +} + +int main(int argc, char **argv) +{ + if (argc != 2) { + fprintf(stderr,"usage: aplay \n"); + return -1; + } + + return play_wav(argv[1]); +} + diff --git a/libaudio/arec.c b/libaudio/arec.c new file mode 100644 index 0000000..b1e9eda --- /dev/null +++ b/libaudio/arec.c @@ -0,0 +1,128 @@ +/* +** Copyright 2010, The Android Open-Source Project +** +** 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 "alsa_audio.h" + +#define ID_RIFF 0x46464952 +#define ID_WAVE 0x45564157 +#define ID_FMT 0x20746d66 +#define ID_DATA 0x61746164 + +#define FORMAT_PCM 1 + +struct wav_header { + uint32_t riff_id; + uint32_t riff_sz; + uint32_t riff_fmt; + uint32_t fmt_id; + uint32_t fmt_sz; + uint16_t audio_format; + uint16_t num_channels; + uint32_t sample_rate; + uint32_t byte_rate; /* sample_rate * num_channels * bps / 8 */ + uint16_t block_align; /* num_channels * bps / 8 */ + uint16_t bits_per_sample; + uint32_t data_id; + uint32_t data_sz; +}; + +int record_file(unsigned rate, unsigned channels, int fd, unsigned count) +{ + struct pcm *pcm; + unsigned avail, xfer, bufsize; + char *data, *next; + int r; + + pcm = pcm_open(PCM_IN|PCM_MONO); + if (!pcm_ready(pcm)) { + pcm_close(pcm); + goto fail; + } + + bufsize = pcm_buffer_size(pcm); + + data = malloc(bufsize); + if (!data) { + fprintf(stderr,"could not allocate %d bytes\n", count); + return -1; + } + + while (!pcm_read(pcm, data, bufsize)) { + if (write(fd, data, bufsize) != bufsize) { + fprintf(stderr,"could not write %d bytes\n", bufsize); + return -1; + } + } + + close(fd); + pcm_close(pcm); + return 0; + +fail: + fprintf(stderr,"pcm error: %s\n", pcm_error(pcm)); + return -1; +} + +int rec_wav(const char *fn) +{ + struct wav_header hdr; + unsigned rate, channels; + int fd; + fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC, 0664); + if (fd < 0) { + fprintf(stderr, "arec: cannot open '%s'\n", fn); + return -1; + } + + hdr.riff_id = ID_RIFF; + hdr.riff_fmt = ID_WAVE; + hdr.fmt_id = ID_FMT; + hdr.audio_format = FORMAT_PCM; + hdr.fmt_sz = 16; + hdr.bits_per_sample = 16; + hdr.num_channels = 1; + hdr.data_sz = 0; + hdr.sample_rate = 44100; + + if (write(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) { + fprintf(stderr, "arec: cannot write header\n"); + return -1; + } + fprintf(stderr,"arec: %d ch, %d hz, %d bit, %s\n", + hdr.num_channels, hdr.sample_rate, hdr.bits_per_sample, + hdr.audio_format == FORMAT_PCM ? "PCM" : "unknown"); + + + return record_file(hdr.sample_rate, hdr.num_channels, fd, hdr.data_sz); +} + +int main(int argc, char **argv) +{ + if (argc != 2) { + fprintf(stderr,"usage: arec \n"); + return -1; + } + + return rec_wav(argv[1]); +} + diff --git a/libaudio/asound.h b/libaudio/asound.h new file mode 100644 index 0000000..6a17f29 --- /dev/null +++ b/libaudio/asound.h @@ -0,0 +1,814 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + **************************************************************************** + ****************************************************************************/ +#ifndef __SOUND_ASOUND_H +#define __SOUND_ASOUND_H + +#include + +#define SNDRV_PROTOCOL_VERSION(major, minor, subminor) (((major)<<16)|((minor)<<8)|(subminor)) +#define SNDRV_PROTOCOL_MAJOR(version) (((version)>>16)&0xffff) +#define SNDRV_PROTOCOL_MINOR(version) (((version)>>8)&0xff) +#define SNDRV_PROTOCOL_MICRO(version) ((version)&0xff) +#define SNDRV_PROTOCOL_INCOMPATIBLE(kversion, uversion) (SNDRV_PROTOCOL_MAJOR(kversion) != SNDRV_PROTOCOL_MAJOR(uversion) || (SNDRV_PROTOCOL_MAJOR(kversion) == SNDRV_PROTOCOL_MAJOR(uversion) && SNDRV_PROTOCOL_MINOR(kversion) != SNDRV_PROTOCOL_MINOR(uversion))) + +struct snd_aes_iec958 { + unsigned char status[24]; + unsigned char subcode[147]; + unsigned char pad; + unsigned char dig_subframe[4]; +}; + +#define SNDRV_HWDEP_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 1) + +enum { + SNDRV_HWDEP_IFACE_OPL2 = 0, + SNDRV_HWDEP_IFACE_OPL3, + SNDRV_HWDEP_IFACE_OPL4, + SNDRV_HWDEP_IFACE_SB16CSP, + SNDRV_HWDEP_IFACE_EMU10K1, + SNDRV_HWDEP_IFACE_YSS225, + SNDRV_HWDEP_IFACE_ICS2115, + SNDRV_HWDEP_IFACE_SSCAPE, + SNDRV_HWDEP_IFACE_VX, + SNDRV_HWDEP_IFACE_MIXART, + SNDRV_HWDEP_IFACE_USX2Y, + SNDRV_HWDEP_IFACE_EMUX_WAVETABLE, + SNDRV_HWDEP_IFACE_BLUETOOTH, + SNDRV_HWDEP_IFACE_USX2Y_PCM, + SNDRV_HWDEP_IFACE_PCXHR, + SNDRV_HWDEP_IFACE_SB_RC, + SNDRV_HWDEP_IFACE_HDA, + SNDRV_HWDEP_IFACE_USB_STREAM, + + SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_USB_STREAM +}; + +struct snd_hwdep_info { + unsigned int device; + int card; + unsigned char id[64]; + unsigned char name[80]; + int iface; + unsigned char reserved[64]; +}; + +struct snd_hwdep_dsp_status { + unsigned int version; + unsigned char id[32]; + unsigned int num_dsps; + unsigned int dsp_loaded; + unsigned int chip_ready; + unsigned char reserved[16]; +}; + +struct snd_hwdep_dsp_image { + unsigned int index; + unsigned char name[64]; + unsigned char __user *image; + size_t length; + unsigned long driver_data; +}; + +#define SNDRV_HWDEP_IOCTL_PVERSION _IOR ('H', 0x00, int) +#define SNDRV_HWDEP_IOCTL_INFO _IOR ('H', 0x01, struct snd_hwdep_info) +#define SNDRV_HWDEP_IOCTL_DSP_STATUS _IOR('H', 0x02, struct snd_hwdep_dsp_status) +#define SNDRV_HWDEP_IOCTL_DSP_LOAD _IOW('H', 0x03, struct snd_hwdep_dsp_image) + +#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 10) + +typedef unsigned long snd_pcm_uframes_t; +typedef signed long snd_pcm_sframes_t; + +enum { + SNDRV_PCM_CLASS_GENERIC = 0, + SNDRV_PCM_CLASS_MULTI, + SNDRV_PCM_CLASS_MODEM, + SNDRV_PCM_CLASS_DIGITIZER, + + SNDRV_PCM_CLASS_LAST = SNDRV_PCM_CLASS_DIGITIZER, +}; + +enum { + SNDRV_PCM_SUBCLASS_GENERIC_MIX = 0, + SNDRV_PCM_SUBCLASS_MULTI_MIX, + + SNDRV_PCM_SUBCLASS_LAST = SNDRV_PCM_SUBCLASS_MULTI_MIX, +}; + +enum { + SNDRV_PCM_STREAM_PLAYBACK = 0, + SNDRV_PCM_STREAM_CAPTURE, + SNDRV_PCM_STREAM_LAST = SNDRV_PCM_STREAM_CAPTURE, +}; + +typedef int __bitwise snd_pcm_access_t; +#define SNDRV_PCM_ACCESS_MMAP_INTERLEAVED ((__force snd_pcm_access_t) 0) +#define SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED ((__force snd_pcm_access_t) 1) +#define SNDRV_PCM_ACCESS_MMAP_COMPLEX ((__force snd_pcm_access_t) 2) +#define SNDRV_PCM_ACCESS_RW_INTERLEAVED ((__force snd_pcm_access_t) 3) +#define SNDRV_PCM_ACCESS_RW_NONINTERLEAVED ((__force snd_pcm_access_t) 4) +#define SNDRV_PCM_ACCESS_LAST SNDRV_PCM_ACCESS_RW_NONINTERLEAVED + +typedef int __bitwise snd_pcm_format_t; +#define SNDRV_PCM_FORMAT_S8 ((__force snd_pcm_format_t) 0) +#define SNDRV_PCM_FORMAT_U8 ((__force snd_pcm_format_t) 1) +#define SNDRV_PCM_FORMAT_S16_LE ((__force snd_pcm_format_t) 2) +#define SNDRV_PCM_FORMAT_S16_BE ((__force snd_pcm_format_t) 3) +#define SNDRV_PCM_FORMAT_U16_LE ((__force snd_pcm_format_t) 4) +#define SNDRV_PCM_FORMAT_U16_BE ((__force snd_pcm_format_t) 5) +#define SNDRV_PCM_FORMAT_S24_LE ((__force snd_pcm_format_t) 6) +#define SNDRV_PCM_FORMAT_S24_BE ((__force snd_pcm_format_t) 7) +#define SNDRV_PCM_FORMAT_U24_LE ((__force snd_pcm_format_t) 8) +#define SNDRV_PCM_FORMAT_U24_BE ((__force snd_pcm_format_t) 9) +#define SNDRV_PCM_FORMAT_S32_LE ((__force snd_pcm_format_t) 10) +#define SNDRV_PCM_FORMAT_S32_BE ((__force snd_pcm_format_t) 11) +#define SNDRV_PCM_FORMAT_U32_LE ((__force snd_pcm_format_t) 12) +#define SNDRV_PCM_FORMAT_U32_BE ((__force snd_pcm_format_t) 13) +#define SNDRV_PCM_FORMAT_FLOAT_LE ((__force snd_pcm_format_t) 14) +#define SNDRV_PCM_FORMAT_FLOAT_BE ((__force snd_pcm_format_t) 15) +#define SNDRV_PCM_FORMAT_FLOAT64_LE ((__force snd_pcm_format_t) 16) +#define SNDRV_PCM_FORMAT_FLOAT64_BE ((__force snd_pcm_format_t) 17) +#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE ((__force snd_pcm_format_t) 18) +#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE ((__force snd_pcm_format_t) 19) +#define SNDRV_PCM_FORMAT_MU_LAW ((__force snd_pcm_format_t) 20) +#define SNDRV_PCM_FORMAT_A_LAW ((__force snd_pcm_format_t) 21) +#define SNDRV_PCM_FORMAT_IMA_ADPCM ((__force snd_pcm_format_t) 22) +#define SNDRV_PCM_FORMAT_MPEG ((__force snd_pcm_format_t) 23) +#define SNDRV_PCM_FORMAT_GSM ((__force snd_pcm_format_t) 24) +#define SNDRV_PCM_FORMAT_SPECIAL ((__force snd_pcm_format_t) 31) +#define SNDRV_PCM_FORMAT_S24_3LE ((__force snd_pcm_format_t) 32) +#define SNDRV_PCM_FORMAT_S24_3BE ((__force snd_pcm_format_t) 33) +#define SNDRV_PCM_FORMAT_U24_3LE ((__force snd_pcm_format_t) 34) +#define SNDRV_PCM_FORMAT_U24_3BE ((__force snd_pcm_format_t) 35) +#define SNDRV_PCM_FORMAT_S20_3LE ((__force snd_pcm_format_t) 36) +#define SNDRV_PCM_FORMAT_S20_3BE ((__force snd_pcm_format_t) 37) +#define SNDRV_PCM_FORMAT_U20_3LE ((__force snd_pcm_format_t) 38) +#define SNDRV_PCM_FORMAT_U20_3BE ((__force snd_pcm_format_t) 39) +#define SNDRV_PCM_FORMAT_S18_3LE ((__force snd_pcm_format_t) 40) +#define SNDRV_PCM_FORMAT_S18_3BE ((__force snd_pcm_format_t) 41) +#define SNDRV_PCM_FORMAT_U18_3LE ((__force snd_pcm_format_t) 42) +#define SNDRV_PCM_FORMAT_U18_3BE ((__force snd_pcm_format_t) 43) +#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_U18_3BE + +#ifdef SNDRV_LITTLE_ENDIAN +#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE +#define SNDRV_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16_LE +#define SNDRV_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24_LE +#define SNDRV_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24_LE +#define SNDRV_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32_LE +#define SNDRV_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32_LE +#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_LE +#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_LE +#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE +#endif +#ifdef SNDRV_BIG_ENDIAN +#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_BE +#define SNDRV_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16_BE +#define SNDRV_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24_BE +#define SNDRV_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24_BE +#define SNDRV_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32_BE +#define SNDRV_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32_BE +#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_BE +#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_BE +#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE +#endif + +typedef int __bitwise snd_pcm_subformat_t; +#define SNDRV_PCM_SUBFORMAT_STD ((__force snd_pcm_subformat_t) 0) +#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_STD + +#define SNDRV_PCM_INFO_MMAP 0x00000001 +#define SNDRV_PCM_INFO_MMAP_VALID 0x00000002 +#define SNDRV_PCM_INFO_DOUBLE 0x00000004 +#define SNDRV_PCM_INFO_BATCH 0x00000010 +#define SNDRV_PCM_INFO_INTERLEAVED 0x00000100 +#define SNDRV_PCM_INFO_NONINTERLEAVED 0x00000200 +#define SNDRV_PCM_INFO_COMPLEX 0x00000400 +#define SNDRV_PCM_INFO_BLOCK_TRANSFER 0x00010000 +#define SNDRV_PCM_INFO_OVERRANGE 0x00020000 +#define SNDRV_PCM_INFO_RESUME 0x00040000 +#define SNDRV_PCM_INFO_PAUSE 0x00080000 +#define SNDRV_PCM_INFO_HALF_DUPLEX 0x00100000 +#define SNDRV_PCM_INFO_JOINT_DUPLEX 0x00200000 +#define SNDRV_PCM_INFO_SYNC_START 0x00400000 +#define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 + +typedef int __bitwise snd_pcm_state_t; +#define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) +#define SNDRV_PCM_STATE_SETUP ((__force snd_pcm_state_t) 1) +#define SNDRV_PCM_STATE_PREPARED ((__force snd_pcm_state_t) 2) +#define SNDRV_PCM_STATE_RUNNING ((__force snd_pcm_state_t) 3) +#define SNDRV_PCM_STATE_XRUN ((__force snd_pcm_state_t) 4) +#define SNDRV_PCM_STATE_DRAINING ((__force snd_pcm_state_t) 5) +#define SNDRV_PCM_STATE_PAUSED ((__force snd_pcm_state_t) 6) +#define SNDRV_PCM_STATE_SUSPENDED ((__force snd_pcm_state_t) 7) +#define SNDRV_PCM_STATE_DISCONNECTED ((__force snd_pcm_state_t) 8) +#define SNDRV_PCM_STATE_LAST SNDRV_PCM_STATE_DISCONNECTED + +enum { + SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000, + SNDRV_PCM_MMAP_OFFSET_STATUS = 0x80000000, + SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000, +}; + +union snd_pcm_sync_id { + unsigned char id[16]; + unsigned short id16[8]; + unsigned int id32[4]; +}; + +struct snd_pcm_info { + unsigned int device; + unsigned int subdevice; + int stream; + int card; + unsigned char id[64]; + unsigned char name[80]; + unsigned char subname[32]; + int dev_class; + int dev_subclass; + unsigned int subdevices_count; + unsigned int subdevices_avail; + union snd_pcm_sync_id sync; + unsigned char reserved[64]; +}; + +typedef int snd_pcm_hw_param_t; +#define SNDRV_PCM_HW_PARAM_ACCESS 0 +#define SNDRV_PCM_HW_PARAM_FORMAT 1 +#define SNDRV_PCM_HW_PARAM_SUBFORMAT 2 +#define SNDRV_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_ACCESS +#define SNDRV_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_SUBFORMAT + +#define SNDRV_PCM_HW_PARAM_SAMPLE_BITS 8 +#define SNDRV_PCM_HW_PARAM_FRAME_BITS 9 +#define SNDRV_PCM_HW_PARAM_CHANNELS 10 +#define SNDRV_PCM_HW_PARAM_RATE 11 +#define SNDRV_PCM_HW_PARAM_PERIOD_TIME 12 +#define SNDRV_PCM_HW_PARAM_PERIOD_SIZE 13 +#define SNDRV_PCM_HW_PARAM_PERIOD_BYTES 14 +#define SNDRV_PCM_HW_PARAM_PERIODS 15 +#define SNDRV_PCM_HW_PARAM_BUFFER_TIME 16 +#define SNDRV_PCM_HW_PARAM_BUFFER_SIZE 17 +#define SNDRV_PCM_HW_PARAM_BUFFER_BYTES 18 +#define SNDRV_PCM_HW_PARAM_TICK_TIME 19 +#define SNDRV_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_SAMPLE_BITS +#define SNDRV_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_TICK_TIME + +#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) + +struct snd_interval { + unsigned int min, max; + unsigned int openmin:1, + openmax:1, + integer:1, + empty:1; +}; + +#define SNDRV_MASK_MAX 256 + +struct snd_mask { + __u32 bits[(SNDRV_MASK_MAX+31)/32]; +}; + +struct snd_pcm_hw_params { + unsigned int flags; + struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - + SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; + struct snd_mask mres[5]; + struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - + SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1]; + struct snd_interval ires[9]; + unsigned int rmask; + unsigned int cmask; + unsigned int info; + unsigned int msbits; + unsigned int rate_num; + unsigned int rate_den; + snd_pcm_uframes_t fifo_size; + unsigned char reserved[64]; +}; + +enum { + SNDRV_PCM_TSTAMP_NONE = 0, + SNDRV_PCM_TSTAMP_ENABLE, + SNDRV_PCM_TSTAMP_LAST = SNDRV_PCM_TSTAMP_ENABLE, +}; + +struct snd_pcm_sw_params { + int tstamp_mode; + unsigned int period_step; + unsigned int sleep_min; + snd_pcm_uframes_t avail_min; + snd_pcm_uframes_t xfer_align; + snd_pcm_uframes_t start_threshold; + snd_pcm_uframes_t stop_threshold; + snd_pcm_uframes_t silence_threshold; + snd_pcm_uframes_t silence_size; + snd_pcm_uframes_t boundary; + unsigned char reserved[64]; +}; + +struct snd_pcm_channel_info { + unsigned int channel; + __kernel_off_t offset; + unsigned int first; + unsigned int step; +}; + +struct snd_pcm_status { + snd_pcm_state_t state; + struct timespec trigger_tstamp; + struct timespec tstamp; + snd_pcm_uframes_t appl_ptr; + snd_pcm_uframes_t hw_ptr; + snd_pcm_sframes_t delay; + snd_pcm_uframes_t avail; + snd_pcm_uframes_t avail_max; + snd_pcm_uframes_t overrange; + snd_pcm_state_t suspended_state; + unsigned char reserved[60]; +}; + +struct snd_pcm_mmap_status { + snd_pcm_state_t state; + int pad1; + snd_pcm_uframes_t hw_ptr; + struct timespec tstamp; + snd_pcm_state_t suspended_state; +}; + +struct snd_pcm_mmap_control { + snd_pcm_uframes_t appl_ptr; + snd_pcm_uframes_t avail_min; +}; + +#define SNDRV_PCM_SYNC_PTR_HWSYNC (1<<0) +#define SNDRV_PCM_SYNC_PTR_APPL (1<<1) +#define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1<<2) + +struct snd_pcm_sync_ptr { + unsigned int flags; + union { + struct snd_pcm_mmap_status status; + unsigned char reserved[64]; + } s; + union { + struct snd_pcm_mmap_control control; + unsigned char reserved[64]; + } c; +}; + +struct snd_xferi { + snd_pcm_sframes_t result; + void __user *buf; + snd_pcm_uframes_t frames; +}; + +struct snd_xfern { + snd_pcm_sframes_t result; + void __user * __user *bufs; + snd_pcm_uframes_t frames; +}; + +enum { + SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0, + SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, + SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, +}; + +#define SNDRV_PCM_IOCTL_PVERSION _IOR('A', 0x00, int) +#define SNDRV_PCM_IOCTL_INFO _IOR('A', 0x01, struct snd_pcm_info) +#define SNDRV_PCM_IOCTL_TSTAMP _IOW('A', 0x02, int) +#define SNDRV_PCM_IOCTL_TTSTAMP _IOW('A', 0x03, int) +#define SNDRV_PCM_IOCTL_HW_REFINE _IOWR('A', 0x10, struct snd_pcm_hw_params) +#define SNDRV_PCM_IOCTL_HW_PARAMS _IOWR('A', 0x11, struct snd_pcm_hw_params) +#define SNDRV_PCM_IOCTL_HW_FREE _IO('A', 0x12) +#define SNDRV_PCM_IOCTL_SW_PARAMS _IOWR('A', 0x13, struct snd_pcm_sw_params) +#define SNDRV_PCM_IOCTL_STATUS _IOR('A', 0x20, struct snd_pcm_status) +#define SNDRV_PCM_IOCTL_DELAY _IOR('A', 0x21, snd_pcm_sframes_t) +#define SNDRV_PCM_IOCTL_HWSYNC _IO('A', 0x22) +#define SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct snd_pcm_sync_ptr) +#define SNDRV_PCM_IOCTL_CHANNEL_INFO _IOR('A', 0x32, struct snd_pcm_channel_info) +#define SNDRV_PCM_IOCTL_PREPARE _IO('A', 0x40) +#define SNDRV_PCM_IOCTL_RESET _IO('A', 0x41) +#define SNDRV_PCM_IOCTL_START _IO('A', 0x42) +#define SNDRV_PCM_IOCTL_DROP _IO('A', 0x43) +#define SNDRV_PCM_IOCTL_DRAIN _IO('A', 0x44) +#define SNDRV_PCM_IOCTL_PAUSE _IOW('A', 0x45, int) +#define SNDRV_PCM_IOCTL_REWIND _IOW('A', 0x46, snd_pcm_uframes_t) +#define SNDRV_PCM_IOCTL_RESUME _IO('A', 0x47) +#define SNDRV_PCM_IOCTL_XRUN _IO('A', 0x48) +#define SNDRV_PCM_IOCTL_FORWARD _IOW('A', 0x49, snd_pcm_uframes_t) +#define SNDRV_PCM_IOCTL_WRITEI_FRAMES _IOW('A', 0x50, struct snd_xferi) +#define SNDRV_PCM_IOCTL_READI_FRAMES _IOR('A', 0x51, struct snd_xferi) +#define SNDRV_PCM_IOCTL_WRITEN_FRAMES _IOW('A', 0x52, struct snd_xfern) +#define SNDRV_PCM_IOCTL_READN_FRAMES _IOR('A', 0x53, struct snd_xfern) +#define SNDRV_PCM_IOCTL_LINK _IOW('A', 0x60, int) +#define SNDRV_PCM_IOCTL_UNLINK _IO('A', 0x61) + +#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 0) + +enum { + SNDRV_RAWMIDI_STREAM_OUTPUT = 0, + SNDRV_RAWMIDI_STREAM_INPUT, + SNDRV_RAWMIDI_STREAM_LAST = SNDRV_RAWMIDI_STREAM_INPUT, +}; + +#define SNDRV_RAWMIDI_INFO_OUTPUT 0x00000001 +#define SNDRV_RAWMIDI_INFO_INPUT 0x00000002 +#define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004 + +struct snd_rawmidi_info { + unsigned int device; + unsigned int subdevice; + int stream; + int card; + unsigned int flags; + unsigned char id[64]; + unsigned char name[80]; + unsigned char subname[32]; + unsigned int subdevices_count; + unsigned int subdevices_avail; + unsigned char reserved[64]; +}; + +struct snd_rawmidi_params { + int stream; + size_t buffer_size; + size_t avail_min; + unsigned int no_active_sensing: 1; + unsigned char reserved[16]; +}; + +struct snd_rawmidi_status { + int stream; + struct timespec tstamp; + size_t avail; + size_t xruns; + unsigned char reserved[16]; +}; + +#define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int) +#define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info) +#define SNDRV_RAWMIDI_IOCTL_PARAMS _IOWR('W', 0x10, struct snd_rawmidi_params) +#define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status) +#define SNDRV_RAWMIDI_IOCTL_DROP _IOW('W', 0x30, int) +#define SNDRV_RAWMIDI_IOCTL_DRAIN _IOW('W', 0x31, int) + +#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6) + +enum { + SNDRV_TIMER_CLASS_NONE = -1, + SNDRV_TIMER_CLASS_SLAVE = 0, + SNDRV_TIMER_CLASS_GLOBAL, + SNDRV_TIMER_CLASS_CARD, + SNDRV_TIMER_CLASS_PCM, + SNDRV_TIMER_CLASS_LAST = SNDRV_TIMER_CLASS_PCM, +}; + +enum { + SNDRV_TIMER_SCLASS_NONE = 0, + SNDRV_TIMER_SCLASS_APPLICATION, + SNDRV_TIMER_SCLASS_SEQUENCER, + SNDRV_TIMER_SCLASS_OSS_SEQUENCER, + SNDRV_TIMER_SCLASS_LAST = SNDRV_TIMER_SCLASS_OSS_SEQUENCER, +}; + +#define SNDRV_TIMER_GLOBAL_SYSTEM 0 +#define SNDRV_TIMER_GLOBAL_RTC 1 +#define SNDRV_TIMER_GLOBAL_HPET 2 +#define SNDRV_TIMER_GLOBAL_HRTIMER 3 + +#define SNDRV_TIMER_FLG_SLAVE (1<<0) + +struct snd_timer_id { + int dev_class; + int dev_sclass; + int card; + int device; + int subdevice; +}; + +struct snd_timer_ginfo { + struct snd_timer_id tid; + unsigned int flags; + int card; + unsigned char id[64]; + unsigned char name[80]; + unsigned long reserved0; + unsigned long resolution; + unsigned long resolution_min; + unsigned long resolution_max; + unsigned int clients; + unsigned char reserved[32]; +}; + +struct snd_timer_gparams { + struct snd_timer_id tid; + unsigned long period_num; + unsigned long period_den; + unsigned char reserved[32]; +}; + +struct snd_timer_gstatus { + struct snd_timer_id tid; + unsigned long resolution; + unsigned long resolution_num; + unsigned long resolution_den; + unsigned char reserved[32]; +}; + +struct snd_timer_select { + struct snd_timer_id id; + unsigned char reserved[32]; +}; + +struct snd_timer_info { + unsigned int flags; + int card; + unsigned char id[64]; + unsigned char name[80]; + unsigned long reserved0; + unsigned long resolution; + unsigned char reserved[64]; +}; + +#define SNDRV_TIMER_PSFLG_AUTO (1<<0) +#define SNDRV_TIMER_PSFLG_EXCLUSIVE (1<<1) +#define SNDRV_TIMER_PSFLG_EARLY_EVENT (1<<2) + +struct snd_timer_params { + unsigned int flags; + unsigned int ticks; + unsigned int queue_size; + unsigned int reserved0; + unsigned int filter; + unsigned char reserved[60]; +}; + +struct snd_timer_status { + struct timespec tstamp; + unsigned int resolution; + unsigned int lost; + unsigned int overrun; + unsigned int queue; + unsigned char reserved[64]; +}; + +#define SNDRV_TIMER_IOCTL_PVERSION _IOR('T', 0x00, int) +#define SNDRV_TIMER_IOCTL_NEXT_DEVICE _IOWR('T', 0x01, struct snd_timer_id) +#define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x02, int) +#define SNDRV_TIMER_IOCTL_GINFO _IOWR('T', 0x03, struct snd_timer_ginfo) +#define SNDRV_TIMER_IOCTL_GPARAMS _IOW('T', 0x04, struct snd_timer_gparams) +#define SNDRV_TIMER_IOCTL_GSTATUS _IOWR('T', 0x05, struct snd_timer_gstatus) +#define SNDRV_TIMER_IOCTL_SELECT _IOW('T', 0x10, struct snd_timer_select) +#define SNDRV_TIMER_IOCTL_INFO _IOR('T', 0x11, struct snd_timer_info) +#define SNDRV_TIMER_IOCTL_PARAMS _IOW('T', 0x12, struct snd_timer_params) +#define SNDRV_TIMER_IOCTL_STATUS _IOR('T', 0x14, struct snd_timer_status) + +#define SNDRV_TIMER_IOCTL_START _IO('T', 0xa0) +#define SNDRV_TIMER_IOCTL_STOP _IO('T', 0xa1) +#define SNDRV_TIMER_IOCTL_CONTINUE _IO('T', 0xa2) +#define SNDRV_TIMER_IOCTL_PAUSE _IO('T', 0xa3) + +struct snd_timer_read { + unsigned int resolution; + unsigned int ticks; +}; + +enum { + SNDRV_TIMER_EVENT_RESOLUTION = 0, + SNDRV_TIMER_EVENT_TICK, + SNDRV_TIMER_EVENT_START, + SNDRV_TIMER_EVENT_STOP, + SNDRV_TIMER_EVENT_CONTINUE, + SNDRV_TIMER_EVENT_PAUSE, + SNDRV_TIMER_EVENT_EARLY, + SNDRV_TIMER_EVENT_SUSPEND, + SNDRV_TIMER_EVENT_RESUME, + + SNDRV_TIMER_EVENT_MSTART = SNDRV_TIMER_EVENT_START + 10, + SNDRV_TIMER_EVENT_MSTOP = SNDRV_TIMER_EVENT_STOP + 10, + SNDRV_TIMER_EVENT_MCONTINUE = SNDRV_TIMER_EVENT_CONTINUE + 10, + SNDRV_TIMER_EVENT_MPAUSE = SNDRV_TIMER_EVENT_PAUSE + 10, + SNDRV_TIMER_EVENT_MSUSPEND = SNDRV_TIMER_EVENT_SUSPEND + 10, + SNDRV_TIMER_EVENT_MRESUME = SNDRV_TIMER_EVENT_RESUME + 10, +}; + +struct snd_timer_tread { + int event; + struct timespec tstamp; + unsigned int val; +}; + +#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6) + +struct snd_ctl_card_info { + int card; + int pad; + unsigned char id[16]; + unsigned char driver[16]; + unsigned char name[32]; + unsigned char longname[80]; + unsigned char reserved_[16]; + unsigned char mixername[80]; + unsigned char components[128]; +}; + +typedef int __bitwise snd_ctl_elem_type_t; +#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0) +#define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1) +#define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2) +#define SNDRV_CTL_ELEM_TYPE_ENUMERATED ((__force snd_ctl_elem_type_t) 3) +#define SNDRV_CTL_ELEM_TYPE_BYTES ((__force snd_ctl_elem_type_t) 4) +#define SNDRV_CTL_ELEM_TYPE_IEC958 ((__force snd_ctl_elem_type_t) 5) +#define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force snd_ctl_elem_type_t) 6) +#define SNDRV_CTL_ELEM_TYPE_LAST SNDRV_CTL_ELEM_TYPE_INTEGER64 + +typedef int __bitwise snd_ctl_elem_iface_t; +#define SNDRV_CTL_ELEM_IFACE_CARD ((__force snd_ctl_elem_iface_t) 0) +#define SNDRV_CTL_ELEM_IFACE_HWDEP ((__force snd_ctl_elem_iface_t) 1) +#define SNDRV_CTL_ELEM_IFACE_MIXER ((__force snd_ctl_elem_iface_t) 2) +#define SNDRV_CTL_ELEM_IFACE_PCM ((__force snd_ctl_elem_iface_t) 3) +#define SNDRV_CTL_ELEM_IFACE_RAWMIDI ((__force snd_ctl_elem_iface_t) 4) +#define SNDRV_CTL_ELEM_IFACE_TIMER ((__force snd_ctl_elem_iface_t) 5) +#define SNDRV_CTL_ELEM_IFACE_SEQUENCER ((__force snd_ctl_elem_iface_t) 6) +#define SNDRV_CTL_ELEM_IFACE_LAST SNDRV_CTL_ELEM_IFACE_SEQUENCER + +#define SNDRV_CTL_ELEM_ACCESS_READ (1<<0) +#define SNDRV_CTL_ELEM_ACCESS_WRITE (1<<1) +#define SNDRV_CTL_ELEM_ACCESS_READWRITE (SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE) +#define SNDRV_CTL_ELEM_ACCESS_VOLATILE (1<<2) +#define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP (1<<3) +#define SNDRV_CTL_ELEM_ACCESS_TLV_READ (1<<4) +#define SNDRV_CTL_ELEM_ACCESS_TLV_WRITE (1<<5) +#define SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE (SNDRV_CTL_ELEM_ACCESS_TLV_READ|SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) +#define SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND (1<<6) +#define SNDRV_CTL_ELEM_ACCESS_INACTIVE (1<<8) +#define SNDRV_CTL_ELEM_ACCESS_LOCK (1<<9) +#define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10) +#define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28) +#define SNDRV_CTL_ELEM_ACCESS_USER (1<<29) + +#define SNDRV_CTL_POWER_D0 0x0000 +#define SNDRV_CTL_POWER_D1 0x0100 +#define SNDRV_CTL_POWER_D2 0x0200 +#define SNDRV_CTL_POWER_D3 0x0300 +#define SNDRV_CTL_POWER_D3hot (SNDRV_CTL_POWER_D3|0x0000) +#define SNDRV_CTL_POWER_D3cold (SNDRV_CTL_POWER_D3|0x0001) + +struct snd_ctl_elem_id { + unsigned int numid; + snd_ctl_elem_iface_t iface; + unsigned int device; + unsigned int subdevice; + unsigned char name[44]; + unsigned int index; +}; + +struct snd_ctl_elem_list { + unsigned int offset; + unsigned int space; + unsigned int used; + unsigned int count; + struct snd_ctl_elem_id __user *pids; + unsigned char reserved[50]; +}; + +struct snd_ctl_elem_info { + struct snd_ctl_elem_id id; + snd_ctl_elem_type_t type; + unsigned int access; + unsigned int count; + __kernel_pid_t owner; + union { + struct { + long min; + long max; + long step; + } integer; + struct { + long long min; + long long max; + long long step; + } integer64; + struct { + unsigned int items; + unsigned int item; + char name[64]; + } enumerated; + unsigned char reserved[128]; + } value; + union { + unsigned short d[4]; + unsigned short *d_ptr; + } dimen; + unsigned char reserved[64-4*sizeof(unsigned short)]; +}; + +struct snd_ctl_elem_value { + struct snd_ctl_elem_id id; + unsigned int indirect: 1; + union { + union { + long value[128]; + long *value_ptr; + } integer; + union { + long long value[64]; + long long *value_ptr; + } integer64; + union { + unsigned int item[128]; + unsigned int *item_ptr; + } enumerated; + union { + unsigned char data[512]; + unsigned char *data_ptr; + } bytes; + struct snd_aes_iec958 iec958; + } value; + struct timespec tstamp; + unsigned char reserved[128-sizeof(struct timespec)]; +}; + +struct snd_ctl_tlv { + unsigned int numid; + unsigned int length; + unsigned int tlv[0]; +}; + +#define SNDRV_CTL_IOCTL_PVERSION _IOR('U', 0x00, int) +#define SNDRV_CTL_IOCTL_CARD_INFO _IOR('U', 0x01, struct snd_ctl_card_info) +#define SNDRV_CTL_IOCTL_ELEM_LIST _IOWR('U', 0x10, struct snd_ctl_elem_list) +#define SNDRV_CTL_IOCTL_ELEM_INFO _IOWR('U', 0x11, struct snd_ctl_elem_info) +#define SNDRV_CTL_IOCTL_ELEM_READ _IOWR('U', 0x12, struct snd_ctl_elem_value) +#define SNDRV_CTL_IOCTL_ELEM_WRITE _IOWR('U', 0x13, struct snd_ctl_elem_value) +#define SNDRV_CTL_IOCTL_ELEM_LOCK _IOW('U', 0x14, struct snd_ctl_elem_id) +#define SNDRV_CTL_IOCTL_ELEM_UNLOCK _IOW('U', 0x15, struct snd_ctl_elem_id) +#define SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS _IOWR('U', 0x16, int) +#define SNDRV_CTL_IOCTL_ELEM_ADD _IOWR('U', 0x17, struct snd_ctl_elem_info) +#define SNDRV_CTL_IOCTL_ELEM_REPLACE _IOWR('U', 0x18, struct snd_ctl_elem_info) +#define SNDRV_CTL_IOCTL_ELEM_REMOVE _IOWR('U', 0x19, struct snd_ctl_elem_id) +#define SNDRV_CTL_IOCTL_TLV_READ _IOWR('U', 0x1a, struct snd_ctl_tlv) +#define SNDRV_CTL_IOCTL_TLV_WRITE _IOWR('U', 0x1b, struct snd_ctl_tlv) +#define SNDRV_CTL_IOCTL_TLV_COMMAND _IOWR('U', 0x1c, struct snd_ctl_tlv) +#define SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE _IOWR('U', 0x20, int) +#define SNDRV_CTL_IOCTL_HWDEP_INFO _IOR('U', 0x21, struct snd_hwdep_info) +#define SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE _IOR('U', 0x30, int) +#define SNDRV_CTL_IOCTL_PCM_INFO _IOWR('U', 0x31, struct snd_pcm_info) +#define SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE _IOW('U', 0x32, int) +#define SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE _IOWR('U', 0x40, int) +#define SNDRV_CTL_IOCTL_RAWMIDI_INFO _IOWR('U', 0x41, struct snd_rawmidi_info) +#define SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE _IOW('U', 0x42, int) +#define SNDRV_CTL_IOCTL_POWER _IOWR('U', 0xd0, int) +#define SNDRV_CTL_IOCTL_POWER_STATE _IOR('U', 0xd1, int) + +enum sndrv_ctl_event_type { + SNDRV_CTL_EVENT_ELEM = 0, + SNDRV_CTL_EVENT_LAST = SNDRV_CTL_EVENT_ELEM, +}; + +#define SNDRV_CTL_EVENT_MASK_VALUE (1<<0) +#define SNDRV_CTL_EVENT_MASK_INFO (1<<1) +#define SNDRV_CTL_EVENT_MASK_ADD (1<<2) +#define SNDRV_CTL_EVENT_MASK_TLV (1<<3) +#define SNDRV_CTL_EVENT_MASK_REMOVE (~0U) + +struct snd_ctl_event { + int type; + union { + struct { + unsigned int mask; + struct snd_ctl_elem_id id; + } elem; + unsigned char data8[60]; + } data; +}; + +#define SNDRV_CTL_NAME_NONE "" +#define SNDRV_CTL_NAME_PLAYBACK "Playback " +#define SNDRV_CTL_NAME_CAPTURE "Capture " + +#define SNDRV_CTL_NAME_IEC958_NONE "" +#define SNDRV_CTL_NAME_IEC958_SWITCH "Switch" +#define SNDRV_CTL_NAME_IEC958_VOLUME "Volume" +#define SNDRV_CTL_NAME_IEC958_DEFAULT "Default" +#define SNDRV_CTL_NAME_IEC958_MASK "Mask" +#define SNDRV_CTL_NAME_IEC958_CON_MASK "Con Mask" +#define SNDRV_CTL_NAME_IEC958_PRO_MASK "Pro Mask" +#define SNDRV_CTL_NAME_IEC958_PCM_STREAM "PCM Stream" +#define SNDRV_CTL_NAME_IEC958(expl,direction,what) "IEC958 " expl SNDRV_CTL_NAME_##direction SNDRV_CTL_NAME_IEC958_##what + +#endif + diff --git a/libaudio/secril-client.h b/libaudio/secril-client.h new file mode 100644 index 0000000..7bbaa03 --- /dev/null +++ b/libaudio/secril-client.h @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * 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 __SECRIL_CLIENT_H__ +#define __SECRIL_CLIENT_H__ + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +struct RilClient { + void *prv; +}; + +typedef struct RilClient * HRilClient; + + +//--------------------------------------------------------------------------- +// Defines +//--------------------------------------------------------------------------- +#define RIL_CLIENT_ERR_SUCCESS 0 +#define RIL_CLIENT_ERR_AGAIN 1 +#define RIL_CLIENT_ERR_INIT 2 // Client is not initialized +#define RIL_CLIENT_ERR_INVAL 3 // Invalid value +#define RIL_CLIENT_ERR_CONNECT 4 // Connection error +#define RIL_CLIENT_ERR_IO 5 // IO error +#define RIL_CLIENT_ERR_RESOURCE 6 // Resource not available +#define RIL_CLIENT_ERR_UNKNOWN 7 + + +//--------------------------------------------------------------------------- +// Type definitions +//--------------------------------------------------------------------------- + +typedef int (*RilOnComplete)(HRilClient handle, const void *data, size_t datalen); + +typedef int (*RilOnUnsolicited)(HRilClient handle, const void *data, size_t datalen); + +typedef int (*RilOnError)(void *data, int error); + + +//--------------------------------------------------------------------------- +// Client APIs +//--------------------------------------------------------------------------- + +/** + * Open RILD multi-client. + * Return is client handle, NULL on error. + */ +HRilClient OpenClient_RILD(void); + +/** + * Stop RILD multi-client. If client socket was connected, + * it will be disconnected. + */ +int CloseClient_RILD(HRilClient client); + +/** + * Connect to RIL deamon. One client task starts. + * Return is 0 or error code. + */ +int Connect_RILD(HRilClient client); + +/** + * check whether RILD is connected + * Returns 0 or 1 + */ +int isConnected_RILD(HRilClient client); + +/** + * Disconnect connection to RIL deamon(socket close). + * Return is 0 or error code. + */ +int Disconnect_RILD(HRilClient client); + +/** + * Register unsolicited response handler. If handler is NULL, + * the handler for the request ID is unregistered. + * The response handler is invoked in the client task context. + * Return is 0 or error code. + */ +int RegisterUnsolicitedHandler(HRilClient client, uint32_t id, RilOnUnsolicited handler); + +/** + * Register solicited response handler. If handler is NULL, + * the handler for the ID is unregistered. + * The response handler is invoked in the client task context. + * Return is 0 or error code. + */ +int RegisterRequestCompleteHandler(HRilClient client, uint32_t id, RilOnComplete handler); + +/** + * Register error callback. If handler is NULL, + * the callback is unregistered. + * The response handler is invoked in the client task context. + * Return is 0 or error code. + */ +int RegisterErrorCallback(HRilClient client, RilOnError cb, void *data); + +/** + * Invoke OEM request. Request ID is RIL_REQUEST_OEM_HOOK_RAW. + * Return is 0 or error code. For RIL_CLIENT_ERR_AGAIN caller should retry. + */ +int InvokeOemRequestHookRaw(HRilClient client, char *data, size_t len); + +/** + * Sound device types. + */ +typedef enum _SoundType { + SOUND_TYPE_VOICE, + SOUND_TYPE_SPEAKER, + SOUND_TYPE_HEADSET, + SOUND_TYPE_BTVOICE +} SoundType; + +/** + * External sound device path. + */ +typedef enum _AudioPath { + SOUND_AUDIO_PATH_HANDSET, + SOUND_AUDIO_PATH_HEADSET, + SOUND_AUDIO_PATH_SPEAKER, + SOUND_AUDIO_PATH_BLUETOOTH, + SOUND_AUDIO_PATH_BLUETOOTH_NO_NR, + SOUND_AUDIO_PATH_HEADPHONE +} AudioPath; + +/** + * Clock adjustment parameters. + */ +typedef enum _SoundClockCondition { + SOUND_CLOCK_STOP, + SOUND_CLOCK_START +} SoundClockCondition; + +/** + * Set in-call volume. + */ +int SetCallVolume(HRilClient client, SoundType type, int vol_level); + +/** + * Set external sound device path for noise reduction. + */ +int SetCallAudioPath(HRilClient client, AudioPath path); + +/** + * Set modem clock to master or slave. + */ +int SetCallClockSync(HRilClient client, SoundClockCondition condition); + +#ifdef __cplusplus +}; +#endif + +#endif // __SECRIL_CLIENT_H__ + +// end of file + diff --git a/libcamera/Android.mk b/libcamera/Android.mk new file mode 100644 index 0000000..f4b41bb --- /dev/null +++ b/libcamera/Android.mk @@ -0,0 +1,51 @@ +ifeq ($(Y_U_NO_HAVE_CAMERA),true) + +# When zero we link against libqcamera; when 1, we dlopen libqcamera. +ifeq ($(BOARD_CAMERA_LIBRARIES),libcamera) + +DLOPEN_LIBSECCAMERA:=1 + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_CFLAGS:=-fno-short-enums +LOCAL_CFLAGS+=-DDLOPEN_LIBSECCAMERA=$(DLOPEN_LIBSECCAMERA) + +ifdef BOARD_CAMERA_DEVICE + LOCAL_CFLAGS += -DCAMERA_DEV_NAME=\"$(BOARD_CAMERA_DEVICE)\" +endif + +ifdef BOARD_SECOND_CAMERA_DEVICE + LOCAL_CFLAGS += -DCAMERA_DEV_NAME2=\"$(BOARD_SECOND_CAMERA_DEVICE)\" + LOCAL_CFLAGS += -DFFC_PRESENT +endif + +LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include +LOCAL_C_INCLUDES += $(LOCAL_PATH)/../libs3cjpeg + + +LOCAL_SRC_FILES:= \ + SecCamera.cpp \ + SecCameraHWInterface.cpp + + +LOCAL_SHARED_LIBRARIES:= libutils libui liblog libbinder libcutils +LOCAL_SHARED_LIBRARIES+= libs3cjpeg.aries +LOCAL_SHARED_LIBRARIES+= libcamera_client + +ifeq ($(BOARD_USES_OVERLAY),true) +LOCAL_CFLAGS += -DBOARD_USES_OVERLAY +endif + +ifeq ($(DLOPEN_LIBSECCAMERA),1) +LOCAL_SHARED_LIBRARIES+= libdl +endif + +LOCAL_MODULE:= libcamera + +LOCAL_MODULE_TAGS := optional + +include $(BUILD_SHARED_LIBRARY) + +endif +endif diff --git a/libcamera/NOTICE b/libcamera/NOTICE new file mode 100644 index 0000000..f921593 --- /dev/null +++ b/libcamera/NOTICE @@ -0,0 +1,190 @@ + + Copyright (C) 2008 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + 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. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/libcamera/SecCamera.cpp b/libcamera/SecCamera.cpp new file mode 100644 index 0000000..4bd3fc7 --- /dev/null +++ b/libcamera/SecCamera.cpp @@ -0,0 +1,3142 @@ +/* + * Copyright 2008, The Android Open Source Project + * Copyright 2010, Samsung Electronics Co. LTD + * + * 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. + */ + +/* +************************************ +* Filename: SecCamera.cpp +* Author: Sachin P. Kamat +* Purpose: This file interacts with the Camera and JPEG drivers. +************************************* +*/ + +//#define LOG_NDEBUG 0 +#define LOG_TAG "SecCamera" + +#include + +#include +#include +#include +#include "SecCamera.h" +#include "cutils/properties.h" + +using namespace android; + +#define CHECK(return_value) \ + if (return_value < 0) { \ + LOGE("%s::%d fail. errno: %s, m_camera_id = %d\n", \ + __func__, __LINE__, strerror(errno), m_camera_id); \ + return -1; \ + } + + +#define CHECK_PTR(return_value) \ + if (return_value < 0) { \ + LOGE("%s::%d fail, errno: %s, m_camera_id = %d\n", \ + __func__,__LINE__, strerror(errno), m_camera_id); \ + return NULL; \ + } + +#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5) +#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7) +#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13) + +namespace android { + +// ====================================================================== +// Camera controls + +static struct timeval time_start; +static struct timeval time_stop; + +unsigned long measure_time(struct timeval *start, struct timeval *stop) +{ + unsigned long sec, usec, time; + + sec = stop->tv_sec - start->tv_sec; + + if (stop->tv_usec >= start->tv_usec) { + usec = stop->tv_usec - start->tv_usec; + } else { + usec = stop->tv_usec + 1000000 - start->tv_usec; + sec--; + } + + time = (sec * 1000000) + usec; + + return time; +} + +static int get_pixel_depth(unsigned int fmt) +{ + int depth = 0; + + switch (fmt) { + case V4L2_PIX_FMT_NV12: + depth = 12; + break; + case V4L2_PIX_FMT_NV12T: + depth = 12; + break; + case V4L2_PIX_FMT_NV21: + depth = 12; + break; + case V4L2_PIX_FMT_YUV420: + depth = 12; + break; + + case V4L2_PIX_FMT_RGB565: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_YVYU: + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_VYUY: + case V4L2_PIX_FMT_NV16: + case V4L2_PIX_FMT_NV61: + case V4L2_PIX_FMT_YUV422P: + depth = 16; + break; + + case V4L2_PIX_FMT_RGB32: + depth = 32; + break; + } + + return depth; +} + +#define ALIGN_W(x) (((x) + 0x7F) & (~0x7F)) // Set as multiple of 128 +#define ALIGN_H(x) (((x) + 0x1F) & (~0x1F)) // Set as multiple of 32 +#define ALIGN_BUF(x) (((x) + 0x1FFF)& (~0x1FFF)) // Set as multiple of 8K + +static int init_preview_buffers(struct fimc_buffer *buffers, int width, int height, unsigned int fmt) +{ + int i, len; + + if (fmt==V4L2_PIX_FMT_NV12T) { + len = ALIGN_BUF(ALIGN_W(width) * ALIGN_H(height)) + + ALIGN_BUF(ALIGN_W(width) * ALIGN_H(height / 2)); + } else { + len = (width * height * get_pixel_depth(fmt)) / 8; + } + + for (i = 0; i < MAX_BUFFERS; i++) { + buffers[i].length = len; + } + + return 0; +} + +static int fimc_poll(struct pollfd *events) +{ + int ret; + + /* 10 second delay is because sensor can take a long time + * to do auto focus and capture in dark settings + */ + ret = poll(events, 1, 10000); + if (ret < 0) { + LOGE("ERR(%s):poll error\n", __func__); + return ret; + } + + if (ret == 0) { + LOGE("ERR(%s):No data in 10 secs..\n", __func__); + return ret; + } + + return ret; +} + +int SecCamera::previewPoll(bool preview) +{ + int ret; + + if (preview) { +#ifdef ENABLE_ESD_PREVIEW_CHECK + int status = 0; + + if (!(++m_esd_check_count % 60)) { + status = getCameraSensorESDStatus(); + m_esd_check_count = 0; + if (status) { + LOGE("ERR(%s) ESD status(%d)", __func__, status); + return status; + } + } +#endif + + ret = poll(&m_events_c, 1, 1000); + } else { + ret = poll(&m_events_c2, 1, 1000); + } + + if (ret < 0) { + LOGE("ERR(%s):poll error\n", __func__); + return ret; + } + + if (ret == 0) { + LOGE("ERR(%s):No data in 1 secs.. Camera Device Reset \n", __func__); + return ret; + } + + return ret; +} + +static int fimc_v4l2_querycap(int fp) +{ + struct v4l2_capability cap; + int ret = 0; + + ret = ioctl(fp, VIDIOC_QUERYCAP, &cap); + + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_QUERYCAP failed\n", __func__); + return -1; + } + + if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { + LOGE("ERR(%s):no capture devices\n", __func__); + return -1; + } + + return ret; +} + +static const __u8* fimc_v4l2_enuminput(int fp, int index) +{ + static struct v4l2_input input; + + input.index = index; + if (ioctl(fp, VIDIOC_ENUMINPUT, &input) != 0) { + LOGE("ERR(%s):No matching index found\n", __func__); + return NULL; + } + LOGI("Name of input channel[%d] is %s\n", input.index, input.name); + + return input.name; +} + + +static int fimc_v4l2_s_input(int fp, int index) +{ + struct v4l2_input input; + int ret; + + input.index = index; + + ret = ioctl(fp, VIDIOC_S_INPUT, &input); + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_S_INPUT failed\n", __func__); + return ret; + } + + return ret; +} + +static int fimc_v4l2_s_fmt(int fp, int width, int height, unsigned int fmt, int flag_capture) +{ + struct v4l2_format v4l2_fmt; + struct v4l2_pix_format pixfmt; + int ret; + + v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + memset(&pixfmt, 0, sizeof(pixfmt)); + + pixfmt.width = width; + pixfmt.height = height; + pixfmt.pixelformat = fmt; + + pixfmt.sizeimage = (width * height * get_pixel_depth(fmt)) / 8; + + pixfmt.field = V4L2_FIELD_NONE; + + v4l2_fmt.fmt.pix = pixfmt; + + /* Set up for capture */ + ret = ioctl(fp, VIDIOC_S_FMT, &v4l2_fmt); + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_S_FMT failed\n", __func__); + return -1; + } + + return 0; +} + +static int fimc_v4l2_s_fmt_cap(int fp, int width, int height, unsigned int fmt) +{ + struct v4l2_format v4l2_fmt; + struct v4l2_pix_format pixfmt; + int ret; + + memset(&pixfmt, 0, sizeof(pixfmt)); + + v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + pixfmt.width = width; + pixfmt.height = height; + pixfmt.pixelformat = fmt; + if (fmt == V4L2_PIX_FMT_JPEG) { + pixfmt.colorspace = V4L2_COLORSPACE_JPEG; + } + + pixfmt.sizeimage = (width * height * get_pixel_depth(fmt)) / 8; + + v4l2_fmt.fmt.pix = pixfmt; + + LOGV("ori_w %d, ori_h %d, w %d, h %d\n", width, height, v4l2_fmt.fmt.pix.width, v4l2_fmt.fmt.pix.height); + + /* Set up for capture */ + ret = ioctl(fp, VIDIOC_S_FMT, &v4l2_fmt); + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_S_FMT failed\n", __func__); + return ret; + } + + return ret; +} + +static int fimc_v4l2_enum_fmt(int fp, unsigned int fmt) +{ + struct v4l2_fmtdesc fmtdesc; + int found = 0; + + fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + fmtdesc.index = 0; + + while (ioctl(fp, VIDIOC_ENUM_FMT, &fmtdesc) == 0) { + if (fmtdesc.pixelformat == fmt) { + LOGV("passed fmt = %#x found pixel format[%d]: %s\n", fmt, fmtdesc.index, fmtdesc.description); + found = 1; + break; + } + + fmtdesc.index++; + } + + if (!found) { + LOGE("unsupported pixel format\n"); + return -1; + } + + return 0; +} + +static int fimc_v4l2_reqbufs(int fp, enum v4l2_buf_type type, int nr_bufs) +{ + struct v4l2_requestbuffers req; + int ret; + + req.count = nr_bufs; + req.type = type; + req.memory = V4L2_MEMORY_MMAP; + + ret = ioctl(fp, VIDIOC_REQBUFS, &req); + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_REQBUFS failed\n", __func__); + return -1; + } + + return req.count; +} + +static int fimc_v4l2_querybuf(int fp, struct fimc_buffer *buffer, enum v4l2_buf_type type) +{ + struct v4l2_buffer v4l2_buf; + int ret; + + LOGI("%s :", __func__); + + v4l2_buf.type = type; + v4l2_buf.memory = V4L2_MEMORY_MMAP; + v4l2_buf.index = 0; + + ret = ioctl(fp , VIDIOC_QUERYBUF, &v4l2_buf); + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_QUERYBUF failed\n", __func__); + return -1; + } + + buffer->length = v4l2_buf.length; + if ((buffer->start = (char *)mmap(0, v4l2_buf.length, + PROT_READ | PROT_WRITE, MAP_SHARED, + fp, v4l2_buf.m.offset)) < 0) { + LOGE("%s %d] mmap() failed\n",__func__, __LINE__); + return -1; + } + + LOGI("%s: buffer->start = %p v4l2_buf.length = %d", + __func__, buffer->start, v4l2_buf.length); + + return 0; +} + +static int fimc_v4l2_streamon(int fp) +{ + enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + int ret; + + ret = ioctl(fp, VIDIOC_STREAMON, &type); + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_STREAMON failed\n", __func__); + return ret; + } + + return ret; +} + +static int fimc_v4l2_streamoff(int fp) +{ + enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + int ret; + + LOGV("%s :", __func__); + ret = ioctl(fp, VIDIOC_STREAMOFF, &type); + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_STREAMOFF failed\n", __func__); + return ret; + } + + return ret; +} + +static int fimc_v4l2_qbuf(int fp, int index) +{ + struct v4l2_buffer v4l2_buf; + int ret; + + v4l2_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + v4l2_buf.memory = V4L2_MEMORY_MMAP; + v4l2_buf.index = index; + + ret = ioctl(fp, VIDIOC_QBUF, &v4l2_buf); + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_QBUF failed\n", __func__); + return ret; + } + + return 0; +} + +static int fimc_v4l2_dqbuf(int fp) +{ + struct v4l2_buffer v4l2_buf; + int ret; + + v4l2_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + v4l2_buf.memory = V4L2_MEMORY_MMAP; + + ret = ioctl(fp, VIDIOC_DQBUF, &v4l2_buf); + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_DQBUF failed, dropped frame\n", __func__); + return ret; + } + + return v4l2_buf.index; +} + +static int fimc_v4l2_g_ctrl(int fp, unsigned int id) +{ + struct v4l2_control ctrl; + int ret; + + ctrl.id = id; + + ret = ioctl(fp, VIDIOC_G_CTRL, &ctrl); + if (ret < 0) { + LOGE("ERR(%s): VIDIOC_G_CTRL(id = 0x%x (%d)) failed, ret = %d\n", + __func__, id, id-V4L2_CID_PRIVATE_BASE, ret); + return ret; + } + + return ctrl.value; +} + +static int fimc_v4l2_s_ctrl(int fp, unsigned int id, unsigned int value) +{ + struct v4l2_control ctrl; + int ret; + + ctrl.id = id; + ctrl.value = value; + + ret = ioctl(fp, VIDIOC_S_CTRL, &ctrl); + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_S_CTRL(id = %#x (%d), value = %d) failed ret = %d\n", + __func__, id, id-V4L2_CID_PRIVATE_BASE, value, ret); + + return ret; + } + + return ctrl.value; +} + +static int fimc_v4l2_s_ext_ctrl(int fp, unsigned int id, void *value) +{ + struct v4l2_ext_controls ctrls; + struct v4l2_ext_control ctrl; + int ret; + + ctrl.id = id; + ctrl.reserved = value; + + ctrls.ctrl_class = V4L2_CTRL_CLASS_CAMERA; + ctrls.count = 1; + ctrls.controls = &ctrl; + + ret = ioctl(fp, VIDIOC_S_EXT_CTRLS, &ctrls); + if (ret < 0) + LOGE("ERR(%s):VIDIOC_S_EXT_CTRLS failed\n", __func__); + + return ret; +} + +static int fimc_v4l2_g_parm(int fp, struct v4l2_streamparm *streamparm) +{ + int ret; + + streamparm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + ret = ioctl(fp, VIDIOC_G_PARM, streamparm); + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_G_PARM failed\n", __func__); + return -1; + } + + LOGV("%s : timeperframe: numerator %d, denominator %d\n", __func__, + streamparm->parm.capture.timeperframe.numerator, + streamparm->parm.capture.timeperframe.denominator); + + return 0; +} + +static int fimc_v4l2_s_parm(int fp, struct v4l2_streamparm *streamparm) +{ + int ret; + + streamparm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + ret = ioctl(fp, VIDIOC_S_PARM, streamparm); + if (ret < 0) { + LOGE("ERR(%s):VIDIOC_S_PARM failed\n", __func__); + return ret; + } + + return 0; +} + +// ====================================================================== +// Constructor & Destructor + +SecCamera::SecCamera() : + m_flag_init(0), + m_camera_id(CAMERA_ID_BACK), + m_preview_v4lformat(V4L2_PIX_FMT_NV21), + m_preview_width (0), + m_preview_height (0), + m_preview_max_width (MAX_BACK_CAMERA_PREVIEW_WIDTH), + m_preview_max_height (MAX_BACK_CAMERA_PREVIEW_HEIGHT), + m_snapshot_v4lformat(-1), + m_snapshot_width (0), + m_snapshot_height (0), + m_snapshot_max_width (MAX_BACK_CAMERA_SNAPSHOT_WIDTH), + m_snapshot_max_height (MAX_BACK_CAMERA_SNAPSHOT_HEIGHT), + m_angle(-1), + m_anti_banding(-1), + m_wdr(-1), + m_anti_shake(-1), + m_zoom_level(-1), + m_object_tracking(-1), + m_smart_auto(-1), + m_beauty_shot(-1), + m_vintage_mode(-1), + m_face_detect(-1), + m_gps_latitude(-1), + m_gps_longitude(-1), + m_gps_altitude(-1), + m_gps_timestamp(-1), + m_vtmode(0), + m_sensor_mode(-1), + m_shot_mode(-1), + m_exif_orientation(-1), + m_blur_level(-1), + m_chk_dataline(-1), + m_video_gamma(-1), + m_slow_ae(-1), + m_camera_af_flag(-1), + m_flag_camera_start(0), + m_jpeg_thumbnail_width (0), + m_jpeg_thumbnail_height(0), + m_jpeg_quality(100) +#ifdef ENABLE_ESD_PREVIEW_CHECK + , + m_esd_check_count(0) +#endif // ENABLE_ESD_PREVIEW_CHECK +{ + m_params = (struct sec_cam_parm*)&m_streamparm.parm.raw_data; + struct v4l2_captureparm capture; + m_params->capture.timeperframe.numerator = 1; + m_params->capture.timeperframe.denominator = 0; + m_params->contrast = -1; + m_params->effects = -1; + m_params->brightness = -1; + m_params->flash_mode = -1; + m_params->focus_mode = -1; + m_params->iso = -1; + m_params->metering = -1; + m_params->saturation = -1; + m_params->scene_mode = -1; + m_params->sharpness = -1; + m_params->white_balance = -1; + + memset(&m_capture_buf, 0, sizeof(m_capture_buf)); + + LOGV("%s :", __func__); +} + +int SecCamera::flagCreate(void) const +{ + LOGV("%s : : %d", __func__, m_flag_init); + return m_flag_init; +} + +SecCamera::~SecCamera() +{ + LOGV("%s :", __func__); +} + +int SecCamera::initCamera(int index) +{ + LOGV("%s :", __func__); + int ret = 0; + + if (!m_flag_init) { + /* Arun C + * Reset the lense position only during camera starts; don't do + * reset between shot to shot + */ + m_camera_af_flag = -1; + + m_cam_fd_temp = -1; + m_cam_fd2_temp = -1; + + m_cam_fd = open(CAMERA_DEV_NAME, O_RDWR); + if (m_cam_fd < 0) { + LOGE("ERR(%s):Cannot open %s (error : %s)\n", __func__, CAMERA_DEV_NAME, strerror(errno)); + return -1; + } + + if (m_cam_fd < 3) { // for 0, 1, 2 + LOGE("ERR(%s):m_cam_fd is %d\n", __func__, m_cam_fd); + + close(m_cam_fd); + + m_cam_fd_temp = open(CAMERA_DEV_NAME_TEMP, O_CREAT); + + LOGE("ERR(%s):m_cam_fd_temp is %d\n", __func__, m_cam_fd_temp); + + m_cam_fd = open(CAMERA_DEV_NAME, O_RDWR); + + if (m_cam_fd < 3) { // for 0, 1, 2 + LOGE("ERR(%s):retring to open %s is failed, %d\n", __func__, CAMERA_DEV_NAME, m_cam_fd); + + if (m_cam_fd < 0) { + return -1; + } else { + close(m_cam_fd); + m_cam_fd = -1; + } + + if (m_cam_fd_temp != -1){ + close(m_cam_fd_temp); + m_cam_fd_temp = -1; + } + return -1; + } + } + + LOGE("initCamera: m_cam_fd(%d), m_jpeg_fd(%d)", m_cam_fd, m_jpeg_fd); + + ret = fimc_v4l2_querycap(m_cam_fd); + CHECK(ret); + if (!fimc_v4l2_enuminput(m_cam_fd, index)) + return -1; + ret = fimc_v4l2_s_input(m_cam_fd, index); + CHECK(ret); + + m_cam_fd2 = open(CAMERA_DEV_NAME2, O_RDWR); + if (m_cam_fd2 < 0) { + LOGE("ERR(%s):Cannot open %s (error : %s)\n", __func__, CAMERA_DEV_NAME2, strerror(errno)); + return -1; + } + if (m_cam_fd2 < 3) { // for 0, 1, 2 + LOGE("ERR(%s):m_cam_fd2 is %d\n", __func__, m_cam_fd2); + + close(m_cam_fd2); + + m_cam_fd2_temp = open(CAMERA_DEV_NAME2_TEMP, O_CREAT); + + LOGE("ERR(%s):m_cam_fd2_temp is %d\n", __func__, m_cam_fd2_temp); + + m_cam_fd2 = open(CAMERA_DEV_NAME2, O_RDWR); + + if (m_cam_fd2 < 3) { // for 0, 1, 2 + LOGE("ERR(%s):retring to open %s is failed, %d\n", __func__, CAMERA_DEV_NAME2, m_cam_fd2); + + if (m_cam_fd2 < 0) { + return -1; + } + else{ + close(m_cam_fd2); + m_cam_fd2 = -1; + } + + if (m_cam_fd2_temp != -1) { + close(m_cam_fd2_temp); + m_cam_fd2_temp = -1; + } + + return -1; + } + } + + if (m_cam_fd_temp != -1) { + close(m_cam_fd_temp); + m_cam_fd_temp = -1; + } + + if (m_cam_fd2_temp != -1) { + close(m_cam_fd2_temp); + m_cam_fd2_temp = -1; + } + + LOGE("initCamera: m_cam_fd2(%d)", m_cam_fd2); + + ret = fimc_v4l2_querycap(m_cam_fd2); + CHECK(ret); + if (!fimc_v4l2_enuminput(m_cam_fd2, index)) + return -1; + ret = fimc_v4l2_s_input(m_cam_fd2, index); + CHECK(ret); + + m_camera_id = index; + + switch (m_camera_id) { + case CAMERA_ID_FRONT: + m_preview_max_width = MAX_FRONT_CAMERA_PREVIEW_WIDTH; + m_preview_max_height = MAX_FRONT_CAMERA_PREVIEW_HEIGHT; + m_snapshot_max_width = MAX_FRONT_CAMERA_SNAPSHOT_WIDTH; + m_snapshot_max_height = MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT; + break; + + case CAMERA_ID_BACK: + m_preview_max_width = MAX_BACK_CAMERA_PREVIEW_WIDTH; + m_preview_max_height = MAX_BACK_CAMERA_PREVIEW_HEIGHT; + m_snapshot_max_width = MAX_BACK_CAMERA_SNAPSHOT_WIDTH; + m_snapshot_max_height = MAX_BACK_CAMERA_SNAPSHOT_HEIGHT; + break; + } + + setExifFixedAttribute(); + + m_flag_init = 1; + } + return 0; +} + +void SecCamera::resetCamera() +{ + LOGV("%s :", __func__); + DeinitCamera(); + initCamera(m_camera_id); +} + +void SecCamera::DeinitCamera() +{ + LOGV("%s :", __func__); + + if (m_flag_init) { + + stopRecord(); + + /* close m_cam_fd after stopRecord() because stopRecord() + * uses m_cam_fd to change frame rate + */ + LOGI("DeinitCamera: m_cam_fd(%d)", m_cam_fd); + if (m_cam_fd > -1) { + close(m_cam_fd); + m_cam_fd = -1; + } + + LOGI("DeinitCamera: m_cam_fd2(%d)", m_cam_fd2); + if (m_cam_fd2 > -1) { + close(m_cam_fd2); + m_cam_fd2 = -1; + } + + if (m_cam_fd_temp != -1) { + close(m_cam_fd_temp); + m_cam_fd_temp = -1; + } + + if (m_cam_fd2_temp != -1) { + close(m_cam_fd2_temp); + m_cam_fd2_temp = -1; + } + + m_flag_init = 0; + } +} + + +int SecCamera::getCameraFd(void) +{ + return m_cam_fd; +} + +// ====================================================================== +// Preview + +int SecCamera::startPreview(void) +{ + v4l2_streamparm streamparm; + struct sec_cam_parm *parms; + parms = (struct sec_cam_parm*)&streamparm.parm.raw_data; + LOGV("%s :", __func__); + + // aleady started + if (m_flag_camera_start > 0) { + LOGE("ERR(%s):Preview was already started\n", __func__); + return 0; + } + + if (m_cam_fd <= 0) { + LOGE("ERR(%s):Camera was closed\n", __func__); + return -1; + } + + memset(&m_events_c, 0, sizeof(m_events_c)); + m_events_c.fd = m_cam_fd; + m_events_c.events = POLLIN | POLLERR; + + /* enum_fmt, s_fmt sample */ + int ret = fimc_v4l2_enum_fmt(m_cam_fd,m_preview_v4lformat); + CHECK(ret); + ret = fimc_v4l2_s_fmt(m_cam_fd, m_preview_width,m_preview_height,m_preview_v4lformat, 0); + CHECK(ret); + + ret = fimc_v4l2_reqbufs(m_cam_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS); + CHECK(ret); + + LOGV("%s : m_preview_width: %d m_preview_height: %d m_angle: %d\n", + __func__, m_preview_width, m_preview_height, m_angle); + + ret = fimc_v4l2_s_ctrl(m_cam_fd, + V4L2_CID_CAMERA_CHECK_DATALINE, m_chk_dataline); + CHECK(ret); + + if (m_camera_id == CAMERA_ID_FRONT) { + /* VT mode setting */ + ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VT_MODE, m_vtmode); + CHECK(ret); + } + + /* start with all buffers in queue */ + for (int i = 0; i < MAX_BUFFERS; i++) { + ret = fimc_v4l2_qbuf(m_cam_fd, i); + CHECK(ret); + } + + ret = fimc_v4l2_streamon(m_cam_fd); + CHECK(ret); + + m_flag_camera_start = 1; + + ret = fimc_v4l2_s_parm(m_cam_fd, &m_streamparm); + CHECK(ret); + + if (m_camera_id == CAMERA_ID_FRONT) { + /* Blur setting */ + LOGV("m_blur_level = %d", m_blur_level); + ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VGA_BLUR, + m_blur_level); + CHECK(ret); + } + + // It is a delay for a new frame, not to show the previous bigger ugly picture frame. + ret = fimc_poll(&m_events_c); + CHECK(ret); + ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_RETURN_FOCUS, 0); + CHECK(ret); + + LOGV("%s: got the first frame of the preview\n", __func__); + + return 0; +} + +int SecCamera::stopPreview(void) +{ + int ret; + + LOGV("%s :", __func__); + + if (m_flag_camera_start == 0) { + LOGW("%s: doing nothing because m_flag_camera_start is zero", __func__); + return 0; + } + + if (m_params->flash_mode == FLASH_MODE_TORCH) + setFlashMode(FLASH_MODE_OFF); + + if (m_cam_fd <= 0) { + LOGE("ERR(%s):Camera was closed\n", __func__); + return -1; + } + + ret = fimc_v4l2_streamoff(m_cam_fd); + CHECK(ret); + + m_flag_camera_start = 0; + + return ret; +} + +//Recording +int SecCamera::startRecord(void) +{ + int ret, i; + + LOGV("%s :", __func__); + + // aleady started + if (m_flag_record_start > 0) { + LOGE("ERR(%s):Preview was already started\n", __func__); + return 0; + } + + if (m_cam_fd2 <= 0) { + LOGE("ERR(%s):Camera was closed\n", __func__); + return -1; + } + + /* enum_fmt, s_fmt sample */ + ret = fimc_v4l2_enum_fmt(m_cam_fd2, V4L2_PIX_FMT_NV12T); + CHECK(ret); + + LOGI("%s: m_recording_width = %d, m_recording_height = %d\n", + __func__, m_recording_width, m_recording_height); + + ret = fimc_v4l2_s_fmt(m_cam_fd2, m_recording_width, + m_recording_height, V4L2_PIX_FMT_NV12T, 0); + CHECK(ret); + + ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FRAME_RATE, + m_params->capture.timeperframe.denominator); + CHECK(ret); + + ret = fimc_v4l2_reqbufs(m_cam_fd2, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS); + CHECK(ret); + + /* start with all buffers in queue */ + for (i = 0; i < MAX_BUFFERS; i++) { + ret = fimc_v4l2_qbuf(m_cam_fd2, i); + CHECK(ret); + } + + ret = fimc_v4l2_streamon(m_cam_fd2); + CHECK(ret); + + // Get and throw away the first frame since it is often garbled. + memset(&m_events_c2, 0, sizeof(m_events_c2)); + m_events_c2.fd = m_cam_fd2; + m_events_c2.events = POLLIN | POLLERR; + ret = fimc_poll(&m_events_c2); + CHECK(ret); + + m_flag_record_start = 1; + + return 0; +} + +int SecCamera::stopRecord(void) +{ + int ret; + + LOGV("%s :", __func__); + + if (m_flag_record_start == 0) { + LOGW("%s: doing nothing because m_flag_record_start is zero", __func__); + return 0; + } + + if (m_cam_fd2 <= 0) { + LOGE("ERR(%s):Camera was closed\n", __func__); + return -1; + } + + m_flag_record_start = 0; + + ret = fimc_v4l2_streamoff(m_cam_fd2); + CHECK(ret); + + ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FRAME_RATE, + FRAME_RATE_AUTO); + CHECK(ret); + + return 0; +} + +unsigned int SecCamera::getRecPhyAddrY(int index) +{ + unsigned int addr_y; + + addr_y = fimc_v4l2_s_ctrl(m_cam_fd2, V4L2_CID_PADDR_Y, index); + CHECK((int)addr_y); + return addr_y; +} + +unsigned int SecCamera::getRecPhyAddrC(int index) +{ + unsigned int addr_c; + + addr_c = fimc_v4l2_s_ctrl(m_cam_fd2, V4L2_CID_PADDR_CBCR, index); + CHECK((int)addr_c); + return addr_c; +} + +unsigned int SecCamera::getPhyAddrY(int index) +{ + unsigned int addr_y; + + addr_y = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_PADDR_Y, index); + CHECK((int)addr_y); + return addr_y; +} + +unsigned int SecCamera::getPhyAddrC(int index) +{ + unsigned int addr_c; + + addr_c = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_PADDR_CBCR, index); + CHECK((int)addr_c); + return addr_c; +} + +void SecCamera::pausePreview() +{ + fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0); +} + +int SecCamera::getPreview() +{ + int index; + int ret; + + if (m_flag_camera_start == 0 || previewPoll(true) == 0) { + LOGE("ERR(%s):Start Camera Device Reset \n", __func__); + /* GAUDI Project([arun.c@samsung.com]) 2010.05.20. [Implemented ESD code] */ + /* + * When there is no data for more than 1 second from the camera we inform + * the FIMC driver by calling fimc_v4l2_s_input() with a special value = 1000 + * FIMC driver identify that there is something wrong with the camera + * and it restarts the sensor. + */ + stopPreview(); + /* Reset Only Camera Device */ + ret = fimc_v4l2_querycap(m_cam_fd); + CHECK(ret); + if (fimc_v4l2_enuminput(m_cam_fd, m_camera_id)) + return -1; + ret = fimc_v4l2_s_input(m_cam_fd, 1000); + CHECK(ret); + ret = startPreview(); + if (ret < 0) { + LOGE("ERR(%s): startPreview() return %d\n", __func__, ret); + return 0; + } + } + + index = fimc_v4l2_dqbuf(m_cam_fd); + if (!(0 <= index && index < MAX_BUFFERS)) { + LOGE("ERR(%s):wrong index = %d\n", __func__, index); + return -1; + } + + ret = fimc_v4l2_qbuf(m_cam_fd, index); + CHECK(ret); + + return index; +} + +int SecCamera::getRecordFrame() +{ + if (m_flag_record_start == 0) { + LOGE("%s: m_flag_record_start is 0", __func__); + return -1; + } + + previewPoll(false); + return fimc_v4l2_dqbuf(m_cam_fd2); +} + +int SecCamera::releaseRecordFrame(int index) +{ + if (!m_flag_record_start) { + /* this can happen when recording frames are returned after + * the recording is stopped at the driver level. we don't + * need to return the buffers in this case and we've seen + * cases where fimc could crash if we called qbuf and it + * wasn't expecting it. + */ + LOGI("%s: recording not in progress, ignoring", __func__); + return 0; + } + + return fimc_v4l2_qbuf(m_cam_fd2, index); +} + +int SecCamera::setPreviewSize(int width, int height, int pixel_format) +{ + LOGV("%s(width(%d), height(%d), format(%d))", __func__, width, height, pixel_format); + + int v4lpixelformat = pixel_format; + +#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0 + if (v4lpixelformat == V4L2_PIX_FMT_YUV420) + LOGV("PreviewFormat:V4L2_PIX_FMT_YUV420"); + else if (v4lpixelformat == V4L2_PIX_FMT_NV12) + LOGV("PreviewFormat:V4L2_PIX_FMT_NV12"); + else if (v4lpixelformat == V4L2_PIX_FMT_NV12T) + LOGV("PreviewFormat:V4L2_PIX_FMT_NV12T"); + else if (v4lpixelformat == V4L2_PIX_FMT_NV21) + LOGV("PreviewFormat:V4L2_PIX_FMT_NV21"); + else if (v4lpixelformat == V4L2_PIX_FMT_YUV422P) + LOGV("PreviewFormat:V4L2_PIX_FMT_YUV422P"); + else if (v4lpixelformat == V4L2_PIX_FMT_YUYV) + LOGV("PreviewFormat:V4L2_PIX_FMT_YUYV"); + else if (v4lpixelformat == V4L2_PIX_FMT_RGB565) + LOGV("PreviewFormat:V4L2_PIX_FMT_RGB565"); + else + LOGV("PreviewFormat:UnknownFormat"); +#endif + m_preview_width = width; + m_preview_height = height; + m_preview_v4lformat = v4lpixelformat; + + return 0; +} + +int SecCamera::getPreviewSize(int *width, int *height, int *frame_size) +{ + *width = m_preview_width; + *height = m_preview_height; + *frame_size = m_frameSize(m_preview_v4lformat, m_preview_width, m_preview_height); + + return 0; +} + +int SecCamera::getPreviewMaxSize(int *width, int *height) +{ + *width = m_preview_max_width; + *height = m_preview_max_height; + + return 0; +} + +int SecCamera::getPreviewPixelFormat(void) +{ + return m_preview_v4lformat; +} + + +// ====================================================================== +// Snapshot +/* + * Devide getJpeg() as two funcs, setSnapshotCmd() & getJpeg() because of the shutter sound timing. + * Here, just send the capture cmd to camera ISP to start JPEG capture. + */ +int SecCamera::setSnapshotCmd(void) +{ + LOGV("%s :", __func__); + + int ret = 0; + + LOG_TIME_DEFINE(0) + LOG_TIME_DEFINE(1) + + if (m_cam_fd <= 0) { + LOGE("ERR(%s):Camera was closed\n", __func__); + return 0; + } + + if (m_flag_camera_start > 0) { + LOG_TIME_START(0) + LOGW("WARN(%s):Camera was in preview, should have been stopped\n", __func__); + stopPreview(); + LOG_TIME_END(0) + } + + memset(&m_events_c, 0, sizeof(m_events_c)); + m_events_c.fd = m_cam_fd; + m_events_c.events = POLLIN | POLLERR; + + LOG_TIME_START(1) // prepare + int nframe = 1; + + ret = fimc_v4l2_enum_fmt(m_cam_fd,m_snapshot_v4lformat); + CHECK(ret); + ret = fimc_v4l2_s_fmt_cap(m_cam_fd, m_snapshot_width, m_snapshot_height, V4L2_PIX_FMT_JPEG); + CHECK(ret); + ret = fimc_v4l2_reqbufs(m_cam_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, nframe); + CHECK(ret); + ret = fimc_v4l2_querybuf(m_cam_fd, &m_capture_buf, V4L2_BUF_TYPE_VIDEO_CAPTURE); + CHECK(ret); + + ret = fimc_v4l2_qbuf(m_cam_fd, 0); + CHECK(ret); + + ret = fimc_v4l2_streamon(m_cam_fd); + CHECK(ret); + LOG_TIME_END(1) + + return 0; +} + +int SecCamera::endSnapshot(void) +{ + int ret; + + LOGI("%s :", __func__); + if (m_capture_buf.start) { + munmap(m_capture_buf.start, m_capture_buf.length); + LOGI("munmap():virt. addr %p size = %d\n", + m_capture_buf.start, m_capture_buf.length); + m_capture_buf.start = NULL; + m_capture_buf.length = 0; + } + return 0; +} + +/* + * Set Jpeg quality & exif info and get JPEG data from camera ISP + */ +unsigned char* SecCamera::getJpeg(int *jpeg_size, unsigned int *phyaddr) +{ + LOGV("%s :", __func__); + + int index, ret = 0; + unsigned char *addr; + + LOG_TIME_DEFINE(2) + + // capture + ret = fimc_poll(&m_events_c); + CHECK_PTR(ret); + index = fimc_v4l2_dqbuf(m_cam_fd); + if (index != 0) { + LOGE("ERR(%s):wrong index = %d\n", __func__, index); + return NULL; + } + + *jpeg_size = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_MAIN_SIZE); + CHECK_PTR(*jpeg_size); + + int main_offset = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_MAIN_OFFSET); + CHECK_PTR(main_offset); + m_postview_offset = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_POSTVIEW_OFFSET); + CHECK_PTR(m_postview_offset); + + ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0); + CHECK_PTR(ret); + LOGV("\nsnapshot dqueued buffer = %d snapshot_width = %d snapshot_height = %d, size = %d\n\n", + index, m_snapshot_width, m_snapshot_height, *jpeg_size); + + addr = (unsigned char*)(m_capture_buf.start) + main_offset; + *phyaddr = getPhyAddrY(index) + m_postview_offset; + + LOG_TIME_START(2) // post + ret = fimc_v4l2_streamoff(m_cam_fd); + CHECK_PTR(ret); + LOG_TIME_END(2) + + return addr; +} + +int SecCamera::getExif(unsigned char *pExifDst, unsigned char *pThumbSrc) +{ + JpegEncoder jpgEnc; + + LOGV("%s : m_jpeg_thumbnail_width = %d, height = %d", + __func__, m_jpeg_thumbnail_width, m_jpeg_thumbnail_height); + if ((m_jpeg_thumbnail_width > 0) && (m_jpeg_thumbnail_height > 0)) { + int inFormat = JPG_MODESEL_YCBCR; + int outFormat = JPG_422; + switch (m_snapshot_v4lformat) { + case V4L2_PIX_FMT_NV12: + case V4L2_PIX_FMT_NV21: + case V4L2_PIX_FMT_NV12T: + case V4L2_PIX_FMT_YUV420: + outFormat = JPG_420; + break; + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_YUV422P: + outFormat = JPG_422; + break; + } + + if (jpgEnc.setConfig(JPEG_SET_ENCODE_IN_FORMAT, inFormat) != JPG_SUCCESS) + return -1; + + if (jpgEnc.setConfig(JPEG_SET_SAMPING_MODE, outFormat) != JPG_SUCCESS) + return -1; + + if (jpgEnc.setConfig(JPEG_SET_ENCODE_QUALITY, JPG_QUALITY_LEVEL_2) != JPG_SUCCESS) + return -1; + + int thumbWidth, thumbHeight, thumbSrcSize; + getThumbnailConfig(&thumbWidth, &thumbHeight, &thumbSrcSize); + if (jpgEnc.setConfig(JPEG_SET_ENCODE_WIDTH, thumbWidth) != JPG_SUCCESS) + return -1; + + if (jpgEnc.setConfig(JPEG_SET_ENCODE_HEIGHT, thumbHeight) != JPG_SUCCESS) + return -1; + + char *pInBuf = (char *)jpgEnc.getInBuf(thumbSrcSize); + if (pInBuf == NULL) + return -1; + memcpy(pInBuf, pThumbSrc, thumbSrcSize); + + unsigned int thumbSize; + + jpgEnc.encode(&thumbSize, NULL); + + LOGV("%s : enableThumb set to true", __func__); + mExifInfo.enableThumb = true; + } else { + LOGV("%s : enableThumb set to false", __func__); + mExifInfo.enableThumb = false; + } + + unsigned int exifSize; + + setExifChangedAttribute(); + + LOGV("%s: calling jpgEnc.makeExif, mExifInfo.width set to %d, height to %d\n", + __func__, mExifInfo.width, mExifInfo.height); + + jpgEnc.makeExif(pExifDst, &mExifInfo, &exifSize, true); + + return exifSize; +} + +void SecCamera::getPostViewConfig(int *width, int *height, int *size) +{ + if (m_preview_width == 1024) { + *width = BACK_CAMERA_POSTVIEW_WIDE_WIDTH; + *height = BACK_CAMERA_POSTVIEW_HEIGHT; + *size = BACK_CAMERA_POSTVIEW_WIDE_WIDTH * BACK_CAMERA_POSTVIEW_HEIGHT * BACK_CAMERA_POSTVIEW_BPP / 8; + } else { + *width = BACK_CAMERA_POSTVIEW_WIDTH; + *height = BACK_CAMERA_POSTVIEW_HEIGHT; + *size = BACK_CAMERA_POSTVIEW_WIDTH * BACK_CAMERA_POSTVIEW_HEIGHT * BACK_CAMERA_POSTVIEW_BPP / 8; + } + LOGV("[5B] m_preview_width : %d, mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d", + m_preview_width, *width, *height, *size); +} + +void SecCamera::getThumbnailConfig(int *width, int *height, int *size) +{ + if (m_camera_id == CAMERA_ID_BACK) { + *width = BACK_CAMERA_THUMBNAIL_WIDTH; + *height = BACK_CAMERA_THUMBNAIL_HEIGHT; + *size = BACK_CAMERA_THUMBNAIL_WIDTH * BACK_CAMERA_THUMBNAIL_HEIGHT + * BACK_CAMERA_THUMBNAIL_BPP / 8; + } else { + *width = FRONT_CAMERA_THUMBNAIL_WIDTH; + *height = FRONT_CAMERA_THUMBNAIL_HEIGHT; + *size = FRONT_CAMERA_THUMBNAIL_WIDTH * FRONT_CAMERA_THUMBNAIL_HEIGHT + * FRONT_CAMERA_THUMBNAIL_BPP / 8; + } +} + +int SecCamera::getPostViewOffset(void) +{ + return m_postview_offset; +} + +int SecCamera::getSnapshotAndJpeg(unsigned char *yuv_buf, unsigned char *jpeg_buf, + unsigned int *output_size) +{ + LOGV("%s :", __func__); + + int index; + //unsigned int addr; + unsigned char *addr; + int ret = 0; + + LOG_TIME_DEFINE(0) + LOG_TIME_DEFINE(1) + LOG_TIME_DEFINE(2) + LOG_TIME_DEFINE(3) + LOG_TIME_DEFINE(4) + LOG_TIME_DEFINE(5) + + //fimc_v4l2_streamoff(m_cam_fd); [zzangdol] remove - it is separate in HWInterface with camera_id + + if (m_cam_fd <= 0) { + LOGE("ERR(%s):Camera was closed\n", __func__); + return -1; + } + + if (m_flag_camera_start > 0) { + LOG_TIME_START(0) + LOGW("WARN(%s):Camera was in preview, should have been stopped\n", __func__); + stopPreview(); + LOG_TIME_END(0) + } + + memset(&m_events_c, 0, sizeof(m_events_c)); + m_events_c.fd = m_cam_fd; + m_events_c.events = POLLIN | POLLERR; + +#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0 + if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV420) + LOGV("SnapshotFormat:V4L2_PIX_FMT_YUV420"); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12) + LOGV("SnapshotFormat:V4L2_PIX_FMT_NV12"); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12T) + LOGV("SnapshotFormat:V4L2_PIX_FMT_NV12T"); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV21) + LOGV("SnapshotFormat:V4L2_PIX_FMT_NV21"); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV422P) + LOGV("SnapshotFormat:V4L2_PIX_FMT_YUV422P"); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUYV) + LOGV("SnapshotFormat:V4L2_PIX_FMT_YUYV"); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_UYVY) + LOGV("SnapshotFormat:V4L2_PIX_FMT_UYVY"); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_RGB565) + LOGV("SnapshotFormat:V4L2_PIX_FMT_RGB565"); + else + LOGV("SnapshotFormat:UnknownFormat"); +#endif + + LOG_TIME_START(1) // prepare + int nframe = 1; + + ret = fimc_v4l2_enum_fmt(m_cam_fd,m_snapshot_v4lformat); + CHECK(ret); + ret = fimc_v4l2_s_fmt_cap(m_cam_fd, m_snapshot_width, m_snapshot_height, m_snapshot_v4lformat); + CHECK(ret); + ret = fimc_v4l2_reqbufs(m_cam_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, nframe); + CHECK(ret); + ret = fimc_v4l2_querybuf(m_cam_fd, &m_capture_buf, V4L2_BUF_TYPE_VIDEO_CAPTURE); + CHECK(ret); + + ret = fimc_v4l2_qbuf(m_cam_fd, 0); + CHECK(ret); + + ret = fimc_v4l2_streamon(m_cam_fd); + CHECK(ret); + LOG_TIME_END(1) + + LOG_TIME_START(2) // capture + fimc_poll(&m_events_c); + index = fimc_v4l2_dqbuf(m_cam_fd); + fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0); + LOGV("\nsnapshot dequeued buffer = %d snapshot_width = %d snapshot_height = %d\n\n", + index, m_snapshot_width, m_snapshot_height); + + LOG_TIME_END(2) + + LOGI("%s : calling memcpy from m_capture_buf", __func__); + memcpy(yuv_buf, (unsigned char*)m_capture_buf.start, m_snapshot_width * m_snapshot_height * 2); + LOG_TIME_START(5) // post + fimc_v4l2_streamoff(m_cam_fd); + LOG_TIME_END(5) + + LOG_CAMERA("getSnapshotAndJpeg intervals : stopPreview(%lu), prepare(%lu)," + " capture(%lu), memcpy(%lu), yuv2Jpeg(%lu), post(%lu) us", + LOG_TIME(0), LOG_TIME(1), LOG_TIME(2), LOG_TIME(3), LOG_TIME(4), LOG_TIME(5)); + /* JPEG encoding */ + JpegEncoder jpgEnc; + int inFormat = JPG_MODESEL_YCBCR; + int outFormat = JPG_422; + + switch (m_snapshot_v4lformat) { + case V4L2_PIX_FMT_NV12: + case V4L2_PIX_FMT_NV21: + case V4L2_PIX_FMT_NV12T: + case V4L2_PIX_FMT_YUV420: + outFormat = JPG_420; + break; + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_YUV422P: + default: + outFormat = JPG_422; + break; + } + + if (jpgEnc.setConfig(JPEG_SET_ENCODE_IN_FORMAT, inFormat) != JPG_SUCCESS) + LOGE("[JPEG_SET_ENCODE_IN_FORMAT] Error\n"); + + if (jpgEnc.setConfig(JPEG_SET_SAMPING_MODE, outFormat) != JPG_SUCCESS) + LOGE("[JPEG_SET_SAMPING_MODE] Error\n"); + + image_quality_type_t jpegQuality; + if (m_jpeg_quality >= 90) + jpegQuality = JPG_QUALITY_LEVEL_1; + else if (m_jpeg_quality >= 80) + jpegQuality = JPG_QUALITY_LEVEL_2; + else if (m_jpeg_quality >= 70) + jpegQuality = JPG_QUALITY_LEVEL_3; + else + jpegQuality = JPG_QUALITY_LEVEL_4; + + if (jpgEnc.setConfig(JPEG_SET_ENCODE_QUALITY, jpegQuality) != JPG_SUCCESS) + LOGE("[JPEG_SET_ENCODE_QUALITY] Error\n"); + if (jpgEnc.setConfig(JPEG_SET_ENCODE_WIDTH, m_snapshot_width) != JPG_SUCCESS) + LOGE("[JPEG_SET_ENCODE_WIDTH] Error\n"); + + if (jpgEnc.setConfig(JPEG_SET_ENCODE_HEIGHT, m_snapshot_height) != JPG_SUCCESS) + LOGE("[JPEG_SET_ENCODE_HEIGHT] Error\n"); + + unsigned int snapshot_size = m_snapshot_width * m_snapshot_height * 2; + unsigned char *pInBuf = (unsigned char *)jpgEnc.getInBuf(snapshot_size); + + if (pInBuf == NULL) { + LOGE("JPEG input buffer is NULL!!\n"); + return -1; + } + memcpy(pInBuf, yuv_buf, snapshot_size); + + setExifChangedAttribute(); + jpgEnc.encode(output_size, &mExifInfo); + + uint64_t outbuf_size; + unsigned char *pOutBuf = (unsigned char *)jpgEnc.getOutBuf(&outbuf_size); + + if (pOutBuf == NULL) { + LOGE("JPEG output buffer is NULL!!\n"); + return -1; + } + + memcpy(jpeg_buf, pOutBuf, outbuf_size); + + return 0; +} + + +int SecCamera::setSnapshotSize(int width, int height) +{ + LOGV("%s(width(%d), height(%d))", __func__, width, height); + + m_snapshot_width = width; + m_snapshot_height = height; + + return 0; +} + +int SecCamera::getSnapshotSize(int *width, int *height, int *frame_size) +{ + *width = m_snapshot_width; + *height = m_snapshot_height; + + int frame = 0; + + frame = m_frameSize(m_snapshot_v4lformat, m_snapshot_width, m_snapshot_height); + + // set it big. + if (frame == 0) + frame = m_snapshot_width * m_snapshot_height * BPP; + + *frame_size = frame; + + return 0; +} + +int SecCamera::getSnapshotMaxSize(int *width, int *height) +{ + switch (m_camera_id) { + case CAMERA_ID_FRONT: + m_snapshot_max_width = MAX_FRONT_CAMERA_SNAPSHOT_WIDTH; + m_snapshot_max_height = MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT; + break; + + default: + case CAMERA_ID_BACK: + m_snapshot_max_width = MAX_BACK_CAMERA_SNAPSHOT_WIDTH; + m_snapshot_max_height = MAX_BACK_CAMERA_SNAPSHOT_HEIGHT; + break; + } + + *width = m_snapshot_max_width; + *height = m_snapshot_max_height; + + return 0; +} + +int SecCamera::setSnapshotPixelFormat(int pixel_format) +{ + int v4lpixelformat= pixel_format; + + if (m_snapshot_v4lformat != v4lpixelformat) { + m_snapshot_v4lformat = v4lpixelformat; + } + +#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0 + if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV420) + LOGE("%s : SnapshotFormat:V4L2_PIX_FMT_YUV420", __func__); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12) + LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_NV12", __func__); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12T) + LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_NV12T", __func__); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV21) + LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_NV21", __func__); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV422P) + LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_YUV422P", __func__); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUYV) + LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_YUYV", __func__); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_UYVY) + LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_UYVY", __func__); + else if (m_snapshot_v4lformat == V4L2_PIX_FMT_RGB565) + LOGD("%s : SnapshotFormat:V4L2_PIX_FMT_RGB565", __func__); + else + LOGD("SnapshotFormat:UnknownFormat"); +#endif + return 0; +} + +int SecCamera::getSnapshotPixelFormat(void) +{ + return m_snapshot_v4lformat; +} + +// ====================================================================== +// Settings + +int SecCamera::getCameraId(void) +{ + return m_camera_id; +} + +// ----------------------------------- + +int SecCamera::setAutofocus(void) +{ + LOGV("%s :", __func__); + + if (m_cam_fd <= 0) { + LOGE("ERR(%s):Camera was closed\n", __func__); + return -1; + } + + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_AUTO_FOCUS, AUTO_FOCUS_ON) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_AUTO_FOCUS", __func__); + return -1; + } + + return 0; +} + +int SecCamera::getAutoFocusResult(void) +{ + int af_result; + + af_result = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_AUTO_FOCUS_RESULT); + + LOGV("%s : returning %d", __func__, af_result); + + return af_result; +} + +int SecCamera::cancelAutofocus(void) +{ + LOGV("%s :", __func__); + + if (m_cam_fd <= 0) { + LOGE("ERR(%s):Camera was closed\n", __func__); + return -1; + } + + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_AUTO_FOCUS, AUTO_FOCUS_OFF) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_AUTO_FOCUS", __func__); + return -1; + } + + return 0; +} + +// ----------------------------------- + +int SecCamera::zoomIn(void) +{ + LOGV("%s :", __func__); + return 0; +} + +int SecCamera::zoomOut(void) +{ + LOGV("%s :", __func__); + return 0; +} + +// ----------------------------------- + +int SecCamera::SetRotate(int angle) +{ + LOGE("%s(angle(%d))", __func__, angle); + + if (m_angle != angle) { + switch (angle) { + case -360: + case 0: + case 360: + m_angle = 0; + break; + + case -270: + case 90: + m_angle = 90; + break; + + case -180: + case 180: + m_angle = 180; + break; + + case -90: + case 270: + m_angle = 270; + break; + + default: + LOGE("ERR(%s):Invalid angle(%d)", __func__, angle); + return -1; + } + + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_ROTATION, angle) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_ROTATION", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getRotate(void) +{ + LOGV("%s : angle(%d)", __func__, m_angle); + return m_angle; +} + +int SecCamera::setFrameRate(int frame_rate) +{ + LOGV("%s(FrameRate(%d))", __func__, frame_rate); + + if (frame_rate < FRAME_RATE_AUTO || FRAME_RATE_MAX < frame_rate ) + LOGE("ERR(%s):Invalid frame_rate(%d)", __func__, frame_rate); + + if (m_params->capture.timeperframe.denominator != (unsigned)frame_rate) { + m_params->capture.timeperframe.denominator = frame_rate; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FRAME_RATE, frame_rate) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FRAME_RATE", __func__); + return -1; + } + } + } + + return 0; +} + +// ----------------------------------- + +int SecCamera::setVerticalMirror(void) +{ + LOGV("%s :", __func__); + + if (m_cam_fd <= 0) { + LOGE("ERR(%s):Camera was closed\n", __func__); + return -1; + } + + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_VFLIP, 0) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_VFLIP", __func__); + return -1; + } + + return 0; +} + +int SecCamera::setHorizontalMirror(void) +{ + LOGV("%s :", __func__); + + if (m_cam_fd <= 0) { + LOGE("ERR(%s):Camera was closed\n", __func__); + return -1; + } + + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_HFLIP, 0) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_HFLIP", __func__); + return -1; + } + + return 0; +} + +// ----------------------------------- + +int SecCamera::setWhiteBalance(int white_balance) +{ + LOGV("%s(white_balance(%d))", __func__, white_balance); + + if (white_balance <= WHITE_BALANCE_BASE || WHITE_BALANCE_MAX <= white_balance) { + LOGE("ERR(%s):Invalid white_balance(%d)", __func__, white_balance); + return -1; + } + + if (m_params->white_balance != white_balance) { + m_params->white_balance = white_balance; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WHITE_BALANCE, white_balance) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_WHITE_BALANCE", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getWhiteBalance(void) +{ + LOGV("%s : white_balance(%d)", __func__, m_params->white_balance); + return m_params->white_balance; +} + +// ----------------------------------- + +int SecCamera::setBrightness(int brightness) +{ + LOGV("%s(brightness(%d))", __func__, brightness); + + brightness += EV_DEFAULT; + + if (brightness < EV_MINUS_4 || EV_PLUS_4 < brightness) { + LOGE("ERR(%s):Invalid brightness(%d)", __func__, brightness); + return -1; + } + + if (m_params->brightness != brightness) { + m_params->brightness = brightness; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, brightness) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BRIGHTNESS", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getBrightness(void) +{ + LOGV("%s : brightness(%d)", __func__, m_params->brightness); + return m_params->brightness; +} + +// ----------------------------------- + +int SecCamera::setImageEffect(int image_effect) +{ + LOGV("%s(image_effect(%d))", __func__, image_effect); + + if (image_effect <= IMAGE_EFFECT_BASE || IMAGE_EFFECT_MAX <= image_effect) { + LOGE("ERR(%s):Invalid image_effect(%d)", __func__, image_effect); + return -1; + } + + if (m_params->effects != image_effect) { + m_params->effects = image_effect; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EFFECT, image_effect) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_EFFECT", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getImageEffect(void) +{ + LOGV("%s : image_effect(%d)", __func__, m_params->effects); + return m_params->effects; +} + +// ====================================================================== +int SecCamera::setAntiBanding(int anti_banding) +{ + LOGV("%s(anti_banding(%d))", __func__, anti_banding); + + if (anti_banding < ANTI_BANDING_AUTO || ANTI_BANDING_OFF < anti_banding) { + LOGE("ERR(%s):Invalid anti_banding (%d)", __func__, anti_banding); + return -1; + } + + if (m_anti_banding != anti_banding) { + m_anti_banding = anti_banding; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ANTI_BANDING, anti_banding) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ANTI_BANDING", __func__); + return -1; + } + } + } + + return 0; +} + +//====================================================================== +int SecCamera::setSceneMode(int scene_mode) +{ + LOGV("%s(scene_mode(%d))", __func__, scene_mode); + + if (scene_mode <= SCENE_MODE_BASE || SCENE_MODE_MAX <= scene_mode) { + LOGE("ERR(%s):Invalid scene_mode (%d)", __func__, scene_mode); + return -1; + } + + if (m_params->scene_mode != scene_mode) { + m_params->scene_mode = scene_mode; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SCENE_MODE, scene_mode) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SCENE_MODE", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getSceneMode(void) +{ + return m_params->scene_mode; +} + +//====================================================================== + +int SecCamera::setFlashMode(int flash_mode) +{ + LOGV("%s(flash_mode(%d))", __func__, flash_mode); + + if (flash_mode <= FLASH_MODE_BASE || FLASH_MODE_MAX <= flash_mode) { + LOGE("ERR(%s):Invalid flash_mode (%d)", __func__, flash_mode); + return -1; + } + + if (m_params->flash_mode != flash_mode) { + m_params->flash_mode = flash_mode; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FLASH_MODE, flash_mode) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FLASH_MODE", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getFlashMode(void) +{ + return m_params->flash_mode; +} + +//====================================================================== + +int SecCamera::setISO(int iso_value) +{ + LOGV("%s(iso_value(%d))", __func__, iso_value); + if (iso_value < ISO_AUTO || ISO_MAX <= iso_value) { + LOGE("ERR(%s):Invalid iso_value (%d)", __func__, iso_value); + return -1; + } + + if (m_params->iso != iso_value) { + m_params->iso = iso_value; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ISO, iso_value) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ISO", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getISO(void) +{ + return m_params->iso; +} + +//====================================================================== + +int SecCamera::setContrast(int contrast_value) +{ + LOGV("%s(contrast_value(%d))", __func__, contrast_value); + + if (contrast_value < CONTRAST_MINUS_2 || CONTRAST_MAX <= contrast_value) { + LOGE("ERR(%s):Invalid contrast_value (%d)", __func__, contrast_value); + return -1; + } + + if (m_params->contrast != contrast_value) { + m_params->contrast = contrast_value; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CONTRAST, contrast_value) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_CONTRAST", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getContrast(void) +{ + return m_params->contrast; +} + +//====================================================================== + +int SecCamera::setSaturation(int saturation_value) +{ + LOGV("%s(saturation_value(%d))", __func__, saturation_value); + + if (saturation_value saturation != saturation_value) { + m_params->saturation = saturation_value; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SATURATION, saturation_value) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SATURATION", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getSaturation(void) +{ + return m_params->saturation; +} + +//====================================================================== + +int SecCamera::setSharpness(int sharpness_value) +{ + LOGV("%s(sharpness_value(%d))", __func__, sharpness_value); + + if (sharpness_value < SHARPNESS_MINUS_2 || SHARPNESS_MAX <= sharpness_value) { + LOGE("ERR(%s):Invalid sharpness_value (%d)", __func__, sharpness_value); + return -1; + } + + if (m_params->sharpness != sharpness_value) { + m_params->sharpness = sharpness_value; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SHARPNESS, sharpness_value) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SHARPNESS", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getSharpness(void) +{ + return m_params->sharpness; +} + +//====================================================================== + +int SecCamera::setWDR(int wdr_value) +{ + LOGV("%s(wdr_value(%d))", __func__, wdr_value); + + if (wdr_value < WDR_OFF || WDR_MAX <= wdr_value) { + LOGE("ERR(%s):Invalid wdr_value (%d)", __func__, wdr_value); + return -1; + } + + if (m_wdr != wdr_value) { + m_wdr = wdr_value; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WDR, wdr_value) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_WDR", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getWDR(void) +{ + return m_wdr; +} + +//====================================================================== + +int SecCamera::setAntiShake(int anti_shake) +{ + LOGV("%s(anti_shake(%d))", __func__, anti_shake); + + if (anti_shake < ANTI_SHAKE_OFF || ANTI_SHAKE_MAX <= anti_shake) { + LOGE("ERR(%s):Invalid anti_shake (%d)", __func__, anti_shake); + return -1; + } + + if (m_anti_shake != anti_shake) { + m_anti_shake = anti_shake; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ANTI_SHAKE, anti_shake) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ANTI_SHAKE", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getAntiShake(void) +{ + return m_anti_shake; +} + +//====================================================================== + + +int SecCamera::setMetering(int metering_value) +{ + LOGV("%s(metering (%d))", __func__, metering_value); + + if (metering_value <= METERING_BASE || METERING_MAX <= metering_value) { + LOGE("ERR(%s):Invalid metering_value (%d)", __func__, metering_value); + return -1; + } + + if (m_params->metering != metering_value) { + m_params->metering = metering_value; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_METERING, metering_value) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_METERING", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getMetering(void) +{ + return m_params->metering; +} + +//====================================================================== + +int SecCamera::setJpegQuality(int jpeg_quality) +{ + LOGV("%s(jpeg_quality (%d))", __func__, jpeg_quality); + + if (jpeg_quality < JPEG_QUALITY_ECONOMY || JPEG_QUALITY_MAX <= jpeg_quality) { + LOGE("ERR(%s):Invalid jpeg_quality (%d)", __func__, jpeg_quality); + return -1; + } + + if (m_jpeg_quality != jpeg_quality) { + m_jpeg_quality = jpeg_quality; + if (m_flag_camera_start && (m_camera_id == CAMERA_ID_BACK)) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_QUALITY, jpeg_quality) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAM_JPEG_QUALITY", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getJpegQuality(void) +{ + return m_jpeg_quality; +} + +//====================================================================== + +int SecCamera::setZoom(int zoom_level) +{ + LOGV("%s(zoom_level (%d))", __func__, zoom_level); + + if (zoom_level < ZOOM_LEVEL_0 || ZOOM_LEVEL_MAX <= zoom_level) { + LOGE("ERR(%s):Invalid zoom_level (%d)", __func__, zoom_level); + return -1; + } + + if (m_zoom_level != zoom_level) { + m_zoom_level = zoom_level; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ZOOM, zoom_level) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ZOOM", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getZoom(void) +{ + return m_zoom_level; +} + +//====================================================================== + +int SecCamera::setObjectTracking(int object_tracking) +{ + LOGV("%s(object_tracking (%d))", __func__, object_tracking); + + if (object_tracking < OBJECT_TRACKING_OFF || OBJECT_TRACKING_MAX <= object_tracking) { + LOGE("ERR(%s):Invalid object_tracking (%d)", __func__, object_tracking); + return -1; + } + + if (m_object_tracking != object_tracking) { + m_object_tracking = object_tracking; + } + + return 0; +} + +int SecCamera::getObjectTracking(void) +{ + return m_object_tracking; +} + +int SecCamera::getObjectTrackingStatus(void) +{ + int obj_status = 0; + obj_status = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJ_TRACKING_STATUS); + return obj_status; +} + +int SecCamera::setObjectTrackingStartStop(int start_stop) +{ + LOGV("%s(object_tracking_start_stop (%d))", __func__, start_stop); + + if (m_object_tracking_start_stop != start_stop) { + m_object_tracking_start_stop = start_stop; + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJ_TRACKING_START_STOP, start_stop) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJ_TRACKING_START_STOP", __func__); + return -1; + } + } + + return 0; +} + +int SecCamera::setTouchAFStartStop(int start_stop) +{ + LOGV("%s(touch_af_start_stop (%d))", __func__, start_stop); + + if (m_touch_af_start_stop != start_stop) { + m_touch_af_start_stop = start_stop; + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_TOUCH_AF_START_STOP, start_stop) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_TOUCH_AF_START_STOP", __func__); + return -1; + } + } + + return 0; +} + +//====================================================================== + +int SecCamera::setSmartAuto(int smart_auto) +{ + LOGV("%s(smart_auto (%d))", __func__, smart_auto); + + if (smart_auto < SMART_AUTO_OFF || SMART_AUTO_MAX <= smart_auto) { + LOGE("ERR(%s):Invalid smart_auto (%d)", __func__, smart_auto); + return -1; + } + + if (m_smart_auto != smart_auto) { + m_smart_auto = smart_auto; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SMART_AUTO, smart_auto) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SMART_AUTO", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getSmartAuto(void) +{ + return m_smart_auto; +} + +int SecCamera::getAutosceneStatus(void) +{ + int autoscene_status = -1; + + if (getSmartAuto() == SMART_AUTO_ON) { + autoscene_status = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_SMART_AUTO_STATUS); + + if ((autoscene_status < SMART_AUTO_STATUS_AUTO) || (autoscene_status > SMART_AUTO_STATUS_MAX)) { + LOGE("ERR(%s):Invalid getAutosceneStatus (%d)", __func__, autoscene_status); + return -1; + } + } + //LOGV("%s : autoscene_status (%d)", __func__, autoscene_status); + return autoscene_status; +} +//====================================================================== + +int SecCamera::setBeautyShot(int beauty_shot) +{ + LOGV("%s(beauty_shot (%d))", __func__, beauty_shot); + + if (beauty_shot < BEAUTY_SHOT_OFF || BEAUTY_SHOT_MAX <= beauty_shot) { + LOGE("ERR(%s):Invalid beauty_shot (%d)", __func__, beauty_shot); + return -1; + } + + if (m_beauty_shot != beauty_shot) { + m_beauty_shot = beauty_shot; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BEAUTY_SHOT, beauty_shot) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BEAUTY_SHOT", __func__); + return -1; + } + } + + setFaceDetect(FACE_DETECTION_ON_BEAUTY); + } + + return 0; +} + +int SecCamera::getBeautyShot(void) +{ + return m_beauty_shot; +} + +//====================================================================== + +int SecCamera::setVintageMode(int vintage_mode) +{ + LOGV("%s(vintage_mode(%d))", __func__, vintage_mode); + + if (vintage_mode <= VINTAGE_MODE_BASE || VINTAGE_MODE_MAX <= vintage_mode) { + LOGE("ERR(%s):Invalid vintage_mode (%d)", __func__, vintage_mode); + return -1; + } + + if (m_vintage_mode != vintage_mode) { + m_vintage_mode = vintage_mode; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VINTAGE_MODE, vintage_mode) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_VINTAGE_MODE", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getVintageMode(void) +{ + return m_vintage_mode; +} + +//====================================================================== + +int SecCamera::setFocusMode(int focus_mode) +{ + LOGV("%s(focus_mode(%d))", __func__, focus_mode); + + if (FOCUS_MODE_MAX <= focus_mode) { + LOGE("ERR(%s):Invalid focus_mode (%d)", __func__, focus_mode); + return -1; + } + + if (m_params->focus_mode != focus_mode) { + m_params->focus_mode = focus_mode; + + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, focus_mode) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FOCUS_MODE", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getFocusMode(void) +{ + return m_params->focus_mode; +} + +//====================================================================== + +int SecCamera::setFaceDetect(int face_detect) +{ + LOGV("%s(face_detect(%d))", __func__, face_detect); + + if (m_face_detect != face_detect) { + m_face_detect = face_detect; + if (m_flag_camera_start) { + if (m_face_detect != FACE_DETECTION_OFF) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, FOCUS_MODE_AUTO) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FOCUS_MODin face detecion", __func__); + return -1; + } + } + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FACE_DETECTION, face_detect) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FACE_DETECTION", __func__); + return -1; + } + } + } + + return 0; +} + +int SecCamera::getFaceDetect(void) +{ + return m_face_detect; +} + +//====================================================================== + +int SecCamera::setGPSLatitude(const char *gps_latitude) +{ + double conveted_latitude = 0; + LOGV("%s(gps_latitude(%s))", __func__, gps_latitude); + if (gps_latitude == NULL) + m_gps_latitude = 0; + else { + conveted_latitude = atof(gps_latitude); + m_gps_latitude = (long)(conveted_latitude * 10000 / 1); + } + + LOGV("%s(m_gps_latitude(%ld))", __func__, m_gps_latitude); + return 0; +} + +int SecCamera::setGPSLongitude(const char *gps_longitude) +{ + double conveted_longitude = 0; + LOGV("%s(gps_longitude(%s))", __func__, gps_longitude); + if (gps_longitude == NULL) + m_gps_longitude = 0; + else { + conveted_longitude = atof(gps_longitude); + m_gps_longitude = (long)(conveted_longitude * 10000 / 1); + } + + LOGV("%s(m_gps_longitude(%ld))", __func__, m_gps_longitude); + return 0; +} + +int SecCamera::setGPSAltitude(const char *gps_altitude) +{ + double conveted_altitude = 0; + LOGV("%s(gps_altitude(%s))", __func__, gps_altitude); + if (gps_altitude == NULL) + m_gps_altitude = 0; + else { + conveted_altitude = atof(gps_altitude); + m_gps_altitude = (long)(conveted_altitude * 100 / 1); + } + + LOGV("%s(m_gps_altitude(%ld))", __func__, m_gps_altitude); + return 0; +} + +int SecCamera::setGPSTimeStamp(const char *gps_timestamp) +{ + LOGV("%s(gps_timestamp(%s))", __func__, gps_timestamp); + if (gps_timestamp == NULL) + m_gps_timestamp = 0; + else + m_gps_timestamp = atol(gps_timestamp); + + LOGV("%s(m_gps_timestamp(%ld))", __func__, m_gps_timestamp); + return 0; +} + +int SecCamera::setGPSProcessingMethod(const char *gps_processing_method) +{ + LOGV("%s(gps_processing_method(%s))", __func__, gps_processing_method); + memset(mExifInfo.gps_processing_method, 0, sizeof(mExifInfo.gps_processing_method)); + if (gps_processing_method != NULL) { + size_t len = strlen(gps_processing_method); + if (len > sizeof(mExifInfo.gps_processing_method)) { + len = sizeof(mExifInfo.gps_processing_method); + } + memcpy(mExifInfo.gps_processing_method, gps_processing_method, len); + } + return 0; +} + +int SecCamera::setFaceDetectLockUnlock(int facedetect_lockunlock) +{ + LOGV("%s(facedetect_lockunlock(%d))", __func__, facedetect_lockunlock); + + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FACEDETECT_LOCKUNLOCK, facedetect_lockunlock) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FACEDETECT_LOCKUNLOCK", __func__); + return -1; + } + + return 0; +} + +int SecCamera::setObjectPosition(int x, int y) +{ + LOGV("%s(setObjectPosition(x=%d, y=%d))", __func__, x, y); + + if (m_preview_width ==640) + x = x - 80; + + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_X, x) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_X", __func__); + return -1; + } + + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_Y, y) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_Y", __func__); + return -1; + } + + return 0; +} + +//====================================================================== + +int SecCamera::setGamma(int gamma) +{ + LOGV("%s(gamma(%d))", __func__, gamma); + + if (gamma < GAMMA_OFF || GAMMA_MAX <= gamma) { + LOGE("ERR(%s):Invalid gamma (%d)", __func__, gamma); + return -1; + } + + if (m_video_gamma != gamma) { + m_video_gamma = gamma; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_GAMMA, gamma) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_GAMMA", __func__); + return -1; + } + } + } + + return 0; +} + +//====================================================================== + +int SecCamera::setSlowAE(int slow_ae) +{ + LOGV("%s(slow_ae(%d))", __func__, slow_ae); + + if (slow_ae < GAMMA_OFF || GAMMA_MAX <= slow_ae) { + LOGE("ERR(%s):Invalid slow_ae (%d)", __func__, slow_ae); + return -1; + } + + if (m_slow_ae!= slow_ae) { + m_slow_ae = slow_ae; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_SLOW_AE, slow_ae) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_SLOW_AE", __func__); + return -1; + } + } + } + + return 0; +} + +//====================================================================== +int SecCamera::setRecordingSize(int width, int height) +{ + LOGV("%s(width(%d), height(%d))", __func__, width, height); + + m_recording_width = width; + m_recording_height = height; + + return 0; +} + +//====================================================================== + +int SecCamera::setExifOrientationInfo(int orientationInfo) +{ + LOGV("%s(orientationInfo(%d))", __func__, orientationInfo); + + if (orientationInfo < 0) { + LOGE("ERR(%s):Invalid orientationInfo (%d)", __func__, orientationInfo); + return -1; + } + m_exif_orientation = orientationInfo; + + return 0; +} + +//====================================================================== +int SecCamera::setBatchReflection() +{ + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BATCH_REFLECTION, 1) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BATCH_REFLECTION", __func__); + return -1; + } + } + + return 0; +} + +/*Video call*/ +int SecCamera::setVTmode(int vtmode) +{ + LOGV("%s(vtmode (%d))", __func__, vtmode); + + if (vtmode < VT_MODE_OFF || VT_MODE_MAX <= vtmode) { + LOGE("ERR(%s):Invalid vtmode (%d)", __func__, vtmode); + return -1; + } + + if (m_vtmode != vtmode) { + m_vtmode = vtmode; + } + + return 0; +} + +/* Camcorder fix fps */ +int SecCamera::setSensorMode(int sensor_mode) +{ + LOGV("%s(sensor_mode (%d))", __func__, sensor_mode); + + if (sensor_mode < SENSOR_MODE_CAMERA || SENSOR_MODE_MOVIE < sensor_mode) { + LOGE("ERR(%s):Invalid sensor mode (%d)", __func__, sensor_mode); + return -1; + } + + if (m_sensor_mode != sensor_mode) { + m_sensor_mode = sensor_mode; + } + + return 0; +} + +/* Shot mode */ +/* SINGLE = 0 +* CONTINUOUS = 1 +* PANORAMA = 2 +* SMILE = 3 +* SELF = 6 +*/ +int SecCamera::setShotMode(int shot_mode) +{ + LOGV("%s(shot_mode (%d))", __func__, shot_mode); + if (shot_mode < SHOT_MODE_SINGLE || SHOT_MODE_SELF < shot_mode) { + LOGE("ERR(%s):Invalid shot_mode (%d)", __func__, shot_mode); + return -1; + } + m_shot_mode = shot_mode; + + return 0; +} + +int SecCamera::getVTmode(void) +{ + return m_vtmode; +} + +int SecCamera::setBlur(int blur_level) +{ + LOGV("%s(level (%d))", __func__, blur_level); + + if (blur_level < BLUR_LEVEL_0 || BLUR_LEVEL_MAX <= blur_level) { + LOGE("ERR(%s):Invalid level (%d)", __func__, blur_level); + return -1; + } + + if (m_blur_level != blur_level) { + m_blur_level = blur_level; + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VGA_BLUR, blur_level) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_VGA_BLUR", __func__); + return -1; + } + } + } + return 0; +} + +int SecCamera::getBlur(void) +{ + return m_blur_level; +} + +int SecCamera::setDataLineCheck(int chk_dataline) +{ + LOGV("%s(chk_dataline (%d))", __func__, chk_dataline); + + if (chk_dataline < CHK_DATALINE_OFF || CHK_DATALINE_MAX <= chk_dataline) { + LOGE("ERR(%s):Invalid chk_dataline (%d)", __func__, chk_dataline); + return -1; + } + + if (m_chk_dataline != chk_dataline) { + m_chk_dataline = chk_dataline; + } + + return 0; +} + +int SecCamera::getDataLineCheck(void) +{ + return m_chk_dataline; +} + +int SecCamera::setDataLineCheckStop(void) +{ + LOGV("%s", __func__); + + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CHECK_DATALINE_STOP, 1) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_CHECK_DATALINE_STOP", __func__); + return -1; + } + } + return 0; +} + +const __u8* SecCamera::getCameraSensorName(void) +{ + LOGV("%s", __func__); + + return fimc_v4l2_enuminput(m_cam_fd, getCameraId()); +} + +#ifdef ENABLE_ESD_PREVIEW_CHECK +int SecCamera::getCameraSensorESDStatus(void) +{ + LOGV("%s", __func__); + + // 0 : normal operation, 1 : abnormal operation + int status = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_ESD_INT); + + return status; +} +#endif // ENABLE_ESD_PREVIEW_CHECK + +// ====================================================================== +// Jpeg + +int SecCamera::setJpegThumbnailSize(int width, int height) +{ + LOGV("%s(width(%d), height(%d))", __func__, width, height); + + m_jpeg_thumbnail_width = width; + m_jpeg_thumbnail_height = height; + + return 0; +} + +int SecCamera::getJpegThumbnailSize(int *width, int *height) +{ + if (width) + *width = m_jpeg_thumbnail_width; + if (height) + *height = m_jpeg_thumbnail_height; + + return 0; +} + +void SecCamera::setExifFixedAttribute() +{ + char property[PROPERTY_VALUE_MAX]; + + //2 0th IFD TIFF Tags + //3 Maker + property_get("ro.product.brand", property, EXIF_DEF_MAKER); + strncpy((char *)mExifInfo.maker, property, + sizeof(mExifInfo.maker) - 1); + mExifInfo.maker[sizeof(mExifInfo.maker) - 1] = '\0'; + //3 Model + property_get("ro.product.model", property, EXIF_DEF_MODEL); + strncpy((char *)mExifInfo.model, property, + sizeof(mExifInfo.model) - 1); + mExifInfo.model[sizeof(mExifInfo.model) - 1] = '\0'; + //3 Software + property_get("ro.build.id", property, EXIF_DEF_SOFTWARE); + strncpy((char *)mExifInfo.software, property, + sizeof(mExifInfo.software) - 1); + mExifInfo.software[sizeof(mExifInfo.software) - 1] = '\0'; + + //3 YCbCr Positioning + mExifInfo.ycbcr_positioning = EXIF_DEF_YCBCR_POSITIONING; + + //2 0th IFD Exif Private Tags + //3 F Number + mExifInfo.fnumber.num = EXIF_DEF_FNUMBER_NUM; + mExifInfo.fnumber.den = EXIF_DEF_FNUMBER_DEN; + //3 Exposure Program + mExifInfo.exposure_program = EXIF_DEF_EXPOSURE_PROGRAM; + //3 Exif Version + memcpy(mExifInfo.exif_version, EXIF_DEF_EXIF_VERSION, sizeof(mExifInfo.exif_version)); + //3 Aperture + uint32_t av = APEX_FNUM_TO_APERTURE((double)mExifInfo.fnumber.num/mExifInfo.fnumber.den); + mExifInfo.aperture.num = av*EXIF_DEF_APEX_DEN; + mExifInfo.aperture.den = EXIF_DEF_APEX_DEN; + //3 Maximum lens aperture + mExifInfo.max_aperture.num = mExifInfo.aperture.num; + mExifInfo.max_aperture.den = mExifInfo.aperture.den; + //3 Lens Focal Length + if (m_camera_id == CAMERA_ID_BACK) + mExifInfo.focal_length.num = BACK_CAMERA_FOCAL_LENGTH; + else + mExifInfo.focal_length.num = FRONT_CAMERA_FOCAL_LENGTH; + + mExifInfo.focal_length.den = EXIF_DEF_FOCAL_LEN_DEN; + //3 User Comments + strcpy((char *)mExifInfo.user_comment, EXIF_DEF_USERCOMMENTS); + //3 Color Space information + mExifInfo.color_space = EXIF_DEF_COLOR_SPACE; + //3 Exposure Mode + mExifInfo.exposure_mode = EXIF_DEF_EXPOSURE_MODE; + + //2 0th IFD GPS Info Tags + unsigned char gps_version[4] = { 0x02, 0x02, 0x00, 0x00 }; + memcpy(mExifInfo.gps_version_id, gps_version, sizeof(gps_version)); + + //2 1th IFD TIFF Tags + mExifInfo.compression_scheme = EXIF_DEF_COMPRESSION; + mExifInfo.x_resolution.num = EXIF_DEF_RESOLUTION_NUM; + mExifInfo.x_resolution.den = EXIF_DEF_RESOLUTION_DEN; + mExifInfo.y_resolution.num = EXIF_DEF_RESOLUTION_NUM; + mExifInfo.y_resolution.den = EXIF_DEF_RESOLUTION_DEN; + mExifInfo.resolution_unit = EXIF_DEF_RESOLUTION_UNIT; +} + +void SecCamera::setExifChangedAttribute() +{ + //2 0th IFD TIFF Tags + //3 Width + mExifInfo.width = m_snapshot_width; + //3 Height + mExifInfo.height = m_snapshot_height; + //3 Orientation + switch (m_exif_orientation) { + case 0: + mExifInfo.orientation = EXIF_ORIENTATION_UP; + break; + case 90: + mExifInfo.orientation = EXIF_ORIENTATION_90; + break; + case 180: + mExifInfo.orientation = EXIF_ORIENTATION_180; + break; + case 270: + mExifInfo.orientation = EXIF_ORIENTATION_270; + break; + default: + mExifInfo.orientation = EXIF_ORIENTATION_UP; + break; + } + //3 Date time + time_t rawtime; + struct tm *timeinfo; + time(&rawtime); + timeinfo = localtime(&rawtime); + strftime((char *)mExifInfo.date_time, 20, "%Y:%m:%d %H:%M:%S", timeinfo); + + //2 0th IFD Exif Private Tags + //3 Exposure Time + int shutterSpeed = fimc_v4l2_g_ctrl(m_cam_fd, + V4L2_CID_CAMERA_GET_SHT_TIME); + /* TBD - front camera needs to be fixed to support this g_ctrl, + it current returns a negative err value, so avoid putting + odd value into exif for now */ + if (shutterSpeed < 0) { + LOGE("%s: error %d getting shutterSpeed, camera_id = %d, using 100", + __func__, shutterSpeed, m_camera_id); + shutterSpeed = 100; + } + mExifInfo.exposure_time.num = 1; + // x us -> 1/x s */ + mExifInfo.exposure_time.den = (uint32_t)(1000000 / shutterSpeed); + + //3 ISO Speed Rating + int iso = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_GET_ISO); + /* TBD - front camera needs to be fixed to support this g_ctrl, + it current returns a negative err value, so avoid putting + odd value into exif for now */ + if (iso < 0) { + LOGE("%s: error %d getting iso, camera_id = %d, using 100", + __func__, iso, m_camera_id); + iso = ISO_100; + } + switch(iso) { + case ISO_50: + mExifInfo.iso_speed_rating = 50; + break; + case ISO_100: + mExifInfo.iso_speed_rating = 100; + break; + case ISO_200: + mExifInfo.iso_speed_rating = 200; + break; + case ISO_400: + mExifInfo.iso_speed_rating = 400; + break; + case ISO_800: + mExifInfo.iso_speed_rating = 800; + break; + case ISO_1600: + mExifInfo.iso_speed_rating = 1600; + break; + default: + mExifInfo.iso_speed_rating = 100; + break; + } + + uint32_t av, tv, bv, sv, ev; + av = APEX_FNUM_TO_APERTURE((double)mExifInfo.fnumber.num / mExifInfo.fnumber.den); + tv = APEX_EXPOSURE_TO_SHUTTER((double)mExifInfo.exposure_time.num / mExifInfo.exposure_time.den); + sv = APEX_ISO_TO_FILMSENSITIVITY(mExifInfo.iso_speed_rating); + bv = av + tv - sv; + ev = av + tv; + LOGD("Shutter speed=%d us, iso=%d\n", shutterSpeed, mExifInfo.iso_speed_rating); + LOGD("AV=%d, TV=%d, SV=%d\n", av, tv, sv); + + //3 Shutter Speed + mExifInfo.shutter_speed.num = tv*EXIF_DEF_APEX_DEN; + mExifInfo.shutter_speed.den = EXIF_DEF_APEX_DEN; + //3 Brightness + mExifInfo.brightness.num = bv*EXIF_DEF_APEX_DEN; + mExifInfo.brightness.den = EXIF_DEF_APEX_DEN; + //3 Exposure Bias + if (m_params->scene_mode == SCENE_MODE_BEACH_SNOW) { + mExifInfo.exposure_bias.num = EXIF_DEF_APEX_DEN; + mExifInfo.exposure_bias.den = EXIF_DEF_APEX_DEN; + } else { + mExifInfo.exposure_bias.num = 0; + mExifInfo.exposure_bias.den = 0; + } + //3 Metering Mode + switch (m_params->metering) { + case METERING_SPOT: + mExifInfo.metering_mode = EXIF_METERING_SPOT; + break; + case METERING_MATRIX: + mExifInfo.metering_mode = EXIF_METERING_AVERAGE; + break; + case METERING_CENTER: + mExifInfo.metering_mode = EXIF_METERING_CENTER; + break; + default : + mExifInfo.metering_mode = EXIF_METERING_AVERAGE; + break; + } + + //3 Flash + int flash = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_GET_FLASH_ONOFF); + if (flash < 0) + mExifInfo.flash = EXIF_DEF_FLASH; + else + mExifInfo.flash = flash; + + //3 White Balance + if (m_params->white_balance == WHITE_BALANCE_AUTO) + mExifInfo.white_balance = EXIF_WB_AUTO; + else + mExifInfo.white_balance = EXIF_WB_MANUAL; + //3 Scene Capture Type + switch (m_params->scene_mode) { + case SCENE_MODE_PORTRAIT: + mExifInfo.scene_capture_type = EXIF_SCENE_PORTRAIT; + break; + case SCENE_MODE_LANDSCAPE: + mExifInfo.scene_capture_type = EXIF_SCENE_LANDSCAPE; + break; + case SCENE_MODE_NIGHTSHOT: + mExifInfo.scene_capture_type = EXIF_SCENE_NIGHT; + break; + default: + mExifInfo.scene_capture_type = EXIF_SCENE_STANDARD; + break; + } + + //2 0th IFD GPS Info Tags + if (m_gps_latitude != 0 && m_gps_longitude != 0) { + if (m_gps_latitude > 0) + strcpy((char *)mExifInfo.gps_latitude_ref, "N"); + else + strcpy((char *)mExifInfo.gps_latitude_ref, "S"); + + if (m_gps_longitude > 0) + strcpy((char *)mExifInfo.gps_longitude_ref, "E"); + else + strcpy((char *)mExifInfo.gps_longitude_ref, "W"); + + if (m_gps_altitude > 0) + mExifInfo.gps_altitude_ref = 0; + else + mExifInfo.gps_altitude_ref = 1; + + double latitude = fabs(m_gps_latitude / 10000.0); + double longitude = fabs(m_gps_longitude / 10000.0); + double altitude = fabs(m_gps_altitude / 100.0); + + mExifInfo.gps_latitude[0].num = (uint32_t)latitude; + mExifInfo.gps_latitude[0].den = 1; + mExifInfo.gps_latitude[1].num = (uint32_t)((latitude - mExifInfo.gps_latitude[0].num) * 60); + mExifInfo.gps_latitude[1].den = 1; + mExifInfo.gps_latitude[2].num = (uint32_t)((((latitude - mExifInfo.gps_latitude[0].num) * 60) + - mExifInfo.gps_latitude[1].num) * 60); + mExifInfo.gps_latitude[2].den = 1; + + mExifInfo.gps_longitude[0].num = (uint32_t)longitude; + mExifInfo.gps_longitude[0].den = 1; + mExifInfo.gps_longitude[1].num = (uint32_t)((longitude - mExifInfo.gps_longitude[0].num) * 60); + mExifInfo.gps_longitude[1].den = 1; + mExifInfo.gps_longitude[2].num = (uint32_t)((((longitude - mExifInfo.gps_longitude[0].num) * 60) + - mExifInfo.gps_longitude[1].num) * 60); + mExifInfo.gps_longitude[2].den = 1; + + mExifInfo.gps_altitude.num = (uint32_t)altitude; + mExifInfo.gps_altitude.den = 1; + + struct tm tm_data; + gmtime_r(&m_gps_timestamp, &tm_data); + mExifInfo.gps_timestamp[0].num = tm_data.tm_hour; + mExifInfo.gps_timestamp[0].den = 1; + mExifInfo.gps_timestamp[1].num = tm_data.tm_min; + mExifInfo.gps_timestamp[1].den = 1; + mExifInfo.gps_timestamp[2].num = tm_data.tm_sec; + mExifInfo.gps_timestamp[2].den = 1; + snprintf((char*)mExifInfo.gps_datestamp, sizeof(mExifInfo.gps_datestamp), + "%04d:%02d:%02d", tm_data.tm_year + 1900, tm_data.tm_mon, tm_data.tm_mday); + + mExifInfo.enableGps = true; + } else { + mExifInfo.enableGps = false; + } + + //2 1th IFD TIFF Tags + mExifInfo.widthThumb = m_jpeg_thumbnail_width; + mExifInfo.heightThumb = m_jpeg_thumbnail_height; +} + +// ====================================================================== +// Conversions + +inline int SecCamera::m_frameSize(int format, int width, int height) +{ + int size = 0; + + switch (format) { + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_NV12: + case V4L2_PIX_FMT_NV21: + size = (width * height * 3 / 2); + break; + + case V4L2_PIX_FMT_NV12T: + size = ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)) + + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2)); + break; + + case V4L2_PIX_FMT_YUV422P: + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_UYVY: + size = (width * height * 2); + break; + + default : + LOGE("ERR(%s):Invalid V4L2 pixel format(%d)\n", __func__, format); + case V4L2_PIX_FMT_RGB565: + size = (width * height * BPP); + break; + } + + return size; +} + +status_t SecCamera::dump(int fd, const Vector &args) +{ + const size_t SIZE = 256; + char buffer[SIZE]; + String8 result; + snprintf(buffer, 255, "dump(%d)\n", fd); + result.append(buffer); + ::write(fd, result.string(), result.size()); + return NO_ERROR; +} + +double SecCamera::jpeg_ratio = 0.7; +int SecCamera::interleaveDataSize = 4261248; +int SecCamera::jpegLineLength = 636; + +}; // namespace android diff --git a/libcamera/SecCamera.h b/libcamera/SecCamera.h new file mode 100644 index 0000000..b846201 --- /dev/null +++ b/libcamera/SecCamera.h @@ -0,0 +1,538 @@ +/* +** +** Copyright 2008, The Android Open Source Project +** Copyright 2010, Samsung Electronics Co. LTD +** +** 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_SEC_H +#define ANDROID_HARDWARE_CAMERA_SEC_H + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "JpegEncoder.h" + +#include + +namespace android { + +#define ENABLE_ESD_PREVIEW_CHECK + +#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0 +#define LOG_CAMERA LOGD +#define LOG_CAMERA_PREVIEW LOGD + +#define LOG_TIME_DEFINE(n) \ + struct timeval time_start_##n, time_stop_##n; unsigned long log_time_##n = 0; + +#define LOG_TIME_START(n) \ + gettimeofday(&time_start_##n, NULL); + +#define LOG_TIME_END(n) \ + gettimeofday(&time_stop_##n, NULL); log_time_##n = measure_time(&time_start_##n, &time_stop_##n); + +#define LOG_TIME(n) \ + log_time_##n + +#else +#define LOG_CAMERA(...) +#define LOG_CAMERA_PREVIEW(...) +#define LOG_TIME_DEFINE(n) +#define LOG_TIME_START(n) +#define LOG_TIME_END(n) +#define LOG_TIME(n) +#endif + +#define MAX_BACK_CAMERA_PREVIEW_WIDTH 720 +#define MAX_BACK_CAMERA_PREVIEW_HEIGHT 480 +#define MAX_BACK_CAMERA_SNAPSHOT_WIDTH 2560 +#define MAX_BACK_CAMERA_SNAPSHOT_HEIGHT 1920 +#define BACK_CAMERA_POSTVIEW_WIDTH 640 +#define BACK_CAMERA_POSTVIEW_WIDE_WIDTH 800 +#define BACK_CAMERA_POSTVIEW_HEIGHT 480 +#define BACK_CAMERA_POSTVIEW_BPP 16 +#define BACK_CAMERA_THUMBNAIL_WIDTH 320 +#define BACK_CAMERA_THUMBNAIL_HEIGHT 240 +#define BACK_CAMERA_THUMBNAIL_BPP 16 + +#define BACK_CAMERA_FOCAL_LENGTH 379 /* 3.79mm */ + +#define MAX_FRONT_CAMERA_PREVIEW_WIDTH 640 +#define MAX_FRONT_CAMERA_PREVIEW_HEIGHT 480 +#define MAX_FRONT_CAMERA_SNAPSHOT_WIDTH 640 +#define MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT 480 + +#define FRONT_CAMERA_THUMBNAIL_WIDTH 160 +#define FRONT_CAMERA_THUMBNAIL_HEIGHT 120 +#define FRONT_CAMERA_THUMBNAIL_BPP 16 +#define FRONT_CAMERA_FOCAL_LENGTH 130 /* 1.3mm */ + +#define DEFAULT_JPEG_THUMBNAIL_WIDTH 256 +#define DEFAULT_JPEG_THUMBNAIL_HEIGHT 192 + +#ifndef CAMERA_DEV_NAME +#define CAMERA_DEV_NAME "/dev/video0" +#endif +#ifndef CAMERA_DEV_NAME2 +#define CAMERA_DEV_NAME2 "/dev/video2" +#endif + +#define CAMERA_DEV_NAME_TEMP "/data/videotmp_000" +#define CAMERA_DEV_NAME2_TEMP "/data/videotemp_002" + + +#define BPP 2 +#define MIN(x, y) (((x) < (y)) ? (x) : (y)) +#define MAX_BUFFERS 11 + +/* + * V 4 L 2 F I M C E X T E N S I O N S + * + */ +#define V4L2_CID_ROTATION (V4L2_CID_PRIVATE_BASE + 0) +#define V4L2_CID_PADDR_Y (V4L2_CID_PRIVATE_BASE + 1) +#define V4L2_CID_PADDR_CB (V4L2_CID_PRIVATE_BASE + 2) +#define V4L2_CID_PADDR_CR (V4L2_CID_PRIVATE_BASE + 3) +#define V4L2_CID_PADDR_CBCR (V4L2_CID_PRIVATE_BASE + 4) +#define V4L2_CID_STREAM_PAUSE (V4L2_CID_PRIVATE_BASE + 53) + +#define V4L2_CID_CAM_JPEG_MAIN_SIZE (V4L2_CID_PRIVATE_BASE + 32) +#define V4L2_CID_CAM_JPEG_MAIN_OFFSET (V4L2_CID_PRIVATE_BASE + 33) +#define V4L2_CID_CAM_JPEG_THUMB_SIZE (V4L2_CID_PRIVATE_BASE + 34) +#define V4L2_CID_CAM_JPEG_THUMB_OFFSET (V4L2_CID_PRIVATE_BASE + 35) +#define V4L2_CID_CAM_JPEG_POSTVIEW_OFFSET (V4L2_CID_PRIVATE_BASE + 36) +#define V4L2_CID_CAM_JPEG_QUALITY (V4L2_CID_PRIVATE_BASE + 37) + +#define TPATTERN_COLORBAR 1 +#define TPATTERN_HORIZONTAL 2 +#define TPATTERN_VERTICAL 3 + +#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') + +/* FOURCC for FIMC specific */ +#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') +#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') +#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') +#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2') +/* + * U S E R D E F I N E D T Y P E S + * + */ + +struct fimc_buffer { + void *start; + size_t length; +}; + +struct yuv_fmt_list { + const char *name; + const char *desc; + unsigned int fmt; + int depth; + int planes; +}; + +//s1 [Apply factory standard] +struct camsensor_date_info { + unsigned int year; + unsigned int month; + unsigned int date; +}; + + +class SecCamera { +public: + + enum CAMERA_ID { + CAMERA_ID_BACK = 0, + CAMERA_ID_FRONT = 1, + }; + + enum JPEG_QUALITY { + JPEG_QUALITY_ECONOMY = 0, + JPEG_QUALITY_NORMAL = 50, + JPEG_QUALITY_SUPERFINE = 100, + JPEG_QUALITY_MAX, + }; + + enum OBJECT_TRACKING { + OBJECT_TRACKING_OFF, + OBJECT_TRACKING_ON, + OBJECT_TRACKING_MAX, + }; + + /*VT call*/ + enum VT_MODE { + VT_MODE_OFF, + VT_MODE_ON, + VT_MODE_MAX, + }; + + /*Camera sensor mode - Camcorder fix fps*/ + enum SENSOR_MODE { + SENSOR_MODE_CAMERA, + SENSOR_MODE_MOVIE, + }; + + /*Camera Shot mode*/ + enum SHOT_MODE { + SHOT_MODE_SINGLE = 0, + SHOT_MODE_CONTINUOUS = 1, + SHOT_MODE_PANORAMA = 2, + SHOT_MODE_SMILE = 3, + SHOT_MODE_SELF = 6, + }; + + enum CHK_DATALINE { + CHK_DATALINE_OFF, + CHK_DATALINE_ON, + CHK_DATALINE_MAX, + }; + + int m_touch_af_start_stop; + + struct gps_info_latiude { + unsigned int north_south; + unsigned int dgree; + unsigned int minute; + unsigned int second; + } gpsInfoLatitude; + struct gps_info_longitude { + unsigned int east_west; + unsigned int dgree; + unsigned int minute; + unsigned int second; + } gpsInfoLongitude; + struct gps_info_altitude { + unsigned int plus_minus; + unsigned int dgree; + unsigned int minute; + unsigned int second; + } gpsInfoAltitude; + + SecCamera(); + ~SecCamera(); + + static SecCamera* createInstance(void) + { + static SecCamera singleton; + return &singleton; + } + status_t dump(int fd, const Vector& args); + + int flagCreate(void) const; + + int getCameraId(void); + + int startPreview(void); + int stopPreview(void); + + int startRecord(void); + int stopRecord(void); + int getRecordFrame(void); + int releaseRecordFrame(int index); + unsigned int getRecPhyAddrY(int); + unsigned int getRecPhyAddrC(int); + + int getPreview(void); + int setPreviewSize(int width, int height, int pixel_format); + int getPreviewSize(int *width, int *height, int *frame_size); + int getPreviewMaxSize(int *width, int *height); + int getPreviewPixelFormat(void); + int setPreviewImage(int index, unsigned char *buffer, int size); + + int setSnapshotSize(int width, int height); + int getSnapshotSize(int *width, int *height, int *frame_size); + int getSnapshotMaxSize(int *width, int *height); + int setSnapshotPixelFormat(int pixel_format); + int getSnapshotPixelFormat(void); + + unsigned char* getJpeg(unsigned char *snapshot_data, int snapshot_size, int *size); + unsigned char* yuv2Jpeg(unsigned char *raw_data, int raw_size, + int *jpeg_size, + int width, int height, int pixel_format); + + int setJpegThumbnailSize(int width, int height); + int getJpegThumbnailSize(int *width, int *height); + + int setAutofocus(void); + int zoomIn(void); + int zoomOut(void); + + int SetRotate(int angle); + int getRotate(void); + + int setVerticalMirror(void); + int setHorizontalMirror(void); + + int setWhiteBalance(int white_balance); + int getWhiteBalance(void); + + int setBrightness(int brightness); + int getBrightness(void); + + int setImageEffect(int image_effect); + int getImageEffect(void); + + int setSceneMode(int scene_mode); + int getSceneMode(void); + + int setFlashMode(int flash_mode); + int getFlashMode(void); + + int setMetering(int metering_value); + int getMetering(void); + + int setISO(int iso_value); + int getISO(void); + + int setContrast(int contrast_value); + int getContrast(void); + + int setSaturation(int saturation_value); + int getSaturation(void); + + int setSharpness(int sharpness_value); + int getSharpness(void); + + int setWDR(int wdr_value); + int getWDR(void); + + int setAntiShake(int anti_shake); + int getAntiShake(void); + + int setJpegQuality(int jpeg_qality); + int getJpegQuality(void); + + int setZoom(int zoom_level); + int getZoom(void); + + int setObjectTracking(int object_tracking); + int getObjectTracking(void); + int getObjectTrackingStatus(void); + + int setSmartAuto(int smart_auto); + int getSmartAuto(void); + int getAutosceneStatus(void); + + int setBeautyShot(int beauty_shot); + int getBeautyShot(void); + + int setVintageMode(int vintage_mode); + int getVintageMode(void); + + int setFocusMode(int focus_mode); + int getFocusMode(void); + + int setFaceDetect(int face_detect); + int getFaceDetect(void); + + int setGPSLatitude(const char *gps_latitude); + int setGPSLongitude(const char *gps_longitude); + int setGPSAltitude(const char *gps_altitude); + int setGPSTimeStamp(const char *gps_timestamp); + int setGPSProcessingMethod(const char *gps_timestamp); + int cancelAutofocus(void); + int setFaceDetectLockUnlock(int facedetect_lockunlock); + int setObjectPosition(int x, int y); + int setObjectTrackingStartStop(int start_stop); + int setTouchAFStartStop(int start_stop); + int setCAFStatus(int on_off); + int getAutoFocusResult(void); + int setAntiBanding(int anti_banding); + int getPostview(void); + int setRecordingSize(int width, int height); + int setGamma(int gamma); + int setSlowAE(int slow_ae); + int setExifOrientationInfo(int orientationInfo); + int setBatchReflection(void); + int setSnapshotCmd(void); + int endSnapshot(void); + int setCameraSensorReset(void); + int setSensorMode(int sensor_mode); /* Camcorder fix fps */ + int setShotMode(int shot_mode); /* Shot mode */ + /*VT call*/ + int setVTmode(int vtmode); + int getVTmode(void); + int setBlur(int blur_level); + int getBlur(void); + int setDataLineCheck(int chk_dataline); + int getDataLineCheck(void); + int setDataLineCheckStop(void); + int setDefultIMEI(int imei); + int getDefultIMEI(void); + const __u8* getCameraSensorName(void); + int previewPoll(bool preview); +#ifdef ENABLE_ESD_PREVIEW_CHECK + int getCameraSensorESDStatus(void); +#endif // ENABLE_ESD_PREVIEW_CHECK + + int setFrameRate(int frame_rate); + unsigned char* getJpeg(int*, unsigned int*); + int getSnapshotAndJpeg(unsigned char *yuv_buf, unsigned char *jpeg_buf, + unsigned int *output_size); + int getExif(unsigned char *pExifDst, unsigned char *pThumbSrc); + + void getPostViewConfig(int*, int*, int*); + void getThumbnailConfig(int *width, int *height, int *size); + + int getPostViewOffset(void); + int getCameraFd(void); + int getJpegFd(void); + void SetJpgAddr(unsigned char *addr); + unsigned int getPhyAddrY(int); + unsigned int getPhyAddrC(int); + void pausePreview(); + int initCamera(int index); + void DeinitCamera(); + static void setJpegRatio(double ratio) + { + if((ratio < 0) || (ratio > 1)) + return; + + jpeg_ratio = ratio; + } + + static double getJpegRatio() + { + return jpeg_ratio; + } + + static void setInterleaveDataSize(int x) + { + interleaveDataSize = x; + } + + static int getInterleaveDataSize() + { + return interleaveDataSize; + } + + static void setJpegLineLength(int x) + { + jpegLineLength = x; + } + + static int getJpegLineLength() + { + return jpegLineLength; + } + + +private: + v4l2_streamparm m_streamparm; + struct sec_cam_parm *m_params; + int m_flag_init; + + int m_camera_id; + + int m_cam_fd; + + int m_cam_fd_temp; + int m_cam_fd2_temp; + + int m_cam_fd2; + struct pollfd m_events_c2; + int m_flag_record_start; + + int m_preview_v4lformat; + int m_preview_width; + int m_preview_height; + int m_preview_max_width; + int m_preview_max_height; + + int m_snapshot_v4lformat; + int m_snapshot_width; + int m_snapshot_height; + int m_snapshot_max_width; + int m_snapshot_max_height; + + int m_angle; + int m_anti_banding; + int m_wdr; + int m_anti_shake; + int m_zoom_level; + int m_object_tracking; + int m_smart_auto; + int m_beauty_shot; + int m_vintage_mode; + int m_face_detect; + int m_object_tracking_start_stop; + int m_recording_width; + int m_recording_height; + long m_gps_latitude; + long m_gps_longitude; + long m_gps_altitude; + long m_gps_timestamp; + int m_vtmode; + int m_sensor_mode; /*Camcorder fix fps */ + int m_shot_mode; /* Shot mode */ + int m_exif_orientation; + int m_blur_level; + int m_chk_dataline; + int m_video_gamma; + int m_slow_ae; + int m_caf_on_off; + int m_default_imei; + int m_camera_af_flag; + + int m_flag_camera_start; + + int m_jpeg_fd; + int m_jpeg_thumbnail_width; + int m_jpeg_thumbnail_height; + int m_jpeg_quality; + + int m_postview_offset; + +#ifdef ENABLE_ESD_PREVIEW_CHECK + int m_esd_check_count; +#endif // ENABLE_ESD_PREVIEW_CHECK + + exif_attribute_t mExifInfo; + + struct fimc_buffer m_capture_buf; + struct pollfd m_events_c; + + inline int m_frameSize(int format, int width, int height); + + void setExifChangedAttribute(); + void setExifFixedAttribute(); + void resetCamera(); + + static double jpeg_ratio; + static int interleaveDataSize; + static int jpegLineLength; +}; + +extern unsigned long measure_time(struct timeval *start, struct timeval *stop); + +}; // namespace android + +#endif // ANDROID_HARDWARE_CAMERA_SEC_H diff --git a/libcamera/SecCameraHWInterface.cpp b/libcamera/SecCameraHWInterface.cpp new file mode 100644 index 0000000..f019e01 --- /dev/null +++ b/libcamera/SecCameraHWInterface.cpp @@ -0,0 +1,2142 @@ +/* +** +** Copyright 2008, The Android Open Source Project +** Copyright 2010, Samsung Electronics Co. LTD +** +** 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. +*/ + +#define LOG_NDEBUG 0 +#define LOG_TAG "CameraHardwareSec" +#include + +#include "SecCameraHWInterface.h" +#include +#include +#include + +#if defined(BOARD_USES_OVERLAY) +#include +#include +#define CACHEABLE_BUFFERS 0x1 +#define ALL_BUFFERS_FLUSHED -66 +#endif + +#define VIDEO_COMMENT_MARKER_H 0xFFBE +#define VIDEO_COMMENT_MARKER_L 0xFFBF +#define VIDEO_COMMENT_MARKER_LENGTH 4 +#define JPEG_EOI_MARKER 0xFFD9 +#define HIBYTE(x) (((x) >> 8) & 0xFF) +#define LOBYTE(x) ((x) & 0xFF) + +#define BACK_CAMERA_AUTO_FOCUS_DISTANCES_STR "0.10,1.20,Infinity" +#define BACK_CAMERA_MACRO_FOCUS_DISTANCES_STR "0.10,0.20,Infinity" +#define BACK_CAMERA_INFINITY_FOCUS_DISTANCES_STR "0.10,1.20,Infinity" +#define FRONT_CAMERA_FOCUS_DISTANCES_STR "0.20,0.25,Infinity" + +namespace android { + +struct addrs { + unsigned int addr_y; + unsigned int addr_cbcr; + unsigned int buf_index; + unsigned int reserved; +}; + +struct addrs_cap { + unsigned int addr_y; + unsigned int width; + unsigned int height; +}; + +static const int INITIAL_SKIP_FRAME = 3; +static const int EFFECT_SKIP_FRAME = 1; + +CameraHardwareSec::CameraHardwareSec(int cameraId) + : + mCaptureInProgress(false), + mParameters(), + mPreviewHeap(0), + mRawHeap(0), + mRecordHeap(0), + mJpegHeap(0), + mSecCamera(NULL), + mCameraSensorName(NULL), + mSkipFrame(0), +#if defined(BOARD_USES_OVERLAY) + mUseOverlay(false), + mOverlayBufferIdx(0), +#endif + mNotifyCb(0), + mDataCb(0), + mDataCbTimestamp(0), + mCallbackCookie(0), + mMsgEnabled(0), + mRecordRunning(false), + mPostViewWidth(0), + mPostViewHeight(0), + mPostViewSize(0) +{ + LOGV("%s :", __func__); + int ret = 0; + + mSecCamera = SecCamera::createInstance(); + + if (mSecCamera == NULL) { + LOGE("ERR(%s):Fail on mSecCamera object creation", __func__); + } + + ret = mSecCamera->initCamera(cameraId); + if (ret < 0) { + LOGE("ERR(%s):Fail on mSecCamera init", __func__); + } + + if (mSecCamera->flagCreate() == 0) { + LOGE("ERR(%s):Fail on mSecCamera->flagCreate()", __func__); + } + + int recordHeapSize = sizeof(struct addrs) * kBufferCount; + LOGV("mRecordHeap : MemoryHeapBase(recordHeapSize(%d))", recordHeapSize); + mRecordHeap = new MemoryHeapBase(recordHeapSize); + if (mRecordHeap->getHeapID() < 0) { + LOGE("ERR(%s): Record heap creation fail", __func__); + mRecordHeap.clear(); + } + + mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize); + LOGV("mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d", + mPostViewWidth,mPostViewHeight,mPostViewSize); + + int rawHeapSize = mPostViewSize; + LOGV("mRawHeap : MemoryHeapBase(previewHeapSize(%d))", rawHeapSize); + mRawHeap = new MemoryHeapBase(rawHeapSize); + if (mRawHeap->getHeapID() < 0) { + LOGE("ERR(%s): Raw heap creation fail", __func__); + mRawHeap.clear(); + } + + initDefaultParameters(cameraId); + + mExitAutoFocusThread = false; + mExitPreviewThread = false; + /* whether the PreviewThread is active in preview or stopped. we + * create the thread but it is initially in stopped state. + */ + mPreviewRunning = false; + mPreviewThread = new PreviewThread(this); + mAutoFocusThread = new AutoFocusThread(this); + mPictureThread = new PictureThread(this); +} + +void CameraHardwareSec::initDefaultParameters(int cameraId) +{ + if (mSecCamera == NULL) { + LOGE("ERR(%s):mSecCamera object is NULL", __func__); + return; + } + + CameraParameters p; + CameraParameters ip; + + mCameraSensorName = mSecCamera->getCameraSensorName(); + LOGV("CameraSensorName: %s", mCameraSensorName); + + int preview_max_width = 0; + int preview_max_height = 0; + int snapshot_max_width = 0; + int snapshot_max_height = 0; + + if (cameraId == SecCamera::CAMERA_ID_BACK) { + p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, + "720x480,640x480,320x240,176x144"); + p.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, + "2560x1920,2048x1536,1600x1200,1600x960,640x480"); + } else { + p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, + "640x480,320x240,176x144"); + p.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, + "640x480"); + } + + // If these fail, then we are using an invalid cameraId and we'll leave the + // sizes at zero to catch the error. + if (mSecCamera->getPreviewMaxSize(&preview_max_width, + &preview_max_height) < 0) + LOGE("getPreviewMaxSize fail (%d / %d) \n", + preview_max_width, preview_max_height); + if (mSecCamera->getSnapshotMaxSize(&snapshot_max_width, + &snapshot_max_height) < 0) + LOGE("getSnapshotMaxSize fail (%d / %d) \n", + snapshot_max_width, snapshot_max_height); + + p.setPreviewFormat(CameraParameters::PIXEL_FORMAT_YUV420SP); + p.setPreviewSize(preview_max_width, preview_max_height); + + p.setPictureFormat(CameraParameters::PIXEL_FORMAT_JPEG); + p.setPictureSize(snapshot_max_width, snapshot_max_height); + p.set(CameraParameters::KEY_JPEG_QUALITY, "100"); // maximum quality + + p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS, + CameraParameters::PIXEL_FORMAT_YUV420SP); + p.set(CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS, + CameraParameters::PIXEL_FORMAT_JPEG); + p.set(CameraParameters::KEY_VIDEO_FRAME_FORMAT, + CameraParameters::PIXEL_FORMAT_YUV420SP); + + String8 parameterString; + + if (cameraId == SecCamera::CAMERA_ID_BACK) { + parameterString = CameraParameters::FOCUS_MODE_AUTO; + parameterString.append(","); + parameterString.append(CameraParameters::FOCUS_MODE_INFINITY); + parameterString.append(","); + parameterString.append(CameraParameters::FOCUS_MODE_MACRO); + p.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES, + parameterString.string()); + p.set(CameraParameters::KEY_FOCUS_MODE, + CameraParameters::FOCUS_MODE_AUTO); + p.set(CameraParameters::KEY_FOCUS_DISTANCES, + BACK_CAMERA_AUTO_FOCUS_DISTANCES_STR); + p.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, + "320x240,0x0"); + p.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, "320"); + p.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, "240"); + p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES, "30"); + p.setPreviewFrameRate(30); + } else { + parameterString = CameraParameters::FOCUS_MODE_FIXED; + p.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES, + parameterString.string()); + p.set(CameraParameters::KEY_FOCUS_MODE, + CameraParameters::FOCUS_MODE_FIXED); + p.set(CameraParameters::KEY_FOCUS_DISTANCES, + FRONT_CAMERA_FOCUS_DISTANCES_STR); + p.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, + "160x120,0x0"); + p.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, "160"); + p.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, "120"); + p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES, "15"); + p.setPreviewFrameRate(15); + } + + parameterString = CameraParameters::EFFECT_NONE; + parameterString.append(","); + parameterString.append(CameraParameters::EFFECT_MONO); + parameterString.append(","); + parameterString.append(CameraParameters::EFFECT_NEGATIVE); + parameterString.append(","); + parameterString.append(CameraParameters::EFFECT_SEPIA); + p.set(CameraParameters::KEY_SUPPORTED_EFFECTS, parameterString.string()); + + if (cameraId == SecCamera::CAMERA_ID_BACK) { + parameterString = CameraParameters::FLASH_MODE_ON; + parameterString.append(","); + parameterString.append(CameraParameters::FLASH_MODE_OFF); + parameterString.append(","); + parameterString.append(CameraParameters::FLASH_MODE_AUTO); + parameterString.append(","); + parameterString.append(CameraParameters::FLASH_MODE_TORCH); + p.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, + parameterString.string()); + p.set(CameraParameters::KEY_FLASH_MODE, + CameraParameters::FLASH_MODE_OFF); + + parameterString = CameraParameters::SCENE_MODE_AUTO; + parameterString.append(","); + parameterString.append(CameraParameters::SCENE_MODE_PORTRAIT); + parameterString.append(","); + parameterString.append(CameraParameters::SCENE_MODE_LANDSCAPE); + parameterString.append(","); + parameterString.append(CameraParameters::SCENE_MODE_NIGHT); + parameterString.append(","); + parameterString.append(CameraParameters::SCENE_MODE_BEACH); + parameterString.append(","); + parameterString.append(CameraParameters::SCENE_MODE_SNOW); + parameterString.append(","); + parameterString.append(CameraParameters::SCENE_MODE_SUNSET); + parameterString.append(","); + parameterString.append(CameraParameters::SCENE_MODE_FIREWORKS); + parameterString.append(","); + parameterString.append(CameraParameters::SCENE_MODE_SPORTS); + parameterString.append(","); + parameterString.append(CameraParameters::SCENE_MODE_PARTY); + parameterString.append(","); + parameterString.append(CameraParameters::SCENE_MODE_CANDLELIGHT); + p.set(CameraParameters::KEY_SUPPORTED_SCENE_MODES, + parameterString.string()); + p.set(CameraParameters::KEY_SCENE_MODE, + CameraParameters::SCENE_MODE_AUTO); + + /* we have two ranges, 4-30fps for night mode and + * 15-30fps for all others + */ + p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, "(15000,30000)"); + p.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, "15000,30000"); + + p.set(CameraParameters::KEY_FOCAL_LENGTH, "3.43"); + } else { + p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, "(7500,30000)"); + p.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, "7500,30000"); + + p.set(CameraParameters::KEY_FOCAL_LENGTH, "0.9"); + } + + parameterString = CameraParameters::WHITE_BALANCE_AUTO; + parameterString.append(","); + parameterString.append(CameraParameters::WHITE_BALANCE_INCANDESCENT); + parameterString.append(","); + parameterString.append(CameraParameters::WHITE_BALANCE_FLUORESCENT); + parameterString.append(","); + parameterString.append(CameraParameters::WHITE_BALANCE_DAYLIGHT); + parameterString.append(","); + parameterString.append(CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT); + p.set(CameraParameters::KEY_SUPPORTED_WHITE_BALANCE, + parameterString.string()); + + ip.set("sharpness-min", 0); + ip.set("sharpness-max", 4); + ip.set("saturation-min", 0); + ip.set("saturation-max", 4); + ip.set("contrast-min", 0); + ip.set("contrast-max", 4); + + p.set(CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY, "100"); + + p.set(CameraParameters::KEY_ROTATION, 0); + p.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO); + + p.set(CameraParameters::KEY_EFFECT, CameraParameters::EFFECT_NONE); + + ip.set("sharpness", SHARPNESS_DEFAULT); + ip.set("contrast", CONTRAST_DEFAULT); + ip.set("saturation", SATURATION_DEFAULT); + ip.set("iso", "auto"); + ip.set("metering", "center"); + + ip.set("wdr", 0); + ip.set("chk_dataline", 0); + if (cameraId == SecCamera::CAMERA_ID_FRONT) { + ip.set("vtmode", 0); + ip.set("blur", 0); + } + + p.set(CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE, "51.2"); + p.set(CameraParameters::KEY_VERTICAL_VIEW_ANGLE, "39.4"); + + p.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, "0"); + p.set(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "4"); + p.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-4"); + p.set(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5"); + + mParameters = p; + mInternalParameters = ip; + + /* make sure mSecCamera has all the settings we do. applications + * aren't required to call setParameters themselves (only if they + * want to change something. + */ + setParameters(p); + mSecCamera->setISO(ISO_AUTO); + mSecCamera->setMetering(METERING_CENTER); + mSecCamera->setContrast(CONTRAST_DEFAULT); + mSecCamera->setSharpness(SHARPNESS_DEFAULT); + mSecCamera->setSaturation(SATURATION_DEFAULT); + if (cameraId == SecCamera::CAMERA_ID_BACK) + mSecCamera->setFrameRate(30); + else + mSecCamera->setFrameRate(15); +} + +CameraHardwareSec::~CameraHardwareSec() +{ + LOGV("%s :", __func__); + + singleton.clear(); +} + +sp CameraHardwareSec::getPreviewHeap() const +{ + return mPreviewHeap; +} + +sp CameraHardwareSec::getRawHeap() const +{ + return mRawHeap; +} + +void CameraHardwareSec::setCallbacks(notify_callback notify_cb, + data_callback data_cb, + data_callback_timestamp data_cb_timestamp, + void *user) +{ + mNotifyCb = notify_cb; + mDataCb = data_cb; + mDataCbTimestamp = data_cb_timestamp; + mCallbackCookie = user; +} + +void CameraHardwareSec::enableMsgType(int32_t msgType) +{ + LOGV("%s : msgType = 0x%x, mMsgEnabled before = 0x%x", + __func__, msgType, mMsgEnabled); + mMsgEnabled |= msgType; + LOGV("%s : mMsgEnabled = 0x%x", __func__, mMsgEnabled); +} + +void CameraHardwareSec::disableMsgType(int32_t msgType) +{ + LOGV("%s : msgType = 0x%x, mMsgEnabled before = 0x%x", + __func__, msgType, mMsgEnabled); + mMsgEnabled &= ~msgType; + LOGV("%s : mMsgEnabled = 0x%x", __func__, mMsgEnabled); +} + +bool CameraHardwareSec::msgTypeEnabled(int32_t msgType) +{ + return (mMsgEnabled & msgType); +} + +// --------------------------------------------------------------------------- +void CameraHardwareSec::setSkipFrame(int frame) +{ + Mutex::Autolock lock(mSkipFrameLock); + if (frame < mSkipFrame) + return; + + mSkipFrame = frame; +} + +int CameraHardwareSec::previewThreadWrapper() +{ + LOGI("%s: starting", __func__); + while (1) { + mPreviewLock.lock(); + while (!mPreviewRunning) { + LOGI("%s: calling mSecCamera->stopPreview() and waiting", __func__); + mSecCamera->stopPreview(); + /* signal that we're stopping */ + mPreviewStoppedCondition.signal(); + mPreviewCondition.wait(mPreviewLock); + LOGI("%s: return from wait", __func__); + } + mPreviewLock.unlock(); + + if (mExitPreviewThread) { + LOGI("%s: exiting", __func__); + mSecCamera->stopPreview(); + return 0; + } + previewThread(); + } +} + +int CameraHardwareSec::previewThread() +{ + int index; + nsecs_t timestamp; + unsigned int phyYAddr; + unsigned int phyCAddr; + struct addrs *addrs; + + index = mSecCamera->getPreview(); + if (index < 0) { + LOGE("ERR(%s):Fail on SecCamera->getPreview()", __func__); + return UNKNOWN_ERROR; + } + mSkipFrameLock.lock(); + if (mSkipFrame > 0) { + mSkipFrame--; + mSkipFrameLock.unlock(); + return NO_ERROR; + } + mSkipFrameLock.unlock(); + + timestamp = systemTime(SYSTEM_TIME_MONOTONIC); + + phyYAddr = mSecCamera->getPhyAddrY(index); + phyCAddr = mSecCamera->getPhyAddrC(index); + + if (phyYAddr == 0xffffffff || phyCAddr == 0xffffffff) { + LOGE("ERR(%s):Fail on SecCamera getPhyAddr Y addr = %0x C addr = %0x", __func__, phyYAddr, phyCAddr); + return UNKNOWN_ERROR; + } + + int width, height, frame_size, offset; + + mSecCamera->getPreviewSize(&width, &height, &frame_size); + + offset = (frame_size + 16) * index; + sp buffer = new MemoryBase(mPreviewHeap, offset, frame_size); + + memcpy(static_cast(mPreviewHeap->base()) + (offset + frame_size ), &phyYAddr, 4); + memcpy(static_cast(mPreviewHeap->base()) + (offset + frame_size + 4), &phyCAddr, 4); + +#if defined(BOARD_USES_OVERLAY) + if (mUseOverlay) { + int ret; + overlay_buffer_t overlay_buffer; + + mOverlayBufferIdx ^= 1; + memcpy(static_cast(mPreviewHeap->base()) + offset + frame_size + sizeof(phyYAddr) + sizeof(phyCAddr), + &mOverlayBufferIdx, sizeof(mOverlayBufferIdx)); + + ret = mOverlay->queueBuffer((void*)(static_cast(mPreviewHeap->base()) + (offset + frame_size))); + + if (ret == -1 ) { + LOGE("ERR(%s):overlay queueBuffer fail", __func__); + } else if (ret != ALL_BUFFERS_FLUSHED) { + ret = mOverlay->dequeueBuffer(&overlay_buffer); + if (ret == -1) { + LOGE("ERR(%s):overlay dequeueBuffer fail", __func__); + } + } + } +#endif + + // Notify the client of a new frame. + if (mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME) { + mDataCb(CAMERA_MSG_PREVIEW_FRAME, buffer, mCallbackCookie); + } + + Mutex::Autolock lock(mRecordLock); + if (mRecordRunning == true) { + index = mSecCamera->getRecordFrame(); + if (index < 0) { + LOGE("ERR(%s):Fail on SecCamera->getRecord()", __func__); + return UNKNOWN_ERROR; + } + + phyYAddr = mSecCamera->getRecPhyAddrY(index); + phyCAddr = mSecCamera->getRecPhyAddrC(index); + + if (phyYAddr == 0xffffffff || phyCAddr == 0xffffffff) { + LOGE("ERR(%s):Fail on SecCamera getRectPhyAddr Y addr = %0x C addr = %0x", __func__, phyYAddr, phyCAddr); + return UNKNOWN_ERROR; + } + + addrs = (struct addrs *)mRecordHeap->base(); + + sp buffer = new MemoryBase(mRecordHeap, index * sizeof(struct addrs), sizeof(struct addrs)); + addrs[index].addr_y = phyYAddr; + addrs[index].addr_cbcr = phyCAddr; + addrs[index].buf_index = index; + + // Notify the client of a new frame. + if (mMsgEnabled & CAMERA_MSG_VIDEO_FRAME) { + mDataCbTimestamp(timestamp, CAMERA_MSG_VIDEO_FRAME, buffer, mCallbackCookie); + } else { + mSecCamera->releaseRecordFrame(index); + } + } + + return NO_ERROR; +} + +status_t CameraHardwareSec::startPreview() +{ + int ret = 0; //s1 [Apply factory standard] + + LOGV("%s :", __func__); + + Mutex::Autolock lock(mStateLock); + if (mCaptureInProgress) { + LOGE("%s : capture in progress, not allowed", __func__); + return INVALID_OPERATION; + } + + mPreviewLock.lock(); + if (mPreviewRunning) { + // already running + LOGE("%s : preview thread already running", __func__); + mPreviewLock.unlock(); + return INVALID_OPERATION; + } + + setSkipFrame(INITIAL_SKIP_FRAME); + + ret = mSecCamera->startPreview(); + LOGV("%s : mSecCamera->startPreview() returned %d", __func__, ret); + + if (ret < 0) { + LOGE("ERR(%s):Fail on mSecCamera->startPreview()", __func__); + return -1; //UNKNOWN_ERROR; + } + + if (mPreviewHeap != NULL) + mPreviewHeap.clear(); + + int width, height, frame_size; + + mSecCamera->getPreviewSize(&width, &height, &frame_size); + + int previewHeapSize = (frame_size + 16) * kBufferCount; + + LOGD("MemoryHeapBase(fd(%d), size(%d), width(%d), height(%d))", (int)mSecCamera->getCameraFd(), (size_t)(previewHeapSize), width, height); + mPreviewHeap = new MemoryHeapBase((int)mSecCamera->getCameraFd(), (size_t)(previewHeapSize), (uint32_t)0); + + mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize); + LOGV("CameraHardwareSec: mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d",mPostViewWidth,mPostViewHeight,mPostViewSize); + + mPreviewRunning = true; + mPreviewCondition.signal(); + mPreviewLock.unlock(); + + return NO_ERROR; +} + +#if defined(BOARD_USES_OVERLAY) +bool CameraHardwareSec::useOverlay() +{ + LOGV("%s: returning true", __func__); + return true; +} + +status_t CameraHardwareSec::setOverlay(const sp &overlay) +{ + LOGV("%s :", __func__); + + int overlayWidth = 0; + int overlayHeight = 0; + int overlayFrameSize = 0; + + if (overlay == NULL) { + LOGV("%s : overlay == NULL", __func__); + goto setOverlayFail; + } + LOGV("%s : overlay = %p", __func__, overlay->getHandleRef()); + + if (overlay->getHandleRef()== NULL && mUseOverlay == true) { + if (mOverlay != 0) + mOverlay->destroy(); + + mOverlay = NULL; + mUseOverlay = false; + + return NO_ERROR; + } + + if (overlay->getStatus() != NO_ERROR) { + LOGE("ERR(%s):overlay->getStatus() fail", __func__); + goto setOverlayFail; + } + + mSecCamera->getPreviewSize(&overlayWidth, &overlayHeight, &overlayFrameSize); + + if (overlay->setCrop(0, 0, overlayWidth, overlayHeight) != NO_ERROR) { + LOGE("ERR(%s)::(mOverlay->setCrop(0, 0, %d, %d) fail", __func__, overlayWidth, overlayHeight); + goto setOverlayFail; + } + + mOverlay = overlay; + mUseOverlay = true; + + return NO_ERROR; + +setOverlayFail : + if (mOverlay != 0) + mOverlay->destroy(); + mOverlay = 0; + + mUseOverlay = false; + + return UNKNOWN_ERROR; +} +#endif + +void CameraHardwareSec::stopPreview() +{ + LOGV("%s :", __func__); + + /* request that the preview thread stop. */ + mPreviewLock.lock(); + if (mPreviewRunning) { + mPreviewRunning = false; + mPreviewCondition.signal(); + /* wait until preview thread is stopped */ + mPreviewStoppedCondition.wait(mPreviewLock); + } else { + LOGI("%s : preview not running, doing nothing", __func__); + } + mPreviewLock.unlock(); +} + +bool CameraHardwareSec::previewEnabled() +{ + Mutex::Autolock lock(mPreviewLock); + LOGV("%s : %d", __func__, mPreviewRunning); + return mPreviewRunning; +} + +// --------------------------------------------------------------------------- + +status_t CameraHardwareSec::startRecording() +{ + LOGV("%s :", __func__); + + Mutex::Autolock lock(mRecordLock); + + if (mRecordRunning == false) { + if (mSecCamera->startRecord() < 0) { + LOGE("ERR(%s):Fail on mSecCamera->startRecord()", __func__); + return UNKNOWN_ERROR; + } + mRecordRunning = true; + } + return NO_ERROR; +} + +void CameraHardwareSec::stopRecording() +{ + LOGV("%s :", __func__); + + Mutex::Autolock lock(mRecordLock); + + if (mRecordRunning == true) { + if (mSecCamera->stopRecord() < 0) { + LOGE("ERR(%s):Fail on mSecCamera->stopRecord()", __func__); + return; + } + mRecordRunning = false; + } +} + +bool CameraHardwareSec::recordingEnabled() +{ + LOGV("%s :", __func__); + + return mRecordRunning; +} + +void CameraHardwareSec::releaseRecordingFrame(const sp& mem) +{ + ssize_t offset; + sp heap = mem->getMemory(&offset, NULL); + struct addrs *addrs = (struct addrs *)((uint8_t *)heap->base() + offset); + + mSecCamera->releaseRecordFrame(addrs->buf_index); +} + +// --------------------------------------------------------------------------- + +int CameraHardwareSec::autoFocusThread() +{ + int count =0; + int af_status =0 ; + + LOGV("%s : starting", __func__); + + /* block until we're told to start. we don't want to use + * a restartable thread and requestExitAndWait() in cancelAutoFocus() + * because it would cause deadlock between our callbacks and the + * caller of cancelAutoFocus() which both want to grab the same lock + * in CameraServices layer. + */ + mFocusLock.lock(); + /* check early exit request */ + if (mExitAutoFocusThread) { + mFocusLock.unlock(); + LOGV("%s : exiting on request0", __func__); + return NO_ERROR; + } + mFocusCondition.wait(mFocusLock); + /* check early exit request */ + if (mExitAutoFocusThread) { + mFocusLock.unlock(); + LOGV("%s : exiting on request1", __func__); + return NO_ERROR; + } + mFocusLock.unlock(); + + LOGV("%s : calling setAutoFocus", __func__); + if (mSecCamera->setAutofocus() < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setAutofocus()", __func__); + return UNKNOWN_ERROR; + } + + af_status = mSecCamera->getAutoFocusResult(); + + int i; + + i = 0; + + af_status = mSecCamera->getAutoFocusResult(); + + while(af_status == 0x05 && i < 100) + { + LOGV("%s : AF Result == 0X05 sleeping!!", __func__); + usleep(50000); + af_status = mSecCamera->getAutoFocusResult(); + i++; + } + + LOGV("%s : AF Result == %d", __func__, af_status); + + if (af_status == 0x02) { + LOGV("%s : AF Success!!", __func__); + if (mMsgEnabled & CAMERA_MSG_FOCUS) + mNotifyCb(CAMERA_MSG_FOCUS, true, 0, mCallbackCookie); + } +//FIXME: determine that the user cancled the AF +#if 0 + else if (af_status == 0x02) { + LOGV("%s : AF Cancelled !!", __func__); + if (mMsgEnabled & CAMERA_MSG_FOCUS) { + /* CAMERA_MSG_FOCUS only takes a bool. true for + * finished and false for failure. cancel is still + * considered a true result. + */ + mNotifyCb(CAMERA_MSG_FOCUS, true, 0, mCallbackCookie); + } + } +#endif + else { + LOGV("%s : AF Fail !!", __func__); + LOGV("%s : mMsgEnabled = 0x%x", __func__, mMsgEnabled); + if (mMsgEnabled & CAMERA_MSG_FOCUS) + mNotifyCb(CAMERA_MSG_FOCUS, false, 0, mCallbackCookie); + } + + LOGV("%s : exiting with no error", __func__); + return NO_ERROR; +} + +status_t CameraHardwareSec::autoFocus() +{ + LOGV("%s :", __func__); + /* signal autoFocusThread to run once */ + mFocusCondition.signal(); + return NO_ERROR; +} + +/* 2009.10.14 by icarus for added interface */ +status_t CameraHardwareSec::cancelAutoFocus() +{ + LOGV("%s :", __func__); + + if (mSecCamera->cancelAutofocus() < 0) { + LOGE("ERR(%s):Fail on mSecCamera->cancelAutofocus()", __func__); + return UNKNOWN_ERROR; + } + + return NO_ERROR; +} + +int CameraHardwareSec::save_jpeg( unsigned char *real_jpeg, int jpeg_size) +{ + FILE *yuv_fp = NULL; + char filename[100], *buffer = NULL; + + /* file create/open, note to "wb" */ + yuv_fp = fopen("/data/camera_dump.jpeg", "wb"); + if (yuv_fp == NULL) { + LOGE("Save jpeg file open error"); + return -1; + } + + LOGV("[BestIQ] real_jpeg size ========> %d\n", jpeg_size); + buffer = (char *) malloc(jpeg_size); + if (buffer == NULL) { + LOGE("Save YUV] buffer alloc failed"); + if (yuv_fp) + fclose(yuv_fp); + + return -1; + } + + memcpy(buffer, real_jpeg, jpeg_size); + + fflush(stdout); + + fwrite(buffer, 1, jpeg_size, yuv_fp); + + fflush(yuv_fp); + + if (yuv_fp) + fclose(yuv_fp); + if (buffer) + free(buffer); + + return 0; +} + +void CameraHardwareSec::save_postview(const char *fname, uint8_t *buf, uint32_t size) +{ + int nw; + int cnt = 0; + uint32_t written = 0; + + LOGD("opening file [%s]\n", fname); + int fd = open(fname, O_RDWR | O_CREAT); + if (fd < 0) { + LOGE("failed to create file [%s]: %s", fname, strerror(errno)); + return; + } + + LOGD("writing %d bytes to file [%s]\n", size, fname); + while (written < size) { + nw = ::write(fd, buf + written, size - written); + if (nw < 0) { + LOGE("failed to write to file %d [%s]: %s",written,fname, strerror(errno)); + break; + } + written += nw; + cnt++; + } + LOGD("done writing %d bytes to file [%s] in %d passes\n",size, fname, cnt); + ::close(fd); +} + +bool CameraHardwareSec::scaleDownYuv422(char *srcBuf, uint32_t srcWidth, uint32_t srcHeight, + char *dstBuf, uint32_t dstWidth, uint32_t dstHeight) +{ + int32_t step_x, step_y; + int32_t iXsrc, iXdst; + int32_t x, y, src_y_start_pos, dst_pos, src_pos; + + if (dstWidth % 2 != 0 || dstHeight % 2 != 0){ + LOGE("scale_down_yuv422: invalid width, height for scaling"); + return false; + } + + step_x = srcWidth / dstWidth; + step_y = srcHeight / dstHeight; + + dst_pos = 0; + for (uint32_t y = 0; y < dstHeight; y++) { + src_y_start_pos = (y * step_y * (srcWidth * 2)); + + for (uint32_t x = 0; x < dstWidth; x += 2) { + src_pos = src_y_start_pos + (x * (step_x * 2)); + + dstBuf[dst_pos++] = srcBuf[src_pos ]; + dstBuf[dst_pos++] = srcBuf[src_pos + 1]; + dstBuf[dst_pos++] = srcBuf[src_pos + 2]; + dstBuf[dst_pos++] = srcBuf[src_pos + 3]; + } + } + + return true; +} + +bool CameraHardwareSec::YUY2toNV21(void *srcBuf, void *dstBuf, uint32_t srcWidth, uint32_t srcHeight) +{ + int32_t x, y, src_y_start_pos, dst_cbcr_pos, dst_pos, src_pos; + unsigned char *srcBufPointer = (unsigned char *)srcBuf; + unsigned char *dstBufPointer = (unsigned char *)dstBuf; + + dst_pos = 0; + dst_cbcr_pos = srcWidth*srcHeight; + for (uint32_t y = 0; y < srcHeight; y++) { + src_y_start_pos = (y * (srcWidth * 2)); + + for (uint32_t x = 0; x < (srcWidth * 2); x += 2) { + src_pos = src_y_start_pos + x; + + dstBufPointer[dst_pos++] = srcBufPointer[src_pos]; + } + } + for (uint32_t y = 0; y < srcHeight; y += 2) { + src_y_start_pos = (y * (srcWidth * 2)); + + for (uint32_t x = 0; x < (srcWidth * 2); x += 4) { + src_pos = src_y_start_pos + x; + + dstBufPointer[dst_cbcr_pos++] = srcBufPointer[src_pos + 3]; + dstBufPointer[dst_cbcr_pos++] = srcBufPointer[src_pos + 1]; + } + } + + return true; +} + +int CameraHardwareSec::pictureThread() +{ + LOGV("%s :", __func__); + + int jpeg_size = 0; + int ret = NO_ERROR; + unsigned char *jpeg_data = NULL; + int postview_offset = 0; + unsigned char *postview_data = NULL; + + unsigned char *addr = NULL; + int mPostViewWidth, mPostViewHeight, mPostViewSize; + int mThumbWidth, mThumbHeight, mThumbSize; + int cap_width, cap_height, cap_frame_size; + + unsigned int output_size = 0; + + mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize); + mSecCamera->getThumbnailConfig(&mThumbWidth, &mThumbHeight, &mThumbSize); + int postviewHeapSize = mPostViewSize; + mSecCamera->getSnapshotSize(&cap_width, &cap_height, &cap_frame_size); + int mJpegHeapSize; + if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) + mJpegHeapSize = cap_frame_size * SecCamera::getJpegRatio(); + else + mJpegHeapSize = cap_frame_size; + + LOG_TIME_DEFINE(0) + LOG_TIME_START(0) + + sp buffer = new MemoryBase(mRawHeap, 0, mPostViewSize + 8); + + struct addrs_cap *addrs = (struct addrs_cap *)mRawHeap->base(); + + addrs[0].width = mPostViewWidth; + addrs[0].height = mPostViewHeight; + LOGV("[5B] mPostViewWidth = %d mPostViewHeight = %d\n",mPostViewWidth,mPostViewHeight); + + sp JpegHeap = new MemoryHeapBase(mJpegHeapSize); + sp PostviewHeap = new MemoryHeapBase(mPostViewSize); + sp ThumbnailHeap = new MemoryHeapBase(mThumbSize); + + if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE) { + LOG_TIME_DEFINE(1) + LOG_TIME_START(1) + + int picture_size, picture_width, picture_height; + mSecCamera->getSnapshotSize(&picture_width, &picture_height, &picture_size); + int picture_format = mSecCamera->getSnapshotPixelFormat(); + + unsigned int phyAddr; + + // Modified the shutter sound timing for Jpeg capture + if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) + mSecCamera->setSnapshotCmd(); + if (mMsgEnabled & CAMERA_MSG_SHUTTER) { + mNotifyCb(CAMERA_MSG_SHUTTER, 0, 0, mCallbackCookie); + } + + if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK){ + jpeg_data = mSecCamera->getJpeg(&jpeg_size, &phyAddr); + if (jpeg_data == NULL) { + LOGE("ERR(%s):Fail on SecCamera->getSnapshot()", __func__); + ret = UNKNOWN_ERROR; + } + } else { + if (mSecCamera->getSnapshotAndJpeg((unsigned char*)PostviewHeap->base(), + (unsigned char*)JpegHeap->base(), &output_size) < 0) { + mStateLock.lock(); + mCaptureInProgress = false; + mStateLock.unlock(); + return UNKNOWN_ERROR; + } + LOGI("snapshotandjpeg done\n"); + } + + addrs[0].addr_y = phyAddr; + + LOG_TIME_END(1) + LOG_CAMERA("getSnapshotAndJpeg interval: %lu us", LOG_TIME(1)); + } + + /* the capture is done at this point so we can allow sensor commands + * again, we still need to do jpeg and thumbnail processing, but the + * sensor is available for something else + */ + mStateLock.lock(); + mCaptureInProgress = false; + mStateLock.unlock(); + + if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE) { + mDataCb(CAMERA_MSG_RAW_IMAGE, buffer, mCallbackCookie); + } + + if (mMsgEnabled & CAMERA_MSG_COMPRESSED_IMAGE) { + + memcpy(JpegHeap->base (), jpeg_data, jpeg_size + 2); + + int JpegExifSize; + sp ExifHeap = new MemoryHeapBase(EXIF_FILE_SIZE + JPG_STREAM_BUF_SIZE); + JpegExifSize = mSecCamera->getExif((unsigned char *)ExifHeap->base(), + (unsigned char *)ThumbnailHeap->base()); + + LOGV("JpegExifSize=%d", JpegExifSize); + + if (JpegExifSize < 0) { + ret = UNKNOWN_ERROR; + goto out; + } + + unsigned char *ExifStart = (unsigned char *)JpegHeap->base() + 2; + unsigned char *ImageStart = ExifStart + JpegExifSize; + memmove(ImageStart, ExifStart, jpeg_size - 2); + memcpy(ExifStart, ExifHeap->base(), JpegExifSize); + + sp mem = new MemoryBase(JpegHeap, 0, jpeg_size + JpegExifSize); + + mDataCb(CAMERA_MSG_COMPRESSED_IMAGE, mem, mCallbackCookie); + } + + LOG_TIME_END(0) + LOG_CAMERA("pictureThread interval: %lu us", LOG_TIME(0)); +out: + LOGV("%s : pictureThread end", __func__); + return ret; +} + +status_t CameraHardwareSec::takePicture() +{ + LOGV("%s :", __func__); + + stopPreview(); + + Mutex::Autolock lock(mStateLock); + if (mCaptureInProgress) { + LOGE("%s : capture already in progress", __func__); + return INVALID_OPERATION; + } + + if (mPictureThread->run("CameraPictureThread", PRIORITY_DEFAULT) != NO_ERROR) { + LOGE("%s : couldn't run picture thread", __func__); + return INVALID_OPERATION; + } + mCaptureInProgress = true; + + return NO_ERROR; +} + +status_t CameraHardwareSec::cancelPicture() +{ + mPictureThread->requestExitAndWait(); + + return NO_ERROR; +} + +bool CameraHardwareSec::CheckVideoStartMarker(unsigned char *pBuf) +{ + if (!pBuf) { + LOGE("CheckVideoStartMarker() => pBuf is NULL\n"); + return false; + } + + if (HIBYTE(VIDEO_COMMENT_MARKER_H) == * pBuf && LOBYTE(VIDEO_COMMENT_MARKER_H) == *(pBuf + 1) && + HIBYTE(VIDEO_COMMENT_MARKER_L) == *(pBuf + 2) && LOBYTE(VIDEO_COMMENT_MARKER_L) == *(pBuf + 3)) + return true; + + return false; +} + +bool CameraHardwareSec::CheckEOIMarker(unsigned char *pBuf) +{ + if (!pBuf) { + LOGE("CheckEOIMarker() => pBuf is NULL\n"); + return false; + } + + // EOI marker [FF D9] + if (HIBYTE(JPEG_EOI_MARKER) == *pBuf && LOBYTE(JPEG_EOI_MARKER) == *(pBuf + 1)) + return true; + + return false; +} + +bool CameraHardwareSec::FindEOIMarkerInJPEG(unsigned char *pBuf, int dwBufSize, int *pnJPEGsize) +{ + if (NULL == pBuf || 0 >= dwBufSize) { + LOGE("FindEOIMarkerInJPEG() => There is no contents."); + return false; + } + + unsigned char *pBufEnd = pBuf + dwBufSize; + + while (pBuf < pBufEnd) { + if (CheckEOIMarker(pBuf++)) + return true; + + (*pnJPEGsize)++; + } + + return false; +} + +bool CameraHardwareSec::SplitFrame(unsigned char *pFrame, int dwSize, + int dwJPEGLineLength, int dwVideoLineLength, int dwVideoHeight, + void *pJPEG, int *pdwJPEGSize, + void *pVideo, int *pdwVideoSize) +{ + LOGV("===========SplitFrame Start=============="); + + if (NULL == pFrame || 0 >= dwSize) { + LOGE("There is no contents.\r\n"); + return false; + } + + if (0 == dwJPEGLineLength || 0 == dwVideoLineLength) { + LOGE("There in no input information for decoding interleaved jpeg"); + return false; + } + + unsigned char *pSrc = pFrame; + unsigned char *pSrcEnd = pFrame + dwSize; + + unsigned char *pJ = (unsigned char *)pJPEG; + int dwJSize = 0; + unsigned char *pV = (unsigned char *)pVideo; + int dwVSize = 0; + + bool bRet = false; + bool isFinishJpeg = false; + + while (pSrc < pSrcEnd) { + // Check video start marker + if (CheckVideoStartMarker(pSrc)) { + int copyLength; + + if (pSrc + dwVideoLineLength <= pSrcEnd) + copyLength = dwVideoLineLength; + else + copyLength = pSrcEnd - pSrc - VIDEO_COMMENT_MARKER_LENGTH; + + // Copy video data + if (pV) { + memcpy(pV, pSrc + VIDEO_COMMENT_MARKER_LENGTH, copyLength); + pV += copyLength; + dwVSize += copyLength; + } + + pSrc += copyLength + VIDEO_COMMENT_MARKER_LENGTH; + } else { + // Copy pure JPEG data + int size = 0; + int dwCopyBufLen = dwJPEGLineLength <= pSrcEnd-pSrc ? dwJPEGLineLength : pSrcEnd - pSrc; + + if (FindEOIMarkerInJPEG((unsigned char *)pSrc, dwCopyBufLen, &size)) { + isFinishJpeg = true; + size += 2; // to count EOF marker size + } else { + if ((dwCopyBufLen == 1) && (pJPEG < pJ)) { + unsigned char checkBuf[2] = { *(pJ - 1), *pSrc }; + + if (CheckEOIMarker(checkBuf)) + isFinishJpeg = true; + } + size = dwCopyBufLen; + } + + memcpy(pJ, pSrc, size); + + dwJSize += size; + + pJ += dwCopyBufLen; + pSrc += dwCopyBufLen; + } + if (isFinishJpeg) + break; + } + + if (isFinishJpeg) { + bRet = true; + if(pdwJPEGSize) + *pdwJPEGSize = dwJSize; + if(pdwVideoSize) + *pdwVideoSize = dwVSize; + } else { + LOGE("DecodeInterleaveJPEG_WithOutDT() => Can not find EOI"); + bRet = false; + if(pdwJPEGSize) + *pdwJPEGSize = 0; + if(pdwVideoSize) + *pdwVideoSize = 0; + } + LOGV("===========SplitFrame end=============="); + + return bRet; +} + +int CameraHardwareSec::decodeInterleaveData(unsigned char *pInterleaveData, + int interleaveDataSize, + int yuvWidth, + int yuvHeight, + int *pJpegSize, + void *pJpegData, + void *pYuvData) +{ + if (pInterleaveData == NULL) + return false; + + bool ret = true; + unsigned int *interleave_ptr = (unsigned int *)pInterleaveData; + unsigned char *jpeg_ptr = (unsigned char *)pJpegData; + unsigned char *yuv_ptr = (unsigned char *)pYuvData; + unsigned char *p; + int jpeg_size = 0; + int yuv_size = 0; + + int i = 0; + + LOGV("decodeInterleaveData Start~~~"); + while (i < interleaveDataSize) { + if ((*interleave_ptr == 0xFFFFFFFF) || (*interleave_ptr == 0x02FFFFFF) || + (*interleave_ptr == 0xFF02FFFF)) { + // Padding Data +// LOGE("%d(%x) padding data\n", i, *interleave_ptr); + interleave_ptr++; + i += 4; + } + else if ((*interleave_ptr & 0xFFFF) == 0x05FF) { + // Start-code of YUV Data +// LOGE("%d(%x) yuv data\n", i, *interleave_ptr); + p = (unsigned char *)interleave_ptr; + p += 2; + i += 2; + + // Extract YUV Data + if (pYuvData != NULL) { + memcpy(yuv_ptr, p, yuvWidth * 2); + yuv_ptr += yuvWidth * 2; + yuv_size += yuvWidth * 2; + } + p += yuvWidth * 2; + i += yuvWidth * 2; + + // Check End-code of YUV Data + if ((*p == 0xFF) && (*(p + 1) == 0x06)) { + interleave_ptr = (unsigned int *)(p + 2); + i += 2; + } else { + ret = false; + break; + } + } else { + // Extract JPEG Data +// LOGE("%d(%x) jpg data, jpeg_size = %d bytes\n", i, *interleave_ptr, jpeg_size); + if (pJpegData != NULL) { + memcpy(jpeg_ptr, interleave_ptr, 4); + jpeg_ptr += 4; + jpeg_size += 4; + } + interleave_ptr++; + i += 4; + } + } + if (ret) { + if (pJpegData != NULL) { + // Remove Padding after EOI + for (i = 0; i < 3; i++) { + if (*(--jpeg_ptr) != 0xFF) { + break; + } + jpeg_size--; + } + *pJpegSize = jpeg_size; + + } + // Check YUV Data Size + if (pYuvData != NULL) { + if (yuv_size != (yuvWidth * yuvHeight * 2)) { + ret = false; + } + } + } + LOGV("decodeInterleaveData End~~~"); + return ret; +} + +status_t CameraHardwareSec::dump(int fd, const Vector& args) const +{ + const size_t SIZE = 256; + char buffer[SIZE]; + String8 result; + + if (mSecCamera != 0) { + mSecCamera->dump(fd, args); + mParameters.dump(fd, args); + mInternalParameters.dump(fd, args); + snprintf(buffer, 255, " preview running(%s)\n", mPreviewRunning?"true": "false"); + result.append(buffer); + } else { + result.append("No camera client yet.\n"); + } + write(fd, result.string(), result.size()); + return NO_ERROR; +} + +status_t CameraHardwareSec::setParameters(const CameraParameters& params) +{ + LOGV("%s :", __func__); + + status_t ret = NO_ERROR; + + /* if someone calls us while picture thread is running, it could screw + * up the sensor quite a bit so return error. we can't wait because + * that would cause deadlock with the callbacks + */ + mStateLock.lock(); + if (mCaptureInProgress) { + mStateLock.unlock(); + LOGE("%s : capture in progress, not allowed", __func__); + return UNKNOWN_ERROR; + } + mStateLock.unlock(); + + // preview size + int new_preview_width = 0; + int new_preview_height = 0; + params.getPreviewSize(&new_preview_width, &new_preview_height); + const char *new_str_preview_format = params.getPreviewFormat(); + LOGV("%s : new_preview_width x new_preview_height = %dx%d, format = %s", + __func__, new_preview_width, new_preview_height, new_str_preview_format); + + if (0 < new_preview_width && 0 < new_preview_height && new_str_preview_format != NULL) { + int new_preview_format = 0; + + if (!strcmp(new_str_preview_format, + CameraParameters::PIXEL_FORMAT_RGB565)) + new_preview_format = V4L2_PIX_FMT_RGB565; + else if (!strcmp(new_str_preview_format, + CameraParameters::PIXEL_FORMAT_YUV420SP)) + new_preview_format = V4L2_PIX_FMT_NV21; + else if (!strcmp(new_str_preview_format, "yuv420sp_custom")) + new_preview_format = V4L2_PIX_FMT_NV12T; + else if (!strcmp(new_str_preview_format, "yuv420p")) + new_preview_format = V4L2_PIX_FMT_YUV420; + else if (!strcmp(new_str_preview_format, "yuv422i")) + new_preview_format = V4L2_PIX_FMT_YUYV; + else if (!strcmp(new_str_preview_format, "yuv422p")) + new_preview_format = V4L2_PIX_FMT_YUV422P; + else + new_preview_format = V4L2_PIX_FMT_NV21; //for 3rd party + + if (mSecCamera->setPreviewSize(new_preview_width, new_preview_height, new_preview_format) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setPreviewSize(width(%d), height(%d), format(%d))", + __func__, new_preview_width, new_preview_height, new_preview_format); + ret = UNKNOWN_ERROR; + } else { + mParameters.setPreviewSize(new_preview_width, new_preview_height); + mParameters.setPreviewFormat(new_str_preview_format); + } +#if defined(BOARD_USES_OVERLAY) + if (mUseOverlay == true && mOverlay != 0) { + if (mOverlay->setCrop(0, 0, new_preview_width, new_preview_height) != NO_ERROR) { + LOGE("ERR(%s)::(mOverlay->setCrop(0, 0, %d, %d) fail", + __func__, new_preview_width, new_preview_height); + } + } +#endif + } + + int new_picture_width = 0; + int new_picture_height = 0; + + params.getPictureSize(&new_picture_width, &new_picture_height); + LOGV("%s : new_picture_width x new_picture_height = %dx%d", __func__, new_picture_width, new_picture_height); + if (0 < new_picture_width && 0 < new_picture_height) { + if (mSecCamera->setSnapshotSize(new_picture_width, new_picture_height) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setSnapshotSize(width(%d), height(%d))", + __func__, new_picture_width, new_picture_height); + ret = UNKNOWN_ERROR; + } else { + mParameters.setPictureSize(new_picture_width, new_picture_height); + } + } + + // picture format + const char *new_str_picture_format = params.getPictureFormat(); + LOGV("%s : new_str_picture_format %s", __func__, new_str_picture_format); + if (new_str_picture_format != NULL) { + int new_picture_format = 0; + + if (!strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_RGB565)) + new_picture_format = V4L2_PIX_FMT_RGB565; + else if (!strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_YUV420SP)) + new_picture_format = V4L2_PIX_FMT_NV21; + else if (!strcmp(new_str_picture_format, "yuv420sp_custom")) + new_picture_format = V4L2_PIX_FMT_NV12T; + else if (!strcmp(new_str_picture_format, "yuv420p")) + new_picture_format = V4L2_PIX_FMT_YUV420; + else if (!strcmp(new_str_picture_format, "yuv422i")) + new_picture_format = V4L2_PIX_FMT_YUYV; + else if (!strcmp(new_str_picture_format, "uyv422i_custom")) //Zero copy UYVY format + new_picture_format = V4L2_PIX_FMT_UYVY; + else if (!strcmp(new_str_picture_format, "uyv422i")) //Non-zero copy UYVY format + new_picture_format = V4L2_PIX_FMT_UYVY; + else if (!strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_JPEG)) + new_picture_format = V4L2_PIX_FMT_YUYV; + else if (!strcmp(new_str_picture_format, "yuv422p")) + new_picture_format = V4L2_PIX_FMT_YUV422P; + else + new_picture_format = V4L2_PIX_FMT_NV21; //for 3rd party + + if (mSecCamera->setSnapshotPixelFormat(new_picture_format) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setSnapshotPixelFormat(format(%d))", __func__, new_picture_format); + ret = UNKNOWN_ERROR; + } else { + mParameters.setPictureFormat(new_str_picture_format); + } + } + + //JPEG image quality + int new_jpeg_quality = params.getInt(CameraParameters::KEY_JPEG_QUALITY); + LOGV("%s : new_jpeg_quality %d", __func__, new_jpeg_quality); + /* we ignore bad values */ + if (new_jpeg_quality >=1 && new_jpeg_quality <= 100) { + if (mSecCamera->setJpegQuality(new_jpeg_quality) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setJpegQuality(quality(%d))", __func__, new_jpeg_quality); + ret = UNKNOWN_ERROR; + } else { + mParameters.set(CameraParameters::KEY_JPEG_QUALITY, new_jpeg_quality); + } + } + + // JPEG thumbnail size + int new_jpeg_thumbnail_width = params.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH); + int new_jpeg_thumbnail_height= params.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT); + if (0 <= new_jpeg_thumbnail_width && 0 <= new_jpeg_thumbnail_height) { + if (mSecCamera->setJpegThumbnailSize(new_jpeg_thumbnail_width, new_jpeg_thumbnail_height) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setJpegThumbnailSize(width(%d), height(%d))", __func__, new_jpeg_thumbnail_width, new_jpeg_thumbnail_height); + ret = UNKNOWN_ERROR; + } else { + mParameters.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, new_jpeg_thumbnail_width); + mParameters.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, new_jpeg_thumbnail_height); + } + } + + // frame rate + int new_frame_rate = params.getPreviewFrameRate(); + /* ignore any fps request, we're determine fps automatically based + * on scene mode. don't return an error because it causes CTS failure. + */ + if (new_frame_rate != mParameters.getPreviewFrameRate()) { + LOGW("WARN(%s): request for preview frame %d not allowed, != %d\n", + __func__, new_frame_rate, mParameters.getPreviewFrameRate()); + } + + // rotation + int new_rotation = params.getInt(CameraParameters::KEY_ROTATION); + LOGV("%s : new_rotation %d", __func__, new_rotation); + if (0 <= new_rotation) { + LOGV("%s : set orientation:%d\n", __func__, new_rotation); + if (mSecCamera->setExifOrientationInfo(new_rotation) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setExifOrientationInfo(%d)", __func__, new_rotation); + ret = UNKNOWN_ERROR; + } else { + mParameters.set(CameraParameters::KEY_ROTATION, new_rotation); + } + } + + // brightness + int new_exposure_compensation = params.getInt(CameraParameters::KEY_EXPOSURE_COMPENSATION); + int max_exposure_compensation = params.getInt(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION); + int min_exposure_compensation = params.getInt(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION); + LOGV("%s : new_exposure_compensation %d", __func__, new_exposure_compensation); + if ((min_exposure_compensation <= new_exposure_compensation) && + (max_exposure_compensation >= new_exposure_compensation)) { + if (mSecCamera->setBrightness(new_exposure_compensation) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setBrightness(brightness(%d))", __func__, new_exposure_compensation); + ret = UNKNOWN_ERROR; + } else { + mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, new_exposure_compensation); + } + } + + // whitebalance + const char *new_white_str = params.get(CameraParameters::KEY_WHITE_BALANCE); + LOGV("%s : new_white_str %s", __func__, new_white_str); + if (new_white_str != NULL) { + int new_white = -1; + + if (!strcmp(new_white_str, CameraParameters::WHITE_BALANCE_AUTO)) + new_white = WHITE_BALANCE_AUTO; + else if (!strcmp(new_white_str, + CameraParameters::WHITE_BALANCE_DAYLIGHT)) + new_white = WHITE_BALANCE_SUNNY; + else if (!strcmp(new_white_str, + CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT)) + new_white = WHITE_BALANCE_CLOUDY; + else if (!strcmp(new_white_str, + CameraParameters::WHITE_BALANCE_FLUORESCENT)) + new_white = WHITE_BALANCE_FLUORESCENT; + else if (!strcmp(new_white_str, + CameraParameters::WHITE_BALANCE_INCANDESCENT)) + new_white = WHITE_BALANCE_TUNGSTEN; + else { + LOGE("ERR(%s):Invalid white balance(%s)", __func__, new_white_str); //twilight, shade, warm_flourescent + ret = UNKNOWN_ERROR; + } + + if (0 <= new_white) { + if (mSecCamera->setWhiteBalance(new_white) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setWhiteBalance(white(%d))", __func__, new_white); + ret = UNKNOWN_ERROR; + } else { + mParameters.set(CameraParameters::KEY_WHITE_BALANCE, new_white_str); + } + } + } + + // scene mode + const char *new_scene_mode_str = params.get(CameraParameters::KEY_SCENE_MODE); + const char *current_scene_mode_str = mParameters.get(CameraParameters::KEY_SCENE_MODE); + + // fps range + int new_min_fps = 0; + int new_max_fps = 0; + int current_min_fps, current_max_fps; + params.getPreviewFpsRange(&new_min_fps, &new_max_fps); + mParameters.getPreviewFpsRange(¤t_min_fps, ¤t_max_fps); + /* our fps range is determined by the sensor, reject any request + * that isn't exactly what we're already at. + * but the check is performed when requesting only changing fps range + */ + if (new_scene_mode_str && current_scene_mode_str) { + if (!strcmp(new_scene_mode_str, current_scene_mode_str)) { + if ((new_min_fps != current_min_fps) || (new_max_fps != current_max_fps)) { + LOGW("%s : requested new_min_fps = %d, new_max_fps = %d not allowed", + __func__, new_min_fps, new_max_fps); + LOGE("%s : current_min_fps = %d, current_max_fps = %d", + __func__, current_min_fps, current_max_fps); + ret = UNKNOWN_ERROR; + } + } + } else { + /* Check basic validation if scene mode is different */ + if ((new_min_fps > new_max_fps) || + (new_min_fps < 0) || (new_max_fps < 0)) + ret = UNKNOWN_ERROR; + } + + if (new_scene_mode_str != NULL) { + int new_scene_mode = -1; + + const char *new_flash_mode_str = params.get(CameraParameters::KEY_FLASH_MODE); + const char *new_focus_mode_str; + + new_focus_mode_str = params.get(CameraParameters::KEY_FOCUS_MODE); + // fps range is (15000,30000) by default. + mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, "(15000,30000)"); + mParameters.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, + "15000,30000"); + + if (!strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_AUTO)) { + new_scene_mode = SCENE_MODE_NONE; + } else { + // defaults for non-auto scene modes + if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) { + new_focus_mode_str = CameraParameters::FOCUS_MODE_AUTO; + } + new_flash_mode_str = CameraParameters::FLASH_MODE_OFF; + + if (!strcmp(new_scene_mode_str, + CameraParameters::SCENE_MODE_PORTRAIT)) { + new_scene_mode = SCENE_MODE_PORTRAIT; + new_flash_mode_str = CameraParameters::FLASH_MODE_AUTO; + } else if (!strcmp(new_scene_mode_str, + CameraParameters::SCENE_MODE_LANDSCAPE)) { + new_scene_mode = SCENE_MODE_LANDSCAPE; + } else if (!strcmp(new_scene_mode_str, + CameraParameters::SCENE_MODE_SPORTS)) { + new_scene_mode = SCENE_MODE_SPORTS; + } else if (!strcmp(new_scene_mode_str, + CameraParameters::SCENE_MODE_PARTY)) { + new_scene_mode = SCENE_MODE_PARTY_INDOOR; + new_flash_mode_str = CameraParameters::FLASH_MODE_AUTO; + } else if ((!strcmp(new_scene_mode_str, + CameraParameters::SCENE_MODE_BEACH)) || + (!strcmp(new_scene_mode_str, + CameraParameters::SCENE_MODE_SNOW))) { + new_scene_mode = SCENE_MODE_BEACH_SNOW; + } else if (!strcmp(new_scene_mode_str, + CameraParameters::SCENE_MODE_SUNSET)) { + new_scene_mode = SCENE_MODE_SUNSET; + } else if (!strcmp(new_scene_mode_str, + CameraParameters::SCENE_MODE_NIGHT)) { + new_scene_mode = SCENE_MODE_NIGHTSHOT; + mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, "(4000,30000)"); + mParameters.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, + "4000,30000"); + } else if (!strcmp(new_scene_mode_str, + CameraParameters::SCENE_MODE_FIREWORKS)) { + new_scene_mode = SCENE_MODE_FIREWORKS; + } else if (!strcmp(new_scene_mode_str, + CameraParameters::SCENE_MODE_CANDLELIGHT)) { + new_scene_mode = SCENE_MODE_CANDLE_LIGHT; + } else { + LOGE("%s::unmatched scene_mode(%s)", + __func__, new_scene_mode_str); //action, night-portrait, theatre, steadyphoto + ret = UNKNOWN_ERROR; + } + } + + // focus mode + if (new_focus_mode_str != NULL) { + int new_focus_mode = -1; + + if (!strcmp(new_focus_mode_str, + CameraParameters::FOCUS_MODE_AUTO)) { + new_focus_mode = FOCUS_MODE_AUTO; + mParameters.set(CameraParameters::KEY_FOCUS_DISTANCES, + BACK_CAMERA_AUTO_FOCUS_DISTANCES_STR); + } + else if (!strcmp(new_focus_mode_str, + CameraParameters::FOCUS_MODE_MACRO)) { + new_focus_mode = FOCUS_MODE_MACRO; + mParameters.set(CameraParameters::KEY_FOCUS_DISTANCES, + BACK_CAMERA_MACRO_FOCUS_DISTANCES_STR); + } + else if (!strcmp(new_focus_mode_str, + CameraParameters::FOCUS_MODE_INFINITY)) { + new_focus_mode = FOCUS_MODE_INFINITY; + mParameters.set(CameraParameters::KEY_FOCUS_DISTANCES, + BACK_CAMERA_INFINITY_FOCUS_DISTANCES_STR); + } + else { + LOGE("%s::unmatched focus_mode(%s)", __func__, new_focus_mode_str); + ret = UNKNOWN_ERROR; + } + + if (0 <= new_focus_mode) { + if (mSecCamera->setFocusMode(new_focus_mode) < 0) { + LOGE("%s::mSecCamera->setFocusMode(%d) fail", __func__, new_focus_mode); + ret = UNKNOWN_ERROR; + } else { + mParameters.set(CameraParameters::KEY_FOCUS_MODE, new_focus_mode_str); + } + } + } + + // flash.. + if (new_flash_mode_str != NULL) { + int new_flash_mode = -1; + + if (!strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_OFF)) + new_flash_mode = FLASH_MODE_OFF; + else if (!strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_AUTO)) + new_flash_mode = FLASH_MODE_AUTO; + else if (!strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_ON)) + new_flash_mode = FLASH_MODE_ON; + else if (!strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_TORCH)) + new_flash_mode = FLASH_MODE_TORCH; + else { + LOGE("%s::unmatched flash_mode(%s)", __func__, new_flash_mode_str); //red-eye + ret = UNKNOWN_ERROR; + } + if (0 <= new_flash_mode) { + if (mSecCamera->setFlashMode(new_flash_mode) < 0) { + LOGE("%s::mSecCamera->setFlashMode(%d) fail", __func__, new_flash_mode); + ret = UNKNOWN_ERROR; + } else { + mParameters.set(CameraParameters::KEY_FLASH_MODE, new_flash_mode_str); + } + } + } + + // scene.. + if (0 <= new_scene_mode) { + if (mSecCamera->setSceneMode(new_scene_mode) < 0) { + LOGE("%s::mSecCamera->setSceneMode(%d) fail", __func__, new_scene_mode); + ret = UNKNOWN_ERROR; + } else { + mParameters.set(CameraParameters::KEY_SCENE_MODE, new_scene_mode_str); + } + } + } + + // --------------------------------------------------------------------------- + + // image effect + const char *new_image_effect_str = params.get(CameraParameters::KEY_EFFECT); + if (new_image_effect_str != NULL) { + + int new_image_effect = -1; + + if (!strcmp(new_image_effect_str, CameraParameters::EFFECT_NONE)) + new_image_effect = IMAGE_EFFECT_NONE; + else if (!strcmp(new_image_effect_str, CameraParameters::EFFECT_MONO)) + new_image_effect = IMAGE_EFFECT_BNW; + else if (!strcmp(new_image_effect_str, CameraParameters::EFFECT_SEPIA)) + new_image_effect = IMAGE_EFFECT_SEPIA; + else if (!strcmp(new_image_effect_str, CameraParameters::EFFECT_AQUA)) + new_image_effect = IMAGE_EFFECT_AQUA; + else if (!strcmp(new_image_effect_str, CameraParameters::EFFECT_NEGATIVE)) + new_image_effect = IMAGE_EFFECT_NEGATIVE; + else { + //posterize, whiteboard, blackboard, solarize + LOGE("ERR(%s):Invalid effect(%s)", __func__, new_image_effect_str); + ret = UNKNOWN_ERROR; + } + + if (new_image_effect >= 0) { + if (mSecCamera->setImageEffect(new_image_effect) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setImageEffect(effect(%d))", __func__, new_image_effect); + ret = UNKNOWN_ERROR; + } else { + const char *old_image_effect_str = mParameters.get(CameraParameters::KEY_EFFECT); + + if (old_image_effect_str) { + if (strcmp(old_image_effect_str, new_image_effect_str)) { + setSkipFrame(EFFECT_SKIP_FRAME); + } + } + + mParameters.set(CameraParameters::KEY_EFFECT, new_image_effect_str); + } + } + } + + //vt mode + int new_vtmode = mInternalParameters.getInt("vtmode"); + if (0 <= new_vtmode) { + if (mSecCamera->setVTmode(new_vtmode) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setVTMode(%d)", __func__, new_vtmode); + ret = UNKNOWN_ERROR; + } + } + + //contrast + int new_contrast = mInternalParameters.getInt("contrast"); + + if (0 <= new_contrast) { + if (mSecCamera->setContrast(new_contrast) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setContrast(%d)", __func__, new_contrast); + ret = UNKNOWN_ERROR; + } + } + + //WDR + int new_wdr = mInternalParameters.getInt("wdr"); + + if (0 <= new_wdr) { + if (mSecCamera->setWDR(new_wdr) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setWDR(%d)", __func__, new_wdr); + ret = UNKNOWN_ERROR; + } + } + + //anti shake + int new_anti_shake = mInternalParameters.getInt("anti-shake"); + + if (0 <= new_anti_shake) { + if (mSecCamera->setAntiShake(new_anti_shake) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setWDR(%d)", __func__, new_anti_shake); + ret = UNKNOWN_ERROR; + } + } + + // gps latitude + const char *new_gps_latitude_str = params.get(CameraParameters::KEY_GPS_LATITUDE); + if (mSecCamera->setGPSLatitude(new_gps_latitude_str) < 0) { + LOGE("%s::mSecCamera->setGPSLatitude(%s) fail", __func__, new_gps_latitude_str); + ret = UNKNOWN_ERROR; + } else { + if (new_gps_latitude_str) { + mParameters.set(CameraParameters::KEY_GPS_LATITUDE, new_gps_latitude_str); + } else { + mParameters.remove(CameraParameters::KEY_GPS_LATITUDE); + } + } + + // gps longitude + const char *new_gps_longitude_str = params.get(CameraParameters::KEY_GPS_LONGITUDE); + + if (mSecCamera->setGPSLongitude(new_gps_longitude_str) < 0) { + LOGE("%s::mSecCamera->setGPSLongitude(%s) fail", __func__, new_gps_longitude_str); + ret = UNKNOWN_ERROR; + } else { + if (new_gps_longitude_str) { + mParameters.set(CameraParameters::KEY_GPS_LONGITUDE, new_gps_longitude_str); + } else { + mParameters.remove(CameraParameters::KEY_GPS_LONGITUDE); + } + } + + // gps altitude + const char *new_gps_altitude_str = params.get(CameraParameters::KEY_GPS_ALTITUDE); + + if (mSecCamera->setGPSAltitude(new_gps_altitude_str) < 0) { + LOGE("%s::mSecCamera->setGPSAltitude(%s) fail", __func__, new_gps_altitude_str); + ret = UNKNOWN_ERROR; + } else { + if (new_gps_altitude_str) { + mParameters.set(CameraParameters::KEY_GPS_ALTITUDE, new_gps_altitude_str); + } else { + mParameters.remove(CameraParameters::KEY_GPS_ALTITUDE); + } + } + + // gps timestamp + const char *new_gps_timestamp_str = params.get(CameraParameters::KEY_GPS_TIMESTAMP); + + if (mSecCamera->setGPSTimeStamp(new_gps_timestamp_str) < 0) { + LOGE("%s::mSecCamera->setGPSTimeStamp(%s) fail", __func__, new_gps_timestamp_str); + ret = UNKNOWN_ERROR; + } else { + if (new_gps_timestamp_str) { + mParameters.set(CameraParameters::KEY_GPS_TIMESTAMP, new_gps_timestamp_str); + } else { + mParameters.remove(CameraParameters::KEY_GPS_TIMESTAMP); + } + } + + // gps processing method + const char *new_gps_processing_method_str = params.get(CameraParameters::KEY_GPS_PROCESSING_METHOD); + + if (mSecCamera->setGPSProcessingMethod(new_gps_processing_method_str) < 0) { + LOGE("%s::mSecCamera->setGPSProcessingMethod(%s) fail", __func__, new_gps_processing_method_str); + ret = UNKNOWN_ERROR; + } else { + if (new_gps_processing_method_str) { + mParameters.set(CameraParameters::KEY_GPS_PROCESSING_METHOD, new_gps_processing_method_str); + } else { + mParameters.remove(CameraParameters::KEY_GPS_PROCESSING_METHOD); + } + } + + // Recording size + int new_recording_width = mInternalParameters.getInt("recording-size-width"); + int new_recording_height= mInternalParameters.getInt("recording-size-height"); + + if (0 < new_recording_width && 0 < new_recording_height) { + if (mSecCamera->setRecordingSize(new_recording_width, new_recording_height) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setRecordingSize(width(%d), height(%d))", __func__, new_recording_width, new_recording_height); + ret = UNKNOWN_ERROR; + } + } else { + if (mSecCamera->setRecordingSize(new_preview_width, new_preview_height) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setRecordingSize(width(%d), height(%d))", __func__, new_preview_width, new_preview_height); + ret = UNKNOWN_ERROR; + } + } + + //gamma + const char *new_gamma_str = mInternalParameters.get("video_recording_gamma"); + + if (new_gamma_str != NULL) { + int new_gamma = -1; + if (!strcmp(new_gamma_str, "off")) + new_gamma = GAMMA_OFF; + else if (!strcmp(new_gamma_str, "on")) + new_gamma = GAMMA_ON; + else { + LOGE("%s::unmatched gamma(%s)", __func__, new_gamma_str); + ret = UNKNOWN_ERROR; + } + + if (0 <= new_gamma) { + if (mSecCamera->setGamma(new_gamma) < 0) { + LOGE("%s::mSecCamera->setGamma(%d) fail", __func__, new_gamma); + ret = UNKNOWN_ERROR; + } + } + } + + //slow ae + const char *new_slow_ae_str = mInternalParameters.get("slow_ae"); + + if (new_slow_ae_str != NULL) { + int new_slow_ae = -1; + + if (!strcmp(new_slow_ae_str, "off")) + new_slow_ae = SLOW_AE_OFF; + else if (!strcmp(new_slow_ae_str, "on")) + new_slow_ae = SLOW_AE_ON; + else { + LOGE("%s::unmatched slow_ae(%s)", __func__, new_slow_ae_str); + ret = UNKNOWN_ERROR; + } + + if (0 <= new_slow_ae) { + if (mSecCamera->setSlowAE(new_slow_ae) < 0) { + LOGE("%s::mSecCamera->setSlowAE(%d) fail", __func__, new_slow_ae); + ret = UNKNOWN_ERROR; + } + } + } + + /*Camcorder fix fps*/ + int new_sensor_mode = mInternalParameters.getInt("cam_mode"); + + if (0 <= new_sensor_mode) { + if (mSecCamera->setSensorMode(new_sensor_mode) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setSensorMode(%d)", __func__, new_sensor_mode); + ret = UNKNOWN_ERROR; + } + } else { + new_sensor_mode=0; + } + + /*Shot mode*/ + int new_shot_mode = mInternalParameters.getInt("shot_mode"); + + if (0 <= new_shot_mode) { + if (mSecCamera->setShotMode(new_shot_mode) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setShotMode(%d)", __func__, new_shot_mode); + ret = UNKNOWN_ERROR; + } + } else { + new_shot_mode=0; + } + + //blur for Video call + int new_blur_level = mInternalParameters.getInt("blur"); + + if (0 <= new_blur_level) { + if (mSecCamera->setBlur(new_blur_level) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setBlur(%d)", __func__, new_blur_level); + ret = UNKNOWN_ERROR; + } + } + + + // chk_dataline + int new_dataline = mInternalParameters.getInt("chk_dataline"); + + if (0 <= new_dataline) { + if (mSecCamera->setDataLineCheck(new_dataline) < 0) { + LOGE("ERR(%s):Fail on mSecCamera->setDataLineCheck(%d)", __func__, new_dataline); + ret = UNKNOWN_ERROR; + } + } + LOGV("%s return ret = %d", __func__, ret); + + if (mSecCamera->stopPreview() < 0) { + LOGE("ERR(%s):Fail on mSecCamera->stopPreview", __func__); + ret = UNKNOWN_ERROR; + } + + //sleep a bit to give the cam a chance to get ready + usleep(100000); + if (mSecCamera->startPreview() < 0) { + LOGE("ERR(%s):Fail on mSecCamera->startPreview", __func__); + ret = UNKNOWN_ERROR; + } + + return ret; +} + +CameraParameters CameraHardwareSec::getParameters() const +{ + LOGV("%s :", __func__); + return mParameters; +} + +status_t CameraHardwareSec::sendCommand(int32_t command, int32_t arg1, int32_t arg2) +{ + return BAD_VALUE; +} + +void CameraHardwareSec::release() +{ + LOGV("%s :", __func__); + + /* shut down any threads we have that might be running. do it here + * instead of the destructor. we're guaranteed to be on another thread + * than the ones below. if we used the destructor, since the threads + * have a reference to this object, we could wind up trying to wait + * for ourself to exit, which is a deadlock. + */ + if (mPreviewThread != NULL) { + /* this thread is normally already in it's threadLoop but blocked + * on the condition variable or running. signal it so it wakes + * up and can exit. + */ + mPreviewThread->requestExit(); + mExitPreviewThread = true; + mPreviewRunning = true; /* let it run so it can exit */ + mPreviewCondition.signal(); + mPreviewThread->requestExitAndWait(); + mPreviewThread.clear(); + } + if (mAutoFocusThread != NULL) { + /* this thread is normally already in it's threadLoop but blocked + * on the condition variable. signal it so it wakes up and can exit. + */ + mFocusLock.lock(); + mAutoFocusThread->requestExit(); + mExitAutoFocusThread = true; + mFocusCondition.signal(); + mFocusLock.unlock(); + mAutoFocusThread->requestExitAndWait(); + mAutoFocusThread.clear(); + } + if (mPictureThread != NULL) { + mPictureThread->requestExitAndWait(); + mPictureThread.clear(); + } + if (mRawHeap != NULL) + mRawHeap.clear(); + + if (mJpegHeap != NULL) + mJpegHeap.clear(); + + if (mPreviewHeap != NULL) { + LOGI("%s: calling mPreviewHeap.dispose()", __func__); + mPreviewHeap->dispose(); + mPreviewHeap.clear(); + } + + if (mRecordHeap != NULL) + mRecordHeap.clear(); + +#if defined(BOARD_USES_OVERLAY) + if (mUseOverlay) { + mOverlay->destroy(); + mUseOverlay = false; + mOverlay = NULL; + } +#endif + + /* close after all the heaps are cleared since those + * could have dup'd our file descriptor. + */ + mSecCamera->DeinitCamera(); + mSecCamera = NULL; + +} + +wp CameraHardwareSec::singleton; + +sp CameraHardwareSec::createInstance(int cameraId) +{ + LOGV("%s :", __func__); + if (singleton != 0) { + sp hardware = singleton.promote(); + if (hardware != 0) { + return hardware; + } + } + sp hardware(new CameraHardwareSec(cameraId)); + singleton = hardware; + return hardware; +} + +static CameraInfo sCameraInfo[] = { + { + CAMERA_FACING_BACK, + 90, /* orientation */ + }, +#ifdef FFC_PRESENT + { + CAMERA_FACING_FRONT, + 0, /* orientation */ + } +#endif +}; + +extern "C" int HAL_getNumberOfCameras() +{ + return sizeof(sCameraInfo) / sizeof(sCameraInfo[0]); +} + +extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo *cameraInfo) +{ + memcpy(cameraInfo, &sCameraInfo[cameraId], sizeof(CameraInfo)); +} + +extern "C" sp HAL_openCameraHardware(int cameraId) +{ + return CameraHardwareSec::createInstance(cameraId); +} + +}; // namespace android diff --git a/libcamera/SecCameraHWInterface.h b/libcamera/SecCameraHWInterface.h new file mode 100644 index 0000000..75526c6 --- /dev/null +++ b/libcamera/SecCameraHWInterface.h @@ -0,0 +1,212 @@ +/* +** +** Copyright 2008, The Android Open Source Project +** Copyright 2010, Samsung Electronics Co. LTD +** +** 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_SEC_H +#define ANDROID_HARDWARE_CAMERA_HARDWARE_SEC_H + +#include "SecCamera.h" +#include +#include +#include +#include +#include + +namespace android { +class CameraHardwareSec : public CameraHardwareInterface { +public: + virtual sp getPreviewHeap() const; + virtual sp getRawHeap() const; + + virtual void setCallbacks(notify_callback notify_cb, + data_callback data_cb, + data_callback_timestamp data_cb_timestamp, + void *user); + + virtual void enableMsgType(int32_t msgType); + virtual void disableMsgType(int32_t msgType); + virtual bool msgTypeEnabled(int32_t msgType); + + virtual status_t startPreview(); +#if defined(BOARD_USES_OVERLAY) + virtual bool useOverlay(); + virtual status_t setOverlay(const sp &overlay); +#endif + virtual void stopPreview(); + virtual bool previewEnabled(); + + virtual status_t startRecording(); + virtual void stopRecording(); + virtual bool recordingEnabled(); + virtual void releaseRecordingFrame(const sp &mem); + + virtual status_t autoFocus(); + virtual status_t cancelAutoFocus(); + virtual status_t takePicture(); + virtual status_t cancelPicture(); + virtual status_t dump(int fd, const Vector &args) const; + virtual status_t setParameters(const CameraParameters& params); + virtual CameraParameters getParameters() const; + virtual status_t sendCommand(int32_t command, int32_t arg1, + int32_t arg2); + virtual void release(); + + static sp createInstance(int cameraId); + +private: + CameraHardwareSec(int cameraId); + virtual ~CameraHardwareSec(); + + static wp singleton; + + static const int kBufferCount = MAX_BUFFERS; + static const int kBufferCountForRecord = MAX_BUFFERS; + + class PreviewThread : public Thread { + CameraHardwareSec *mHardware; + public: + PreviewThread(CameraHardwareSec *hw): + Thread(false), + mHardware(hw) { } + virtual void onFirstRef() { + run("CameraPreviewThread", PRIORITY_URGENT_DISPLAY); + } + virtual bool threadLoop() { + mHardware->previewThreadWrapper(); + return false; + } + }; + + class PictureThread : public Thread { + CameraHardwareSec *mHardware; + public: + PictureThread(CameraHardwareSec *hw): + Thread(false), + mHardware(hw) { } + virtual bool threadLoop() { + mHardware->pictureThread(); + mHardware->mSecCamera->endSnapshot(); + return false; + } + }; + + class AutoFocusThread : public Thread { + CameraHardwareSec *mHardware; + public: + AutoFocusThread(CameraHardwareSec *hw): Thread(false), mHardware(hw) { } + virtual void onFirstRef() { + run("CameraAutoFocusThread", PRIORITY_DEFAULT); + } + virtual bool threadLoop() { + mHardware->autoFocusThread(); + return true; + } + }; + + void initDefaultParameters(int cameraId); + void initHeapLocked(); + + sp mPreviewThread; + int previewThread(); + int previewThreadWrapper(); + + sp mAutoFocusThread; + int autoFocusThread(); + + sp mPictureThread; + int pictureThread(); + bool mCaptureInProgress; + + int save_jpeg(unsigned char *real_jpeg, int jpeg_size); + void save_postview(const char *fname, uint8_t *buf, + uint32_t size); + int decodeInterleaveData(unsigned char *pInterleaveData, + int interleaveDataSize, + int yuvWidth, + int yuvHeight, + int *pJpegSize, + void *pJpegData, + void *pYuvData); + bool YUY2toNV21(void *srcBuf, void *dstBuf, uint32_t srcWidth, uint32_t srcHeight); + bool scaleDownYuv422(char *srcBuf, uint32_t srcWidth, + uint32_t srcHight, char *dstBuf, + uint32_t dstWidth, uint32_t dstHight); + + bool CheckVideoStartMarker(unsigned char *pBuf); + bool CheckEOIMarker(unsigned char *pBuf); + bool FindEOIMarkerInJPEG(unsigned char *pBuf, + int dwBufSize, int *pnJPEGsize); + bool SplitFrame(unsigned char *pFrame, int dwSize, + int dwJPEGLineLength, int dwVideoLineLength, + int dwVideoHeight, void *pJPEG, + int *pdwJPEGSize, void *pVideo, + int *pdwVideoSize); + void setSkipFrame(int frame); + /* used by auto focus thread to block until it's told to run */ + mutable Mutex mFocusLock; + mutable Condition mFocusCondition; + bool mExitAutoFocusThread; + + /* used by preview thread to block until it's told to run */ + mutable Mutex mPreviewLock; + mutable Condition mPreviewCondition; + mutable Condition mPreviewStoppedCondition; + bool mPreviewRunning; + bool mExitPreviewThread; + + /* used to guard threading state */ + mutable Mutex mStateLock; + + CameraParameters mParameters; + CameraParameters mInternalParameters; + + sp mPreviewHeap; + sp mRawHeap; + sp mRecordHeap; + sp mJpegHeap; + sp mBuffers[kBufferCount]; + sp mRecordBuffers[kBufferCountForRecord]; + + SecCamera *mSecCamera; + const __u8 *mCameraSensorName; + + mutable Mutex mSkipFrameLock; + int mSkipFrame; + +#if defined(BOARD_USES_OVERLAY) + sp mOverlay; + bool mUseOverlay; + int mOverlayBufferIdx; +#endif + + notify_callback mNotifyCb; + data_callback mDataCb; + data_callback_timestamp mDataCbTimestamp; + void *mCallbackCookie; + + int32_t mMsgEnabled; + + bool mRecordRunning; + mutable Mutex mRecordLock; + int mPostViewWidth; + int mPostViewHeight; + int mPostViewSize; +}; + +}; // namespace android + +#endif diff --git a/liblight/Android.mk b/liblight/Android.mk new file mode 100644 index 0000000..9933c34 --- /dev/null +++ b/liblight/Android.mk @@ -0,0 +1,32 @@ +# Copyright (C) 2008 The Android Open Source Project +# +# 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 implemenation, not prelinked and stored in +# hw/..so +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := lights.c + +LOCAL_PRELINK_MODULE := false +LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw + +LOCAL_SHARED_LIBRARIES := liblog + +LOCAL_MODULE := lights.aries + +LOCAL_MODULE_TAGS := optional + +include $(BUILD_SHARED_LIBRARY) + diff --git a/liblight/NOTICE b/liblight/NOTICE new file mode 100644 index 0000000..f921593 --- /dev/null +++ b/liblight/NOTICE @@ -0,0 +1,190 @@ + + Copyright (C) 2008 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + 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. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/liblight/lights.c b/liblight/lights.c new file mode 100644 index 0000000..118fa66 --- /dev/null +++ b/liblight/lights.c @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2011 + * + * 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. + */ + +#define LOG_TAG "lights" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static pthread_once_t g_init = PTHREAD_ONCE_INIT; +static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; + +char const *const LCD_FILE = "/sys/class/backlight/s5p_bl/brightness"; +char const *const LED_FILE = "/sys/class/misc/notification/led"; + +static int write_int(char const *path, int value) +{ + int fd; + static int already_warned; + + already_warned = 0; + + LOGV("write_int: path %s, value %d", path, value); + fd = open(path, O_RDWR); + + if (fd >= 0) { + char buffer[20]; + int bytes = sprintf(buffer, "%d\n", value); + int amt = write(fd, buffer, bytes); + close(fd); + return amt == -1 ? -errno : 0; + } else { + if (already_warned == 0) { + LOGE("write_int failed to open %s\n", path); + already_warned = 1; + } + return -errno; + } +} + +static int rgb_to_brightness(struct light_state_t const *state) +{ + int color = state->color & 0x00ffffff; + + return ((77*((color>>16) & 0x00ff)) + + (150*((color>>8) & 0x00ff)) + (29*(color & 0x00ff))) >> 8; +} + +static int set_light_notifications(struct light_device_t* dev, + struct light_state_t const* state) +{ + int brightness = rgb_to_brightness(state); + int v = 0; + int ret = 0; + pthread_mutex_lock(&g_lock); + + if (brightness+state->color == 0 || brightness > 100) { + if (state->color & 0x00ffffff) + v = 1; + } else + v = 0; + + LOGI("color %u fm %u status %u is lit %u brightness", state->color, state->flashMode, v, (state->color & 0x00ffffff), brightness); + ret = write_int(LED_FILE, v); + pthread_mutex_unlock(&g_lock); + return ret; +} + +static int set_light_backlight(struct light_device_t *dev, + struct light_state_t const *state) +{ + int err = 0; + int brightness = rgb_to_brightness(state); + + pthread_mutex_lock(&g_lock); + err = write_int(LCD_FILE, brightness); + + pthread_mutex_unlock(&g_lock); + return err; +} + +static int close_lights(struct light_device_t *dev) +{ + LOGV("close_light is called"); + if (dev) + free(dev); + + return 0; +} + +static int open_lights(const struct hw_module_t *module, char const *name, + struct hw_device_t **device) +{ + int (*set_light)(struct light_device_t *dev, + struct light_state_t const *state); + + LOGV("open_lights: open with %s", name); + + if (0 == strcmp(LIGHT_ID_BACKLIGHT, name)) + set_light = set_light_backlight; + else if (0 == strcmp(LIGHT_ID_NOTIFICATIONS, name)) + set_light = set_light_notifications; + else + return -EINVAL; + + pthread_mutex_init(&g_lock, NULL); + + struct light_device_t *dev = malloc(sizeof(struct light_device_t)); + memset(dev, 0, sizeof(*dev)); + + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.version = 0; + dev->common.module = (struct hw_module_t *)module; + dev->common.close = (int (*)(struct hw_device_t *))close_lights; + dev->set_light = set_light; + + *device = (struct hw_device_t *)dev; + + return 0; +} + +static struct hw_module_methods_t lights_module_methods = { + .open = open_lights, +}; + +const struct hw_module_t HAL_MODULE_INFO_SYM = { + .tag = HARDWARE_MODULE_TAG, + .version_major = 1, + .version_minor = 0, + .id = LIGHTS_HARDWARE_MODULE_ID, + .name = "lights Module", + .author = "Google, Inc.", + .methods = &lights_module_methods, +}; diff --git a/liboverlay/Android.mk b/liboverlay/Android.mk new file mode 100644 index 0000000..c4de48c --- /dev/null +++ b/liboverlay/Android.mk @@ -0,0 +1,35 @@ +# Copyright (C) 2008 The Android Open Source Project +# +# 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 implemenation, not prelinked and stored in +# hw/..so + +include $(CLEAR_VARS) +LOCAL_PRELINK_MODULE := false +LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw +LOCAL_SHARED_LIBRARIES := liblog libcutils + +ifdef BOARD_V4L2_DEVICE + LOCAL_CFLAGS += -DV4L2_DEVICE=\"$(BOARD_V4L2_DEVICE)\" +endif + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/../include + +LOCAL_SRC_FILES := v4l2_utils.c overlay.cpp + +LOCAL_MODULE := overlay.aries +LOCAL_MODULE_TAGS := optional +include $(BUILD_SHARED_LIBRARY) diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp new file mode 100644 index 0000000..d0a4289 --- /dev/null +++ b/liboverlay/overlay.cpp @@ -0,0 +1,1490 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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. + */ + +/*#define LOG_NDEBUG 0*/ +#define LOG_TAG "SEC_Overlay" + +#include +#include + +extern "C" { +#include "v4l2_utils.h" +} + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "linux/fb.h" + +/*****************************************************************************/ + +#define LOG_FUNCTION_NAME LOGV(" %s %s", __FILE__, __func__) + +#define NUM_OVERLAY_BUFFERS_REQUESTED (3) +/* OVRLYSHM on phone keypad*/ +#define SHARED_DATA_MARKER (0x68759746) + +/* These values should come from Surface Flinger */ +unsigned int g_lcd_width = 480; +unsigned int g_lcd_height = 800; +unsigned int g_lcd_bpp = 32; + +#define CACHEABLE_BUFFERS 0x1 + +/* shared with Camera/Video Playback HAL */ +#define ALL_BUFFERS_FLUSHED -66 + +uint32_t phyAddr; +s5p_fimc_t g_s5p_fimc; + +typedef struct +{ + uint32_t posX; + uint32_t posY; + uint32_t posW; + uint32_t posH; + uint32_t rotation; + uint32_t flip; + + uint32_t posX_org; + uint32_t posY_org; + uint32_t posW_org; + uint32_t posH_org; + +} overlay_ctrl_t; + +typedef struct +{ + uint32_t cropX; + uint32_t cropY; + uint32_t cropW; + uint32_t cropH; +} overlay_data_t; + +typedef struct +{ + uint32_t marker; + uint32_t size; + + volatile int32_t refCnt; + + uint32_t controlReady; /* Only updated by the control side */ + uint32_t dataReady; /* Only updated by the data side */ + + pthread_mutex_t lock; + pthread_mutexattr_t attr; + + uint32_t streamEn; + uint32_t streamingReset; + + uint32_t dispW; + uint32_t dispH; + +} overlay_shared_t; + +/* Only one instance is created per platform */ +struct overlay_control_context_t { + struct overlay_control_device_t device; + /* our private state goes below here */ + struct overlay_t* overlay_video1; + struct overlay_t* overlay_video2; +}; + +/* A separate instance is created per overlay data side user*/ +struct overlay_data_context_t { + struct overlay_data_device_t device; + /* our private state goes below here */ + int ctl_fd; + int shared_fd; + int shared_size; + int width; + int height; + int format; + int num_buffers; + size_t *buffers_len; + void **buffers; + + overlay_data_t data; + overlay_shared_t *shared; + struct mapping_data *mapping_data; + /* Need to count Qd buffers + to be sure we don't block DQ'ing when exiting */ + int qd_buf_count; + int cacheable_buffers; + + bool zerocopy; +}; + +static int create_shared_data(overlay_shared_t **shared); +static void destroy_shared_data(int shared_fd, overlay_shared_t *shared, + bool closefd); +static int open_shared_data(overlay_data_context_t *ctx); +static void close_shared_data(overlay_data_context_t *ctx); +enum { LOCK_REQUIRED = 1, NO_LOCK_NEEDED = 0 }; +static int enable_streaming(overlay_shared_t *shared, int ovly_fd, + int lock_required ); + +static int overlay_device_open(const struct hw_module_t* module, + const char* name, struct hw_device_t** device); + +static int check_fimc_dst_constraints(s5p_fimc_t *s5p_fimc, + unsigned int rotation); +static int check_fimc_src_constraints(s5p_fimc_t *s5p_fimc); + +static struct hw_module_methods_t overlay_module_methods = { +open: overlay_device_open +}; + +struct overlay_module_t HAL_MODULE_INFO_SYM = { +common: { +tag: HARDWARE_MODULE_TAG, + version_major: 1, + version_minor: 0, + id: OVERLAY_HARDWARE_MODULE_ID, + name: "SEC Overlay module", + author: "The Android Open Source Project", + methods: &overlay_module_methods, + } +}; + +/*****************************************************************************/ + +/* + * This is the overlay_t object, it is returned to the user and represents + * an overlay. here we use a subclass, where we can store our own state. + * This handles will be passed across processes and possibly given to other + * HAL modules (for instance video decode modules). + */ +struct handle_t : public native_handle { + /* add the data fields we need here, for instance: */ + int ctl_fd; + int shared_fd; + int width; + int height; + int format; + int num_buffers; + int shared_size; +}; + +static int handle_format(const overlay_handle_t overlay) { + return static_cast(overlay)->format; +} + +static int handle_ctl_fd(const overlay_handle_t overlay) { + return static_cast(overlay)->ctl_fd; +} + +static int handle_shared_fd(const overlay_handle_t overlay) { + return static_cast(overlay)->shared_fd; +} + +static int handle_num_buffers(const overlay_handle_t overlay) { + return static_cast(overlay)->num_buffers; +} + +static int handle_width(const overlay_handle_t overlay) { + return static_cast(overlay)->width; +} + +static int handle_height(const overlay_handle_t overlay) { + return static_cast(overlay)->height; +} + +static int handle_shared_size(const overlay_handle_t overlay) { + return static_cast(overlay)->shared_size; +} + +/* A separate instance of this class is created per overlay */ +class overlay_object : public overlay_t +{ + handle_t mHandle; + + overlay_ctrl_t mCtl; + overlay_ctrl_t mCtlStage; + overlay_shared_t *mShared; + + static overlay_handle_t getHandleRef(struct overlay_t* overlay) { + /* returns a reference to the handle, caller doesn't take ownership */ + return &(static_cast(overlay)->mHandle); + } + + public: + overlay_object(int ctl_fd, int shared_fd, int shared_size, int w, int h, + int format, int num_buffers) { + this->overlay_t::getHandleRef = getHandleRef; + mHandle.version = sizeof(native_handle); + mHandle.numFds = 2; + mHandle.numInts = 5; /* extra ints we have in our handle */ + mHandle.ctl_fd = ctl_fd; + mHandle.shared_fd = shared_fd; + mHandle.width = w; + mHandle.height = h; + mHandle.format = format; + mHandle.num_buffers = num_buffers; + mHandle.shared_size = shared_size; + this->w = w; + this->h = h; + this->format = format; + + memset( &mCtl, 0, sizeof( mCtl ) ); + memset( &mCtlStage, 0, sizeof( mCtlStage ) ); + } + + int ctl_fd() { return mHandle.ctl_fd; } + int shared_fd() { return mHandle.shared_fd; } + overlay_ctrl_t* data() { return &mCtl; } + overlay_ctrl_t* staging() { return &mCtlStage; } + overlay_shared_t* getShared() { return mShared; } + void setShared( overlay_shared_t *p ) { mShared = p; } +}; + +/***************************************************************************** + * Local Functions + *****************************************************************************/ + +static int create_shared_data(overlay_shared_t **shared) +{ + int fd; + /* assuming sizeof(overlay_shared_t) < a single page */ + int size = getpagesize(); + overlay_shared_t *p; + + if ((fd = ashmem_create_region("overlay_data", size)) < 0) { + LOGE("Failed to Create Overlay Shared Data!\n"); + return fd; + } + + p = (overlay_shared_t*)mmap(NULL, size, PROT_READ | PROT_WRITE, + MAP_SHARED, fd, 0); + if (p == MAP_FAILED) { + LOGE("Failed to Map Overlay Shared Data!\n"); + close(fd); + return -1; + } + + memset(p, 0, size); + p->marker = SHARED_DATA_MARKER; + p->size = size; + p->refCnt = 1; + if (pthread_mutexattr_init(&p->attr) != 0) { + LOGE("Failed to initialize overlay mutex attr"); + goto MutexAttrErr; + } + if (pthread_mutexattr_setpshared(&p->attr, PTHREAD_PROCESS_SHARED) != 0) { + LOGE("Failed to set the overlay mutex attr to be shared across-processes"); + goto MutexAttrSetErr; + } + if (pthread_mutex_init(&p->lock, &p->attr) != 0) { + LOGE("Failed to initialize overlay mutex\n"); + goto MutexErr; + } + + *shared = p; + return fd; + +MutexErr: +MutexAttrSetErr: + pthread_mutexattr_destroy(&p->attr); +MutexAttrErr: + munmap(p, size); + close(fd); + return -1; +} + +static void destroy_shared_data(int shared_fd, overlay_shared_t *shared, + bool closefd ) +{ + if (shared == NULL) + return; + + /* Last side deallocated releases the mutex, otherwise the remaining */ + /* side will deadlock trying to use an already released mutex */ + if (android_atomic_dec(&shared->refCnt) == 1) { + if (pthread_mutex_destroy(&shared->lock)) { + LOGE("Failed to uninitialize overlay mutex!\n"); + } + + if (pthread_mutexattr_destroy(&shared->attr)) { + LOGE("Failed to uninitialize the overlay mutex attr!\n"); + } + shared->marker = 0; + } + + if (munmap(shared, shared->size)) { + LOGE("Failed to Unmap Overlay Shared Data!\n"); + } + + if (closefd && close(shared_fd)) { + LOGE("Failed to Close Overlay Shared Data!\n"); + } +} + +static int open_shared_data( overlay_data_context_t *ctx ) +{ + int rc = -1; + int mode = PROT_READ | PROT_WRITE; + int fd = ctx->shared_fd; + int size = ctx->shared_size; + + if (ctx->shared != NULL) { + /* Already open, return success */ + LOGI("Overlay Shared Data Already Open\n"); + return 0; + } + ctx->shared = (overlay_shared_t*)mmap(0, size, mode, MAP_SHARED, fd, 0); + + if (ctx->shared == MAP_FAILED) { + LOGE("Failed to Map Overlay Shared Data!\n"); + } else if ( ctx->shared->marker != SHARED_DATA_MARKER ) { + LOGE("Invalid Overlay Shared Marker!\n"); + munmap( ctx->shared, size); + } else if ( (int)ctx->shared->size != size ) { + LOGE("Invalid Overlay Shared Size!\n"); + munmap(ctx->shared, size); + } else { + android_atomic_inc(&ctx->shared->refCnt); + rc = 0; + } + + return rc; +} + +static void close_shared_data(overlay_data_context_t *ctx) +{ + destroy_shared_data(ctx->shared_fd, ctx->shared, false); + ctx->shared = NULL; +} + +static int enable_streaming_locked(overlay_shared_t *shared, int ovly_fd) +{ + int rc = 0; + + if (!shared->controlReady || !shared->dataReady) { + LOGI("Postponing Stream Enable/%d/%d\n", shared->controlReady, + shared->dataReady); + } else { + shared->streamEn = 1; + rc = v4l2_overlay_stream_on(ovly_fd); + if (rc) { + LOGE("Stream Enable Failed!/%d\n", rc); + shared->streamEn = 0; + } + } + + return rc; +} + +static int enable_streaming(overlay_shared_t *shared, int ovly_fd) +{ + int ret; + + pthread_mutex_lock(&shared->lock); + ret = enable_streaming_locked(shared, ovly_fd); + pthread_mutex_unlock(&shared->lock); + return ret; +} + +static int disable_streaming_locked(overlay_shared_t *shared, int ovly_fd) +{ + int ret = 0; + + if (shared->streamEn) { + ret = v4l2_overlay_stream_off( ovly_fd ); + if (ret) { + LOGE("Stream Off Failed!/%d\n", ret); + } else { + shared->streamingReset = 1; + shared->streamEn = 0; + } + } + + return ret; +} + +static void set_color_space(unsigned int overlay_color_format, unsigned int *v4l2_color_format) +{ + switch (overlay_color_format) { + case OVERLAY_FORMAT_RGB_565: + *v4l2_color_format = V4L2_PIX_FMT_RGB565; + break; + + case OVERLAY_FORMAT_YCbYCr_422_I: + case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I: + *v4l2_color_format = V4L2_PIX_FMT_YUYV; + break; + + case OVERLAY_FORMAT_CbYCrY_422_I: + case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I: + *v4l2_color_format = V4L2_PIX_FMT_UYVY; + break; + + case HAL_PIXEL_FORMAT_YCbCr_420_P: + *v4l2_color_format = V4L2_PIX_FMT_YUV420; + break; + + case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP: + *v4l2_color_format = V4L2_PIX_FMT_NV12T; + break; + + case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP: + *v4l2_color_format = V4L2_PIX_FMT_NV21; + break; + + default : + LOGE("unsupported pixel format (0x%x)", overlay_color_format); + *v4l2_color_format = -1; + } +} + +/**************************************************************************** + * Control module + *****************************************************************************/ + +static int overlay_get(struct overlay_control_device_t *dev, int name) +{ + int result = -1; + + switch (name) { + /* 0 = no limit */ + case OVERLAY_MINIFICATION_LIMIT: result = 0; break; + /* 0 = no limit */ + case OVERLAY_MAGNIFICATION_LIMIT: result = 0; break; + /* 0 = infinite */ + case OVERLAY_SCALING_FRAC_BITS: result = 0; break; + /* 90 rotation steps (for instance) */ + case OVERLAY_ROTATION_STEP_DEG: result = 90; break; + /* 1-pixel alignment */ + case OVERLAY_HORIZONTAL_ALIGNMENT: result = 1; break; + /* 1-pixel alignment */ + case OVERLAY_VERTICAL_ALIGNMENT: result = 1; break; + /* 1-pixel alignment */ + case OVERLAY_WIDTH_ALIGNMENT: result = 1; break; + case OVERLAY_HEIGHT_ALIGNMENT: break; + } + + return result; +} + +static int get_fb_var_screeninfo( struct fb_var_screeninfo *info ) +{ + int fd = -1; + int i=0; + char name[64]; + int ret = 0; + + char const * const device_template[] = { + "/dev/graphics/fb%u", + "/dev/fb%u", + 0 }; + + while ((fd==-1) && device_template[i]) { + snprintf(name, 64, device_template[i], 0); + fd = open(name, O_RDWR, 0); + i++; + } + + if (fd < 0) + ret = -EINVAL; + + if (ioctl(fd, FBIOGET_VSCREENINFO, info) == -1) + ret = -EINVAL; + + if (fd > 0) + close(fd); + + return 0; +} +static overlay_t* overlay_createOverlay(struct overlay_control_device_t *dev, + uint32_t w, uint32_t h, int32_t format) +{ + LOGD("overlay_createOverlay:IN w=%d h=%d format=%d\n", w, h, format); + LOG_FUNCTION_NAME; + + overlay_object *overlay; + overlay_control_context_t *ctx = (overlay_control_context_t *)dev; + overlay_shared_t *shared; + + int ret; + uint32_t num = NUM_OVERLAY_BUFFERS_REQUESTED; + int fd; + int shared_fd; + struct fb_var_screeninfo info; + bool zerocopy = false; + + phyAddr = 0; + + if (format == OVERLAY_FORMAT_DEFAULT) { + LOGD("format == OVERLAY_FORMAT_DEFAULT\n"); + LOGD("set to HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP\n"); + format = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP; + } + + if (ctx->overlay_video1) { + LOGE("Error - overlays already in use\n"); + return NULL; + } + + shared_fd = create_shared_data(&shared); + if (shared_fd < 0) { + LOGE("Failed to create shared data"); + return NULL; + } + + fd = v4l2_overlay_open(V4L2_OVERLAY_PLANE_VIDEO1); + if (fd < 0) { + LOGE("Failed to open overlay device : %s\n", strerror(errno)); + goto error; + } + + g_s5p_fimc.params.src.full_width = w; + g_s5p_fimc.params.src.full_height = h; + g_s5p_fimc.params.src.width = w; + g_s5p_fimc.params.src.height = h; + set_color_space(format, &g_s5p_fimc.params.src.color_space); + ret = check_fimc_src_constraints(&g_s5p_fimc); + if(ret != 0) { + if(ret < 0) { + LOGE("Not supported source image size"); + goto error1; + } else { + LOGD("src width, height are changed [w= %d, h= %d]->[w=%d, h= %d]" + , w, h, g_s5p_fimc.params.src.width + , g_s5p_fimc.params.src.height); + w = g_s5p_fimc.params.src.width; + h = g_s5p_fimc.params.src.height; + } + } + + if (v4l2_overlay_init(fd, w, h, format, phyAddr)) { + LOGE("Failed initializing overlays\n"); + goto error1; + } + + if (v4l2_overlay_set_crop(fd, 0, 0, w, h)) { + LOGE("Failed defaulting crop window\n"); + goto error1; + } + + if (v4l2_overlay_set_flip(fd, 0)) { + LOGE("Failed defaulting flip\n"); + goto error1; + } + + if (v4l2_overlay_set_rotation(fd, 0, 0)) { + LOGE("Failed defaulting rotation\n"); + goto error1; + } + + if (format >= HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP + && format < HAL_PIXEL_FORMAT_CUSTOM_MAX) + zerocopy = true; + + if (v4l2_overlay_req_buf(fd, &num, 0, (int)zerocopy)) { + LOGE("Failed requesting buffers\n"); + goto error1; + } + + v4l2_overlay_init_fimc(fd, &g_s5p_fimc); + + overlay = new overlay_object(fd, shared_fd, shared->size, + w, h, format, num); + if (overlay == NULL) { + LOGE("Failed to create overlay object\n"); + goto error1; + } + ctx->overlay_video1 = overlay; + + overlay->setShared(shared); + + shared->controlReady = 0; + shared->streamEn = 0; + shared->streamingReset = 0; + + /* get lcd size from kernel framebuffer */ + if(get_fb_var_screeninfo(&info) == 0) { + shared->dispW = info.xres; + shared->dispH = info.yres; + g_lcd_width = info.xres; + g_lcd_height = info.yres; + g_lcd_bpp = info.bits_per_pixel; + } else { + shared->dispW = g_lcd_width; /* Need to determine this properly */ + shared->dispH = g_lcd_height; /* Need to determine this properly */ + } + + LOGI("Opened video1/fd=%d/obj=%08lx/shm=%d/size=%d", fd, + (unsigned long)overlay, shared_fd, shared->size); + + return overlay; + +error1: + close(fd); +error: + destroy_shared_data(shared_fd, shared, true); + return NULL; +} + +static void overlay_destroyOverlay(struct overlay_control_device_t *dev, + overlay_t* overlay) +{ + LOGD("overlay_destroyOverlay:IN dev (%p) and overlay (%p)", dev, overlay); + LOG_FUNCTION_NAME; + + overlay_control_context_t *ctx = (overlay_control_context_t *)dev; + overlay_object *obj = static_cast(overlay); + + int rc; + int fd = obj->ctl_fd(); + uint32_t num = 0; + + overlay_shared_t *shared = obj->getShared(); + + if (shared == NULL) { + LOGE("Overlay was already destroyed - nothing needs to be done\n"); + return; + } + + pthread_mutex_lock(&shared->lock); + + disable_streaming_locked(shared, fd); + + pthread_mutex_unlock(&shared->lock); + + destroy_shared_data(obj->shared_fd(), shared, true); + obj->setShared(NULL); + + if (v4l2_overlay_req_buf(fd, &num, 0, 0)) { + LOGE("Failed requesting buffers\n"); + } + + LOGI("Destroying overlay/fd=%d/obj=%08lx", fd, (unsigned long)overlay); + + if (close(fd)) { + LOGE( "Error closing overly fd/%d\n", errno); + } + + if (overlay) { + if (ctx->overlay_video1 == overlay) + ctx->overlay_video1 = NULL; + delete overlay; + overlay = NULL; + } + LOGD("overlay_destroyOverlay:OUT"); +} + +static int overlay_setPosition(struct overlay_control_device_t *dev, + overlay_t* overlay, int x, int y, uint32_t w, + uint32_t h) +{ + LOG_FUNCTION_NAME; + + overlay_object *obj = static_cast(overlay); + + overlay_ctrl_t *stage = obj->staging(); + overlay_shared_t *shared = obj->getShared(); + + int rc = 0; + int temp_x = x, temp_y = y, temp_w = w, temp_h = h; + + /* + * This logic here is to return an error if the rectangle is not fully + * within the display, unless we have not received a valid position yet, + * in which case we will do our best to adjust the rectangle to be within + * the display. + */ + + /* Require a minimum size */ + if (temp_w < 16) + temp_w = 16; + if (temp_h < 8) + temp_h = 8; + + if (!shared->controlReady) { + if ( temp_x < 0 ) temp_x = 0; + if ( temp_y < 0 ) temp_y = 0; + if ( temp_w > shared->dispW ) temp_w = shared->dispW; + if ( temp_h > shared->dispH ) temp_h = shared->dispH; + if ( (temp_x + temp_w) > shared->dispW ) temp_w = shared->dispW - temp_x; + if ( (temp_y + temp_h) > shared->dispH ) temp_h = shared->dispH - temp_y; + } else if (temp_x < 0 || temp_y < 0 || (temp_x + temp_w) > shared->dispW || + (temp_y + temp_h) > shared->dispH) { + /* Return an error */ + rc = -1; + } + + if (rc == 0) { + stage->posX = temp_x; + stage->posY = temp_y; + stage->posW = temp_w; + stage->posH = temp_h; + + stage->posX_org = x; + stage->posY_org = y; + stage->posW_org = w; + stage->posH_org = h; + } + + return rc; +} + +static int overlay_getPosition(struct overlay_control_device_t *dev, + overlay_t* overlay, int* x, int* y, uint32_t* w, + uint32_t* h) +{ + LOG_FUNCTION_NAME; + + overlay_object *obj = static_cast(overlay); + overlay_ctrl_t *stage = obj->staging(); + + *x = stage->posX_org; + *y = stage->posY_org; + *w = stage->posW_org; + *h = stage->posH_org; + + return 0; +} + +static int overlay_setParameter(struct overlay_control_device_t *dev, + overlay_t* overlay, int param, int value) +{ + LOG_FUNCTION_NAME; + + overlay_ctrl_t *stage = static_cast(overlay)->staging(); + int rc = 0; + + switch (param) { + case OVERLAY_DITHER: + break; + + case OVERLAY_TRANSFORM: + switch ( value ) + { + case 0: + stage->rotation = 0; + stage->flip = 0; + break; + case OVERLAY_TRANSFORM_ROT_90: + stage->rotation = 90; + stage->flip = 0; + break; + case OVERLAY_TRANSFORM_ROT_180: + stage->rotation = 180; + stage->flip = 0; + break; + case OVERLAY_TRANSFORM_ROT_270: + stage->rotation = 270; + stage->flip = 0; + break; + // FIMC VFLIP = android overlay FLIP_H. + case OVERLAY_TRANSFORM_FLIP_H: + stage->rotation = 0; + stage->flip = V4L2_CID_VFLIP; + break; + case OVERLAY_TRANSFORM_FLIP_V: + stage->rotation = 0; + stage->flip = V4L2_CID_HFLIP; + break; + // FIMC rotates first but android flips first. + case OVERLAY_TRANSFORM_ROT_90+OVERLAY_TRANSFORM_FLIP_H: + stage->rotation = 90; + stage->flip = V4L2_CID_HFLIP; + break; + case OVERLAY_TRANSFORM_ROT_90+OVERLAY_TRANSFORM_FLIP_V: + stage->rotation = 90; + stage->flip = V4L2_CID_VFLIP; + break; + + default: + rc = -EINVAL; + break; + } + break; + } + + return rc; +} + +static int overlay_stage(struct overlay_control_device_t *dev, + overlay_t* overlay) { + return 0; +} + +static int overlay_commit(struct overlay_control_device_t *dev, + overlay_t* overlay) { + LOG_FUNCTION_NAME; + + overlay_object *obj = static_cast(overlay); + + overlay_ctrl_t *data = obj->data(); + overlay_ctrl_t *stage = obj->staging(); + overlay_shared_t *shared = obj->getShared(); + + int ret = 0; + int fd = obj->ctl_fd(); + + if (shared == NULL) { + LOGI("Shared Data Not Init'd!\n"); + return -1; + } + + pthread_mutex_lock(&shared->lock); + + if (!shared->controlReady) { + shared->controlReady = 1; + } + + g_s5p_fimc.params.dst.full_width = g_lcd_width; + g_s5p_fimc.params.dst.full_height = g_lcd_height; + g_s5p_fimc.params.dst.width = stage->posW; + g_s5p_fimc.params.dst.height = stage->posH; + if (g_lcd_bpp == 32) + g_s5p_fimc.params.dst.color_space = V4L2_PIX_FMT_RGB32; + else + g_s5p_fimc.params.dst.color_space = V4L2_PIX_FMT_RGB565; + ret = check_fimc_dst_constraints(&g_s5p_fimc, stage->rotation); + if (ret != 0) { + if (ret < 0) { + LOGE("Unsupported destination image size"); + goto end; + } else { + LOGD("dst width, height have changed [w= %d, h= %d] -> [w=%d, h= %d]", + stage->posW, stage->posH, g_s5p_fimc.params.dst.width, + g_s5p_fimc.params.dst.height); + stage->posW = g_s5p_fimc.params.dst.width; + stage->posH = g_s5p_fimc.params.dst.height; + } + } + + if (data->posX == stage->posX && data->posY == stage->posY && + data->posW == stage->posW && data->posH == stage->posH && + data->rotation == stage->rotation && + data->flip == stage->flip) { + LOGI("Nothing to do!\n"); + goto end; + } + + LOGD("Position/X%d/Y%d/W%d/H%d\n", data->posX, data->posY, data->posW, + data->posH); + LOGD("Adjusted Position/X%d/Y%d/W%d/H%d\n", stage->posX, stage->posY, + stage->posW, stage->posH); + LOGD("Rotation/%d\n", stage->rotation ); + + if ((ret = disable_streaming_locked(shared, fd))) + goto end; + + if (stage->flip != data->flip) { + ret = v4l2_overlay_set_flip(fd, stage->flip); + if (ret) { + LOGE("Set Flip Failed!/%d\n", ret); + goto end; + } + } + + if (stage->rotation != data->rotation) { + ret = v4l2_overlay_set_rotation(fd, stage->rotation, 0); + if (ret) { + LOGE("Set Rotation Failed!/%d\n", ret); + goto end; + } + v4l2_overlay_s_fbuf(fd, stage->rotation); + } + + ret = v4l2_overlay_set_position(fd, stage->posX, stage->posY, + stage->posW, stage->posH, stage->rotation); + if (ret) { + LOGE("Set Position Failed!/%d\n", ret); + goto end; + } + + data->posX = stage->posX; + data->posY = stage->posY; + data->posW = stage->posW; + data->posH = stage->posH; + data->rotation = stage->rotation; + data->flip = stage->flip; + + ret = enable_streaming_locked(shared, fd); + +end: + pthread_mutex_unlock(&shared->lock); + + return ret; +} + +static int overlay_control_close(struct hw_device_t *dev) +{ + LOG_FUNCTION_NAME; + + struct overlay_control_context_t* ctx = + (struct overlay_control_context_t*)dev; + overlay_object *overlay_v1; + + if (ctx) { + overlay_v1 = static_cast(ctx->overlay_video1); + + overlay_destroyOverlay((struct overlay_control_device_t *)ctx, + overlay_v1); + + free(ctx); + } + return 0; +} + +static int get_pixel_format_type(unsigned int pixelformat) +{ + switch(pixelformat) { + case V4L2_PIX_FMT_RGB32: + case V4L2_PIX_FMT_RGB565: + return PFT_RGB; + + case V4L2_PIX_FMT_NV12: + case V4L2_PIX_FMT_NV12T: + case V4L2_PIX_FMT_NV21: + case V4L2_PIX_FMT_YUV420: + return PFT_YUV420; + + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_YVYU: + case V4L2_PIX_FMT_VYUY: + case V4L2_PIX_FMT_NV16: + case V4L2_PIX_FMT_NV61: + case V4L2_PIX_FMT_YUV422P: + return PFT_YUV422; + + default: + return PFT_YUV444; + } +} + +/* check the constraints of destination image size */ +static int check_fimc_dst_constraints(s5p_fimc_t *s5p_fimc, + unsigned int rotation) +{ + int tmp = 0; + + if((s5p_fimc->params.dst.height > 0) && (s5p_fimc->params.dst.height < 16)) + s5p_fimc->params.dst.height = 16; + + if(s5p_fimc->params.dst.width%8 != 0) { + tmp = s5p_fimc->params.dst.width - (s5p_fimc->params.dst.width%8); + if(tmp <= 0) + return -1; + else + s5p_fimc->params.dst.width = tmp; + } + + return 1; +} +/* check the constraints of source image size */ +static int check_fimc_src_constraints(s5p_fimc_t *s5p_fimc) +{ + int format_type = 0; + + if(s5p_fimc->params.src.full_width < 16 || + s5p_fimc->params.src.full_height < 8 ) + return -1; + + if(s5p_fimc->hw_ver == 0x50) { + format_type = get_pixel_format_type(s5p_fimc->params.src.color_space); + switch (format_type) { + case PFT_YUV420: + if (s5p_fimc->params.src.height%2 != 0) + s5p_fimc->params.src.height = s5p_fimc->params.src.height + - (s5p_fimc->params.src.height)%2; + + if (s5p_fimc->params.src.width%2 != 0) + s5p_fimc->params.src.width = s5p_fimc->params.src.width + - (s5p_fimc->params.src.width)%2; + break; + + case PFT_YUV422: + if (s5p_fimc->params.src.width%2 != 0) + s5p_fimc->params.src.width = s5p_fimc->params.src.width + - (s5p_fimc->params.src.width)%2; + } + } else { + if (s5p_fimc->params.src.height < 8) { + s5p_fimc->params.src.height = 8; + } + + if (s5p_fimc->params.src.width%16 != 0) { + s5p_fimc->params.src.width = s5p_fimc->params.src.width + - (s5p_fimc->params.src.width)%16; + } + } + + return 1; +} + +/**************************************************************************** + * Data module + *****************************************************************************/ + +int overlay_initialize(struct overlay_data_device_t *dev, + overlay_handle_t handle) +{ + LOG_FUNCTION_NAME; + + struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; + struct stat stat; + + int i; + int rc = -1; + + ctx->num_buffers = handle_num_buffers(handle); + ctx->width = handle_width(handle); + ctx->height = handle_height(handle); + ctx->format = handle_format(handle); + ctx->ctl_fd = handle_ctl_fd(handle); + ctx->shared_fd = handle_shared_fd(handle); + ctx->shared_size = handle_shared_size(handle); + ctx->shared = NULL; + ctx->qd_buf_count = 0; + ctx->cacheable_buffers = 0; + + if (ctx->format >= HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP + && ctx->format < HAL_PIXEL_FORMAT_CUSTOM_MAX) + ctx->zerocopy = true; + else + ctx->zerocopy = false; + + if (fstat(ctx->ctl_fd, &stat)) { + LOGE("Error = %s from %s\n", strerror(errno), "overlay initialize"); + return -1; + } + + if (open_shared_data(ctx)) { + return -1; + } + + ctx->shared->dataReady = 0; + + ctx->mapping_data = new struct mapping_data; + ctx->buffers = new void* [ctx->num_buffers]; + ctx->buffers_len = new size_t[ctx->num_buffers]; + + if (!ctx->buffers || !ctx->buffers_len || !ctx->mapping_data) { + LOGE("Failed alloc'ing buffer arrays\n"); + goto error; + } else { + + /* + * in the zero copy case, + * don't need to mmap buffer for source + */ + if (ctx->zerocopy) + rc = 0; + else { + for (i = 0; i < ctx->num_buffers; i++) { + rc = v4l2_overlay_map_buf(ctx->ctl_fd, i, &ctx->buffers[i], + &ctx->buffers_len[i]); + if (rc) { + LOGE("Failed mapping buffers\n"); + goto error; + } + } + } + } + + v4l2_overlay_init_fimc(ctx->ctl_fd, &g_s5p_fimc); + + return ( rc ); + +error: + + if(ctx->mapping_data) + delete (ctx->mapping_data); + if(ctx->buffers) + delete [] ctx->buffers; + if(ctx->buffers_len) + delete [] ctx->buffers_len; + + close_shared_data( ctx ); + + return -1; +} + +static int overlay_resizeInput(struct overlay_data_device_t *dev, uint32_t w, + uint32_t h) +{ + int rc = -1; + int ret = 0; + + struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; + + if ((ctx->width == (int)w) && (ctx->width == (int)h)) { + LOGV("same as current width and height. so do nothing"); + return 0; + } + + if (!ctx->shared) { + LOGI("Shared Data Not Init'd!\n"); + return -1; + } + + if (ctx->shared->dataReady) { + LOGV("Either setCrop() or queueBuffer() was called prior to this!" + "Therefore failing this call.\n"); + return -1; + } + + pthread_mutex_lock(&ctx->shared->lock); + + if ((rc = disable_streaming_locked(ctx->shared, ctx->ctl_fd))) + goto end; + + if (!ctx->zerocopy) { + for (int i = 0; i < ctx->num_buffers; i++) { + v4l2_overlay_unmap_buf(ctx->buffers[i], ctx->buffers_len[i]); + } + } + + g_s5p_fimc.params.src.full_width = w; + g_s5p_fimc.params.src.full_height = h; + g_s5p_fimc.params.src.width = w; + g_s5p_fimc.params.src.height = h; + set_color_space(ctx->format, &g_s5p_fimc.params.src.color_space); + ret = check_fimc_src_constraints(&g_s5p_fimc); + + if(ret != 0) { + if(ret < 0) { + LOGE("Not supported source image size"); + goto end; + } else { + LOGD("src width, height are changed [w= %d, h= %d] -> [w=%d, h= %d]" + , w, h, g_s5p_fimc.params.src.width + , g_s5p_fimc.params.src.height); + w = g_s5p_fimc.params.src.width; + h = g_s5p_fimc.params.src.height; + } + } + + rc = v4l2_overlay_init(ctx->ctl_fd, w, h, ctx->format, phyAddr); + if (rc) { + LOGE("Error initializing overlay"); + goto end; + } + rc = v4l2_overlay_set_crop(ctx->ctl_fd, 0, 0, w, h); + if (rc) { + LOGE("Error setting crop window\n"); + goto end; + } + rc = v4l2_overlay_req_buf(ctx->ctl_fd, (uint32_t *)(&ctx->num_buffers), + ctx->cacheable_buffers, (int)ctx->zerocopy); + if (rc) { + LOGE("Error creating buffers"); + goto end; + } + + if (!ctx->zerocopy) { + for (int i = 0; i < ctx->num_buffers; i++) + v4l2_overlay_map_buf(ctx->ctl_fd, i, &ctx->buffers[i], + &ctx->buffers_len[i]); + } + + rc = enable_streaming_locked(ctx->shared, ctx->ctl_fd); + +end: + pthread_mutex_unlock(&ctx->shared->lock); + + return rc; +} + + +static int overlay_data_setParameter(struct overlay_data_device_t *dev, + int param, int value) +{ + int ret = 0; + struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; + + if (ctx->shared == NULL) { + LOGI("Shared Data Not Init'd!\n"); + return -1; + } + + if (ctx->shared->dataReady) { + LOGI("Too late. Cant set it now!\n"); + return -1; + } + + if (param == CACHEABLE_BUFFERS) + ctx->cacheable_buffers = value; + + return ( ret ); +} + + +static int overlay_setCrop(struct overlay_data_device_t *dev, uint32_t x, + uint32_t y, uint32_t w, uint32_t h) { + LOG_FUNCTION_NAME; + + int rc = 0; + int cnt = 0; + struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; + + if (ctx->shared == NULL) { + LOGI("Shared Data Not Init'd!\n"); + return -1; + } + + pthread_mutex_lock(&ctx->shared->lock); + + ctx->shared->dataReady = 1; + + if (ctx->data.cropX == x && ctx->data.cropY == y && ctx->data.cropW == w + && ctx->data.cropH == h) { + goto end; + } + + ctx->data.cropX = x; + ctx->data.cropY = y; + ctx->data.cropW = w; + ctx->data.cropH = h; + + LOGD("Crop Win/X%d/Y%d/W%d/H%d\n", x, y, w, h ); + + if ((rc = disable_streaming_locked(ctx->shared, ctx->ctl_fd))) + goto end; + + rc = v4l2_overlay_set_crop(ctx->ctl_fd, x, y, w, h); + if (rc) { + LOGE("Set Crop Window Failed!/%d\n", rc); + } + + rc = enable_streaming_locked(ctx->shared, ctx->ctl_fd); + +end: + pthread_mutex_unlock(&ctx->shared->lock); + return rc; +} + +static int overlay_getCrop(struct overlay_data_device_t *dev , uint32_t* x, + uint32_t* y, uint32_t* w, uint32_t* h) { + struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; + + return v4l2_overlay_get_crop(ctx->ctl_fd, x, y, w, h); +} + +int overlay_dequeueBuffer(struct overlay_data_device_t *dev, + overlay_buffer_t *buffer) { + /* blocks until a buffer is available and return an opaque structure + * representing this buffer. + */ + + struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; + + int rc=0; + int i = -1; + uint32_t num = 0; + int cnt = 0; + + pthread_mutex_lock(&ctx->shared->lock); + if ( ctx->shared->streamingReset ) { + ctx->shared->streamingReset = 0; + pthread_mutex_unlock(&ctx->shared->lock); + return ALL_BUFFERS_FLUSHED; + } + pthread_mutex_unlock(&ctx->shared->lock); + + /* If we are not streaming dequeue will fail, + skip to prevent error printouts */ + if (ctx->shared->streamEn && ctx->qd_buf_count) { + if ((rc = v4l2_overlay_dq_buf( ctx->ctl_fd, &i ,ctx->zerocopy)) != 0) { + LOGE("Failed to DQ/%d\n", rc); + } + else if (i < 0 || i > ctx->num_buffers) { + rc = -EINVAL; + } else { + *((int *)buffer) = i; + ctx->qd_buf_count --; + } + } else { + rc = -1; + } + + return rc; +} + +int overlay_queueBuffer(struct overlay_data_device_t *dev, + overlay_buffer_t buffer) { + struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; + + int cnt = 0; + + pthread_mutex_lock(&ctx->shared->lock); + if ( ctx->shared->streamingReset ) { + ctx->shared->streamingReset = 0; + pthread_mutex_unlock(&ctx->shared->lock); + return ALL_BUFFERS_FLUSHED; + } + pthread_mutex_unlock(&ctx->shared->lock); + + /* Catch the case where the data side had no need to set the crop window */ + if (!ctx->shared->dataReady) { + ctx->shared->dataReady = 1; + enable_streaming(ctx->shared, ctx->ctl_fd); + } + + if (!ctx->shared->controlReady) return -1; + int rc = v4l2_overlay_q_buf( ctx->ctl_fd, (int)buffer, (int) ctx->zerocopy ); + if (rc == 0 && ctx->qd_buf_count < ctx->num_buffers) { + ctx->qd_buf_count ++; + } + + return rc; +} + +void *overlay_getBufferAddress(struct overlay_data_device_t *dev, + overlay_buffer_t buffer) +{ + LOG_FUNCTION_NAME; + + /* this may fail (NULL) if this feature is not supported. In that case, + * presumably, there is some other HAL module that can fill the buffer, + * using a DSP for instance + */ + int ret; + struct v4l2_buffer buf; + struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; + + if (ctx->zerocopy) + return NULL; + + if ((int)buffer >= 0 && (int)buffer < ctx->num_buffers) + return (void*) ctx->buffers[(int)buffer]; + else + return NULL; +} + +int overlay_getBufferCount(struct overlay_data_device_t *dev) +{ + LOG_FUNCTION_NAME; + + struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; + + return (ctx->num_buffers); +} + +static int overlay_data_close(struct hw_device_t *dev) { + + LOG_FUNCTION_NAME; + + struct overlay_data_context_t* ctx = (struct overlay_data_context_t*)dev; + int rc; + + if (ctx) { + overlay_data_device_t *overlay_dev = &ctx->device; + int buf; + int i; + + pthread_mutex_lock(&ctx->shared->lock); + + if (!ctx->zerocopy) + for (i = 0; i < ctx->num_buffers; i++) { + LOGV("Unmap Buffer/%d/%08lx/%d", i, (unsigned long)ctx->buffers[i], + ctx->buffers_len[i] ); + rc = v4l2_overlay_unmap_buf(ctx->buffers[i], ctx->buffers_len[i]); + if (rc != 0) { + LOGE("Error unmapping the buffer/%d/%d", i, rc); + } + } + + delete (ctx->mapping_data); + delete [] ctx->buffers; + delete [] ctx->buffers_len; + + pthread_mutex_unlock(&ctx->shared->lock); + + ctx->shared->dataReady = 0; + close_shared_data( ctx ); + + free(ctx); + } + + return 0; +} + +/*****************************************************************************/ + +static int overlay_device_open(const struct hw_module_t* module, + const char* name, struct hw_device_t** device) +{ + LOG_FUNCTION_NAME; + int status = -EINVAL; + + if (!strcmp(name, OVERLAY_HARDWARE_CONTROL)) { + struct overlay_control_context_t *dev; + dev = (overlay_control_context_t*)malloc(sizeof(*dev)); + + /* initialize our state here */ + memset(dev, 0, sizeof(*dev)); + + /* initialize the procs */ + dev->device.common.tag = HARDWARE_DEVICE_TAG; + dev->device.common.version = 0; + dev->device.common.module = const_cast(module); + dev->device.common.close = overlay_control_close; + + dev->device.get = overlay_get; + dev->device.createOverlay = overlay_createOverlay; + dev->device.destroyOverlay = overlay_destroyOverlay; + dev->device.setPosition = overlay_setPosition; + dev->device.getPosition = overlay_getPosition; + dev->device.setParameter = overlay_setParameter; + dev->device.stage = overlay_stage; + dev->device.commit = overlay_commit; + + *device = &dev->device.common; + status = 0; + } else if (!strcmp(name, OVERLAY_HARDWARE_DATA)) { + struct overlay_data_context_t *dev; + dev = (overlay_data_context_t*)malloc(sizeof(*dev)); + + /* initialize our state here */ + memset(dev, 0, sizeof(*dev)); + + /* initialize the procs */ + dev->device.common.tag = HARDWARE_DEVICE_TAG; + dev->device.common.version = 0; + dev->device.common.module = const_cast(module); + dev->device.common.close = overlay_data_close; + + dev->device.initialize = overlay_initialize; + dev->device.resizeInput = overlay_resizeInput; + dev->device.setCrop = overlay_setCrop; + dev->device.getCrop = overlay_getCrop; + dev->device.setParameter = overlay_data_setParameter; + dev->device.dequeueBuffer = overlay_dequeueBuffer; + dev->device.queueBuffer = overlay_queueBuffer; + dev->device.getBufferAddress = overlay_getBufferAddress; + dev->device.getBufferCount = overlay_getBufferCount; + + *device = &dev->device.common; + status = 0; + } + return status; +} diff --git a/liboverlay/v4l2_utils.c b/liboverlay/v4l2_utils.c new file mode 100644 index 0000000..f3ebbc2 --- /dev/null +++ b/liboverlay/v4l2_utils.c @@ -0,0 +1,788 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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. + */ + +/* #define OVERLAY_DEBUG 1 */ +#define LOG_TAG "v4l2_utils" + +#include +#include +#include +#include +#include +#include +#include +#include "v4l2_utils.h" + +#ifndef V4L2_DEVICE +#define V4L2_DEVICE "/dev/video1" +#endif + + + +#define LOG_FUNCTION_NAME LOGV("%s: %s", __FILE__, __func__); + +#define V4L2_CID_PRIV_OFFSET 0x0 +#define V4L2_CID_PRIV_ROTATION (V4L2_CID_PRIVATE_BASE \ + + V4L2_CID_PRIV_OFFSET + 0) +#define V4L2_CID_PRIV_COLORKEY (V4L2_CID_PRIVATE_BASE \ + + V4L2_CID_PRIV_OFFSET + 1) +#define V4L2_CID_PRIV_COLORKEY_EN (V4L2_CID_PRIVATE_BASE \ + + V4L2_CID_PRIV_OFFSET + 2) + +extern unsigned int g_lcd_width; +extern unsigned int g_lcd_height; +extern unsigned int g_lcd_bpp; + +int v4l2_overlay_get(int name) +{ + int result = -1; + switch (name) { + case OVERLAY_MINIFICATION_LIMIT: + result = 4; /* 0 = no limit */ + break; + case OVERLAY_MAGNIFICATION_LIMIT: + result = 2; /* 0 = no limit */ + break; + case OVERLAY_SCALING_FRAC_BITS: + result = 0; /* 0 = infinite */ + break; + case OVERLAY_ROTATION_STEP_DEG: + result = 90; /* 90 rotation steps (for instance) */ + break; + case OVERLAY_HORIZONTAL_ALIGNMENT: + result = 1; /* 1-pixel alignment */ + break; + case OVERLAY_VERTICAL_ALIGNMENT: + result = 1; /* 1-pixel alignment */ + break; + case OVERLAY_WIDTH_ALIGNMENT: + result = 1; /* 1-pixel alignment */ + break; + case OVERLAY_HEIGHT_ALIGNMENT: + result = 1; /* 1-pixel alignment */ + break; + } + return result; +} + +int v4l2_overlay_open(int id) +{ + LOG_FUNCTION_NAME + return open(V4L2_DEVICE, O_RDWR); +} + +int v4l2_overlay_init_fimc(int fd, s5p_fimc_t *s5p_fimc) +{ + int ret; + struct v4l2_control vc; + + if (fd < 0) + return -1; + + vc.id = V4L2_CID_FIMC_VERSION; + vc.value = 0; + + s5p_fimc->dev_fd = fd; + + ret = ioctl(s5p_fimc->dev_fd, VIDIOC_G_CTRL, &vc); + if (ret < 0) { + LOGE("Error in video VIDIOC_G_CTRL - V4L2_CID_FIMC_VERSION (%d)", ret); + LOGE("FIMC version is set with default"); + vc.value = 0x43; + } + s5p_fimc->hw_ver = vc.value; + return 0; +} + +void dump_pixfmt(struct v4l2_pix_format *pix) +{ + LOGV("w: %d\n", pix->width); + LOGV("h: %d\n", pix->height); + LOGV("color: %x\n", pix->colorspace); + + switch (pix->pixelformat) { + case V4L2_PIX_FMT_YUYV: + LOGV("YUYV\n"); + break; + case V4L2_PIX_FMT_UYVY: + LOGV("UYVY\n"); + break; + case V4L2_PIX_FMT_RGB565: + LOGV("RGB565\n"); + break; + case V4L2_PIX_FMT_RGB565X: + LOGV("RGB565X\n"); + break; + default: + LOGV("not supported\n"); + } +} + +void dump_crop(struct v4l2_crop *crop) +{ + LOGV("crop l: %d ", crop->c.left); + LOGV("crop t: %d ", crop->c.top); + LOGV("crop w: %d ", crop->c.width); + LOGV("crop h: %d\n", crop->c.height); +} + +void dump_window(struct v4l2_window *win) +{ + LOGV("window l: %d ", win->w.left); + LOGV("window t: %d ", win->w.top); + LOGV("window w: %d ", win->w.width); + LOGV("window h: %d\n", win->w.height); +} + +void v4l2_overlay_dump_state(int fd) +{ + struct v4l2_format format; + struct v4l2_crop crop; + int ret; + + LOGV("dumping driver state:"); + format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + ret = ioctl(fd, VIDIOC_G_FMT, &format); + if (ret < 0) + return; + LOGV("output pixfmt:\n"); + dump_pixfmt(&format.fmt.pix); + + format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; + ret = ioctl(fd, VIDIOC_G_FMT, &format); + if (ret < 0) + return; + LOGV("v4l2_overlay window:\n"); + dump_window(&format.fmt.win); + + crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + ret = ioctl(fd, VIDIOC_G_CROP, &crop); + if (ret < 0) + return; + LOGV("output crop:\n"); + dump_crop(&crop); +} + +static void error(int fd, const char *msg) +{ + LOGE("Error = %s from %s", strerror(errno), msg); +#ifdef OVERLAY_DEBUG + v4l2_overlay_dump_state(fd); +#endif +} + +static int v4l2_overlay_ioctl(int fd, int req, void *arg, const char* msg) +{ + int ret; + ret = ioctl(fd, req, arg); + if (ret < 0) { + error(fd, msg); + return -1; + } + return 0; +} + +#define v4l2_fourcc(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \ + ((__u32)(c) << 16) | ((__u32)(d) << 24)) +/* 12 Y/CbCr 4:2:0 64x32 macroblocks */ +#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2') + +int configure_pixfmt(struct v4l2_pix_format *pix, int32_t fmt, + uint32_t w, uint32_t h) +{ + LOG_FUNCTION_NAME + int fd; + + switch (fmt) { + case OVERLAY_FORMAT_RGBA_8888: + return -1; + case OVERLAY_FORMAT_RGB_565: + pix->pixelformat = V4L2_PIX_FMT_RGB565; + break; + case OVERLAY_FORMAT_BGRA_8888: + return -1; + case OVERLAY_FORMAT_YCbYCr_422_I: + case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I: + pix->pixelformat = V4L2_PIX_FMT_YUYV; + break; + case OVERLAY_FORMAT_CbYCrY_422_I: + case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I: + pix->pixelformat = V4L2_PIX_FMT_UYVY; + break; + case HAL_PIXEL_FORMAT_YCbCr_420_P: + pix->pixelformat = V4L2_PIX_FMT_YUV420; + break; + case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP: + pix->pixelformat = V4L2_PIX_FMT_NV12T; + break; + case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP: + pix->pixelformat = V4L2_PIX_FMT_NV21; + break; + default: + return -1; + } + pix->width = w; + pix->height = h; + return 0; +} + +static void configure_window(struct v4l2_window *win, int32_t w, + int32_t h, int32_t x, int32_t y) +{ + LOG_FUNCTION_NAME + + win->w.left = x; + win->w.top = y; + win->w.width = w; + win->w.height = h; +} + +void get_window(struct v4l2_format *format, int32_t *x, + int32_t *y, int32_t *w, int32_t *h) +{ + LOG_FUNCTION_NAME + + *x = format->fmt.win.w.left; + *y = format->fmt.win.w.top; + *w = format->fmt.win.w.width; + *h = format->fmt.win.w.height; +} + +int v4l2_overlay_init(int fd, uint32_t w, uint32_t h, uint32_t fmt, + uint32_t addr) +{ + LOG_FUNCTION_NAME + + struct v4l2_format format; + struct v4l2_framebuffer fbuf; + int ret; + + format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FMT, &format, "get format"); + if (ret) + return ret; + LOGV("v4l2_overlay_init:: w=%d h=%d\n", format.fmt.pix.width, + format.fmt.pix.height); + + format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + configure_pixfmt(&format.fmt.pix, fmt, w, h); + LOGV("v4l2_overlay_init:: w=%d h=%d\n", format.fmt.pix.width, + format.fmt.pix.height); + ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FMT, &format, "set output format"); + if (ret) + return ret; + + ret = v4l2_overlay_s_fbuf(fd, 0); + if (ret) + return ret; + + return ret; +} + +int v4l2_overlay_s_fbuf(int fd, int rotation) +{ + struct v4l2_framebuffer fbuf; + int ret; + + /* configure the v4l2_overlay framebuffer */ + ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FBUF, &fbuf, "get fbuf"); + if (ret) + return ret; + + /* if fbuf.base value is set by 0, using local DMA. */ + fbuf.base = (void *)0; + if (rotation == 0 || rotation == 180) { + fbuf.fmt.width = g_lcd_width; + fbuf.fmt.height = g_lcd_height; + } else { + fbuf.fmt.width = g_lcd_height; + fbuf.fmt.height = g_lcd_width; + } + + if (g_lcd_bpp == 32) + fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB32; + else + fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB565; + + ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FBUF, &fbuf, "set fbuf"); + if (ret) + return ret; + + return ret; +} + +int v4l2_overlay_get_input_size_and_format(int fd, uint32_t *w, uint32_t *h + , uint32_t *fmt) +{ + LOG_FUNCTION_NAME + + struct v4l2_format format; + int ret; + + format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FMT, &format, "get format"); + *w = format.fmt.pix.width; + *h = format.fmt.pix.height; + if (format.fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV) + *fmt = OVERLAY_FORMAT_CbYCrY_422_I; + else + return -EINVAL; + return ret; +} + +int v4l2_overlay_set_position(int fd, int32_t x, int32_t y + , int32_t w, int32_t h, int rotation) +{ + LOG_FUNCTION_NAME + + struct v4l2_format format; + int ret; + int rot_x = 0, rot_y = 0 , rot_w = 0, rot_h = 0; + + /* configure the src format pix */ + /* configure the dst v4l2_overlay window */ + format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; + ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FMT, &format, + "get v4l2_overlay format"); + if (ret) + return ret; + LOGV("v4l2_overlay_set_position:: w=%d h=%d", format.fmt.win.w.width + , format.fmt.win.w.height); + + if (rotation == 0) { + rot_x = x; + rot_y = y; + rot_w = w; + rot_h = h; + } else if (rotation == 90) { + rot_x = y; + rot_y = g_lcd_width - (x + w); + rot_w = h; + rot_h = w; + } else if (rotation == 180) { + rot_x = g_lcd_width - (x + w); + rot_y = g_lcd_height - (y + h); + rot_w = w; + rot_h = h; + } else if (rotation == 270) { + rot_x = g_lcd_height - (y + h); + rot_y = x; + rot_w = h; + rot_h = w; + } + + configure_window(&format.fmt.win, rot_w, rot_h, rot_x, rot_y); + + format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; + ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FMT, &format, + "set v4l2_overlay format"); + + LOGV("v4l2_overlay_set_position:: w=%d h=%d rotation=%d" + , format.fmt.win.w.width, format.fmt.win.w.height, rotation); + + if (ret) + return ret; + v4l2_overlay_dump_state(fd); + + return 0; +} + +int v4l2_overlay_get_position(int fd, int32_t *x, int32_t *y, int32_t *w, + int32_t *h) +{ + struct v4l2_format format; + int ret; + + format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; + ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FMT, &format, + "get v4l2_overlay format"); + + if (ret) + return ret; + + get_window(&format, x, y, w, h); + + return 0; +} + +int v4l2_overlay_set_crop(int fd, uint32_t x, uint32_t y, uint32_t w, + uint32_t h) +{ + LOG_FUNCTION_NAME + + struct v4l2_crop crop; + int ret; + + crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + ret = v4l2_overlay_ioctl(fd, VIDIOC_G_CROP, &crop, "get crop"); + crop.c.left = x; + crop.c.top = y; + crop.c.width = w; + crop.c.height = h; + crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + + LOGV("%s:crop.c.left = %d\n", __func__, crop.c.left); + LOGV("%s:crop.c.top = %d\n", __func__, crop.c.top); + LOGV("%s:crop.c.width = %d\n", __func__, crop.c.width); + LOGV("%s:crop.c.height = %d\n", __func__, crop.c.height); + LOGV("%s:crop.type = 0x%x\n", __func__, crop.type); + + return v4l2_overlay_ioctl(fd, VIDIOC_S_CROP, &crop, "set crop"); +} + +int v4l2_overlay_get_crop(int fd, uint32_t *x, uint32_t *y, uint32_t *w, + uint32_t *h) +{ + LOG_FUNCTION_NAME + + struct v4l2_crop crop; + int ret; + + crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + ret = v4l2_overlay_ioctl(fd, VIDIOC_G_CROP, &crop, "get crop"); + *x = crop.c.left; + *y = crop.c.top; + *w = crop.c.width; + *h = crop.c.height; + return ret; +} + +int v4l2_overlay_set_flip(int fd, int flip) +{ + LOG_FUNCTION_NAME + + int ret; + struct v4l2_control ctrl_v; + struct v4l2_control ctrl_h; + + switch (flip) { + case 0: + ctrl_v.value = 0; + ctrl_h.value = 0; + break; + case V4L2_CID_HFLIP: + ctrl_v.value = 0; + ctrl_h.value = 1; + break; + case V4L2_CID_VFLIP: + ctrl_v.value = 1; + ctrl_h.value = 0; + break; + default: + return -1; + } + + ctrl_v.id = V4L2_CID_VFLIP; + ret = v4l2_overlay_ioctl(fd, VIDIOC_S_CTRL, &ctrl_v, "set vflip"); + if (ret) return ret; + + ctrl_h.id = V4L2_CID_HFLIP; + ret = v4l2_overlay_ioctl(fd, VIDIOC_S_CTRL, &ctrl_h, "set hflip"); + return ret; +} + +int v4l2_overlay_set_rotation(int fd, int degree, int step) +{ + LOG_FUNCTION_NAME + + int ret; + struct v4l2_control ctrl; + + ctrl.id = V4L2_CID_PRIV_ROTATION; + ctrl.value = degree; + ret = v4l2_overlay_ioctl(fd, VIDIOC_S_CTRL, &ctrl, "set rotation"); + + return ret; +} + +int v4l2_overlay_set_colorkey(int fd, int enable, int colorkey) +{ + LOG_FUNCTION_NAME + + int ret; + struct v4l2_framebuffer fbuf; + struct v4l2_format fmt; + + memset(&fbuf, 0, sizeof(fbuf)); + ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FBUF, &fbuf, + "get transparency enables"); + + if (ret) + return ret; + + if (enable) + fbuf.flags |= V4L2_FBUF_FLAG_CHROMAKEY; + else + fbuf.flags &= ~V4L2_FBUF_FLAG_CHROMAKEY; + + ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FBUF, &fbuf, "enable colorkey"); + + if (ret) + return ret; + + if (enable) { + memset(&fmt, 0, sizeof(fmt)); + fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; + ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FMT, &fmt, "get colorkey"); + + if (ret) + return ret; + + fmt.fmt.win.chromakey = colorkey & 0xFFFFFF; + + ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FMT, &fmt, "set colorkey"); + } + + return ret; +} + +int v4l2_overlay_set_global_alpha(int fd, int enable, int alpha) +{ + LOG_FUNCTION_NAME + + int ret; + struct v4l2_framebuffer fbuf; + struct v4l2_format fmt; + + memset(&fbuf, 0, sizeof(fbuf)); + ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FBUF, &fbuf, + "get transparency enables"); + + if (ret) + return ret; + + if (enable) + fbuf.flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; + else + fbuf.flags &= ~V4L2_FBUF_FLAG_GLOBAL_ALPHA; + + ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FBUF, &fbuf, "enable global alpha"); + + if (ret) + return ret; + + if (enable) { + memset(&fmt, 0, sizeof(fmt)); + fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; + ret = v4l2_overlay_ioctl(fd, VIDIOC_G_FMT, &fmt, "get global alpha"); + + if (ret) + return ret; + + fmt.fmt.win.global_alpha = alpha & 0xFF; + + ret = v4l2_overlay_ioctl(fd, VIDIOC_S_FMT, &fmt, "set global alpha"); + } + + return ret; +} + +int v4l2_overlay_set_local_alpha(int fd, int enable) +{ + int ret; + struct v4l2_framebuffer fbuf; + + ret = 0; + + return ret; +} + +int v4l2_overlay_req_buf(int fd, uint32_t *num_bufs, int cacheable_buffers, int zerocopy) +{ + struct v4l2_requestbuffers reqbuf; + int ret, i; + + reqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + + if (zerocopy) + reqbuf.memory = V4L2_MEMORY_USERPTR; + else + reqbuf.memory = V4L2_MEMORY_MMAP; + reqbuf.count = *num_bufs; + + ret = ioctl(fd, VIDIOC_REQBUFS, &reqbuf); + if (ret < 0) { + error(fd, "reqbuf ioctl"); + return ret; + } + + if (reqbuf.count > *num_bufs) { + error(fd, "Not enough buffer structs passed to get_buffers"); + return -ENOMEM; + } + *num_bufs = reqbuf.count; + + return 0; +} + +static int is_mmaped(struct v4l2_buffer *buf) +{ + return buf->flags == V4L2_BUF_FLAG_MAPPED; +} + +static int is_queued(struct v4l2_buffer *buf) +{ + /* is either on the input or output queue in the kernel */ + return (buf->flags & V4L2_BUF_FLAG_QUEUED) || + (buf->flags & V4L2_BUF_FLAG_DONE); +} + +static int is_dequeued(struct v4l2_buffer *buf) +{ + /* is on neither input or output queue in kernel */ + return !(buf->flags & V4L2_BUF_FLAG_QUEUED) && + !(buf->flags & V4L2_BUF_FLAG_DONE); +} + +int v4l2_overlay_query_buffer(int fd, int index, struct v4l2_buffer *buf) +{ + LOG_FUNCTION_NAME + + memset(buf, 0, sizeof(struct v4l2_buffer)); + + buf->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + buf->memory = V4L2_MEMORY_MMAP; + buf->index = index; + LOGV("query buffer, mem=%u type=%u index=%u\n", + buf->memory, buf->type, buf->index); + return v4l2_overlay_ioctl(fd, VIDIOC_QUERYBUF, buf, "querybuf ioctl"); +} + +int v4l2_overlay_map_buf(int fd, int index, void **start, size_t *len) +{ + LOG_FUNCTION_NAME + + struct v4l2_buffer buf; + int ret; + + ret = v4l2_overlay_query_buffer(fd, index, &buf); + if (ret) + return ret; + + if (is_mmaped(&buf)) { + LOGE("Trying to mmap buffers that are already mapped!\n"); + return -EINVAL; + } + + *len = buf.length; + *start = mmap(NULL, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, + fd, buf.m.offset); + if (*start == MAP_FAILED) { + LOGE("map failed, length=%u offset=%u\n", buf.length, buf.m.offset); + return -EINVAL; + } + return 0; +} + +int v4l2_overlay_unmap_buf(void *start, size_t len) +{ + LOG_FUNCTION_NAME + return munmap(start, len); +} + + +int v4l2_overlay_get_caps(int fd, struct v4l2_capability *caps) +{ + return v4l2_overlay_ioctl(fd, VIDIOC_QUERYCAP, caps, "query cap"); +} + +int v4l2_overlay_stream_on(int fd) +{ + int ret; + uint32_t type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + + ret = v4l2_overlay_set_local_alpha(fd, 1); + if (ret) + return ret; + + ret = v4l2_overlay_ioctl(fd, VIDIOC_STREAMON, &type, "stream on"); + + return ret; +} + +int v4l2_overlay_stream_off(int fd) +{ + int ret; + uint32_t type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + + ret = v4l2_overlay_set_local_alpha(fd, 0); + if (ret) + return ret; + + ret = v4l2_overlay_ioctl(fd, VIDIOC_STREAMOFF, &type, "stream off"); + + return ret; +} + +int v4l2_overlay_q_buf(int fd, int buffer, int zerocopy) +{ + struct v4l2_buffer buf; + int ret; + + if (zerocopy) { + uint8_t *pPhyYAddr; + uint8_t *pPhyCAddr; + struct fimc_buf fimc_src_buf; + uint8_t index; + + memcpy(&pPhyYAddr, (void *) buffer, sizeof(pPhyYAddr)); + memcpy(&pPhyCAddr, (void *) (buffer + sizeof(pPhyYAddr)), + sizeof(pPhyCAddr)); + memcpy(&index, + (void *) (buffer + sizeof(pPhyYAddr) + sizeof(pPhyCAddr)), + sizeof(index)); + + fimc_src_buf.base[0] = (dma_addr_t) pPhyYAddr; + fimc_src_buf.base[1] = (dma_addr_t) pPhyCAddr; + fimc_src_buf.base[2] = + (dma_addr_t) (pPhyCAddr + (pPhyCAddr - pPhyYAddr)/4); + + buf.index = index; + buf.memory = V4L2_MEMORY_USERPTR; + buf.m.userptr = (unsigned long)&fimc_src_buf; + buf.length = 0; + } else { + buf.index = buffer; + buf.memory = V4L2_MEMORY_MMAP; + } + + buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + buf.field = V4L2_FIELD_NONE; + buf.timestamp.tv_sec = 0; + buf.timestamp.tv_usec = 0; + buf.flags = 0; + + return v4l2_overlay_ioctl(fd, VIDIOC_QBUF, &buf, "qbuf"); +} + +int v4l2_overlay_dq_buf(int fd, int *index, int zerocopy) +{ + struct v4l2_buffer buf; + int ret; + + buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + + if (zerocopy) + buf.memory = V4L2_MEMORY_USERPTR; + else + buf.memory = V4L2_MEMORY_MMAP; + + ret = v4l2_overlay_ioctl(fd, VIDIOC_DQBUF, &buf, "dqbuf"); + if (ret) + return ret; + *index = buf.index; + return 0; +} diff --git a/liboverlay/v4l2_utils.h b/liboverlay/v4l2_utils.h new file mode 100644 index 0000000..02797c3 --- /dev/null +++ b/liboverlay/v4l2_utils.h @@ -0,0 +1,75 @@ +/* + * Copyright 2009 Google Inc. All Rights Reserved. + * Author: rschultz@google.com (Rebecca Schultz Zavin) + */ + +#ifndef ANDROID_ZOOM_REPO_HARDWARE_SEC_LIBOVERLAY_V4L2_UTILS_H_ +#define ANDROID_ZOOM_REPO_HARDWARE_SEC_LIBOVERLAY_V4L2_UTILS_H_ + +#include "s5p_fimc.h" + +int v4l2_overlay_open(int id); +int v4l2_overlay_get_caps(int fd, struct v4l2_capability *caps); +int v4l2_overlay_req_buf(int fd, uint32_t *num_bufs, int cacheable_buffers, + int zerocopy); +int v4l2_overlay_query_buffer(int fd, int index, struct v4l2_buffer *buf); +int v4l2_overlay_map_buf(int fd, int index, void **start, size_t *len); +int v4l2_overlay_unmap_buf(void *start, size_t len); +int v4l2_overlay_stream_on(int fd); +int v4l2_overlay_stream_off(int fd); +int v4l2_overlay_q_buf(int fd, int index, int zerocopy); +int v4l2_overlay_dq_buf(int fd, int *index, int zerocopy); +int v4l2_overlay_init(int fd, uint32_t w, uint32_t h, uint32_t fmt, + uint32_t addr); +int v4l2_overlay_get_input_size(int fd, uint32_t *w, uint32_t *h, + uint32_t *fmt); +int v4l2_overlay_set_position(int fd, int32_t x, int32_t y, int32_t w, + int32_t h, int rotation); +int v4l2_overlay_get_position(int fd, int32_t *x, int32_t *y, int32_t *w, + int32_t *h); +int v4l2_overlay_set_crop(int fd, uint32_t x, uint32_t y, uint32_t w, + uint32_t h); +int v4l2_overlay_get_crop(int fd, uint32_t *x, uint32_t *y, uint32_t *w, + uint32_t *h); +int v4l2_overlay_set_flip(int fd, int degree); +int v4l2_overlay_set_rotation(int fd, int degree, int step); +int v4l2_overlay_set_colorkey(int fd, int enable, int colorkey); +int v4l2_overlay_set_global_alpha(int fd, int enable, int alpha); +int v4l2_overlay_set_local_alpha(int fd, int enable); +int v4l2_overlay_init_fimc(int fd, s5p_fimc_t *s5p_fimc); +int v4l2_overlay_s_fbuf(int fd, int rotation); + +enum { + V4L2_OVERLAY_PLANE_GRAPHICS, + V4L2_OVERLAY_PLANE_VIDEO1, + V4L2_OVERLAY_PLANE_VIDEO2, +}; + +enum { + /* support customed format for zero copy */ + HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x21, + HAL_PIXEL_FORMAT_YCbCr_420_P = 0x13, + HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP = 0x100, + HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I = 0x101, + HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I = 0x102, + HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP = 0x103, + HAL_PIXEL_FORMAT_CUSTOM_MAX +}; + +enum { + PFT_RGB, + PFT_YUV420, + PFT_YUV422, + PFT_YUV444, +}; + +struct mapping_data { + int fd; + size_t length; + uint32_t offset; + void *ptr; +}; + +#define ALL_BUFFERS_FLUSHED -66 + +#endif /* ANDROID_ZOOM_REPO_HARDWARE_SEC_LIBOVERLAY_V4L2_UTILS_H_*/ diff --git a/libs3cjpeg/Android.mk b/libs3cjpeg/Android.mk new file mode 100644 index 0000000..7a1acd6 --- /dev/null +++ b/libs3cjpeg/Android.mk @@ -0,0 +1,36 @@ +ifeq ($(Y_U_NO_HAVE_CAMERA),true) +# Copyright (C) 2008 The Android Open Source Project +# +# 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_C_INCLUDES := $(LOCAL_PATH) +LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include + +LOCAL_SRC_FILES:= \ + JpegEncoder.cpp + +LOCAL_SHARED_LIBRARIES:= liblog +LOCAL_SHARED_LIBRARIES+= libdl + +LOCAL_MODULE:= libs3cjpeg.aries + +LOCAL_MODULE_TAGS := optional + +LOCAL_PRELINK_MODULE := false + +include $(BUILD_SHARED_LIBRARY) +endif diff --git a/libs3cjpeg/Exif.h b/libs3cjpeg/Exif.h new file mode 100644 index 0000000..96e11dd --- /dev/null +++ b/libs3cjpeg/Exif.h @@ -0,0 +1,233 @@ +/* + * Copyright Samsung Electronics Co.,LTD. + * Copyright (C) 2010 The Android Open Source Project + * + * 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_EXIF_H +#define ANDROID_HARDWARE_EXIF_H + +#include + +#define EXIF_LOG2(x) (log((double)(x)) / log(2.0)) +#define APEX_FNUM_TO_APERTURE(x) ((int)(EXIF_LOG2((double)(x)) * 2 + 0.5)) +#define APEX_EXPOSURE_TO_SHUTTER(x) ((x) >= 1 ? \ + (int)(-(EXIF_LOG2((double)(x)) + 0.5)) : \ + (int)(-(EXIF_LOG2((double)(x)) - 0.5))) +#define APEX_ISO_TO_FILMSENSITIVITY(x) ((int)(EXIF_LOG2((x) / 3.125) + 0.5)) + +#define NUM_SIZE 2 +#define IFD_SIZE 12 +#define OFFSET_SIZE 4 + +#define NUM_0TH_IFD_TIFF 10 +#define NUM_0TH_IFD_EXIF 22 +#define NUM_0TH_IFD_GPS 10 +#define NUM_1TH_IFD_TIFF 9 + +/* Type */ +#define EXIF_TYPE_BYTE 1 +#define EXIF_TYPE_ASCII 2 +#define EXIF_TYPE_SHORT 3 +#define EXIF_TYPE_LONG 4 +#define EXIF_TYPE_RATIONAL 5 +#define EXIF_TYPE_UNDEFINED 7 +#define EXIF_TYPE_SLONG 9 +#define EXIF_TYPE_SRATIONAL 10 + +#define EXIF_FILE_SIZE 28800 + +/* 0th IFD TIFF Tags */ +#define EXIF_TAG_IMAGE_WIDTH 0x0100 +#define EXIF_TAG_IMAGE_HEIGHT 0x0101 +#define EXIF_TAG_MAKE 0x010f +#define EXIF_TAG_MODEL 0x0110 +#define EXIF_TAG_ORIENTATION 0x0112 +#define EXIF_TAG_SOFTWARE 0x0131 +#define EXIF_TAG_DATE_TIME 0x0132 +#define EXIF_TAG_YCBCR_POSITIONING 0x0213 +#define EXIF_TAG_EXIF_IFD_POINTER 0x8769 +#define EXIF_TAG_GPS_IFD_POINTER 0x8825 + +/* 0th IFD Exif Private Tags */ +#define EXIF_TAG_EXPOSURE_TIME 0x829A +#define EXIF_TAG_FNUMBER 0x829D +#define EXIF_TAG_EXPOSURE_PROGRAM 0x8822 +#define EXIF_TAG_ISO_SPEED_RATING 0x8827 +#define EXIF_TAG_EXIF_VERSION 0x9000 +#define EXIF_TAG_DATE_TIME_ORG 0x9003 +#define EXIF_TAG_DATE_TIME_DIGITIZE 0x9004 +#define EXIF_TAG_SHUTTER_SPEED 0x9201 +#define EXIF_TAG_APERTURE 0x9202 +#define EXIF_TAG_BRIGHTNESS 0x9203 +#define EXIF_TAG_EXPOSURE_BIAS 0x9204 +#define EXIF_TAG_MAX_APERTURE 0x9205 +#define EXIF_TAG_METERING_MODE 0x9207 +#define EXIF_TAG_FLASH 0x9209 +#define EXIF_TAG_FOCAL_LENGTH 0x920A +#define EXIF_TAG_USER_COMMENT 0x9286 +#define EXIF_TAG_COLOR_SPACE 0xA001 +#define EXIF_TAG_PIXEL_X_DIMENSION 0xA002 +#define EXIF_TAG_PIXEL_Y_DIMENSION 0xA003 +#define EXIF_TAG_EXPOSURE_MODE 0xA402 +#define EXIF_TAG_WHITE_BALANCE 0xA403 +#define EXIF_TAG_SCENCE_CAPTURE_TYPE 0xA406 + +/* 0th IFD GPS Info Tags */ +#define EXIF_TAG_GPS_VERSION_ID 0x0000 +#define EXIF_TAG_GPS_LATITUDE_REF 0x0001 +#define EXIF_TAG_GPS_LATITUDE 0x0002 +#define EXIF_TAG_GPS_LONGITUDE_REF 0x0003 +#define EXIF_TAG_GPS_LONGITUDE 0x0004 +#define EXIF_TAG_GPS_ALTITUDE_REF 0x0005 +#define EXIF_TAG_GPS_ALTITUDE 0x0006 +#define EXIF_TAG_GPS_TIMESTAMP 0x0007 +#define EXIF_TAG_GPS_PROCESSING_METHOD 0x001B +#define EXIF_TAG_GPS_DATESTAMP 0x001D + +/* 1th IFD TIFF Tags */ +#define EXIF_TAG_COMPRESSION_SCHEME 0x0103 +#define EXIF_TAG_X_RESOLUTION 0x011A +#define EXIF_TAG_Y_RESOLUTION 0x011B +#define EXIF_TAG_RESOLUTION_UNIT 0x0128 +#define EXIF_TAG_JPEG_INTERCHANGE_FORMAT 0x0201 +#define EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LEN 0x0202 + + +typedef enum { + EXIF_ORIENTATION_UP = 1, + EXIF_ORIENTATION_90 = 6, + EXIF_ORIENTATION_180 = 3, + EXIF_ORIENTATION_270 = 8, +} ExifOrientationType; + +typedef enum { + EXIF_SCENE_STANDARD, + EXIF_SCENE_LANDSCAPE, + EXIF_SCENE_PORTRAIT, + EXIF_SCENE_NIGHT, +} CamExifSceneCaptureType; + +typedef enum { + EXIF_METERING_UNKNOWN, + EXIF_METERING_AVERAGE, + EXIF_METERING_CENTER, + EXIF_METERING_SPOT, + EXIF_METERING_MULTISPOT, + EXIF_METERING_PATTERN, + EXIF_METERING_PARTIAL, + EXIF_METERING_OTHER = 255, +} CamExifMeteringModeType; + +typedef enum { + EXIF_EXPOSURE_AUTO, + EXIF_EXPOSURE_MANUAL, + EXIF_EXPOSURE_AUTO_BRACKET, +} CamExifExposureModeType; + +typedef enum { + EXIF_WB_AUTO, + EXIF_WB_MANUAL, +} CamExifWhiteBalanceType; + +/* Values */ +#define EXIF_DEF_MAKER "SAMSUNG" +#define EXIF_DEF_MODEL "GT-I9020" +#define EXIF_DEF_SOFTWARE "CRESPOJH2" +#define EXIF_DEF_EXIF_VERSION "0220" +#define EXIF_DEF_USERCOMMENTS "User comments" + +#define EXIF_DEF_YCBCR_POSITIONING 1 /* centered */ +#define EXIF_DEF_FNUMBER_NUM 26 /* 2.6 */ +#define EXIF_DEF_FNUMBER_DEN 10 +#define EXIF_DEF_EXPOSURE_PROGRAM 3 /* aperture priority */ +#define EXIF_DEF_FOCAL_LEN_NUM 278 /* 2.78mm */ +#define EXIF_DEF_FOCAL_LEN_DEN 100 +#define EXIF_DEF_FLASH 0 /* O: off, 1: on*/ +#define EXIF_DEF_COLOR_SPACE 1 +#define EXIF_DEF_EXPOSURE_MODE EXIF_EXPOSURE_AUTO +#define EXIF_DEF_APEX_DEN 10 + +#define EXIF_DEF_COMPRESSION 6 +#define EXIF_DEF_RESOLUTION_NUM 72 +#define EXIF_DEF_RESOLUTION_DEN 1 +#define EXIF_DEF_RESOLUTION_UNIT 2 /* inches */ + +typedef struct { + uint32_t num; + uint32_t den; +} rational_t; + +typedef struct { + int32_t num; + int32_t den; +} srational_t; + +typedef struct { + bool enableGps; + bool enableThumb; + + unsigned char maker[32]; + unsigned char model[32]; + unsigned char software[32]; + unsigned char exif_version[4]; + unsigned char date_time[20]; + unsigned char user_comment[150]; + + uint32_t width; + uint32_t height; + uint32_t widthThumb; + uint32_t heightThumb; + + uint16_t orientation; + uint16_t ycbcr_positioning; + uint16_t exposure_program; + uint16_t iso_speed_rating; + uint16_t metering_mode; + uint16_t flash; + uint16_t color_space; + uint16_t exposure_mode; + uint16_t white_balance; + uint16_t scene_capture_type; + + rational_t exposure_time; + rational_t fnumber; + rational_t aperture; + rational_t max_aperture; + rational_t focal_length; + + srational_t shutter_speed; + srational_t brightness; + srational_t exposure_bias; + + unsigned char gps_latitude_ref[2]; + unsigned char gps_longitude_ref[2]; + + uint8_t gps_version_id[4]; + uint8_t gps_altitude_ref; + + rational_t gps_latitude[3]; + rational_t gps_longitude[3]; + rational_t gps_altitude; + rational_t gps_timestamp[3]; + unsigned char gps_datestamp[11]; + unsigned char gps_processing_method[100]; + + rational_t x_resolution; + rational_t y_resolution; + uint16_t resolution_unit; + uint16_t compression_scheme; +} exif_attribute_t; + + +#endif /* ANDROID_HARDWARE_EXIF_H */ diff --git a/libs3cjpeg/JpegEncoder.cpp b/libs3cjpeg/JpegEncoder.cpp new file mode 100644 index 0000000..1361bca --- /dev/null +++ b/libs3cjpeg/JpegEncoder.cpp @@ -0,0 +1,796 @@ +/* + * Copyright Samsung Electronics Co.,LTD. + * Copyright (C) 2010 The Android Open Source Project + * + * 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. + * + * JPEG DRIVER MODULE (JpegEncoder.cpp) + * Author : ge.lee -- initial version + * Date : 03 June 2010 + * Purpose : This file implements the JPEG encoder APIs as needed by Camera HAL + */ +#define LOG_TAG "JpegEncoder" +#define MAIN_DUMP 0 +#define THUMB_DUMP 0 + +#include +#include +#include + +#include "JpegEncoder.h" + +static const char ExifAsciiPrefix[] = { 0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0 }; + +namespace android { +JpegEncoder::JpegEncoder() : available(false) +{ + mArgs.mmapped_addr = (char *)MAP_FAILED; + mArgs.enc_param = NULL; + mArgs.thumb_enc_param = NULL; + + mDevFd = open(JPG_DRIVER_NAME, O_RDWR); + if (mDevFd < 0) { + LOGE("Failed to open the device"); + return; + } + + mArgs.mmapped_addr = (char *)mmap(0, + JPG_TOTAL_BUF_SIZE, + PROT_READ | PROT_WRITE, + MAP_SHARED, + mDevFd, + 0); + + if (mArgs.mmapped_addr == MAP_FAILED) { + LOGE("Failed to mmap"); + return; + } + + mArgs.enc_param = new jpg_enc_proc_param; + if (mArgs.enc_param == NULL) { + LOGE("Failed to allocate the memory for enc_param"); + return; + } + memset(mArgs.enc_param, 0, sizeof(jpg_enc_proc_param)); + + mArgs.thumb_enc_param = new jpg_enc_proc_param; + if (mArgs.thumb_enc_param == NULL) { + LOGE("Failed to allocate the memory for thumb_enc_param"); + delete mArgs.enc_param; + return; + } + memset(mArgs.thumb_enc_param, 0, sizeof(jpg_enc_proc_param)); + + mArgs.enc_param->sample_mode = JPG_420; + mArgs.enc_param->enc_type = JPG_MAIN; + mArgs.thumb_enc_param->sample_mode = JPG_420; + mArgs.thumb_enc_param->enc_type = JPG_THUMBNAIL; + + available = true; +} + +JpegEncoder::~JpegEncoder() +{ + if (mArgs.mmapped_addr != (char*)MAP_FAILED) + munmap(mArgs.mmapped_addr, JPG_TOTAL_BUF_SIZE); + + delete mArgs.enc_param; + + delete mArgs.thumb_enc_param; + + if (mDevFd > 0) + close(mDevFd); +} + +jpg_return_status JpegEncoder::setConfig(jpeg_conf type, int32_t value) +{ + if (!available) + return JPG_FAIL; + + jpg_return_status ret = JPG_SUCCESS; + + switch (type) { + case JPEG_SET_ENCODE_WIDTH: + if (value < 0 || value > MAX_JPG_WIDTH) + ret = JPG_FAIL; + else + mArgs.enc_param->width = value; + break; + + case JPEG_SET_ENCODE_HEIGHT: + if (value < 0 || value > MAX_JPG_HEIGHT) + ret = JPG_FAIL; + else + mArgs.enc_param->height = value; + break; + + case JPEG_SET_ENCODE_QUALITY: + if (value < JPG_QUALITY_LEVEL_1 || value > JPG_QUALITY_LEVEL_4) + ret = JPG_FAIL; + else + mArgs.enc_param->quality = (image_quality_type_t)value; + break; + + case JPEG_SET_ENCODE_IN_FORMAT: + if (value != JPG_MODESEL_YCBCR && value != JPG_MODESEL_RGB) { + ret = JPG_FAIL; + } else { + mArgs.enc_param->in_format = (in_mode_t)value; + mArgs.thumb_enc_param->in_format = (in_mode_t)value; + } + break; + + case JPEG_SET_SAMPING_MODE: + if (value != JPG_420 && value != JPG_422) { + ret = JPG_FAIL; + } else { + mArgs.enc_param->sample_mode = (sample_mode_t)value; + mArgs.thumb_enc_param->sample_mode = (sample_mode_t)value; + } + break; + + case JPEG_SET_THUMBNAIL_WIDTH: + if (value < 0 || value > MAX_JPG_THUMBNAIL_WIDTH) + ret = JPG_FAIL; + else + mArgs.thumb_enc_param->width = value; + break; + + case JPEG_SET_THUMBNAIL_HEIGHT: + if (value < 0 || value > MAX_JPG_THUMBNAIL_HEIGHT) + ret = JPG_FAIL; + else + mArgs.thumb_enc_param->height = value; + break; + + default: + LOGE("Invalid Config type"); + ret = ERR_UNKNOWN; + } + + if (ret == JPG_FAIL) + LOGE("Invalid value(%d) for %d type", value, type); + + return ret; +} + +void* JpegEncoder::getInBuf(uint64_t size) +{ + if (!available) + return NULL; + + if (size > JPG_FRAME_BUF_SIZE) { + LOGE("The buffer size requested is too large"); + return NULL; + } + mArgs.in_buf = (char *)ioctl(mDevFd, IOCTL_JPG_GET_FRMBUF, mArgs.mmapped_addr); + return (void *)(mArgs.in_buf); +} + +void* JpegEncoder::getOutBuf(uint64_t *size) +{ + if (!available) + return NULL; + + if (mArgs.enc_param->file_size <= 0) { + LOGE("The buffer requested doesn't have data"); + return NULL; + } + mArgs.out_buf = (char *)ioctl(mDevFd, IOCTL_JPG_GET_STRBUF, mArgs.mmapped_addr); + *size = mArgs.enc_param->file_size; + return (void *)(mArgs.out_buf); +} + +void* JpegEncoder::getThumbInBuf(uint64_t size) +{ + if (!available) + return NULL; + + if (size > JPG_FRAME_THUMB_BUF_SIZE) { + LOGE("The buffer size requested is too large"); + return NULL; + } + mArgs.in_thumb_buf = (char *)ioctl(mDevFd, IOCTL_JPG_GET_THUMB_FRMBUF, mArgs.mmapped_addr); + return (void *)(mArgs.in_thumb_buf); +} + +void* JpegEncoder::getThumbOutBuf(uint64_t *size) +{ + if (!available) + return NULL; + + if (mArgs.thumb_enc_param->file_size <= 0) { + LOGE("The buffer requested doesn't have data"); + return NULL; + } + mArgs.out_thumb_buf = (char *)ioctl(mDevFd, IOCTL_JPG_GET_THUMB_STRBUF, mArgs.mmapped_addr); + *size = mArgs.thumb_enc_param->file_size; + return (void *)(mArgs.out_thumb_buf); +} + +jpg_return_status JpegEncoder::encode(unsigned int *size, exif_attribute_t *exifInfo) +{ + if (!available) + return JPG_FAIL; + + LOGD("encode E"); + + jpg_return_status ret = JPG_FAIL; + unsigned char *exifOut = NULL; + jpg_enc_proc_param *param = mArgs.enc_param; + + ret = checkMcu(param->sample_mode, param->width, param->height, false); + if (ret != JPG_SUCCESS) + return ret; + + param->enc_type = JPG_MAIN; + ret = (jpg_return_status)ioctl(mDevFd, IOCTL_JPG_ENCODE, &mArgs); + if (ret != JPG_SUCCESS) { + LOGE("Failed to encode main image"); + return ret; + } + + mArgs.out_buf = (char *)ioctl(mDevFd, IOCTL_JPG_GET_STRBUF, mArgs.mmapped_addr); + + if (exifInfo) { + unsigned int thumbLen, exifLen; + + uint_t bufSize = 0; + if (exifInfo->enableThumb) { + ret = encodeThumbImg(&thumbLen); + if (ret != JPG_SUCCESS) { + LOGE("Failed to encode for thumbnail image"); + bufSize = EXIF_FILE_SIZE; + exifInfo->enableThumb = false; + } else { + bufSize = EXIF_FILE_SIZE + thumbLen; + } + } else { + bufSize = EXIF_FILE_SIZE; + } + + if (mArgs.enc_param->file_size + bufSize > JPG_TOTAL_BUF_SIZE) + return ret; + + exifOut = new unsigned char[bufSize]; + if (exifOut == NULL) { + LOGE("Failed to allocate for exifOut"); + return ret; + } + memset(exifOut, 0, bufSize); + + ret = makeExif (exifOut, exifInfo, &exifLen); + if (ret != JPG_SUCCESS) { + LOGE("Failed to make EXIF"); + delete[] exifOut; + return ret; + } + + memmove(&mArgs.out_buf[exifLen + 2], &mArgs.out_buf[2], param->file_size - 2); + memcpy(&mArgs.out_buf[2], exifOut, exifLen); + param->file_size += exifLen; + } + + delete[] exifOut; + + *size = param->file_size; + +#if MAIN_DUMP + FILE *fout = NULL; + char file_name[50] = "/data/main.jpg"; + fout = fopen(file_name, "wb"); + if (!fout) + perror(&file_name[0]); + size_t nwrite = fwrite(mArgs.out_buf, sizeof(char), param->file_size, fout); + fclose(fout); +#endif + + LOGD("encode X"); + + return ret; +} + +jpg_return_status JpegEncoder::encodeThumbImg(unsigned int *size, bool useMain) +{ + if (!available) + return JPG_FAIL; + + LOGD("encodeThumbImg E"); + + jpg_return_status ret = JPG_FAIL; + jpg_enc_proc_param *param = mArgs.thumb_enc_param; + + if (useMain) { + mArgs.in_thumb_buf = (char *)getThumbInBuf(param->width*param->height*2); + if (mArgs.in_thumb_buf == NULL) { + LOGE("Failed to get the buffer for thumbnail"); + return JPG_FAIL; + } + + ret = (jpg_return_status)scaleDownYuv422(mArgs.in_buf, + mArgs.enc_param->width, + mArgs.enc_param->height, + mArgs.in_thumb_buf, + param->width, + param->height); + if (ret != JPG_SUCCESS) + return JPG_FAIL; + } + + ret = checkMcu(param->sample_mode, param->width, param->height, true); + if (ret != JPG_SUCCESS) + return JPG_FAIL; + + mArgs.enc_param->enc_type = JPG_THUMBNAIL; + ret = (jpg_return_status)ioctl(mDevFd, IOCTL_JPG_ENCODE, &mArgs); + if (ret != JPG_SUCCESS) { + LOGE("Failed to encode for thumbnail"); + return JPG_FAIL; + } + + mArgs.out_thumb_buf = (char *)ioctl(mDevFd, IOCTL_JPG_GET_THUMB_STRBUF, mArgs.mmapped_addr); + +#if THUMB_DUMP + FILE *fout = NULL; + char file_name[50] = "/data/thumb.jpg"; + fout = fopen(file_name, "wb"); + if (!fout) + perror(&file_name[0]); + size_t nwrite = fwrite(mArgs.out_thumb_buf, sizeof(char), param->file_size, fout); + fclose(fout); +#endif + + LOGD("encodeThumbImg X"); + + return JPG_SUCCESS; +} + +jpg_return_status JpegEncoder::makeExif (unsigned char *exifOut, + exif_attribute_t *exifInfo, + unsigned int *size, + bool useMainbufForThumb) +{ + if (!available) + return JPG_FAIL; + + LOGD("makeExif E"); + + unsigned char *pCur, *pApp1Start, *pIfdStart, *pGpsIfdPtr, *pNextIfdOffset; + unsigned int tmp, LongerTagOffest = 0; + pApp1Start = pCur = exifOut; + + //2 Exif Identifier Code & TIFF Header + pCur += 4; // Skip 4 Byte for APP1 marker and length + unsigned char ExifIdentifierCode[6] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 }; + memcpy(pCur, ExifIdentifierCode, 6); + pCur += 6; + + /* Byte Order - little endian, Offset of IFD - 0x00000008.H */ + unsigned char TiffHeader[8] = { 0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00 }; + memcpy(pCur, TiffHeader, 8); + pIfdStart = pCur; + pCur += 8; + + //2 0th IFD TIFF Tags + if (exifInfo->enableGps) + tmp = NUM_0TH_IFD_TIFF; + else + tmp = NUM_0TH_IFD_TIFF - 1; + + memcpy(pCur, &tmp, NUM_SIZE); + pCur += NUM_SIZE; + + LongerTagOffest += 8 + NUM_SIZE + tmp*IFD_SIZE + OFFSET_SIZE; + + writeExifIfd(&pCur, EXIF_TAG_IMAGE_WIDTH, EXIF_TYPE_LONG, + 1, exifInfo->width); + writeExifIfd(&pCur, EXIF_TAG_IMAGE_HEIGHT, EXIF_TYPE_LONG, + 1, exifInfo->height); + writeExifIfd(&pCur, EXIF_TAG_MAKE, EXIF_TYPE_ASCII, + strlen((char *)exifInfo->maker) + 1, exifInfo->maker, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_MODEL, EXIF_TYPE_ASCII, + strlen((char *)exifInfo->model) + 1, exifInfo->model, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_ORIENTATION, EXIF_TYPE_SHORT, + 1, exifInfo->orientation); + writeExifIfd(&pCur, EXIF_TAG_SOFTWARE, EXIF_TYPE_ASCII, + strlen((char *)exifInfo->software) + 1, exifInfo->software, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_DATE_TIME, EXIF_TYPE_ASCII, + 20, exifInfo->date_time, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_YCBCR_POSITIONING, EXIF_TYPE_SHORT, + 1, exifInfo->ycbcr_positioning); + writeExifIfd(&pCur, EXIF_TAG_EXIF_IFD_POINTER, EXIF_TYPE_LONG, + 1, LongerTagOffest); + if (exifInfo->enableGps) { + pGpsIfdPtr = pCur; + pCur += IFD_SIZE; // Skip a ifd size for gps IFD pointer + } + + pNextIfdOffset = pCur; // Skip a offset size for next IFD offset + pCur += OFFSET_SIZE; + + //2 0th IFD Exif Private Tags + pCur = pIfdStart + LongerTagOffest; + + tmp = NUM_0TH_IFD_EXIF; + memcpy(pCur, &tmp , NUM_SIZE); + pCur += NUM_SIZE; + + LongerTagOffest += NUM_SIZE + NUM_0TH_IFD_EXIF*IFD_SIZE + OFFSET_SIZE; + + writeExifIfd(&pCur, EXIF_TAG_EXPOSURE_TIME, EXIF_TYPE_RATIONAL, + 1, &exifInfo->exposure_time, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_FNUMBER, EXIF_TYPE_RATIONAL, + 1, &exifInfo->fnumber, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_EXPOSURE_PROGRAM, EXIF_TYPE_SHORT, + 1, exifInfo->exposure_program); + writeExifIfd(&pCur, EXIF_TAG_ISO_SPEED_RATING, EXIF_TYPE_SHORT, + 1, exifInfo->iso_speed_rating); + writeExifIfd(&pCur, EXIF_TAG_EXIF_VERSION, EXIF_TYPE_UNDEFINED, + 4, exifInfo->exif_version); + writeExifIfd(&pCur, EXIF_TAG_DATE_TIME_ORG, EXIF_TYPE_ASCII, + 20, exifInfo->date_time, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_DATE_TIME_DIGITIZE, EXIF_TYPE_ASCII, + 20, exifInfo->date_time, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_SHUTTER_SPEED, EXIF_TYPE_SRATIONAL, + 1, (rational_t *)&exifInfo->shutter_speed, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_APERTURE, EXIF_TYPE_RATIONAL, + 1, &exifInfo->aperture, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_BRIGHTNESS, EXIF_TYPE_SRATIONAL, + 1, (rational_t *)&exifInfo->brightness, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_EXPOSURE_BIAS, EXIF_TYPE_SRATIONAL, + 1, (rational_t *)&exifInfo->exposure_bias, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_MAX_APERTURE, EXIF_TYPE_RATIONAL, + 1, &exifInfo->max_aperture, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_METERING_MODE, EXIF_TYPE_SHORT, + 1, exifInfo->metering_mode); + writeExifIfd(&pCur, EXIF_TAG_FLASH, EXIF_TYPE_SHORT, + 1, exifInfo->flash); + writeExifIfd(&pCur, EXIF_TAG_FOCAL_LENGTH, EXIF_TYPE_RATIONAL, + 1, &exifInfo->focal_length, &LongerTagOffest, pIfdStart); + char code[8] = { 0x00, 0x00, 0x00, 0x49, 0x49, 0x43, 0x53, 0x41 }; + int commentsLen = strlen((char *)exifInfo->user_comment) + 1; + memmove(exifInfo->user_comment + sizeof(code), exifInfo->user_comment, commentsLen); + memcpy(exifInfo->user_comment, code, sizeof(code)); + writeExifIfd(&pCur, EXIF_TAG_USER_COMMENT, EXIF_TYPE_UNDEFINED, + commentsLen + sizeof(code), exifInfo->user_comment, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_COLOR_SPACE, EXIF_TYPE_SHORT, + 1, exifInfo->color_space); + writeExifIfd(&pCur, EXIF_TAG_PIXEL_X_DIMENSION, EXIF_TYPE_LONG, + 1, exifInfo->width); + writeExifIfd(&pCur, EXIF_TAG_PIXEL_Y_DIMENSION, EXIF_TYPE_LONG, + 1, exifInfo->height); + writeExifIfd(&pCur, EXIF_TAG_EXPOSURE_MODE, EXIF_TYPE_LONG, + 1, exifInfo->exposure_mode); + writeExifIfd(&pCur, EXIF_TAG_WHITE_BALANCE, EXIF_TYPE_LONG, + 1, exifInfo->white_balance); + writeExifIfd(&pCur, EXIF_TAG_SCENCE_CAPTURE_TYPE, EXIF_TYPE_LONG, + 1, exifInfo->scene_capture_type); + tmp = 0; + memcpy(pCur, &tmp, OFFSET_SIZE); // next IFD offset + pCur += OFFSET_SIZE; + + //2 0th IFD GPS Info Tags + if (exifInfo->enableGps) { + writeExifIfd(&pGpsIfdPtr, EXIF_TAG_GPS_IFD_POINTER, EXIF_TYPE_LONG, + 1, LongerTagOffest); // GPS IFD pointer skipped on 0th IFD + + pCur = pIfdStart + LongerTagOffest; + + if (exifInfo->gps_processing_method[0] == 0) { + // don't create GPS_PROCESSING_METHOD tag if there isn't any + tmp = NUM_0TH_IFD_GPS - 1; + } else { + tmp = NUM_0TH_IFD_GPS; + } + memcpy(pCur, &tmp, NUM_SIZE); + pCur += NUM_SIZE; + + LongerTagOffest += NUM_SIZE + tmp*IFD_SIZE + OFFSET_SIZE; + + writeExifIfd(&pCur, EXIF_TAG_GPS_VERSION_ID, EXIF_TYPE_BYTE, + 4, exifInfo->gps_version_id); + writeExifIfd(&pCur, EXIF_TAG_GPS_LATITUDE_REF, EXIF_TYPE_ASCII, + 2, exifInfo->gps_latitude_ref); + writeExifIfd(&pCur, EXIF_TAG_GPS_LATITUDE, EXIF_TYPE_RATIONAL, + 3, exifInfo->gps_latitude, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_GPS_LONGITUDE_REF, EXIF_TYPE_ASCII, + 2, exifInfo->gps_longitude_ref); + writeExifIfd(&pCur, EXIF_TAG_GPS_LONGITUDE, EXIF_TYPE_RATIONAL, + 3, exifInfo->gps_longitude, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_GPS_ALTITUDE_REF, EXIF_TYPE_BYTE, + 1, exifInfo->gps_altitude_ref); + writeExifIfd(&pCur, EXIF_TAG_GPS_ALTITUDE, EXIF_TYPE_RATIONAL, + 1, &exifInfo->gps_altitude, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_GPS_TIMESTAMP, EXIF_TYPE_RATIONAL, + 3, exifInfo->gps_timestamp, &LongerTagOffest, pIfdStart); + tmp = strlen((char*)exifInfo->gps_processing_method); + if (tmp > 0) { + if (tmp > 100) { + tmp = 100; + } + unsigned char tmp_buf[100+sizeof(ExifAsciiPrefix)]; + memcpy(tmp_buf, ExifAsciiPrefix, sizeof(ExifAsciiPrefix)); + memcpy(&tmp_buf[sizeof(ExifAsciiPrefix)], exifInfo->gps_processing_method, tmp); + writeExifIfd(&pCur, EXIF_TAG_GPS_PROCESSING_METHOD, EXIF_TYPE_UNDEFINED, + tmp+sizeof(ExifAsciiPrefix), tmp_buf, &LongerTagOffest, pIfdStart); + } + writeExifIfd(&pCur, EXIF_TAG_GPS_DATESTAMP, EXIF_TYPE_ASCII, + 11, exifInfo->gps_datestamp, &LongerTagOffest, pIfdStart); + tmp = 0; + memcpy(pCur, &tmp, OFFSET_SIZE); // next IFD offset + pCur += OFFSET_SIZE; + } + + //2 1th IFD TIFF Tags + char *thumbBuf; + int thumbSize; + + if (useMainbufForThumb) { + thumbBuf = mArgs.out_buf; + thumbSize = mArgs.enc_param->file_size; + } else { + thumbBuf = mArgs.out_thumb_buf; + thumbSize = mArgs.thumb_enc_param->file_size; + } + + if (exifInfo->enableThumb && (thumbBuf != NULL) && (thumbSize > 0)) { + tmp = LongerTagOffest; + memcpy(pNextIfdOffset, &tmp, OFFSET_SIZE); // NEXT IFD offset skipped on 0th IFD + + pCur = pIfdStart + LongerTagOffest; + + tmp = NUM_1TH_IFD_TIFF; + memcpy(pCur, &tmp, NUM_SIZE); + pCur += NUM_SIZE; + + LongerTagOffest += NUM_SIZE + NUM_1TH_IFD_TIFF*IFD_SIZE + OFFSET_SIZE; + + writeExifIfd(&pCur, EXIF_TAG_IMAGE_WIDTH, EXIF_TYPE_LONG, + 1, exifInfo->widthThumb); + writeExifIfd(&pCur, EXIF_TAG_IMAGE_HEIGHT, EXIF_TYPE_LONG, + 1, exifInfo->heightThumb); + writeExifIfd(&pCur, EXIF_TAG_COMPRESSION_SCHEME, EXIF_TYPE_SHORT, + 1, exifInfo->compression_scheme); + writeExifIfd(&pCur, EXIF_TAG_ORIENTATION, EXIF_TYPE_SHORT, + 1, exifInfo->orientation); + writeExifIfd(&pCur, EXIF_TAG_X_RESOLUTION, EXIF_TYPE_RATIONAL, + 1, &exifInfo->x_resolution, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_Y_RESOLUTION, EXIF_TYPE_RATIONAL, + 1, &exifInfo->y_resolution, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_RESOLUTION_UNIT, EXIF_TYPE_SHORT, + 1, exifInfo->resolution_unit); + writeExifIfd(&pCur, EXIF_TAG_JPEG_INTERCHANGE_FORMAT, EXIF_TYPE_LONG, + 1, LongerTagOffest); + writeExifIfd(&pCur, EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LEN, EXIF_TYPE_LONG, + 1, thumbSize); + + tmp = 0; + memcpy(pCur, &tmp, OFFSET_SIZE); // next IFD offset + pCur += OFFSET_SIZE; + + memcpy(pIfdStart + LongerTagOffest, + thumbBuf, thumbSize); + LongerTagOffest += thumbSize; + } else { + tmp = 0; + memcpy(pNextIfdOffset, &tmp, OFFSET_SIZE); // NEXT IFD offset skipped on 0th IFD + } + + unsigned char App1Marker[2] = { 0xff, 0xe1 }; + memcpy(pApp1Start, App1Marker, 2); + pApp1Start += 2; + + *size = 10 + LongerTagOffest; + tmp = *size - 2; // APP1 Maker isn't counted + unsigned char size_mm[2] = {(tmp >> 8) & 0xFF, tmp & 0xFF}; + memcpy(pApp1Start, size_mm, 2); + + LOGD("makeExif X"); + + return JPG_SUCCESS; +} + +jpg_return_status JpegEncoder::checkMcu(sample_mode_t sampleMode, + uint32_t width, uint32_t height, bool isThumb) +{ + if (!available) + return JPG_FAIL; + + uint32_t expectedWidth = width; + uint32_t expectedHeight = height; + + switch (sampleMode){ + case JPG_422: + if (width % 16 != 0) + expectedWidth = width + 16 - (width % 16); + if (height % 8 != 0) + expectedHeight = height + 8 - (height % 8); + break; + + case JPG_420: + if (width % 16 != 0) + expectedWidth = width + 16 - (width % 16); + if (height % 16 != 0) + expectedHeight = height + 16 - (height % 16); + break; + + default: + LOGE("Invaild sample mode"); + return JPG_FAIL; + } + + if (expectedWidth == width && expectedHeight == height) + return JPG_SUCCESS; + + LOGW("The image is not matched for MCU"); + + uint32_t size = width*height * 2; + char *srcBuf, *dstBuf; + + if ((srcBuf = new char[size]) == NULL) { + LOGE("Failed to allocate for srcBuf"); + return JPG_FAIL; + } + + if (!isThumb) + dstBuf = mArgs.in_buf; + else + dstBuf = mArgs.in_thumb_buf; + + memcpy(srcBuf, dstBuf, size); + bool ret = pad(srcBuf, width, height, dstBuf, expectedWidth, expectedHeight); + + delete[] srcBuf; + + return JPG_SUCCESS; +} + +bool JpegEncoder::pad(char *srcBuf, uint32_t srcWidth, uint32_t srcHight, + char *dstBuf, uint32_t dstWidth, uint32_t dstHight) +{ + if (!available) + return false; + + if (srcBuf == NULL || dstBuf == NULL) { + LOGE("srcBuf or dstBuf is NULL"); + return false; + } + + int padW = dstWidth - srcWidth; + int padH = dstHight - srcHight; + + if ((int)(dstWidth - srcWidth) < 0 || + (int)(dstHight - srcHight) < 0) { + LOGE("dstSize is smaller than srcSize"); + return false; + } + memset(dstBuf, 0, dstWidth*dstHight * 2); + + for (uint32_t i = 0; i < srcHight; i++) + memcpy(dstBuf + i * dstWidth * 2, srcBuf + i * srcWidth * 2, srcWidth * 2); + + return true; +} + +bool JpegEncoder::scaleDownYuv422(char *srcBuf, uint32_t srcWidth, uint32_t srcHight, + char *dstBuf, uint32_t dstWidth, uint32_t dstHight) +{ + if (!available) + return false; + + int32_t step_x, step_y; + int32_t iXsrc, iXdst; + int32_t x, y, src_y_start_pos, dst_pos, src_pos; + + if (dstWidth % 2 != 0 || dstHight % 2 != 0){ + LOGE("scale_down_yuv422: invalid width, height for scaling"); + return false; + } + + step_x = srcWidth / dstWidth; + step_y = srcHight / dstHight; + + dst_pos = 0; + for (uint32_t y = 0; y < dstHight; y++) { + src_y_start_pos = (y * step_y * (srcWidth * 2)); + + for (uint32_t x = 0; x < dstWidth; x += 2) { + src_pos = src_y_start_pos + (x * (step_x * 2)); + + dstBuf[dst_pos++] = srcBuf[src_pos ]; + dstBuf[dst_pos++] = srcBuf[src_pos + 1]; + dstBuf[dst_pos++] = srcBuf[src_pos + 2]; + dstBuf[dst_pos++] = srcBuf[src_pos + 3]; + } + } + + return true; +} + +inline void JpegEncoder::writeExifIfd(unsigned char **pCur, + unsigned short tag, + unsigned short type, + unsigned int count, + uint32_t value) +{ + memcpy(*pCur, &tag, 2); + *pCur += 2; + memcpy(*pCur, &type, 2); + *pCur += 2; + memcpy(*pCur, &count, 4); + *pCur += 4; + memcpy(*pCur, &value, 4); + *pCur += 4; +} + +inline void JpegEncoder::writeExifIfd(unsigned char **pCur, + unsigned short tag, + unsigned short type, + unsigned int count, + unsigned char *pValue) +{ + char buf[4] = { 0,}; + + memcpy(buf, pValue, count); + memcpy(*pCur, &tag, 2); + *pCur += 2; + memcpy(*pCur, &type, 2); + *pCur += 2; + memcpy(*pCur, &count, 4); + *pCur += 4; + memcpy(*pCur, buf, 4); + *pCur += 4; +} + + +inline void JpegEncoder::writeExifIfd(unsigned char **pCur, + unsigned short tag, + unsigned short type, + unsigned int count, + unsigned char *pValue, + unsigned int *offset, + unsigned char *start) +{ + memcpy(*pCur, &tag, 2); + *pCur += 2; + memcpy(*pCur, &type, 2); + *pCur += 2; + memcpy(*pCur, &count, 4); + *pCur += 4; + memcpy(*pCur, offset, 4); + *pCur += 4; + memcpy(start + *offset, pValue, count); + *offset += count; +} + +inline void JpegEncoder::writeExifIfd(unsigned char **pCur, + unsigned short tag, + unsigned short type, + unsigned int count, + rational_t *pValue, + unsigned int *offset, + unsigned char *start) +{ + memcpy(*pCur, &tag, 2); + *pCur += 2; + memcpy(*pCur, &type, 2); + *pCur += 2; + memcpy(*pCur, &count, 4); + *pCur += 4; + memcpy(*pCur, offset, 4); + *pCur += 4; + memcpy(start + *offset, pValue, 8 * count); + *offset += 8 * count; +} + +}; diff --git a/libs3cjpeg/JpegEncoder.h b/libs3cjpeg/JpegEncoder.h new file mode 100644 index 0000000..b95b1b1 --- /dev/null +++ b/libs3cjpeg/JpegEncoder.h @@ -0,0 +1,240 @@ +/* + * Copyright Samsung Electronics Co.,LTD. + * Copyright (C) 2010 The Android Open Source Project + * + * 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. + * + * JPEG DRIVER MODULE (JpegEncoder.h) + * Author : ge.lee -- initial version + * Date : 03 June 2010 + * Purpose : This file implements the JPEG encoder APIs as needed by Camera HAL + */ +#ifndef __JPG_API_H__ +#define __JPG_API_H__ + +#include +#include + +#include "Exif.h" + +namespace android { +#define MAX_JPG_WIDTH 800 +#define MAX_JPG_HEIGHT 480 +#define MAX_JPG_RESOLUTION (MAX_JPG_WIDTH * MAX_JPG_HEIGHT) + +#define MAX_JPG_THUMBNAIL_WIDTH 320 +#define MAX_JPG_THUMBNAIL_HEIGHT 240 +#define MAX_JPG_THUMBNAIL_RESOLUTION (MAX_JPG_THUMBNAIL_WIDTH * \ + MAX_JPG_THUMBNAIL_HEIGHT) + +#define MAX_RGB_WIDTH 800 +#define MAX_RGB_HEIGHT 480 +#define MAX_RGB_RESOLUTION (MAX_RGB_WIDTH * MAX_RGB_HEIGHT) + +/*******************************************************************************/ +/* define JPG & image memory */ +/* memory area is 4k(PAGE_SIZE) aligned because of VirtualCopyEx() */ +#define JPG_STREAM_BUF_SIZE \ + (MAX_JPG_RESOLUTION / PAGE_SIZE + 1) * PAGE_SIZE +#define JPG_STREAM_THUMB_BUF_SIZE \ + (MAX_JPG_THUMBNAIL_RESOLUTION / PAGE_SIZE + 1) * PAGE_SIZE +#define JPG_FRAME_BUF_SIZE \ + ((MAX_JPG_RESOLUTION * 3) / PAGE_SIZE + 1) * PAGE_SIZE +#define JPG_FRAME_THUMB_BUF_SIZE \ + ((MAX_JPG_THUMBNAIL_RESOLUTION * 3) / PAGE_SIZE + 1) * PAGE_SIZE +#define JPG_RGB_BUF_SIZE \ + ((MAX_RGB_RESOLUTION * 4) / PAGE_SIZE + 1) * PAGE_SIZE + +#define JPG_TOTAL_BUF_SIZE (JPG_STREAM_BUF_SIZE + \ + JPG_STREAM_THUMB_BUF_SIZE + \ + JPG_FRAME_BUF_SIZE + \ + JPG_FRAME_THUMB_BUF_SIZE + \ + JPG_RGB_BUF_SIZE) + +#define JPG_MAIN_START 0x00 +#define JPG_THUMB_START JPG_STREAM_BUF_SIZE +#define IMG_MAIN_START (JPG_STREAM_BUF_SIZE + JPG_STREAM_THUMB_BUF_SIZE) +#define IMG_THUMB_START (IMG_MAIN_START + JPG_FRAME_BUF_SIZE) +/*******************************************************************************/ + +#define JPG_DRIVER_NAME "/dev/s3c-jpg" + +#define JPEG_IOCTL_MAGIC 'J' +#define IOCTL_JPG_DECODE _IO(JPEG_IOCTL_MAGIC, 1) +#define IOCTL_JPG_ENCODE _IO(JPEG_IOCTL_MAGIC, 2) +#define IOCTL_JPG_GET_STRBUF _IO(JPEG_IOCTL_MAGIC, 3) +#define IOCTL_JPG_GET_FRMBUF _IO(JPEG_IOCTL_MAGIC, 4) +#define IOCTL_JPG_GET_THUMB_STRBUF _IO(JPEG_IOCTL_MAGIC, 5) +#define IOCTL_JPG_GET_THUMB_FRMBUF _IO(JPEG_IOCTL_MAGIC, 6) +#define IOCTL_JPG_GET_PHY_FRMBUF _IO(JPEG_IOCTL_MAGIC, 7) +#define IOCTL_JPG_GET_PHY_THUMB_FRMBUF _IO(JPEG_IOCTL_MAGIC, 8) + +typedef enum { + JPEG_SET_ENCODE_WIDTH, + JPEG_SET_ENCODE_HEIGHT, + JPEG_SET_ENCODE_QUALITY, + JPEG_SET_ENCODE_IN_FORMAT, + JPEG_SET_SAMPING_MODE, + JPEG_SET_THUMBNAIL_WIDTH, + JPEG_SET_THUMBNAIL_HEIGHT +} jpeg_conf; + +typedef enum { + JPG_FAIL, + JPG_SUCCESS, + OK_HD_PARSING, + ERR_HD_PARSING, + OK_ENC_OR_DEC, + ERR_ENC_OR_DEC, + ERR_UNKNOWN +} jpg_return_status; + +typedef enum { + JPG_RGB16, + JPG_YCBYCR, + JPG_TYPE_UNKNOWN +} image_type_t; + +typedef enum { + JPG_444, + JPG_422, + JPG_420, + JPG_400, + RESERVED1, + RESERVED2, + JPG_411, + JPG_SAMPLE_UNKNOWN +} sample_mode_t; + +typedef enum { + YCBCR_422, + YCBCR_420, + YCBCR_SAMPLE_UNKNOWN +} out_mode_t; + +typedef enum { + JPG_MODESEL_YCBCR = 1, + JPG_MODESEL_RGB, + JPG_MODESEL_UNKNOWN +} in_mode_t; + +typedef enum { + JPG_MAIN, + JPG_THUMBNAIL +} encode_type_t; + +typedef enum { + JPG_QUALITY_LEVEL_1, /* high */ + JPG_QUALITY_LEVEL_2, + JPG_QUALITY_LEVEL_3, + JPG_QUALITY_LEVEL_4 /* low */ +} image_quality_type_t; + +typedef struct { + sample_mode_t sample_mode; + encode_type_t dec_type; + out_mode_t out_format; + uint32_t width; + uint32_t height; + uint32_t data_size; + uint32_t file_size; +} jpg_dec_proc_param; + +typedef struct { + sample_mode_t sample_mode; + encode_type_t enc_type; + in_mode_t in_format; + image_quality_type_t quality; + uint32_t width; + uint32_t height; + uint32_t data_size; + uint32_t file_size; + uint32_t set_framebuf; +} jpg_enc_proc_param; + +typedef struct { + char *in_buf; + char *phy_in_buf; + int in_buf_size; + char *out_buf; + char *phy_out_buf; + int out_buf_size; + char *in_thumb_buf; + char *phy_in_thumb_buf; + int in_thumb_buf_size; + char *out_thumb_buf; + char *phy_out_thumb_buf; + int out_thumb_buf_size; + char *mmapped_addr; + jpg_dec_proc_param *dec_param; + jpg_enc_proc_param *enc_param; + jpg_enc_proc_param *thumb_enc_param; +} jpg_args; + +class JpegEncoder { +public: + JpegEncoder(); + virtual ~JpegEncoder(); + + int openHardware(); + jpg_return_status setConfig(jpeg_conf type, int32_t value); + void *getInBuf(uint64_t size); + void *getOutBuf(uint64_t *size); + void *getThumbInBuf(uint64_t size); + void *getThumbOutBuf(uint64_t *size); + jpg_return_status encode(unsigned int *size, exif_attribute_t *exifInfo); + jpg_return_status encodeThumbImg(unsigned int *size, bool useMain = true); + jpg_return_status makeExif(unsigned char *exifOut, + exif_attribute_t *exifIn, + unsigned int *size, + bool useMainbufForThumb = false); + +private: + jpg_return_status checkMcu(sample_mode_t sampleMode, uint32_t width, uint32_t height, bool isThumb); + bool pad(char *srcBuf, uint32_t srcWidth, uint32_t srcHight, + char *dstBuf, uint32_t dstWidth, uint32_t dstHight); + bool scaleDownYuv422(char *srcBuf, uint32_t srcWidth, uint32_t srcHight, + char *dstBuf, uint32_t dstWidth, uint32_t dstHight); + + inline void writeExifIfd(unsigned char **pCur, + unsigned short tag, + unsigned short type, + unsigned int count, + uint32_t value); + inline void writeExifIfd(unsigned char **pCur, + unsigned short tag, + unsigned short type, + unsigned int count, + unsigned char *pValue); + inline void writeExifIfd(unsigned char **pCur, + unsigned short tag, + unsigned short type, + unsigned int count, + rational_t *pValue, + unsigned int *offset, + unsigned char *start); + inline void writeExifIfd(unsigned char **pCur, + unsigned short tag, + unsigned short type, + unsigned int count, + unsigned char *pValue, + unsigned int *offset, + unsigned char *start); + int mDevFd; + jpg_args mArgs; + + bool available; + +}; +}; +#endif /* __JPG_API_H__ */ diff --git a/libsensors/Android.mk b/libsensors/Android.mk new file mode 100644 index 0000000..228bfe7 --- /dev/null +++ b/libsensors/Android.mk @@ -0,0 +1,50 @@ +# Copyright (C) 2008 The Android Open Source Project +# +# 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) + +ifneq ($(TARGET_SIMULATOR),true) + +# HAL module implemenation, not prelinked, and stored in +# hw/..so +include $(CLEAR_VARS) + +LOCAL_MODULE := sensors.aries + +LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw + +LOCAL_MODULE_TAGS := optional + +LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" + +ifeq ($(TARGET_DEVICE),captivate) + LOCAL_CFLAGS += -DCAPTIVATE +endif + +LOCAL_SRC_FILES := \ + sensors.cpp \ + SensorBase.cpp \ + LightSensor.cpp \ + ProximitySensor.cpp \ + Smb380Sensor.cpp \ + CompassSensor.cpp \ + OrientationSensor.cpp \ + InputEventReader.cpp + +LOCAL_SHARED_LIBRARIES := liblog libcutils libdl +LOCAL_PRELINK_MODULE := false + +include $(BUILD_SHARED_LIBRARY) + +endif diff --git a/libsensors/BoschYamaha.cpp b/libsensors/BoschYamaha.cpp new file mode 100644 index 0000000..ba88ff9 --- /dev/null +++ b/libsensors/BoschYamaha.cpp @@ -0,0 +1,500 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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 "BoschYamaha.h" + +/*****************************************************************************/ + +int stub_is_sensor_enabled(uint32_t sensor_type) { + return 0; +} + +int stub_enable_disable_sensor(uint32_t sensor_type) { + return -ENODEV; +} + +int stub_set_delay(uint64_t delay) { + return -ENODEV; +} + +BoschYamaha::BoschYamaha() +: SensorBase(NULL, NULL), + //mEnabled(0), + mPendingMask(0), + mInputReaderMagnetic(4), + mInputReaderAccel(4) +{ + + counterAccel = 0; + + /* FIXME set input device name for magnetic sensor */ + data_name = "input0"; + data_compass_fd = openInput("geomagnetic"); + + + //Open Compass + if (data_compass_fd) { + strcpy(input_sysfs_path, "/sys/class/input/"); + strcat(input_sysfs_path, input_name); + strcat(input_sysfs_path, "/device/"); + input_sysfs_path_len = strlen(input_sysfs_path); + //enable(MagneticField, 1); + + } + + /* FIXME set input device name for accelereometer sensor */ + data_accel_name = "event6"; + data_fd = openInput("SMB380-Sensor"); + + //Open Compass + if (data_fd) { + strcpy(input_accel_sysfs_path, "/sys/class/input/"); + strcat(input_accel_sysfs_path, data_accel_name); + strcat(input_accel_sysfs_path, "/device/"); + input_accel_sysfs_path_len = strlen(input_accel_sysfs_path); + + enable(Accelerometer, 1); + + } + + + memset(mPendingEvents, 0, sizeof(mPendingEvents)); + + mPendingEvents[Accelerometer].version = sizeof(sensors_event_t); + mPendingEvents[Accelerometer].sensor = ID_A; + mPendingEvents[Accelerometer].type = SENSOR_TYPE_ACCELEROMETER; + mPendingEvents[Accelerometer].acceleration.status = SENSOR_STATUS_ACCURACY_HIGH; + + mPendingEvents[MagneticField].version = sizeof(sensors_event_t); + mPendingEvents[MagneticField].sensor = ID_M; + mPendingEvents[MagneticField].type = SENSOR_TYPE_MAGNETIC_FIELD; + mPendingEvents[MagneticField].magnetic.status = SENSOR_STATUS_ACCURACY_HIGH; + + mPendingEvents[Orientation].version = sizeof(sensors_event_t); + mPendingEvents[Orientation].sensor = ID_O; + mPendingEvents[Orientation].type = SENSOR_TYPE_ORIENTATION; + mPendingEvents[Orientation].orientation.status = SENSOR_STATUS_ACCURACY_HIGH; + + + + + for (int i=0 ; i= numSensors) + return -EINVAL; + + int newState = en ? 1 : 0; + int err = 0; + + /* + //FIXME enabling the right sensor over sysfs interface + if(what == MagneticField){ + what = Accelerometer; //Enable also Accel + //Compass + LOGD("BoschYamaha::~enable Compass(0, %d)", en); + int flags = en ? 1 : 0; + if (flags != compassEnabled) { + int fd; + strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); + LOGD("BoschYamaha::~enable Compass(0, %d) open %s",en, input_sysfs_path); + fd = open(input_sysfs_path, O_RDWR); + if (fd >= 0) { + LOGD("CompassSensor::~enable(0, %d) opened %s",en, input_sysfs_path); + char buf[2]; + int err; + buf[1] = 0; + if (flags) { + buf[0] = '1'; + } else { + buf[0] = '0'; + } + err = write(fd, buf, sizeof(buf)); + close(fd); + //mEnabled = flags; + compassEnabled = flags; + return 0; + } + } + } + */ + + if(what == Accelerometer){ + //Accelerometer + LOGD("BoschYamaha::~enable Accel(0, %d)", en); + int flags = en ? 1 : 0; + if (flags != accelEnabled) { + int fd; + strcpy(&input_accel_sysfs_path[input_accel_sysfs_path_len], "enable"); + LOGD("BoschYamaha::~enable Accel(0, %d) open %s",en, input_accel_sysfs_path); + fd = open(input_accel_sysfs_path, O_RDWR); + if (fd >= 0) { + LOGD("CompassSensor::~enable(0, %d) opened %s",en, input_accel_sysfs_path); + char buf[2]; + int err; + buf[1] = 0; + if (flags) { + // counterAccel++; + buf[0] = '1'; + } else { + // counterAccel--; + buf[0] = '0'; + } + //if(counterAccel <= 1){ + err = write(fd, buf, sizeof(buf)); + //} + close(fd); + //mEnabled = flags; + accelEnabled = flags; + return 0; + } + } + } + + + return err; +} + +int BoschYamaha::setDelay(int32_t handle, int64_t ns) +{ + int what = -1; + switch (handle) { + case ID_A: what = Accelerometer; break; + case ID_M: what = MagneticField; break; + case ID_O: what = Orientation; break; + } + + if (uint32_t(what) >= numSensors) + return -EINVAL; + + if (ns < 0) + return -EINVAL; + + mDelays[what] = ns; + return update_delay(); +} + +int BoschYamaha::update_delay() +{ + return 0; +} + + +bool BoschYamaha::hasPendingEvents() { + + //LOGD("hasPendingEvents was called"); + if(accelEnabled || compassEnabled){ + //LOGD("hasPendingEvents will return true"); + return true; + } + else { + //LOGD("hasPendingEvents will return false"); + return false; + } +} + + + +int BoschYamaha::readEvents(sensors_event_t* data, int count) +{ + if (count < 1) + return -EINVAL; + + + int numEventReceived = 0; + + //LOGD("Sensor: Read events was called with count: %d", count); + + if(compassEnabled) + { + //LOGD("Sensor: Compass is enabled, going to take care of it, count: %d", count); + ssize_t n = mInputReaderMagnetic.fill(data_compass_fd); + if (n < 0) + return n; + + input_event const* event; + + while ( count && mInputReaderMagnetic.readEvent(&event)) { + int type = event->type; + //Everything is ABS! + if (type == EV_ABS) { + float value = event->value; + if (event->code == EVENT_TYPE_MAGV_X) { + mPendingEvents[MagneticField].magnetic.x = (value * CONVERT_M_X); + } else if (event->code == EVENT_TYPE_MAGV_Y) { + mPendingEvents[MagneticField].magnetic.y = (value * CONVERT_M_Y); + } else if (event->code == EVENT_TYPE_MAGV_Z) { + mPendingEvents[MagneticField].magnetic.z = (value * CONVERT_M_Z); + } + } + else if (type == EV_SYN) { + mPendingEvents[MagneticField].timestamp = timevalToNano(event->time); + if (compassEnabled) { + //LOGD("Sensor: Compass was enabled, made a read and received a Sync"); + compassDataReady = 1; + compassLastRead[0] = mPendingEvents[MagneticField].magnetic.x; + compassLastRead[1] = mPendingEvents[MagneticField].magnetic.y; + compassLastRead[2] = mPendingEvents[MagneticField].magnetic.z; + + *data++ = mPendingEvents[MagneticField]; + count--; + numEventReceived++; + } + } else { + LOGE("BoschYamaha: unknown event (type=%d, code=%d)", type, event->code); + + } + mInputReaderMagnetic.next(); + } + } + + //LOGD("Sensor: Compass read quited, count: %d", count); + + + if(accelEnabled) + { + //LOGD("Sensor: Accel is enabled, going to take care of it, count: %d", count); + + ssize_t n = mInputReaderAccel.fill(data_fd); + //LOGD("Sensor: Accel Input Reader was filled up: %d", count); + if (n < 0) + return n; + + input_event const* event; + + while (count && mInputReaderAccel.readEvent(&event)) { + int type = event->type; + if (type == EV_ABS) { + //LOGD("Sensor: Received one EV_ABS Event"); + float value = event->value; + if (event->code == EVENT_TYPE_ACCEL_X) { + mPendingEvents[Accelerometer].acceleration.x = value * CONVERT_A_X; + } else if (event->code == EVENT_TYPE_ACCEL_Y) { + mPendingEvents[Accelerometer].acceleration.y = value * CONVERT_A_Y; + } else if (event->code == EVENT_TYPE_ACCEL_Z) { + mPendingEvents[Accelerometer].acceleration.z = value * CONVERT_A_Z; + } + } else if (type == EV_SYN) { + mPendingEvents[Accelerometer].timestamp = timevalToNano(event->time); + if (accelEnabled) { + //LOGD("Sensor: Accel was enabled, made a read and received a Sync"); + accelDataReady = 1; + accelLastRead[0] = mPendingEvents[Accelerometer].acceleration.x; + accelLastRead[1] = mPendingEvents[Accelerometer].acceleration.y; + accelLastRead[2] = mPendingEvents[Accelerometer].acceleration.z; + *data++ = mPendingEvents[Accelerometer]; + count--; + numEventReceived++; + } + } + else { + LOGE("BoschYamaha: unknown event (type=%d, code=%d)", type, event->code); + + } + mInputReaderAccel.next(); + } + } + + //LOGD("Sensor: Accel read quited, count: %d, acceldata Ready: %d, compassData Ready = %d", count, accelDataReady, compassDataReady); + + if( (accelDataReady == 1) && (compassDataReady == 1)){ + //LOGD("BoschYamaha: Going to Process Orientation Data"); + accelDataReady = 0; + compassDataReady = 0; + processOrientation(); + *data++ = mPendingEvents[Orientation]; + numEventReceived++; + } + + + return numEventReceived; +} + + +int BoschYamaha::processOrientation(){ + + float matrix[9], euler[3]; + int rt, i; + + + rt = get_rotation_matrix(accelLastRead, compassLastRead, matrix); + + + if (rt < 0) { + for (i = 0; i < 3; i++) { + euler[i] = 0; + } + } + else { + get_euler(matrix, euler); + } + + //LOGD("BoschYamaha: azimuth is %d", (int)(euler[0])); + //LOGD("BoschYamaha: pitch is %d", (int)(euler[1])); + //LOGD("BoschYamaha: roll is %d", (int)(euler[2])); + + //Use CONVERT_O_A + mPendingEvents[Orientation].orientation.azimuth = (int)(euler[0]); + mPendingEvents[Orientation].orientation.pitch = (int)(euler[1]); + mPendingEvents[Orientation].orientation.roll = (int)(euler[2]); + //mPendingEvents[Orientation].orientation.status = uint8_t(value & SENSOR_STATE_MASK); + + return 1; + +} + + +float BoschYamaha::calc_intensity(float x, float y, float z) +{ + return sqrt(x*x + y*y + z*z); +} + + +int BoschYamaha::get_rotation_matrix(const float *gsdata, const float *msdata, float *matrix) +{ + float m_intensity, g_intensity, a_intensity, b_intensity; + float gdata[3], mdata[3], adata[3], bdata[3]; + int i; + + if (gsdata == NULL || msdata == NULL || matrix == NULL) { + return -1; + } + g_intensity = calc_intensity(gsdata[0], gsdata[1], gsdata[2]); + m_intensity = calc_intensity(msdata[0], msdata[1], msdata[2]); + if (g_intensity == 0 || m_intensity == 0) { + return -1; + } + for (i = 0; i < 3; i++) { + gdata[i] = -gsdata[i] / g_intensity; + mdata[i] = msdata[i] / m_intensity; + } + + adata[0] = (gdata[1] * mdata[2] - gdata[2] * mdata[1]); + adata[1] = (gdata[2] * mdata[0] - gdata[0] * mdata[2]); + adata[2] = (gdata[0] * mdata[1] - gdata[1] * mdata[0]); + a_intensity = calc_intensity(adata[0], adata[1], adata[2]); + if (a_intensity == 0) { + return -1; + } + for (i = 0; i < 3; i++) { + adata[i] /= a_intensity; + } + + bdata[0] = (adata[1] * gdata[2] - adata[2] * gdata[1]); + bdata[1] = (adata[2] * gdata[0] - adata[0] * gdata[2]); + bdata[2] = (adata[0] * gdata[1] - adata[1] * gdata[0]); + b_intensity = calc_intensity(bdata[0], bdata[1], bdata[2]); + if (b_intensity == 0) { + return -1; + } + for (i = 0; i < 3; i++) { + bdata[i] /= b_intensity; + } + + matrix[0] = adata[0]; + matrix[1] = adata[1]; + matrix[2] = adata[2]; + matrix[3] = bdata[0]; + matrix[4] = bdata[1]; + matrix[5] = bdata[2]; + matrix[6] = -gdata[0]; + matrix[7] = -gdata[1]; + matrix[8] = -gdata[2]; + + return 0; +} + +int BoschYamaha::get_euler(const float *matrix, float *euler) +{ + float m11, m12; + float m21, m22; + float m31, m32, m33; + float yaw = 0, roll = 0, pitch = 0; + + if (matrix == NULL || euler == NULL) { + return -1; + } + + m11 = matrix[0]; + m12 = matrix[1]; + m21 = matrix[3]; + m22 = matrix[4]; + m31 = matrix[6]; + m32 = matrix[7]; + m33 = matrix[8]; + + yaw = atan2(m12-m21, m11+m22); + pitch = -asin(m32); + roll = asin(m31); + + yaw *= 180.0 / M_PI; + pitch *= 180.0 / M_PI; + roll *= 180.0 / M_PI; + + if (m33 < 0) { + pitch = -180 - pitch; + if (pitch < -180) { + pitch += 360; + } + } + if (yaw < 0) { + yaw += 360.0f; + } + + euler[0] = (float)(int)yaw; /* yaw */ + + euler[1] = (float)(int)pitch; /* pitch */ + euler[2] = (float)(int)roll; /* roll */ + + return 0; +} + + + diff --git a/libsensors/BoschYamaha.h b/libsensors/BoschYamaha.h new file mode 100644 index 0000000..52af86b --- /dev/null +++ b/libsensors/BoschYamaha.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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_BOSCHYAMAHA_SENSOR_H +#define ANDROID_BOSCHYAMAHA_SENSOR_H + +#include +#include +#include +#include + + +#include "sensors.h" +#include "SensorBase.h" +#include "InputEventReader.h" + +/*****************************************************************************/ + +struct input_event; + +class BoschYamaha : public SensorBase { +public: + BoschYamaha(); + virtual ~BoschYamaha(); + + + + enum { + Accelerometer = 0, + MagneticField = 1, + Orientation = 2, + numSensors + }; + + virtual int setDelay(int32_t handle, int64_t ns); + virtual int enable(int32_t handle, int enabled); + virtual int readEvents(sensors_event_t* data, int count); + virtual bool hasPendingEvents(); + int processOrientation(); + float calc_intensity(float x, float y, float z); + int get_rotation_matrix(const float *gsdata, const float *msdata, float *matrix); + int get_euler(const float *matrix, float *euler); + +private: + const char* data_accel_name; + int data_compass_fd; + int update_delay(); + //uint32_t mEnabled; + int compassEnabled; + int accelEnabled; + float accelLastRead[3]; + float compassLastRead[3]; + int compassDataReady; + int accelDataReady; + int counterAccel; + uint32_t mPendingMask; + InputEventCircularReader mInputReaderMagnetic; + InputEventCircularReader mInputReaderAccel; + sensors_event_t mPendingEvents[numSensors]; + uint64_t mDelays[numSensors]; + char input_sysfs_path[PATH_MAX]; + int input_sysfs_path_len; + char input_accel_sysfs_path[PATH_MAX]; + int input_accel_sysfs_path_len; + +}; + +/*****************************************************************************/ + +#endif // ANDROID_BOSCHYAMAHA_SENSOR_H diff --git a/libsensors/CompassSensor.cpp b/libsensors/CompassSensor.cpp new file mode 100644 index 0000000..c4b6822 --- /dev/null +++ b/libsensors/CompassSensor.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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 "CompassSensor.h" + + +/*****************************************************************************/ +CompassSensor::CompassSensor() + : SensorBase(NULL, "magnetic_sensor"), + //mEnabled(0), + mInputReader(4), + mHasPendingEvent(false) +{ + LOGD("CompassSensor::CompassSensor()"); + mPendingEvent.version = sizeof(sensors_event_t); + mPendingEvent.sensor = ID_M; + mPendingEvent.type = SENSOR_TYPE_MAGNETIC_FIELD; + mPendingEvent.magnetic.status = SENSOR_STATUS_ACCURACY_HIGH; + + + memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); + + LOGD("CompassSensor::CompassSensor() open data_fd"); + + if (data_fd) { + strcpy(input_sysfs_path, "/sys/class/input/"); + strcat(input_sysfs_path, input_name); + strcat(input_sysfs_path, "/device/"); + input_sysfs_path_len = strlen(input_sysfs_path); + + //enable(0, 1); + } +} + +CompassSensor::~CompassSensor() { + + LOGD("CompassSensor::~CompassSensor()"); + if (mEnabled) { + enable(0, 0); + } +} + + + +int CompassSensor::enable(int32_t, int en) { + + + LOGD("CompassSensor::~enable(0, %d)", en); + int flags = en ? 1 : 0; + if (flags != mEnabled) { + int fd; + strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); + LOGD("CompassSensor::~enable(0, %d) open %s",en, input_sysfs_path); + fd = open(input_sysfs_path, O_RDWR); + if (fd >= 0) { + LOGD("CompassSensor::~enable(0, %d) opened %s",en, input_sysfs_path); + char buf[2]; + int err; + buf[1] = 0; + if (flags) { + buf[0] = '1'; + } else { + buf[0] = '0'; + } + err = write(fd, buf, sizeof(buf)); + close(fd); + mEnabled = flags; + return 0; + } + return -1; + } + return 0; +} + + +bool CompassSensor::hasPendingEvents() const { + /* FIXME probably here should be returning mEnabled but instead + mHasPendingEvents. It does not work, so we cheat.*/ + //LOGD("CompassSensor::~hasPendingEvents %d", mHasPendingEvent ? 1 : 0 ); + return mHasPendingEvent; +} + + +int CompassSensor::setDelay(int32_t handle, int64_t ns) +{ + LOGD("CompassSensor::~setDelay(%d, %d)", handle, ns); + /* FIXME needs changes to the kernel driver. + We need to add a IOCTL that can set the samplingrate + the driver in ther kernel supports this allready only need + to add a IOCTL on both sides for that*/ + return 0; +} + + +int CompassSensor::readEvents(sensors_event_t* data, int count) +{ + //LOGD("CompassSensor::~readEvents() %d", count); + if (count < 1) + return -EINVAL; + + if (mHasPendingEvent) { + mHasPendingEvent = false; + mPendingEvent.timestamp = getTimestamp(); + *data = mPendingEvent; + return mEnabled ? 1 : 0; + } + + ssize_t n = mInputReader.fill(data_fd); + if (n < 0) + return n; + + int numEventReceived = 0; + input_event const* event; + + while (count && mInputReader.readEvent(&event)) { + int type = event->type; + if (type == EV_REL) { + float value = event->value; + if (event->code == EVENT_TYPE_MAGV_X) { + mPendingEvent.magnetic.x = value * CONVERT_M_X; + } else if (event->code == EVENT_TYPE_MAGV_Y) { + mPendingEvent.magnetic.y = value * CONVERT_M_Y; + } else if (event->code == EVENT_TYPE_MAGV_Z) { + mPendingEvent.magnetic.z = value * CONVERT_M_Z; + } + } else if (type == EV_SYN) { + mPendingEvent.timestamp = timevalToNano(event->time); + if (mEnabled) { + *data++ = mPendingEvent; + count--; + numEventReceived++; + } + } else { + LOGE("CompassSensor: unknown event (type=%d, code=%d)", + type, event->code); + } + mInputReader.next(); + } + + //LOGD("CompassSensor::~readEvents() numEventReceived = %d", numEventReceived); + return numEventReceived++; + +} diff --git a/libsensors/CompassSensor.h b/libsensors/CompassSensor.h new file mode 100644 index 0000000..0270431 --- /dev/null +++ b/libsensors/CompassSensor.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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_COMPASS_SENSOR_H +#define ANDROID_COMPASS_SENSOR_H + +#include +#include +#include +#include + +#include "sensors.h" +#include "SensorBase.h" +#include "InputEventReader.h" + +/*****************************************************************************/ + + +struct input_event; + +class CompassSensor : public SensorBase { + int mEnabled; + InputEventCircularReader mInputReader; + sensors_event_t mPendingEvent; + bool mHasPendingEvent; + char input_sysfs_path[PATH_MAX]; + int input_sysfs_path_len; + + +public: + CompassSensor(); + virtual ~CompassSensor(); + virtual int readEvents(sensors_event_t* data, int count); + virtual bool hasPendingEvents() const; + virtual int setDelay(int32_t handle, int64_t ns); + virtual int enable(int32_t handle, int enabled); +}; + +/*****************************************************************************/ + +#endif // ANDROID_GYRO_SENSOR_H diff --git a/libsensors/GyroSensor.cpp b/libsensors/GyroSensor.cpp new file mode 100644 index 0000000..11df71e --- /dev/null +++ b/libsensors/GyroSensor.cpp @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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 "GyroSensor.h" + +#define FETCH_FULL_EVENT_BEFORE_RETURN 1 + +/*****************************************************************************/ + +GyroSensor::GyroSensor() + : SensorBase(NULL, "gyro"), + mEnabled(0), + mInputReader(4), + mHasPendingEvent(false) +{ + mPendingEvent.version = sizeof(sensors_event_t); + mPendingEvent.sensor = ID_GY; + mPendingEvent.type = SENSOR_TYPE_GYROSCOPE; + memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); + + if (data_fd) { + strcpy(input_sysfs_path, "/sys/class/input/"); + strcat(input_sysfs_path, input_name); + strcat(input_sysfs_path, "/device/"); + input_sysfs_path_len = strlen(input_sysfs_path); + enable(0, 1); + } +} + +GyroSensor::~GyroSensor() { + if (mEnabled) { + enable(0, 0); + } +} + +int GyroSensor::setInitialState() { + struct input_absinfo absinfo_x; + struct input_absinfo absinfo_y; + struct input_absinfo absinfo_z; + float value; + if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_GYRO_X), &absinfo_x) && + !ioctl(data_fd, EVIOCGABS(EVENT_TYPE_GYRO_X), &absinfo_y) && + !ioctl(data_fd, EVIOCGABS(EVENT_TYPE_GYRO_X), &absinfo_z)) { + value = absinfo_x.value; + mPendingEvent.data[0] = value * CONVERT_GYRO_X; + value = absinfo_x.value; + mPendingEvent.data[1] = value * CONVERT_GYRO_Y; + value = absinfo_x.value; + mPendingEvent.data[2] = value * CONVERT_GYRO_Z; + mHasPendingEvent = true; + } + return 0; +} + +int GyroSensor::enable(int32_t, int en) { + int flags = en ? 1 : 0; + if (flags != mEnabled) { + int fd; + strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); + fd = open(input_sysfs_path, O_RDWR); + if (fd >= 0) { + char buf[2]; + int err; + buf[1] = 0; + if (flags) { + buf[0] = '1'; + } else { + buf[0] = '0'; + } + err = write(fd, buf, sizeof(buf)); + close(fd); + mEnabled = flags; + setInitialState(); + return 0; + } + return -1; + } + return 0; +} + +bool GyroSensor::hasPendingEvents() const { + return mHasPendingEvent; +} + +int GyroSensor::setDelay(int32_t handle, int64_t delay_ns) +{ + int fd; + strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay"); + fd = open(input_sysfs_path, O_RDWR); + if (fd >= 0) { + char buf[80]; + sprintf(buf, "%lld", delay_ns); + write(fd, buf, strlen(buf)+1); + close(fd); + return 0; + } + return -1; +} + +int GyroSensor::readEvents(sensors_event_t* data, int count) +{ + if (count < 1) + return -EINVAL; + + if (mHasPendingEvent) { + mHasPendingEvent = false; + mPendingEvent.timestamp = getTimestamp(); + *data = mPendingEvent; + return mEnabled ? 1 : 0; + } + + ssize_t n = mInputReader.fill(data_fd); + if (n < 0) + return n; + + int numEventReceived = 0; + input_event const* event; + +#if FETCH_FULL_EVENT_BEFORE_RETURN +again: +#endif + while (count && mInputReader.readEvent(&event)) { + int type = event->type; + if (type == EV_REL) { + float value = event->value; + if (event->code == EVENT_TYPE_GYRO_X) { + mPendingEvent.data[0] = value * CONVERT_GYRO_X; + } else if (event->code == EVENT_TYPE_GYRO_Y) { + mPendingEvent.data[1] = value * CONVERT_GYRO_Y; + } else if (event->code == EVENT_TYPE_GYRO_Z) { + mPendingEvent.data[2] = value * CONVERT_GYRO_Z; + } + } else if (type == EV_SYN) { + mPendingEvent.timestamp = timevalToNano(event->time); + if (mEnabled) { + *data++ = mPendingEvent; + count--; + numEventReceived++; + } + } else { + LOGE("GyroSensor: unknown event (type=%d, code=%d)", + type, event->code); + } + mInputReader.next(); + } + +#if FETCH_FULL_EVENT_BEFORE_RETURN + /* if we didn't read a complete event, see if we can fill and + try again instead of returning with nothing and redoing poll. */ + if (numEventReceived == 0 && mEnabled == 1) { + n = mInputReader.fill(data_fd); + if (n) + goto again; + } +#endif + + return numEventReceived; +} + diff --git a/libsensors/GyroSensor.h b/libsensors/GyroSensor.h new file mode 100644 index 0000000..1b206bd --- /dev/null +++ b/libsensors/GyroSensor.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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_GYRO_SENSOR_H +#define ANDROID_GYRO_SENSOR_H + +#include +#include +#include +#include + +#include "sensors.h" +#include "SensorBase.h" +#include "InputEventReader.h" + +/*****************************************************************************/ + +struct input_event; + +class GyroSensor : public SensorBase { + int mEnabled; + InputEventCircularReader mInputReader; + sensors_event_t mPendingEvent; + bool mHasPendingEvent; + char input_sysfs_path[PATH_MAX]; + int input_sysfs_path_len; + + int setInitialState(); + +public: + GyroSensor(); + virtual ~GyroSensor(); + virtual int readEvents(sensors_event_t* data, int count); + virtual bool hasPendingEvents() const; + virtual int setDelay(int32_t handle, int64_t ns); + virtual int enable(int32_t handle, int enabled); +}; + +/*****************************************************************************/ + +#endif // ANDROID_GYRO_SENSOR_H diff --git a/libsensors/InputEventReader.cpp b/libsensors/InputEventReader.cpp new file mode 100644 index 0000000..c6bac93 --- /dev/null +++ b/libsensors/InputEventReader.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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 "InputEventReader.h" + +/*****************************************************************************/ + +struct input_event; + +InputEventCircularReader::InputEventCircularReader(size_t numEvents) + : mBuffer(new input_event[numEvents * 2]), + mBufferEnd(mBuffer + numEvents), + mHead(mBuffer), + mCurr(mBuffer), + mFreeSpace(numEvents) +{ +} + +InputEventCircularReader::~InputEventCircularReader() +{ + delete [] mBuffer; +} + +ssize_t InputEventCircularReader::fill(int fd) +{ + size_t numEventsRead = 0; + if (mFreeSpace) { + const ssize_t nread = read(fd, mHead, mFreeSpace * sizeof(input_event)); + if (nread<0 || nread % sizeof(input_event)) { + // we got a partial event!! + return nread<0 ? -errno : -EINVAL; + } + + numEventsRead = nread / sizeof(input_event); + if (numEventsRead) { + mHead += numEventsRead; + mFreeSpace -= numEventsRead; + if (mHead > mBufferEnd) { + size_t s = mHead - mBufferEnd; + memcpy(mBuffer, mBufferEnd, s * sizeof(input_event)); + mHead = mBuffer + s; + } + } + } + + return numEventsRead; +} + +ssize_t InputEventCircularReader::readEvent(input_event const** events) +{ + *events = mCurr; + ssize_t available = (mBufferEnd - mBuffer) - mFreeSpace; + return available ? 1 : 0; +} + +void InputEventCircularReader::next() +{ + mCurr++; + mFreeSpace++; + if (mCurr >= mBufferEnd) { + mCurr = mBuffer; + } +} diff --git a/libsensors/InputEventReader.h b/libsensors/InputEventReader.h new file mode 100644 index 0000000..fbf5121 --- /dev/null +++ b/libsensors/InputEventReader.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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_INPUT_EVENT_READER_H +#define ANDROID_INPUT_EVENT_READER_H + +#include +#include +#include +#include + +/*****************************************************************************/ + +struct input_event; + +class InputEventCircularReader +{ + struct input_event* const mBuffer; + struct input_event* const mBufferEnd; + struct input_event* mHead; + struct input_event* mCurr; + ssize_t mFreeSpace; + +public: + InputEventCircularReader(size_t numEvents); + ~InputEventCircularReader(); + ssize_t fill(int fd); + ssize_t readEvent(input_event const** events); + void next(); +}; + +/*****************************************************************************/ + +#endif // ANDROID_INPUT_EVENT_READER_H diff --git a/libsensors/LightSensor.cpp b/libsensors/LightSensor.cpp new file mode 100644 index 0000000..ea3e250 --- /dev/null +++ b/libsensors/LightSensor.cpp @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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 "LightSensor.h" + +/*****************************************************************************/ + +/* The Crespo ADC sends 4 somewhat bogus events after enabling the sensor. + This becomes a problem if the phone is turned off in bright light + and turned back on in the dark. + To avoid this we ignore the first 4 events received after enabling the sensor. + */ +#define FIRST_GOOD_EVENT 5 + +LightSensor::LightSensor() + : SensorBase(NULL, "light_sensor"), + mEnabled(0), + mEventsSinceEnable(0), + mInputReader(4), + mHasPendingEvent(false) +{ + mPendingEvent.version = sizeof(sensors_event_t); + mPendingEvent.sensor = ID_L; + mPendingEvent.type = SENSOR_TYPE_LIGHT; + memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); + + if (data_fd) { + strcpy(input_sysfs_path, "/sys/class/input/"); + strcat(input_sysfs_path, input_name); + strcat(input_sysfs_path, "/device/"); + input_sysfs_path_len = strlen(input_sysfs_path); + enable(0, 1); + } +} + +LightSensor::~LightSensor() { + if (mEnabled) { + enable(0, 0); + } +} + +int LightSensor::setDelay(int32_t handle, int64_t ns) +{ + int fd; + strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay"); + fd = open(input_sysfs_path, O_RDWR); + if (fd >= 0) { + char buf[80]; + sprintf(buf, "%lld", ns); + write(fd, buf, strlen(buf)+1); + close(fd); + return 0; + } + return -1; +} + +int LightSensor::enable(int32_t handle, int en) +{ + int flags = en ? 1 : 0; + mEventsSinceEnable = 0; + mPreviousLight = -1; + if (flags != mEnabled) { + int fd; + strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); + fd = open(input_sysfs_path, O_RDWR); + if (fd >= 0) { + char buf[2]; + int err; + buf[1] = 0; + if (flags) { + buf[0] = '1'; + } else { + buf[0] = '0'; + } + err = write(fd, buf, sizeof(buf)); + close(fd); + mEnabled = flags; + return 0; + } + return -1; + } + return 0; +} + +bool LightSensor::hasPendingEvents() const { + return mHasPendingEvent; +} + +int LightSensor::readEvents(sensors_event_t* data, int count) +{ + if (count < 1) + return -EINVAL; + + if (mHasPendingEvent) { + mHasPendingEvent = false; + mPendingEvent.timestamp = getTimestamp(); + *data = mPendingEvent; + return mEnabled ? 1 : 0; + } + + ssize_t n = mInputReader.fill(data_fd); + if (n < 0) + return n; + + int numEventReceived = 0; + input_event const* event; + + while (count && mInputReader.readEvent(&event)) { + int type = event->type; + if (type == EV_ABS) { + if (event->code == EVENT_TYPE_LIGHT) { + mPendingEvent.light = indexToValue(event->value); + if (mEventsSinceEnable < FIRST_GOOD_EVENT) + mEventsSinceEnable++; + } + } else if (type == EV_SYN) { + mPendingEvent.timestamp = timevalToNano(event->time); + if (mEnabled && (mPendingEvent.light != mPreviousLight) && + mEventsSinceEnable >= FIRST_GOOD_EVENT) { + *data++ = mPendingEvent; + count--; + numEventReceived++; + mPreviousLight = mPendingEvent.light; + } + } else { + LOGE("LightSensor: unknown event (type=%d, code=%d)", + type, event->code); + } + mInputReader.next(); + } + + return numEventReceived; +} + +float LightSensor::indexToValue(size_t index) const +{ + /* Driver gives a rolling average adc value. We convert it lux levels. */ + static const struct adcToLux { + size_t adc_value; + float lux_value; + } adcToLux[] = { + { 150, 10.0 }, /* from 0 - 150 adc, we map to 10.0 lux */ + { 800, 160.0 }, /* from 151 - 800 adc, we map to 160.0 lux */ + { 900, 225.0 }, /* from 801 - 900 adc, we map to 225.0 lux */ + { 1000, 320.0 }, /* from 901 - 1000 adc, we map to 320.0 lux */ + { 1200, 640.0 }, /* from 1001 - 1200 adc, we map to 640.0 lux */ + { 1400, 1280.0 }, /* from 1201 - 1400 adc, we map to 1280.0 lux */ + { 1600, 2600.0 }, /* from 1401 - 1600 adc, we map to 2600.0 lux */ + { 4095, 10240.0 }, /* from 1601 - 4095 adc, we map to 10240.0 lux */ + }; + size_t i; + for (i = 0; i < ARRAY_SIZE(adcToLux); i++) { + if (index < adcToLux[i].adc_value) { + return adcToLux[i].lux_value; + } + } + return adcToLux[ARRAY_SIZE(adcToLux)-1].lux_value; +} diff --git a/libsensors/LightSensor.h b/libsensors/LightSensor.h new file mode 100644 index 0000000..cc1a00d --- /dev/null +++ b/libsensors/LightSensor.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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_LIGHT_SENSOR_H +#define ANDROID_LIGHT_SENSOR_H + +#include +#include +#include +#include + +#include "sensors.h" +#include "SensorBase.h" +#include "InputEventReader.h" + +/*****************************************************************************/ + +struct input_event; + +class LightSensor : public SensorBase { + int mEnabled; + int mEventsSinceEnable; + InputEventCircularReader mInputReader; + sensors_event_t mPendingEvent; + bool mHasPendingEvent; + char input_sysfs_path[PATH_MAX]; + int input_sysfs_path_len; + + int setInitialState(); + float mPreviousLight; + float indexToValue(size_t index) const; + +public: + LightSensor(); + virtual ~LightSensor(); + virtual int readEvents(sensors_event_t* data, int count); + virtual bool hasPendingEvents() const; + virtual int setDelay(int32_t handle, int64_t ns); + virtual int enable(int32_t handle, int enabled); +}; + +/*****************************************************************************/ + +#endif // ANDROID_LIGHT_SENSOR_H diff --git a/libsensors/OrientationSensor.cpp b/libsensors/OrientationSensor.cpp new file mode 100644 index 0000000..3fb5d29 --- /dev/null +++ b/libsensors/OrientationSensor.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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 "OrientationSensor.h" + + +/*****************************************************************************/ +OrientationSensor::OrientationSensor() + : SensorBase(NULL, "orientation_sensor"), + mEnabled(0), + mInputReader(4), + mHasPendingEvent(false) +{ + LOGD("OrientationSensor::OrientationSensor()"); + mPendingEvent.version = sizeof(sensors_event_t); + mPendingEvent.sensor = ID_O; + mPendingEvent.type = SENSOR_TYPE_ORIENTATION; + memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); + + LOGD("OrientationSensor::OrientationSensor() open data_fd"); + + if (data_fd) { + strcpy(input_sysfs_path, "/sys/class/input/"); + strcat(input_sysfs_path, input_name); + strcat(input_sysfs_path, "/device/"); + input_sysfs_path_len = strlen(input_sysfs_path); + + // enable(0, 1); + } +} + +OrientationSensor::~OrientationSensor() { + + LOGD("OrientationSensor::~OrientationSensor()"); + if (mEnabled) { + enable(0, 0); + } +} + + +int OrientationSensor::enable(int32_t, int en) { + + + LOGD("OrientationSensor::~enable(0, %d)", en); + int flags = en ? 1 : 0; + if (flags != mEnabled) { + int fd; + strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); + LOGD("OrientationSensor::~enable(0, %d) open %s",en, input_sysfs_path); + fd = open(input_sysfs_path, O_RDWR); + if (fd >= 0) { + LOGD("OrientationSensor::~enable(0, %d) opened %s",en, input_sysfs_path); + char buf[2]; + int err; + buf[1] = 0; + if (flags) { + buf[0] = '1'; + } else { + buf[0] = '0'; + } + err = write(fd, buf, sizeof(buf)); + close(fd); + mEnabled = flags; + //setInitialState(); + return 0; + } + return -1; + } + return 0; +} + + +bool OrientationSensor::hasPendingEvents() const { + /* FIXME probably here should be returning mEnabled but instead + mHasPendingEvents. It does not work, so we cheat.*/ + //LOGD("OrientationSensor::~hasPendingEvents %d", mHasPendingEvent ? 1 : 0 ); + return mHasPendingEvent; +} + + +int OrientationSensor::setDelay(int32_t handle, int64_t ns) +{ + LOGD("OrientationSensor::~setDelay(%d, %d)", handle, ns); + /* FIXME needs changes to the kernel driver. + We need to add a IOCTL that can set the samplingrate + the driver in ther kernel supports this allready only need + to add a IOCTL on both sides for that*/ + return 0; +} + + +int OrientationSensor::readEvents(sensors_event_t* data, int count) +{ + //LOGD("OrientationSensor::~readEvents() %d", count); + if (count < 1) + return -EINVAL; + + if (mHasPendingEvent) { + mHasPendingEvent = false; + mPendingEvent.timestamp = getTimestamp(); + *data = mPendingEvent; + return mEnabled ? 1 : 0; + } + + ssize_t n = mInputReader.fill(data_fd); + if (n < 0) + return n; + + int numEventReceived = 0; + input_event const* event; + + while (count && mInputReader.readEvent(&event)) { + int type = event->type; + if (type == EV_REL) { + float value = event->value; + if (event->code == EVENT_TYPE_YAW) { + mPendingEvent.orientation.azimuth = value * CONVERT_O_A; + } else if (event->code == EVENT_TYPE_PITCH) { + mPendingEvent.orientation.pitch = value * CONVERT_O_P; + } else if (event->code == EVENT_TYPE_ROLL) { + mPendingEvent.orientation.roll = value * CONVERT_O_R; + } + } else if (type == EV_SYN) { + mPendingEvent.timestamp = timevalToNano(event->time); + if (mEnabled) { + *data++ = mPendingEvent; + count--; + numEventReceived++; + } + } else { + LOGE("OrientationSensor: unknown event (type=%d, code=%d)", + type, event->code); + } + mInputReader.next(); + } + + //LOGD("OrientationSensor::~readEvents() numEventReceived = %d", numEventReceived); + return numEventReceived++; + +} diff --git a/libsensors/OrientationSensor.h b/libsensors/OrientationSensor.h new file mode 100644 index 0000000..cbb7064 --- /dev/null +++ b/libsensors/OrientationSensor.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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_ORIEN_SENSOR_H +#define ANDROID_ORIEN_SENSOR_H + +#include +#include +#include +#include + +#include "sensors.h" +#include "SensorBase.h" +#include "InputEventReader.h" + +/*****************************************************************************/ + + +struct input_event; + +class OrientationSensor : public SensorBase { + int mEnabled; + InputEventCircularReader mInputReader; + sensors_event_t mPendingEvent; + bool mHasPendingEvent; + char input_sysfs_path[PATH_MAX]; + int input_sysfs_path_len; + + +public: + OrientationSensor(); + virtual ~OrientationSensor(); + virtual int readEvents(sensors_event_t* data, int count); + virtual bool hasPendingEvents() const; + virtual int setDelay(int32_t handle, int64_t ns); + virtual int enable(int32_t handle, int enabled); +}; + +/*****************************************************************************/ + +#endif // ANDROID_GYRO_SENSOR_H diff --git a/libsensors/ProximitySensor.cpp b/libsensors/ProximitySensor.cpp new file mode 100644 index 0000000..f7151ee --- /dev/null +++ b/libsensors/ProximitySensor.cpp @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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 "ProximitySensor.h" + +/*****************************************************************************/ + +ProximitySensor::ProximitySensor() + : SensorBase(NULL, "proximity_sensor"), + mEnabled(0), + mInputReader(4), + mHasPendingEvent(false) +{ + mPendingEvent.version = sizeof(sensors_event_t); + mPendingEvent.sensor = ID_P; + mPendingEvent.type = SENSOR_TYPE_PROXIMITY; + memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); + + if (data_fd) { + strcpy(input_sysfs_path, "/sys/class/input/"); + strcat(input_sysfs_path, input_name); + strcat(input_sysfs_path, "/device/"); + input_sysfs_path_len = strlen(input_sysfs_path); + enable(0, 1); + } +} + +ProximitySensor::~ProximitySensor() { + if (mEnabled) { + enable(0, 0); + } +} + +int ProximitySensor::setInitialState() { + struct input_absinfo absinfo; + if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_PROXIMITY), &absinfo)) { + // make sure to report an event immediately + mHasPendingEvent = true; + mPendingEvent.distance = indexToValue(absinfo.value); + } + return 0; +} + +int ProximitySensor::enable(int32_t, int en) { + int flags = en ? 1 : 0; + if (flags != mEnabled) { + int fd; + strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); + fd = open(input_sysfs_path, O_RDWR); + if (fd >= 0) { + char buf[2]; + buf[1] = 0; + if (flags) { + buf[0] = '1'; + } else { + buf[0] = '0'; + } + write(fd, buf, sizeof(buf)); + close(fd); + mEnabled = flags; + setInitialState(); + return 0; + } + return -1; + } + return 0; +} + +bool ProximitySensor::hasPendingEvents() const { + return mHasPendingEvent; +} + +int ProximitySensor::readEvents(sensors_event_t* data, int count) +{ + if (count < 1) + return -EINVAL; + + if (mHasPendingEvent) { + mHasPendingEvent = false; + mPendingEvent.timestamp = getTimestamp(); + *data = mPendingEvent; + return mEnabled ? 1 : 0; + } + + ssize_t n = mInputReader.fill(data_fd); + if (n < 0) + return n; + + int numEventReceived = 0; + input_event const* event; + + while (count && mInputReader.readEvent(&event)) { + int type = event->type; + if (type == EV_ABS) { + if (event->code == EVENT_TYPE_PROXIMITY) { + if (event->value != -1) { + // FIXME: not sure why we're getting -1 sometimes + mPendingEvent.distance = indexToValue(event->value); + } + } + } else if (type == EV_SYN) { + mPendingEvent.timestamp = timevalToNano(event->time); + if (mEnabled) { + *data++ = mPendingEvent; + count--; + numEventReceived++; + } + } else { + LOGE("ProximitySensor: unknown event (type=%d, code=%d)", + type, event->code); + } + mInputReader.next(); + } + + return numEventReceived; +} + +float ProximitySensor::indexToValue(size_t index) const +{ + return index * PROXIMITY_THRESHOLD_GP2A; +} diff --git a/libsensors/ProximitySensor.h b/libsensors/ProximitySensor.h new file mode 100644 index 0000000..e9f782f --- /dev/null +++ b/libsensors/ProximitySensor.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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_PROXIMITY_SENSOR_H +#define ANDROID_PROXIMITY_SENSOR_H + +#include +#include +#include +#include + +#include "sensors.h" +#include "SensorBase.h" +#include "InputEventReader.h" + +/*****************************************************************************/ + +struct input_event; + +class ProximitySensor : public SensorBase { + int mEnabled; + InputEventCircularReader mInputReader; + sensors_event_t mPendingEvent; + bool mHasPendingEvent; + char input_sysfs_path[PATH_MAX]; + int input_sysfs_path_len; + + int setInitialState(); + float indexToValue(size_t index) const; + +public: + ProximitySensor(); + virtual ~ProximitySensor(); + virtual int readEvents(sensors_event_t* data, int count); + virtual bool hasPendingEvents() const; + virtual int enable(int32_t handle, int enabled); +}; + +/*****************************************************************************/ + +#endif // ANDROID_PROXIMITY_SENSOR_H diff --git a/libsensors/SensorBase.cpp b/libsensors/SensorBase.cpp new file mode 100644 index 0000000..2fe5c2d --- /dev/null +++ b/libsensors/SensorBase.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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 "SensorBase.h" + +/*****************************************************************************/ + +SensorBase::SensorBase( + const char* dev_name, + const char* data_name) + : dev_name(dev_name), data_name(data_name), + dev_fd(-1), data_fd(-1) +{ + if (data_name) { + data_fd = openInput(data_name); + } +} + +SensorBase::~SensorBase() { + if (data_fd >= 0) { + close(data_fd); + } + if (dev_fd >= 0) { + close(dev_fd); + } +} + +int SensorBase::open_device() { + if (dev_fd<0 && dev_name) { + dev_fd = open(dev_name, O_RDONLY); + LOGE_IF(dev_fd<0, "Couldn't open %s (%s)", dev_name, strerror(errno)); + } + return 0; +} + +int SensorBase::close_device() { + if (dev_fd >= 0) { + close(dev_fd); + dev_fd = -1; + } + return 0; +} + +int SensorBase::getFd() const { + if (!data_name) { + return dev_fd; + } + return data_fd; +} + +int SensorBase::setDelay(int32_t handle, int64_t ns) { + return 0; +} + +bool SensorBase::hasPendingEvents() const { + return false; +} + +int64_t SensorBase::getTimestamp() { + struct timespec t; + t.tv_sec = t.tv_nsec = 0; + clock_gettime(CLOCK_MONOTONIC, &t); + return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec; +} + +int SensorBase::openInput(const char* inputName) { + int fd = -1; + const char *dirname = "/dev/input"; + char devname[PATH_MAX]; + char *filename; + DIR *dir; + struct dirent *de; + dir = opendir(dirname); + if(dir == NULL) + return -1; + strcpy(devname, dirname); + filename = devname + strlen(devname); + *filename++ = '/'; + while((de = readdir(dir))) { + if(de->d_name[0] == '.' && + (de->d_name[1] == '\0' || + (de->d_name[1] == '.' && de->d_name[2] == '\0'))) + continue; + strcpy(filename, de->d_name); + fd = open(devname, O_RDONLY); + if (fd>=0) { + char name[80]; + if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) { + name[0] = '\0'; + } + if (!strcmp(name, inputName)) { + strcpy(input_name, filename); + break; + } else { + close(fd); + fd = -1; + } + } + } + closedir(dir); + LOGE_IF(fd<0, "couldn't find '%s' input device", inputName); + return fd; +} diff --git a/libsensors/SensorBase.h b/libsensors/SensorBase.h new file mode 100644 index 0000000..6b4b555 --- /dev/null +++ b/libsensors/SensorBase.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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_SENSOR_BASE_H +#define ANDROID_SENSOR_BASE_H + +#include +#include +#include +#include + + +/*****************************************************************************/ + +struct sensors_event_t; + +class SensorBase { +protected: + const char* dev_name; + const char* data_name; + char input_name[PATH_MAX]; + int dev_fd; + int data_fd; + + int openInput(const char* inputName); + static int64_t getTimestamp(); + + + static int64_t timevalToNano(timeval const& t) { + return t.tv_sec*1000000000LL + t.tv_usec*1000; + } + + int open_device(); + int close_device(); + +public: + SensorBase( + const char* dev_name, + const char* data_name); + + virtual ~SensorBase(); + + virtual int readEvents(sensors_event_t* data, int count) = 0; + virtual bool hasPendingEvents() const; + virtual int getFd() const; + virtual int setDelay(int32_t handle, int64_t ns); + virtual int enable(int32_t handle, int enabled) = 0; +}; + +/*****************************************************************************/ + +#endif // ANDROID_SENSOR_BASE_H diff --git a/libsensors/Smb380Sensor.cpp b/libsensors/Smb380Sensor.cpp new file mode 100644 index 0000000..3de4d9b --- /dev/null +++ b/libsensors/Smb380Sensor.cpp @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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 "Smb380Sensor.h" + + +/*****************************************************************************/ +Smb380Sensor::Smb380Sensor() + : SensorBase(NULL, "accelerometer_sensor"), + mEnabled(0), + + mInputReader(4), + mHasPendingEvent(false) +{ + LOGD("Smb380Sensor::Smb380Sensor()"); + mPendingEvent.version = sizeof(sensors_event_t); + mPendingEvent.sensor = ID_A; + mPendingEvent.type = SENSOR_TYPE_ACCELEROMETER; + memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); + + LOGD("Smb380Sensor::Smb380Sensor() open data_fd"); + + if (data_fd) { + strcpy(input_sysfs_path, "/sys/class/input/"); + strcat(input_sysfs_path, input_name); + strcat(input_sysfs_path, "/device/"); + input_sysfs_path_len = strlen(input_sysfs_path); + + //enable(0, 1); + } +} + +Smb380Sensor::~Smb380Sensor() { + + LOGD("Smb380Sensor::~Smb380Sensor()"); + if (mEnabled) { + enable(0, 0); + } +} + + + +int Smb380Sensor::enable(int32_t, int en) { + + + LOGD("Smb380Sensor::~enable(0, %d)", en); + int flags = en ? 1 : 0; + if (flags != mEnabled) { + int fd; + strcpy(&input_sysfs_path[input_sysfs_path_len], "enable"); + LOGD("Smb380Sensor::~enable(0, %d) open %s",en, input_sysfs_path); + fd = open(input_sysfs_path, O_RDWR); + if (fd >= 0) { + LOGD("Smb380Sensor::~enable(0, %d) opened %s",en, input_sysfs_path); + char buf[2]; + int err; + buf[1] = 0; + if (flags) { + buf[0] = '1'; + } else { + buf[0] = '0'; + } + err = write(fd, buf, sizeof(buf)); + close(fd); + mEnabled = flags; + //setInitialState(); + return 0; + } + return -1; + } + return 0; +} + + +bool Smb380Sensor::hasPendingEvents() const { + /* FIXME probably here should be returning mEnabled but instead + mHasPendingEvents. It does not work, so we cheat.*/ + //LOGD("Smb380Sensor::~hasPendingEvents %d", mHasPendingEvent ? 1 : 0 ); + return mHasPendingEvent; +} + + +int Smb380Sensor::setDelay(int32_t handle, int64_t ns) +{ + LOGD("Smb380Sensor::~setDelay(%d, %d)", handle, ns); + /* FIXME needs changes to the kernel driver. + We need to add a IOCTL that can set the samplingrate + the driver in ther kernel supports this allready only need + to add a IOCTL on both sides for that*/ + return 0; +} + + +int Smb380Sensor::readEvents(sensors_event_t* data, int count) +{ + //LOGD("Smb380Sensor::~readEvents() %d", count); + if (count < 1) + return -EINVAL; + + if (mHasPendingEvent) { + mHasPendingEvent = false; + mPendingEvent.timestamp = getTimestamp(); + *data = mPendingEvent; + return mEnabled ? 1 : 0; + } + + ssize_t n = mInputReader.fill(data_fd); + if (n < 0) + return n; + + int numEventReceived = 0; + input_event const* event; + + while (count && mInputReader.readEvent(&event)) { + int type = event->type; + if (type == EV_REL) { + float value = event->value; + if (event->code == EVENT_TYPE_ACCEL_X) { + mPendingEvent.acceleration.x = value * CONVERT_A_X; + } else if (event->code == EVENT_TYPE_ACCEL_Y) { + mPendingEvent.acceleration.y = value * CONVERT_A_Y; + } else if (event->code == EVENT_TYPE_ACCEL_Z) { + mPendingEvent.acceleration.z = value * CONVERT_A_Z; + } + } else if (type == EV_SYN) { + mPendingEvent.timestamp = timevalToNano(event->time); + if (mEnabled) { + *data++ = mPendingEvent; + count--; + numEventReceived++; + } + } else { + LOGE("Smb380Sensor: unknown event (type=%d, code=%d)", + type, event->code); + } + mInputReader.next(); + } + + //LOGD("Smb380Sensor::~readEvents() numEventReceived = %d", numEventReceived); + return numEventReceived++; + +} diff --git a/libsensors/Smb380Sensor.h b/libsensors/Smb380Sensor.h new file mode 100644 index 0000000..5e55e9b --- /dev/null +++ b/libsensors/Smb380Sensor.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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_SMB380_SENSOR_H +#define ANDROID_SMB380_SENSOR_H + +#include +#include +#include +#include + +#include "sensors.h" +#include "SensorBase.h" +#include "InputEventReader.h" + +/*****************************************************************************/ + + +struct smb380acc_t { + short x, /**< holds x-axis acceleration data sign extended. Range -512 to 511. */ + y, /**< holds y-axis acceleration data sign extended. Range -512 to 511. */ + z; /**< holds z-axis acceleration data sign extended. Range -512 to 511. */ +} ; + +/* smb ioctl command label */ +#define IOCTL_SMB_GET_ACC_VALUE 0 +#define DCM_IOC_MAGIC 's' +#define IOC_SET_ACCELEROMETER _IO (DCM_IOC_MAGIC, 0x64) +#define BMA150_CALIBRATION _IOWR(DCM_IOC_MAGIC,48,short) + +#define SMB_POWER_OFF 0 +#define SMB_POWER_ON 1 + +struct input_event; + +class Smb380Sensor : public SensorBase { + int mEnabled; + InputEventCircularReader mInputReader; + sensors_event_t mPendingEvent; + bool mHasPendingEvent; + char input_sysfs_path[PATH_MAX]; + int input_sysfs_path_len; + + +public: + Smb380Sensor(); + virtual ~Smb380Sensor(); + virtual int readEvents(sensors_event_t* data, int count); + virtual bool hasPendingEvents() const; + virtual int setDelay(int32_t handle, int64_t ns); + virtual int enable(int32_t handle, int enabled); +}; + +/*****************************************************************************/ + +#endif // ANDROID_GYRO_SENSOR_H diff --git a/libsensors/sensors.cpp b/libsensors/sensors.cpp new file mode 100644 index 0000000..2358a2e --- /dev/null +++ b/libsensors/sensors.cpp @@ -0,0 +1,335 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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. + */ + +#define LOG_TAG "Sensors" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +#include +#include + +#include "sensors.h" + +#include "LightSensor.h" +#include "ProximitySensor.h" +//#include "BoschYamaha.h" +#include "Smb380Sensor.h" +#include "CompassSensor.h" +#include "OrientationSensor.h" + +/*****************************************************************************/ + +#define DELAY_OUT_TIME 0x7FFFFFFF + +#define LIGHT_SENSOR_POLLTIME 2000000000 + + +#define SENSORS_ACCELERATION (1<getFd(); + mPollFds[light].events = POLLIN; + mPollFds[light].revents = 0; + + mSensors[proximity] = new ProximitySensor(); + mPollFds[proximity].fd = mSensors[proximity]->getFd(); + mPollFds[proximity].events = POLLIN; + mPollFds[proximity].revents = 0; + + mSensors[bosch] = new Smb380Sensor(); + mPollFds[bosch].fd = mSensors[bosch]->getFd(); + mPollFds[bosch].events = POLLIN; + mPollFds[bosch].revents = 0; + + mSensors[yamaha] = new CompassSensor(); + mPollFds[yamaha].fd = mSensors[yamaha]->getFd(); + mPollFds[yamaha].events = POLLIN; + mPollFds[yamaha].revents = 0; + + mSensors[orientation] = new OrientationSensor(); + mPollFds[orientation].fd = mSensors[orientation]->getFd(); + mPollFds[orientation].events = POLLIN; + mPollFds[orientation].revents = 0; + + int wakeFds[2]; + int result = pipe(wakeFds); + LOGE_IF(result<0, "error creating wake pipe (%s)", strerror(errno)); + fcntl(wakeFds[0], F_SETFL, O_NONBLOCK); + fcntl(wakeFds[1], F_SETFL, O_NONBLOCK); + mWritePipeFd = wakeFds[1]; + + mPollFds[wake].fd = wakeFds[0]; + mPollFds[wake].events = POLLIN; + mPollFds[wake].revents = 0; +} + +sensors_poll_context_t::~sensors_poll_context_t() { + for (int i=0 ; ienable(handle, enabled); + if (enabled && !err) { + const char wakeMessage(WAKE_MESSAGE); + int result = write(mWritePipeFd, &wakeMessage, 1); + LOGE_IF(result<0, "error sending wake message (%s)", strerror(errno)); + } + return err; +} + +int sensors_poll_context_t::setDelay(int handle, int64_t ns) { + + int index = handleToDriver(handle); + if (index < 0) return index; + return mSensors[index]->setDelay(handle, ns); +} + +int sensors_poll_context_t::pollEvents(sensors_event_t* data, int count) +{ + int nbEvents = 0; + int n = 0; + + do { + // see if we have some leftover from the last poll() + for (int i=0 ; count && ihasPendingEvents())) { + int nb = sensor->readEvents(data, count); + if (nb < count) { + // no more data for this sensor + mPollFds[i].revents = 0; + } + count -= nb; + nbEvents += nb; + data += nb; + } + } + + if (count) { + // we still have some room, so try to see if we can get + // some events immediately or just wait if we don't have + // anything to return + n = poll(mPollFds, numFds, nbEvents ? 0 : -1); + if (n<0) { + LOGE("poll() failed (%s)", strerror(errno)); + return -errno; + } + if (mPollFds[wake].revents & POLLIN) { + char msg; + int result = read(mPollFds[wake].fd, &msg, 1); + LOGE_IF(result<0, "error reading from wake pipe (%s)", strerror(errno)); + LOGE_IF(msg != WAKE_MESSAGE, "unknown message on wake queue (0x%02x)", int(msg)); + + mPollFds[wake].revents = 0; + } + } + // if we have events and space, go read them + } while (n && count); + + return nbEvents; +} + +/*****************************************************************************/ + +static int poll__close(struct hw_device_t *dev) +{ + sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; + if (ctx) { + delete ctx; + } + return 0; +} + +static int poll__activate(struct sensors_poll_device_t *dev, + int handle, int enabled) { + sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; + return ctx->activate(handle, enabled); +} + +static int poll__setDelay(struct sensors_poll_device_t *dev, + int handle, int64_t ns) { + sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; + return ctx->setDelay(handle, ns); +} + +static int poll__poll(struct sensors_poll_device_t *dev, + sensors_event_t* data, int count) { + sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev; + return ctx->pollEvents(data, count); +} + +/*****************************************************************************/ + +/** Open a new instance of a sensor device using name */ +static int open_sensors(const struct hw_module_t* module, const char* id, + struct hw_device_t** device) +{ + int status = -EINVAL; + sensors_poll_context_t *dev = new sensors_poll_context_t(); + + memset(&dev->device, 0, sizeof(sensors_poll_device_t)); + + dev->device.common.tag = HARDWARE_DEVICE_TAG; + dev->device.common.version = 0; + dev->device.common.module = const_cast(module); + dev->device.common.close = poll__close; + dev->device.activate = poll__activate; + dev->device.setDelay = poll__setDelay; + dev->device.poll = poll__poll; + + *device = &dev->device.common; + status = 0; + + return status; +} + diff --git a/libsensors/sensors.h b/libsensors/sensors.h new file mode 100644 index 0000000..4943fc1 --- /dev/null +++ b/libsensors/sensors.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * 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_SENSORS_H +#define ANDROID_SENSORS_H + +#include +#include +#include +#include + +#include + +#include +#include + +__BEGIN_DECLS + +/*****************************************************************************/ + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + +#define ID_A (0) +#define ID_M (1) +#define ID_O (2) +#define ID_L (3) +#define ID_P (4) +#define ID_GY (5) + +/*****************************************************************************/ + +/* + * The SENSORS Module + */ + +/* the GP2A is a binary proximity sensor that triggers around 5 cm on + * this hardware */ +#define PROXIMITY_THRESHOLD_GP2A 5.0f + +/*****************************************************************************/ + +#define AKM_DEVICE_NAME "/dev/akm8973_aot" + + +#define EVENT_TYPE_ACCEL_X ABS_X +#define EVENT_TYPE_ACCEL_Y ABS_Y +#define EVENT_TYPE_ACCEL_Z ABS_Z + +#define EVENT_TYPE_YAW REL_X +#define EVENT_TYPE_PITCH REL_Y +#define EVENT_TYPE_ROLL REL_Z +#define EVENT_TYPE_ORIENT_STATUS REL_WHEEL + +/* For AK8973iB */ +#define EVENT_TYPE_MAGV_X ABS_X +#define EVENT_TYPE_MAGV_Y ABS_Y +#define EVENT_TYPE_MAGV_Z ABS_Z + +#define EVENT_TYPE_PROXIMITY ABS_DISTANCE +#define EVENT_TYPE_LIGHT ABS_MISC + +#define EVENT_TYPE_GYRO_X REL_RY +#define EVENT_TYPE_GYRO_Y REL_RX +#define EVENT_TYPE_GYRO_Z REL_RZ + + +// 720 LSG = 1G +#define LSG (720.0f) +#define NUMOFACCDATA 8 + +// conversion of acceleration data to SI units (m/s^2) +#define RANGE_A (2*GRAVITY_EARTH) +#define RESOLUTION_A (RANGE_A/(512)) +#define CONVERT_A (RANGE_A/(512)) +#define CONVERT_A_X (CONVERT_A) +#define CONVERT_A_Y (CONVERT_A) +#define CONVERT_A_Z (CONVERT_A) + +// conversion of magnetic data to uT units +#define CONVERT_M (1.0f/1000.0f) +#define CONVERT_M_X (CONVERT_M) +#define CONVERT_M_Y (CONVERT_M) +#define CONVERT_M_Z (CONVERT_M) + +/* conversion of orientation data to degree units */ +#define CONVERT_O (1.0f/1000.0f) +#define CONVERT_O_A (CONVERT_O) +#define CONVERT_O_P (CONVERT_O) +#define CONVERT_O_R (CONVERT_O) + +// conversion of gyro data to SI units (radian/sec) +#define RANGE_GYRO (2000.0f*(float)M_PI/180.0f) +#define CONVERT_GYRO ((70.0f / 1000.0f) * ((float)M_PI / 180.0f)) +#define CONVERT_GYRO_X (CONVERT_GYRO) +#define CONVERT_GYRO_Y (-CONVERT_GYRO) +#define CONVERT_GYRO_Z (CONVERT_GYRO) + +#define SENSOR_STATE_MASK (0x7FFF) + +/*****************************************************************************/ + +__END_DECLS + +#endif // ANDROID_SENSORS_H diff --git a/libstagefrighthw/Android.mk b/libstagefrighthw/Android.mk new file mode 100644 index 0000000..7716541 --- /dev/null +++ b/libstagefrighthw/Android.mk @@ -0,0 +1,27 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + stagefright_overlay_output.cpp \ + SecHardwareRenderer.cpp \ + SEC_OMX_Plugin.cpp + +LOCAL_CFLAGS += $(PV_CFLAGS_MINUS_VISIBILITY) + +LOCAL_C_INCLUDES:= \ + $(TOP)/frameworks/base/include/media/stagefright/openmax \ + $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../liboverlay + +LOCAL_SHARED_LIBRARIES := \ + libbinder \ + libutils \ + libcutils \ + libui \ + libdl \ + libsurfaceflinger_client + +LOCAL_MODULE := libstagefrighthw + +LOCAL_MODULE_TAGS := optional +include $(BUILD_SHARED_LIBRARY) diff --git a/libstagefrighthw/SEC_OMX_Plugin.cpp b/libstagefrighthw/SEC_OMX_Plugin.cpp new file mode 100644 index 0000000..0bb70c5 --- /dev/null +++ b/libstagefrighthw/SEC_OMX_Plugin.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * 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 "SEC_OMX_Plugin.h" + +#include + +#include +#include + +namespace android { + +OMXPluginBase *createOMXPlugin() { + return new SECOMXPlugin; +} + +SECOMXPlugin::SECOMXPlugin() + : mLibHandle(dlopen("libSEC_OMX_Core.aries.so", RTLD_NOW)), + mInit(NULL), + mDeinit(NULL), + mComponentNameEnum(NULL), + mGetHandle(NULL), + mFreeHandle(NULL), + mGetRolesOfComponentHandle(NULL) { + if (mLibHandle != NULL) { + mInit = (InitFunc)dlsym(mLibHandle, "SEC_OMX_Init"); + mDeinit = (DeinitFunc)dlsym(mLibHandle, "SEC_OMX_DeInit"); + + mComponentNameEnum = + (ComponentNameEnumFunc)dlsym(mLibHandle, "SEC_OMX_ComponentNameEnum"); + + mGetHandle = (GetHandleFunc)dlsym(mLibHandle, "SEC_OMX_GetHandle"); + mFreeHandle = (FreeHandleFunc)dlsym(mLibHandle, "SEC_OMX_FreeHandle"); + + mGetRolesOfComponentHandle = + (GetRolesOfComponentFunc)dlsym( + mLibHandle, "SEC_OMX_GetRolesOfComponent"); + + (*mInit)(); + + } +} + +SECOMXPlugin::~SECOMXPlugin() { + if (mLibHandle != NULL) { + (*mDeinit)(); + + dlclose(mLibHandle); + mLibHandle = NULL; + } +} + +OMX_ERRORTYPE SECOMXPlugin::makeComponentInstance( + const char *name, + const OMX_CALLBACKTYPE *callbacks, + OMX_PTR appData, + OMX_COMPONENTTYPE **component) { + if (mLibHandle == NULL) { + return OMX_ErrorUndefined; + } + + return (*mGetHandle)( + reinterpret_cast(component), + const_cast(name), + appData, const_cast(callbacks)); +} + +OMX_ERRORTYPE SECOMXPlugin::destroyComponentInstance( + OMX_COMPONENTTYPE *component) { + if (mLibHandle == NULL) { + return OMX_ErrorUndefined; + } + + return (*mFreeHandle)(reinterpret_cast(component)); +} + +OMX_ERRORTYPE SECOMXPlugin::enumerateComponents( + OMX_STRING name, + size_t size, + OMX_U32 index) { + if (mLibHandle == NULL) { + return OMX_ErrorUndefined; + } + + return (*mComponentNameEnum)(name, size, index); +} + +OMX_ERRORTYPE SECOMXPlugin::getRolesOfComponent( + const char *name, + Vector *roles) { + roles->clear(); + + if (mLibHandle == NULL) { + return OMX_ErrorUndefined; + } + + OMX_U32 numRoles; + OMX_ERRORTYPE err = (*mGetRolesOfComponentHandle)( + const_cast(name), &numRoles, NULL); + + if (err != OMX_ErrorNone) { + return err; + } + + if (numRoles > 0) { + OMX_U8 **array = new OMX_U8 *[numRoles]; + for (OMX_U32 i = 0; i < numRoles; ++i) { + array[i] = new OMX_U8[OMX_MAX_STRINGNAME_SIZE]; + } + + OMX_U32 numRoles2; + err = (*mGetRolesOfComponentHandle)( + const_cast(name), &numRoles2, array); + + CHECK_EQ(err, OMX_ErrorNone); + CHECK_EQ(numRoles, numRoles2); + + for (OMX_U32 i = 0; i < numRoles; ++i) { + String8 s((const char *)array[i]); + roles->push(s); + + delete[] array[i]; + array[i] = NULL; + } + + delete[] array; + array = NULL; + } + + return OMX_ErrorNone; +} + +} // namespace android + diff --git a/libstagefrighthw/SEC_OMX_Plugin.h b/libstagefrighthw/SEC_OMX_Plugin.h new file mode 100644 index 0000000..6df2d31 --- /dev/null +++ b/libstagefrighthw/SEC_OMX_Plugin.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * 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 SEC_OMX_PLUGIN + +#define SEC_OMX_PLUGIN + +#include + +namespace android { + +struct SECOMXPlugin : public OMXPluginBase { + SECOMXPlugin(); + virtual ~SECOMXPlugin(); + + virtual OMX_ERRORTYPE makeComponentInstance( + const char *name, + const OMX_CALLBACKTYPE *callbacks, + OMX_PTR appData, + OMX_COMPONENTTYPE **component); + + virtual OMX_ERRORTYPE destroyComponentInstance( + OMX_COMPONENTTYPE *component); + + virtual OMX_ERRORTYPE enumerateComponents( + OMX_STRING name, + size_t size, + OMX_U32 index); + + virtual OMX_ERRORTYPE getRolesOfComponent( + const char *name, + Vector *roles); + +private: + void *mLibHandle; + + typedef OMX_ERRORTYPE (*InitFunc)(); + typedef OMX_ERRORTYPE (*DeinitFunc)(); + typedef OMX_ERRORTYPE (*ComponentNameEnumFunc)( + OMX_STRING, OMX_U32, OMX_U32); + + typedef OMX_ERRORTYPE (*GetHandleFunc)( + OMX_HANDLETYPE *, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE *); + + typedef OMX_ERRORTYPE (*FreeHandleFunc)(OMX_HANDLETYPE *); + + typedef OMX_ERRORTYPE (*GetRolesOfComponentFunc)( + OMX_STRING, OMX_U32 *, OMX_U8 **); + + InitFunc mInit; + DeinitFunc mDeinit; + ComponentNameEnumFunc mComponentNameEnum; + GetHandleFunc mGetHandle; + FreeHandleFunc mFreeHandle; + GetRolesOfComponentFunc mGetRolesOfComponentHandle; + + SECOMXPlugin(const SECOMXPlugin &); + SECOMXPlugin &operator=(const SECOMXPlugin &); +}; + +} // namespace android + +#endif // SEC_OMX_PLUGIN diff --git a/libstagefrighthw/SecHardwareRenderer.cpp b/libstagefrighthw/SecHardwareRenderer.cpp new file mode 100644 index 0000000..cb9e8e8 --- /dev/null +++ b/libstagefrighthw/SecHardwareRenderer.cpp @@ -0,0 +1,228 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * 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. + */ + +#define LOG_TAG "SecHardwareRenderer" +#define LOG_NDEBUG 0 +#include + +#include "SecHardwareRenderer.h" + +#include +#include +#include + +#include + +#include "v4l2_utils.h" +#include "utils/Timers.h" + +#define CACHEABLE_BUFFERS 0x1 + +#define USE_ZERO_COPY +//#define SEC_DEBUG + +namespace android { + +//////////////////////////////////////////////////////////////////////////////// + +SecHardwareRenderer::SecHardwareRenderer( + const sp &surface, + size_t displayWidth, size_t displayHeight, + size_t decodedWidth, size_t decodedHeight, + OMX_COLOR_FORMATTYPE colorFormat, + int32_t rotationDegrees, + bool fromHardwareDecoder) + : mISurface(surface), + mDisplayWidth(displayWidth), + mDisplayHeight(displayHeight), + mDecodedWidth(decodedWidth), + mDecodedHeight(decodedHeight), + mColorFormat(colorFormat), + mInitCheck(NO_INIT), + mFrameSize(mDecodedWidth * mDecodedHeight * 2), + mIsFirstFrame(true), + mCustomFormat(false), + mIndex(0) { + + CHECK(mISurface.get() != NULL); + CHECK(mDecodedWidth > 0); + CHECK(mDecodedHeight > 0); + + if (colorFormat != OMX_COLOR_FormatCbYCrY + && colorFormat != OMX_COLOR_FormatYUV420Planar + && colorFormat != OMX_COLOR_FormatYUV420SemiPlanar) { + LOGE("Invalid colorFormat (0x%x)", colorFormat); + return; + } + + uint32_t orientation; + switch (rotationDegrees) { + case 0: orientation = ISurface::BufferHeap::ROT_0; break; + case 90: orientation = ISurface::BufferHeap::ROT_90; break; + case 180: orientation = ISurface::BufferHeap::ROT_180; break; + case 270: orientation = ISurface::BufferHeap::ROT_270; break; + default: orientation = ISurface::BufferHeap::ROT_0; break; + } + + sp ref; + +#if defined (USE_ZERO_COPY) + if (fromHardwareDecoder) { + ref = mISurface->createOverlay( + mDecodedWidth, mDecodedHeight, + HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP, orientation); + mCustomFormat = true; + } +#else + else + { + ref = mISurface->createOverlay( + mDecodedWidth, mDecodedHeight, HAL_PIXEL_FORMAT_YCbCr_420_P, + orientation); + } +#endif + + if (ref.get() == NULL) { + LOGE("Unable to create the overlay!"); + return; + } + + mOverlay = new Overlay(ref); + mOverlay->setParameter(CACHEABLE_BUFFERS, 0); + + mNumBuf = mOverlay->getBufferCount(); + + if (mCustomFormat) { + mFrameSize = 32; + mMemoryHeap = new MemoryHeapBase(mNumBuf * mFrameSize); + } else { + for (size_t i = 0; i < (size_t)mNumBuf; ++i) { + void *addr = mOverlay->getBufferAddress((void *)i); + mOverlayAddresses.push(addr); + } + } + + mInitCheck = OK; +} + +SecHardwareRenderer::~SecHardwareRenderer() { + + if(mMemoryHeap != NULL) + mMemoryHeap.clear(); + + if (mOverlay.get() != NULL) { + mOverlay->destroy(); + mOverlay.clear(); + } +} + +void SecHardwareRenderer::handleYUV420Planar( + const void *data, size_t size) { + + int FrameSize; + uint8_t* pPhyYAddr; + uint8_t* pPhyCAddr; + int AddrSize; + size_t offset; + + CHECK(size >= (mDecodedWidth * mDecodedHeight * 3) / 2); + + offset = mIndex * mFrameSize; + void *dst = (uint8_t *)mMemoryHeap->getBase() + offset; + + AddrSize = sizeof(void *); + memcpy(&FrameSize, data, sizeof(FrameSize)); + memcpy(&pPhyYAddr, data + sizeof(FrameSize), sizeof(pPhyYAddr)); + memcpy(&pPhyCAddr, data + sizeof(FrameSize) + (AddrSize * 1), sizeof(pPhyCAddr)); + + memcpy(dst , &pPhyYAddr, sizeof(pPhyYAddr)); + memcpy(dst + sizeof(pPhyYAddr) , &pPhyCAddr, sizeof(pPhyCAddr)); + memcpy(dst + sizeof(pPhyYAddr) + sizeof(pPhyCAddr), &mIndex, sizeof(mIndex)); +} + +void SecHardwareRenderer::render( + const void *data, size_t size, void *platformPrivate) { + + if (mOverlay.get() == NULL) { + return; + } + + if (mCustomFormat) { + /* zero copy solution case */ + + overlay_buffer_t dst = (uint8_t *)mMemoryHeap->getBase() + mIndex*mFrameSize; + + if (mColorFormat == OMX_COLOR_FormatYUV420Planar || + mColorFormat == OMX_COLOR_FormatYUV420SemiPlanar) { + handleYUV420Planar(data, size); + } + + if (mOverlay->queueBuffer(dst) == ALL_BUFFERS_FLUSHED) { + mIsFirstFrame = true; + if (mOverlay->queueBuffer((void *)dst) != 0) { + return; + } + } + + if (++mIndex == mNumBuf) { + mIndex = 0; + } + + overlay_buffer_t overlay_buffer; + if (!mIsFirstFrame) { + status_t err = mOverlay->dequeueBuffer(&overlay_buffer); + if (err == ALL_BUFFERS_FLUSHED) { + mIsFirstFrame = true; + } else { + return; + } + } else { + mIsFirstFrame = false; + } + } else { + /* normal frame case */ + if (mColorFormat == OMX_COLOR_FormatYUV420Planar) { + memcpy(mOverlayAddresses[mIndex], data, size); + } + + if (mOverlay->queueBuffer((void *)mIndex) == ALL_BUFFERS_FLUSHED) { + mIsFirstFrame = true; + if (mOverlay->queueBuffer((void *)mIndex) != 0) { + return; + } + } + + if (++mIndex == mNumBuf) { + mIndex = 0; + } + + overlay_buffer_t overlay_buffer; + if (!mIsFirstFrame) { + status_t err = mOverlay->dequeueBuffer(&overlay_buffer); + + if (err == ALL_BUFFERS_FLUSHED) { + mIsFirstFrame = true; + } else { + return; + } + } else { + mIsFirstFrame = false; + } + } +} + +} // namespace android + diff --git a/libstagefrighthw/SecHardwareRenderer.h b/libstagefrighthw/SecHardwareRenderer.h new file mode 100644 index 0000000..3fad243 --- /dev/null +++ b/libstagefrighthw/SecHardwareRenderer.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * 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 SEC_HARDWARE_RENDERER_H_ + +#define SEC_HARDWARE_RENDERER_H_ + +#include +#include +#include + +#include + +#include +#include + +namespace android { + +class ISurface; +class Overlay; + +class SecHardwareRenderer : public VideoRenderer { +public: + SecHardwareRenderer( + const sp &surface, + size_t displayWidth, size_t displayHeight, + size_t decodedWidth, size_t decodedHeight, + OMX_COLOR_FORMATTYPE colorFormat, + int32_t rotationDegrees, + bool fromHardwareDecoder); + + virtual ~SecHardwareRenderer(); + + status_t initCheck() const { return mInitCheck; } + + virtual void render( + const void *data, size_t size, void *platformPrivate); + + +private: + sp mISurface; + size_t mDisplayWidth, mDisplayHeight; + size_t mDecodedWidth, mDecodedHeight; + OMX_COLOR_FORMATTYPE mColorFormat; + status_t mInitCheck; + size_t mFrameSize; + sp mOverlay; + sp mMemoryHeap; + Vector mOverlayAddresses; + bool mIsFirstFrame; + int mNumBuf; + size_t mIndex; + bool mCustomFormat; + + + SecHardwareRenderer(const SecHardwareRenderer &); + SecHardwareRenderer &operator=(const SecHardwareRenderer &); + + void handleYUV420Planar(const void *, size_t); +}; + +} // namespace android + +#endif // SEC_HARDWARE_RENDERER_H_ + diff --git a/libstagefrighthw/stagefright_overlay_output.cpp b/libstagefrighthw/stagefright_overlay_output.cpp new file mode 100644 index 0000000..fce1d7e --- /dev/null +++ b/libstagefrighthw/stagefright_overlay_output.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * 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 "SecHardwareRenderer.h" + +#include + +using android::sp; +using android::ISurface; +using android::VideoRenderer; + +VideoRenderer *createRendererWithRotation( + const sp &surface, + const char *componentName, + OMX_COLOR_FORMATTYPE colorFormat, + size_t displayWidth, size_t displayHeight, + size_t decodedWidth, size_t decodedHeight, + int32_t rotationDegrees) { + using android::SecHardwareRenderer; + + bool fromHardwareDecoder = !strncmp(componentName, "OMX.SEC.", 8); + + SecHardwareRenderer *renderer = + new SecHardwareRenderer( + surface, displayWidth, displayHeight, + decodedWidth, decodedHeight, + colorFormat, + rotationDegrees, + fromHardwareDecoder); + + if (renderer->initCheck() != android::OK) { + delete renderer; + renderer = NULL; + } + + return renderer; +} + diff --git a/mkshbootimg.py b/mkshbootimg.py new file mode 100755 index 0000000..dcc8294 --- /dev/null +++ b/mkshbootimg.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +import sys, os + +def copydata(outfile, infile): + while 1: + data = infile.read(512) + if (data): + outfile.write(data) + else: + break + +def alignoffset(outfile): + offset = outfile.tell() + outfile.seek((offset + 511) & ~511) + return outfile.tell() + +def appendimage(outfile, infile): + offset = alignoffset(outfile) + copydata(outfile, infile) + length = alignoffset(outfile) - offset + assert (offset % 512 == 0) + assert (length % 512 == 0) + return (offset/512, length/512) + +if len(sys.argv) < 4: + print "Usage:", sys.argv[0], "output kernel boot [recovery]" + sys.exit(1) + +outfile = open(sys.argv[1], 'wb') +kernel = open(sys.argv[2], 'r') +boot = open(sys.argv[3], 'r') +recovery = None +if (len(sys.argv) == 5): + recovery = open(sys.argv[4], 'r') +offset_table = "\n\nBOOT_IMAGE_OFFSETS\n" +copydata(outfile, kernel) +table_loc = alignoffset(outfile) +outfile.write('\x00' * 512) +offset_table += "boot_offset=%d;boot_len=%d;" % appendimage(outfile, boot) +if recovery: + offset_table += "recovery_offset=%d;recovery_len=%d;" % appendimage(outfile, recovery) +offset_table += "\n\n" +outfile.seek(table_loc) +outfile.write(offset_table) +outfile.flush() +os.fsync(outfile.fileno()) +outfile.close() diff --git a/sec_mm/Android.mk b/sec_mm/Android.mk new file mode 100644 index 0000000..6571161 --- /dev/null +++ b/sec_mm/Android.mk @@ -0,0 +1 @@ +include $(all-subdir-makefiles) diff --git a/sec_mm/sec_omx/Android.mk b/sec_mm/sec_omx/Android.mk new file mode 100644 index 0000000..cbae428 --- /dev/null +++ b/sec_mm/sec_omx/Android.mk @@ -0,0 +1,22 @@ + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +SEC_OMX_TOP := $(LOCAL_PATH) +SEC_CODECS := $(SEC_OMX_TOP)/sec_codecs/ + +SEC_OMX_INC := $(SEC_OMX_TOP)/sec_omx_include/ +SEC_OMX_COMPONENT := $(SEC_OMX_TOP)/sec_omx_component + +include $(SEC_OMX_TOP)/sec_osal/Android.mk +include $(SEC_OMX_TOP)/sec_omx_core/Android.mk + +include $(SEC_CODECS)/Android.mk +include $(SEC_OMX_COMPONENT)/common/Android.mk +include $(SEC_OMX_COMPONENT)/video/dec/Android.mk +include $(SEC_OMX_COMPONENT)/video/dec/h264dec/Android.mk +include $(SEC_OMX_COMPONENT)/video/dec/mpeg4dec/Android.mk +include $(SEC_OMX_COMPONENT)/video/enc/Android.mk +include $(SEC_OMX_COMPONENT)/video/enc/h264enc/Android.mk +include $(SEC_OMX_COMPONENT)/video/enc/mpeg4enc/Android.mk diff --git a/sec_mm/sec_omx/sec_codecs/Android.mk b/sec_mm/sec_omx/sec_codecs/Android.mk new file mode 100644 index 0000000..a51a075 --- /dev/null +++ b/sec_mm/sec_omx/sec_codecs/Android.mk @@ -0,0 +1,7 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +include $(SEC_CODECS)/video/mfc_c110/dec/Android.mk +include $(SEC_CODECS)/video/mfc_c110/enc/Android.mk + diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/Android.mk b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/Android.mk new file mode 100644 index 0000000..a694deb --- /dev/null +++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/Android.mk @@ -0,0 +1,26 @@ + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := \ + src/SsbSipMfcDecAPI.c + +LOCAL_MODULE := libsecmfcdecapi.aries + +LOCAL_PRELINK_MODULE := false + +LOCAL_CFLAGS := + +LOCAL_ARM_MODE := arm + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := liblog + +LOCAL_C_INCLUDES := \ + $(SEC_CODECS)/video/mfc_c110/include + +include $(BUILD_STATIC_LIBRARY) + diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/src/SsbSipMfcDecAPI.c b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/src/SsbSipMfcDecAPI.c new file mode 100644 index 0000000..508f290 --- /dev/null +++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/src/SsbSipMfcDecAPI.c @@ -0,0 +1,675 @@ +/* + * Copyright 2010 Samsung Electronics Co. LTD + * + * 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 "mfc_interface.h" +#include "SsbSipMfcApi.h" + +#define _MFCLIB_MAGIC_NUMBER 0x92241000 + +#define USR_DATA_START_CODE (0x000001B2) +#define VOP_START_CODE (0x000001B6) +#define MP4_START_CODE (0x000001) + +static void getAByte(char *buff, int *code) +{ + int byte; + + *code = (*code << 8); + byte = (int)*buff; + byte &= 0xFF; + *code |= byte; +} + +static mfc_packed_mode isPBPacked(_MFCLIB *pCtx, int length) +{ + char *strmBuffer = NULL; + char *strmBufferEnd = NULL; + int startCode = 0xFFFFFFFF; + + strmBuffer = (char *)pCtx->virStrmBuf; + strmBufferEnd = (char *)pCtx->virStrmBuf + length; + + while (1) { + while (startCode != USR_DATA_START_CODE) { + if (startCode == VOP_START_CODE) { + LOGV("isPBPacked: VOP START Found !!.....return\n"); + LOGV("isPBPacked: Non Packed PB\n"); + return MFC_UNPACKED_PB; + } + getAByte(strmBuffer, &startCode); + strmBuffer++; + if (strmBuffer >= strmBufferEnd) + goto out; + } + LOGV("isPBPacked: User Data Found !!\n"); + + do { + if (*strmBuffer == 'p') { + LOGI("isPBPacked: Packed PB\n"); + return MFC_PACKED_PB; + } + getAByte(strmBuffer, &startCode); + strmBuffer++; + if (strmBuffer >= strmBufferEnd) + goto out; + } while ((startCode >> 8) != MP4_START_CODE); + } + +out: + LOGV("isPBPacked: Non Packed PB\n"); + return MFC_UNPACKED_PB; +} + +void *SsbSipMfcDecOpen(void) +{ + int hMFCOpen; + unsigned int mapped_addr; + _MFCLIB *pCTX; + + pCTX = (_MFCLIB *)malloc(sizeof(_MFCLIB)); + if (pCTX == NULL) { + LOGE("SsbSipMfcDecOpen: malloc failed.\n"); + return NULL; + } + memset(pCTX, 0, sizeof(_MFCLIB)); + + hMFCOpen = open(S5PC110_MFC_DEV_NAME, O_RDWR | O_NDELAY); + if (hMFCOpen < 0) { + LOGE("SsbSipMfcDecOpen: MFC Open failure\n"); + return NULL; + } + + mapped_addr = (unsigned int)mmap(0, MMAP_BUFFER_SIZE_MMAP, PROT_READ | PROT_WRITE, MAP_SHARED, hMFCOpen, 0); + if (!mapped_addr) { + LOGE("SsbSipMfcDecOpen: FIMV5.0 driver address mapping failed\n"); + return NULL; + } + + pCTX->magic = _MFCLIB_MAGIC_NUMBER; + pCTX->hMFC = hMFCOpen; + pCTX->mapped_addr = mapped_addr; + pCTX->inter_buff_status = MFC_USE_NONE; + + return (void *)pCTX; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcDecInit(void *openHandle, SSBSIP_MFC_CODEC_TYPE codec_type, int Frameleng) +{ + int ret_code; + int packedPB = MFC_UNPACKED_PB; + mfc_common_args DecArg; + _MFCLIB *pCTX; + + if (openHandle == NULL) { + LOGE("SsbSipMfcDecSetConfig: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX = (_MFCLIB *)openHandle; + memset(&DecArg, 0x00, sizeof(DecArg)); + + if ((codec_type != MPEG4_DEC) && + (codec_type != H264_DEC) && + (codec_type != H263_DEC) && + (codec_type != MPEG1_DEC) && + (codec_type != MPEG2_DEC) && + (codec_type != FIMV1_DEC) && + (codec_type != FIMV2_DEC) && + (codec_type != FIMV3_DEC) && + (codec_type != FIMV4_DEC) && + (codec_type != XVID_DEC) && + (codec_type != VC1RCV_DEC) && + (codec_type != VC1_DEC)) { + LOGE("SsbSipMfcDecOpen: Undefined codec type.\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX->codec_type = codec_type; + + if ((pCTX->codec_type == MPEG4_DEC) || + (pCTX->codec_type == FIMV1_DEC) || + (pCTX->codec_type == FIMV2_DEC) || + (pCTX->codec_type == FIMV3_DEC) || + (pCTX->codec_type == FIMV4_DEC) || + (pCTX->codec_type == XVID_DEC)) + packedPB = isPBPacked(pCTX, Frameleng); + + /* init args */ + DecArg.args.dec_init.in_codec_type = pCTX->codec_type; + DecArg.args.dec_init.in_strm_size = Frameleng; + DecArg.args.dec_init.in_strm_buf = pCTX->phyStrmBuf; + DecArg.args.dec_init.in_packed_PB = packedPB; + + /* mem alloc args */ + DecArg.args.dec_init.in_mapped_addr = pCTX->mapped_addr; + + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_DEC_INIT, &DecArg); + if (DecArg.ret_code != MFC_RET_OK) { + LOGE("SsbSipMfcDecInit: IOCTL_MFC_DEC_INIT (%d) failed\n", DecArg.ret_code); + return MFC_RET_DEC_INIT_FAIL; + } + + pCTX->decOutInfo.img_width = DecArg.args.dec_init.out_img_width; + pCTX->decOutInfo.img_height = DecArg.args.dec_init.out_img_height; + pCTX->decOutInfo.buf_width = DecArg.args.dec_init.out_buf_width; + pCTX->decOutInfo.buf_height = DecArg.args.dec_init.out_buf_height; + + /* by RainAde : crop information */ + pCTX->decOutInfo.crop_top_offset = DecArg.args.dec_init.out_crop_top_offset; + pCTX->decOutInfo.crop_bottom_offset = DecArg.args.dec_init.out_crop_bottom_offset; + pCTX->decOutInfo.crop_left_offset = DecArg.args.dec_init.out_crop_left_offset; + pCTX->decOutInfo.crop_right_offset = DecArg.args.dec_init.out_crop_right_offset; + + pCTX->virFrmBuf.luma = DecArg.args.dec_init.out_u_addr.luma; + pCTX->virFrmBuf.chroma = DecArg.args.dec_init.out_u_addr.chroma; + + pCTX->phyFrmBuf.luma = DecArg.args.dec_init.out_p_addr.luma; + pCTX->phyFrmBuf.chroma = DecArg.args.dec_init.out_p_addr.chroma; + pCTX->sizeFrmBuf.luma = DecArg.args.dec_init.out_frame_buf_size.luma; + pCTX->sizeFrmBuf.chroma = DecArg.args.dec_init.out_frame_buf_size.chroma; + pCTX->inter_buff_status |= MFC_USE_YUV_BUFF; + + return MFC_RET_OK; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcDecExe(void *openHandle, int lengthBufFill) +{ + int ret_code; + int Yoffset; + int Coffset; + _MFCLIB *pCTX; + mfc_common_args DecArg; + + if (openHandle == NULL) { + LOGE("SsbSipMfcDecExe: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + if ((lengthBufFill < 0) || (lengthBufFill > MAX_DECODER_INPUT_BUFFER_SIZE)) { + LOGE("SsbSipMfcDecExe: lengthBufFill is invalid. (lengthBufFill=%d)\n", lengthBufFill); + return MFC_RET_INVALID_PARAM; + } + + pCTX = (_MFCLIB *)openHandle; + memset(&DecArg, 0x00, sizeof(DecArg)); + + DecArg.args.dec_exe.in_codec_type = pCTX->codec_type; + DecArg.args.dec_exe.in_strm_buf = pCTX->phyStrmBuf; + DecArg.args.dec_exe.in_strm_size = lengthBufFill; + DecArg.args.dec_exe.in_frm_buf.luma = pCTX->phyFrmBuf.luma; + DecArg.args.dec_exe.in_frm_buf.chroma = pCTX->phyFrmBuf.chroma; + DecArg.args.dec_exe.in_frm_size.luma = pCTX->sizeFrmBuf.luma; + DecArg.args.dec_exe.in_frm_size.chroma = pCTX->sizeFrmBuf.chroma; + DecArg.args.dec_exe.in_frametag = pCTX->in_frametag; + + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_DEC_EXE, &DecArg); + if (DecArg.ret_code != MFC_RET_OK) { + LOGE("SsbSipMfcDecExe: IOCTL_MFC_DEC_EXE failed(ret : %d)\n", DecArg.ret_code); + return MFC_RET_DEC_EXE_ERR; + } + + Yoffset = DecArg.args.dec_exe.out_display_Y_addr - DecArg.args.dec_exe.in_frm_buf.luma; + Coffset = DecArg.args.dec_exe.out_display_C_addr - DecArg.args.dec_exe.in_frm_buf.chroma; + + pCTX->decOutInfo.YPhyAddr = (void *)(DecArg.args.dec_exe.out_display_Y_addr); + pCTX->decOutInfo.CPhyAddr = (void *)(DecArg.args.dec_exe.out_display_C_addr); + pCTX->decOutInfo.YVirAddr = (void *)(pCTX->virFrmBuf.luma + Yoffset); + pCTX->decOutInfo.CVirAddr = (void *)(pCTX->virFrmBuf.chroma + Coffset); + pCTX->decOutInfo.timestamp_top = DecArg.args.dec_exe.out_timestamp_top; + pCTX->decOutInfo.timestamp_bottom = DecArg.args.dec_exe.out_timestamp_bottom; + pCTX->decOutInfo.consumedByte = DecArg.args.dec_exe.out_consume_bytes; + pCTX->decOutInfo.res_change = DecArg.args.dec_exe.out_res_change; + pCTX->decOutInfo.crop_top_offset = DecArg.args.dec_exe.out_crop_top_offset; + pCTX->decOutInfo.crop_bottom_offset = DecArg.args.dec_exe.out_crop_bottom_offset; + pCTX->decOutInfo.crop_left_offset = DecArg.args.dec_exe.out_crop_left_offset; + pCTX->decOutInfo.crop_right_offset = DecArg.args.dec_exe.out_crop_right_offset; + pCTX->out_frametag_top = DecArg.args.dec_exe.out_frametag_top; + pCTX->out_frametag_bottom = DecArg.args.dec_exe.out_frametag_bottom; + pCTX->displayStatus = DecArg.args.dec_exe.out_display_status; + + return MFC_RET_OK; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcDecClose(void *openHandle) +{ + int ret_code; + _MFCLIB *pCTX; + mfc_common_args free_arg; + + if (openHandle == NULL) { + LOGE("SsbSipMfcDecClose: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX = (_MFCLIB *)openHandle; + + if (pCTX->inter_buff_status & MFC_USE_YUV_BUFF) { + free_arg.args.mem_free.u_addr = pCTX->virFrmBuf.luma; + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_FREE_BUF, &free_arg); + free_arg.args.mem_free.u_addr = pCTX->virFrmBuf.chroma; + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_FREE_BUF, &free_arg); + } + + if (pCTX->inter_buff_status & MFC_USE_STRM_BUFF) { + free_arg.args.mem_free.u_addr = pCTX->virStrmBuf; + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_FREE_BUF, &free_arg); + } + + pCTX->inter_buff_status = MFC_USE_NONE; + + munmap((void *)pCTX->mapped_addr, MMAP_BUFFER_SIZE_MMAP); + close(pCTX->hMFC); + free(pCTX); + + return MFC_RET_OK; +} + +void *SsbSipMfcDecGetInBuf(void *openHandle, void **phyInBuf, int inputBufferSize) +{ + int ret_code; + _MFCLIB *pCTX; + mfc_common_args user_addr_arg, phys_addr_arg; + + if (inputBufferSize < 0) { + LOGE("SsbSipMfcDecGetInBuf: inputBufferSize = %d is invalid\n", inputBufferSize); + return NULL; + } + + if (openHandle == NULL) { + LOGE("SsbSipMfcDecGetInBuf: openHandle is NULL\n"); + return NULL; + } + + pCTX = (_MFCLIB *)openHandle; + + user_addr_arg.args.mem_alloc.codec_type = pCTX->codec_type; + user_addr_arg.args.mem_alloc.buff_size = inputBufferSize; + user_addr_arg.args.mem_alloc.mapped_addr = pCTX->mapped_addr; + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_GET_IN_BUF, &user_addr_arg); + if (ret_code < 0) { + LOGE("SsbSipMfcDecGetInBuf: IOCTL_MFC_GET_IN_BUF failed\n"); + return NULL; + } + pCTX->virStrmBuf = user_addr_arg.args.mem_alloc.out_uaddr; + pCTX->phyStrmBuf = user_addr_arg.args.mem_alloc.out_paddr; + pCTX->sizeStrmBuf = inputBufferSize; + pCTX->inter_buff_status |= MFC_USE_STRM_BUFF; + + *phyInBuf = (void *)pCTX->phyStrmBuf; + + return (void *)pCTX->virStrmBuf; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcDecSetInBuf(void *openHandle, void *phyInBuf, void *virInBuf, int inputBufferSize) +{ + _MFCLIB *pCTX; + + if (openHandle == NULL) { + LOGE("SsbSipMfcDecSetInBuf: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX = (_MFCLIB *)openHandle; + + pCTX->phyStrmBuf = (int)phyInBuf; + pCTX->virStrmBuf = (int)virInBuf; + pCTX->sizeStrmBuf = inputBufferSize; + return MFC_RET_OK; +} + +SSBSIP_MFC_DEC_OUTBUF_STATUS SsbSipMfcDecGetOutBuf(void *openHandle, SSBSIP_MFC_DEC_OUTPUT_INFO *output_info) +{ + _MFCLIB *pCTX; + + if (openHandle == NULL) { + LOGE("SsbSipMfcDecGetOutBuf: openHandle is NULL\n"); + return MFC_GETOUTBUF_DISPLAY_END; + } + + pCTX = (_MFCLIB *)openHandle; + + output_info->YPhyAddr = pCTX->decOutInfo.YPhyAddr; + output_info->CPhyAddr = pCTX->decOutInfo.CPhyAddr; + + output_info->YVirAddr = pCTX->decOutInfo.YVirAddr; + output_info->CVirAddr = pCTX->decOutInfo.CVirAddr; + + output_info->img_width = pCTX->decOutInfo.img_width; + output_info->img_height= pCTX->decOutInfo.img_height; + + output_info->buf_width = pCTX->decOutInfo.buf_width; + output_info->buf_height= pCTX->decOutInfo.buf_height; + + /* by RainAde : for crop information */ + output_info->crop_top_offset = pCTX->decOutInfo.crop_top_offset; + output_info->crop_bottom_offset= pCTX->decOutInfo.crop_bottom_offset; + output_info->crop_left_offset = pCTX->decOutInfo.crop_left_offset; + output_info->crop_right_offset= pCTX->decOutInfo.crop_right_offset; + + if (pCTX->displayStatus == 0) + return MFC_GETOUTBUF_DISPLAY_END; + else if (pCTX->displayStatus == 1) + return MFC_GETOUTBUF_DISPLAY_DECODING; + else if (pCTX->displayStatus == 2) + return MFC_GETOUTBUF_DISPLAY_ONLY; + else + return MFC_GETOUTBUF_DECODING_ONLY; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcDecSetConfig(void *openHandle, SSBSIP_MFC_DEC_CONF conf_type, void *value) +{ + int ret_code; + _MFCLIB *pCTX; + mfc_common_args DecArg; + SSBSIP_MFC_IMG_RESOLUTION *img_resolution; + + if (openHandle == NULL) { + LOGE("SsbSipMfcDecSetConfig: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + if (value == NULL) { + LOGE("SsbSipMfcDecSetConfig: value is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX = (_MFCLIB *)openHandle; + memset(&DecArg, 0x00, sizeof(DecArg)); + + switch (conf_type) { + case MFC_DEC_SETCONF_POST_ENABLE: + case MFC_DEC_SETCONF_EXTRA_BUFFER_NUM: + case MFC_DEC_SETCONF_DISPLAY_DELAY: + case MFC_DEC_SETCONF_IS_LAST_FRAME: + case MFC_DEC_SETCONF_SLICE_ENABLE: + case MFC_DEC_SETCONF_CRC_ENABLE: + DecArg.args.set_config.in_config_param = conf_type; + DecArg.args.set_config.in_config_value[0] = *((unsigned int *)value); + DecArg.args.set_config.in_config_value[1] = 0; + break; + + case MFC_DEC_SETCONF_FIMV1_WIDTH_HEIGHT: + img_resolution = (SSBSIP_MFC_IMG_RESOLUTION *)value; + DecArg.args.set_config.in_config_param = conf_type; + DecArg.args.set_config.in_config_value[0] = img_resolution->width; + DecArg.args.set_config.in_config_value[1] = img_resolution->height; + break; + + case MFC_DEC_SETCONF_FRAME_TAG: + pCTX->in_frametag = *((int *)value); + return MFC_RET_OK; + + default: + LOGE("SsbSipMfcDecSetConfig: No such conf_type is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_SET_CONFIG, &DecArg); + if (DecArg.ret_code != MFC_RET_OK) { + LOGE("SsbSipMfcDecSetConfig: IOCTL_MFC_SET_CONFIG failed(ret : %d, conf_type: %d)\n", DecArg.ret_code, conf_type); + return MFC_RET_DEC_SET_CONF_FAIL; + } + + return MFC_RET_OK; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcDecGetConfig(void *openHandle, SSBSIP_MFC_DEC_CONF conf_type, void *value) +{ + int ret_code; + _MFCLIB *pCTX; + mfc_common_args DecArg; + + SSBSIP_MFC_IMG_RESOLUTION *img_resolution; + SSBSIP_MFC_CROP_INFORMATION *crop_information; + MFC_CRC_DATA *crc_data; + + if (openHandle == NULL) { + LOGE("SsbSipMfcDecGetConfig: openHandle is NULL\n"); + return MFC_RET_FAIL; + } + + if (value == NULL) { + LOGE("SsbSipMfcDecGetConfig: value is NULL\n"); + return MFC_RET_FAIL; + } + + pCTX = (_MFCLIB *)openHandle; + memset(&DecArg, 0x00, sizeof(DecArg)); + + switch (conf_type) { + case MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT: + img_resolution = (SSBSIP_MFC_IMG_RESOLUTION *)value; + img_resolution->width = pCTX->decOutInfo.img_width; + img_resolution->height = pCTX->decOutInfo.img_height; + img_resolution->buf_width = pCTX->decOutInfo.buf_width; + img_resolution->buf_height = pCTX->decOutInfo.buf_height; + break; + + /* Added by RainAde */ + case MFC_DEC_GETCONF_CROP_INFO: + crop_information = (SSBSIP_MFC_CROP_INFORMATION*)value; + crop_information->crop_top_offset = pCTX->decOutInfo.crop_top_offset; + crop_information->crop_bottom_offset= pCTX->decOutInfo.crop_bottom_offset; + crop_information->crop_left_offset = pCTX->decOutInfo.crop_left_offset; + crop_information->crop_right_offset= pCTX->decOutInfo.crop_right_offset; + break; + + case MFC_DEC_GETCONF_CRC_DATA: + crc_data = (MFC_CRC_DATA *)value; + + DecArg.args.get_config.in_config_param = conf_type; + + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_GET_CONFIG, &DecArg); + if (DecArg.ret_code != MFC_RET_OK) { + LOGE("SsbSipMfcDecGetConfig: IOCTL_MFC_GET_CONFIG failed(ret : %d, conf_type: %d)\n", DecArg.ret_code, conf_type); + return MFC_RET_DEC_GET_CONF_FAIL; + } + crc_data->luma0 = DecArg.args.get_config.out_config_value[0]; + crc_data->chroma0 = DecArg.args.get_config.out_config_value[1]; + break; + + case MFC_DEC_GETCONF_FRAME_TAG: + *((unsigned int *)value) = pCTX->out_frametag_top; + break; + + default: + LOGE("SsbSipMfcDecGetConfig: No such conf_type is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + + return MFC_RET_OK; +} + +int tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos) +{ + int pixel_x_m1, pixel_y_m1; + int roundup_x, roundup_y; + int linear_addr0, linear_addr1, bank_addr ; + int x_addr; + int trans_addr; + + pixel_x_m1 = x_size -1; + pixel_y_m1 = y_size -1; + + roundup_x = ((pixel_x_m1 >> 7) + 1); + roundup_y = ((pixel_x_m1 >> 6) + 1); + + x_addr = x_pos >> 2; + + if ((y_size <= y_pos+32) && ( y_pos < y_size) && + (((pixel_y_m1 >> 5) & 0x1) == 0) && (((y_pos >> 5) & 0x1) == 0)) { + linear_addr0 = (((y_pos & 0x1f) <<4) | (x_addr & 0xf)); + linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 6) & 0x3f)); + + if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1)) + bank_addr = ((x_addr >> 4) & 0x1); + else + bank_addr = 0x2 | ((x_addr >> 4) & 0x1); + } else { + linear_addr0 = (((y_pos & 0x1f) << 4) | (x_addr & 0xf)); + linear_addr1 = (((y_pos >> 6) & 0xff) * roundup_x + ((x_addr >> 5) & 0x7f)); + + if (((x_addr >> 5) & 0x1) == ((y_pos >> 5) & 0x1)) + bank_addr = ((x_addr >> 4) & 0x1); + else + bank_addr = 0x2 | ((x_addr >> 4) & 0x1); + } + + linear_addr0 = linear_addr0 << 2; + trans_addr = (linear_addr1 <<13) | (bank_addr << 11) | linear_addr0; + + return trans_addr; +} + +void Y_tile_to_linear_4x2(unsigned char *p_linear_addr, unsigned char *p_tiled_addr, unsigned int x_size, unsigned int y_size) +{ + int trans_addr; + unsigned int i, j, k, index; + unsigned char data8[4]; + unsigned int max_index = x_size * y_size; + + for (i = 0; i < y_size; i = i + 16) { + for (j = 0; j < x_size; j = j + 16) { + trans_addr = tile_4x2_read(x_size, y_size, j, i); + for (k = 0; k < 16; k++) { + /* limit check - prohibit segmentation fault */ + index = (i * x_size) + (x_size * k) + j; + /* remove equal condition to solve thumbnail bug */ + if (index + 16 > max_index) { + continue; + } + + data8[0] = p_tiled_addr[trans_addr + 64 * k + 0]; + data8[1] = p_tiled_addr[trans_addr + 64 * k + 1]; + data8[2] = p_tiled_addr[trans_addr + 64 * k + 2]; + data8[3] = p_tiled_addr[trans_addr + 64 * k + 3]; + + p_linear_addr[index] = data8[0]; + p_linear_addr[index + 1] = data8[1]; + p_linear_addr[index + 2] = data8[2]; + p_linear_addr[index + 3] = data8[3]; + + data8[0] = p_tiled_addr[trans_addr + 64 * k + 4]; + data8[1] = p_tiled_addr[trans_addr + 64 * k + 5]; + data8[2] = p_tiled_addr[trans_addr + 64 * k + 6]; + data8[3] = p_tiled_addr[trans_addr + 64 * k + 7]; + + p_linear_addr[index + 4] = data8[0]; + p_linear_addr[index + 5] = data8[1]; + p_linear_addr[index + 6] = data8[2]; + p_linear_addr[index + 7] = data8[3]; + + data8[0] = p_tiled_addr[trans_addr + 64 * k + 8]; + data8[1] = p_tiled_addr[trans_addr + 64 * k + 9]; + data8[2] = p_tiled_addr[trans_addr + 64 * k + 10]; + data8[3] = p_tiled_addr[trans_addr + 64 * k + 11]; + + p_linear_addr[index + 8] = data8[0]; + p_linear_addr[index + 9] = data8[1]; + p_linear_addr[index + 10] = data8[2]; + p_linear_addr[index + 11] = data8[3]; + + data8[0] = p_tiled_addr[trans_addr + 64 * k + 12]; + data8[1] = p_tiled_addr[trans_addr + 64 * k + 13]; + data8[2] = p_tiled_addr[trans_addr + 64 * k + 14]; + data8[3] = p_tiled_addr[trans_addr + 64 * k + 15]; + + p_linear_addr[index + 12] = data8[0]; + p_linear_addr[index + 13] = data8[1]; + p_linear_addr[index + 14] = data8[2]; + p_linear_addr[index + 15] = data8[3]; + } + } + } +} + +void CbCr_tile_to_linear_4x2(unsigned char *p_linear_addr, unsigned char *p_tiled_addr, unsigned int x_size, unsigned int y_size) +{ + int trans_addr; + unsigned int i, j, k, index; + unsigned char data8[4]; + unsigned int half_y_size = y_size / 2; + unsigned int max_index = x_size * half_y_size; + unsigned char *pUVAddr[2]; + + pUVAddr[0] = p_linear_addr; + pUVAddr[1] = p_linear_addr + ((x_size * half_y_size) / 2); + + for (i = 0; i < half_y_size; i = i + 16) { + for (j = 0; j < x_size; j = j + 16) { + trans_addr = tile_4x2_read(x_size, half_y_size, j, i); + for (k = 0; k < 16; k++) { + /* limit check - prohibit segmentation fault */ + index = (i * x_size) + (x_size * k) + j; + /* remove equal condition to solve thumbnail bug */ + if (index + 16 > max_index) { + continue; + } + + data8[0] = p_tiled_addr[trans_addr + 64 * k + 0]; + data8[1] = p_tiled_addr[trans_addr + 64 * k + 1]; + data8[2] = p_tiled_addr[trans_addr + 64 * k + 2]; + data8[3] = p_tiled_addr[trans_addr + 64 * k + 3]; + + pUVAddr[index%2][index/2] = data8[0]; + pUVAddr[(index+1)%2][(index+1)/2] = data8[1]; + pUVAddr[(index+2)%2][(index+2)/2] = data8[2]; + pUVAddr[(index+3)%2][(index+3)/2] = data8[3]; + + data8[0] = p_tiled_addr[trans_addr + 64 * k + 4]; + data8[1] = p_tiled_addr[trans_addr + 64 * k + 5]; + data8[2] = p_tiled_addr[trans_addr + 64 * k + 6]; + data8[3] = p_tiled_addr[trans_addr + 64 * k + 7]; + + pUVAddr[(index+4)%2][(index+4)/2] = data8[0]; + pUVAddr[(index+5)%2][(index+5)/2] = data8[1]; + pUVAddr[(index+6)%2][(index+6)/2] = data8[2]; + pUVAddr[(index+7)%2][(index+7)/2] = data8[3]; + + data8[0] = p_tiled_addr[trans_addr + 64 * k + 8]; + data8[1] = p_tiled_addr[trans_addr + 64 * k + 9]; + data8[2] = p_tiled_addr[trans_addr + 64 * k + 10]; + data8[3] = p_tiled_addr[trans_addr + 64 * k + 11]; + + pUVAddr[(index+8)%2][(index+8)/2] = data8[0]; + pUVAddr[(index+9)%2][(index+9)/2] = data8[1]; + pUVAddr[(index+10)%2][(index+10)/2] = data8[2]; + pUVAddr[(index+11)%2][(index+11)/2] = data8[3]; + + data8[0] = p_tiled_addr[trans_addr + 64 * k + 12]; + data8[1] = p_tiled_addr[trans_addr + 64 * k + 13]; + data8[2] = p_tiled_addr[trans_addr + 64 * k + 14]; + data8[3] = p_tiled_addr[trans_addr + 64 * k + 15]; + + pUVAddr[(index+12)%2][(index+12)/2] = data8[0]; + pUVAddr[(index+13)%2][(index+13)/2] = data8[1]; + pUVAddr[(index+14)%2][(index+14)/2] = data8[2]; + pUVAddr[(index+15)%2][(index+15)/2] = data8[3]; + } + } + } +} diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/Android.mk b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/Android.mk new file mode 100644 index 0000000..e138a99 --- /dev/null +++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/Android.mk @@ -0,0 +1,26 @@ + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := \ + src/SsbSipMfcEncAPI.c + +LOCAL_MODULE := libsecmfcencapi.aries + +LOCAL_PRELINK_MODULE := false + +LOCAL_CFLAGS := -DUSE_FIMC_FRAME_BUFFER + +LOCAL_ARM_MODE := arm + +LOCAL_STATIC_LIBRARIES := + +LOCAL_SHARED_LIBRARIES := liblog + +LOCAL_C_INCLUDES := \ + $(SEC_CODECS)/video/mfc_c110/include + +include $(BUILD_STATIC_LIBRARY) + diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/src/SsbSipMfcEncAPI.c b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/src/SsbSipMfcEncAPI.c new file mode 100644 index 0000000..2c33c5b --- /dev/null +++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/src/SsbSipMfcEncAPI.c @@ -0,0 +1,630 @@ +/* + * Copyright 2010 Samsung Electronics Co. LTD + * + * 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 "SsbSipMfcApi.h" +#include "mfc_interface.h" + +#define _MFCLIB_MAGIC_NUMBER 0x92241001 + +void *SsbSipMfcEncOpen(void) +{ + int hMFCOpen; + _MFCLIB *pCTX; + unsigned int mapped_addr; + + hMFCOpen = open(S5PC110_MFC_DEV_NAME, O_RDWR | O_NDELAY); + if (hMFCOpen < 0) { + LOGE("SsbSipMfcEncOpen: MFC Open failure\n"); + return NULL; + } + + pCTX = (_MFCLIB *)malloc(sizeof(_MFCLIB)); + if (pCTX == NULL) { + LOGE("SsbSipMfcEncOpen: malloc failed.\n"); + close(hMFCOpen); + return NULL; + } + + mapped_addr = (unsigned int)mmap(0, MMAP_BUFFER_SIZE_MMAP, PROT_READ | PROT_WRITE, MAP_SHARED, hMFCOpen, 0); + if (!mapped_addr) { + LOGE("SsbSipMfcEncOpen: FIMV5.0 driver address mapping failed\n"); + return NULL; + } + + memset(pCTX, 0, sizeof(_MFCLIB)); + + pCTX->magic = _MFCLIB_MAGIC_NUMBER; + pCTX->hMFC = hMFCOpen; + pCTX->mapped_addr = mapped_addr; + pCTX->inter_buff_status = MFC_USE_NONE; + + return (void *)pCTX; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncInit(void *openHandle, void *param) +{ + int ret_code; + int dpbBufSize; + + _MFCLIB *pCTX; + mfc_common_args EncArg; + mfc_common_args user_addr_arg, phys_addr_arg; + SSBSIP_MFC_ENC_H264_PARAM *h264_arg; + SSBSIP_MFC_ENC_MPEG4_PARAM *mpeg4_arg; + SSBSIP_MFC_ENC_H263_PARAM *h263_arg; + SSBSIP_MFC_CODEC_TYPE codec_type; + + pCTX = (_MFCLIB *)openHandle; + memset(&EncArg, 0, sizeof(mfc_common_args)); + + LOGV("SsbSipMfcEncInit: Encode Init start\n"); + + mpeg4_arg = (SSBSIP_MFC_ENC_MPEG4_PARAM *)param; + codec_type = mpeg4_arg->codecType; + + if ((codec_type != MPEG4_ENC) && + (codec_type != H264_ENC) && + (codec_type != H263_ENC)) { + LOGE("SsbSipMfcEncOpen: Undefined codec type.\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX->codec_type = codec_type; + + switch (pCTX->codec_type) { + case MPEG4_ENC: + LOGV("SsbSipMfcEncInit: MPEG4 Encode\n"); + mpeg4_arg = (SSBSIP_MFC_ENC_MPEG4_PARAM *)param; + + pCTX->width = mpeg4_arg->SourceWidth; + pCTX->height = mpeg4_arg->SourceHeight; + break; + + case H263_ENC: + LOGV("SsbSipMfcEncInit: H263 Encode\n"); + h263_arg = (SSBSIP_MFC_ENC_H263_PARAM *)param; + + pCTX->width = h263_arg->SourceWidth; + pCTX->height = h263_arg->SourceHeight; + break; + + case H264_ENC: + LOGV("SsbSipMfcEncInit: H264 Encode\n"); + h264_arg = (SSBSIP_MFC_ENC_H264_PARAM *)param; + + pCTX->width = h264_arg->SourceWidth; + pCTX->height = h264_arg->SourceHeight; + break; + + default: + break; + } + + switch (pCTX->codec_type) { + case MPEG4_ENC: + mpeg4_arg = (SSBSIP_MFC_ENC_MPEG4_PARAM*)param; + + EncArg.args.enc_init_mpeg4.in_codec_type = pCTX->codec_type; + EncArg.args.enc_init_mpeg4.in_profile_level = ENC_PROFILE_LEVEL(mpeg4_arg->ProfileIDC, mpeg4_arg->LevelIDC); + + EncArg.args.enc_init_mpeg4.in_width = mpeg4_arg->SourceWidth; + EncArg.args.enc_init_mpeg4.in_height = mpeg4_arg->SourceHeight; + EncArg.args.enc_init_mpeg4.in_gop_num = mpeg4_arg->IDRPeriod; + if (mpeg4_arg->DisableQpelME) + EncArg.args.enc_init_mpeg4.in_qpelME_enable = 0; + else + EncArg.args.enc_init_mpeg4.in_qpelME_enable = 1; + + EncArg.args.enc_init_mpeg4.in_MS_mode = mpeg4_arg->SliceMode; + EncArg.args.enc_init_mpeg4.in_MS_size = mpeg4_arg->SliceArgument; + + if (mpeg4_arg->NumberBFrames > 2) { + LOGE("SsbSipMfcEncInit: No such BframeNum is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_mpeg4.in_BframeNum = mpeg4_arg->NumberBFrames; + EncArg.args.enc_init_mpeg4.in_mb_refresh = mpeg4_arg->RandomIntraMBRefresh; + + /* rate control*/ + EncArg.args.enc_init_mpeg4.in_RC_frm_enable = mpeg4_arg->EnableFRMRateControl; + if ((mpeg4_arg->QSCodeMin > 51) || (mpeg4_arg->QSCodeMax > 51)) { + LOGE("SsbSipMfcEncInit: No such Min/Max QP is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_mpeg4.in_RC_qbound = ENC_RC_QBOUND(mpeg4_arg->QSCodeMin, mpeg4_arg->QSCodeMax); + EncArg.args.enc_init_mpeg4.in_RC_rpara = mpeg4_arg->CBRPeriodRf; + + /* pad control */ + EncArg.args.enc_init_mpeg4.in_pad_ctrl_on = mpeg4_arg->PadControlOn; + if ((mpeg4_arg->LumaPadVal > 255) || (mpeg4_arg->CbPadVal > 255) || (mpeg4_arg->CrPadVal > 255)) { + LOGE("SsbSipMfcEncInit: No such Pad value is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_mpeg4.in_luma_pad_val = mpeg4_arg->LumaPadVal; + EncArg.args.enc_init_mpeg4.in_cb_pad_val = mpeg4_arg->CbPadVal; + EncArg.args.enc_init_mpeg4.in_cr_pad_val = mpeg4_arg->CrPadVal; + + EncArg.args.enc_init_mpeg4.in_time_increament_res = mpeg4_arg->TimeIncreamentRes; + EncArg.args.enc_init_mpeg4.in_time_vop_time_increament = mpeg4_arg->VopTimeIncreament; + EncArg.args.enc_init_mpeg4.in_RC_framerate = (mpeg4_arg->TimeIncreamentRes / mpeg4_arg->VopTimeIncreament); + EncArg.args.enc_init_mpeg4.in_RC_bitrate = mpeg4_arg->Bitrate; + if ((mpeg4_arg->FrameQp > 51) || (mpeg4_arg->FrameQp_P) > 51 || (mpeg4_arg->FrameQp_B > 51)) { + LOGE("SsbSipMfcEncInit: No such FrameQp is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_mpeg4.in_frame_qp = mpeg4_arg->FrameQp; + if (mpeg4_arg->FrameQp_P) + EncArg.args.enc_init_mpeg4.in_frame_P_qp = mpeg4_arg->FrameQp_P; + else + EncArg.args.enc_init_mpeg4.in_frame_P_qp = mpeg4_arg->FrameQp; + if (mpeg4_arg->FrameQp_B) + EncArg.args.enc_init_mpeg4.in_frame_B_qp = mpeg4_arg->FrameQp_B; + else + EncArg.args.enc_init_mpeg4.in_frame_B_qp = mpeg4_arg->FrameQp; + + break; + + case H263_ENC: + h263_arg = (SSBSIP_MFC_ENC_H263_PARAM *)param; + + EncArg.args.enc_init_mpeg4.in_codec_type = pCTX->codec_type; + EncArg.args.enc_init_mpeg4.in_profile_level = ENC_PROFILE_LEVEL(66, 40); + EncArg.args.enc_init_mpeg4.in_width = h263_arg->SourceWidth; + EncArg.args.enc_init_mpeg4.in_height = h263_arg->SourceHeight; + EncArg.args.enc_init_mpeg4.in_gop_num = h263_arg->IDRPeriod; + EncArg.args.enc_init_mpeg4.in_mb_refresh = h263_arg->RandomIntraMBRefresh; + EncArg.args.enc_init_mpeg4.in_MS_mode = h263_arg->SliceMode; + EncArg.args.enc_init_mpeg4.in_MS_size = 0; + + /* rate control*/ + EncArg.args.enc_init_mpeg4.in_RC_frm_enable = h263_arg->EnableFRMRateControl; + if ((h263_arg->QSCodeMin > 51) || (h263_arg->QSCodeMax > 51)) { + LOGE("SsbSipMfcEncInit: No such Min/Max QP is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_mpeg4.in_RC_qbound = ENC_RC_QBOUND(h263_arg->QSCodeMin, h263_arg->QSCodeMax); + EncArg.args.enc_init_mpeg4.in_RC_rpara = h263_arg->CBRPeriodRf; + + /* pad control */ + EncArg.args.enc_init_mpeg4.in_pad_ctrl_on = h263_arg->PadControlOn; + if ((h263_arg->LumaPadVal > 255) || (h263_arg->CbPadVal > 255) || (h263_arg->CrPadVal > 255)) { + LOGE("SsbSipMfcEncInit: No such Pad value is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_mpeg4.in_luma_pad_val = h263_arg->LumaPadVal; + EncArg.args.enc_init_mpeg4.in_cb_pad_val = h263_arg->CbPadVal; + EncArg.args.enc_init_mpeg4.in_cr_pad_val = h263_arg->CrPadVal; + + EncArg.args.enc_init_mpeg4.in_RC_framerate = h263_arg->FrameRate; + EncArg.args.enc_init_mpeg4.in_RC_bitrate = h263_arg->Bitrate; + if (h263_arg->FrameQp > 51) { + LOGE("SsbSipMfcEncInit: No such FrameQp is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_mpeg4.in_frame_qp = h263_arg->FrameQp; + if (h263_arg->FrameQp_P) + EncArg.args.enc_init_mpeg4.in_frame_P_qp = h263_arg->FrameQp_P; + else + EncArg.args.enc_init_mpeg4.in_frame_P_qp = h263_arg->FrameQp; + + break; + + case H264_ENC: + h264_arg = (SSBSIP_MFC_ENC_H264_PARAM *)param; + + EncArg.args.enc_init_h264.in_codec_type = H264_ENC; + EncArg.args.enc_init_h264.in_profile_level = ENC_PROFILE_LEVEL(h264_arg->ProfileIDC, h264_arg->LevelIDC); + + EncArg.args.enc_init_h264.in_width = h264_arg->SourceWidth; + EncArg.args.enc_init_h264.in_height = h264_arg->SourceHeight; + EncArg.args.enc_init_h264.in_gop_num = h264_arg->IDRPeriod; + + if ((h264_arg->NumberRefForPframes > 2) || (h264_arg->NumberReferenceFrames > 2)) { + LOGE("SsbSipMfcEncInit: No such ref Num is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_h264.in_reference_num = h264_arg->NumberReferenceFrames; + EncArg.args.enc_init_h264.in_ref_num_p = h264_arg->NumberRefForPframes; + + if ((h264_arg->SliceMode == 0) || (h264_arg->SliceMode == 1) || + (h264_arg->SliceMode == 2) || (h264_arg->SliceMode == 4)) { + EncArg.args.enc_init_h264.in_MS_mode = h264_arg->SliceMode; + } else { + LOGE("SsbSipMfcEncInit: No such slice mode is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_h264.in_MS_size = h264_arg->SliceArgument; + + if (h264_arg->NumberBFrames > 2) { + LOGE("SsbSipMfcEncInit: No such BframeNum is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_h264.in_BframeNum = h264_arg->NumberBFrames; + + EncArg.args.enc_init_h264.in_deblock_filt = h264_arg->LoopFilterDisable; + if ((abs(h264_arg->LoopFilterAlphaC0Offset) > 6) || (abs(h264_arg->LoopFilterBetaOffset) > 6)) { + LOGE("SsbSipMfcEncInit: No such AlphaC0Offset or BetaOffset is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_h264.in_deblock_alpha_C0 = h264_arg->LoopFilterAlphaC0Offset; + EncArg.args.enc_init_h264.in_deblock_beta = h264_arg->LoopFilterBetaOffset; + + EncArg.args.enc_init_h264.in_symbolmode = h264_arg->SymbolMode; + EncArg.args.enc_init_h264.in_interlace_mode = h264_arg->PictureInterlace; + EncArg.args.enc_init_h264.in_transform8x8_mode = h264_arg->Transform8x8Mode; + + EncArg.args.enc_init_h264.in_mb_refresh = h264_arg->RandomIntraMBRefresh; + + /* pad control */ + EncArg.args.enc_init_h264.in_pad_ctrl_on = h264_arg->PadControlOn; + if ((h264_arg->LumaPadVal > 255) || (h264_arg->CbPadVal > 255) || (h264_arg->CrPadVal > 255)) { + LOGE("SsbSipMfcEncInit: No such Pad value is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_h264.in_luma_pad_val = h264_arg->LumaPadVal; + EncArg.args.enc_init_h264.in_cb_pad_val = h264_arg->CbPadVal; + EncArg.args.enc_init_h264.in_cr_pad_val = h264_arg->CrPadVal; + + /* rate control*/ + EncArg.args.enc_init_h264.in_RC_frm_enable = h264_arg->EnableFRMRateControl; + EncArg.args.enc_init_h264.in_RC_mb_enable = h264_arg->EnableMBRateControl; + EncArg.args.enc_init_h264.in_RC_framerate = h264_arg->FrameRate; + EncArg.args.enc_init_h264.in_RC_bitrate = h264_arg->Bitrate; + if (h264_arg->FrameQp > 51) { + LOGE("SsbSipMfcEncInit: No such FrameQp is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_h264.in_frame_qp = h264_arg->FrameQp; + if (h264_arg->FrameQp_P) + EncArg.args.enc_init_h264.in_frame_P_qp = h264_arg->FrameQp_P; + else + EncArg.args.enc_init_h264.in_frame_P_qp = h264_arg->FrameQp; + if (h264_arg->FrameQp_B) + EncArg.args.enc_init_h264.in_frame_B_qp = h264_arg->FrameQp_B; + else + EncArg.args.enc_init_h264.in_frame_B_qp = h264_arg->FrameQp; + + if ((h264_arg->QSCodeMin > 51) || (h264_arg->QSCodeMax > 51)) { + LOGE("SsbSipMfcEncInit: No such Min/Max QP is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + EncArg.args.enc_init_h264.in_RC_qbound = ENC_RC_QBOUND(h264_arg->QSCodeMin, h264_arg->QSCodeMax); + EncArg.args.enc_init_h264.in_RC_rpara = h264_arg->CBRPeriodRf; + EncArg.args.enc_init_h264.in_RC_mb_dark_disable = h264_arg->DarkDisable; + EncArg.args.enc_init_h264.in_RC_mb_smooth_disable = h264_arg->SmoothDisable; + EncArg.args.enc_init_h264.in_RC_mb_static_disable = h264_arg->StaticDisable; + EncArg.args.enc_init_h264.in_RC_mb_activity_disable = h264_arg->ActivityDisable; + + /* default setting */ + EncArg.args.enc_init_h264.in_md_interweight_pps = 0; + EncArg.args.enc_init_h264.in_md_intraweight_pps = 0; + break; + + default: + break; + } + + EncArg.args.enc_init_mpeg4.in_mapped_addr = pCTX->mapped_addr; + + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_ENC_INIT, &EncArg); + if (EncArg.ret_code != MFC_RET_OK) { + LOGE("SsbSipMfcEncInit: IOCTL_MFC_ENC_INIT (%d) failed\n", EncArg.ret_code); + return MFC_RET_ENC_INIT_FAIL; + } + + pCTX->virStrmBuf = EncArg.args.enc_init_mpeg4.out_u_addr.strm_ref_y; + pCTX->phyStrmBuf = EncArg.args.enc_init_mpeg4.out_p_addr.strm_ref_y; + pCTX->sizeStrmBuf = MAX_ENCODER_OUTPUT_BUFFER_SIZE; + pCTX->encodedHeaderSize = EncArg.args.enc_init_mpeg4.out_header_size; + + pCTX->virMvRefYC = EncArg.args.enc_init_mpeg4.out_u_addr.mv_ref_yc; + + pCTX->inter_buff_status |= MFC_USE_STRM_BUFF; + + return MFC_RET_OK; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncExe(void *openHandle) +{ + int ret_code; + _MFCLIB *pCTX; + mfc_common_args EncArg; + + if (openHandle == NULL) { + LOGE("SsbSipMfcEncExe: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX = (_MFCLIB *)openHandle; + + memset(&EncArg, 0x00, sizeof(mfc_common_args)); + + EncArg.args.enc_exe.in_codec_type = pCTX->codec_type; + EncArg.args.enc_exe.in_Y_addr = (unsigned int)pCTX->phyFrmBuf.luma; + EncArg.args.enc_exe.in_CbCr_addr = (unsigned int)pCTX->phyFrmBuf.chroma; + EncArg.args.enc_exe.in_Y_addr_vir = (unsigned int)pCTX->virFrmBuf.luma; + EncArg.args.enc_exe.in_CbCr_addr_vir = (unsigned int)pCTX->virFrmBuf.chroma; + EncArg.args.enc_exe.in_strm_st = (unsigned int)pCTX->phyStrmBuf; + EncArg.args.enc_exe.in_strm_end = (unsigned int)pCTX->phyStrmBuf + pCTX->sizeStrmBuf; + EncArg.args.enc_exe.in_frametag = pCTX->in_frametag; + + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_ENC_EXE, &EncArg); + if (EncArg.ret_code != MFC_RET_OK) { + LOGE("SsbSipMfcDecExe: IOCTL_MFC_ENC_EXE failed(ret : %d)\n", EncArg.ret_code); + return MFC_RET_ENC_EXE_ERR; + } + + pCTX->encodedDataSize = EncArg.args.enc_exe.out_encoded_size; + pCTX->encodedframeType = EncArg.args.enc_exe.out_frame_type; + pCTX->encoded_Y_paddr = EncArg.args.enc_exe.out_encoded_Y_paddr; + pCTX->encoded_C_paddr = EncArg.args.enc_exe.out_encoded_C_paddr; + pCTX->out_frametag_top = EncArg.args.enc_exe.out_frametag_top; + pCTX->out_frametag_bottom = EncArg.args.enc_exe.out_frametag_bottom; + + return MFC_RET_OK; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncClose(void *openHandle) +{ + int ret_code; + _MFCLIB *pCTX; + mfc_common_args free_arg; + + if (openHandle == NULL) { + LOGE("SsbSipMfcEncClose: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX = (_MFCLIB *)openHandle; + + if (pCTX->inter_buff_status & MFC_USE_YUV_BUFF) { + free_arg.args.mem_free.u_addr = pCTX->virFrmBuf.luma; + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_FREE_BUF, &free_arg); + } + + if (pCTX->inter_buff_status & MFC_USE_STRM_BUFF) { + free_arg.args.mem_free.u_addr = pCTX->virStrmBuf; + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_FREE_BUF, &free_arg); + free_arg.args.mem_free.u_addr = pCTX->virMvRefYC; + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_FREE_BUF, &free_arg); + } + + pCTX->inter_buff_status = MFC_USE_NONE; + + munmap((void *)pCTX->mapped_addr, MMAP_BUFFER_SIZE_MMAP); + close(pCTX->hMFC); + free(pCTX); + + return MFC_RET_OK; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetInBuf(void *openHandle, SSBSIP_MFC_ENC_INPUT_INFO *input_info) +{ + int ret_code; + _MFCLIB *pCTX; + mfc_common_args user_addr_arg, phys_addr_arg; + int y_size, c_size; + int aligned_y_size, aligned_c_size; + + if (openHandle == NULL) { + LOGE("SsbSipMfcEncGetInBuf: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX = (_MFCLIB *)openHandle; + + user_addr_arg.args.mem_alloc.codec_type = pCTX->codec_type; + + y_size = pCTX->width * pCTX->height; + c_size = (pCTX->width * pCTX->height) >> 1; + + aligned_y_size = ALIGN_TO_8KB(ALIGN_TO_128B(pCTX->width) * ALIGN_TO_32B(pCTX->height)); + aligned_c_size = ALIGN_TO_8KB(ALIGN_TO_128B(pCTX->width) * ALIGN_TO_32B(pCTX->height/2)); + + /* Allocate luma & chroma buf */ + user_addr_arg.args.mem_alloc.buff_size = aligned_y_size + aligned_c_size; + user_addr_arg.args.mem_alloc.mapped_addr = pCTX->mapped_addr; + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_GET_IN_BUF, &user_addr_arg); + if (ret_code < 0) { + LOGE("SsbSipMfcEncGetInBuf: IOCTL_MFC_GET_IN_BUF failed\n"); + return MFC_RET_ENC_GET_INBUF_FAIL; + } + pCTX->virFrmBuf.luma = user_addr_arg.args.mem_alloc.out_uaddr; + pCTX->virFrmBuf.chroma = user_addr_arg.args.mem_alloc.out_uaddr + (unsigned int)aligned_y_size; + pCTX->phyFrmBuf.luma = user_addr_arg.args.mem_alloc.out_paddr; + pCTX->phyFrmBuf.chroma = user_addr_arg.args.mem_alloc.out_paddr + (unsigned int)aligned_y_size; + + pCTX->sizeFrmBuf.luma = (unsigned int)y_size; + pCTX->sizeFrmBuf.chroma = (unsigned int)c_size; + pCTX->inter_buff_status |= MFC_USE_YUV_BUFF; + + input_info->YPhyAddr = (void*)pCTX->phyFrmBuf.luma; + input_info->CPhyAddr = (void*)pCTX->phyFrmBuf.chroma; + input_info->YVirAddr = (void*)pCTX->virFrmBuf.luma; + input_info->CVirAddr = (void*)pCTX->virFrmBuf.chroma; + + return MFC_RET_OK; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetInBuf(void *openHandle, SSBSIP_MFC_ENC_INPUT_INFO *input_info) +{ + _MFCLIB *pCTX; + + if (openHandle == NULL) { + LOGE("SsbSipMfcEncSetInBuf: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + LOGV("SsbSipMfcEncSetInBuf: input_info->YPhyAddr & input_info->CPhyAddr should be 64KB aligned\n"); + + pCTX = (_MFCLIB *)openHandle; + + pCTX->phyFrmBuf.luma = (unsigned int)input_info->YPhyAddr; + pCTX->phyFrmBuf.chroma = (unsigned int)input_info->CPhyAddr; + pCTX->virFrmBuf.luma = (unsigned int)input_info->YVirAddr; + pCTX->virFrmBuf.chroma = (unsigned int)input_info->CVirAddr; + + pCTX->sizeFrmBuf.luma = (unsigned int)input_info->YSize; + pCTX->sizeFrmBuf.chroma = (unsigned int)input_info->CSize; + + return MFC_RET_OK; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetOutBuf(void *openHandle, SSBSIP_MFC_ENC_OUTPUT_INFO *output_info) +{ + _MFCLIB *pCTX; + + if (openHandle == NULL) { + LOGE("SsbSipMfcEncGetOutBuf: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX = (_MFCLIB *)openHandle; + + output_info->headerSize = pCTX->encodedHeaderSize; + output_info->dataSize = pCTX->encodedDataSize; + output_info->StrmPhyAddr = (void *)pCTX->phyStrmBuf; + output_info->StrmVirAddr = (void *)pCTX->virStrmBuf; + + if (pCTX->encodedframeType == 0) + output_info->frameType = MFC_FRAME_TYPE_NOT_CODED; + else if (pCTX->encodedframeType == 1) + output_info->frameType = MFC_FRAME_TYPE_I_FRAME; + else if (pCTX->encodedframeType == 2) + output_info->frameType = MFC_FRAME_TYPE_P_FRAME; + else if (pCTX->encodedframeType == 3) + output_info->frameType = MFC_FRAME_TYPE_B_FRAME; + else if (pCTX->encodedframeType == 4) + output_info->frameType = MFC_FRAME_TYPE_OTHERS; + else { + LOGE("Strange encoded frame type = %d\n", pCTX->encodedframeType); + return MFC_RET_INVALID_PARAM; + } + + output_info->encodedYPhyAddr = (void *)pCTX->encoded_Y_paddr; + output_info->encodedCPhyAddr = (void *)pCTX->encoded_C_paddr; + + return MFC_RET_OK; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetOutBuf(void *openHandle, void *phyOutbuf, void *virOutbuf, int outputBufferSize) +{ + _MFCLIB *pCTX; + + if (openHandle == NULL) { + LOGE("SsbSipMfcEncSetOutBuf: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX = (_MFCLIB *)openHandle; + + pCTX->phyStrmBuf = (int)phyOutbuf; + pCTX->virStrmBuf = (int)virOutbuf; + pCTX->sizeStrmBuf = outputBufferSize; + + return MFC_RET_OK; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetConfig(void *openHandle, SSBSIP_MFC_ENC_CONF conf_type, void *value) +{ + int ret_code; + _MFCLIB *pCTX; + mfc_common_args EncArg; + + if (openHandle == NULL) { + LOGE("SsbSipMfcEncSetConfig: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + if (value == NULL) { + LOGE("SsbSipMfcEncSetConfig: value is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX = (_MFCLIB *)openHandle; + memset(&EncArg, 0x00, sizeof(mfc_common_args)); + + switch (conf_type) { + case MFC_ENC_SETCONF_FRAME_TYPE: + case MFC_ENC_SETCONF_CHANGE_FRAME_RATE: + case MFC_ENC_SETCONF_CHANGE_BIT_RATE: + case MFC_ENC_SETCONF_ALLOW_FRAME_SKIP: + EncArg.args.set_config.in_config_param = conf_type; + EncArg.args.set_config.in_config_value[0] = *((unsigned int *) value); + EncArg.args.set_config.in_config_value[1] = 0; + break; + + case MFC_ENC_SETCONF_FRAME_TAG: + pCTX->in_frametag = *((int *)value); + return MFC_RET_OK; + + default: + LOGE("SsbSipMfcEncSetConfig: No such conf_type is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + + ret_code = ioctl(pCTX->hMFC, IOCTL_MFC_SET_CONFIG, &EncArg); + if (EncArg.ret_code != MFC_RET_OK) { + LOGE("SsbSipMfcEncSetConfig: IOCTL_MFC_SET_CONFIG failed(ret : %d)\n", EncArg.ret_code); + return MFC_RET_ENC_SET_CONF_FAIL; + } + + return MFC_RET_OK; +} + +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetConfig(void *openHandle, SSBSIP_MFC_ENC_CONF conf_type, void *value) +{ + int ret_code; + _MFCLIB *pCTX; + mfc_common_args EncArg; + + pCTX = (_MFCLIB *)openHandle; + + if (openHandle == NULL) { + LOGE("SsbSipMfcEncGetConfig: openHandle is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + if (value == NULL) { + LOGE("SsbSipMfcEncGetConfig: value is NULL\n"); + return MFC_RET_INVALID_PARAM; + } + + pCTX = (_MFCLIB *)openHandle; + memset(&EncArg, 0x00, sizeof(mfc_common_args)); + + switch (conf_type) { + case MFC_ENC_GETCONF_FRAME_TAG: + *((unsigned int *)value) = pCTX->out_frametag_top; + break; + + default: + LOGE("SsbSipMfcEncGetConfig: No such conf_type is supported.\n"); + return MFC_RET_INVALID_PARAM; + } + + return MFC_RET_OK; +} diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/SsbSipMfcApi.h b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/SsbSipMfcApi.h new file mode 100644 index 0000000..e083998 --- /dev/null +++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/SsbSipMfcApi.h @@ -0,0 +1,330 @@ +/* + * Copyright 2010 Samsung Electronics Co. LTD + * + * 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 _SSBSIP_MFC_API_H_ +#define _SSBSIP_MFC_API_H_ + +/*--------------------------------------------------------------------------------*/ +/* Definition */ +/*--------------------------------------------------------------------------------*/ +#define MAX_DECODER_INPUT_BUFFER_SIZE (1024 * 3072) +#define MAX_ENCODER_OUTPUT_BUFFER_SIZE (1024 * 3072) + +#define SUPPORT_1080P 1 + +#if SUPPORT_1080P +#define MMAP_BUFFER_SIZE_MMAP (63*1024*1024) +#else +#define MMAP_BUFFER_SIZE_MMAP (49*1024*1024) +#endif + +#define S5PC110_MFC_DEV_NAME "/dev/s3c-mfc" + +/*--------------------------------------------------------------------------------*/ +/* Structure and Type */ +/*--------------------------------------------------------------------------------*/ +typedef enum { + H264_DEC, + VC1_DEC, /* VC1 advaced Profile decoding */ + MPEG4_DEC, + XVID_DEC, + MPEG1_DEC, + MPEG2_DEC, + H263_DEC, + VC1RCV_DEC, /* VC1 simple/main profile decoding */ + FIMV1_DEC, + FIMV2_DEC, + FIMV3_DEC, + FIMV4_DEC, + H264_ENC, + MPEG4_ENC, + H263_ENC, + UNKNOWN_TYPE +} SSBSIP_MFC_CODEC_TYPE; + +typedef enum { + DONT_CARE = 0, + I_FRAME = 1, + NOT_CODED = 2 +} SSBSIP_MFC_FORCE_SET_FRAME_TYPE; + +typedef enum { + MFC_DEC_SETCONF_POST_ENABLE = 1, + MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, + MFC_DEC_SETCONF_DISPLAY_DELAY, + MFC_DEC_SETCONF_IS_LAST_FRAME, + MFC_DEC_SETCONF_SLICE_ENABLE, + MFC_DEC_SETCONF_CRC_ENABLE, + MFC_DEC_SETCONF_FIMV1_WIDTH_HEIGHT, + MFC_DEC_SETCONF_FRAME_TAG, + MFC_DEC_GETCONF_CRC_DATA, + MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, + MFC_DEC_GETCONF_CROP_INFO, + MFC_DEC_GETCONF_FRAME_TAG +} SSBSIP_MFC_DEC_CONF; + +typedef enum { + MFC_ENC_SETCONF_FRAME_TYPE = 100, + MFC_ENC_SETCONF_CHANGE_FRAME_RATE, + MFC_ENC_SETCONF_CHANGE_BIT_RATE, + MFC_ENC_SETCONF_FRAME_TAG, + MFC_ENC_SETCONF_ALLOW_FRAME_SKIP, + MFC_ENC_GETCONF_FRAME_TAG +} SSBSIP_MFC_ENC_CONF; + +typedef enum { + MFC_GETOUTBUF_STATUS_NULL = 0, + MFC_GETOUTBUF_DECODING_ONLY = 1, + MFC_GETOUTBUF_DISPLAY_DECODING, + MFC_GETOUTBUF_DISPLAY_ONLY, + MFC_GETOUTBUF_DISPLAY_END +} SSBSIP_MFC_DEC_OUTBUF_STATUS; + +typedef enum { + MFC_FRAME_TYPE_NOT_CODED, + MFC_FRAME_TYPE_I_FRAME, + MFC_FRAME_TYPE_P_FRAME, + MFC_FRAME_TYPE_B_FRAME, + MFC_FRAME_TYPE_OTHERS +} SSBSIP_MFC_FRAME_TYPE; + +typedef enum { + MFC_RET_OK = 1, + MFC_RET_FAIL = -1000, + MFC_RET_OPEN_FAIL = -1001, + MFC_RET_CLOSE_FAIL = -1002, + + MFC_RET_DEC_INIT_FAIL = -2000, + MFC_RET_DEC_EXE_TIME_OUT = -2001, + MFC_RET_DEC_EXE_ERR = -2002, + MFC_RET_DEC_GET_INBUF_FAIL = -2003, + MFC_RET_DEC_SET_INBUF_FAIL = -2004, + MFC_RET_DEC_GET_OUTBUF_FAIL = -2005, + MFC_RET_DEC_GET_CONF_FAIL = -2006, + MFC_RET_DEC_SET_CONF_FAIL = -2007, + + MFC_RET_ENC_INIT_FAIL = -3000, + MFC_RET_ENC_EXE_TIME_OUT = -3001, + MFC_RET_ENC_EXE_ERR = -3002, + MFC_RET_ENC_GET_INBUF_FAIL = -3003, + MFC_RET_ENC_SET_INBUF_FAIL = -3004, + MFC_RET_ENC_GET_OUTBUF_FAIL = -3005, + MFC_RET_ENC_SET_OUTBUF_FAIL = -3006, + MFC_RET_ENC_GET_CONF_FAIL = -3007, + MFC_RET_ENC_SET_CONF_FAIL = -3008, + + MFC_RET_INVALID_PARAM = -4000 +} SSBSIP_MFC_ERROR_CODE; + +typedef struct { + void *YPhyAddr; // [OUT] physical address of Y + void *CPhyAddr; // [OUT] physical address of CbCr + void *YVirAddr; // [OUT] virtual address of Y + void *CVirAddr; // [OUT] virtual address of CbCr + + int img_width; // [OUT] width of real image + int img_height; // [OUT] height of real image + int buf_width; // [OUT] width aligned to 16 + int buf_height; // [OUT] height alighed to 16 + + int timestamp_top; // [OUT] timestamp of top filed(This is used for interlaced stream) + int timestamp_bottom; // [OUT] timestamp of bottom filed(This is used for interlaced stream) + int consumedByte; // [OUT] the number of byte consumed during decoding + int res_change; // [OUT] whether resolution is changed or not. 0: not change, 1: increased, 2: decreased + int crop_top_offset; // [OUT] crop information, top_offset + int crop_bottom_offset; // [OUT] crop information, bottom_offset + int crop_left_offset; // [OUT] crop information, left_offset + int crop_right_offset; // [OUT] crop information, right_offset +} SSBSIP_MFC_DEC_OUTPUT_INFO; + +typedef struct { + void *YPhyAddr; // [IN/OUT] physical address of Y + void *CPhyAddr; // [IN/OUT] physical address of CbCr + void *YVirAddr; // [IN/OUT] virtual address of Y + void *CVirAddr; // [IN/OUT] virtual address of CbCr + int YSize; // [IN/OUT] input size of Y data + int CSize; // [IN/OUT] input size of CbCr data +} SSBSIP_MFC_ENC_INPUT_INFO; + +typedef struct { + unsigned int dataSize; // [OUT] encoded data size(without header) + unsigned int headerSize; // [OUT] encoded header size + unsigned int frameType; // [OUT] frame type of encoded stream + void *StrmPhyAddr; // [OUT] physical address of Y + void *StrmVirAddr; // [OUT] virtual address of Y + void *encodedYPhyAddr; // [OUT] physical address of Y which is flushed + void *encodedCPhyAddr; // [OUT] physical address of C which is flushed +} SSBSIP_MFC_ENC_OUTPUT_INFO; + +typedef struct { + // common parameters + SSBSIP_MFC_CODEC_TYPE codecType; // [IN] codec type + int SourceWidth; // [IN] width of video to be encoded + int SourceHeight; // [IN] height of video to be encoded + int IDRPeriod; // [IN] GOP number(interval of I-frame) + int SliceMode; // [IN] Multi slice mode + int RandomIntraMBRefresh; // [IN] cyclic intra refresh + int EnableFRMRateControl; // [IN] frame based rate control enable + int Bitrate; // [IN] rate control parameter(bit rate) + int FrameQp; // [IN] The quantization parameter of the frame + int FrameQp_P; // [IN] The quantization parameter of the P frame + int QSCodeMax; // [IN] Maximum Quantization value + int QSCodeMin; // [IN] Minimum Quantization value + int CBRPeriodRf; // [IN] Reaction coefficient parameter for rate control + int PadControlOn; // [IN] Enable padding control + int LumaPadVal; // [IN] Luma pel value used to fill padding area + int CbPadVal; // [IN] CB pel value used to fill padding area + int CrPadVal; // [IN] CR pel value used to fill padding area + + // H.264 specific parameters + int ProfileIDC; // [IN] profile + int LevelIDC; // [IN] level + int FrameQp_B; // [IN] The quantization parameter of the B frame + int FrameRate; // [IN] rate control parameter(frame rate) + int SliceArgument; // [IN] MB number or byte number + int NumberBFrames; // [IN] The number of consecutive B frame inserted + int NumberReferenceFrames; // [IN] The number of reference pictures used + int NumberRefForPframes; // [IN] The number of reference pictures used for encoding P pictures + int LoopFilterDisable; // [IN] disable the loop filter + int LoopFilterAlphaC0Offset; // [IN] Alpha & C0 offset for H.264 loop filter + int LoopFilterBetaOffset; // [IN] Beta offset for H.264 loop filter + int SymbolMode; // [IN] The mode of entropy coding(CABAC, CAVLC) + int PictureInterlace; // [IN] Enables the interlace mode + int Transform8x8Mode; // [IN] Allow 8x8 transform(This is allowed only for high profile) + int EnableMBRateControl; // [IN] Enable macroblock-level rate control + int DarkDisable; // [IN] Disable adaptive rate control on dark region + int SmoothDisable; // [IN] Disable adaptive rate control on smooth region + int StaticDisable; // [IN] Disable adaptive rate control on static region + int ActivityDisable; // [IN] Disable adaptive rate control on high activity region +} SSBSIP_MFC_ENC_H264_PARAM; + +typedef struct { + // common parameters + SSBSIP_MFC_CODEC_TYPE codecType; // [IN] codec type + int SourceWidth; // [IN] width of video to be encoded + int SourceHeight; // [IN] height of video to be encoded + int IDRPeriod; // [IN] GOP number(interval of I-frame) + int SliceMode; // [IN] Multi slice mode + int RandomIntraMBRefresh; // [IN] cyclic intra refresh + int EnableFRMRateControl; // [IN] frame based rate control enable + int Bitrate; // [IN] rate control parameter(bit rate) + int FrameQp; // [IN] The quantization parameter of the frame + int FrameQp_P; // [IN] The quantization parameter of the P frame + int QSCodeMax; // [IN] Maximum Quantization value + int QSCodeMin; // [IN] Minimum Quantization value + int CBRPeriodRf; // [IN] Reaction coefficient parameter for rate control + int PadControlOn; // [IN] Enable padding control + int LumaPadVal; // [IN] Luma pel value used to fill padding area + int CbPadVal; // [IN] CB pel value used to fill padding area + int CrPadVal; // [IN] CR pel value used to fill padding area + + // MPEG4 specific parameters + int ProfileIDC; // [IN] profile + int LevelIDC; // [IN] level + int FrameQp_B; // [IN] The quantization parameter of the B frame + int TimeIncreamentRes; // [IN] frame rate + int VopTimeIncreament; // [IN] frame rate + int SliceArgument; // [IN] MB number or byte number + int NumberBFrames; // [IN] The number of consecutive B frame inserted + int DisableQpelME; // [IN] disable quarter-pixel motion estimation +} SSBSIP_MFC_ENC_MPEG4_PARAM; + +typedef struct { + // common parameters + SSBSIP_MFC_CODEC_TYPE codecType; // [IN] codec type + int SourceWidth; // [IN] width of video to be encoded + int SourceHeight; // [IN] height of video to be encoded + int IDRPeriod; // [IN] GOP number(interval of I-frame) + int SliceMode; // [IN] Multi slice mode + int RandomIntraMBRefresh; // [IN] cyclic intra refresh + int EnableFRMRateControl; // [IN] frame based rate control enable + int Bitrate; // [IN] rate control parameter(bit rate) + int FrameQp; // [IN] The quantization parameter of the frame + int FrameQp_P; // [IN] The quantization parameter of the P frame + int QSCodeMax; // [IN] Maximum Quantization value + int QSCodeMin; // [IN] Minimum Quantization value + int CBRPeriodRf; // [IN] Reaction coefficient parameter for rate control + int PadControlOn; // [IN] Enable padding control + int LumaPadVal; // [IN] Luma pel value used to fill padding area + int CbPadVal; // [IN] CB pel value used to fill padding area + int CrPadVal; // [IN] CR pel value used to fill padding area + + // H.263 specific parameters + int FrameRate; // [IN] rate control parameter(frame rate) +} SSBSIP_MFC_ENC_H263_PARAM; + +typedef struct { + int width; + int height; + int buf_width; + int buf_height; +} SSBSIP_MFC_IMG_RESOLUTION; + +typedef struct { + int crop_top_offset; + int crop_bottom_offset; + int crop_left_offset; + int crop_right_offset; +} SSBSIP_MFC_CROP_INFORMATION; + +#ifdef __cplusplus +extern "C" { +#endif + +/*--------------------------------------------------------------------------------*/ +/* Format Conversion API */ +/*--------------------------------------------------------------------------------*/ +void Y_tile_to_linear_4x2(unsigned char *p_linear_addr, unsigned char *p_tiled_addr, unsigned int x_size, unsigned int y_size); +void CbCr_tile_to_linear_4x2(unsigned char *p_linear_addr, unsigned char *p_tiled_addr, unsigned int x_size, unsigned int y_size); + +/*--------------------------------------------------------------------------------*/ +/* Decoding APIs */ +/*--------------------------------------------------------------------------------*/ +void *SsbSipMfcDecOpen(void); +SSBSIP_MFC_ERROR_CODE SsbSipMfcDecInit(void *openHandle, SSBSIP_MFC_CODEC_TYPE codec_type, int Frameleng); +SSBSIP_MFC_ERROR_CODE SsbSipMfcDecExe(void *openHandle, int lengthBufFill); +SSBSIP_MFC_ERROR_CODE SsbSipMfcDecClose(void *openHandle); + +void *SsbSipMfcDecGetInBuf(void *openHandle, void **phyInBuf, int inputBufferSize); +SSBSIP_MFC_ERROR_CODE SsbSipMfcDecSetInBuf(void *openHandle, void *phyInBuf, void *virInBuf, int inputBufferSize); + +SSBSIP_MFC_DEC_OUTBUF_STATUS SsbSipMfcDecGetOutBuf(void *openHandle, SSBSIP_MFC_DEC_OUTPUT_INFO *output_info); + +SSBSIP_MFC_ERROR_CODE SsbSipMfcDecSetConfig(void *openHandle, SSBSIP_MFC_DEC_CONF conf_type, void *value); +SSBSIP_MFC_ERROR_CODE SsbSipMfcDecGetConfig(void *openHandle, SSBSIP_MFC_DEC_CONF conf_type, void *value); + +/*--------------------------------------------------------------------------------*/ +/* Encoding APIs */ +/*--------------------------------------------------------------------------------*/ +void *SsbSipMfcEncOpen(void); +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncInit(void *openHandle, void *param); +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncExe(void *openHandle); +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncClose(void *openHandle); + +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetInBuf(void *openHandle, SSBSIP_MFC_ENC_INPUT_INFO *input_info); +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetInBuf(void *openHandle, SSBSIP_MFC_ENC_INPUT_INFO *input_info); + +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetOutBuf(void *openHandle, SSBSIP_MFC_ENC_OUTPUT_INFO *output_info); +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetOutBuf (void *openHandle, void *phyOutbuf, void *virOutbuf, int outputBufferSize); + +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetConfig(void *openHandle, SSBSIP_MFC_ENC_CONF conf_type, void *value); +SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetConfig(void *openHandle, SSBSIP_MFC_ENC_CONF conf_type, void *value); + +#ifdef __cplusplus +} +#endif + +#endif /* _SSBSIP_MFC_API_H_ */ diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/mfc_interface.h b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/mfc_interface.h new file mode 100644 index 0000000..e7e23c3 --- /dev/null +++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/mfc_interface.h @@ -0,0 +1,333 @@ +/* + * Copyright 2010 Samsung Electronics Co. LTD + * + * 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 _MFC_INTERFACE_H_ +#define _MFC_INTERFACE_H_ + +#include "SsbSipMfcApi.h" + +#define IOCTL_MFC_DEC_INIT 0x00800001 +#define IOCTL_MFC_ENC_INIT 0x00800002 +#define IOCTL_MFC_DEC_EXE 0x00800003 +#define IOCTL_MFC_ENC_EXE 0x00800004 + +#define IOCTL_MFC_GET_IN_BUF 0x00800010 +#define IOCTL_MFC_FREE_BUF 0x00800011 +#define IOCTL_MFC_GET_PHYS_ADDR 0x00800012 + +#define IOCTL_MFC_SET_CONFIG 0x00800101 +#define IOCTL_MFC_GET_CONFIG 0x00800102 + +/* MFC H/W support maximum 32 extra DPB */ +#define MFC_MAX_EXTRA_DPB 5 + +#define ENC_PROFILE_LEVEL(profile, level) ((profile) | ((level) << 8)) + +#define ENC_PROFILE_MPEG4_SP 0 +#define ENC_PROFILE_MPEG4_ASP 1 +#define ENC_PROFILE_H264_BP 0 +#define ENC_PROFILE_H264_MAIN 1 +#define ENC_PROFILE_H264_HIGH 2 + +#define ENC_RC_DISABLE 0 +#define ENC_RC_ENABLE_MACROBLOCK 1 +#define ENC_RC_ENABLE_FRAME 2 + +#define ENC_RC_QBOUND(min_qp, max_qp) ((min_qp) | ((max_qp) << 8)) +#define ENC_RC_MB_CTRL_DARK_DISABLE (1 << 3) +#define ENC_RC_MB_CTRL_SMOOTH_DISABLE (1 << 2) +#define ENC_RC_MB_CTRL_STATIC_DISABLE (1 << 1) +#define ENC_RC_MB_CTRL_ACTIVITY_DISABLE (1 << 0) + +#define ALIGN_TO_16B(x) ((((x) + (1 << 4) - 1) >> 4) << 4) +#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5) +#define ALIGN_TO_64B(x) ((((x) + (1 << 6) - 1) >> 6) << 6) +#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7) +#define ALIGN_TO_2KB(x) ((((x) + (1 << 11) - 1) >> 11) << 11) +#define ALIGN_TO_4KB(x) ((((x) + (1 << 12) - 1) >> 12) << 12) +#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13) +#define ALIGN_TO_64KB(x) ((((x) + (1 << 16) - 1) >> 16) << 16) +#define ALIGN_TO_128KB(x) ((((x) + (1 << 17) - 1) >> 17) << 17) + +typedef struct { + int luma0; // per frame (or top field) + int chroma0; // per frame (or top field) + int luma1; // per frame (or bottom field) + int chroma1; // per frame (or bottom field) +} MFC_CRC_DATA; + +typedef enum { + MFC_USE_NONE = 0x00, + MFC_USE_YUV_BUFF = 0x01, + MFC_USE_STRM_BUFF = 0x10 +} mfc_interbuff_status; + +typedef enum { + MFC_UNPACKED_PB = 0, + MFC_PACKED_PB = 1 +} mfc_packed_mode; + +typedef struct tag_strm_ref_buf_arg { + unsigned int strm_ref_y; + unsigned int mv_ref_yc; +} mfc_strm_ref_buf_arg_t; + +typedef struct tag_frame_buf_arg { + unsigned int luma; + unsigned int chroma; +} mfc_frame_buf_arg_t; + +typedef struct { + SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */ + int in_width; /* [IN] width of YUV420 frame to be encoded */ + int in_height; /* [IN] height of YUV420 frame to be encoded */ + int in_profile_level; /* [IN] profile & level */ + int in_gop_num; /* [IN] GOP Number (interval of I-frame) */ + int in_frame_qp; /* [IN] the quantization parameter of the frame */ + int in_frame_P_qp; /* [IN] the quantization parameter of the P frame */ + int in_frame_B_qp; /* [IN] the quantization parameter of the B frame */ + + int in_RC_frm_enable; /* [IN] RC enable (0:disable, 1:frame level RC) */ + int in_RC_framerate; /* [IN] RC parameter (framerate) */ + int in_RC_bitrate; /* [IN] RC parameter (bitrate in kbps) */ + int in_RC_qbound; /* [IN] RC parameter (Q bound) */ + int in_RC_rpara; /* [IN] RC parameter (Reaction Coefficient) */ + + int in_MS_mode; /* [IN] Multi-slice mode (0:single, 1:multiple) */ + int in_MS_size; /* [IN] Multi-slice size (in num. of mb or byte) */ + int in_mb_refresh; /* [IN] Macroblock refresh */ + int in_interlace_mode; /* [IN] interlace mode(0:progressive, 1:interlace) */ + int in_BframeNum; /* [IN] B frame number */ + + int in_pad_ctrl_on; /* [IN] Enable (1) / Disable (0) padding */ + int in_luma_pad_val; /* [IN] pad value if pad_ctrl_on is Enable */ + int in_cb_pad_val; + int in_cr_pad_val; + + unsigned int in_mapped_addr; + mfc_strm_ref_buf_arg_t out_u_addr; + mfc_strm_ref_buf_arg_t out_p_addr; + mfc_strm_ref_buf_arg_t out_buf_size; + unsigned int out_header_size; + + /* MPEG4 Only */ + int in_qpelME_enable; /* [IN] Quarter-pel MC enable(1:enable, 0:disable) */ + int in_time_increament_res; /* [IN] time increment resolution */ + int in_time_vop_time_increament; /* [IN] time increment */ +} mfc_enc_init_mpeg4_arg_t; + +typedef mfc_enc_init_mpeg4_arg_t mfc_enc_init_h263_arg_t; + +typedef struct { + SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */ + int in_width; /* [IN] width of YUV420 frame to be encoded */ + int in_height; /* [IN] height of YUV420 frame to be encoded */ + int in_profile_level; /* [IN] profile & level */ + int in_gop_num; /* [IN] GOP Number (interval of I-frame) */ + int in_frame_qp; /* [IN] the quantization parameter of the frame */ + int in_frame_P_qp; /* [IN] the quantization parameter of the P frame */ + int in_frame_B_qp; /* [IN] the quantization parameter of the B frame */ + + int in_RC_frm_enable; /* [IN] RC enable (0:disable, 1:frame level RC) */ + int in_RC_framerate; /* [IN] RC parameter (framerate) */ + int in_RC_bitrate; /* [IN] RC parameter (bitrate in kbps) */ + int in_RC_qbound; /* [IN] RC parameter (Q bound) */ + int in_RC_rpara; /* [IN] RC parameter (Reaction Coefficient) */ + + int in_MS_mode; /* [IN] Multi-slice mode (0:single, 1:multiple) */ + int in_MS_size; /* [IN] Multi-slice size (in num. of mb or byte) */ + int in_mb_refresh; /* [IN] Macroblock refresh */ + int in_interlace_mode; /* [IN] interlace mode(0:progressive, 1:interlace) */ + int in_BframeNum; + + int in_pad_ctrl_on; /* [IN] Enable padding control */ + int in_luma_pad_val; /* [IN] Luma pel value used to fill padding area */ + int in_cb_pad_val; /* [IN] CB pel value used to fill padding area */ + int in_cr_pad_val; /* [IN] CR pel value used to fill padding area */ + + unsigned int in_mapped_addr; + mfc_strm_ref_buf_arg_t out_u_addr; + mfc_strm_ref_buf_arg_t out_p_addr; + mfc_strm_ref_buf_arg_t out_buf_size; + unsigned int out_header_size; + + /* H264 Only */ + int in_RC_mb_enable; /* [IN] RC enable (0:disable, 1:MB level RC) */ + int in_reference_num; /* [IN] The number of reference pictures used */ + int in_ref_num_p; /* [IN] The number of reference pictures used for P pictures */ + int in_RC_mb_dark_disable; /* [IN] Disable adaptive rate control on dark region */ + int in_RC_mb_smooth_disable; /* [IN] Disable adaptive rate control on smooth region */ + int in_RC_mb_static_disable; /* [IN] Disable adaptive rate control on static region */ + int in_RC_mb_activity_disable; /* [IN] Disable adaptive rate control on static region */ + int in_deblock_filt; /* [IN] disable the loop filter */ + int in_deblock_alpha_C0; /* [IN] Alpha & C0 offset for H.264 loop filter */ + int in_deblock_beta; /* [IN] Beta offset for H.264 loop filter */ + int in_symbolmode; /* [IN] The mode of entropy coding(CABAC, CAVLC) */ + int in_transform8x8_mode; /* [IN] Allow 8x8 transform(only for high profile) */ + int in_md_interweight_pps; /* [IN] Inter weighted parameter for mode decision */ + int in_md_intraweight_pps; /* [IN] Intra weighted parameter for mode decision */ +} mfc_enc_init_h264_arg_t; + +typedef struct { + SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */ + unsigned int in_Y_addr; /* [IN] In-buffer addr of Y component */ + unsigned int in_CbCr_addr; /* [IN] In-buffer addr of CbCr component */ + unsigned int in_Y_addr_vir; /* [IN] In-buffer addr of Y component */ + unsigned int in_CbCr_addr_vir; /* [IN] In-buffer addr of CbCr component */ + unsigned int in_strm_st; /* [IN] Out-buffer start addr of encoded strm */ + unsigned int in_strm_end; /* [IN] Out-buffer end addr of encoded strm */ + int in_frametag; /* [IN] unique frame ID */ + + unsigned int out_frame_type; /* [OUT] frame type */ + int out_encoded_size; /* [OUT] Length of Encoded video stream */ + unsigned int out_encoded_Y_paddr; /* [OUT] physical Y address which is flushed */ + unsigned int out_encoded_C_paddr; /* [OUT] physical C address which is flushed */ + int out_frametag_top; /* [OUT] unique frame ID of an output frame or top field */ + int out_frametag_bottom; /* [OUT] unique frame ID of bottom field */ +} mfc_enc_exe_arg; + +typedef struct { + SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */ + unsigned int in_strm_buf; /* [IN] the physical address of STRM_BUF */ + int in_strm_size; /* [IN] size of video stream filled in STRM_BUF */ + int in_packed_PB; /* [IN] Is packed PB frame or not, 1: packedPB 0: unpacked */ + + int out_img_width; /* [OUT] width of YUV420 frame */ + int out_img_height; /* [OUT] height of YUV420 frame */ + int out_buf_width; /* [OUT] width of YUV420 frame */ + int out_buf_height; /* [OUT] height of YUV420 frame */ + int out_dpb_cnt; /* [OUT] the number of buffers which is nessary during decoding */ + + int out_crop_top_offset; /* [OUT] crop information, top offset */ + int out_crop_bottom_offset; /* [OUT] crop information, bottom offset */ + int out_crop_left_offset; /* [OUT] crop information, left offset */ + int out_crop_right_offset; /* [OUT] crop information, right offset */ + + mfc_frame_buf_arg_t in_frm_buf; /* [IN] the address of dpb FRAME_BUF */ + mfc_frame_buf_arg_t in_frm_size; /* [IN] size of dpb FRAME_BUF */ + unsigned int in_mapped_addr; + + mfc_frame_buf_arg_t out_u_addr; + mfc_frame_buf_arg_t out_p_addr; + mfc_frame_buf_arg_t out_frame_buf_size; +} mfc_dec_init_arg_t; + +typedef struct { + SSBSIP_MFC_CODEC_TYPE in_codec_type; /* [IN] codec type */ + unsigned int in_strm_buf; /* [IN] the physical address of STRM_BUF */ + int in_strm_size; /* [IN] Size of video stream filled in STRM_BUF */ + mfc_frame_buf_arg_t in_frm_buf; /* [IN] the address of dpb FRAME_BUF */ + mfc_frame_buf_arg_t in_frm_size; /* [IN] size of dpb FRAME_BUF */ + int in_frametag; /* [IN] unique frame ID */ + + unsigned int out_display_Y_addr; /* [OUT] the physical address of display buf */ + unsigned int out_display_C_addr; /* [OUT] the physical address of display buf */ + int out_display_status; /* [OUT] whether display frame exist or not. */ + int out_timestamp_top; /* [OUT] presentation time of an output frame or top field */ + int out_timestamp_bottom; /* [OUT] presentation time of bottom field */ + int out_consume_bytes; /* [OUT] consumed bytes when decoding finished */ + int out_frametag_top; /* [OUT] unique frame ID of an output frame or top field */ + int out_frametag_bottom; /* [OUT] unique frame ID of bottom field */ + int out_res_change; /* [OUT] whether resolution is changed or not (0, 1, 2) */ + int out_crop_top_offset; /* [OUT] crop information, top offset */ + int out_crop_bottom_offset; /* [OUT] crop information, bottom offset */ + int out_crop_left_offset; /* [OUT] crop information, left offset */ + int out_crop_right_offset; /* [OUT] crop information, right offset */ +} mfc_dec_exe_arg_t; + +typedef struct { + int in_config_param; /* [IN] Configurable parameter type */ + int out_config_value[4]; /* [IN] Values to get for the configurable parameter. */ +} mfc_get_config_arg_t; + +typedef struct { + int in_config_param; /* [IN] Configurable parameter type */ + int in_config_value[2]; /* [IN] Values to be set for the configurable parameter. */ + int out_config_value_old[2]; /* [OUT] Old values of the configurable parameters */ +} mfc_set_config_arg_t; + +typedef struct tag_get_phys_addr_arg +{ + unsigned int u_addr; + unsigned int p_addr; +} mfc_get_phys_addr_arg_t; + +typedef struct tag_mem_alloc_arg +{ + SSBSIP_MFC_CODEC_TYPE codec_type; + int buff_size; + unsigned int mapped_addr; + unsigned int out_uaddr; + unsigned int out_paddr; +} mfc_mem_alloc_arg_t; + +typedef struct tag_mem_free_arg_t +{ + unsigned int u_addr; +} mfc_mem_free_arg_t; + +typedef union { + mfc_enc_init_mpeg4_arg_t enc_init_mpeg4; + mfc_enc_init_h263_arg_t enc_init_h263; + mfc_enc_init_h264_arg_t enc_init_h264; + mfc_enc_exe_arg enc_exe; + + mfc_dec_init_arg_t dec_init; + mfc_dec_exe_arg_t dec_exe; + + mfc_get_config_arg_t get_config; + mfc_set_config_arg_t set_config; + + mfc_mem_alloc_arg_t mem_alloc; + mfc_mem_free_arg_t mem_free; + mfc_get_phys_addr_arg_t get_phys_addr; +} mfc_args; + +typedef struct tag_mfc_args { + SSBSIP_MFC_ERROR_CODE ret_code; /* [OUT] error code */ + mfc_args args; +} mfc_common_args; + +typedef struct { + int magic; + int hMFC; + int width; + int height; + int sizeStrmBuf; + mfc_frame_buf_arg_t sizeFrmBuf; + int displayStatus; + int inter_buff_status; + unsigned int virFreeStrmAddr; + unsigned int phyStrmBuf; + unsigned int virStrmBuf; + unsigned int virMvRefYC; + mfc_frame_buf_arg_t phyFrmBuf; + mfc_frame_buf_arg_t virFrmBuf; + unsigned int mapped_addr; + mfc_common_args MfcArg; + SSBSIP_MFC_CODEC_TYPE codec_type; + SSBSIP_MFC_DEC_OUTPUT_INFO decOutInfo; + unsigned int encodedHeaderSize; + int encodedDataSize; + unsigned int encodedframeType; + int in_frametag; + int out_frametag_top; + int out_frametag_bottom; + unsigned int encoded_Y_paddr; + unsigned int encoded_C_paddr; +} _MFCLIB; + +#endif /* _MFC_INTERFACE_H_ */ diff --git a/sec_mm/sec_omx/sec_omx_component/common/Android.mk b/sec_mm/sec_omx/sec_omx_component/common/Android.mk new file mode 100644 index 0000000..6633682 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/common/Android.mk @@ -0,0 +1,24 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := \ + SEC_OMX_Basecomponent.c \ + SEC_OMX_Baseport.c \ + SEC_OMX_Resourcemanager.c + +LOCAL_PRELINK_MODULE := false +LOCAL_MODULE := libsecbasecomponent.aries + +LOCAL_CFLAGS := + +LOCAL_STATIC_LIBRARIES := libsecosal.aries +LOCAL_SHARED_LIBRARIES := libcutils libutils + +LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ + $(SEC_OMX_INC)/sec \ + $(SEC_OMX_TOP)/sec_osal + +include $(BUILD_STATIC_LIBRARY) + diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c new file mode 100644 index 0000000..d1b224f --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c @@ -0,0 +1,1486 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Basecomponent.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include + +#include "SEC_OSAL_Event.h" +#include "SEC_OSAL_Thread.h" +#include "SEC_OMX_Baseport.h" +#include "SEC_OMX_Basecomponent.h" +#include "SEC_OMX_Macros.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_BASE_COMP" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +/* Change CHECK_SIZE_VERSION Macro */ +OMX_ERRORTYPE SEC_OMX_Check_SizeVersion(OMX_PTR header, OMX_U32 size) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + + OMX_VERSIONTYPE* version = NULL; + if (header == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + version = (OMX_VERSIONTYPE*)((char*)header + sizeof(OMX_U32)); + if (*((OMX_U32*)header) != size) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (version->s.nVersionMajor != VERSIONMAJOR_NUMBER || + version->s.nVersionMinor != VERSIONMINOR_NUMBER) { + ret = OMX_ErrorVersionMismatch; + goto EXIT; + } + ret = OMX_ErrorNone; +EXIT: + return ret; +} + +OMX_ERRORTYPE SEC_OMX_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 ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + OMX_U32 compUUID[3]; + + FunctionIn(); + + /* check parameters */ + if (hComponent == NULL || + pComponentName == NULL || pComponentVersion == NULL || + pSpecVersion == NULL || pComponentUUID == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + SEC_OSAL_Strcpy(pComponentName, pSECComponent->componentName); + SEC_OSAL_Memcpy(pComponentVersion, &(pSECComponent->componentVersion), sizeof(OMX_VERSIONTYPE)); + SEC_OSAL_Memcpy(pSpecVersion, &(pSECComponent->specVersion), sizeof(OMX_VERSIONTYPE)); + + /* Fill UUID with handle address, PID and UID. + * This should guarantee uiniqness */ + compUUID[0] = (OMX_U32)pOMXComponent; + compUUID[1] = getpid(); + compUUID[2] = getuid(); + SEC_OSAL_Memcpy(*pComponentUUID, compUUID, 3 * sizeof(*compUUID)); + + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_GetState ( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_OUT OMX_STATETYPE *pState) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL || pState == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + *pState = pSECComponent->currentState; + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +static OMX_ERRORTYPE SEC_OMX_BufferProcessThread(OMX_PTR threadData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_MESSAGE *message = NULL; + + FunctionIn(); + + if (threadData == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)threadData; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pSECComponent->sec_BufferProcess(pOMXComponent); + + SEC_OSAL_TheadExit(NULL); + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_ComponentStateSet(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 messageParam) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_MESSAGE *message; + OMX_STATETYPE destState = messageParam; + OMX_STATETYPE currentState = pSECComponent->currentState; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_S32 countValue = 0; + int i = 0, j = 0; + + FunctionIn(); + + /* check parameters */ + if (currentState == destState) { + ret = OMX_ErrorSameState; + goto EXIT; + } + if (currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + if ((currentState == OMX_StateLoaded) && (destState == OMX_StateIdle)) { + ret = SEC_OMX_Get_Resource(pOMXComponent); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + } + if (((currentState == OMX_StateIdle) && (destState == OMX_StateLoaded)) || + ((currentState == OMX_StateIdle) && (destState == OMX_StateInvalid)) || + ((currentState == OMX_StateExecuting) && (destState == OMX_StateInvalid)) || + ((currentState == OMX_StatePause) && (destState == OMX_StateInvalid))) { + SEC_OMX_Release_Resource(pOMXComponent); + } + + SEC_OSAL_Log(SEC_LOG_TRACE, "destState: %d", destState); + + switch (destState) { + case OMX_StateInvalid: + switch (currentState) { + case OMX_StateIdle: + case OMX_StateExecuting: + case OMX_StatePause: + case OMX_StateLoaded: + case OMX_StateWaitForResources: + pSECComponent->currentState = OMX_StateInvalid; + if (pSECComponent->hBufferProcess) { + pSECComponent->bExitBufferProcessThread = OMX_TRUE; + + for (i = 0; i < ALL_PORT_NUM; i++) { + SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[i].bufferSemID, &countValue); + if (countValue == 0) + SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[i].bufferSemID); + } + + SEC_OSAL_SignalSet(pSECComponent->pauseEvent); + SEC_OSAL_ThreadTerminate(pSECComponent->hBufferProcess); + pSECComponent->hBufferProcess = NULL; + + for (i = 0; i < ALL_PORT_NUM; i++) { + SEC_OSAL_MutexTerminate(pSECComponent->secDataBuffer[i].bufferMutex); + pSECComponent->secDataBuffer[i].bufferMutex = NULL; + } + + SEC_OSAL_SignalTerminate(pSECComponent->pauseEvent); + for (i = 0; i < ALL_PORT_NUM; i++) { + SEC_OSAL_SemaphoreTerminate(pSECComponent->pSECPort[i].bufferSemID); + pSECComponent->pSECPort[i].bufferSemID = NULL; + } + } + if (pSECComponent->sec_mfc_componentTerminate != NULL) + pSECComponent->sec_mfc_componentTerminate(pOMXComponent); + break; + } + ret = OMX_ErrorInvalidState; + break; + case OMX_StateLoaded: + switch (currentState) { + case OMX_StateIdle: + pSECComponent->bExitBufferProcessThread = OMX_TRUE; + + for (i = 0; i < ALL_PORT_NUM; i++) { + SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[i].bufferSemID, &countValue); + if (countValue == 0) + SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[i].bufferSemID); + } + + SEC_OSAL_SignalSet(pSECComponent->pauseEvent); + SEC_OSAL_ThreadTerminate(pSECComponent->hBufferProcess); + pSECComponent->hBufferProcess = NULL; + + for (i = 0; i < ALL_PORT_NUM; i++) { + SEC_OSAL_MutexTerminate(pSECComponent->secDataBuffer[i].bufferMutex); + pSECComponent->secDataBuffer[i].bufferMutex = NULL; + } + + SEC_OSAL_SignalTerminate(pSECComponent->pauseEvent); + for (i = 0; i < ALL_PORT_NUM; i++) { + SEC_OSAL_SemaphoreTerminate(pSECComponent->pSECPort[i].bufferSemID); + pSECComponent->pSECPort[i].bufferSemID = NULL; + } + + pSECComponent->sec_mfc_componentTerminate(pOMXComponent); + + for (i = 0; i < (pSECComponent->portParam.nPorts); i++) { + pSECPort = (pSECComponent->pSECPort + i); + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) > 0) { + message = (SEC_OMX_MESSAGE*)SEC_OSAL_Dequeue(&pSECPort->bufferQ); + if (message != NULL) + SEC_OSAL_Free(message); + } + ret = pSECComponent->sec_FreeTunnelBuffer(pSECComponent, i); + if (OMX_ErrorNone != ret) { + goto EXIT; + } + } else { + if (CHECK_PORT_ENABLED(pSECPort)) { + SEC_OSAL_SemaphoreWait(pSECPort->unloadedResource); + pSECPort->portDefinition.bPopulated = OMX_FALSE; + } + } + } + pSECComponent->currentState = OMX_StateLoaded; + break; + case OMX_StateWaitForResources: + ret = SEC_OMX_Out_WaitForResource(pOMXComponent); + pSECComponent->currentState = OMX_StateLoaded; + break; + case OMX_StateExecuting: + case OMX_StatePause: + default: + ret = OMX_ErrorIncorrectStateTransition; + break; + } + break; + case OMX_StateIdle: + switch (currentState) { + case OMX_StateLoaded: + for (i = 0; i < pSECComponent->portParam.nPorts; i++) { + pSECPort = (pSECComponent->pSECPort + i); + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + if (CHECK_PORT_ENABLED(pSECPort)) { + ret = pSECComponent->sec_AllocateTunnelBuffer(pSECPort, i); + if (ret!=OMX_ErrorNone) + goto EXIT; + } + } else { + if (CHECK_PORT_ENABLED(pSECPort)) { + SEC_OSAL_SemaphoreWait(pSECComponent->pSECPort[i].loadedResource); + pSECPort->portDefinition.bPopulated = OMX_TRUE; + } + } + } + ret = pSECComponent->sec_mfc_componentInit(pOMXComponent); + if (ret != OMX_ErrorNone) { + /* + * if (CHECK_PORT_TUNNELED == OMX_TRUE) thenTunnel Buffer Free + */ + goto EXIT; + } + pSECComponent->bExitBufferProcessThread = OMX_FALSE; + SEC_OSAL_SignalCreate(&pSECComponent->pauseEvent); + for (i = 0; i < ALL_PORT_NUM; i++) { + SEC_OSAL_SemaphoreCreate(&pSECComponent->pSECPort[i].bufferSemID); + } + for (i = 0; i < ALL_PORT_NUM; i++) { + SEC_OSAL_MutexCreate(&pSECComponent->secDataBuffer[i].bufferMutex); + } + ret = SEC_OSAL_ThreadCreate(&pSECComponent->hBufferProcess, + SEC_OMX_BufferProcessThread, + pOMXComponent); + if (ret != OMX_ErrorNone) { + /* + * if (CHECK_PORT_TUNNELED == OMX_TRUE) thenTunnel Buffer Free + */ + + SEC_OSAL_SignalTerminate(pSECComponent->pauseEvent); + for (i = 0; i < ALL_PORT_NUM; i++) { + SEC_OSAL_MutexTerminate(pSECComponent->secDataBuffer[i].bufferMutex); + pSECComponent->secDataBuffer[i].bufferMutex = NULL; + } + for (i = 0; i < ALL_PORT_NUM; i++) { + SEC_OSAL_SemaphoreTerminate(pSECComponent->pSECPort[i].bufferSemID); + pSECComponent->pSECPort[i].bufferSemID = NULL; + } + + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + pSECComponent->currentState = OMX_StateIdle; + break; + case OMX_StateExecuting: + case OMX_StatePause: + SEC_OMX_BufferFlushProcessNoEvent(pOMXComponent, ALL_PORT_INDEX); + pSECComponent->currentState = OMX_StateIdle; + break; + case OMX_StateWaitForResources: + pSECComponent->currentState = OMX_StateIdle; + break; + } + break; + case OMX_StateExecuting: + switch (currentState) { + case OMX_StateLoaded: + ret = OMX_ErrorIncorrectStateTransition; + break; + case OMX_StateIdle: + for (i = 0; i < pSECComponent->portParam.nPorts; i++) { + pSECPort = &pSECComponent->pSECPort[i]; + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort) && CHECK_PORT_ENABLED(pSECPort)) { + for (j = 0; j < pSECPort->tunnelBufferNum; j++) { + SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[i].bufferSemID); + } + } + } + + pSECComponent->transientState = SEC_OMX_TransStateMax; + pSECComponent->currentState = OMX_StateExecuting; + SEC_OSAL_SignalSet(pSECComponent->pauseEvent); + break; + case OMX_StatePause: + for (i = 0; i < pSECComponent->portParam.nPorts; i++) { + pSECPort = &pSECComponent->pSECPort[i]; + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort) && CHECK_PORT_ENABLED(pSECPort)) { + OMX_U32 semaValue = 0, cnt = 0; + SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[i].bufferSemID, &semaValue); + if (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) > semaValue) { + cnt = SEC_OSAL_GetElemNum(&pSECPort->bufferQ) - semaValue; + for (j = 0; j < cnt; j++) { + SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[i].bufferSemID); + } + } + } + } + + pSECComponent->currentState = OMX_StateExecuting; + SEC_OSAL_SignalSet(pSECComponent->pauseEvent); + break; + case OMX_StateWaitForResources: + ret = OMX_ErrorIncorrectStateTransition; + break; + } + break; + case OMX_StatePause: + switch (currentState) { + case OMX_StateLoaded: + ret = OMX_ErrorIncorrectStateTransition; + break; + case OMX_StateIdle: + pSECComponent->currentState = OMX_StatePause; + break; + case OMX_StateExecuting: + pSECComponent->currentState = OMX_StatePause; + break; + case OMX_StateWaitForResources: + ret = OMX_ErrorIncorrectStateTransition; + break; + } + break; + case OMX_StateWaitForResources: + switch (currentState) { + case OMX_StateLoaded: + ret = SEC_OMX_In_WaitForResource(pOMXComponent); + pSECComponent->currentState = OMX_StateWaitForResources; + break; + case OMX_StateIdle: + case OMX_StateExecuting: + case OMX_StatePause: + ret = OMX_ErrorIncorrectStateTransition; + break; + } + break; + } + +EXIT: + if (ret == OMX_ErrorNone) { + if (pSECComponent->pCallbacks != NULL) { + pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, + pSECComponent->callbackData, + OMX_EventCmdComplete, OMX_CommandStateSet, + destState, NULL); + } + } else { + if (pSECComponent->pCallbacks != NULL) { + pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, + pSECComponent->callbackData, + OMX_EventError, ret, 0, NULL); + } + } + FunctionOut(); + + return ret; +} + +static OMX_ERRORTYPE SEC_OMX_MessageHandlerThread(OMX_PTR threadData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_MESSAGE *message = NULL; + OMX_U32 messageType = 0, portIndex = 0; + + FunctionIn(); + + if (threadData == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pOMXComponent = (OMX_COMPONENTTYPE *)threadData; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + while (pSECComponent->bExitMessageHandlerThread != OMX_TRUE) { + SEC_OSAL_SemaphoreWait(pSECComponent->msgSemaphoreHandle); + message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECComponent->messageQ); + if (message != NULL) { + messageType = message->messageType; + switch (messageType) { + case OMX_CommandStateSet: + ret = SEC_OMX_ComponentStateSet(pOMXComponent, message->messageParam); + break; + case OMX_CommandFlush: + ret = SEC_OMX_BufferFlushProcess(pOMXComponent, message->messageParam); + break; + case OMX_CommandPortDisable: + ret = SEC_OMX_PortDisableProcess(pOMXComponent, message->messageParam); + break; + case OMX_CommandPortEnable: + ret = SEC_OMX_PortEnableProcess(pOMXComponent, message->messageParam); + break; + case OMX_CommandMarkBuffer: + portIndex = message->messageParam; + pSECComponent->pSECPort[portIndex].markType.hMarkTargetComponent = ((OMX_MARKTYPE *)message->pCmdData)->hMarkTargetComponent; + pSECComponent->pSECPort[portIndex].markType.pMarkData = ((OMX_MARKTYPE *)message->pCmdData)->pMarkData; + break; + case (OMX_COMMANDTYPE)SEC_OMX_CommandComponentDeInit: + pSECComponent->bExitMessageHandlerThread = OMX_TRUE; + break; + default: + break; + } + SEC_OSAL_Free(message); + message = NULL; + } + } + + SEC_OSAL_TheadExit(NULL); + +EXIT: + FunctionOut(); + + return ret; +} + +static OMX_ERRORTYPE SEC_StateSet(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) +{ + OMX_U32 destState = nParam; + OMX_U32 i = 0; + + if ((destState == OMX_StateIdle) && (pSECComponent->currentState == OMX_StateLoaded)) { + pSECComponent->transientState = SEC_OMX_TransStateLoadedToIdle; + for(i = 0; i < pSECComponent->portParam.nPorts; i++) { + pSECComponent->pSECPort[i].portState = OMX_StateIdle; + } + SEC_OSAL_Log(SEC_LOG_TRACE, "to OMX_StateIdle"); + } else if ((destState == OMX_StateLoaded) && (pSECComponent->currentState == OMX_StateIdle)) { + pSECComponent->transientState = SEC_OMX_TransStateIdleToLoaded; + for (i = 0; i < pSECComponent->portParam.nPorts; i++) { + pSECComponent->pSECPort[i].portState = OMX_StateLoaded; + } + SEC_OSAL_Log(SEC_LOG_TRACE, "to OMX_StateLoaded"); + } else if ((destState == OMX_StateIdle) && (pSECComponent->currentState == OMX_StateExecuting)) { + pSECComponent->transientState = SEC_OMX_TransStateExecutingToIdle; + SEC_OSAL_Log(SEC_LOG_TRACE, "to OMX_StateIdle"); + } else if ((destState == OMX_StateExecuting) && (pSECComponent->currentState == OMX_StateIdle)) { + pSECComponent->transientState = SEC_OMX_TransStateIdleToExecuting; + SEC_OSAL_Log(SEC_LOG_TRACE, "to OMX_StateExecuting"); + } else if (destState == OMX_StateInvalid) { + for (i = 0; i < pSECComponent->portParam.nPorts; i++) { + pSECComponent->pSECPort[i].portState = OMX_StateInvalid; + } + } + + return OMX_ErrorNone; +} + +static OMX_ERRORTYPE SEC_SetPortFlush(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_U32 portIndex = nParam; + OMX_U16 i = 0, cnt = 0, index = 0; + + + if ((pSECComponent->currentState == OMX_StateExecuting) || + (pSECComponent->currentState == OMX_StatePause)) { + if ((portIndex != ALL_PORT_INDEX) && + ((OMX_S32)portIndex >= (OMX_S32)pSECComponent->portParam.nPorts)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + /********************* + * need flush event set ????? + **********************/ + cnt = (portIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1; + for (i = 0; i < cnt; i++) { + if (portIndex == ALL_PORT_INDEX) + index = i; + else + index = portIndex; + pSECComponent->pSECPort[index].bIsPortFlushed = OMX_TRUE; + } + } else { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + ret = OMX_ErrorNone; + +EXIT: + return ret; +} + +static OMX_ERRORTYPE SEC_SetPortEnable(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_U32 portIndex = nParam; + OMX_U16 i = 0, cnt = 0; + + FunctionIn(); + + if ((portIndex != ALL_PORT_INDEX) && + ((OMX_S32)portIndex >= (OMX_S32)pSECComponent->portParam.nPorts)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + if (portIndex == ALL_PORT_INDEX) { + for (i = 0; i < pSECComponent->portParam.nPorts; i++) { + pSECPort = &pSECComponent->pSECPort[i]; + if (CHECK_PORT_ENABLED(pSECPort)) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } else { + pSECPort->portState = OMX_StateIdle; + } + } + } else { + pSECPort = &pSECComponent->pSECPort[portIndex]; + if (CHECK_PORT_ENABLED(pSECPort)) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } else { + pSECPort->portState = OMX_StateIdle; + } + } + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; + +} + +static OMX_ERRORTYPE SEC_SetPortDisable(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_U32 portIndex = nParam; + OMX_U16 i = 0, cnt = 0; + + FunctionIn(); + + if ((portIndex != ALL_PORT_INDEX) && + ((OMX_S32)portIndex >= (OMX_S32)pSECComponent->portParam.nPorts)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + if (portIndex == ALL_PORT_INDEX) { + for (i = 0; i < pSECComponent->portParam.nPorts; i++) { + pSECPort = &pSECComponent->pSECPort[i]; + if (!CHECK_PORT_ENABLED(pSECPort)) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + pSECPort->portState = OMX_StateLoaded; + pSECPort->bIsPortDisabled = OMX_TRUE; + } + } else { + pSECPort = &pSECComponent->pSECPort[portIndex]; + pSECPort->portState = OMX_StateLoaded; + pSECPort->bIsPortDisabled = OMX_TRUE; + } + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +static OMX_ERRORTYPE SEC_SetMarkBuffer(SEC_OMX_BASECOMPONENT *pSECComponent, OMX_U32 nParam) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_U32 portIndex = nParam; + OMX_U16 i = 0, cnt = 0; + + + if (nParam >= pSECComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + if ((pSECComponent->currentState == OMX_StateExecuting) || + (pSECComponent->currentState == OMX_StatePause)) { + ret = OMX_ErrorNone; + } else { + ret = OMX_ErrorIncorrectStateOperation; + } + +EXIT: + return ret; +} + +static OMX_ERRORTYPE SEC_OMX_CommandQueue( + SEC_OMX_BASECOMPONENT *pSECComponent, + OMX_COMMANDTYPE Cmd, + OMX_U32 nParam, + OMX_PTR pCmdData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_MESSAGE *command = (SEC_OMX_MESSAGE *)SEC_OSAL_Malloc(sizeof(SEC_OMX_MESSAGE)); + + if (command == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + command->messageType = (OMX_U32)Cmd; + command->messageParam = nParam; + command->pCmdData = pCmdData; + + ret = SEC_OSAL_Queue(&pSECComponent->messageQ, (void *)command); + if (ret != 0) { + ret = OMX_ErrorUndefined; + goto EXIT; + } + ret = SEC_OSAL_SemaphorePost(pSECComponent->msgSemaphoreHandle); + +EXIT: + return ret; +} + +OMX_ERRORTYPE SEC_OMX_SendCommand( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_COMMANDTYPE Cmd, + OMX_IN OMX_U32 nParam, + OMX_IN OMX_PTR pCmdData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_MESSAGE *message = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + switch (Cmd) { + case OMX_CommandStateSet : + SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandStateSet"); + SEC_StateSet(pSECComponent, nParam); + break; + case OMX_CommandFlush : + SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandFlush"); + ret = SEC_SetPortFlush(pSECComponent, nParam); + if (ret != OMX_ErrorNone) + goto EXIT; + break; + case OMX_CommandPortDisable : + SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandPortDisable"); + ret = SEC_SetPortDisable(pSECComponent, nParam); + if (ret != OMX_ErrorNone) + goto EXIT; + break; + case OMX_CommandPortEnable : + SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandPortEnable"); + ret = SEC_SetPortEnable(pSECComponent, nParam); + if (ret != OMX_ErrorNone) + goto EXIT; + break; + case OMX_CommandMarkBuffer : + SEC_OSAL_Log(SEC_LOG_TRACE, "Command: OMX_CommandMarkBuffer"); + ret = SEC_SetMarkBuffer(pSECComponent, nParam); + if (ret != OMX_ErrorNone) + goto EXIT; + break; +/* + case SEC_CommandFillBuffer : + case SEC_CommandEmptyBuffer : + case SEC_CommandDeInit : +*/ + default: + break; + } + + ret = SEC_OMX_CommandQueue(pSECComponent, Cmd, nParam, pCmdData); + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_GetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nParamIndex, + OMX_INOUT OMX_PTR ComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (ComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + switch (nParamIndex) { + case (OMX_INDEXTYPE)OMX_COMPONENT_CAPABILITY_TYPE_INDEX: + { + /* For Android PV OpenCORE */ + OMXComponentCapabilityFlagsType *capabilityFlags = (OMXComponentCapabilityFlagsType *)ComponentParameterStructure; + SEC_OSAL_Memcpy(capabilityFlags, &pSECComponent->capabilityFlags, sizeof(OMXComponentCapabilityFlagsType)); + } + break; + case OMX_IndexParamAudioInit: + case OMX_IndexParamVideoInit: + case OMX_IndexParamImageInit: + case OMX_IndexParamOtherInit: + { + OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure; + ret = SEC_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + portParam->nPorts = 0; + portParam->nStartPortNumber = 0; + } + break; + case OMX_IndexParamPortDefinition: + { + OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure; + OMX_U32 portIndex = portDefinition->nPortIndex; + SEC_OMX_BASEPORT *pSECPort; + + if (portIndex >= pSECComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + ret = SEC_OMX_Check_SizeVersion(portDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[portIndex]; + SEC_OSAL_Memcpy(portDefinition, &pSECPort->portDefinition, portDefinition->nSize); + } + break; + case OMX_IndexParamPriorityMgmt: + { + OMX_PRIORITYMGMTTYPE *compPriority = (OMX_PRIORITYMGMTTYPE *)ComponentParameterStructure; + + ret = SEC_OMX_Check_SizeVersion(compPriority, sizeof(OMX_PRIORITYMGMTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + compPriority->nGroupID = pSECComponent->compPriority.nGroupID; + compPriority->nGroupPriority = pSECComponent->compPriority.nGroupPriority; + } + break; + + case OMX_IndexParamCompBufferSupplier: + { + OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE *)ComponentParameterStructure; + OMX_U32 portIndex = bufferSupplier->nPortIndex; + SEC_OMX_BASEPORT *pSECPort; + + if ((pSECComponent->currentState == OMX_StateLoaded) || + (pSECComponent->currentState == OMX_StateWaitForResources)) { + if (portIndex >= pSECComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + ret = SEC_OMX_Check_SizeVersion(bufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[portIndex]; + + + if (pSECPort->portDefinition.eDir == OMX_DirInput) { + if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + bufferSupplier->eBufferSupplier = OMX_BufferSupplyInput; + } else if (CHECK_PORT_TUNNELED(pSECPort)) { + bufferSupplier->eBufferSupplier = OMX_BufferSupplyOutput; + } else { + bufferSupplier->eBufferSupplier = OMX_BufferSupplyUnspecified; + } + } else { + if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + bufferSupplier->eBufferSupplier = OMX_BufferSupplyOutput; + } else if (CHECK_PORT_TUNNELED(pSECPort)) { + bufferSupplier->eBufferSupplier = OMX_BufferSupplyInput; + } else { + bufferSupplier->eBufferSupplier = OMX_BufferSupplyUnspecified; + } + } + } + else + { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + } + break; + default: + { + ret = OMX_ErrorUnsupportedIndex; + goto EXIT; + } + break; + } + + ret = OMX_ErrorNone; + +EXIT: + + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_SetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR ComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (ComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + switch (nIndex) { + case OMX_IndexParamAudioInit: + case OMX_IndexParamVideoInit: + case OMX_IndexParamImageInit: + case OMX_IndexParamOtherInit: + { + OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure; + ret = SEC_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if ((pSECComponent->currentState != OMX_StateLoaded) && + (pSECComponent->currentState != OMX_StateWaitForResources)) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + ret = OMX_ErrorUndefined; + /* SEC_OSAL_Memcpy(&pSECComponent->portParam, portParam, sizeof(OMX_PORT_PARAM_TYPE)); */ + } + break; + case OMX_IndexParamPortDefinition: + { + OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure; + OMX_U32 portIndex = portDefinition->nPortIndex; + SEC_OMX_BASEPORT *pSECPort; + + if (portIndex >= pSECComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + ret = SEC_OMX_Check_SizeVersion(portDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[portIndex]; + + if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { + if (pSECPort->portDefinition.bEnabled == OMX_TRUE) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + } + if (portDefinition->nBufferCountActual < pSECPort->portDefinition.nBufferCountMin) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + SEC_OSAL_Memcpy(&pSECPort->portDefinition, portDefinition, portDefinition->nSize); + } + break; + case OMX_IndexParamPriorityMgmt: + { + OMX_PRIORITYMGMTTYPE *compPriority = (OMX_PRIORITYMGMTTYPE *)ComponentParameterStructure; + + if ((pSECComponent->currentState != OMX_StateLoaded) && + (pSECComponent->currentState != OMX_StateWaitForResources)) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + + ret = SEC_OMX_Check_SizeVersion(compPriority, sizeof(OMX_PRIORITYMGMTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + pSECComponent->compPriority.nGroupID = compPriority->nGroupID; + pSECComponent->compPriority.nGroupPriority = compPriority->nGroupPriority; + } + break; + case OMX_IndexParamCompBufferSupplier: + { + OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE *)ComponentParameterStructure; + OMX_U32 portIndex = bufferSupplier->nPortIndex; + SEC_OMX_BASEPORT *pSECPort; + + if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { + if (pSECPort->portDefinition.bEnabled == OMX_TRUE) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + } + + if (portIndex >= pSECComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + ret = SEC_OMX_Check_SizeVersion(bufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[portIndex]; + if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyUnspecified) { + ret = OMX_ErrorNone; + goto EXIT; + } + if (CHECK_PORT_TUNNELED(pSECPort) == 0) { + ret = OMX_ErrorNone; /*OMX_ErrorNone ?????*/ + goto EXIT; + } + + if (pSECPort->portDefinition.eDir == OMX_DirInput) { + if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyInput) { + /* + if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + ret = OMX_ErrorNone; + } + */ + pSECPort->tunnelFlags |= SEC_TUNNEL_IS_SUPPLIER; + bufferSupplier->nPortIndex = pSECPort->tunneledPort; + ret = OMX_SetParameter(pSECPort->tunneledComponent, OMX_IndexParamCompBufferSupplier, bufferSupplier); + goto EXIT; + } else if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyOutput) { + ret = OMX_ErrorNone; + if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + pSECPort->tunnelFlags &= ~SEC_TUNNEL_IS_SUPPLIER; + bufferSupplier->nPortIndex = pSECPort->tunneledPort; + ret = OMX_SetParameter(pSECPort->tunneledComponent, OMX_IndexParamCompBufferSupplier, bufferSupplier); + } + goto EXIT; + } + } else if (pSECPort->portDefinition.eDir == OMX_DirOutput) { + if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyInput) { + ret = OMX_ErrorNone; + if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + pSECPort->tunnelFlags &= ~SEC_TUNNEL_IS_SUPPLIER; + ret = OMX_ErrorNone; + } + goto EXIT; + } else if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyOutput) { + /* + if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + ret = OMX_ErrorNone; + } + */ + pSECPort->tunnelFlags |= SEC_TUNNEL_IS_SUPPLIER; + ret = OMX_ErrorNone; + goto EXIT; + } + } + } + break; + default: + { + ret = OMX_ErrorUnsupportedIndex; + goto EXIT; + } + break; + } + + ret = OMX_ErrorNone; + +EXIT: + + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_GetConfig( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_INOUT OMX_PTR pComponentConfigStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pComponentConfigStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_SetConfig( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR pComponentConfigStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pComponentConfigStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_GetExtensionIndex( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_STRING cParameterName, + OMX_OUT OMX_INDEXTYPE *pIndexType) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if ((cParameterName == NULL) || (pIndexType == NULL)) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + ret = OMX_ErrorBadParameter; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_SetCallbacks ( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_CALLBACKTYPE* pCallbacks, + OMX_IN OMX_PTR pAppData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pCallbacks == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + if (pSECComponent->currentState != OMX_StateLoaded) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + + pSECComponent->pCallbacks = pCallbacks; + pSECComponent->callbackData = pAppData; + + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_UseEGLImage( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr, + OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_PTR pAppPrivate, + OMX_IN void *eglImage) +{ + return OMX_ErrorNotImplemented; +} + +OMX_ERRORTYPE SEC_OMX_BaseComponent_Constructor( + OMX_IN OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + pSECComponent = SEC_OSAL_Malloc(sizeof(SEC_OMX_BASECOMPONENT)); + if (pSECComponent == NULL) { + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); + goto EXIT; + } + SEC_OSAL_Memset(pSECComponent, 0, sizeof(SEC_OMX_BASECOMPONENT)); + pOMXComponent->pComponentPrivate = (OMX_PTR)pSECComponent; + + ret = SEC_OSAL_SemaphoreCreate(&pSECComponent->msgSemaphoreHandle); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); + goto EXIT; + } + ret = SEC_OSAL_MutexCreate(&pSECComponent->compMutex); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); + goto EXIT; + } + + pSECComponent->bExitMessageHandlerThread = OMX_FALSE; + SEC_OSAL_QueueCreate(&pSECComponent->messageQ); + ret = SEC_OSAL_ThreadCreate(&pSECComponent->hMessageHandler, SEC_OMX_MessageHandlerThread, pOMXComponent); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); + goto EXIT; + } + + pOMXComponent->GetComponentVersion = &SEC_OMX_GetComponentVersion; + pOMXComponent->SendCommand = &SEC_OMX_SendCommand; + pOMXComponent->GetConfig = &SEC_OMX_GetConfig; + pOMXComponent->GetExtensionIndex = &SEC_OMX_GetExtensionIndex; + pOMXComponent->GetState = &SEC_OMX_GetState; + pOMXComponent->SetCallbacks = &SEC_OMX_SetCallbacks; + pOMXComponent->UseEGLImage = &SEC_OMX_UseEGLImage; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_BaseComponent_Destructor( + OMX_IN OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + OMX_U32 semaValue = 0; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + SEC_OMX_CommandQueue(pSECComponent, SEC_OMX_CommandComponentDeInit, 0, NULL); + SEC_OSAL_SleepMillisec(0); + SEC_OSAL_Get_SemaphoreCount(pSECComponent->msgSemaphoreHandle, &semaValue); + if (semaValue == 0) + SEC_OSAL_SemaphorePost(pSECComponent->msgSemaphoreHandle); + SEC_OSAL_SemaphorePost(pSECComponent->msgSemaphoreHandle); + + SEC_OSAL_ThreadTerminate(pSECComponent->hMessageHandler); + pSECComponent->hMessageHandler = NULL; + + SEC_OSAL_MutexTerminate(pSECComponent->compMutex); + pSECComponent->compMutex = NULL; + SEC_OSAL_SemaphoreTerminate(pSECComponent->msgSemaphoreHandle); + pSECComponent->msgSemaphoreHandle = NULL; + SEC_OSAL_QueueTerminate(&pSECComponent->messageQ); + + SEC_OSAL_Free(pSECComponent); + pSECComponent = NULL; + + ret = OMX_ErrorNone; +EXIT: + FunctionOut(); + + return ret; +} + + diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.h b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.h new file mode 100644 index 0000000..d413257 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.h @@ -0,0 +1,174 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Basecomponent.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_BASECOMP +#define SEC_OMX_BASECOMP + +#include "SEC_OMX_Def.h" +#include "OMX_Component.h" +#include "SEC_OSAL_Queue.h" +#include "SEC_OMX_Baseport.h" + + +typedef struct _SEC_OMX_MESSAGE +{ + OMX_U32 messageType; + OMX_U32 messageParam; + OMX_PTR pCmdData; +} SEC_OMX_MESSAGE; + +typedef struct _SEC_OMX_DATABUFFER +{ + OMX_HANDLETYPE bufferMutex; + OMX_BUFFERHEADERTYPE* bufferHeader; + OMX_BOOL dataValid; + OMX_U32 allocSize; + OMX_U32 dataLen; + OMX_U32 usedDataLen; + OMX_U32 remainDataLen; + OMX_U32 nFlags; + OMX_TICKS timeStamp; +} SEC_OMX_DATABUFFER; + +typedef struct _SEC_BUFFER_HEADER{ + void *YPhyAddr; // [IN/OUT] physical address of Y + void *CPhyAddr; // [IN/OUT] physical address of CbCr + void *YVirAddr; // [IN/OUT] virtual address of Y + void *CVirAddr; // [IN/OUT] virtual address of CbCr + int YSize; // [IN/OUT] input size of Y data + int CSize; // [IN/OUT] input size of CbCr data +} SEC_BUFFER_HEADER; + +typedef struct _SEC_OMX_DATA +{ + OMX_BYTE dataBuffer; + OMX_U32 allocSize; + OMX_U32 dataLen; + OMX_U32 usedDataLen; + OMX_U32 remainDataLen; + OMX_U32 previousDataLen; + OMX_U32 nFlags; + OMX_TICKS timeStamp; + SEC_BUFFER_HEADER specificBufferHeader; +} SEC_OMX_DATA; + +/* for Check TimeStamp after Seek */ +typedef struct _SEC_OMX_TIMESTAPM +{ + OMX_BOOL needSetStartTimeStamp; + OMX_BOOL needCheckStartTimeStamp; + OMX_TICKS startTimeStamp; + OMX_U32 nStartFlags; +} SEC_OMX_TIMESTAMP; + +typedef struct _SEC_OMX_BASECOMPONENT +{ + OMX_STRING componentName; + OMX_VERSIONTYPE componentVersion; + OMX_VERSIONTYPE specVersion; + + OMX_STATETYPE currentState; + SEC_OMX_TRANS_STATETYPE transientState; + + SEC_CODEC_TYPE codecType; + SEC_OMX_PRIORITYMGMTTYPE compPriority; + OMX_MARKTYPE propagateMarkType; + OMX_HANDLETYPE compMutex; + + OMX_HANDLETYPE hCodecHandle; + + /* Message Handler */ + OMX_BOOL bExitMessageHandlerThread; + OMX_HANDLETYPE hMessageHandler; + OMX_HANDLETYPE msgSemaphoreHandle; + SEC_QUEUE messageQ; + + /* Buffer Process */ + OMX_BOOL bExitBufferProcessThread; + OMX_HANDLETYPE hBufferProcess; + + /* Buffer */ + SEC_OMX_DATABUFFER secDataBuffer[2]; + + /* Data */ + SEC_OMX_DATA processData[2]; + + /* Port */ + OMX_PORT_PARAM_TYPE portParam; + SEC_OMX_BASEPORT *pSECPort; + + OMX_HANDLETYPE pauseEvent; + + /* Callback function */ + OMX_CALLBACKTYPE *pCallbacks; + OMX_PTR callbackData; + + /* Save Timestamp */ + OMX_TICKS timeStamp[MAX_TIMESTAMP]; + SEC_OMX_TIMESTAMP checkTimeStamp; + + /* Save Flags */ + OMX_U32 nFlags[MAX_FLAGS]; + + OMX_BOOL getAllDelayBuffer; + OMX_BOOL remainOutputData; + OMX_BOOL reInputData; + + /* Android CapabilityFlags */ + OMXComponentCapabilityFlagsType capabilityFlags; + + OMX_BOOL bUseFlagEOF; + OMX_BOOL bSaveFlagEOS; + + OMX_ERRORTYPE (*sec_mfc_componentInit)(OMX_COMPONENTTYPE *pOMXComponent); + OMX_ERRORTYPE (*sec_mfc_componentTerminate)(OMX_COMPONENTTYPE *pOMXComponent); + OMX_ERRORTYPE (*sec_mfc_bufferProcess) (OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData); + + OMX_ERRORTYPE (*sec_AllocateTunnelBuffer)(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex); + OMX_ERRORTYPE (*sec_FreeTunnelBuffer)(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex); + OMX_ERRORTYPE (*sec_BufferProcess)(OMX_HANDLETYPE hComponent); + OMX_ERRORTYPE (*sec_BufferReset)(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex); + OMX_ERRORTYPE (*sec_InputBufferReturn)(OMX_COMPONENTTYPE *pOMXComponent); + OMX_ERRORTYPE (*sec_OutputBufferReturn)(OMX_COMPONENTTYPE *pOMXComponent); + + int (*sec_checkInputFrame)(unsigned char *pInputStream, int buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame); + +} SEC_OMX_BASECOMPONENT; + + +#ifdef __cplusplus +extern "C" { +#endif + + OMX_ERRORTYPE SEC_OMX_Check_SizeVersion(OMX_PTR header, OMX_U32 size); + + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c new file mode 100644 index 0000000..0e0f7ea --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c @@ -0,0 +1,1005 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Baseport.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * HyeYeon Chung (hyeon.chung@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include + +#include "SEC_OMX_Macros.h" +#include "SEC_OSAL_Event.h" +#include "SEC_OSAL_Semaphore.h" +#include "SEC_OSAL_Mutex.h" + +#include "SEC_OMX_Baseport.h" +#include "SEC_OMX_Basecomponent.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_BASE_PORT" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +OMX_ERRORTYPE SEC_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_BUFFERHEADERTYPE *bufferHeader = NULL; + SEC_OMX_MESSAGE *message = NULL; + OMX_U32 flushNum = 0; + OMX_S32 semValue = 0; + + FunctionIn(); + + pSECPort = &pSECComponent->pSECPort[portIndex]; + while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) > 0) { + SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[portIndex].bufferSemID, &semValue); + if (semValue == 0) + SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[portIndex].bufferSemID); + SEC_OSAL_SemaphoreWait(pSECComponent->pSECPort[portIndex].bufferSemID); + + message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ); + if (message != NULL) { + bufferHeader = (OMX_BUFFERHEADERTYPE *)message->pCmdData; + bufferHeader->nFilledLen = 0; + + if (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + if (portIndex) { + OMX_EmptyThisBuffer(pSECPort->tunneledComponent, bufferHeader); + } else { + OMX_FillThisBuffer(pSECPort->tunneledComponent, bufferHeader); + } + SEC_OSAL_Free(message); + message = NULL; + } else if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + SEC_OSAL_Log(SEC_LOG_ERROR, "Tunneled mode is not working, Line:%d", __LINE__); + ret = OMX_ErrorNotImplemented; + SEC_OSAL_Queue(&pSECPort->bufferQ, pSECPort); + goto EXIT; + } else { + if (portIndex == OUTPUT_PORT_INDEX) { + pSECComponent->pCallbacks->FillBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); + } else { + pSECComponent->pCallbacks->EmptyBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); + } + + SEC_OSAL_Free(message); + message = NULL; + } + } + } + + if (pSECComponent->secDataBuffer[portIndex].dataValid == OMX_TRUE) { + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + message = SEC_OSAL_Malloc(sizeof(SEC_OMX_MESSAGE)); + message->pCmdData = pSECComponent->secDataBuffer[portIndex].bufferHeader; + message->messageType = 0; + message->messageParam = -1; + SEC_OSAL_Queue(&pSECPort->bufferQ, message); + pSECComponent->sec_BufferReset(pOMXComponent, portIndex); + } else { + if (portIndex == INPUT_PORT_INDEX) + pSECComponent->sec_InputBufferReturn(pOMXComponent); + else if (portIndex == OUTPUT_PORT_INDEX) + pSECComponent->sec_OutputBufferReturn(pOMXComponent); + } + } + + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) < pSECPort->assignedBufferNum) { + SEC_OSAL_SemaphoreWait(pSECComponent->pSECPort[portIndex].bufferSemID); + } + if (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) != pSECPort->assignedBufferNum) + SEC_OSAL_SetElemNum(&pSECPort->bufferQ, pSECPort->assignedBufferNum); + } else { + while(1) { + int cnt; + SEC_OSAL_Get_SemaphoreCount(pSECComponent->pSECPort[portIndex].bufferSemID, &cnt); + if (cnt == 0) + break; + SEC_OSAL_SemaphoreWait(pSECComponent->pSECPort[portIndex].bufferSemID); + } + SEC_OSAL_SetElemNum(&pSECPort->bufferQ, 0); + } + + pSECComponent->processData[portIndex].dataLen = 0; + pSECComponent->processData[portIndex].nFlags = 0; + pSECComponent->processData[portIndex].remainDataLen = 0; + pSECComponent->processData[portIndex].timeStamp = 0; + pSECComponent->processData[portIndex].usedDataLen = 0; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_BufferFlushProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_S32 portIndex = 0; + OMX_U32 i = 0, cnt = 0; + SEC_OMX_DATABUFFER *flushBuffer = NULL; + + FunctionIn(); + + if (pOMXComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + cnt = (nPortIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1; + + for (i = 0; i < cnt; i++) { + if (nPortIndex == ALL_PORT_INDEX) + portIndex = i; + else + portIndex = nPortIndex; + + SEC_OSAL_SignalSet(pSECComponent->pauseEvent); + + flushBuffer = &pSECComponent->secDataBuffer[portIndex]; + + SEC_OSAL_MutexLock(flushBuffer->bufferMutex); + ret = SEC_OMX_FlushPort(pOMXComponent, portIndex); + SEC_OSAL_MutexUnlock(flushBuffer->bufferMutex); + + pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_FALSE; + + if (ret == OMX_ErrorNone) { + SEC_OSAL_Log(SEC_LOG_TRACE,"OMX_CommandFlush EventCmdComplete"); + pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, + pSECComponent->callbackData, + OMX_EventCmdComplete, + OMX_CommandFlush, portIndex, NULL); + } + + if (portIndex == INPUT_PORT_INDEX) { + pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE; + pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; + SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); + SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); + pSECComponent->getAllDelayBuffer = OMX_FALSE; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + pSECComponent->reInputData = OMX_FALSE; + } else if (portIndex == OUTPUT_PORT_INDEX) { + pSECComponent->remainOutputData = OMX_FALSE; + } + } + +EXIT: + if (ret != OMX_ErrorNone) { + pSECComponent->pCallbacks->EventHandler(pOMXComponent, + pSECComponent->callbackData, + OMX_EventError, + ret, 0, NULL); + } + + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_BufferFlushProcessNoEvent(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_S32 portIndex = 0; + OMX_U32 i = 0, cnt = 0; + SEC_OMX_DATABUFFER *flushBuffer = NULL; + + FunctionIn(); + + if (pOMXComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + cnt = (nPortIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1; + + for (i = 0; i < cnt; i++) { + if (nPortIndex == ALL_PORT_INDEX) + portIndex = i; + else + portIndex = nPortIndex; + + pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_TRUE; + + SEC_OSAL_SignalSet(pSECComponent->pauseEvent); + + flushBuffer = &pSECComponent->secDataBuffer[portIndex]; + + SEC_OSAL_MutexLock(flushBuffer->bufferMutex); + ret = SEC_OMX_FlushPort(pOMXComponent, portIndex); + SEC_OSAL_MutexUnlock(flushBuffer->bufferMutex); + + pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_FALSE; + + if (portIndex == INPUT_PORT_INDEX) { + pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE; + pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; + SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); + SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); + pSECComponent->getAllDelayBuffer = OMX_FALSE; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + pSECComponent->remainOutputData = OMX_FALSE; + pSECComponent->reInputData = OMX_FALSE; + } + } + +EXIT: + if (ret != OMX_ErrorNone) { + pSECComponent->pCallbacks->EventHandler(pOMXComponent, + pSECComponent->callbackData, + OMX_EventError, + ret, 0, NULL); + } + + FunctionOut(); + + return ret; +} + + +OMX_ERRORTYPE SEC_OMX_EnablePort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_U32 i = 0, cnt = 0; + + FunctionIn(); + + pSECPort = &pSECComponent->pSECPort[portIndex]; + pSECPort->portDefinition.bEnabled = OMX_TRUE; + + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + ret = pSECComponent->sec_AllocateTunnelBuffer(pSECPort, portIndex); + if (OMX_ErrorNone != ret) { + goto EXIT; + } + pSECPort->portDefinition.bPopulated = OMX_TRUE; + if (pSECComponent->currentState == OMX_StateExecuting) { + for (i=0; itunnelBufferNum; i++) { + SEC_OSAL_SemaphorePost(pSECComponent->pSECPort[portIndex].bufferSemID); + } + } + } else if (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { + SEC_OSAL_SemaphoreWait(pSECPort->loadedResource); + pSECPort->portDefinition.bPopulated = OMX_TRUE; + } + } else { + if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { + SEC_OSAL_SemaphoreWait(pSECPort->loadedResource); + pSECPort->portDefinition.bPopulated = OMX_TRUE; + } + } + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_PortEnableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + OMX_S32 portIndex = 0; + OMX_U32 i = 0, cnt = 0; + + FunctionIn(); + + if (pOMXComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + cnt = (nPortIndex == ALL_PORT_INDEX) ? ALL_PORT_NUM : 1; + + for (i = 0; i < cnt; i++) { + if (nPortIndex == ALL_PORT_INDEX) + portIndex = i; + else + portIndex = nPortIndex; + + ret = SEC_OMX_EnablePort(pOMXComponent, portIndex); + if (ret == OMX_ErrorNone) { + pSECComponent->pCallbacks->EventHandler(pOMXComponent, + pSECComponent->callbackData, + OMX_EventCmdComplete, + OMX_CommandPortEnable, portIndex, NULL); + } + } + +EXIT: + if (ret != OMX_ErrorNone) { + pSECComponent->pCallbacks->EventHandler(pOMXComponent, + pSECComponent->callbackData, + OMX_EventError, + ret, 0, NULL); + } + + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_DisablePort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_U32 i = 0, elemNum = 0; + SEC_OMX_MESSAGE *message; + + FunctionIn(); + + pSECPort = &pSECComponent->pSECPort[portIndex]; + + if (!CHECK_PORT_ENABLED(pSECPort)) { + ret = OMX_ErrorNone; + goto EXIT; + } + + if (pSECComponent->currentState!=OMX_StateLoaded) { + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) >0 ) { + message = (SEC_OMX_MESSAGE*)SEC_OSAL_Dequeue(&pSECPort->bufferQ); + SEC_OSAL_Free(message); + } + ret = pSECComponent->sec_FreeTunnelBuffer(pSECPort, portIndex); + if (OMX_ErrorNone != ret) { + goto EXIT; + } + pSECPort->portDefinition.bPopulated = OMX_FALSE; + } else if (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + pSECPort->portDefinition.bPopulated = OMX_FALSE; + SEC_OSAL_SemaphoreWait(pSECPort->unloadedResource); + } else { + if (CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + while (SEC_OSAL_GetElemNum(&pSECPort->bufferQ) >0 ) { + message = (SEC_OMX_MESSAGE*)SEC_OSAL_Dequeue(&pSECPort->bufferQ); + SEC_OSAL_Free(message); + } + } + pSECPort->portDefinition.bPopulated = OMX_FALSE; + SEC_OSAL_SemaphoreWait(pSECPort->unloadedResource); + } + } + pSECPort->portDefinition.bEnabled = OMX_FALSE; + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_PortDisableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + OMX_S32 portIndex = 0; + OMX_U32 i = 0, cnt = 0; + SEC_OMX_DATABUFFER *flushBuffer = NULL; + + FunctionIn(); + + if (pOMXComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + cnt = (nPortIndex == ALL_PORT_INDEX ) ? ALL_PORT_NUM : 1; + + /* port flush*/ + for(i = 0; i < cnt; i++) { + if (nPortIndex == ALL_PORT_INDEX) + portIndex = i; + else + portIndex = nPortIndex; + + pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_TRUE; + + flushBuffer = &pSECComponent->secDataBuffer[portIndex]; + + SEC_OSAL_MutexLock(flushBuffer->bufferMutex); + ret = SEC_OMX_FlushPort(pOMXComponent, portIndex); + SEC_OSAL_MutexUnlock(flushBuffer->bufferMutex); + + pSECComponent->pSECPort[portIndex].bIsPortFlushed = OMX_FALSE; + + if (portIndex == INPUT_PORT_INDEX) { + pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE; + pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; + SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); + SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); + pSECComponent->getAllDelayBuffer = OMX_FALSE; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + pSECComponent->reInputData = OMX_FALSE; + } else if (portIndex == OUTPUT_PORT_INDEX) { + pSECComponent->remainOutputData = OMX_FALSE; + } + } + + for(i = 0; i < cnt; i++) { + if (nPortIndex == ALL_PORT_INDEX) + portIndex = i; + else + portIndex = nPortIndex; + + ret = SEC_OMX_DisablePort(pOMXComponent, portIndex); + pSECComponent->pSECPort[portIndex].bIsPortDisabled = OMX_FALSE; + if (ret == OMX_ErrorNone) { + pSECComponent->pCallbacks->EventHandler(pOMXComponent, + pSECComponent->callbackData, + OMX_EventCmdComplete, + OMX_CommandPortDisable, portIndex, NULL); + } + } + +EXIT: + if (ret != OMX_ErrorNone) { + pSECComponent->pCallbacks->EventHandler(pOMXComponent, + pSECComponent->callbackData, + OMX_EventError, + ret, 0, NULL); + } + + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_EmptyThisBuffer( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_BOOL findBuffer = OMX_FALSE; + SEC_OMX_MESSAGE *message; + OMX_U32 i = 0; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + if (pBuffer == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (pBuffer->nInputPortIndex != INPUT_PORT_INDEX) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + ret = SEC_OMX_Check_SizeVersion(pBuffer, sizeof(OMX_BUFFERHEADERTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if ((pSECComponent->currentState != OMX_StateIdle) && + (pSECComponent->currentState != OMX_StateExecuting) && + (pSECComponent->currentState != OMX_StatePause)) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + if ((!CHECK_PORT_ENABLED(pSECPort)) || + ((CHECK_PORT_BEING_FLUSHED(pSECPort) || CHECK_PORT_BEING_DISABLED(pSECPort)) && + (!CHECK_PORT_TUNNELED(pSECPort) || !CHECK_PORT_BUFFER_SUPPLIER(pSECPort))) || + ((pSECComponent->transientState == SEC_OMX_TransStateExecutingToIdle) && + (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)))) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + + for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { + if (pBuffer == pSECPort->bufferHeader[i]) { + findBuffer = OMX_TRUE; + break; + } + } + + if (findBuffer == OMX_FALSE) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } else { + ret = OMX_ErrorNone; + } + + message = SEC_OSAL_Malloc(sizeof(SEC_OMX_MESSAGE)); + if (message == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + message->messageType = SEC_OMX_CommandEmptyBuffer; + message->messageParam = (OMX_U32) i; + message->pCmdData = (OMX_PTR)pBuffer; + + SEC_OSAL_Queue(&pSECPort->bufferQ, (void *)message); + SEC_OSAL_SemaphorePost(pSECPort->bufferSemID); + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_FillThisBuffer( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_BOOL findBuffer = OMX_FALSE; + SEC_OMX_MESSAGE *message; + OMX_U32 i = 0; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + if (pBuffer == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (pBuffer->nOutputPortIndex != OUTPUT_PORT_INDEX) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + ret = SEC_OMX_Check_SizeVersion(pBuffer, sizeof(OMX_BUFFERHEADERTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if ((pSECComponent->currentState != OMX_StateIdle) && + (pSECComponent->currentState != OMX_StateExecuting) && + (pSECComponent->currentState != OMX_StatePause)) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + if ((!CHECK_PORT_ENABLED(pSECPort)) || + ((CHECK_PORT_BEING_FLUSHED(pSECPort) || CHECK_PORT_BEING_DISABLED(pSECPort)) && + (!CHECK_PORT_TUNNELED(pSECPort) || !CHECK_PORT_BUFFER_SUPPLIER(pSECPort))) || + ((pSECComponent->transientState == SEC_OMX_TransStateExecutingToIdle) && + (CHECK_PORT_TUNNELED(pSECPort) && !CHECK_PORT_BUFFER_SUPPLIER(pSECPort)))) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + + for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { + if (pBuffer == pSECPort->bufferHeader[i]) { + findBuffer = OMX_TRUE; + break; + } + } + + if (findBuffer == OMX_FALSE) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } else { + ret = OMX_ErrorNone; + } + + message = SEC_OSAL_Malloc(sizeof(SEC_OMX_MESSAGE)); + if (message == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + message->messageType = SEC_OMX_CommandFillBuffer; + message->messageParam = (OMX_U32) i; + message->pCmdData = (OMX_PTR)pBuffer; + + SEC_OSAL_Queue(&pSECPort->bufferQ, (void *)message); + SEC_OSAL_SemaphorePost(pSECPort->bufferSemID); + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_Port_Constructor(OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + SEC_OMX_BASEPORT *pSECInputPort = NULL; + SEC_OMX_BASEPORT *pSECOutputPort = NULL; + int i = 0; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + INIT_SET_SIZE_VERSION(&pSECComponent->portParam, OMX_PORT_PARAM_TYPE); + pSECComponent->portParam.nPorts = ALL_PORT_NUM; + pSECComponent->portParam.nStartPortNumber = INPUT_PORT_INDEX; + + pSECPort = SEC_OSAL_Malloc(sizeof(SEC_OMX_BASEPORT) * ALL_PORT_NUM); + if (pSECPort == NULL) { + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); + goto EXIT; + } + SEC_OSAL_Memset(pSECPort, 0, sizeof(SEC_OMX_BASEPORT) * ALL_PORT_NUM); + pSECComponent->pSECPort = pSECPort; + + /* Input Port */ + pSECInputPort = &pSECPort[INPUT_PORT_INDEX]; + + SEC_OSAL_QueueCreate(&pSECInputPort->bufferQ); + + pSECInputPort->bufferHeader = SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE*) * MAX_BUFFER_NUM); + if (pSECInputPort->bufferHeader == NULL) { + SEC_OSAL_Free(pSECPort); + pSECPort = NULL; + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); + goto EXIT; + } + SEC_OSAL_Memset(pSECInputPort->bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE*) * MAX_BUFFER_NUM); + + pSECInputPort->bufferStateAllocate = SEC_OSAL_Malloc(sizeof(OMX_U32) * MAX_BUFFER_NUM); + if (pSECInputPort->bufferStateAllocate == NULL) { + SEC_OSAL_Free(pSECInputPort->bufferHeader); + pSECInputPort->bufferHeader = NULL; + SEC_OSAL_Free(pSECPort); + pSECPort = NULL; + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); + goto EXIT; + } + SEC_OSAL_Memset(pSECInputPort->bufferStateAllocate, 0, sizeof(OMX_U32) * MAX_BUFFER_NUM); + + pSECInputPort->bufferSemID = NULL; + pSECInputPort->assignedBufferNum = 0; + pSECInputPort->portState = OMX_StateMax; + pSECInputPort->bIsPortFlushed = OMX_FALSE; + pSECInputPort->bIsPortDisabled = OMX_FALSE; + pSECInputPort->tunneledComponent = NULL; + pSECInputPort->tunneledPort = 0; + pSECInputPort->tunnelBufferNum = 0; + pSECInputPort->bufferSupplier = OMX_BufferSupplyUnspecified; + pSECInputPort->tunnelFlags = 0; + pSECInputPort->eControlRate = OMX_Video_ControlRateDisable; + ret = SEC_OSAL_SemaphoreCreate(&pSECInputPort->loadedResource); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); + pSECInputPort->bufferStateAllocate = NULL; + SEC_OSAL_Free(pSECInputPort->bufferHeader); + pSECInputPort->bufferHeader = NULL; + SEC_OSAL_Free(pSECPort); + pSECPort = NULL; + goto EXIT; + } + ret = SEC_OSAL_SemaphoreCreate(&pSECInputPort->unloadedResource); + if (ret != OMX_ErrorNone) { + SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); + pSECInputPort->loadedResource = NULL; + SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); + pSECInputPort->bufferStateAllocate = NULL; + SEC_OSAL_Free(pSECInputPort->bufferHeader); + pSECInputPort->bufferHeader = NULL; + SEC_OSAL_Free(pSECPort); + pSECPort = NULL; + goto EXIT; + } + + INIT_SET_SIZE_VERSION(&pSECInputPort->portDefinition, OMX_PARAM_PORTDEFINITIONTYPE); + pSECInputPort->portDefinition.nPortIndex = INPUT_PORT_INDEX; + pSECInputPort->portDefinition.eDir = OMX_DirInput; + pSECInputPort->portDefinition.nBufferCountActual = 0; + pSECInputPort->portDefinition.nBufferCountMin = 0; + pSECInputPort->portDefinition.nBufferSize = 0; + pSECInputPort->portDefinition.bEnabled = OMX_FALSE; + pSECInputPort->portDefinition.bPopulated = OMX_FALSE; + pSECInputPort->portDefinition.eDomain = OMX_PortDomainMax; + pSECInputPort->portDefinition.bBuffersContiguous = OMX_FALSE; + pSECInputPort->portDefinition.nBufferAlignment = 0; + pSECInputPort->markType.hMarkTargetComponent = NULL; + pSECInputPort->markType.pMarkData = NULL; + + /* Output Port */ + pSECOutputPort = &pSECPort[OUTPUT_PORT_INDEX]; + + SEC_OSAL_QueueCreate(&pSECOutputPort->bufferQ); + + pSECOutputPort->bufferHeader = SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE*) * MAX_BUFFER_NUM); + if (pSECOutputPort->bufferHeader == NULL) { + SEC_OSAL_SemaphoreTerminate(pSECInputPort->unloadedResource); + pSECInputPort->unloadedResource = NULL; + SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); + pSECInputPort->loadedResource = NULL; + SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); + pSECInputPort->bufferStateAllocate = NULL; + SEC_OSAL_Free(pSECInputPort->bufferHeader); + pSECInputPort->bufferHeader = NULL; + SEC_OSAL_Free(pSECPort); + pSECPort = NULL; + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + SEC_OSAL_Memset(pSECOutputPort->bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE*) * MAX_BUFFER_NUM); + + pSECOutputPort->bufferStateAllocate = SEC_OSAL_Malloc(sizeof(OMX_U32) * MAX_BUFFER_NUM); + if (pSECOutputPort->bufferStateAllocate == NULL) { + SEC_OSAL_Free(pSECOutputPort->bufferHeader); + pSECOutputPort->bufferHeader = NULL; + + SEC_OSAL_SemaphoreTerminate(pSECInputPort->unloadedResource); + pSECInputPort->unloadedResource = NULL; + SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); + pSECInputPort->loadedResource = NULL; + SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); + pSECInputPort->bufferStateAllocate = NULL; + SEC_OSAL_Free(pSECInputPort->bufferHeader); + pSECInputPort->bufferHeader = NULL; + SEC_OSAL_Free(pSECPort); + pSECPort = NULL; + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + SEC_OSAL_Memset(pSECOutputPort->bufferStateAllocate, 0, sizeof(OMX_U32) * MAX_BUFFER_NUM); + + pSECOutputPort->bufferSemID = NULL; + pSECOutputPort->assignedBufferNum = 0; + pSECOutputPort->portState = OMX_StateMax; + pSECOutputPort->bIsPortFlushed = OMX_FALSE; + pSECOutputPort->bIsPortDisabled = OMX_FALSE; + pSECOutputPort->tunneledComponent = NULL; + pSECOutputPort->tunneledPort = 0; + pSECOutputPort->tunnelBufferNum = 0; + pSECOutputPort->bufferSupplier = OMX_BufferSupplyUnspecified; + pSECOutputPort->tunnelFlags = 0; + pSECOutputPort->eControlRate = OMX_Video_ControlRateDisable; + ret = SEC_OSAL_SemaphoreCreate(&pSECOutputPort->loadedResource); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Free(pSECOutputPort->bufferStateAllocate); + pSECOutputPort->bufferStateAllocate = NULL; + SEC_OSAL_Free(pSECOutputPort->bufferHeader); + pSECOutputPort->bufferHeader = NULL; + + SEC_OSAL_SemaphoreTerminate(pSECInputPort->unloadedResource); + pSECInputPort->unloadedResource = NULL; + SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); + pSECInputPort->loadedResource = NULL; + SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); + pSECInputPort->bufferStateAllocate = NULL; + SEC_OSAL_Free(pSECInputPort->bufferHeader); + pSECInputPort->bufferHeader = NULL; + SEC_OSAL_Free(pSECPort); + pSECPort = NULL; + goto EXIT; + } + ret = SEC_OSAL_SemaphoreCreate(&pSECOutputPort->unloadedResource); + if (ret != OMX_ErrorNone) { + SEC_OSAL_SemaphoreTerminate(pSECOutputPort->loadedResource); + pSECOutputPort->loadedResource = NULL; + SEC_OSAL_Free(pSECOutputPort->bufferStateAllocate); + pSECOutputPort->bufferStateAllocate = NULL; + SEC_OSAL_Free(pSECOutputPort->bufferHeader); + pSECOutputPort->bufferHeader = NULL; + + SEC_OSAL_SemaphoreTerminate(pSECInputPort->unloadedResource); + pSECInputPort->unloadedResource = NULL; + SEC_OSAL_SemaphoreTerminate(pSECInputPort->loadedResource); + pSECInputPort->loadedResource = NULL; + SEC_OSAL_Free(pSECInputPort->bufferStateAllocate); + pSECInputPort->bufferStateAllocate = NULL; + SEC_OSAL_Free(pSECInputPort->bufferHeader); + pSECInputPort->bufferHeader = NULL; + SEC_OSAL_Free(pSECPort); + pSECPort = NULL; + goto EXIT; + } + + INIT_SET_SIZE_VERSION(&pSECOutputPort->portDefinition, OMX_PARAM_PORTDEFINITIONTYPE); + pSECOutputPort->portDefinition.nPortIndex = OUTPUT_PORT_INDEX; + pSECOutputPort->portDefinition.eDir = OMX_DirOutput; + pSECOutputPort->portDefinition.nBufferCountActual = 0; + pSECOutputPort->portDefinition.nBufferCountMin = 0; + pSECOutputPort->portDefinition.nBufferSize = 0; + pSECOutputPort->portDefinition.bEnabled = OMX_FALSE; + pSECOutputPort->portDefinition.bPopulated = OMX_FALSE; + pSECOutputPort->portDefinition.eDomain = OMX_PortDomainMax; + pSECOutputPort->portDefinition.bBuffersContiguous = OMX_FALSE; + pSECOutputPort->portDefinition.nBufferAlignment = 0; + pSECOutputPort->markType.hMarkTargetComponent = NULL; + pSECOutputPort->markType.pMarkData = NULL; + + pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE; + pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; + pSECComponent->checkTimeStamp.startTimeStamp = 0; + pSECComponent->checkTimeStamp.nStartFlags = 0x0; + + pOMXComponent->EmptyThisBuffer = &SEC_OMX_EmptyThisBuffer; + pOMXComponent->FillThisBuffer = &SEC_OMX_FillThisBuffer; + + ret = OMX_ErrorNone; +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_Port_Destructor(OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + + FunctionIn(); + + int i = 0; + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + for (i = 0; i < ALL_PORT_NUM; i++) { + pSECPort = &pSECComponent->pSECPort[i]; + + SEC_OSAL_SemaphoreTerminate(pSECPort->loadedResource); + pSECPort->loadedResource = NULL; + SEC_OSAL_SemaphoreTerminate(pSECPort->unloadedResource); + pSECPort->unloadedResource = NULL; + SEC_OSAL_Free(pSECPort->bufferStateAllocate); + pSECPort->bufferStateAllocate = NULL; + SEC_OSAL_Free(pSECPort->bufferHeader); + pSECPort->bufferHeader = NULL; + + SEC_OSAL_QueueTerminate(&pSECPort->bufferQ); + } + SEC_OSAL_Free(pSECComponent->pSECPort); + pSECComponent->pSECPort = NULL; + ret = OMX_ErrorNone; +EXIT: + FunctionOut(); + + return ret; +} diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h new file mode 100644 index 0000000..f38226b --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h @@ -0,0 +1,90 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Baseport.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * HyeYeon Chung (hyeon.chung@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_BASE_PORT +#define SEC_OMX_BASE_PORT + + +#include "OMX_Component.h" +#include "SEC_OMX_Def.h" +#include "SEC_OSAL_Queue.h" + + +#define BUFFER_STATE_ALLOCATED (1 << 0) +#define BUFFER_STATE_ASSIGNED (1 << 1) +#define HEADER_STATE_ALLOCATED (1 << 2) +#define BUFFER_STATE_FREE 0 + +#define MAX_BUFFER_NUM 20 + +#define INPUT_PORT_INDEX 0 +#define OUTPUT_PORT_INDEX 1 +#define ALL_PORT_INDEX -1 +#define ALL_PORT_NUM 2 + +typedef struct _SEC_OMX_BASEPORT +{ + OMX_BUFFERHEADERTYPE **bufferHeader; + OMX_U32 *bufferStateAllocate; + OMX_PARAM_PORTDEFINITIONTYPE portDefinition; + OMX_HANDLETYPE bufferSemID; + SEC_QUEUE bufferQ; + OMX_U32 assignedBufferNum; + OMX_STATETYPE portState; + OMX_HANDLETYPE loadedResource; + OMX_HANDLETYPE unloadedResource; + + OMX_BOOL bIsPortFlushed; + OMX_BOOL bIsPortDisabled; + OMX_MARKTYPE markType; + + /* Tunnel Info */ + OMX_HANDLETYPE tunneledComponent; + OMX_U32 tunneledPort; + OMX_U32 tunnelBufferNum; + OMX_BUFFERSUPPLIERTYPE bufferSupplier; + OMX_U32 tunnelFlags; + + OMX_VIDEO_CONTROLRATETYPE eControlRate; +} SEC_OMX_BASEPORT; + + +#ifdef __cplusplus +extern "C" { +#endif + +OMX_ERRORTYPE SEC_OMX_PortEnableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); +OMX_ERRORTYPE SEC_OMX_PortDisableProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); +OMX_ERRORTYPE SEC_OMX_BufferFlushProcess(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); +OMX_ERRORTYPE SEC_OMX_BufferFlushProcessNoEvent(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex); + +#ifdef __cplusplus +}; +#endif + + +#endif diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.c b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.c new file mode 100644 index 0000000..41673ad --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.c @@ -0,0 +1,383 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Resourcemanager.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include + +#include "SEC_OMX_Resourcemanager.h" +#include "SEC_OMX_Basecomponent.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_RM" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +#define MAX_RESOURCE_VIDEO 4 + +/* Max allowable video scheduler component instance */ +static SEC_OMX_RM_COMPONENT_LIST *gpVideoRMComponentList = NULL; +static SEC_OMX_RM_COMPONENT_LIST *gpVideoRMWaitingList = NULL; +static OMX_HANDLETYPE ghVideoRMComponentListMutex = NULL; + + +OMX_ERRORTYPE addElementList(SEC_OMX_RM_COMPONENT_LIST **ppList, OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_RM_COMPONENT_LIST *pTempComp = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (*ppList != NULL) { + pTempComp = *ppList; + while (pTempComp->pNext != NULL) { + pTempComp = pTempComp->pNext; + } + pTempComp->pNext = (SEC_OMX_RM_COMPONENT_LIST *)SEC_OSAL_Malloc(sizeof(SEC_OMX_RM_COMPONENT_LIST)); + if (pTempComp->pNext == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + ((SEC_OMX_RM_COMPONENT_LIST *)(pTempComp->pNext))->pNext = NULL; + ((SEC_OMX_RM_COMPONENT_LIST *)(pTempComp->pNext))->pOMXStandComp = pOMXComponent; + ((SEC_OMX_RM_COMPONENT_LIST *)(pTempComp->pNext))->groupPriority = pSECComponent->compPriority.nGroupPriority; + goto EXIT; + } else { + *ppList = (SEC_OMX_RM_COMPONENT_LIST *)SEC_OSAL_Malloc(sizeof(SEC_OMX_RM_COMPONENT_LIST)); + if (*ppList == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + pTempComp = *ppList; + pTempComp->pNext = NULL; + pTempComp->pOMXStandComp = pOMXComponent; + pTempComp->groupPriority = pSECComponent->compPriority.nGroupPriority; + } + +EXIT: + return ret; +} + +OMX_ERRORTYPE removeElementList(SEC_OMX_RM_COMPONENT_LIST **ppList, OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_RM_COMPONENT_LIST *pCurrComp = NULL; + SEC_OMX_RM_COMPONENT_LIST *pPrevComp = NULL; + OMX_BOOL bDetectComp = OMX_FALSE; + + if (*ppList == NULL) { + ret = OMX_ErrorUndefined; + goto EXIT; + } + + pCurrComp = *ppList; + while (pCurrComp != NULL) { + if (pCurrComp->pOMXStandComp == pOMXComponent) { + if (*ppList == pCurrComp) { + *ppList = pCurrComp->pNext; + SEC_OSAL_Free(pCurrComp); + } else { + pPrevComp->pNext = pCurrComp->pNext; + SEC_OSAL_Free(pCurrComp); + } + bDetectComp = OMX_TRUE; + break; + } else { + pPrevComp = pCurrComp; + pCurrComp = pCurrComp->pNext; + } + } + + if (bDetectComp == OMX_FALSE) + ret = OMX_ErrorComponentNotFound; + else + ret = OMX_ErrorNone; + +EXIT: + return ret; +} + +int searchLowPriority(SEC_OMX_RM_COMPONENT_LIST *RMComp_list, int inComp_priority, SEC_OMX_RM_COMPONENT_LIST **outLowComp) +{ + int ret = 0; + SEC_OMX_RM_COMPONENT_LIST *pTempComp = NULL; + SEC_OMX_RM_COMPONENT_LIST *pCandidateComp = NULL; + + if (RMComp_list == NULL) + ret = -1; + + pTempComp = RMComp_list; + *outLowComp = 0; + + while (pTempComp != NULL) { + if (pTempComp->groupPriority > inComp_priority) { + if (pCandidateComp != NULL) { + if (pCandidateComp->groupPriority < pTempComp->groupPriority) + pCandidateComp = pTempComp; + } else { + pCandidateComp = pTempComp; + } + } + + pTempComp = pTempComp->pNext; + } + + *outLowComp = pCandidateComp; + if (pCandidateComp == NULL) + ret = 0; + else + ret = 1; + +EXIT: + return ret; +} + +OMX_ERRORTYPE removeComponent(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateIdle) { + (*(pSECComponent->pCallbacks->EventHandler)) + (pOMXComponent, pSECComponent->callbackData, + OMX_EventError, OMX_ErrorResourcesLost, 0, NULL); + ret = OMX_SendCommand(pOMXComponent, OMX_CommandStateSet, OMX_StateLoaded, NULL); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorUndefined; + goto EXIT; + } + } else if ((pSECComponent->currentState == OMX_StateExecuting) || (pSECComponent->currentState == OMX_StatePause)) { + /* Todo */ + } + + ret = OMX_ErrorNone; + +EXIT: + return ret; +} + + +OMX_ERRORTYPE SEC_OMX_ResourceManager_Init() +{ + FunctionIn(); + SEC_OSAL_MutexCreate(&ghVideoRMComponentListMutex); + FunctionOut(); + return OMX_ErrorNone; +} + +OMX_ERRORTYPE SEC_OMX_ResourceManager_Deinit() +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_RM_COMPONENT_LIST *pCurrComponent; + SEC_OMX_RM_COMPONENT_LIST *pNextComponent; + + FunctionIn(); + + SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); + + if (gpVideoRMComponentList) { + pCurrComponent = gpVideoRMComponentList; + while (pCurrComponent != NULL) { + pNextComponent = pCurrComponent->pNext; + SEC_OSAL_Free(pCurrComponent); + pCurrComponent = pNextComponent; + } + gpVideoRMComponentList = NULL; + } + + if (gpVideoRMWaitingList) { + pCurrComponent = gpVideoRMWaitingList; + while (pCurrComponent != NULL) { + pNextComponent = pCurrComponent->pNext; + SEC_OSAL_Free(pCurrComponent); + pCurrComponent = pNextComponent; + } + gpVideoRMWaitingList = NULL; + } + SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); + + SEC_OSAL_MutexTerminate(ghVideoRMComponentListMutex); + ghVideoRMComponentListMutex = NULL; + + ret = OMX_ErrorNone; +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_Get_Resource(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_RM_COMPONENT_LIST *pComponentTemp = NULL; + SEC_OMX_RM_COMPONENT_LIST *pComponentCandidate = NULL; + int numElem = 0; + int lowCompDetect = 0; + + FunctionIn(); + + SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pComponentTemp = gpVideoRMComponentList; + if (pSECComponent->codecType == HW_VIDEO_CODEC) { + if (pComponentTemp != NULL) { + while (pComponentTemp) { + numElem++; + pComponentTemp = pComponentTemp->pNext; + } + } else { + numElem = 0; + } + if (numElem >= MAX_RESOURCE_VIDEO) { + lowCompDetect = searchLowPriority(gpVideoRMComponentList, pSECComponent->compPriority.nGroupPriority, &pComponentCandidate); + if (lowCompDetect <= 0) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } else { + ret = removeComponent(pComponentCandidate->pOMXStandComp); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } else { + ret = removeElementList(&gpVideoRMComponentList, pComponentCandidate->pOMXStandComp); + ret = addElementList(&gpVideoRMComponentList, pOMXComponent); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + } + } + } else { + ret = addElementList(&gpVideoRMComponentList, pOMXComponent); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + } + } + ret = OMX_ErrorNone; + +EXIT: + + SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); + + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_Release_Resource(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_RM_COMPONENT_LIST *pComponentTemp = NULL; + OMX_COMPONENTTYPE *pOMXWaitComponent = NULL; + int numElem = 0; + + FunctionIn(); + + SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pComponentTemp = gpVideoRMWaitingList; + if (pSECComponent->codecType == HW_VIDEO_CODEC) { + if (gpVideoRMComponentList == NULL) { + ret = OMX_ErrorUndefined; + goto EXIT; + } + + ret = removeElementList(&gpVideoRMComponentList, pOMXComponent); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorUndefined; + goto EXIT; + } + while (pComponentTemp) { + numElem++; + pComponentTemp = pComponentTemp->pNext; + } + if (numElem > 0) { + pOMXWaitComponent = gpVideoRMWaitingList->pOMXStandComp; + removeElementList(&gpVideoRMWaitingList, pOMXWaitComponent); + ret = OMX_SendCommand(pOMXWaitComponent, OMX_CommandStateSet, OMX_StateIdle, NULL); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + } + } + +EXIT: + + SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); + + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_In_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->codecType == HW_VIDEO_CODEC) + ret = addElementList(&gpVideoRMWaitingList, pOMXComponent); + + SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); + + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_Out_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + SEC_OSAL_MutexLock(ghVideoRMComponentListMutex); + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->codecType == HW_VIDEO_CODEC) + ret = removeElementList(&gpVideoRMWaitingList, pOMXComponent); + + SEC_OSAL_MutexUnlock(ghVideoRMComponentListMutex); + + FunctionOut(); + + return ret; +} + diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.h b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.h new file mode 100644 index 0000000..b958575 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Resourcemanager.h @@ -0,0 +1,59 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Resourcemanager.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_RESOURCEMANAGER +#define SEC_OMX_RESOURCEMANAGER + + +#include "SEC_OMX_Def.h" +#include "OMX_Component.h" + + +struct SEC_OMX_RM_COMPONENT_LIST; +typedef struct _SEC_OMX_RM_COMPONENT_LIST +{ + OMX_COMPONENTTYPE *pOMXStandComp; + OMX_U32 groupPriority; + struct SEC_OMX_RM_COMPONENT_LIST *pNext; +} SEC_OMX_RM_COMPONENT_LIST; + + +#ifdef __cplusplus +extern "C" { +#endif + +OMX_ERRORTYPE SEC_OMX_ResourceManager_Init(); +OMX_ERRORTYPE SEC_OMX_ResourceManager_Deinit(); +OMX_ERRORTYPE SEC_OMX_Get_Resource(OMX_COMPONENTTYPE *pOMXComponent); +OMX_ERRORTYPE SEC_OMX_Release_Resource(OMX_COMPONENTTYPE *pOMXComponent); +OMX_ERRORTYPE SEC_OMX_In_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent); +OMX_ERRORTYPE SEC_OMX_Out_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent); + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/Android.mk b/sec_mm/sec_omx/sec_omx_component/video/dec/Android.mk new file mode 100644 index 0000000..401449b --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/Android.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + SEC_OMX_Vdec.c + +LOCAL_MODULE := libSEC_OMX_Vdec.aries +LOCAL_ARM_MODE := arm +LOCAL_MODULE_TAGS := optional + +LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ + $(SEC_OMX_INC)/sec \ + $(SEC_OMX_TOP)/sec_osal \ + $(SEC_OMX_TOP)/sec_omx_core \ + $(SEC_OMX_COMPONENT)/common \ + $(SEC_OMX_COMPONENT)/video/dec + +LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include + +include $(BUILD_STATIC_LIBRARY) diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c b/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c new file mode 100644 index 0000000..48705c1 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c @@ -0,0 +1,1355 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Vdec.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * HyeYeon Chung (hyeon.chung@samsung.com) + * Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include +#include "SEC_OMX_Macros.h" +#include "SEC_OSAL_Event.h" +#include "SEC_OMX_Vdec.h" +#include "SEC_OMX_Basecomponent.h" +#include "SEC_OSAL_Thread.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_VIDEO_DEC" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + +#define ONE_FRAME_OUTPUT /* only one frame output for Android */ +#define S5PC110_DECODE_OUT_DATA_BUFFER /* for Android s5pc110 0copy*/ + + +inline void SEC_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent) +{ + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + + if ((secOutputPort->portDefinition.format.video.nFrameWidth != + secInputPort->portDefinition.format.video.nFrameWidth) || + (secOutputPort->portDefinition.format.video.nFrameHeight != + secInputPort->portDefinition.format.video.nFrameHeight)) { + OMX_U32 width = 0, height = 0; + + secOutputPort->portDefinition.format.video.nFrameWidth = + secInputPort->portDefinition.format.video.nFrameWidth; + secOutputPort->portDefinition.format.video.nFrameHeight = + secInputPort->portDefinition.format.video.nFrameHeight; + width = secOutputPort->portDefinition.format.video.nStride = + secInputPort->portDefinition.format.video.nStride; + height = secOutputPort->portDefinition.format.video.nSliceHeight = + secInputPort->portDefinition.format.video.nSliceHeight; + + switch(secOutputPort->portDefinition.format.video.eColorFormat) { + case OMX_COLOR_FormatYUV420Planar: + case OMX_COLOR_FormatYUV420SemiPlanar: + if (width && height) + secOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2; + break; + default: + if (width && height) + secOutputPort->portDefinition.nBufferSize = width * height * 2; + break; + } + } + + return ; +} + +OMX_ERRORTYPE SEC_OMX_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 ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; + int i = 0; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + pSECPort = &pSECComponent->pSECPort[nPortIndex]; + if (nPortIndex >= pSECComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + if (pSECPort->portState != OMX_StateIdle) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); + if (temp_bufferHeader == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE)); + + for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { + if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { + pSECPort->bufferHeader[i] = temp_bufferHeader; + pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED); + INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE); + temp_bufferHeader->pBuffer = pBuffer; + temp_bufferHeader->nAllocLen = nSizeBytes; + temp_bufferHeader->pAppPrivate = pAppPrivate; + if ( nPortIndex == INPUT_PORT_INDEX) + temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX; + else + temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX; + + pSECPort->assignedBufferNum++; + if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) { + pSECPort->portDefinition.bPopulated = OMX_TRUE; + /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */ + SEC_OSAL_SemaphorePost(pSECPort->loadedResource); + /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */ + } + *ppBufferHdr = temp_bufferHeader; + ret = OMX_ErrorNone; + goto EXIT; + } + } + ret = OMX_ErrorInsufficientResources; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_AllocateBuffer( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer, + OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_PTR pAppPrivate, + OMX_IN OMX_U32 nSizeBytes) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; + OMX_U8 *temp_buffer = NULL; + int i = 0; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + pSECPort = &pSECComponent->pSECPort[nPortIndex]; + if (nPortIndex >= pSECComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } +/* + if (pSECPort->portState != OMX_StateIdle ) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } +*/ + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + temp_buffer = SEC_OSAL_Malloc(sizeof(OMX_U8) * nSizeBytes); + if (temp_buffer == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + + temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); + if (temp_bufferHeader == NULL) { + SEC_OSAL_Free(temp_buffer); + temp_buffer = NULL; + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE)); + + for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { + if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { + pSECPort->bufferHeader[i] = temp_bufferHeader; + pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ALLOCATED | HEADER_STATE_ALLOCATED); + INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE); + temp_bufferHeader->pBuffer = temp_buffer; + temp_bufferHeader->nAllocLen = nSizeBytes; + temp_bufferHeader->pAppPrivate = pAppPrivate; + if ( nPortIndex == INPUT_PORT_INDEX) + temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX; + else + temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX; + pSECPort->assignedBufferNum++; + if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) { + pSECPort->portDefinition.bPopulated = OMX_TRUE; + /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */ + SEC_OSAL_SemaphorePost(pSECPort->loadedResource); + /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */ + } + *ppBuffer = temp_bufferHeader; + ret = OMX_ErrorNone; + goto EXIT; + } + } + ret = OMX_ErrorInsufficientResources; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_FreeBuffer( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; + OMX_U8 *temp_buffer = NULL; + int i = 0; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pSECPort = &pSECComponent->pSECPort[nPortIndex]; + + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + if ((pSECPort->portState != OMX_StateLoaded) && (pSECPort->portState != OMX_StateInvalid)) { + (*(pSECComponent->pCallbacks->EventHandler)) (pOMXComponent, + pSECComponent->callbackData, + (OMX_U32)OMX_EventError, + (OMX_U32)OMX_ErrorPortUnpopulated, + nPortIndex, NULL); + } + + for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { + if (((pSECPort->bufferStateAllocate[i] | BUFFER_STATE_FREE) != 0) && (pSECPort->bufferHeader[i] != NULL)) { + if (pSECPort->bufferHeader[i]->pBuffer == pBufferHdr->pBuffer) { + if (pSECPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) { + SEC_OSAL_Free(pSECPort->bufferHeader[i]->pBuffer); + pSECPort->bufferHeader[i]->pBuffer = NULL; + pBufferHdr->pBuffer = NULL; + } else if (pSECPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) { + ; /* None*/ + } + pSECPort->assignedBufferNum--; + if (pSECPort->bufferStateAllocate[i] & HEADER_STATE_ALLOCATED) { + SEC_OSAL_Free(pSECPort->bufferHeader[i]); + pSECPort->bufferHeader[i] = NULL; + pBufferHdr = NULL; + } + pSECPort->bufferStateAllocate[i] = BUFFER_STATE_FREE; + ret = OMX_ErrorNone; + goto EXIT; + } + } + } + +EXIT: + if (ret == OMX_ErrorNone) { + if ( pSECPort->assignedBufferNum == 0 ) { + SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->unloadedResource signal set"); + /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */ + SEC_OSAL_SemaphorePost(pSECPort->unloadedResource); + /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */ + pSECPort->portDefinition.bPopulated = OMX_FALSE; + } + } + + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_AllocateTunnelBuffer(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; + OMX_U8 *temp_buffer = NULL; + OMX_U32 bufferSize = 0; + OMX_PARAM_PORTDEFINITIONTYPE portDefinition; + + ret = OMX_ErrorTunnelingUnsupported; +EXIT: + return ret; +} + +OMX_ERRORTYPE SEC_OMX_FreeTunnelBuffer(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASEPORT* pSECPort = NULL; + OMX_BUFFERHEADERTYPE* temp_bufferHeader = NULL; + OMX_U8 *temp_buffer = NULL; + OMX_U32 bufferSize = 0; + + ret = OMX_ErrorTunnelingUnsupported; +EXIT: + return ret; +} + +OMX_ERRORTYPE SEC_OMX_ComponentTunnelRequest( + OMX_IN OMX_HANDLETYPE hComp, + OMX_IN OMX_U32 nPort, + OMX_IN OMX_HANDLETYPE hTunneledComp, + OMX_IN OMX_U32 nTunneledPort, + OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + + ret = OMX_ErrorTunnelingUnsupported; +EXIT: + return ret; +} + +OMX_BOOL SEC_Check_BufferProcess_State(SEC_OMX_BASECOMPONENT *pSECComponent) +{ + if ((pSECComponent->currentState == OMX_StateExecuting) && + (pSECComponent->pSECPort[INPUT_PORT_INDEX].portState == OMX_StateIdle) && + (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portState == OMX_StateIdle) && + (pSECComponent->transientState != SEC_OMX_TransStateExecutingToIdle) && + (pSECComponent->transientState != SEC_OMX_TransStateIdleToExecuting)) { + return OMX_TRUE; + } else { + return OMX_FALSE; + } +} + +static OMX_ERRORTYPE SEC_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *secOMXInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + SEC_OMX_BASEPORT *secOMXOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; + OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; + + FunctionIn(); + + if (bufferHeader != NULL) { + if (secOMXInputPort->markType.hMarkTargetComponent != NULL ) { + bufferHeader->hMarkTargetComponent = secOMXInputPort->markType.hMarkTargetComponent; + bufferHeader->pMarkData = secOMXInputPort->markType.pMarkData; + secOMXInputPort->markType.hMarkTargetComponent = NULL; + secOMXInputPort->markType.pMarkData = NULL; + } + + if (bufferHeader->hMarkTargetComponent != NULL) { + if (bufferHeader->hMarkTargetComponent == pOMXComponent) { + pSECComponent->pCallbacks->EventHandler(pOMXComponent, + pSECComponent->callbackData, + OMX_EventMark, + 0, 0, bufferHeader->pMarkData); + } else { + pSECComponent->propagateMarkType.hMarkTargetComponent = bufferHeader->hMarkTargetComponent; + pSECComponent->propagateMarkType.pMarkData = bufferHeader->pMarkData; + } + } + + if (CHECK_PORT_TUNNELED(secOMXInputPort)) { + OMX_FillThisBuffer(secOMXInputPort->tunneledComponent, bufferHeader); + } else { + bufferHeader->nFilledLen = 0; + pSECComponent->pCallbacks->EmptyBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); + } + } + + if ((pSECComponent->currentState == OMX_StatePause) && + ((!CHECK_PORT_BEING_FLUSHED(secOMXInputPort) && !CHECK_PORT_BEING_FLUSHED(secOMXOutputPort)))) { + SEC_OSAL_SignalReset(pSECComponent->pauseEvent); + SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME); + } + + dataBuffer->dataValid = OMX_FALSE; + dataBuffer->dataLen = 0; + dataBuffer->remainDataLen = 0; + dataBuffer->usedDataLen = 0; + dataBuffer->bufferHeader = NULL; + dataBuffer->nFlags = 0; + dataBuffer->timeStamp = 0; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_InputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASEPORT *pSECPort = NULL; + SEC_OMX_DATABUFFER *dataBuffer = NULL; + SEC_OMX_MESSAGE* message = NULL; + SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; + + FunctionIn(); + + pSECPort= &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + dataBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; + + if (pSECComponent->currentState != OMX_StateExecuting) { + ret = OMX_ErrorUndefined; + goto EXIT; + } else { + SEC_OSAL_SemaphoreWait(pSECPort->bufferSemID); + SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex); + if (dataBuffer->dataValid != OMX_TRUE) { + message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ); + if (message == NULL) { + ret = OMX_ErrorUndefined; + SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); + goto EXIT; + } + + dataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData); + dataBuffer->allocSize = dataBuffer->bufferHeader->nAllocLen; + dataBuffer->dataLen = dataBuffer->bufferHeader->nFilledLen; + dataBuffer->remainDataLen = dataBuffer->dataLen; + dataBuffer->usedDataLen = 0; + dataBuffer->dataValid = OMX_TRUE; + dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; + dataBuffer->timeStamp = dataBuffer->bufferHeader->nTimeStamp; + + SEC_OSAL_Free(message); + + if (dataBuffer->allocSize <= dataBuffer->dataLen) + SEC_OSAL_Log(SEC_LOG_WARNING, "Input Buffer Full, Check input buffer size! allocSize:%d, dataLen:%d", dataBuffer->allocSize, dataBuffer->dataLen); + } + SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); + ret = OMX_ErrorNone; + } +EXIT: + FunctionOut(); + + return ret; +} + +static OMX_ERRORTYPE SEC_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *secOMXInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + SEC_OMX_BASEPORT *secOMXOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; + OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; + + FunctionIn(); + + if (bufferHeader != NULL) { + bufferHeader->nFilledLen = dataBuffer->remainDataLen; + bufferHeader->nOffset = 0; + bufferHeader->nFlags = dataBuffer->nFlags; + bufferHeader->nTimeStamp = dataBuffer->timeStamp; + + if (pSECComponent->propagateMarkType.hMarkTargetComponent != NULL) { + bufferHeader->hMarkTargetComponent = pSECComponent->propagateMarkType.hMarkTargetComponent; + bufferHeader->pMarkData = pSECComponent->propagateMarkType.pMarkData; + pSECComponent->propagateMarkType.hMarkTargetComponent = NULL; + pSECComponent->propagateMarkType.pMarkData = NULL; + } + + if (bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) { + pSECComponent->pCallbacks->EventHandler(pOMXComponent, + pSECComponent->callbackData, + OMX_EventBufferFlag, + OUTPUT_PORT_INDEX, + bufferHeader->nFlags, NULL); + } + + if (CHECK_PORT_TUNNELED(secOMXOutputPort)) { + OMX_EmptyThisBuffer(secOMXOutputPort->tunneledComponent, bufferHeader); + } else { + pSECComponent->pCallbacks->FillBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); + } + } + + if ((pSECComponent->currentState == OMX_StatePause) && + ((!CHECK_PORT_BEING_FLUSHED(secOMXInputPort) && !CHECK_PORT_BEING_FLUSHED(secOMXOutputPort)))) { + SEC_OSAL_SignalReset(pSECComponent->pauseEvent); + SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME); + } + + /* reset dataBuffer */ + dataBuffer->dataValid = OMX_FALSE; + dataBuffer->dataLen = 0; + dataBuffer->remainDataLen = 0; + dataBuffer->usedDataLen = 0; + dataBuffer->bufferHeader = NULL; + dataBuffer->nFlags = 0; + dataBuffer->timeStamp = 0; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OutputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASEPORT *pSECPort = NULL; + SEC_OMX_DATABUFFER *dataBuffer = NULL; + SEC_OMX_MESSAGE *message = NULL; + SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; + + FunctionIn(); + + pSECPort= &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + dataBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; + + if (pSECComponent->currentState != OMX_StateExecuting) { + ret = OMX_ErrorUndefined; + goto EXIT; + } else { + SEC_OSAL_SemaphoreWait(pSECPort->bufferSemID); + SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); + if (dataBuffer->dataValid != OMX_TRUE) { + message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ); + if (message == NULL) { + ret = OMX_ErrorUndefined; + SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); + goto EXIT; + } + + dataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData); + dataBuffer->allocSize = dataBuffer->bufferHeader->nAllocLen; + dataBuffer->dataLen = 0; //dataBuffer->bufferHeader->nFilledLen; + dataBuffer->remainDataLen = dataBuffer->dataLen; + dataBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset; + dataBuffer->dataValid =OMX_TRUE; + /* dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; */ + /* dataBuffer->nTimeStamp = dataBuffer->bufferHeader->nTimeStamp; */ +#ifdef S5PC110_DECODE_OUT_DATA_BUFFER + pSECComponent->processData[OUTPUT_PORT_INDEX].dataBuffer = dataBuffer->bufferHeader->pBuffer; + pSECComponent->processData[OUTPUT_PORT_INDEX].allocSize = dataBuffer->bufferHeader->nAllocLen; +#endif + SEC_OSAL_Free(message); + } + SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); + ret = OMX_ErrorNone; + } +EXIT: + FunctionOut(); + + return ret; + +} + +static OMX_ERRORTYPE SEC_BufferReset(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 portIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + /* SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[portIndex]; */ + SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[portIndex]; + /* OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; */ + + dataBuffer->dataValid = OMX_FALSE; + dataBuffer->dataLen = 0; + dataBuffer->remainDataLen = 0; + dataBuffer->usedDataLen = 0; + dataBuffer->bufferHeader = NULL; + dataBuffer->nFlags = 0; + dataBuffer->timeStamp = 0; + + return ret; +} + +static OMX_ERRORTYPE SEC_DataReset(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 portIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + /* SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[portIndex]; */ + /* SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[portIndex]; */ + /* OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; */ + SEC_OMX_DATA *processData = &pSECComponent->processData[portIndex]; + + processData->dataLen = 0; + processData->remainDataLen = 0; + processData->usedDataLen = 0; + processData->nFlags = 0; + processData->timeStamp = 0; + + return ret; +} + +OMX_BOOL SEC_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_BOOL ret = OMX_FALSE; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; + SEC_OMX_DATA *inputData = &pSECComponent->processData[INPUT_PORT_INDEX]; + OMX_U32 copySize = 0; + OMX_BYTE checkInputStream = NULL; + OMX_U32 checkInputStreamLen = 0; + OMX_U32 checkedSize = 0; + OMX_BOOL flagEOF = OMX_FALSE; + OMX_BOOL previousFrameEOF = OMX_FALSE; + + FunctionIn(); + + if (inputUseBuffer->dataValid == OMX_TRUE) { + checkInputStream = inputUseBuffer->bufferHeader->pBuffer + inputUseBuffer->usedDataLen; + checkInputStreamLen = inputUseBuffer->remainDataLen; + + if (inputData->dataLen == 0) { + previousFrameEOF = OMX_TRUE; + } else { + previousFrameEOF = OMX_FALSE; + } + if ((pSECComponent->bUseFlagEOF == OMX_TRUE) && + !(inputUseBuffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG)) { + flagEOF = OMX_TRUE; + checkedSize = checkInputStreamLen; + } else { + pSECComponent->bUseFlagEOF = OMX_FALSE; + checkedSize = pSECComponent->sec_checkInputFrame(checkInputStream, checkInputStreamLen, inputUseBuffer->nFlags, previousFrameEOF, &flagEOF); + } + + if (flagEOF == OMX_TRUE) { + copySize = checkedSize; + SEC_OSAL_Log(SEC_LOG_TRACE, "sec_checkInputFrame : OMX_TRUE"); + } else { + copySize = checkInputStreamLen; + SEC_OSAL_Log(SEC_LOG_TRACE, "sec_checkInputFrame : OMX_FALSE"); + } + + if (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) + pSECComponent->bSaveFlagEOS = OMX_TRUE; + + if (((inputData->allocSize) - (inputData->dataLen)) >= copySize) { + if (copySize > 0) + SEC_OSAL_Memcpy(inputData->dataBuffer + inputData->dataLen, checkInputStream, copySize); + + inputUseBuffer->dataLen -= copySize; + inputUseBuffer->remainDataLen -= copySize; + inputUseBuffer->usedDataLen += copySize; + + inputData->dataLen += copySize; + inputData->remainDataLen += copySize; + + if (previousFrameEOF == OMX_TRUE) { + inputData->timeStamp = inputUseBuffer->timeStamp; + inputData->nFlags = inputUseBuffer->nFlags; + } + + if (pSECComponent->bUseFlagEOF == OMX_TRUE) { + if (pSECComponent->bSaveFlagEOS == OMX_TRUE) { + inputData->nFlags |= OMX_BUFFERFLAG_EOS; + flagEOF = OMX_TRUE; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + } else { + inputData->nFlags = (inputData->nFlags & (~OMX_BUFFERFLAG_EOS)); + } + } else { + if ((checkedSize == checkInputStreamLen) && (pSECComponent->bSaveFlagEOS == OMX_TRUE)) { + if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) && + ((inputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG) || + (inputData->dataLen == 0))) { + inputData->nFlags |= OMX_BUFFERFLAG_EOS; + flagEOF = OMX_TRUE; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + } else if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) && + (!(inputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG)) && + (inputData->dataLen != 0)) { + inputData->nFlags = (inputData->nFlags & (~OMX_BUFFERFLAG_EOS)); + flagEOF = OMX_TRUE; + pSECComponent->bSaveFlagEOS = OMX_TRUE; + } + } else { + inputData->nFlags = (inputUseBuffer->nFlags & (~OMX_BUFFERFLAG_EOS)); + } + } + + if(((inputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) && + (inputData->dataLen <= 0) && (flagEOF == OMX_TRUE)) { + inputData->dataLen = inputData->previousDataLen; + inputData->remainDataLen = inputData->previousDataLen; + } + } else { + /*????????????????????????????????? Error ?????????????????????????????????*/ + SEC_DataReset(pOMXComponent, INPUT_PORT_INDEX); + flagEOF = OMX_FALSE; + } + + if (inputUseBuffer->remainDataLen == 0) + SEC_InputBufferReturn(pOMXComponent); + else + inputUseBuffer->dataValid = OMX_TRUE; + } + + if (flagEOF == OMX_TRUE) { + if (pSECComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) { + pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_TRUE; + pSECComponent->checkTimeStamp.startTimeStamp = inputData->timeStamp; + pSECComponent->checkTimeStamp.nStartFlags = inputData->nFlags; + pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE; + } + + ret = OMX_TRUE; + } else { + ret = OMX_FALSE; + } + + FunctionOut(); + + return ret; +} + +OMX_BOOL SEC_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_BOOL ret = OMX_FALSE; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; + SEC_OMX_DATA *outputData = &pSECComponent->processData[OUTPUT_PORT_INDEX]; + OMX_U32 copySize = 0; + + FunctionIn(); + + if (outputUseBuffer->dataValid == OMX_TRUE) { + if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE) { + if ((pSECComponent->checkTimeStamp.startTimeStamp == outputData->timeStamp) && + (pSECComponent->checkTimeStamp.nStartFlags == outputData->nFlags)){ + pSECComponent->checkTimeStamp.startTimeStamp = -19761123; + pSECComponent->checkTimeStamp.nStartFlags = 0x0; + pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE; + pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; + } else { + SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX); + + ret = OMX_TRUE; + goto EXIT; + } + } else if (pSECComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) { + SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX); + + ret = OMX_TRUE; + goto EXIT; + } + + if (outputData->remainDataLen <= (outputUseBuffer->allocSize - outputUseBuffer->dataLen)) { + copySize = outputData->remainDataLen; +#ifndef S5PC110_DECODE_OUT_DATA_BUFFER + if (copySize > 0) + SEC_OSAL_Memcpy((outputUseBuffer->bufferHeader->pBuffer + outputUseBuffer->dataLen), + (outputData->dataBuffer + outputData->usedDataLen), + copySize); +#endif + + outputUseBuffer->dataLen += copySize; + outputUseBuffer->remainDataLen += copySize; + outputUseBuffer->nFlags = outputData->nFlags; + outputUseBuffer->timeStamp = outputData->timeStamp; + + ret = OMX_TRUE; + + /* reset outputData */ + SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX); + +#ifdef ONE_FRAME_OUTPUT /* only one frame output for Android */ + if ((outputUseBuffer->remainDataLen > 0) || + (outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS)) + SEC_OutputBufferReturn(pOMXComponent); +#else + if ((outputUseBuffer->remainDataLen > 0) || + ((outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) { + SEC_OutputBufferReturn(pOMXComponent); + } else { + outputUseBuffer->dataValid = OMX_TRUE; + } +#endif + } else { + SEC_OSAL_Log(SEC_LOG_ERROR, "output buffer is smaller than decoded data size Out Length"); + + copySize = outputUseBuffer->allocSize - outputUseBuffer->dataLen; + +#ifndef S5PC110_DECODE_OUT_DATA_BUFFER + SEC_OSAL_Memcpy((outputUseBuffer->bufferHeader->pBuffer + outputUseBuffer->dataLen), + (outputData->dataBuffer + outputData->usedDataLen), + copySize); +#endif + outputUseBuffer->dataLen += copySize; + outputUseBuffer->remainDataLen += copySize; + outputUseBuffer->nFlags = 0; + outputUseBuffer->timeStamp = outputData->timeStamp; + + ret = OMX_FALSE; + + outputData->remainDataLen -= copySize; + outputData->usedDataLen += copySize; + + SEC_OutputBufferReturn(pOMXComponent); + } + } else { + ret = OMX_FALSE; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; + SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; + SEC_OMX_DATA *inputData = &pSECComponent->processData[INPUT_PORT_INDEX]; + SEC_OMX_DATA *outputData = &pSECComponent->processData[OUTPUT_PORT_INDEX]; + OMX_U32 copySize = 0; + + pSECComponent->remainOutputData = OMX_FALSE; + pSECComponent->reInputData = OMX_FALSE; + + FunctionIn(); + + while (!pSECComponent->bExitBufferProcessThread) { + SEC_OSAL_SleepMillisec(0); + + if (((pSECComponent->currentState == OMX_StatePause) || + (pSECComponent->currentState == OMX_StateIdle) || + (pSECComponent->transientState == SEC_OMX_TransStateLoadedToIdle) || + (pSECComponent->transientState == SEC_OMX_TransStateExecutingToIdle)) && + (pSECComponent->transientState != SEC_OMX_TransStateIdleToLoaded)&& + ((!CHECK_PORT_BEING_FLUSHED(secInputPort) && !CHECK_PORT_BEING_FLUSHED(secOutputPort)))) { + SEC_OSAL_SignalReset(pSECComponent->pauseEvent); + SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME); + } + + while (SEC_Check_BufferProcess_State(pSECComponent) && !pSECComponent->bExitBufferProcessThread) { + SEC_OSAL_SleepMillisec(0); + + SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); + if ((outputUseBuffer->dataValid != OMX_TRUE) && + (!CHECK_PORT_BEING_FLUSHED(secOutputPort))) { + SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); + ret = SEC_OutputBufferGetQueue(pSECComponent); + if ((ret == OMX_ErrorUndefined) || + (secInputPort->portState != OMX_StateIdle) || + (secOutputPort->portState != OMX_StateIdle)) { + break; + } + } else { + SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); + } + + if (pSECComponent->remainOutputData == OMX_FALSE) { + if (pSECComponent->reInputData == OMX_FALSE) { + SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex); + if ((SEC_Preprocessor_InputData(pOMXComponent) == OMX_FALSE) && + (!CHECK_PORT_BEING_FLUSHED(secInputPort))) { + SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); + ret = SEC_InputBufferGetQueue(pSECComponent); + break; + } + + SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); + } + + SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex); + SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); + ret = pSECComponent->sec_mfc_bufferProcess(pOMXComponent, inputData, outputData); + SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); + SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); + + if (ret == OMX_ErrorInputDataDecodeYet) + pSECComponent->reInputData = OMX_TRUE; + else + pSECComponent->reInputData = OMX_FALSE; + } + + SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); + + if (SEC_Postprocess_OutputData(pOMXComponent) == OMX_FALSE) + pSECComponent->remainOutputData = OMX_TRUE; + else + pSECComponent->remainOutputData = OMX_FALSE; + + SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); + } + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_VideoDecodeGetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nParamIndex, + OMX_INOUT OMX_PTR ComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + if (ComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + switch (nParamIndex) { + case OMX_IndexParamVideoInit: + { + OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure; + ret = SEC_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + portParam->nPorts = pSECComponent->portParam.nPorts; + portParam->nStartPortNumber = pSECComponent->portParam.nStartPortNumber; + ret = OMX_ErrorNone; + } + break; + case OMX_IndexParamVideoPortFormat: + { + OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure; + OMX_U32 portIndex = portFormat->nPortIndex; + OMX_U32 index = portFormat->nIndex; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; + OMX_U32 supportFormatNum = 0; /* supportFormatNum = N-1 */ + + ret = SEC_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if ((portIndex >= pSECComponent->portParam.nPorts)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + + if (portIndex == INPUT_PORT_INDEX) { + supportFormatNum = INPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1; + if (index > supportFormatNum) { + ret = OMX_ErrorNoMore; + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + portDefinition = &pSECPort->portDefinition; + + portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat; + portFormat->eColorFormat = portDefinition->format.video.eColorFormat; + portFormat->xFramerate = portDefinition->format.video.xFramerate; + } else if (portIndex == OUTPUT_PORT_INDEX) { + supportFormatNum = OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1; + if (index > supportFormatNum) { + ret = OMX_ErrorNoMore; + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + portDefinition = &pSECPort->portDefinition; + + switch (index) { + case supportFormat_1: + portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; + portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar; + portFormat->xFramerate = portDefinition->format.video.xFramerate; + break; + case supportFormat_2: + portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; + portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; + portFormat->xFramerate = portDefinition->format.video.xFramerate; + break; + case supportFormat_3: + portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; + portFormat->eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress; + portFormat->xFramerate = portDefinition->format.video.xFramerate; + break; + } + } + ret = OMX_ErrorNone; + } + break; + case OMX_IndexParamVideoBitrate: + { + OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure; + OMX_U32 portIndex = videoRateControl->nPortIndex; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; + + if ((portIndex != INPUT_PORT_INDEX)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } else { + pSECPort = &pSECComponent->pSECPort[portIndex]; + portDefinition = &pSECPort->portDefinition; + + videoRateControl->eControlRate = pSECPort->eControlRate; + videoRateControl->nTargetBitrate = portDefinition->format.video.nBitrate; + } + ret = OMX_ErrorNone; + } + break; + default: + { + ret = SEC_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure); + } + break; + } + +EXIT: + FunctionOut(); + + return ret; +} +OMX_ERRORTYPE SEC_OMX_VideoDecodeSetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR ComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + if (ComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + switch (nIndex) { + case OMX_IndexParamVideoPortFormat: + { + OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure; + OMX_U32 portIndex = portFormat->nPortIndex; + OMX_U32 index = portFormat->nIndex; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; + OMX_U32 supportFormatNum = 0; + + ret = SEC_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if ((portIndex >= pSECComponent->portParam.nPorts)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } else { + pSECPort = &pSECComponent->pSECPort[portIndex]; + portDefinition = &pSECPort->portDefinition; + + portDefinition->format.video.eColorFormat = portFormat->eColorFormat; + portDefinition->format.video.eCompressionFormat = portFormat->eCompressionFormat; + portDefinition->format.video.xFramerate = portFormat->xFramerate; + } + } + break; + case OMX_IndexParamVideoBitrate: + { + OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure; + OMX_U32 portIndex = videoRateControl->nPortIndex; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; + + if ((portIndex != INPUT_PORT_INDEX)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } else { + pSECPort = &pSECComponent->pSECPort[portIndex]; + portDefinition = &pSECPort->portDefinition; + + pSECPort->eControlRate = videoRateControl->eControlRate; + portDefinition->format.video.nBitrate = videoRateControl->nTargetBitrate; + } + ret = OMX_ErrorNone; + } + break; + default: + { + ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure); + } + break; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_VideoDecodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); + goto EXIT; + } + + ret = SEC_OMX_BaseComponent_Constructor(pOMXComponent); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); + goto EXIT; + } + + ret = SEC_OMX_Port_Constructor(pOMXComponent); + if (ret != OMX_ErrorNone) { + SEC_OMX_BaseComponent_Destructor(pOMXComponent); + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + + /* Input port */ + pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + pSECPort->portDefinition.nBufferCountActual = MAX_VIDEO_INPUTBUFFER_NUM; + pSECPort->portDefinition.nBufferCountMin = MAX_VIDEO_INPUTBUFFER_NUM; + pSECPort->portDefinition.nBufferSize = 0; + pSECPort->portDefinition.eDomain = OMX_PortDomainVideo; + + pSECPort->portDefinition.format.video.cMIMEType = SEC_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); + pSECPort->portDefinition.format.video.pNativeRender = 0; + pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; + + pSECPort->portDefinition.format.video.nFrameWidth = 0; + pSECPort->portDefinition.format.video.nFrameHeight= 0; + pSECPort->portDefinition.format.video.nStride = 0; + pSECPort->portDefinition.format.video.nSliceHeight = 0; + pSECPort->portDefinition.format.video.nBitrate = 64000; + pSECPort->portDefinition.format.video.xFramerate = (15 << 16); + pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; + pSECPort->portDefinition.format.video.pNativeWindow = NULL; + + /* Output port */ + pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + pSECPort->portDefinition.nBufferCountActual = MAX_VIDEO_OUTPUTBUFFER_NUM; + pSECPort->portDefinition.nBufferCountMin = MAX_VIDEO_OUTPUTBUFFER_NUM; + pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; + pSECPort->portDefinition.eDomain = OMX_PortDomainVideo; + + pSECPort->portDefinition.format.video.cMIMEType = SEC_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); + pSECPort->portDefinition.format.video.pNativeRender = 0; + pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; + + pSECPort->portDefinition.format.video.nFrameWidth = 0; + pSECPort->portDefinition.format.video.nFrameHeight= 0; + pSECPort->portDefinition.format.video.nStride = 0; + pSECPort->portDefinition.format.video.nSliceHeight = 0; + pSECPort->portDefinition.format.video.nBitrate = 64000; + pSECPort->portDefinition.format.video.xFramerate = (15 << 16); + pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; + pSECPort->portDefinition.format.video.pNativeWindow = NULL; + + pOMXComponent->UseBuffer = &SEC_OMX_UseBuffer; + pOMXComponent->AllocateBuffer = &SEC_OMX_AllocateBuffer; + pOMXComponent->FreeBuffer = &SEC_OMX_FreeBuffer; + pOMXComponent->ComponentTunnelRequest = &SEC_OMX_ComponentTunnelRequest; + + pSECComponent->sec_AllocateTunnelBuffer = &SEC_OMX_AllocateTunnelBuffer; + pSECComponent->sec_FreeTunnelBuffer = &SEC_OMX_FreeTunnelBuffer; + pSECComponent->sec_BufferProcess = &SEC_OMX_BufferProcess; + pSECComponent->sec_BufferReset = &SEC_BufferReset; + pSECComponent->sec_InputBufferReturn = &SEC_InputBufferReturn; + pSECComponent->sec_OutputBufferReturn = &SEC_OutputBufferReturn; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_VideoDecodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + int i = 0; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + for(i = 0; i < ALL_PORT_NUM; i++) { + pSECPort = &pSECComponent->pSECPort[i]; + SEC_OSAL_Free(pSECPort->portDefinition.format.video.cMIMEType); + pSECPort->portDefinition.format.video.cMIMEType = NULL; + } + + ret = SEC_OMX_Port_Destructor(pOMXComponent); + + ret = SEC_OMX_BaseComponent_Destructor(hComponent); + +EXIT: + FunctionOut(); + + return ret; +} diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h b/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h new file mode 100644 index 0000000..b7f71da --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h @@ -0,0 +1,107 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Vdec.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * HyeYeon Chung (hyeon.chung@samsung.com) + * Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_VIDEO_DECODE +#define SEC_OMX_VIDEO_DECODE + +#include "OMX_Component.h" +#include "SEC_OMX_Def.h" +#include "SEC_OSAL_Queue.h" +#include "SEC_OMX_Baseport.h" + +#define MAX_VIDEO_INPUTBUFFER_NUM 5 +#define MAX_VIDEO_OUTPUTBUFFER_NUM 2 + +#define DEFAULT_FRAME_WIDTH 176 +#define DEFAULT_FRAME_HEIGHT 144 + +#define DEFAULT_VIDEO_INPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT) * 2 +#define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2 + +#define DEFAULT_MFC_INPUT_BUFFER_SIZE 1024 * 1024 /*DEFAULT_VIDEO_INPUT_BUFFER_SIZE*/ + +#define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 1 +#define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX 3 + + +typedef struct +{ + void *pAddrY; + void *pAddrC; +} MFC_DEC_ADDR_INFO; + + +#ifdef __cplusplus +extern "C" { +#endif + +OMX_ERRORTYPE SEC_OMX_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 SEC_OMX_AllocateBuffer( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer, + OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_PTR pAppPrivate, + OMX_IN OMX_U32 nSizeBytes); +OMX_ERRORTYPE SEC_OMX_FreeBuffer( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr); +OMX_ERRORTYPE SEC_OMX_AllocateTunnelBuffer( + SEC_OMX_BASEPORT *pOMXBasePort, + OMX_U32 nPortIndex); +OMX_ERRORTYPE SEC_OMX_FreeTunnelBuffer( + SEC_OMX_BASEPORT *pOMXBasePort, + OMX_U32 nPortIndex); +OMX_ERRORTYPE SEC_OMX_ComponentTunnelRequest( + OMX_IN OMX_HANDLETYPE hComp, + OMX_IN OMX_U32 nPort, + OMX_IN OMX_HANDLETYPE hTunneledComp, + OMX_IN OMX_U32 nTunneledPort, + OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup); +OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent); +OMX_ERRORTYPE SEC_OMX_VideoDecodeGetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nParamIndex, + OMX_INOUT OMX_PTR ComponentParameterStructure); +OMX_ERRORTYPE SEC_OMX_VideoDecodeSetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR ComponentParameterStructure); +OMX_ERRORTYPE SEC_OMX_VideoDecodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk new file mode 100644 index 0000000..2dadf50 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk @@ -0,0 +1,29 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := \ + SEC_OMX_H264dec.c \ + library_register.c + +LOCAL_PRELINK_MODULE := false +LOCAL_MODULE := libOMX.SEC.AVC.Decoder.aries + +LOCAL_CFLAGS := + +LOCAL_ARM_MODE := arm + +LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec.aries libsecosal.aries libsecbasecomponent.aries libsecmfcdecapi.aries +LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils + +LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ + $(SEC_OMX_INC)/sec \ + $(SEC_OMX_TOP)/sec_osal \ + $(SEC_OMX_TOP)/sec_omx_core \ + $(SEC_OMX_COMPONENT)/common \ + $(SEC_OMX_COMPONENT)/video/dec \ + +LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include + +include $(BUILD_SHARED_LIBRARY) diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c new file mode 100644 index 0000000..5e73b7f --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c @@ -0,0 +1,1191 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_H264dec.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include + +#include "SEC_OMX_Macros.h" +#include "SEC_OMX_Basecomponent.h" +#include "SEC_OMX_Baseport.h" +#include "SEC_OMX_Vdec.h" +#include "library_register.h" +#include "SEC_OMX_H264dec.h" +#include "SsbSipMfcApi.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_H264_DEC" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + +//#define ADD_SPS_PPS_I_FRAME +//#define FULL_FRAME_SEARCH + +/* H.264 Decoder Supported Levels & profiles */ +SEC_OMX_VIDEO_PROFILELEVEL supportedAVCProfileLevels[] ={ + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1b}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel11}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel12}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel2}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel21}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel22}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel3}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel31}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel32}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4}, + + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1b}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel11}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel12}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel13}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel2}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel21}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel22}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel3}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel31}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel32}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel4}, + + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1b}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel11}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel12}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel13}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel2}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel21}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel22}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel3}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel31}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel32}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4}}; + + +static int Check_H264_Frame(OMX_U8 *pInputStream, int buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame) +{ + OMX_U32 preFourByte = (OMX_U32)-1; + int accessUnitSize = 0; + int frameTypeBoundary = 0; + int nextNaluSize = 0; + int naluStart = 0; + + if (bPreviousFrameEOF == OMX_TRUE) + naluStart = 0; + else + naluStart = 1; + + while (1) { + int inputOneByte = 0; + + if (accessUnitSize == buffSize) + goto EXIT; + + inputOneByte = *(pInputStream++); + accessUnitSize += 1; + + if (preFourByte == 0x00000001 || (preFourByte << 8) == 0x00000100) { + int naluType = inputOneByte & 0x1F; + + SEC_OSAL_Log(SEC_LOG_TRACE, "NaluType : %d", naluType); + if (naluStart == 0) { +#ifdef ADD_SPS_PPS_I_FRAME + if (naluType == 1 || naluType == 5) +#else + if (naluType == 1 || naluType == 5 || naluType == 7 || naluType == 8) +#endif + naluStart = 1; + } else { +#ifdef OLD_DETECT + frameTypeBoundary = (8 - naluType) & (naluType - 10); //AUD(9) +#else + if (naluType == 9) + frameTypeBoundary = -2; +#endif + if (naluType == 1 || naluType == 5) { + if (accessUnitSize == buffSize) { + accessUnitSize--; + goto EXIT; + } + inputOneByte = *pInputStream++; + accessUnitSize += 1; + + if (inputOneByte >= 0x80) + frameTypeBoundary = -1; + } + if (frameTypeBoundary < 0) { + break; + } + } + + } + preFourByte = (preFourByte << 8) + inputOneByte; + } + + *pbEndOfFrame = OMX_TRUE; + nextNaluSize = -5; + if (frameTypeBoundary == -1) + nextNaluSize = -6; + if (preFourByte != 0x00000001) + nextNaluSize++; + return (accessUnitSize + nextNaluSize); + +EXIT: + *pbEndOfFrame = OMX_FALSE; + + return accessUnitSize; +} + +OMX_BOOL Check_H264_StartCode(OMX_U8 *pInputStream, OMX_U32 streamSize) +{ + if (streamSize < 4) { + return OMX_FALSE; + } else if ((pInputStream[0] == 0x00) && + (pInputStream[1] == 0x00) && + (pInputStream[2] == 0x00) && + (pInputStream[3] != 0x00) && + ((pInputStream[3] >> 3) == 0x00)) { + return OMX_TRUE; + } else if ((pInputStream[0] == 0x00) && + (pInputStream[1] == 0x00) && + (pInputStream[2] != 0x00) && + ((pInputStream[2] >> 3) == 0x00)) { + return OMX_TRUE; + } else { + return OMX_FALSE; + } +} + +OMX_ERRORTYPE SEC_MFC_H264Dec_GetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nParamIndex, + OMX_INOUT OMX_PTR pComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL || pComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + switch (nParamIndex) { + case OMX_IndexParamVideoAvc: + { + OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL; + SEC_H264DEC_HANDLE *pH264Dec = NULL; + + ret = SEC_OMX_Check_SizeVersion(pDstAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstAVCComponent->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + pSrcAVCComponent = &pH264Dec->AVCComponent[pDstAVCComponent->nPortIndex]; + + SEC_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); + } + break; + case OMX_IndexParamStandardComponentRole: + { + OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure; + ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_H264_DEC_ROLE); + } + break; + case OMX_IndexParamVideoProfileLevelQuerySupported: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure; + SEC_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL; + OMX_U32 maxProfileLevelNum = 0; + + ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pProfileLevel = supportedAVCProfileLevels; + maxProfileLevelNum = sizeof(supportedAVCProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL); + + if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) { + ret = OMX_ErrorNoMore; + goto EXIT; + } + + pProfileLevel += pDstProfileLevel->nProfileIndex; + pDstProfileLevel->eProfile = pProfileLevel->profile; + pDstProfileLevel->eLevel = pProfileLevel->level; + } + break; + case OMX_IndexParamVideoProfileLevelCurrent: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure; + OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL; + SEC_H264DEC_HANDLE *pH264Dec = NULL; + + ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + pSrcAVCComponent = &pH264Dec->AVCComponent[pDstProfileLevel->nPortIndex]; + + pDstProfileLevel->eProfile = pSrcAVCComponent->eProfile; + pDstProfileLevel->eLevel = pSrcAVCComponent->eLevel; + } + break; + case OMX_IndexParamVideoErrorCorrection: + { + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; + SEC_H264DEC_HANDLE *pH264Dec = NULL; + + ret = SEC_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + pSrcErrorCorrectionType = &pH264Dec->errorCorrectionType[INPUT_PORT_INDEX]; + + pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; + pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; + pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; + pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; + pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; + } + break; + default: + ret = SEC_OMX_VideoDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); + break; + } +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_H264Dec_SetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR pComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL || pComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + switch (nIndex) { + case OMX_IndexParamVideoAvc: + { + OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL; + OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure; + SEC_H264DEC_HANDLE *pH264Dec = NULL; + + ret = SEC_OMX_Check_SizeVersion(pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcAVCComponent->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + pDstAVCComponent = &pH264Dec->AVCComponent[pSrcAVCComponent->nPortIndex]; + + SEC_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); + } + break; + case OMX_IndexParamStandardComponentRole: + { + OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; + + ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + + if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_H264_DEC_ROLE)) { + pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; + } else { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + } + break; + case OMX_IndexParamPortDefinition: + { + OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)pComponentParameterStructure; + OMX_U32 portIndex = pPortDefinition->nPortIndex; + SEC_OMX_BASEPORT *pSECPort; + OMX_U32 width, height, size; + + if (portIndex >= pSECComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + ret = SEC_OMX_Check_SizeVersion(pPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[portIndex]; + + if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { + if (pSECPort->portDefinition.bEnabled == OMX_TRUE) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + } + if(pPortDefinition->nBufferCountActual < pSECPort->portDefinition.nBufferCountMin) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + SEC_OSAL_Memcpy(&pSECPort->portDefinition, pPortDefinition, pPortDefinition->nSize); + + width = ((pSECPort->portDefinition.format.video.nFrameWidth + 15) & (~15)); + height = ((pSECPort->portDefinition.format.video.nFrameHeight + 15) & (~15)); + size = (width * height * 3) / 2; + pSECPort->portDefinition.format.video.nStride = width; + pSECPort->portDefinition.format.video.nSliceHeight = height; + pSECPort->portDefinition.nBufferSize = (size > pSECPort->portDefinition.nBufferSize) ? size : pSECPort->portDefinition.nBufferSize; + + if (portIndex == INPUT_PORT_INDEX) { + SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + pSECOutputPort->portDefinition.format.video.nFrameWidth = pSECPort->portDefinition.format.video.nFrameWidth; + pSECOutputPort->portDefinition.format.video.nFrameHeight = pSECPort->portDefinition.format.video.nFrameHeight; + pSECOutputPort->portDefinition.format.video.nStride = width; + pSECOutputPort->portDefinition.format.video.nSliceHeight = height; + if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) { + pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2; + } else if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV422Planar) { + pSECOutputPort->portDefinition.nBufferSize = width * height * 2; + } + } + } + break; + case OMX_IndexParamVideoProfileLevelCurrent: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL; + SEC_H264DEC_HANDLE *pH264Dec = NULL; + + ret = SEC_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); + if (ret != OMX_ErrorNone) + goto EXIT; + + if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + + pDstAVCComponent = &pH264Dec->AVCComponent[pSrcProfileLevel->nPortIndex]; + pDstAVCComponent->eProfile = pSrcProfileLevel->eProfile; + pDstAVCComponent->eLevel = pSrcProfileLevel->eLevel; + } + break; + case OMX_IndexParamVideoErrorCorrection: + { + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; + SEC_H264DEC_HANDLE *pH264Dec = NULL; + + ret = SEC_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + pDstErrorCorrectionType = &pH264Dec->errorCorrectionType[INPUT_PORT_INDEX]; + + pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; + pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; + pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; + pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; + pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; + } + break; + default: + ret = SEC_OMX_VideoDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure); + break; + } +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_H264Dec_SetConfig( + OMX_HANDLETYPE hComponent, + OMX_INDEXTYPE nIndex, + OMX_PTR pComponentConfigStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pComponentConfigStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + switch (nIndex) { + case OMX_IndexVendorThumbnailMode: + { + SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + + pH264Dec->hMFCH264Handle.bThumbnailMode = *((OMX_BOOL *)pComponentConfigStructure); + + ret = OMX_ErrorNone; + } + break; + default: + ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure); + break; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_H264Dec_GetExtensionIndex( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_STRING cParameterName, + OMX_OUT OMX_INDEXTYPE *pIndexType) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if ((cParameterName == NULL) || (pIndexType == NULL)) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + if (SEC_OSAL_Strcmp(cParameterName, "OMX.SEC.index.ThumbnailMode") == 0) { + SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + + *pIndexType = OMX_IndexVendorThumbnailMode; + + ret = OMX_ErrorNone; + } else { + ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType); + } + +EXIT: + FunctionOut(); + + return ret; +} + + +OMX_ERRORTYPE SEC_MFC_H264Dec_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if ((hComponent == NULL) || (cRole == NULL)) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (nIndex == (MAX_COMPONENT_ROLE_NUM-1)) { + SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_H264_DEC_ROLE); + ret = OMX_ErrorNone; + } else { + ret = OMX_ErrorNoMore; + } + +EXIT: + FunctionOut(); + + return ret; +} + +/* MFC Init */ +OMX_ERRORTYPE SEC_MFC_H264Dec_Init(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_H264DEC_HANDLE *pH264Dec = NULL; + + OMX_PTR hMFCHandle = NULL; + OMX_PTR pStreamBuffer = NULL; + OMX_PTR pStreamPhyBuffer = NULL; + + pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + pH264Dec->hMFCH264Handle.bConfiguredMFC = OMX_FALSE; + pSECComponent->bUseFlagEOF = OMX_FALSE; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + + /* MFC(Multi Function Codec) decoder and CMM(Codec Memory Management) driver open */ + hMFCHandle = (OMX_PTR)SsbSipMfcDecOpen(); + if (hMFCHandle == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + pH264Dec->hMFCH264Handle.hMFCHandle = hMFCHandle; + + /* Allocate decoder's input buffer */ + pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE); + if (pStreamBuffer == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + pH264Dec->hMFCH264Handle.pMFCStreamBuffer = pStreamBuffer; + pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = pStreamPhyBuffer; + pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pStreamBuffer; + pSECComponent->processData[INPUT_PORT_INDEX].allocSize = DEFAULT_MFC_INPUT_BUFFER_SIZE; + + SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); + SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); + pH264Dec->hMFCH264Handle.indexTimestamp = 0; + pSECComponent->getAllDelayBuffer = OMX_FALSE; + +EXIT: + return ret; +} + +/* MFC Terminate */ +OMX_ERRORTYPE SEC_MFC_H264Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_H264DEC_HANDLE *pH264Dec = NULL; + OMX_PTR hMFCHandle = NULL; + + FunctionIn(); + + pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; + + pH264Dec->hMFCH264Handle.pMFCStreamBuffer = NULL; + pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = NULL; + pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = NULL; + pSECComponent->processData[INPUT_PORT_INDEX].allocSize = 0; + + if (hMFCHandle != NULL) { + SsbSipMfcDecClose(hMFCHandle); + hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle = NULL; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + OMX_U32 oneFrameSize = pInputData->dataLen; + SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo; + OMX_S32 setConfVal = 0; + OMX_S32 returnCodec = 0; + int bufWidth; + int bufHeight; + + FunctionIn(); + + if (pH264Dec->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) { + SSBSIP_MFC_CODEC_TYPE eCodecType = H264_DEC; + + if ((oneFrameSize <= 0) && (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) { + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + ret = OMX_ErrorNone; + goto EXIT; + } + + setConfVal = 5; + SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &setConfVal); + + /* Default number in the driver is optimized */ + if (pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_TRUE) { + setConfVal = 0; + SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal); + } else { + setConfVal = 8; + SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal); + } + + returnCodec = SsbSipMfcDecInit(pH264Dec->hMFCH264Handle.hMFCHandle, eCodecType, oneFrameSize); + if (returnCodec == MFC_RET_OK) { + SSBSIP_MFC_IMG_RESOLUTION imgResol; + SSBSIP_MFC_CROP_INFORMATION cropInfo; + SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + + SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol); + SEC_OSAL_Log(SEC_LOG_TRACE, "set width height information : %d, %d", + secInputPort->portDefinition.format.video.nFrameWidth, + secInputPort->portDefinition.format.video.nFrameHeight); + SEC_OSAL_Log(SEC_LOG_TRACE, "mfc width height information : %d, %d", + imgResol.width, imgResol.height); + + SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_CROP_INFO, &cropInfo); + SEC_OSAL_Log(SEC_LOG_TRACE, "mfc crop_top crop_bottom crop_left crop_right : %d, %d, %d, %d", + cropInfo.crop_top_offset , cropInfo.crop_bottom_offset , + cropInfo.crop_left_offset , cropInfo.crop_right_offset); + + int actualWidth = imgResol.width - cropInfo.crop_left_offset - cropInfo.crop_right_offset; + int actualHeight = imgResol.height - cropInfo.crop_top_offset - cropInfo.crop_bottom_offset; + + /** Update Frame Size **/ + if((secInputPort->portDefinition.format.video.nFrameWidth != actualWidth) || + (secInputPort->portDefinition.format.video.nFrameHeight != actualHeight)) { + SEC_OSAL_Log(SEC_LOG_TRACE, "change width height information : OMX_EventPortSettingsChanged"); + /* change width and height information */ + secInputPort->portDefinition.format.video.nFrameWidth = actualWidth; + secInputPort->portDefinition.format.video.nFrameHeight = actualHeight; + secInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15)); + secInputPort->portDefinition.format.video.nSliceHeight = ((imgResol.height + 15) & (~15)); + + SEC_UpdateFrameSize(pOMXComponent); + + /** Send Port Settings changed call back */ + (*(pSECComponent->pCallbacks->EventHandler)) + (pOMXComponent, + pSECComponent->callbackData, + OMX_EventPortSettingsChanged, /* The command was completed */ + OMX_DirOutput, /* This is the port index */ + 0, + NULL); + } + + pH264Dec->hMFCH264Handle.bConfiguredMFC = OMX_TRUE; +#ifdef ADD_SPS_PPS_I_FRAME + ret = OMX_ErrorInputDataDecodeYet; +#else + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + + ret = OMX_ErrorNone; +#endif + goto EXIT; + } else { + ret = OMX_ErrorMFCInit; + goto EXIT; + } + } + +#ifndef FULL_FRAME_SEARCH + if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) && + (pSECComponent->bUseFlagEOF == OMX_FALSE)) { + pSECComponent->bUseFlagEOF = OMX_TRUE; + } +#endif + + pSECComponent->timeStamp[pH264Dec->hMFCH264Handle.indexTimestamp] = pInputData->timeStamp; + pSECComponent->nFlags[pH264Dec->hMFCH264Handle.indexTimestamp] = pInputData->nFlags; + SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pH264Dec->hMFCH264Handle.indexTimestamp)); + pH264Dec->hMFCH264Handle.indexTimestamp++; + if (pH264Dec->hMFCH264Handle.indexTimestamp >= MAX_TIMESTAMP) + pH264Dec->hMFCH264Handle.indexTimestamp = 0; + + if (Check_H264_StartCode(pInputData->dataBuffer, pInputData->dataLen) == OMX_TRUE) { + returnCodec = SsbSipMfcDecExe(pH264Dec->hMFCH264Handle.hMFCHandle, oneFrameSize); + } else { + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + returnCodec = MFC_RET_OK; + goto EXIT; + } + + if (returnCodec == MFC_RET_OK) { + SSBSIP_MFC_DEC_OUTBUF_STATUS status; + OMX_S32 indexTimestamp = 0; + + status = SsbSipMfcDecGetOutBuf(pH264Dec->hMFCH264Handle.hMFCHandle, &outputInfo); + bufWidth = (outputInfo.img_width + 15) & (~15); + bufHeight = (outputInfo.img_height + 15) & (~15); + + if ((SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) || + (((indexTimestamp < 0) || (indexTimestamp > MAX_TIMESTAMP)))) { + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + } else { + pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp]; + pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp]; + } + + if ((status == MFC_GETOUTBUF_DISPLAY_DECODING) || + (status == MFC_GETOUTBUF_DISPLAY_ONLY)) { + switch(pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) { + case OMX_COLOR_FormatYUV420Planar: + case OMX_COLOR_FormatYUV420SemiPlanar: + pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2; + break; + default: + pOutputData->dataLen = bufWidth * bufHeight * 2; + break; + } + } + if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS) + pOutputData->dataLen = 0; + + if ((status == MFC_GETOUTBUF_DISPLAY_ONLY) || + (pSECComponent->getAllDelayBuffer == OMX_TRUE)) { + ret = OMX_ErrorInputDataDecodeYet; + } + + if(status == MFC_GETOUTBUF_DECODING_ONLY) { + /* ret = OMX_ErrorInputDataDecodeYet; */ + ret = OMX_ErrorNone; + goto EXIT; + } + +#ifdef FULL_FRAME_SEARCH + if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS) && + (pSECComponent->bSaveFlagEOS == OMX_TRUE)) { + pInputData->nFlags |= OMX_BUFFERFLAG_EOS; + pSECComponent->getAllDelayBuffer = OMX_TRUE; + ret = OMX_ErrorInputDataDecodeYet; + } else +#endif + + if ((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { + pInputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS)); + pSECComponent->getAllDelayBuffer = OMX_TRUE; + ret = OMX_ErrorInputDataDecodeYet; + } else if ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { + pSECComponent->getAllDelayBuffer = OMX_FALSE; + ret = OMX_ErrorNone; + } + } else { + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + switch(pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) { + case OMX_COLOR_FormatYUV420Planar: + case OMX_COLOR_FormatYUV420SemiPlanar: + pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2; + break; + default: + pOutputData->dataLen = bufWidth * bufHeight * 2; + break; + } + + if ((pSECComponent->bSaveFlagEOS == OMX_TRUE) || + (pSECComponent->getAllDelayBuffer == OMX_TRUE) || + (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) { + pOutputData->nFlags |= OMX_BUFFERFLAG_EOS; + pSECComponent->getAllDelayBuffer = OMX_FALSE; + pOutputData->dataLen = 0; + } + + /* ret = OMX_ErrorUndefined; */ /* ????? */ + ret = OMX_ErrorNone; + goto EXIT; + } + + /** Fill Output Buffer **/ + if (pOutputData->dataLen > 0) + { + int frameSize = bufWidth * bufHeight; + void *pOutBuf = (void *)pOutputData->dataBuffer; + +#ifdef USE_SAMSUNG_COLORFORMAT + SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + + if ((pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_FALSE) && + (pSECOutputPort->portDefinition.format.video.eColorFormat == SEC_OMX_COLOR_FormatNV12PhysicalAddress)) + +#else + if (pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_FALSE) +#endif + { + /* if use Post copy address structure */ + SEC_OSAL_Memcpy(pOutBuf, &frameSize, sizeof(frameSize)); + SEC_OSAL_Memcpy(pOutBuf + sizeof(frameSize), &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr)); + SEC_OSAL_Memcpy(pOutBuf + sizeof(frameSize) + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr)); + SEC_OSAL_Memcpy(pOutBuf + sizeof(frameSize) + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr)); + SEC_OSAL_Memcpy(pOutBuf + sizeof(frameSize) + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr)); + } else { + SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420 out for ThumbnailMode"); + Y_tile_to_linear_4x2( + (unsigned char *)pOutBuf, + (unsigned char *)outputInfo.YVirAddr, + bufWidth, bufHeight); + CbCr_tile_to_linear_4x2( + ((unsigned char *)pOutBuf) + frameSize, + (unsigned char *)outputInfo.CVirAddr, + bufWidth, bufHeight); + } + } + +EXIT: + FunctionOut(); + + return ret; +} + +/* MFC Decode */ +OMX_ERRORTYPE SEC_MFC_H264Dec_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + OMX_BOOL endOfFrame = OMX_FALSE; + + FunctionIn(); + + if ((!CHECK_PORT_ENABLED(pSECInputPort)) || (!CHECK_PORT_ENABLED(pSECOutputPort)) || + (!CHECK_PORT_POPULATED(pSECInputPort)) || (!CHECK_PORT_POPULATED(pSECOutputPort))) { + ret = OMX_ErrorNone; + goto EXIT; + } + if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) { + ret = OMX_ErrorNone; + goto EXIT; + } + + ret = SEC_MFC_H264_Decode(pOMXComponent, pInputData, pOutputData); + if (ret != OMX_ErrorNone) { + if (ret == OMX_ErrorInputDataDecodeYet) { + pOutputData->usedDataLen = 0; + pOutputData->remainDataLen = pOutputData->dataLen; + } else { + pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, + pSECComponent->callbackData, + OMX_EventError, ret, 0, NULL); + } + } else { + pInputData->previousDataLen = pInputData->dataLen; + pInputData->usedDataLen += pInputData->dataLen; + pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen; + pInputData->dataLen -= pInputData->usedDataLen; + pInputData->usedDataLen = 0; + + pOutputData->usedDataLen = 0; + pOutputData->remainDataLen = pOutputData->dataLen; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + SEC_H264DEC_HANDLE *pH264Dec = NULL; + int i = 0; + + FunctionIn(); + + if ((hComponent == NULL) || (componentName == NULL)) { + ret = OMX_ErrorBadParameter; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); + goto EXIT; + } + if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_H264_DEC, componentName) != 0) { + ret = OMX_ErrorBadParameter; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__); + goto EXIT; + } + + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_VideoDecodeComponentInit(pOMXComponent); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pSECComponent->codecType = HW_VIDEO_CODEC; + + pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); + if (pSECComponent->componentName == NULL) { + SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent); + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); + goto EXIT; + } + SEC_OSAL_Memset(pSECComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); + + pH264Dec = SEC_OSAL_Malloc(sizeof(SEC_H264DEC_HANDLE)); + if (pH264Dec == NULL) { + SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent); + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); + goto EXIT; + } + SEC_OSAL_Memset(pH264Dec, 0, sizeof(SEC_H264DEC_HANDLE)); + pSECComponent->hCodecHandle = (OMX_HANDLETYPE)pH264Dec; + + SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_H264_DEC); + /* Set componentVersion */ + pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; + pSECComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; + pSECComponent->componentVersion.s.nRevision = REVISION_NUMBER; + pSECComponent->componentVersion.s.nStep = STEP_NUMBER; + /* Set specVersion */ + pSECComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; + pSECComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; + pSECComponent->specVersion.s.nRevision = REVISION_NUMBER; + pSECComponent->specVersion.s.nStep = STEP_NUMBER; + + /* Android CapabilityFlags */ + pSECComponent->capabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_FALSE; + pSECComponent->capabilityFlags.iOMXComponentSupportsPartialFrames = OMX_FALSE; + pSECComponent->capabilityFlags.iOMXComponentUsesNALStartCodes = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentUsesFullAVCFrames = OMX_TRUE; + + /* Input port */ + pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; + pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; + pSECPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ + pSECPort->portDefinition.format.video.nSliceHeight = 0; + pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; + SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/avc"); + pSECPort->portDefinition.format.video.pNativeRender = 0; + pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; + pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; + pSECPort->portDefinition.bEnabled = OMX_TRUE; + + /* Output port */ + pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; + pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; + pSECPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ + pSECPort->portDefinition.format.video.nSliceHeight = 0; + pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; + SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); + pSECPort->portDefinition.format.video.pNativeRender = 0; + pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; + pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar; + pSECPort->portDefinition.bEnabled = OMX_TRUE; + + for(i = 0; i < ALL_PORT_NUM; i++) { + INIT_SET_SIZE_VERSION(&pH264Dec->AVCComponent[i], OMX_VIDEO_PARAM_AVCTYPE); + pH264Dec->AVCComponent[i].nPortIndex = i; + pH264Dec->AVCComponent[i].eProfile = OMX_VIDEO_AVCProfileBaseline; + pH264Dec->AVCComponent[i].eLevel = OMX_VIDEO_AVCLevel4; + } + + pOMXComponent->GetParameter = &SEC_MFC_H264Dec_GetParameter; + pOMXComponent->SetParameter = &SEC_MFC_H264Dec_SetParameter; + pOMXComponent->SetConfig = &SEC_MFC_H264Dec_SetConfig; + pOMXComponent->GetExtensionIndex = &SEC_MFC_H264Dec_GetExtensionIndex; + pOMXComponent->ComponentRoleEnum = &SEC_MFC_H264Dec_ComponentRoleEnum; + pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit; + + pSECComponent->sec_mfc_componentInit = &SEC_MFC_H264Dec_Init; + pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_H264Dec_Terminate; + pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_H264Dec_bufferProcess; + pSECComponent->sec_checkInputFrame = &Check_H264_Frame; + + pSECComponent->currentState = OMX_StateLoaded; + + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_H264DEC_HANDLE *pH264Dec = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + SEC_OSAL_Free(pSECComponent->componentName); + pSECComponent->componentName = NULL; + + pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle; + if (pH264Dec != NULL) { + SEC_OSAL_Free(pH264Dec); + pH264Dec = pSECComponent->hCodecHandle = NULL; + } + + ret = SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent); + if(ret != OMX_ErrorNone) { + goto EXIT; + } + + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.h b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.h new file mode 100644 index 0000000..b1374fb --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.h @@ -0,0 +1,66 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_H264dec.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_H264_DEC_COMPONENT +#define SEC_OMX_H264_DEC_COMPONENT + +#include "SEC_OMX_Def.h" +#include "OMX_Component.h" +#include "OMX_Video.h" + + +typedef struct _SEC_MFC_H264DEC_HANDLE +{ + OMX_HANDLETYPE hMFCHandle; + OMX_PTR pMFCStreamBuffer; + OMX_PTR pMFCStreamPhyBuffer; + OMX_U32 indexTimestamp; + OMX_BOOL bConfiguredMFC; + OMX_BOOL bThumbnailMode; +} SEC_MFC_H264DEC_HANDLE; + +typedef struct _SEC_H264DEC_HANDLE +{ + /* OMX Codec specific */ + OMX_VIDEO_PARAM_AVCTYPE AVCComponent[ALL_PORT_NUM]; + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE errorCorrectionType[ALL_PORT_NUM]; + + /* SEC MFC Codec specific */ + SEC_MFC_H264DEC_HANDLE hMFCH264Handle; +} SEC_H264DEC_HANDLE; + +#ifdef __cplusplus +extern "C" { +#endif + +OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName); +OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent); + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c new file mode 100644 index 0000000..f7bcf25 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c @@ -0,0 +1,55 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 library_register.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include +#include + +#include "SEC_OSAL_Memory.h" +#include "SEC_OSAL_ETC.h" +#include "library_register.h" +#include "SEC_OSAL_Log.h" + + +OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents) +{ + FunctionIn(); + + if (secComponents == NULL) + goto EXIT; + + /* component 1 - video decoder H.264 */ + SEC_OSAL_Strcpy(secComponents[0]->componentName, SEC_OMX_COMPOMENT_H264_DEC); + SEC_OSAL_Strcpy(secComponents[0]->roles[0], SEC_OMX_COMPOMENT_H264_DEC_ROLE); + secComponents[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM; + +EXIT: + FunctionOut(); + + return MAX_COMPONENT_NUM; +} + diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h new file mode 100644 index 0000000..cdbfaa4 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h @@ -0,0 +1,55 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 library_register.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_H264_REG +#define SEC_OMX_H264_REG + +#include "SEC_OMX_Def.h" +#include "OMX_Component.h" +#include "SEC_OMX_Component_Register.h" + + +#define OSCL_EXPORT_REF __attribute__((visibility("default"))) +#define MAX_COMPONENT_NUM 1 +#define MAX_COMPONENT_ROLE_NUM 1 + +/* H.264 */ +#define SEC_OMX_COMPOMENT_H264_DEC "OMX.SEC.AVC.Decoder" +#define SEC_OMX_COMPOMENT_H264_DEC_ROLE "video_decoder.avc" + + +#ifdef __cplusplus +extern "C" { +#endif + +OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents); + +#ifdef __cplusplus +}; +#endif + +#endif + diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk new file mode 100644 index 0000000..a3a3c0c --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk @@ -0,0 +1,29 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := \ + SEC_OMX_Mpeg4dec.c \ + library_register.c + +LOCAL_PRELINK_MODULE := false +LOCAL_MODULE := libOMX.SEC.M4V.Decoder.aries + +LOCAL_CFLAGS := + +LOCAL_ARM_MODE := arm + +LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec.aries libsecosal.aries libsecbasecomponent.aries libsecmfcdecapi.aries +LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils + +LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ + $(SEC_OMX_INC)/sec \ + $(SEC_OMX_TOP)/sec_osal \ + $(SEC_OMX_TOP)/sec_omx_core \ + $(SEC_OMX_COMPONENT)/common \ + $(SEC_OMX_COMPONENT)/video/dec + +LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include + +include $(BUILD_SHARED_LIBRARY) diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c new file mode 100644 index 0000000..5074214 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c @@ -0,0 +1,1399 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Mpeg4dec.c + * @brief + * @author Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include + +#include "SEC_OMX_Macros.h" +#include "SEC_OMX_Basecomponent.h" +#include "SEC_OMX_Baseport.h" +#include "SEC_OMX_Vdec.h" +#include "library_register.h" +#include "SEC_OMX_Mpeg4dec.h" +#include "SsbSipMfcApi.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_MPEG4_DEC" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + +//#define FULL_FRAME_SEARCH + +/* MPEG4 Decoder Supported Levels & profiles */ +SEC_OMX_VIDEO_PROFILELEVEL supportedMPEG4ProfileLevels[] ={ + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0b}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level2}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level3}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4a}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level5}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0b}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level1}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level2}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level3}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4a}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level5}}; + +/* H.263 Decoder Supported Levels & profiles */ +SEC_OMX_VIDEO_PROFILELEVEL supportedH263ProfileLevels[] = { + /* Baseline (Profile 0) */ + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level10}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level20}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level30}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level40}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level45}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level50}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level60}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level70}, + /* Profile 1 */ + {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level10}, + {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level20}, + {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level30}, + {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level40}, + {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level45}, + {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level50}, + {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level60}, + {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level70}, + /* Profile 2 */ + {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level10}, + {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level20}, + {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level30}, + {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level40}, + {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level45}, + {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level50}, + {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level60}, + {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level70}, + /* Profile 3, restricted up to SD resolution */ + {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level10}, + {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level20}, + {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level30}, + {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level40}, + {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level45}, + {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level50}, + {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level60}, + {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level70}}; + +static OMX_HANDLETYPE ghMFCHandle = NULL; +static OMX_BOOL gbFIMV1 = OMX_FALSE; + +static int Check_Mpeg4_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame) +{ + int len, readStream; + unsigned startCode; + OMX_BOOL bFrameStart; + + len = 0; + bFrameStart = OMX_FALSE; + + if (flag & OMX_BUFFERFLAG_CODECCONFIG) { + if (*pInputStream == 0x03) { /* FIMV1 */ + if (ghMFCHandle != NULL) { + BitmapInfoHhr *pInfoHeader; + SSBSIP_MFC_IMG_RESOLUTION imgResolution; + + pInfoHeader = (BitmapInfoHhr *)(pInputStream + 1); + imgResolution.width = pInfoHeader->BiWidth; + imgResolution.height = pInfoHeader->BiHeight; + SsbSipMfcDecSetConfig(ghMFCHandle, MFC_DEC_SETCONF_FIMV1_WIDTH_HEIGHT, &imgResolution); + + SEC_OSAL_Log(SEC_LOG_TRACE, "width(%d), height(%d)", imgResolution.width, imgResolution.height); + gbFIMV1 = OMX_TRUE; + *pbEndOfFrame = OMX_TRUE; + return buffSize; + } + } + } + + if (gbFIMV1) { + *pbEndOfFrame = OMX_TRUE; + return buffSize; + } + + if (bPreviousFrameEOF == OMX_FALSE) + bFrameStart = OMX_TRUE; + + startCode = 0xFFFFFFFF; + if (bFrameStart == OMX_FALSE) { + /* find VOP start code */ + while(startCode != 0x1B6) { + readStream = *(pInputStream + len); + startCode = (startCode << 8) | readStream; + len++; + if (len > buffSize) + goto EXIT; + } + } + + /* find next VOP start code */ + startCode = 0xFFFFFFFF; + while ((startCode != 0x1B6)) { + readStream = *(pInputStream + len); + startCode = (startCode << 8) | readStream; + len++; + if (len > buffSize) + goto EXIT; + } + + *pbEndOfFrame = OMX_TRUE; + + SEC_OSAL_Log(SEC_LOG_TRACE, "1. Check_Mpeg4_Frame returned EOF = %d, len = %d, buffSize = %d", *pbEndOfFrame, len - 4, buffSize); + + return len - 4; + +EXIT : + *pbEndOfFrame = OMX_FALSE; + + SEC_OSAL_Log(SEC_LOG_TRACE, "2. Check_Mpeg4_Frame returned EOF = %d, len = %d, buffSize = %d", *pbEndOfFrame, len - 1, buffSize); + + return --len; +} + +static int Check_H263_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame) +{ + int len, readStream; + unsigned startCode; + OMX_BOOL bFrameStart = 0; + + len = 0; + bFrameStart = OMX_FALSE; + + if (bPreviousFrameEOF == OMX_FALSE) + bFrameStart = OMX_TRUE; + + startCode = 0xFFFFFFFF; + if (bFrameStart == OMX_FALSE) { + /* find PSC(Picture Start Code) : 0000 0000 0000 0000 1000 00 */ + while (((startCode << 8 >> 10) != 0x20)) { + readStream = *(pInputStream + len); + startCode = (startCode << 8) | readStream; + len++; + if (len > buffSize) + goto EXIT; + } + } + + /* find next PSC */ + startCode = 0xFFFFFFFF; + while (((startCode << 8 >> 10) != 0x20)) { + readStream = *(pInputStream + len); + startCode = (startCode << 8) | readStream; + len++; + if (len > buffSize) + goto EXIT; + } + + *pbEndOfFrame = OMX_TRUE; + + SEC_OSAL_Log(SEC_LOG_TRACE, "1. Check_H263_Frame returned EOF = %d, len = %d, iBuffSize = %d", *pbEndOfFrame, len - 3, buffSize); + + return len - 3; + +EXIT : + + *pbEndOfFrame = OMX_FALSE; + + SEC_OSAL_Log(SEC_LOG_TRACE, "2. Check_H263_Frame returned EOF = %d, len = %d, iBuffSize = %d", *pbEndOfFrame, len - 1, buffSize); + + return --len; +} + +OMX_BOOL Check_Stream_PrefixCode(OMX_U8 *pInputStream, OMX_U32 streamSize, CODEC_TYPE codecType) +{ + switch (codecType) { + case CODEC_TYPE_MPEG4: + if (gbFIMV1) { + return OMX_TRUE; + } else { + if (streamSize < 3) { + return OMX_FALSE; + } else if ((pInputStream[0] == 0x00) && + (pInputStream[1] == 0x00) && + (pInputStream[2] == 0x01)) { + return OMX_TRUE; + } else { + return OMX_FALSE; + } + } + break; + case CODEC_TYPE_H263: + if (streamSize > 0) + return OMX_TRUE; + else + return OMX_FALSE; + default: + SEC_OSAL_Log(SEC_LOG_WARNING, "%s: undefined codec type (%d)", __FUNCTION__, codecType); + return OMX_FALSE; + } +} + +OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nParamIndex, + OMX_INOUT OMX_PTR pComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL || pComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + switch (nParamIndex) { + case OMX_IndexParamVideoMpeg4: + { + OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL; + SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; + ret = SEC_OMX_Check_SizeVersion(pDstMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstMpeg4Param->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + pSrcMpeg4Param = &pMpeg4Dec->mpeg4Component[pDstMpeg4Param->nPortIndex]; + + SEC_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); + } + break; + case OMX_IndexParamVideoH263: + { + OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL; + SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; + ret = SEC_OMX_Check_SizeVersion(pDstH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstH263Param->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + pSrcH263Param = &pMpeg4Dec->h263Component[pDstH263Param->nPortIndex]; + + SEC_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); + } + break; + case OMX_IndexParamStandardComponentRole: + { + OMX_S32 codecType; + OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure; + + ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + codecType = ((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType; + if (codecType == CODEC_TYPE_MPEG4) + SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_MPEG4_DEC_ROLE); + else + SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_H263_DEC_ROLE); + } + break; + case OMX_IndexParamVideoProfileLevelQuerySupported: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; + SEC_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL; + OMX_U32 maxProfileLevelNum = 0; + OMX_S32 codecType; + + ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + codecType = ((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType; + if (codecType == CODEC_TYPE_MPEG4) { + pProfileLevel = supportedMPEG4ProfileLevels; + maxProfileLevelNum = sizeof(supportedMPEG4ProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL); + } else { + pProfileLevel = supportedH263ProfileLevels; + maxProfileLevelNum = sizeof(supportedH263ProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL); + } + + if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) { + ret = OMX_ErrorNoMore; + goto EXIT; + } + + pProfileLevel += pDstProfileLevel->nProfileIndex; + pDstProfileLevel->eProfile = pProfileLevel->profile; + pDstProfileLevel->eLevel = pProfileLevel->level; + } + break; + case OMX_IndexParamVideoProfileLevelCurrent: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL; + OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL; + SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; + OMX_S32 codecType; + + ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + codecType = pMpeg4Dec->hMFCMpeg4Handle.codecType; + if (codecType == CODEC_TYPE_MPEG4) { + pSrcMpeg4Param = &pMpeg4Dec->mpeg4Component[pDstProfileLevel->nPortIndex]; + pDstProfileLevel->eProfile = pSrcMpeg4Param->eProfile; + pDstProfileLevel->eLevel = pSrcMpeg4Param->eLevel; + } else { + pSrcH263Param = &pMpeg4Dec->h263Component[pDstProfileLevel->nPortIndex]; + pDstProfileLevel->eProfile = pSrcH263Param->eProfile; + pDstProfileLevel->eLevel = pSrcH263Param->eLevel; + } + } + break; + case OMX_IndexParamVideoErrorCorrection: + { + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; + SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; + + ret = SEC_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + pSrcErrorCorrectionType = &pMpeg4Dec->errorCorrectionType[INPUT_PORT_INDEX]; + + pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; + pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; + pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; + pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; + pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; + } + break; + default: + ret = SEC_OMX_VideoDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); + break; + } +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR pComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL || pComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + switch (nIndex) { + case OMX_IndexParamVideoMpeg4: + { + OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL; + OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure; + SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; + + ret = SEC_OMX_Check_SizeVersion(pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcMpeg4Param->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + pDstMpeg4Param = &pMpeg4Dec->mpeg4Component[pSrcMpeg4Param->nPortIndex]; + + SEC_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); + } + break; + case OMX_IndexParamVideoH263: + { + OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL; + OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure; + SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; + + ret = SEC_OMX_Check_SizeVersion(pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcH263Param->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + pDstH263Param = &pMpeg4Dec->h263Component[pSrcH263Param->nPortIndex]; + + SEC_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); + } + break; + case OMX_IndexParamStandardComponentRole: + { + OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; + + ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + + if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_MPEG4_DEC_ROLE)) { + pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; + //((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_MPEG4; + } else if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_H263_DEC_ROLE)) { + pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; + //((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_H263; + } else { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + } + break; + case OMX_IndexParamPortDefinition: + { + OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)pComponentParameterStructure; + OMX_U32 portIndex = pPortDefinition->nPortIndex; + SEC_OMX_BASEPORT *pSECPort; + OMX_U32 width, height, size; + + if (portIndex >= pSECComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + ret = SEC_OMX_Check_SizeVersion(pPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[portIndex]; + + if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { + if (pSECPort->portDefinition.bEnabled == OMX_TRUE) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + } + if (pPortDefinition->nBufferCountActual < pSECPort->portDefinition.nBufferCountMin) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + SEC_OSAL_Memcpy(&pSECPort->portDefinition, pPortDefinition, pPortDefinition->nSize); + + width = ((pSECPort->portDefinition.format.video.nFrameWidth + 15) & (~15)); + height = ((pSECPort->portDefinition.format.video.nFrameHeight + 15) & (~15)); + size = (width * height * 3) / 2; + pSECPort->portDefinition.format.video.nStride = width; + pSECPort->portDefinition.format.video.nSliceHeight = height; + pSECPort->portDefinition.nBufferSize = (size > pSECPort->portDefinition.nBufferSize) ? size : pSECPort->portDefinition.nBufferSize; + + if (portIndex == INPUT_PORT_INDEX) { + SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + pSECOutputPort->portDefinition.format.video.nFrameWidth = pSECPort->portDefinition.format.video.nFrameWidth; + pSECOutputPort->portDefinition.format.video.nFrameHeight = pSECPort->portDefinition.format.video.nFrameHeight; + pSECOutputPort->portDefinition.format.video.nStride = width; + pSECOutputPort->portDefinition.format.video.nSliceHeight = height; + if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) { + pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2; + } else if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV422Planar) { + pSECOutputPort->portDefinition.nBufferSize = width * height * 2; + } + } + } + break; + case OMX_IndexParamVideoProfileLevelCurrent: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL; + OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL; + SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; + OMX_S32 codecType; + + ret = SEC_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + codecType = pMpeg4Dec->hMFCMpeg4Handle.codecType; + if (codecType == CODEC_TYPE_MPEG4) { + /* + * To do: Check validity of profile & level parameters + */ + + pDstMpeg4Param = &pMpeg4Dec->mpeg4Component[pSrcProfileLevel->nPortIndex]; + pDstMpeg4Param->eProfile = pSrcProfileLevel->eProfile; + pDstMpeg4Param->eLevel = pSrcProfileLevel->eLevel; + } else { + /* + * To do: Check validity of profile & level parameters + */ + + pDstH263Param = &pMpeg4Dec->h263Component[pSrcProfileLevel->nPortIndex]; + pDstH263Param->eProfile = pSrcProfileLevel->eProfile; + pDstH263Param->eLevel = pSrcProfileLevel->eLevel; + } + } + break; + case OMX_IndexParamVideoErrorCorrection: + { + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; + SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; + + ret = SEC_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + pDstErrorCorrectionType = &pMpeg4Dec->errorCorrectionType[INPUT_PORT_INDEX]; + + pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; + pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; + pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; + pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; + pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; + } + break; + default: + ret = SEC_OMX_VideoDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure); + break; + } +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetConfig( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR pComponentConfigStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL || pComponentConfigStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + switch (nIndex) { + case OMX_IndexVendorThumbnailMode: + { + SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + + pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode = *((OMX_BOOL *)pComponentConfigStructure); + } + break; + default: + ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure); + break; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetExtensionIndex( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_STRING cParameterName, + OMX_OUT OMX_INDEXTYPE *pIndexType) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if ((cParameterName == NULL) || (pIndexType == NULL)) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + if (SEC_OSAL_Strcmp(cParameterName, "OMX.SEC.index.ThumbnailMode") == 0) { + SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + + *pIndexType = OMX_IndexVendorThumbnailMode; + + ret = OMX_ErrorNone; + } else { + ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType); + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_ComponentRoleEnum( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_OUT OMX_U8 *cRole, + OMX_IN OMX_U32 nIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + OMX_S32 codecType; + + FunctionIn(); + + if ((hComponent == NULL) || (cRole == NULL)) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (nIndex != (MAX_COMPONENT_ROLE_NUM - 1)) { + ret = OMX_ErrorNoMore; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + codecType = ((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType; + if (codecType == CODEC_TYPE_MPEG4) + SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_MPEG4_DEC_ROLE); + else + SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_H263_DEC_ROLE); + +EXIT: + FunctionOut(); + + return ret; +} + +/* MFC Init */ +OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_Init(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; + OMX_HANDLETYPE hMFCHandle = NULL; + OMX_PTR pStreamBuffer = NULL; + OMX_PTR pStreamPhyBuffer = NULL; + + FunctionIn(); + + pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFC = OMX_FALSE; + pSECComponent->bUseFlagEOF = OMX_FALSE; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + + /* MFC(Multi Format Codec) decoder and CMM(Codec Memory Management) driver open */ + hMFCHandle = SsbSipMfcDecOpen(); + if (hMFCHandle == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + ghMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle = hMFCHandle; + + /* Allocate decoder's input buffer */ + pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE); + if (pStreamBuffer == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = pStreamBuffer; + pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = pStreamPhyBuffer; + pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pStreamBuffer; + pSECComponent->processData[INPUT_PORT_INDEX].allocSize = DEFAULT_MFC_INPUT_BUFFER_SIZE; + + SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); + SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); + pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp = 0; + pSECComponent->getAllDelayBuffer = OMX_FALSE; + +EXIT: + FunctionOut(); + + return ret; +} + +/* MFC Terminate */ +OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; + OMX_HANDLETYPE hMFCHandle = NULL; + + FunctionIn(); + + pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; + + pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = NULL; + pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = NULL; + pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = NULL; + pSECComponent->processData[INPUT_PORT_INDEX].allocSize = 0; + + if (hMFCHandle != NULL) { + SsbSipMfcDecClose(hMFCHandle); + pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle = NULL; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + OMX_HANDLETYPE hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle; + OMX_U32 oneFrameSize = pInputData->dataLen; + SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo; + OMX_S32 configValue; + OMX_S32 returnCodec; + int bufWidth; + int bufHeight; + + FunctionIn(); + + if (pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFC == OMX_FALSE) { + SSBSIP_MFC_CODEC_TYPE MFCCodecType; + if (pMpeg4Dec->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) { + if (gbFIMV1) + MFCCodecType = FIMV1_DEC; + else + MFCCodecType = MPEG4_DEC; + } else { + MFCCodecType = H263_DEC; + } + + if ((oneFrameSize <= 0) && (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) { + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + ret = OMX_ErrorNone; + goto EXIT; + } + + /* Set the number of extra buffer to prevent tearing */ + configValue = 5; + SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &configValue); + + /* Set mpeg4 deblocking filter enable */ + configValue = 1; + SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_POST_ENABLE, &configValue); + + if (pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_TRUE) { + configValue = 0; // the number that you want to delay + SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &configValue); + } + + returnCodec = SsbSipMfcDecInit(hMFCHandle, MFCCodecType, oneFrameSize); + if (returnCodec == MFC_RET_OK) { + SSBSIP_MFC_IMG_RESOLUTION imgResol; + SEC_OMX_BASEPORT *pInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + + if (SsbSipMfcDecGetConfig(hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol) != MFC_RET_OK) { + ret = OMX_ErrorMFCInit; + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcDecGetConfig failed", __FUNCTION__); + goto EXIT; + } + + /** Update Frame Size **/ + if ((pInputPort->portDefinition.format.video.nFrameWidth != imgResol.width) || + (pInputPort->portDefinition.format.video.nFrameHeight != imgResol.height)) { + /* change width and height information */ + pInputPort->portDefinition.format.video.nFrameWidth = imgResol.width; + pInputPort->portDefinition.format.video.nFrameHeight = imgResol.height; + pInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15)); + pInputPort->portDefinition.format.video.nSliceHeight = ((imgResol.height + 15) & (~15)); + + SEC_UpdateFrameSize(pOMXComponent); + + /* Send Port Settings changed call back */ + (*(pSECComponent->pCallbacks->EventHandler)) + (pOMXComponent, + pSECComponent->callbackData, + OMX_EventPortSettingsChanged, // The command was completed + OMX_DirOutput, // This is the port index + 0, + NULL); + } + + SEC_OSAL_Log(SEC_LOG_TRACE, "nFrameWidth(%d) nFrameHeight(%d), nStride(%d), nSliceHeight(%d)", + pInputPort->portDefinition.format.video.nFrameWidth, pInputPort->portDefinition.format.video.nFrameHeight, + pInputPort->portDefinition.format.video.nStride, pInputPort->portDefinition.format.video.nSliceHeight); + + pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFC = OMX_TRUE; + if (pMpeg4Dec->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) { + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + ret = OMX_ErrorNone; + } else { + pOutputData->dataLen = 0; + ret = OMX_ErrorInputDataDecodeYet; + } + goto EXIT; + } else { + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcDecInit failed", __FUNCTION__); + ret = OMX_ErrorMFCInit; /* OMX_ErrorUndefined */ + goto EXIT; + } + } + +#ifndef FULL_FRAME_SEARCH + if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) && + (pSECComponent->bUseFlagEOF == OMX_FALSE)) { + pSECComponent->bUseFlagEOF = OMX_TRUE; + } +#endif + + pSECComponent->timeStamp[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp; + pSECComponent->nFlags[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags; + SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp)); + pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp++; + if (pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp >= MAX_TIMESTAMP) + pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp = 0; + + if (Check_Stream_PrefixCode(pInputData->dataBuffer, pInputData->dataLen, pMpeg4Dec->hMFCMpeg4Handle.codecType) == OMX_TRUE) { + returnCodec = SsbSipMfcDecExe(hMFCHandle, oneFrameSize); + } else { + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + returnCodec = MFC_RET_OK; + goto EXIT; + } + + if (returnCodec == MFC_RET_OK) { + SSBSIP_MFC_DEC_OUTBUF_STATUS status; + OMX_S32 indexTimestamp = 0; + + status = SsbSipMfcDecGetOutBuf(hMFCHandle, &outputInfo); + bufWidth = (outputInfo.img_width + 15) & (~15); + bufHeight = (outputInfo.img_height + 15) & (~15); + + if ((SsbSipMfcDecGetConfig(hMFCHandle, MFC_DEC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) || + (((indexTimestamp < 0) || (indexTimestamp > MAX_TIMESTAMP)))) { + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + } else { + pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp]; + pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp]; + } + + if ((status == MFC_GETOUTBUF_DISPLAY_DECODING) || + (status == MFC_GETOUTBUF_DISPLAY_ONLY)) { + switch(pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) { + case OMX_COLOR_FormatYUV420Planar: + case OMX_COLOR_FormatYUV420SemiPlanar: + pOutputData->dataLen = (bufWidth * bufHeight * 3) /2; + break; + default: + pOutputData->dataLen = bufWidth * bufHeight * 2; + break; + } + } + if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS) + pOutputData->dataLen = 0; + + if ((status == MFC_GETOUTBUF_DISPLAY_ONLY) || + (pSECComponent->getAllDelayBuffer == OMX_TRUE)) { + ret = OMX_ErrorInputDataDecodeYet; + } + + if (status == MFC_GETOUTBUF_DECODING_ONLY) { + /* ret = OMX_ErrorInputDataDecodeYet; */ + ret = OMX_ErrorNone; + goto EXIT; + } + +#ifdef FULL_FRAME_SEARCH + if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS) && + (pSECComponent->bSaveFlagEOS == OMX_TRUE)) { + pInputData->nFlags |= OMX_BUFFERFLAG_EOS; + pSECComponent->getAllDelayBuffer = OMX_TRUE; + ret = OMX_ErrorInputDataDecodeYet; + } else +#endif + + if ((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { + pInputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS)); + pSECComponent->getAllDelayBuffer = OMX_TRUE; + ret = OMX_ErrorInputDataDecodeYet; + } else if ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { + pSECComponent->getAllDelayBuffer = OMX_FALSE; + ret = OMX_ErrorNone; + } + } else { + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + switch(pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) { + case OMX_COLOR_FormatYUV420Planar: + case OMX_COLOR_FormatYUV420SemiPlanar: + pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2; + break; + default: + pOutputData->dataLen = bufWidth * bufHeight * 2; + break; + } + + if ((pSECComponent->bSaveFlagEOS == OMX_TRUE) || + (pSECComponent->getAllDelayBuffer == OMX_TRUE) || + (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) { + pOutputData->nFlags |= OMX_BUFFERFLAG_EOS; + pSECComponent->getAllDelayBuffer = OMX_FALSE; + pOutputData->dataLen = 0; + } + + /* ret = OMX_ErrorUndefined; */ /* ????? */ + ret = OMX_ErrorNone; + goto EXIT; + } + + /** Fill Output Buffer **/ + if (pOutputData->dataLen > 0) + { + int frameSize = bufWidth * bufHeight; + void *pOutputBuf = (void *)pOutputData->dataBuffer; + +#ifdef USE_SAMSUNG_COLORFORMAT + SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + + if ((pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_FALSE) && + (pSECOutputPort->portDefinition.format.video.eColorFormat == SEC_OMX_COLOR_FormatNV12PhysicalAddress)) + +#else + if (pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_FALSE) +#endif + { + /* if use Post copy address structure */ + SEC_OSAL_Memcpy(pOutputBuf, &frameSize, sizeof(frameSize)); + SEC_OSAL_Memcpy(pOutputBuf + sizeof(frameSize), &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr)); + SEC_OSAL_Memcpy(pOutputBuf + sizeof(frameSize) + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr)); + SEC_OSAL_Memcpy(pOutputBuf + sizeof(frameSize) + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr)); + SEC_OSAL_Memcpy(pOutputBuf + sizeof(frameSize) + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr)); + } else { + SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420 out for ThumbnailMode"); + Y_tile_to_linear_4x2( + (unsigned char *)pOutputBuf, + (unsigned char *)outputInfo.YVirAddr, + bufWidth, bufHeight); + CbCr_tile_to_linear_4x2( + ((unsigned char *)pOutputBuf) + frameSize, + (unsigned char *)outputInfo.CVirAddr, + bufWidth, bufHeight); + } + } + +EXIT: + FunctionOut(); + + return ret; +} + +/* MFC Decode */ +OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + SEC_OMX_BASEPORT *pInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + SEC_OMX_BASEPORT *pOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + OMX_BOOL bCheckPrefix = OMX_FALSE; + + FunctionIn(); + + if ((!CHECK_PORT_ENABLED(pInputPort)) || (!CHECK_PORT_ENABLED(pOutputPort)) || + (!CHECK_PORT_POPULATED(pInputPort)) || (!CHECK_PORT_POPULATED(pOutputPort))) { + ret = OMX_ErrorNone; + goto EXIT; + } + if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) { + ret = OMX_ErrorNone; + goto EXIT; + } + + ret = SEC_MFC_Mpeg4_Decode(pOMXComponent, pInputData, pOutputData); + if (ret != OMX_ErrorNone) { + if (ret == OMX_ErrorInputDataDecodeYet) { + pOutputData->usedDataLen = 0; + pOutputData->remainDataLen = pOutputData->dataLen; + } else { + pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, + pSECComponent->callbackData, + OMX_EventError, ret, 0, NULL); + } + } else { + pInputData->previousDataLen = pInputData->dataLen; + pInputData->usedDataLen += pInputData->dataLen; + pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen; + pInputData->dataLen -= pInputData->usedDataLen; + pInputData->usedDataLen = 0; + + pOutputData->usedDataLen = 0; + pOutputData->remainDataLen = pOutputData->dataLen; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; + OMX_S32 codecType = -1; + int i = 0; + + FunctionIn(); + + if ((hComponent == NULL) || (componentName == NULL)) { + ret = OMX_ErrorBadParameter; + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: parameters are null, ret: %X", __FUNCTION__, ret); + goto EXIT; + } + if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_MPEG4_DEC, componentName) == 0) { + codecType = CODEC_TYPE_MPEG4; + } else if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_H263_DEC, componentName) == 0) { + codecType = CODEC_TYPE_H263; + } else { + ret = OMX_ErrorBadParameter; + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName(%s) error, ret: %X", __FUNCTION__, ret); + goto EXIT; + } + + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_VideoDecodeComponentInit(pOMXComponent); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_OMX_VideoDecodeComponentInit error, ret: %X", __FUNCTION__, ret); + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pSECComponent->codecType = HW_VIDEO_CODEC; + + pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); + if (pSECComponent->componentName == NULL) { + SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent); + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName alloc error, ret: %X", __FUNCTION__, ret); + goto EXIT; + } + SEC_OSAL_Memset(pSECComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); + + pMpeg4Dec = SEC_OSAL_Malloc(sizeof(SEC_MPEG4_HANDLE)); + if (pMpeg4Dec == NULL) { + SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent); + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_MPEG4_HANDLE alloc error, ret: %X", __FUNCTION__, ret); + goto EXIT; + } + SEC_OSAL_Memset(pMpeg4Dec, 0, sizeof(SEC_MPEG4_HANDLE)); + pSECComponent->hCodecHandle = (OMX_HANDLETYPE)pMpeg4Dec; + pMpeg4Dec->hMFCMpeg4Handle.codecType = codecType; + + if (codecType == CODEC_TYPE_MPEG4) + SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_MPEG4_DEC); + else + SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_H263_DEC); + + /* Set componentVersion */ + pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; + pSECComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; + pSECComponent->componentVersion.s.nRevision = REVISION_NUMBER; + pSECComponent->componentVersion.s.nStep = STEP_NUMBER; + /* Set specVersion */ + pSECComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; + pSECComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; + pSECComponent->specVersion.s.nRevision = REVISION_NUMBER; + pSECComponent->specVersion.s.nStep = STEP_NUMBER; + + /* Android CapabilityFlags */ + pSECComponent->capabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_FALSE; + pSECComponent->capabilityFlags.iOMXComponentSupportsPartialFrames = OMX_FALSE; + pSECComponent->capabilityFlags.iOMXComponentUsesNALStartCodes = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentUsesFullAVCFrames = OMX_TRUE; + + /* Input port */ + pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; + pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; + pSECPort->portDefinition.format.video.nStride = 0; + pSECPort->portDefinition.format.video.nSliceHeight = 0; + pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; + if (codecType == CODEC_TYPE_MPEG4) { + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; + SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/mpeg4"); + } else { + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; + SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/h263"); + } + pSECPort->portDefinition.format.video.pNativeRender = 0; + pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; + pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; + pSECPort->portDefinition.bEnabled = OMX_TRUE; + + /* Output port */ + pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; + pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; + pSECPort->portDefinition.format.video.nStride = 0; + pSECPort->portDefinition.format.video.nSliceHeight = 0; + pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; + SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); + pSECPort->portDefinition.format.video.pNativeRender = 0; + pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; + pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar; + pSECPort->portDefinition.bEnabled = OMX_TRUE; + + if (codecType == CODEC_TYPE_MPEG4) { + for(i = 0; i < ALL_PORT_NUM; i++) { + INIT_SET_SIZE_VERSION(&pMpeg4Dec->mpeg4Component[i], OMX_VIDEO_PARAM_MPEG4TYPE); + pMpeg4Dec->mpeg4Component[i].nPortIndex = i; + pMpeg4Dec->mpeg4Component[i].eProfile = OMX_VIDEO_MPEG4ProfileSimple; + pMpeg4Dec->mpeg4Component[i].eLevel = OMX_VIDEO_MPEG4Level3; + } + } else { + for(i = 0; i < ALL_PORT_NUM; i++) { + INIT_SET_SIZE_VERSION(&pMpeg4Dec->h263Component[i], OMX_VIDEO_PARAM_H263TYPE); + pMpeg4Dec->h263Component[i].nPortIndex = i; + pMpeg4Dec->h263Component[i].eProfile = OMX_VIDEO_H263ProfileBaseline | OMX_VIDEO_H263ProfileISWV2; + pMpeg4Dec->h263Component[i].eLevel = OMX_VIDEO_H263Level45; + } + } + + pOMXComponent->GetParameter = &SEC_MFC_Mpeg4Dec_GetParameter; + pOMXComponent->SetParameter = &SEC_MFC_Mpeg4Dec_SetParameter; + pOMXComponent->SetConfig = &SEC_MFC_Mpeg4Dec_SetConfig; + pOMXComponent->GetExtensionIndex = &SEC_MFC_Mpeg4Dec_GetExtensionIndex; + pOMXComponent->ComponentRoleEnum = &SEC_MFC_Mpeg4Dec_ComponentRoleEnum; + pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit; + + pSECComponent->sec_mfc_componentInit = &SEC_MFC_Mpeg4Dec_Init; + pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_Mpeg4Dec_Terminate; + pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_Mpeg4Dec_bufferProcess; + if (codecType == CODEC_TYPE_MPEG4) + pSECComponent->sec_checkInputFrame = &Check_Mpeg4_Frame; + else + pSECComponent->sec_checkInputFrame = &Check_H263_Frame; + + pSECComponent->currentState = OMX_StateLoaded; + + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_MPEG4_HANDLE *pMpeg4Dec = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + SEC_OSAL_Free(pSECComponent->componentName); + pSECComponent->componentName = NULL; + + pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle; + if (pMpeg4Dec != NULL) { + SEC_OSAL_Free(pMpeg4Dec); + pSECComponent->hCodecHandle = NULL; + } + + ret = SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h new file mode 100644 index 0000000..25170b8 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h @@ -0,0 +1,91 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Mpeg4dec.h + * @brief + * @author Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_MPEG4_DEC_COMPONENT +#define SEC_OMX_MPEG4_DEC_COMPONENT + +#include "SEC_OMX_Def.h" +#include "OMX_Component.h" + + +typedef enum _CODEC_TYPE +{ + CODEC_TYPE_H263, + CODEC_TYPE_MPEG4 +} CODEC_TYPE; + +/* + * This structure is the same as BitmapInfoHhr struct in pv_avifile_typedefs.h file + */ +typedef struct _BitmapInfoHhr +{ + OMX_U32 BiSize; + OMX_U32 BiWidth; + OMX_U32 BiHeight; + OMX_U16 BiPlanes; + OMX_U16 BiBitCount; + OMX_U32 BiCompression; + OMX_U32 BiSizeImage; + OMX_U32 BiXPelsPerMeter; + OMX_U32 BiYPelsPerMeter; + OMX_U32 BiClrUsed; + OMX_U32 BiClrImportant; +} BitmapInfoHhr; + +typedef struct _SEC_MFC_MPEG4_HANDLE +{ + OMX_HANDLETYPE hMFCHandle; + OMX_PTR pMFCStreamBuffer; + OMX_PTR pMFCStreamPhyBuffer; + OMX_U32 indexTimestamp; + OMX_BOOL bConfiguredMFC; + OMX_BOOL bThumbnailMode; + CODEC_TYPE codecType; +} SEC_MFC_MPEG4_HANDLE; + +typedef struct _SEC_MPEG4_HANDLE +{ + /* OMX Codec specific */ + OMX_VIDEO_PARAM_H263TYPE h263Component[ALL_PORT_NUM]; + OMX_VIDEO_PARAM_MPEG4TYPE mpeg4Component[ALL_PORT_NUM]; + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE errorCorrectionType[ALL_PORT_NUM]; + + /* SEC MFC Codec specific */ + SEC_MFC_MPEG4_HANDLE hMFCMpeg4Handle; +} SEC_MPEG4_HANDLE; + +#ifdef __cplusplus +extern "C" { +#endif + +OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName); + OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent); + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c new file mode 100644 index 0000000..89b856d --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c @@ -0,0 +1,63 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 library_register.c + * @brief + * @author Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include +#include + +#include "SEC_OSAL_Memory.h" +#include "SEC_OSAL_ETC.h" +#include "library_register.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_MPEG4_DEC" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent) +{ + FunctionIn(); + + if (ppSECComponent == NULL) + goto EXIT; + + /* component 1 - video decoder MPEG4 */ + SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPOMENT_MPEG4_DEC); + SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPOMENT_MPEG4_DEC_ROLE); + ppSECComponent[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM; + + /* component 2 - video decoder H.263 */ + SEC_OSAL_Strcpy(ppSECComponent[1]->componentName, SEC_OMX_COMPOMENT_H263_DEC); + SEC_OSAL_Strcpy(ppSECComponent[1]->roles[0], SEC_OMX_COMPOMENT_H263_DEC_ROLE); + ppSECComponent[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM; + +EXIT: + FunctionOut(); + return MAX_COMPONENT_NUM; +} + diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h new file mode 100644 index 0000000..e9bcfe8 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h @@ -0,0 +1,59 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 library_register.h + * @brief + * @author Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_MPEG4_DEC_REG +#define SEC_OMX_MPEG4_DEC_REG + +#include "SEC_OMX_Def.h" +#include "OMX_Component.h" +#include "SEC_OMX_Component_Register.h" + + +#define OSCL_EXPORT_REF __attribute__((visibility("default"))) +#define MAX_COMPONENT_NUM 2 +#define MAX_COMPONENT_ROLE_NUM 1 + +/* MPEG4 */ +#define SEC_OMX_COMPOMENT_MPEG4_DEC "OMX.SEC.MPEG4.Decoder" +#define SEC_OMX_COMPOMENT_MPEG4_DEC_ROLE "video_decoder.mpeg4" + +/* H.263 */ +#define SEC_OMX_COMPOMENT_H263_DEC "OMX.SEC.H263.Decoder" +#define SEC_OMX_COMPOMENT_H263_DEC_ROLE "video_decoder.h263" + + +#ifdef __cplusplus +extern "C" { +#endif + +OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent); + +#ifdef __cplusplus +}; +#endif + +#endif + diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/Android.mk b/sec_mm/sec_omx/sec_omx_component/video/enc/Android.mk new file mode 100644 index 0000000..e9ca8e7 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/Android.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + SEC_OMX_Venc.c + +LOCAL_MODULE := libSEC_OMX_Venc.aries +LOCAL_ARM_MODE := arm +LOCAL_MODULE_TAGS := optional + +LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ + $(SEC_OMX_INC)/sec \ + $(SEC_OMX_TOP)/sec_osal \ + $(SEC_OMX_TOP)/sec_omx_core \ + $(SEC_OMX_COMPONENT)/common \ + $(SEC_OMX_COMPONENT)/video/dec + +LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include + +include $(BUILD_STATIC_LIBRARY) diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c b/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c new file mode 100644 index 0000000..eff5dec --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c @@ -0,0 +1,1411 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Venc.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include +#include "SEC_OMX_Macros.h" +#include "SEC_OSAL_Event.h" +#include "SEC_OMX_Venc.h" +#include "SEC_OMX_Basecomponent.h" +#include "SEC_OSAL_Thread.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_VIDEO_ENC" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + +#define ONE_FRAME_OUTPUT /* only one frame output for Android */ +#define S5PC110_ENCODE_IN_DATA_BUFFER /* for Android s5pc110 0copy*/ + + +inline void SEC_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent) +{ + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + + if ((secOutputPort->portDefinition.format.video.nFrameWidth != + secInputPort->portDefinition.format.video.nFrameWidth) || + (secOutputPort->portDefinition.format.video.nFrameHeight != + secInputPort->portDefinition.format.video.nFrameHeight)) { + OMX_U32 width = 0, height = 0; + + secOutputPort->portDefinition.format.video.nFrameWidth = + secInputPort->portDefinition.format.video.nFrameWidth; + secOutputPort->portDefinition.format.video.nFrameHeight = + secInputPort->portDefinition.format.video.nFrameHeight; + width = secOutputPort->portDefinition.format.video.nStride = + secInputPort->portDefinition.format.video.nStride; + height = secOutputPort->portDefinition.format.video.nSliceHeight = + secInputPort->portDefinition.format.video.nSliceHeight; + + switch(secOutputPort->portDefinition.format.video.eColorFormat) { + case OMX_COLOR_FormatYUV420Planar: + case OMX_COLOR_FormatYUV420SemiPlanar: + if (width && height) + secOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2; + break; + default: + if (width && height) + secOutputPort->portDefinition.nBufferSize = width * height * 2; + break; + } + } + + return ; +} + +OMX_ERRORTYPE SEC_OMX_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 ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; + int i = 0; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + pSECPort = &pSECComponent->pSECPort[nPortIndex]; + if (nPortIndex >= pSECComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + if (pSECPort->portState != OMX_StateIdle) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); + if (temp_bufferHeader == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE)); + + for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { + if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { + pSECPort->bufferHeader[i] = temp_bufferHeader; + pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED); + INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE); + temp_bufferHeader->pBuffer = pBuffer; + temp_bufferHeader->nAllocLen = nSizeBytes; + temp_bufferHeader->pAppPrivate = pAppPrivate; + if (nPortIndex == INPUT_PORT_INDEX) + temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX; + else + temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX; + + pSECPort->assignedBufferNum++; + if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) { + pSECPort->portDefinition.bPopulated = OMX_TRUE; + /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */ + SEC_OSAL_SemaphorePost(pSECPort->loadedResource); + /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */ + } + *ppBufferHdr = temp_bufferHeader; + ret = OMX_ErrorNone; + goto EXIT; + } + } + ret = OMX_ErrorInsufficientResources; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_AllocateBuffer( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer, + OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_PTR pAppPrivate, + OMX_IN OMX_U32 nSizeBytes) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; + OMX_U8 *temp_buffer = NULL; + int i = 0; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + pSECPort = &pSECComponent->pSECPort[nPortIndex]; + if (nPortIndex >= pSECComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } +/* + if (pSECPort->portState != OMX_StateIdle ) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } +*/ + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + temp_buffer = SEC_OSAL_Malloc(sizeof(OMX_U8) * nSizeBytes); + if (temp_buffer == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + + temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); + if (temp_bufferHeader == NULL) { + SEC_OSAL_Free(temp_buffer); + temp_buffer = NULL; + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE)); + + for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { + if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { + pSECPort->bufferHeader[i] = temp_bufferHeader; + pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ALLOCATED | HEADER_STATE_ALLOCATED); + INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE); + temp_bufferHeader->pBuffer = temp_buffer; + temp_bufferHeader->nAllocLen = nSizeBytes; + temp_bufferHeader->pAppPrivate = pAppPrivate; + if (nPortIndex == INPUT_PORT_INDEX) + temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX; + else + temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX; + pSECPort->assignedBufferNum++; + if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) { + pSECPort->portDefinition.bPopulated = OMX_TRUE; + /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */ + SEC_OSAL_SemaphorePost(pSECPort->loadedResource); + /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */ + } + *ppBuffer = temp_bufferHeader; + ret = OMX_ErrorNone; + goto EXIT; + } + } + ret = OMX_ErrorInsufficientResources; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_FreeBuffer( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; + OMX_U8 *temp_buffer = NULL; + int i = 0; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pSECPort = &pSECComponent->pSECPort[nPortIndex]; + + if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + if ((pSECPort->portState != OMX_StateLoaded) && (pSECPort->portState != OMX_StateInvalid)) { + (*(pSECComponent->pCallbacks->EventHandler)) (pOMXComponent, + pSECComponent->callbackData, + (OMX_U32)OMX_EventError, + (OMX_U32)OMX_ErrorPortUnpopulated, + nPortIndex, NULL); + } + + for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) { + if (((pSECPort->bufferStateAllocate[i] | BUFFER_STATE_FREE) != 0) && (pSECPort->bufferHeader[i] != NULL)) { + if (pSECPort->bufferHeader[i]->pBuffer == pBufferHdr->pBuffer) { + if (pSECPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) { + SEC_OSAL_Free(pSECPort->bufferHeader[i]->pBuffer); + pSECPort->bufferHeader[i]->pBuffer = NULL; + pBufferHdr->pBuffer = NULL; + } else if (pSECPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) { + ; /* None*/ + } + pSECPort->assignedBufferNum--; + if (pSECPort->bufferStateAllocate[i] & HEADER_STATE_ALLOCATED) { + SEC_OSAL_Free(pSECPort->bufferHeader[i]); + pSECPort->bufferHeader[i] = NULL; + pBufferHdr = NULL; + } + pSECPort->bufferStateAllocate[i] = BUFFER_STATE_FREE; + ret = OMX_ErrorNone; + goto EXIT; + } + } + } + +EXIT: + if (ret == OMX_ErrorNone) { + if (pSECPort->assignedBufferNum == 0 ) { + SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->unloadedResource signal set"); + /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */ + SEC_OSAL_SemaphorePost(pSECPort->unloadedResource); + /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */ + pSECPort->portDefinition.bPopulated = OMX_FALSE; + } + } + + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_AllocateTunnelBuffer(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; + OMX_U8 *temp_buffer = NULL; + OMX_U32 bufferSize = 0; + OMX_PARAM_PORTDEFINITIONTYPE portDefinition; + + ret = OMX_ErrorTunnelingUnsupported; +EXIT: + return ret; +} + +OMX_ERRORTYPE SEC_OMX_FreeTunnelBuffer(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASEPORT* pSECPort = NULL; + OMX_BUFFERHEADERTYPE* temp_bufferHeader = NULL; + OMX_U8 *temp_buffer = NULL; + OMX_U32 bufferSize = 0; + OMX_PARAM_PORTDEFINITIONTYPE portDefinition; + + ret = OMX_ErrorTunnelingUnsupported; +EXIT: + return ret; +} + +OMX_ERRORTYPE SEC_OMX_ComponentTunnelRequest( + OMX_IN OMX_HANDLETYPE hComp, + OMX_IN OMX_U32 nPort, + OMX_IN OMX_HANDLETYPE hTunneledComp, + OMX_IN OMX_U32 nTunneledPort, + OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + + ret = OMX_ErrorTunnelingUnsupported; +EXIT: + return ret; +} + +OMX_BOOL SEC_Check_BufferProcess_State(SEC_OMX_BASECOMPONENT *pSECComponent) +{ + if ((pSECComponent->currentState == OMX_StateExecuting) && + (pSECComponent->pSECPort[INPUT_PORT_INDEX].portState == OMX_StateIdle) && + (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portState == OMX_StateIdle) && + (pSECComponent->transientState != SEC_OMX_TransStateExecutingToIdle) && + (pSECComponent->transientState != SEC_OMX_TransStateIdleToExecuting)) + return OMX_TRUE; + else + return OMX_FALSE; +} + +static OMX_ERRORTYPE SEC_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *secOMXInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + SEC_OMX_BASEPORT *secOMXOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; + OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; + + FunctionIn(); + + if (bufferHeader != NULL) { + if (secOMXInputPort->markType.hMarkTargetComponent != NULL ) { + bufferHeader->hMarkTargetComponent = secOMXInputPort->markType.hMarkTargetComponent; + bufferHeader->pMarkData = secOMXInputPort->markType.pMarkData; + secOMXInputPort->markType.hMarkTargetComponent = NULL; + secOMXInputPort->markType.pMarkData = NULL; + } + + if (bufferHeader->hMarkTargetComponent != NULL) { + if (bufferHeader->hMarkTargetComponent == pOMXComponent) { + pSECComponent->pCallbacks->EventHandler(pOMXComponent, + pSECComponent->callbackData, + OMX_EventMark, + 0, 0, bufferHeader->pMarkData); + } else { + pSECComponent->propagateMarkType.hMarkTargetComponent = bufferHeader->hMarkTargetComponent; + pSECComponent->propagateMarkType.pMarkData = bufferHeader->pMarkData; + } + } + + if (CHECK_PORT_TUNNELED(secOMXInputPort)) { + OMX_FillThisBuffer(secOMXInputPort->tunneledComponent, bufferHeader); + } else { + bufferHeader->nFilledLen = 0; + pSECComponent->pCallbacks->EmptyBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); + } + } + + if ((pSECComponent->currentState == OMX_StatePause) && + ((!CHECK_PORT_BEING_FLUSHED(secOMXInputPort) && !CHECK_PORT_BEING_FLUSHED(secOMXOutputPort)))) { + SEC_OSAL_SignalReset(pSECComponent->pauseEvent); + SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME); + } + + dataBuffer->dataValid = OMX_FALSE; + dataBuffer->dataLen = 0; + dataBuffer->remainDataLen = 0; + dataBuffer->usedDataLen = 0; + dataBuffer->bufferHeader = NULL; + dataBuffer->nFlags = 0; + dataBuffer->timeStamp = 0; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_InputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASEPORT *pSECPort = NULL; + SEC_OMX_DATABUFFER *dataBuffer = NULL; + SEC_OMX_MESSAGE* message = NULL; + SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; + + FunctionIn(); + + pSECPort= &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + dataBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; + + if (pSECComponent->currentState != OMX_StateExecuting) { + ret = OMX_ErrorUndefined; + goto EXIT; + } else { + SEC_OSAL_SemaphoreWait(pSECPort->bufferSemID); + SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex); + if (dataBuffer->dataValid != OMX_TRUE) { + message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ); + if (message == NULL) { + ret = OMX_ErrorUndefined; + SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); + goto EXIT; + } + + dataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData); + dataBuffer->allocSize = dataBuffer->bufferHeader->nAllocLen; + dataBuffer->dataLen = dataBuffer->bufferHeader->nFilledLen; + dataBuffer->remainDataLen = dataBuffer->dataLen; + dataBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset; + dataBuffer->dataValid = OMX_TRUE; + dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; + dataBuffer->timeStamp = dataBuffer->bufferHeader->nTimeStamp; +#ifdef S5PC110_ENCODE_IN_DATA_BUFFER + pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = dataBuffer->bufferHeader->pBuffer; + pSECComponent->processData[INPUT_PORT_INDEX].allocSize = dataBuffer->bufferHeader->nAllocLen; +#endif + SEC_OSAL_Free(message); + } + SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); + ret = OMX_ErrorNone; + } +EXIT: + FunctionOut(); + + return ret; +} + +static OMX_ERRORTYPE SEC_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *secOMXInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + SEC_OMX_BASEPORT *secOMXOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; + OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; + + FunctionIn(); + + if (bufferHeader != NULL) { + bufferHeader->nFilledLen = dataBuffer->remainDataLen; + bufferHeader->nOffset = 0; + bufferHeader->nFlags = dataBuffer->nFlags; + bufferHeader->nTimeStamp = dataBuffer->timeStamp; + + if (pSECComponent->propagateMarkType.hMarkTargetComponent != NULL) { + bufferHeader->hMarkTargetComponent = pSECComponent->propagateMarkType.hMarkTargetComponent; + bufferHeader->pMarkData = pSECComponent->propagateMarkType.pMarkData; + pSECComponent->propagateMarkType.hMarkTargetComponent = NULL; + pSECComponent->propagateMarkType.pMarkData = NULL; + } + + if (bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) { + pSECComponent->pCallbacks->EventHandler(pOMXComponent, + pSECComponent->callbackData, + OMX_EventBufferFlag, + OUTPUT_PORT_INDEX, + bufferHeader->nFlags, NULL); + } + + if (CHECK_PORT_TUNNELED(secOMXOutputPort)) { + OMX_EmptyThisBuffer(secOMXOutputPort->tunneledComponent, bufferHeader); + } else { + pSECComponent->pCallbacks->FillBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader); + } + } + + if ((pSECComponent->currentState == OMX_StatePause) && + ((!CHECK_PORT_BEING_FLUSHED(secOMXInputPort) && !CHECK_PORT_BEING_FLUSHED(secOMXOutputPort)))) { + SEC_OSAL_SignalReset(pSECComponent->pauseEvent); + SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME); + } + + /* reset dataBuffer */ + dataBuffer->dataValid = OMX_FALSE; + dataBuffer->dataLen = 0; + dataBuffer->remainDataLen = 0; + dataBuffer->usedDataLen = 0; + dataBuffer->bufferHeader = NULL; + dataBuffer->nFlags = 0; + dataBuffer->timeStamp = 0; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OutputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASEPORT *pSECPort = NULL; + SEC_OMX_DATABUFFER *dataBuffer = NULL; + SEC_OMX_MESSAGE *message = NULL; + SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; + + FunctionIn(); + + pSECPort= &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + dataBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; + + if (pSECComponent->currentState != OMX_StateExecuting) { + ret = OMX_ErrorUndefined; + goto EXIT; + } else { + SEC_OSAL_SemaphoreWait(pSECPort->bufferSemID); + SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); + if (dataBuffer->dataValid != OMX_TRUE) { + message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ); + if (message == NULL) { + ret = OMX_ErrorUndefined; + SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); + goto EXIT; + } + + dataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData); + dataBuffer->allocSize = dataBuffer->bufferHeader->nAllocLen; + dataBuffer->dataLen = 0; //dataBuffer->bufferHeader->nFilledLen; + dataBuffer->remainDataLen = dataBuffer->dataLen; + dataBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset; + dataBuffer->dataValid =OMX_TRUE; + /* dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; */ + /* dataBuffer->nTimeStamp = dataBuffer->bufferHeader->nTimeStamp; */ + SEC_OSAL_Free(message); + } + SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); + ret = OMX_ErrorNone; + } +EXIT: + FunctionOut(); + + return ret; + +} + +static OMX_ERRORTYPE SEC_BufferReset(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 portIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + /* SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[portIndex]; */ + SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[portIndex]; + /* OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; */ + + dataBuffer->dataValid = OMX_FALSE; + dataBuffer->dataLen = 0; + dataBuffer->remainDataLen = 0; + dataBuffer->usedDataLen = 0; + dataBuffer->bufferHeader = NULL; + dataBuffer->nFlags = 0; + dataBuffer->timeStamp = 0; + + return ret; +} + +static OMX_ERRORTYPE SEC_DataReset(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 portIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + /* SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[portIndex]; */ + /* SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[portIndex]; */ + /* OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; */ + SEC_OMX_DATA *processData = &pSECComponent->processData[portIndex]; + + processData->dataLen = 0; + processData->remainDataLen = 0; + processData->usedDataLen = 0; + processData->nFlags = 0; + processData->timeStamp = 0; + + return ret; +} + +OMX_BOOL SEC_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_BOOL ret = OMX_FALSE; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; + SEC_OMX_DATA *inputData = &pSECComponent->processData[INPUT_PORT_INDEX]; + OMX_U32 copySize = 0; + OMX_BYTE checkInputStream = NULL; + OMX_U32 checkInputStreamLen = 0; + OMX_U32 checkedSize = 0; + OMX_BOOL flagEOS = OMX_FALSE; + OMX_BOOL flagEOF = OMX_FALSE; + OMX_BOOL previousFrameEOF = OMX_FALSE; + + if (inputUseBuffer->dataValid == OMX_TRUE) { + checkInputStream = inputUseBuffer->bufferHeader->pBuffer + inputUseBuffer->usedDataLen; + checkInputStreamLen = inputUseBuffer->remainDataLen; + + if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) && + (pSECComponent->bUseFlagEOF == OMX_FALSE)) { + pSECComponent->bUseFlagEOF = OMX_TRUE; + } + + if (inputData->dataLen == 0) { + previousFrameEOF = OMX_TRUE; + } else { + previousFrameEOF = OMX_FALSE; + } + if (pSECComponent->bUseFlagEOF == OMX_TRUE) { + flagEOF = OMX_TRUE; + checkedSize = checkInputStreamLen; + if (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) { + flagEOS = OMX_TRUE; + } + } else { + SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + int width = pSECPort->portDefinition.format.video.nFrameWidth; + int height = pSECPort->portDefinition.format.video.nFrameHeight; + int oneFrameSize = 0; + + if (pSECPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar) + oneFrameSize = (width * height * 3) / 2; + else if (pSECPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) + oneFrameSize = (width * height * 3) / 2; + else if (pSECPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV422Planar) + oneFrameSize = width * height * 2; + + if (previousFrameEOF == OMX_TRUE) { + if (checkInputStreamLen >= oneFrameSize) { + checkedSize = oneFrameSize; + flagEOF = OMX_TRUE; + } else { + flagEOF = OMX_FALSE; + } + } else { + if (checkInputStreamLen >= (oneFrameSize - inputData->dataLen)) { + checkedSize = oneFrameSize - inputData->dataLen; + flagEOF = OMX_TRUE; + } else { + flagEOF = OMX_FALSE; + } + } + + if ((flagEOF == OMX_FALSE) && (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS)) { + flagEOF = OMX_TRUE; + flagEOS = OMX_TRUE; + } + } + + if (flagEOF == OMX_TRUE) { + copySize = checkedSize; + SEC_OSAL_Log(SEC_LOG_TRACE, "sec_checkInputFrame : OMX_TRUE"); + } else { + copySize = checkInputStreamLen; + SEC_OSAL_Log(SEC_LOG_TRACE, "sec_checkInputFrame : OMX_FALSE"); + } + + if (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) + pSECComponent->bSaveFlagEOS = OMX_TRUE; + + if (((inputData->allocSize) - (inputData->dataLen)) >= copySize) { + SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + +#ifndef S5PC110_ENCODE_IN_DATA_BUFFER + if (copySize > 0) { + SEC_OSAL_Memcpy(inputData->dataBuffer + inputData->dataLen, checkInputStream, copySize); + } +#else + if (pSECPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) { + if (flagEOF == OMX_TRUE) { + OMX_U32 width, height; + + width = pSECPort->portDefinition.format.video.nFrameWidth; + height = pSECPort->portDefinition.format.video.nFrameHeight; + + SEC_OSAL_Log(SEC_LOG_TRACE, "inputData->specificBufferHeader.YVirAddr : 0x%x", inputData->specificBufferHeader.YVirAddr); + SEC_OSAL_Log(SEC_LOG_TRACE, "inputData->specificBufferHeader.CVirAddr : 0x%x", inputData->specificBufferHeader.CVirAddr); + + SEC_OSAL_Log(SEC_LOG_TRACE, "width:%d, height:%d, Ysize:%d", width, height, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height))); + SEC_OSAL_Log(SEC_LOG_TRACE, "width:%d, height:%d, Csize:%d", width, height, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2))); + + SEC_OSAL_Memcpy(inputData->specificBufferHeader.YVirAddr, checkInputStream, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height))); + SEC_OSAL_Memcpy(inputData->specificBufferHeader.CVirAddr, checkInputStream + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)), ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2))); + } + } +#endif + inputUseBuffer->dataLen -= copySize; + inputUseBuffer->remainDataLen -= copySize; + inputUseBuffer->usedDataLen += copySize; + + inputData->dataLen += copySize; + inputData->remainDataLen += copySize; + + if (previousFrameEOF == OMX_TRUE) { + inputData->timeStamp = inputUseBuffer->timeStamp; + inputData->nFlags = inputUseBuffer->nFlags; + } + + if (pSECComponent->bUseFlagEOF == OMX_TRUE) { + if (pSECComponent->bSaveFlagEOS == OMX_TRUE) { + inputData->nFlags |= OMX_BUFFERFLAG_EOS; + flagEOF = OMX_TRUE; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + } + } else { + if ((checkedSize == checkInputStreamLen) && (pSECComponent->bSaveFlagEOS == OMX_TRUE)) { + inputData->nFlags |= OMX_BUFFERFLAG_EOS; + flagEOF = OMX_TRUE; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + } else { + inputData->nFlags = (inputUseBuffer->nFlags & (~OMX_BUFFERFLAG_EOS)); + } + } + } else { + /*????????????????????????????????? Error ?????????????????????????????????*/ + SEC_DataReset(pOMXComponent, INPUT_PORT_INDEX); + flagEOF = OMX_FALSE; + } + + if (inputUseBuffer->remainDataLen == 0) { +#ifdef S5PC110_ENCODE_IN_DATA_BUFFER + if(flagEOF == OMX_FALSE) +#endif + SEC_InputBufferReturn(pOMXComponent); + } else { + inputUseBuffer->dataValid = OMX_TRUE; + } + } + + if (flagEOF == OMX_TRUE) { + if (pSECComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) { + pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_TRUE; + pSECComponent->checkTimeStamp.startTimeStamp = inputData->timeStamp; + pSECComponent->checkTimeStamp.nStartFlags = inputData->nFlags; + pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE; + } + + ret = OMX_TRUE; + } else { + ret = OMX_FALSE; + } + return ret; +} + +OMX_BOOL SEC_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_BOOL ret = OMX_FALSE; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; + SEC_OMX_DATA *outputData = &pSECComponent->processData[OUTPUT_PORT_INDEX]; + OMX_U32 copySize = 0; + + if (outputUseBuffer->dataValid == OMX_TRUE) { + if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE) { + if (pSECComponent->checkTimeStamp.startTimeStamp == outputData->timeStamp){ + pSECComponent->checkTimeStamp.startTimeStamp = -19761123; + pSECComponent->checkTimeStamp.nStartFlags = 0x0; + pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE; + pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; + } else { + SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX); + + ret = OMX_TRUE; + goto EXIT; + } + } else if (pSECComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) { + SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX); + + ret = OMX_TRUE; + goto EXIT; + } + + if (outputData->remainDataLen <= (outputUseBuffer->allocSize - outputUseBuffer->dataLen)) { + copySize = outputData->remainDataLen; + if (copySize > 0) + SEC_OSAL_Memcpy((outputUseBuffer->bufferHeader->pBuffer + outputUseBuffer->dataLen), + (outputData->dataBuffer + outputData->usedDataLen), + copySize); + + outputUseBuffer->dataLen += copySize; + outputUseBuffer->remainDataLen += copySize; + outputUseBuffer->nFlags = outputData->nFlags; + outputUseBuffer->timeStamp = outputData->timeStamp; + + ret = OMX_TRUE; + + /* reset outputData */ + SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX); + +#ifdef ONE_FRAME_OUTPUT /* only one frame output for Android */ + if ((outputUseBuffer->remainDataLen > 0) || + (outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS)) + SEC_OutputBufferReturn(pOMXComponent); +#else + if ((outputUseBuffer->remainDataLen > 0) || + ((outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) { + SEC_OutputBufferReturn(pOMXComponent); + } else { + outputUseBuffer->dataValid = OMX_TRUE; + } +#endif + } else { + SEC_OSAL_Log(SEC_LOG_ERROR, "output buffer is smaller than encoded data size Out Length"); + + copySize = outputUseBuffer->allocSize - outputUseBuffer->dataLen; + + SEC_OSAL_Memcpy((outputUseBuffer->bufferHeader->pBuffer + outputUseBuffer->dataLen), + (outputData->dataBuffer + outputData->usedDataLen), + copySize); + + outputUseBuffer->dataLen += copySize; + outputUseBuffer->remainDataLen += copySize; + outputUseBuffer->nFlags = 0; + outputUseBuffer->timeStamp = outputData->timeStamp; + + ret = OMX_FALSE; + + outputData->remainDataLen -= copySize; + outputData->usedDataLen += copySize; + + SEC_OutputBufferReturn(pOMXComponent); + } + } else { + ret = OMX_FALSE; + } + +EXIT: + return ret; +} + +OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX]; + SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX]; + SEC_OMX_DATA *inputData = &pSECComponent->processData[INPUT_PORT_INDEX]; + SEC_OMX_DATA *outputData = &pSECComponent->processData[OUTPUT_PORT_INDEX]; + OMX_U32 copySize = 0; + + pSECComponent->remainOutputData = OMX_FALSE; + pSECComponent->reInputData = OMX_FALSE; + + FunctionIn(); + + while (!pSECComponent->bExitBufferProcessThread) { + SEC_OSAL_SleepMillisec(0); + + if (((pSECComponent->currentState == OMX_StatePause) || + (pSECComponent->currentState == OMX_StateIdle) || + (pSECComponent->transientState == SEC_OMX_TransStateLoadedToIdle) || + (pSECComponent->transientState == SEC_OMX_TransStateExecutingToIdle)) && + (pSECComponent->transientState != SEC_OMX_TransStateIdleToLoaded)&& + ((!CHECK_PORT_BEING_FLUSHED(secInputPort) && !CHECK_PORT_BEING_FLUSHED(secOutputPort)))) { + SEC_OSAL_SignalReset(pSECComponent->pauseEvent); + SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME); + } + + while (SEC_Check_BufferProcess_State(pSECComponent) && !pSECComponent->bExitBufferProcessThread) { + SEC_OSAL_SleepMillisec(0); + + SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); + if ((outputUseBuffer->dataValid != OMX_TRUE) && + (!CHECK_PORT_BEING_FLUSHED(secOutputPort))) { + SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); + ret = SEC_OutputBufferGetQueue(pSECComponent); + if ((ret == OMX_ErrorUndefined) || + (secInputPort->portState != OMX_StateIdle) || + (secOutputPort->portState != OMX_StateIdle)) { + break; + } + } else { + SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); + } + + if (pSECComponent->remainOutputData == OMX_FALSE) { + if (pSECComponent->reInputData == OMX_FALSE) { + SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex); + if ((SEC_Preprocessor_InputData(pOMXComponent) == OMX_FALSE) && + (!CHECK_PORT_BEING_FLUSHED(secInputPort))) { + SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); + ret = SEC_InputBufferGetQueue(pSECComponent); + break; + } + + SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); + } + + SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex); + SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); + ret = pSECComponent->sec_mfc_bufferProcess(pOMXComponent, inputData, outputData); +#ifdef S5PC110_ENCODE_IN_DATA_BUFFER + if (inputUseBuffer->remainDataLen == 0) + SEC_InputBufferReturn(pOMXComponent); + else + inputUseBuffer->dataValid = OMX_TRUE; +#endif + SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); + SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex); + + if (ret == OMX_ErrorInputDataEncodeYet) + pSECComponent->reInputData = OMX_TRUE; + else + pSECComponent->reInputData = OMX_FALSE; + } + + SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex); + + if (SEC_Postprocess_OutputData(pOMXComponent) == OMX_FALSE) + pSECComponent->remainOutputData = OMX_TRUE; + else + pSECComponent->remainOutputData = OMX_FALSE; + + SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex); + } + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_VideoEncodeGetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nParamIndex, + OMX_INOUT OMX_PTR ComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + if (ComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + switch (nParamIndex) { + case OMX_IndexParamVideoInit: + { + OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure; + ret = SEC_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + portParam->nPorts = pSECComponent->portParam.nPorts; + portParam->nStartPortNumber = pSECComponent->portParam.nStartPortNumber; + ret = OMX_ErrorNone; + } + break; + case OMX_IndexParamVideoPortFormat: + { + OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure; + OMX_U32 portIndex = portFormat->nPortIndex; + OMX_U32 index = portFormat->nIndex; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; + OMX_U32 supportFormatNum = 0; + + ret = SEC_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if ((portIndex >= pSECComponent->portParam.nPorts)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + + if (portIndex == INPUT_PORT_INDEX) { + supportFormatNum = INPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1; + if (index > supportFormatNum) { + ret = OMX_ErrorNoMore; + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + portDefinition = &pSECPort->portDefinition; + + switch (index) { + case supportFormat_1: + portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; + portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar; + portFormat->xFramerate = portDefinition->format.video.xFramerate; + break; + case supportFormat_2: + portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; + portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; + portFormat->xFramerate = portDefinition->format.video.xFramerate; + break; + case supportFormat_3: + portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; + portFormat->eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress; + portFormat->xFramerate = portDefinition->format.video.xFramerate; + break; + } + } else if (portIndex == OUTPUT_PORT_INDEX) { + supportFormatNum = OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1; + if (index > supportFormatNum) { + ret = OMX_ErrorNoMore; + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + portDefinition = &pSECPort->portDefinition; + + portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat; + portFormat->eColorFormat = portDefinition->format.video.eColorFormat; + portFormat->xFramerate = portDefinition->format.video.xFramerate; + } + ret = OMX_ErrorNone; + } + break; + case OMX_IndexParamVideoBitrate: + { + OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure; + OMX_U32 portIndex = videoRateControl->nPortIndex; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; + + if ((portIndex != OUTPUT_PORT_INDEX)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } else { + pSECPort = &pSECComponent->pSECPort[portIndex]; + portDefinition = &pSECPort->portDefinition; + + videoRateControl->eControlRate = pSECPort->eControlRate; + videoRateControl->nTargetBitrate = portDefinition->format.video.nBitrate; + } + ret = OMX_ErrorNone; + } + break; + default: + { + ret = SEC_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure); + } + break; + } + +EXIT: + FunctionOut(); + + return ret; +} +OMX_ERRORTYPE SEC_OMX_VideoEncodeSetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR ComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + if (ComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + switch (nIndex) { + case OMX_IndexParamVideoPortFormat: + { + OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure; + OMX_U32 portIndex = portFormat->nPortIndex; + OMX_U32 index = portFormat->nIndex; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; + OMX_U32 supportFormatNum = 0; + + ret = SEC_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if ((portIndex >= pSECComponent->portParam.nPorts)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } else { + pSECPort = &pSECComponent->pSECPort[portIndex]; + portDefinition = &pSECPort->portDefinition; + + portDefinition->format.video.eColorFormat = portFormat->eColorFormat; + portDefinition->format.video.eCompressionFormat = portFormat->eCompressionFormat; + portDefinition->format.video.xFramerate = portFormat->xFramerate; + } + } + break; + case OMX_IndexParamVideoBitrate: + { + OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure; + OMX_U32 portIndex = videoRateControl->nPortIndex; + SEC_OMX_BASEPORT *pSECPort = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; + + if ((portIndex != OUTPUT_PORT_INDEX)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } else { + pSECPort = &pSECComponent->pSECPort[portIndex]; + portDefinition = &pSECPort->portDefinition; + + pSECPort->eControlRate = videoRateControl->eControlRate; + portDefinition->format.video.nBitrate = videoRateControl->nTargetBitrate; + } + ret = OMX_ErrorNone; + } + break; + case OMX_IndexParamPortDefinition: + { + OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = + (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure; + ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pPortDefinition->nPortIndex == INPUT_PORT_INDEX) { + SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + OMX_U32 width = pSECInputPort->portDefinition.format.video.nFrameWidth; + OMX_U32 height = pSECInputPort->portDefinition.format.video.nFrameHeight; + SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + pSECOutputPort->portDefinition.format.video.nFrameWidth = width; + pSECOutputPort->portDefinition.format.video.nFrameHeight = height; + pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2; + SEC_OSAL_Log(SEC_LOG_TRACE, "pSECOutputPort->portDefinition.nBufferSize: %d", + pSECOutputPort->portDefinition.nBufferSize); + } + } + break; + default: + { + ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure); + } + break; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_VideoEncodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); + goto EXIT; + } + + ret = SEC_OMX_BaseComponent_Constructor(pOMXComponent); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); + goto EXIT; + } + + ret = SEC_OMX_Port_Constructor(pOMXComponent); + if (ret != OMX_ErrorNone) { + SEC_OMX_BaseComponent_Destructor(pOMXComponent); + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + + /* Input port */ + pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + pSECPort->portDefinition.nBufferCountActual = MAX_VIDEO_INPUTBUFFER_NUM; + pSECPort->portDefinition.nBufferCountMin = MAX_VIDEO_INPUTBUFFER_NUM; + pSECPort->portDefinition.nBufferSize = 0; + pSECPort->portDefinition.eDomain = OMX_PortDomainVideo; + + pSECPort->portDefinition.format.video.cMIMEType = SEC_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); + pSECPort->portDefinition.format.video.pNativeRender = 0; + pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; + + pSECPort->portDefinition.format.video.nFrameWidth = 0; + pSECPort->portDefinition.format.video.nFrameHeight= 0; + pSECPort->portDefinition.format.video.nStride = 0; + pSECPort->portDefinition.format.video.nSliceHeight = 0; + pSECPort->portDefinition.format.video.nBitrate = 64000; + pSECPort->portDefinition.format.video.xFramerate = (15 << 16); + pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; + pSECPort->portDefinition.format.video.pNativeWindow = NULL; + + /* Output port */ + pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + pSECPort->portDefinition.nBufferCountActual = MAX_VIDEO_OUTPUTBUFFER_NUM; + pSECPort->portDefinition.nBufferCountMin = MAX_VIDEO_OUTPUTBUFFER_NUM; + pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; + pSECPort->portDefinition.eDomain = OMX_PortDomainVideo; + + pSECPort->portDefinition.format.video.cMIMEType = SEC_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); + pSECPort->portDefinition.format.video.pNativeRender = 0; + pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; + + pSECPort->portDefinition.format.video.nFrameWidth = 0; + pSECPort->portDefinition.format.video.nFrameHeight= 0; + pSECPort->portDefinition.format.video.nStride = 0; + pSECPort->portDefinition.format.video.nSliceHeight = 0; + pSECPort->portDefinition.format.video.nBitrate = 64000; + pSECPort->portDefinition.format.video.xFramerate = (15 << 16); + pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; + pSECPort->portDefinition.format.video.pNativeWindow = NULL; + + pOMXComponent->UseBuffer = &SEC_OMX_UseBuffer; + pOMXComponent->AllocateBuffer = &SEC_OMX_AllocateBuffer; + pOMXComponent->FreeBuffer = &SEC_OMX_FreeBuffer; + pOMXComponent->ComponentTunnelRequest = &SEC_OMX_ComponentTunnelRequest; + + pSECComponent->sec_AllocateTunnelBuffer = &SEC_OMX_AllocateTunnelBuffer; + pSECComponent->sec_FreeTunnelBuffer = &SEC_OMX_FreeTunnelBuffer; + pSECComponent->sec_BufferProcess = &SEC_OMX_BufferProcess; + pSECComponent->sec_BufferReset = &SEC_BufferReset; + pSECComponent->sec_InputBufferReturn = &SEC_InputBufferReturn; + pSECComponent->sec_OutputBufferReturn = &SEC_OutputBufferReturn; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_VideoEncodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + int i = 0; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + for(i = 0; i < ALL_PORT_NUM; i++) { + pSECPort = &pSECComponent->pSECPort[i]; + SEC_OSAL_Free(pSECPort->portDefinition.format.video.cMIMEType); + pSECPort->portDefinition.format.video.cMIMEType = NULL; + } + + ret = SEC_OMX_Port_Destructor(pOMXComponent); + + ret = SEC_OMX_BaseComponent_Destructor(hComponent); + +EXIT: + FunctionOut(); + + return ret; +} diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.h b/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.h new file mode 100644 index 0000000..93d2800 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.h @@ -0,0 +1,106 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Venc.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_VIDEO_ENCODE +#define SEC_OMX_VIDEO_ENCODE + +#include "OMX_Component.h" +#include "SEC_OMX_Def.h" +#include "SEC_OSAL_Queue.h" +#include "SEC_OMX_Baseport.h" + +#define MAX_VIDEO_INPUTBUFFER_NUM 5 +#define MAX_VIDEO_OUTPUTBUFFER_NUM 4 + +#define DEFAULT_FRAME_WIDTH 176 +#define DEFAULT_FRAME_HEIGHT 144 + +#define DEFAULT_VIDEO_INPUT_BUFFER_SIZE ALIGN_TO_8KB(ALIGN_TO_128B(DEFAULT_FRAME_WIDTH) * ALIGN_TO_32B(DEFAULT_FRAME_HEIGHT)) \ + + ALIGN_TO_8KB(ALIGN_TO_128B(DEFAULT_FRAME_WIDTH) * ALIGN_TO_32B(DEFAULT_FRAME_HEIGHT / 2)) + /* (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2 */ +#define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE DEFAULT_VIDEO_INPUT_BUFFER_SIZE + +#define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 3 +#define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX 1 + + +typedef struct +{ + void *pAddrY; + void *pAddrC; +} MFC_ENC_ADDR_INFO; + + +#ifdef __cplusplus +extern "C" { +#endif + +OMX_ERRORTYPE SEC_OMX_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 SEC_OMX_AllocateBuffer( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer, + OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_PTR pAppPrivate, + OMX_IN OMX_U32 nSizeBytes); +OMX_ERRORTYPE SEC_OMX_FreeBuffer( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr); +OMX_ERRORTYPE SEC_OMX_AllocateTunnelBuffer( + SEC_OMX_BASEPORT *pOMXBasePort, + OMX_U32 nPortIndex); +OMX_ERRORTYPE SEC_OMX_FreeTunnelBuffer( + SEC_OMX_BASEPORT *pOMXBasePort, + OMX_U32 nPortIndex); +OMX_ERRORTYPE SEC_OMX_ComponentTunnelRequest( + OMX_IN OMX_HANDLETYPE hComp, + OMX_IN OMX_U32 nPort, + OMX_IN OMX_HANDLETYPE hTunneledComp, + OMX_IN OMX_U32 nTunneledPort, + OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup); +OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent); +OMX_ERRORTYPE SEC_OMX_VideoEncodeGetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nParamIndex, + OMX_INOUT OMX_PTR ComponentParameterStructure); +OMX_ERRORTYPE SEC_OMX_VideoEncodeSetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR ComponentParameterStructure); +OMX_ERRORTYPE SEC_OMX_VideoEncodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk new file mode 100644 index 0000000..0a469d4 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk @@ -0,0 +1,29 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := \ + SEC_OMX_H264enc.c \ + library_register.c + +LOCAL_PRELINK_MODULE := false +LOCAL_MODULE := libOMX.SEC.AVC.Encoder.aries + +LOCAL_CFLAGS := + +LOCAL_ARM_MODE := arm + +LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc.aries libsecosal.aries libsecbasecomponent.aries libsecmfcencapi.aries +LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils + +LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ + $(SEC_OMX_INC)/sec \ + $(SEC_OMX_TOP)/sec_osal \ + $(SEC_OMX_TOP)/sec_omx_core \ + $(SEC_OMX_COMPONENT)/common \ + $(SEC_OMX_COMPONENT)/video/enc \ + +LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include + +include $(BUILD_SHARED_LIBRARY) diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c new file mode 100644 index 0000000..239649e --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c @@ -0,0 +1,1029 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_H264enc.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include + +#include "SEC_OMX_Macros.h" +#include "SEC_OMX_Basecomponent.h" +#include "SEC_OMX_Baseport.h" +#include "SEC_OMX_Venc.h" +#include "library_register.h" +#include "SEC_OMX_H264enc.h" +#include "SsbSipMfcApi.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_H264_ENC" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +/* H.264 Encoder Supported Levels & profiles */ +SEC_OMX_VIDEO_PROFILELEVEL supportedAVCProfileLevels[] ={ + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1b}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel11}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel12}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel2}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel21}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel22}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel3}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel31}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel32}, + {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4}, + + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1b}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel11}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel12}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel13}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel2}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel21}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel22}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel3}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel31}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel32}, + {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel4}, + + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1b}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel11}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel12}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel13}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel2}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel21}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel22}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel3}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel31}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel32}, + {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4}}; + + +OMX_U32 OMXAVCProfileToProfileIDC(OMX_VIDEO_AVCPROFILETYPE profile) +{ + OMX_U32 ret = 0; //default OMX_VIDEO_AVCProfileMain + + if (profile == OMX_VIDEO_AVCProfileMain) + ret = 0; + else if (profile == OMX_VIDEO_AVCProfileHigh) + ret = 1; + else if (profile == OMX_VIDEO_AVCProfileBaseline) + ret = 2; + + return ret; +} + +OMX_U32 OMXAVCLevelToLevelIDC(OMX_VIDEO_AVCLEVELTYPE level) +{ + OMX_U32 ret = 40; //default OMX_VIDEO_AVCLevel4 + + if (level == OMX_VIDEO_AVCLevel1) + ret = 10; + else if (level == OMX_VIDEO_AVCLevel1b) + ret = 9; + else if (level == OMX_VIDEO_AVCLevel11) + ret = 11; + else if (level == OMX_VIDEO_AVCLevel12) + ret = 12; + else if (level == OMX_VIDEO_AVCLevel13) + ret = 13; + else if (level == OMX_VIDEO_AVCLevel2) + ret = 20; + else if (level == OMX_VIDEO_AVCLevel21) + ret = 21; + else if (level == OMX_VIDEO_AVCLevel22) + ret = 22; + else if (level == OMX_VIDEO_AVCLevel3) + ret = 30; + else if (level == OMX_VIDEO_AVCLevel31) + ret = 31; + else if (level == OMX_VIDEO_AVCLevel32) + ret = 32; + else if (level == OMX_VIDEO_AVCLevel4) + ret = 40; + + return ret; +} + +OMX_U8 *FindDelimiter(OMX_U8 *pBuffer, OMX_U32 size) +{ + int i; + + for (i = 0; i < size - 3; i++) { + if ((pBuffer[i] == 0x00) && + (pBuffer[i+1] == 0x00) && + (pBuffer[i+2] == 0x00) && + (pBuffer[i+3] == 0x01)) + return (pBuffer + i); + } + + return NULL; +} + +void H264PrintParams(SSBSIP_MFC_ENC_H264_PARAM h264Arg) +{ + SEC_OSAL_Log(SEC_LOG_TRACE, "SourceWidth : %d\n", h264Arg.SourceWidth); + SEC_OSAL_Log(SEC_LOG_TRACE, "SourceHeight : %d\n", h264Arg.SourceHeight); + SEC_OSAL_Log(SEC_LOG_TRACE, "ProfileIDC : %d\n", h264Arg.ProfileIDC); + SEC_OSAL_Log(SEC_LOG_TRACE, "LevelIDC : %d\n", h264Arg.LevelIDC); + SEC_OSAL_Log(SEC_LOG_TRACE, "IDRPeriod : %d\n", h264Arg.IDRPeriod); + SEC_OSAL_Log(SEC_LOG_TRACE, "NumberReferenceFrames : %d\n", h264Arg.NumberReferenceFrames); + SEC_OSAL_Log(SEC_LOG_TRACE, "NumberRefForPframes : %d\n", h264Arg.NumberRefForPframes); + SEC_OSAL_Log(SEC_LOG_TRACE, "SliceMode : %d\n", h264Arg.SliceMode); + SEC_OSAL_Log(SEC_LOG_TRACE, "SliceArgument : %d\n", h264Arg.SliceArgument); + SEC_OSAL_Log(SEC_LOG_TRACE, "NumberBFrames : %d\n", h264Arg.NumberBFrames); + SEC_OSAL_Log(SEC_LOG_TRACE, "LoopFilterDisable : %d\n", h264Arg.LoopFilterDisable); + SEC_OSAL_Log(SEC_LOG_TRACE, "LoopFilterAlphaC0Offset : %d\n", h264Arg.LoopFilterAlphaC0Offset); + SEC_OSAL_Log(SEC_LOG_TRACE, "LoopFilterBetaOffset : %d\n", h264Arg.LoopFilterBetaOffset); + SEC_OSAL_Log(SEC_LOG_TRACE, "SymbolMode : %d\n", h264Arg.SymbolMode); + SEC_OSAL_Log(SEC_LOG_TRACE, "PictureInterlace : %d\n", h264Arg.PictureInterlace); + SEC_OSAL_Log(SEC_LOG_TRACE, "Transform8x8Mode : %d\n", h264Arg.Transform8x8Mode); + SEC_OSAL_Log(SEC_LOG_TRACE, "RandomIntraMBRefresh : %d\n", h264Arg.RandomIntraMBRefresh); + SEC_OSAL_Log(SEC_LOG_TRACE, "PadControlOn : %d\n", h264Arg.PadControlOn); + SEC_OSAL_Log(SEC_LOG_TRACE, "LumaPadVal : %d\n", h264Arg.LumaPadVal); + SEC_OSAL_Log(SEC_LOG_TRACE, "CbPadVal : %d\n", h264Arg.CbPadVal); + SEC_OSAL_Log(SEC_LOG_TRACE, "CrPadVal : %d\n", h264Arg.CrPadVal); + SEC_OSAL_Log(SEC_LOG_TRACE, "EnableFRMRateControl : %d\n", h264Arg.EnableFRMRateControl); + SEC_OSAL_Log(SEC_LOG_TRACE, "EnableMBRateControl : %d\n", h264Arg.EnableMBRateControl); + SEC_OSAL_Log(SEC_LOG_TRACE, "FrameRate : %d\n", h264Arg.FrameRate); + SEC_OSAL_Log(SEC_LOG_TRACE, "Bitrate : %d\n", h264Arg.Bitrate); + SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp : %d\n", h264Arg.FrameQp); + SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMax : %d\n", h264Arg.QSCodeMax); + SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMin : %d\n", h264Arg.QSCodeMin); + SEC_OSAL_Log(SEC_LOG_TRACE, "CBRPeriodRf : %d\n", h264Arg.CBRPeriodRf); + SEC_OSAL_Log(SEC_LOG_TRACE, "DarkDisable : %d\n", h264Arg.DarkDisable); + SEC_OSAL_Log(SEC_LOG_TRACE, "SmoothDisable : %d\n", h264Arg.SmoothDisable); + SEC_OSAL_Log(SEC_LOG_TRACE, "StaticDisable : %d\n", h264Arg.StaticDisable); + SEC_OSAL_Log(SEC_LOG_TRACE, "ActivityDisable : %d\n", h264Arg.ActivityDisable); +} + +void Set_H264ENC_Param(SSBSIP_MFC_ENC_H264_PARAM *pH264Arg, SEC_OMX_BASECOMPONENT *pSECComponent) +{ + SEC_OMX_BASEPORT *pSECInputPort = NULL; + SEC_OMX_BASEPORT *pSECOutputPort = NULL; + SEC_H264ENC_HANDLE *pH264Enc = NULL; + + pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; + pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + + pH264Arg->codecType = H264_ENC; + pH264Arg->SourceWidth = pSECOutputPort->portDefinition.format.video.nFrameWidth; + pH264Arg->SourceHeight = pSECOutputPort->portDefinition.format.video.nFrameHeight; + pH264Arg->IDRPeriod = pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames + 1; + pH264Arg->SliceMode = 0; + pH264Arg->RandomIntraMBRefresh = 0; + pH264Arg->EnableFRMRateControl = 1; // 0: Disable, 1: Frame level RC + pH264Arg->Bitrate = pSECOutputPort->portDefinition.format.video.nBitrate; + pH264Arg->FrameQp = 20; + pH264Arg->FrameQp_P = 20; + pH264Arg->QSCodeMax = 30; + pH264Arg->QSCodeMin = 10; + pH264Arg->CBRPeriodRf = 100; + pH264Arg->PadControlOn = 0; // 0: disable, 1: enable + pH264Arg->LumaPadVal = 0; + pH264Arg->CbPadVal = 0; + pH264Arg->CrPadVal = 0; + + pH264Arg->ProfileIDC = OMXAVCProfileToProfileIDC(pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].eProfile); //0; //(OMX_VIDEO_AVCProfileMain) + pH264Arg->LevelIDC = OMXAVCLevelToLevelIDC(pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].eLevel); //40; //(OMX_VIDEO_AVCLevel4) + pH264Arg->FrameQp_B = 20; + pH264Arg->FrameRate = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16; + pH264Arg->SliceArgument = 0; // Slice mb/byte size number + pH264Arg->NumberBFrames = 0; // 0 ~ 2 + pH264Arg->NumberReferenceFrames = 1; + pH264Arg->NumberRefForPframes = 1; + pH264Arg->LoopFilterDisable = 1; // 1: Loop Filter Disable, 0: Filter Enable + pH264Arg->LoopFilterAlphaC0Offset = 0; + pH264Arg->LoopFilterBetaOffset = 0; + pH264Arg->SymbolMode = 0; // 0: CAVLC, 1: CABAC + pH264Arg->PictureInterlace = 0; + pH264Arg->Transform8x8Mode = 0; // 0: 4x4, 1: allow 8x8 + pH264Arg->EnableMBRateControl = 0; // 0: Disable, 1:MB level RC + pH264Arg->DarkDisable = 1; + pH264Arg->SmoothDisable = 1; + pH264Arg->StaticDisable = 1; + pH264Arg->ActivityDisable = 1; + + SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->eControlRate: 0x%x", pSECOutputPort->eControlRate); + switch (pSECOutputPort->eControlRate) { + case OMX_Video_ControlRateDisable: + /* TBD */ + break; + case OMX_Video_ControlRateVariable: + /* TBD */ + break; + default: + break; + } + + H264PrintParams(*pH264Arg); +} + +OMX_ERRORTYPE SEC_MFC_H264Enc_GetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nParamIndex, + OMX_INOUT OMX_PTR pComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL || pComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + switch (nParamIndex) { + case OMX_IndexParamVideoAvc: + { + OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL; + SEC_H264ENC_HANDLE *pH264Enc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pDstAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstAVCComponent->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; + pSrcAVCComponent = &pH264Enc->AVCComponent[pDstAVCComponent->nPortIndex]; + + SEC_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); + } + break; + case OMX_IndexParamStandardComponentRole: + { + OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure; + ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_H264_ENC_ROLE); + } + break; + case OMX_IndexParamVideoProfileLevelQuerySupported: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure; + SEC_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL; + OMX_U32 maxProfileLevelNum = 0; + + ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pProfileLevel = supportedAVCProfileLevels; + maxProfileLevelNum = sizeof(supportedAVCProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL); + + if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) { + ret = OMX_ErrorNoMore; + goto EXIT; + } + + pProfileLevel += pDstProfileLevel->nProfileIndex; + pDstProfileLevel->eProfile = pProfileLevel->profile; + pDstProfileLevel->eLevel = pProfileLevel->level; + } + break; + case OMX_IndexParamVideoProfileLevelCurrent: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure; + OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL; + SEC_H264ENC_HANDLE *pH264Enc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; + pSrcAVCComponent = &pH264Enc->AVCComponent[pDstProfileLevel->nPortIndex]; + + pDstProfileLevel->eProfile = pSrcAVCComponent->eProfile; + pDstProfileLevel->eLevel = pSrcAVCComponent->eLevel; + } + break; + case OMX_IndexParamVideoErrorCorrection: + { + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; + SEC_H264ENC_HANDLE *pH264Enc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; + pSrcErrorCorrectionType = &pH264Enc->errorCorrectionType[OUTPUT_PORT_INDEX]; + + pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; + pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; + pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; + pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; + pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; + } + break; + default: + ret = SEC_OMX_VideoEncodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); + break; + } +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_H264Enc_SetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR pComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL || pComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + switch (nIndex) { + case OMX_IndexParamVideoAvc: + { + OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL; + OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure; + SEC_H264ENC_HANDLE *pH264Enc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcAVCComponent->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; + pDstAVCComponent = &pH264Enc->AVCComponent[pSrcAVCComponent->nPortIndex]; + + SEC_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); + } + break; + case OMX_IndexParamStandardComponentRole: + { + OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; + + ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + + if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_H264_ENC_ROLE)) { + pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; + } else { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + } + break; + case OMX_IndexParamVideoProfileLevelCurrent: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL; + SEC_H264ENC_HANDLE *pH264Enc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; + + pDstAVCComponent = &pH264Enc->AVCComponent[pSrcProfileLevel->nPortIndex]; + pDstAVCComponent->eProfile = pSrcProfileLevel->eProfile; + pDstAVCComponent->eLevel = pSrcProfileLevel->eLevel; + } + break; + case OMX_IndexParamVideoErrorCorrection: + { + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; + SEC_H264ENC_HANDLE *pH264Enc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; + pDstErrorCorrectionType = &pH264Enc->errorCorrectionType[OUTPUT_PORT_INDEX]; + + pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; + pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; + pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; + pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; + pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; + } + break; + default: + ret = SEC_OMX_VideoEncodeSetParameter(hComponent, nIndex, pComponentParameterStructure); + break; + } +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_H264Enc_SetConfig( + OMX_HANDLETYPE hComponent, + OMX_INDEXTYPE nIndex, + OMX_PTR pComponentConfigStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL || pComponentConfigStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + switch (nIndex) { + default: + ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure); + break; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_H264Enc_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if ((hComponent == NULL) || (cRole == NULL)) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (nIndex == (MAX_COMPONENT_ROLE_NUM-1)) { + SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_H264_ENC_ROLE); + ret = OMX_ErrorNone; + } else { + ret = OMX_ErrorNoMore; + } + +EXIT: + FunctionOut(); + + return ret; +} + +/* MFC Init */ +OMX_ERRORTYPE SEC_MFC_H264Enc_Init(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_H264ENC_HANDLE *pH264Enc = NULL; + OMX_PTR hMFCHandle = NULL; + OMX_S32 returnCodec = 0; + + FunctionIn(); + + pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; + pH264Enc->hMFCH264Handle.bConfiguredMFC = OMX_FALSE; + pSECComponent->bUseFlagEOF = OMX_FALSE; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + + /* MFC(Multi Function Codec) encoder and CMM(Codec Memory Management) driver open */ + hMFCHandle = (OMX_PTR)SsbSipMfcEncOpen(); + if (hMFCHandle == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + pH264Enc->hMFCH264Handle.hMFCHandle = hMFCHandle; + + Set_H264ENC_Param(&(pH264Enc->hMFCH264Handle.mfcVideoAvc), pSECComponent); + + returnCodec = SsbSipMfcEncInit(hMFCHandle, &(pH264Enc->hMFCH264Handle.mfcVideoAvc)); + if (returnCodec != MFC_RET_OK) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + + /* Allocate encoder's input buffer */ + returnCodec = SsbSipMfcEncGetInBuf(hMFCHandle, &(pH264Enc->hMFCH264Handle.inputInfo)); + if (returnCodec != MFC_RET_OK) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + + SEC_OSAL_Log(SEC_LOG_TRACE, "pH264Enc->hMFCH264Handle.inputInfo.YVirAddr : 0x%x", pH264Enc->hMFCH264Handle.inputInfo.YVirAddr); + SEC_OSAL_Log(SEC_LOG_TRACE, "pH264Enc->hMFCH264Handle.inputInfo.CVirAddr : 0x%x", pH264Enc->hMFCH264Handle.inputInfo.CVirAddr); + + pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YPhyAddr = pH264Enc->hMFCH264Handle.inputInfo.YPhyAddr; + pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CPhyAddr = pH264Enc->hMFCH264Handle.inputInfo.CPhyAddr; + pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YVirAddr = pH264Enc->hMFCH264Handle.inputInfo.YVirAddr; + pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CVirAddr = pH264Enc->hMFCH264Handle.inputInfo.CVirAddr; + pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YSize = pH264Enc->hMFCH264Handle.inputInfo.YSize; + pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CSize = pH264Enc->hMFCH264Handle.inputInfo.CSize; + + SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); + SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); + pH264Enc->hMFCH264Handle.indexTimestamp = 0; + +EXIT: + FunctionOut(); + + return ret; +} + +/* MFC Terminate */ +OMX_ERRORTYPE SEC_MFC_H264Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_H264ENC_HANDLE *pH264Enc = NULL; + OMX_PTR hMFCHandle = NULL; + + FunctionIn(); + + pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; + hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; + + if (hMFCHandle != NULL) { + SsbSipMfcEncClose(hMFCHandle); + hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle = NULL; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_H264_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_H264ENC_HANDLE *pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; + SSBSIP_MFC_ENC_INPUT_INFO *pInputInfo = &pH264Enc->hMFCH264Handle.inputInfo; + SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo; + SEC_OMX_BASEPORT *pSECPort = NULL; + MFC_ENC_ADDR_INFO addrInfo; + OMX_U32 oneFrameSize = pInputData->dataLen; + OMX_S32 returnCodec = 0; + + FunctionIn(); + + if (pH264Enc->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) { + returnCodec = SsbSipMfcEncGetOutBuf(pH264Enc->hMFCH264Handle.hMFCHandle, &outputInfo); + if (returnCodec != MFC_RET_OK) + { + SEC_OSAL_Log(SEC_LOG_TRACE, "%s - SsbSipMfcEncGetOutBuf Failed\n", __func__); + ret = OMX_ErrorUndefined; + goto EXIT; + } else { + char *p = NULL; + int iSpsSize = 0; + int iPpsSize = 0; + + p = FindDelimiter((OMX_U8 *)outputInfo.StrmVirAddr + 4, outputInfo.headerSize - 4); + + iSpsSize = (unsigned int)p - (unsigned int)outputInfo.StrmVirAddr; + pH264Enc->hMFCH264Handle.headerData.pHeaderSPS = (OMX_PTR)outputInfo.StrmVirAddr; + pH264Enc->hMFCH264Handle.headerData.SPSLen = iSpsSize; + + iPpsSize = outputInfo.headerSize - iSpsSize; + pH264Enc->hMFCH264Handle.headerData.pHeaderPPS = outputInfo.StrmVirAddr + iSpsSize; + pH264Enc->hMFCH264Handle.headerData.PPSLen = iPpsSize; + } + + /* SEC_OSAL_Memcpy((void*)(pOutputData->dataBuffer), (const void*)(outputInfo.StrmVirAddr), outputInfo.headerSize); */ + pOutputData->dataBuffer = outputInfo.StrmVirAddr; + pOutputData->allocSize = outputInfo.headerSize; + pOutputData->dataLen = outputInfo.headerSize; + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG; + pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; + + pH264Enc->hMFCH264Handle.bConfiguredMFC = OMX_TRUE; + + ret = OMX_ErrorNone; + goto EXIT; + } + + if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) && + (pSECComponent->bUseFlagEOF == OMX_FALSE)) { + pSECComponent->bUseFlagEOF = OMX_TRUE; + } + + pSECComponent->timeStamp[pH264Enc->hMFCH264Handle.indexTimestamp] = pInputData->timeStamp; + pSECComponent->nFlags[pH264Enc->hMFCH264Handle.indexTimestamp] = pInputData->nFlags; + SsbSipMfcEncSetConfig(pH264Enc->hMFCH264Handle.hMFCHandle, MFC_ENC_SETCONF_FRAME_TAG, &(pH264Enc->hMFCH264Handle.indexTimestamp)); + pH264Enc->hMFCH264Handle.indexTimestamp++; + if (pH264Enc->hMFCH264Handle.indexTimestamp >= MAX_TIMESTAMP) + pH264Enc->hMFCH264Handle.indexTimestamp = 0; + + if (oneFrameSize <= 0) { + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + + ret = OMX_ErrorNone; + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + if (pSECPort->portDefinition.format.video.eColorFormat == SEC_OMX_COLOR_FormatNV12PhysicalAddress) { +#define USE_FIMC_FRAME_BUFFER +#ifdef USE_FIMC_FRAME_BUFFER + SEC_OSAL_Memcpy(&addrInfo.pAddrY, pInputData->dataBuffer, sizeof(addrInfo.pAddrY)); + SEC_OSAL_Memcpy(&addrInfo.pAddrC, pInputData->dataBuffer + sizeof(addrInfo.pAddrY), sizeof(addrInfo.pAddrC)); + pInputInfo->YPhyAddr = addrInfo.pAddrY; + pInputInfo->CPhyAddr = addrInfo.pAddrC; + ret = SsbSipMfcEncSetInBuf(pH264Enc->hMFCH264Handle.hMFCHandle, pInputInfo); + if (ret != MFC_RET_OK) { + SEC_OSAL_Log(SEC_LOG_TRACE, "Error : SsbSipMfcEncSetInBuf() \n"); + ret = OMX_ErrorUndefined; + goto EXIT; + } +#else + OMX_U32 width, height; + + width = pSECPort->portDefinition.format.video.nFrameWidth; + height = pSECPort->portDefinition.format.video.nFrameHeight; + + SEC_OSAL_Memcpy(pInputInfo->YVirAddr, pInputData->dataBuffer, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height))); + SEC_OSAL_Memcpy(pInputInfo->CVirAddr, pInputData->dataBuffer + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)), ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2))); +#endif + } + + returnCodec = SsbSipMfcEncExe(pH264Enc->hMFCH264Handle.hMFCHandle); + if (returnCodec == MFC_RET_OK) { + OMX_S32 indexTimestamp = 0; + + returnCodec = SsbSipMfcEncGetOutBuf(pH264Enc->hMFCH264Handle.hMFCHandle, &outputInfo); + if ((SsbSipMfcEncGetConfig(pH264Enc->hMFCH264Handle.hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) || + (((indexTimestamp < 0) || (indexTimestamp > MAX_TIMESTAMP)))){ + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + } else { + pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp]; + pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp]; + } + + if (returnCodec == MFC_RET_OK) { + /** Fill Output Buffer **/ + pOutputData->dataBuffer = outputInfo.StrmVirAddr; + pOutputData->allocSize = outputInfo.dataSize; + pOutputData->dataLen = outputInfo.dataSize; + pOutputData->usedDataLen = 0; + + pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; + if (outputInfo.frameType == MFC_FRAME_TYPE_I_FRAME) + pOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; + + SEC_OSAL_Log(SEC_LOG_TRACE, "MFC Encode OK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); + + ret = OMX_ErrorNone; + } + } + + if (returnCodec != MFC_RET_OK) { + SEC_OSAL_Log(SEC_LOG_ERROR, "In %s : SsbSipMfcEncExe OR SsbSipMfcEncGetOutBuf Failed!!!\n", __func__); + ret = OMX_ErrorUndefined; + } + +EXIT: + FunctionOut(); + + return ret; +} + +/* MFC Encode */ +OMX_ERRORTYPE SEC_MFC_H264Enc_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_H264ENC_HANDLE *pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; + SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + OMX_BOOL endOfFrame = OMX_FALSE; + OMX_BOOL flagEOS = OMX_FALSE; + + FunctionIn(); + + if ((!CHECK_PORT_ENABLED(pSECInputPort)) || (!CHECK_PORT_ENABLED(pSECOutputPort)) || + (!CHECK_PORT_POPULATED(pSECInputPort)) || (!CHECK_PORT_POPULATED(pSECOutputPort))) { + ret = OMX_ErrorNone; + goto EXIT; + } + if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) { + ret = OMX_ErrorNone; + goto EXIT; + } + + ret = SEC_MFC_H264_Encode(pOMXComponent, pInputData, pOutputData); + if (ret != OMX_ErrorNone) { + pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, + pSECComponent->callbackData, + OMX_EventError, ret, 0, NULL); + } else { + pInputData->usedDataLen += pInputData->dataLen; + pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen; + pInputData->dataLen -= pInputData->usedDataLen; + pInputData->usedDataLen = 0; + + /* pOutputData->usedDataLen = 0; */ + pOutputData->remainDataLen = pOutputData->dataLen - pOutputData->usedDataLen; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + SEC_H264ENC_HANDLE *pH264Enc = NULL; + int i = 0; + + FunctionIn(); + + if ((hComponent == NULL) || (componentName == NULL)) { + ret = OMX_ErrorBadParameter; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); + goto EXIT; + } + if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_H264_ENC, componentName) != 0) { + ret = OMX_ErrorBadParameter; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__); + goto EXIT; + } + + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_VideoEncodeComponentInit(pOMXComponent); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pSECComponent->codecType = HW_VIDEO_CODEC; + + pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); + if (pSECComponent->componentName == NULL) { + SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent); + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); + goto EXIT; + } + SEC_OSAL_Memset(pSECComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); + + pH264Enc = SEC_OSAL_Malloc(sizeof(SEC_H264ENC_HANDLE)); + if (pH264Enc == NULL) { + SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent); + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); + goto EXIT; + } + SEC_OSAL_Memset(pH264Enc, 0, sizeof(SEC_H264ENC_HANDLE)); + pSECComponent->hCodecHandle = (OMX_HANDLETYPE)pH264Enc; + + SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_H264_ENC); + /* Set componentVersion */ + pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; + pSECComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; + pSECComponent->componentVersion.s.nRevision = REVISION_NUMBER; + pSECComponent->componentVersion.s.nStep = STEP_NUMBER; + /* Set specVersion */ + pSECComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; + pSECComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; + pSECComponent->specVersion.s.nRevision = REVISION_NUMBER; + pSECComponent->specVersion.s.nStep = STEP_NUMBER; + + /* Android CapabilityFlags */ + pSECComponent->capabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_FALSE; + pSECComponent->capabilityFlags.iOMXComponentSupportsPartialFrames = OMX_FALSE; + pSECComponent->capabilityFlags.iOMXComponentUsesNALStartCodes = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentUsesFullAVCFrames = OMX_TRUE; + + /* Input port */ + pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; + pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; + pSECPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ + pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; + SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); + pSECPort->portDefinition.format.video.eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress; + pSECPort->portDefinition.bEnabled = OMX_TRUE; + + /* Output port */ + pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; + pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; + pSECPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ + pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; + SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/avc"); + pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; + pSECPort->portDefinition.bEnabled = OMX_TRUE; + + for(i = 0; i < ALL_PORT_NUM; i++) { + INIT_SET_SIZE_VERSION(&pH264Enc->AVCComponent[i], OMX_VIDEO_PARAM_AVCTYPE); + pH264Enc->AVCComponent[i].nPortIndex = i; + pH264Enc->AVCComponent[i].eProfile = OMX_VIDEO_AVCProfileBaseline; + pH264Enc->AVCComponent[i].eLevel = OMX_VIDEO_AVCLevel31; + } + + pOMXComponent->GetParameter = &SEC_MFC_H264Enc_GetParameter; + pOMXComponent->SetParameter = &SEC_MFC_H264Enc_SetParameter; + pOMXComponent->SetConfig = &SEC_MFC_H264Enc_SetConfig; + pOMXComponent->ComponentRoleEnum = &SEC_MFC_H264Enc_ComponentRoleEnum; + pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit; + + pSECComponent->sec_mfc_componentInit = &SEC_MFC_H264Enc_Init; + pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_H264Enc_Terminate; + pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_H264Enc_bufferProcess; + pSECComponent->sec_checkInputFrame = NULL; + + pSECComponent->currentState = OMX_StateLoaded; + + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_H264ENC_HANDLE *pH264Dec = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + SEC_OSAL_Free(pSECComponent->componentName); + pSECComponent->componentName = NULL; + + pH264Dec = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle; + if (pH264Dec != NULL) { + SEC_OSAL_Free(pH264Dec); + pH264Dec = pSECComponent->hCodecHandle = NULL; + } + + ret = SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.h b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.h new file mode 100644 index 0000000..80f6260 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.h @@ -0,0 +1,76 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_H264enc.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_H264_ENC_COMPONENT +#define SEC_OMX_H264_ENC_COMPONENT + +#include "SEC_OMX_Def.h" +#include "OMX_Component.h" +#include "OMX_Video.h" +#include "SsbSipMfcApi.h" + + +typedef struct _EXTRA_DATA +{ + OMX_PTR pHeaderSPS; + OMX_U32 SPSLen; + OMX_PTR pHeaderPPS; + OMX_U32 PPSLen; +} EXTRA_DATA; + +typedef struct _SEC_MFC_H264ENC_HANDLE +{ + OMX_HANDLETYPE hMFCHandle; + SSBSIP_MFC_ENC_H264_PARAM mfcVideoAvc; + SSBSIP_MFC_ENC_INPUT_INFO inputInfo; +/* SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo; */ + OMX_U32 indexTimestamp; + OMX_BOOL bConfiguredMFC; + EXTRA_DATA headerData; +} SEC_MFC_H264ENC_HANDLE; + +typedef struct _SEC_H264ENC_HANDLE +{ + /* OMX Codec specific */ + OMX_VIDEO_PARAM_AVCTYPE AVCComponent[ALL_PORT_NUM]; + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE errorCorrectionType[ALL_PORT_NUM]; + + /* SEC MFC Codec specific */ + SEC_MFC_H264ENC_HANDLE hMFCH264Handle; +} SEC_H264ENC_HANDLE; + +#ifdef __cplusplus +extern "C" { +#endif + +OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName); +OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent); + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c new file mode 100644 index 0000000..ee1ea0a --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c @@ -0,0 +1,55 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 library_register.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include +#include + +#include "SEC_OSAL_Memory.h" +#include "SEC_OSAL_ETC.h" +#include "library_register.h" +#include "SEC_OSAL_Log.h" + + +OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents) +{ + FunctionIn(); + + if (secComponents == NULL) + goto EXIT; + + /* component 1 - video decoder H.264 */ + SEC_OSAL_Strcpy(secComponents[0]->componentName, SEC_OMX_COMPOMENT_H264_ENC); + SEC_OSAL_Strcpy(secComponents[0]->roles[0], SEC_OMX_COMPOMENT_H264_ENC_ROLE); + secComponents[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM; + +EXIT: + FunctionOut(); + + return MAX_COMPONENT_NUM; +} + diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.h b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.h new file mode 100644 index 0000000..71397ef --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.h @@ -0,0 +1,55 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 library_register.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_H264_REG +#define SEC_OMX_H264_REG + +#include "SEC_OMX_Def.h" +#include "OMX_Component.h" +#include "SEC_OMX_Component_Register.h" + + +#define OSCL_EXPORT_REF __attribute__((visibility("default"))) +#define MAX_COMPONENT_NUM 1 +#define MAX_COMPONENT_ROLE_NUM 1 + +/* H.264 */ +#define SEC_OMX_COMPOMENT_H264_ENC "OMX.SEC.AVC.Encoder" +#define SEC_OMX_COMPOMENT_H264_ENC_ROLE "video_encoder.avc" + + +#ifdef __cplusplus +extern "C" { +#endif + +OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents); + +#ifdef __cplusplus +}; +#endif + +#endif + diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk new file mode 100644 index 0000000..979c34a --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk @@ -0,0 +1,29 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := \ + SEC_OMX_Mpeg4enc.c \ + library_register.c + +LOCAL_PRELINK_MODULE := false +LOCAL_MODULE := libOMX.SEC.M4V.Encoder.aries + +LOCAL_CFLAGS := + +LOCAL_ARM_MODE := arm + +LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc.aries libsecosal.aries libsecbasecomponent.aries libsecmfcencapi.aries +LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils + +LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ + $(SEC_OMX_INC)/sec \ + $(SEC_OMX_TOP)/sec_osal \ + $(SEC_OMX_TOP)/sec_omx_core \ + $(SEC_OMX_COMPONENT)/common \ + $(SEC_OMX_COMPONENT)/video/enc + +LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include + +include $(BUILD_SHARED_LIBRARY) diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c new file mode 100644 index 0000000..0596c25 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c @@ -0,0 +1,1205 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Mpeg4enc.c + * @brief + * @author Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + + +#include +#include +#include + +#include "SEC_OMX_Macros.h" +#include "SEC_OMX_Basecomponent.h" +#include "SEC_OMX_Baseport.h" +#include "SEC_OMX_Venc.h" +#include "library_register.h" +#include "SEC_OMX_Mpeg4enc.h" +#include "SsbSipMfcApi.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_MPEG4_ENC" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +/* MPEG4 Encoder Supported Levels & profiles */ +SEC_OMX_VIDEO_PROFILELEVEL supportedMPEG4ProfileLevels[] ={ + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0b}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level2}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level3}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4a}, + {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level5}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0b}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level1}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level2}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level3}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4a}, + {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level5}}; + +/* H.263 Encoder Supported Levels & profiles */ +SEC_OMX_VIDEO_PROFILELEVEL supportedH263ProfileLevels[] = { + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level10}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level20}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level30}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level40}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level45}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level50}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level60}, + {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level70}}; + +OMX_U32 OMXMpeg4ProfileToMFCProfile(OMX_VIDEO_MPEG4PROFILETYPE profile) +{ + OMX_U32 ret; + + switch (profile) { + case OMX_VIDEO_MPEG4ProfileSimple: + ret = 0; + break; + case OMX_VIDEO_MPEG4ProfileAdvancedSimple: + ret = 1; + break; + default: + ret = 0; + }; + + return ret; +} +OMX_U32 OMXMpeg4LevelToMFCLevel(OMX_VIDEO_MPEG4LEVELTYPE level) +{ + OMX_U32 ret; + + switch (level) { + case OMX_VIDEO_MPEG4Level0: + ret = 0; + break; + case OMX_VIDEO_MPEG4Level0b: + ret = 9; + break; + case OMX_VIDEO_MPEG4Level1: + ret = 1; + break; + case OMX_VIDEO_MPEG4Level2: + ret = 2; + break; + case OMX_VIDEO_MPEG4Level3: + ret = 3; + break; + case OMX_VIDEO_MPEG4Level4: + case OMX_VIDEO_MPEG4Level4a: + ret = 4; + break; + case OMX_VIDEO_MPEG4Level5: + ret = 5; + break; + default: + ret = 0; + }; + + return ret; +} + +void Mpeg4PrintParams(SSBSIP_MFC_ENC_MPEG4_PARAM mpeg4Param) +{ + SEC_OSAL_Log(SEC_LOG_TRACE, "SourceWidth : %d\n", mpeg4Param.SourceWidth); + SEC_OSAL_Log(SEC_LOG_TRACE, "SourceHeight : %d\n", mpeg4Param.SourceHeight); + SEC_OSAL_Log(SEC_LOG_TRACE, "IDRPeriod : %d\n", mpeg4Param.IDRPeriod); + SEC_OSAL_Log(SEC_LOG_TRACE, "SliceMode : %d\n", mpeg4Param.SliceMode); + SEC_OSAL_Log(SEC_LOG_TRACE, "RandomIntraMBRefresh : %d\n", mpeg4Param.RandomIntraMBRefresh); + SEC_OSAL_Log(SEC_LOG_TRACE, "EnableFRMRateControl : %d\n", mpeg4Param.EnableFRMRateControl); + SEC_OSAL_Log(SEC_LOG_TRACE, "Bitrate : %d\n", mpeg4Param.Bitrate); + SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp : %d\n", mpeg4Param.FrameQp); + SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp_P : %d\n", mpeg4Param.FrameQp_P); + SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMax : %d\n", mpeg4Param.QSCodeMax); + SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMin : %d\n", mpeg4Param.QSCodeMin); + SEC_OSAL_Log(SEC_LOG_TRACE, "CBRPeriodRf : %d\n", mpeg4Param.CBRPeriodRf); + SEC_OSAL_Log(SEC_LOG_TRACE, "PadControlOn : %d\n", mpeg4Param.PadControlOn); + SEC_OSAL_Log(SEC_LOG_TRACE, "LumaPadVal : %d\n", mpeg4Param.LumaPadVal); + SEC_OSAL_Log(SEC_LOG_TRACE, "CbPadVal : %d\n", mpeg4Param.CbPadVal); + SEC_OSAL_Log(SEC_LOG_TRACE, "CrPadVal : %d\n", mpeg4Param.CrPadVal); + + /* MPEG4 specific parameters */ + SEC_OSAL_Log(SEC_LOG_TRACE, "ProfileIDC : %d\n", mpeg4Param.ProfileIDC); + SEC_OSAL_Log(SEC_LOG_TRACE, "LevelIDC : %d\n", mpeg4Param.LevelIDC); + SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp_B : %d\n", mpeg4Param.FrameQp_B); + SEC_OSAL_Log(SEC_LOG_TRACE, "TimeIncreamentRes : %d\n", mpeg4Param.TimeIncreamentRes); + SEC_OSAL_Log(SEC_LOG_TRACE, "VopTimeIncreament : %d\n", mpeg4Param.VopTimeIncreament); + SEC_OSAL_Log(SEC_LOG_TRACE, "SliceArgument : %d\n", mpeg4Param.SliceArgument); + SEC_OSAL_Log(SEC_LOG_TRACE, "NumberBFrames : %d\n", mpeg4Param.NumberBFrames); + SEC_OSAL_Log(SEC_LOG_TRACE, "DisableQpelME : %d\n", mpeg4Param.DisableQpelME); +} + +void H263PrintParams(SSBSIP_MFC_ENC_H263_PARAM h263Param) +{ + SEC_OSAL_Log(SEC_LOG_TRACE, "SourceWidth : %d\n", h263Param.SourceWidth); + SEC_OSAL_Log(SEC_LOG_TRACE, "SourceHeight : %d\n", h263Param.SourceHeight); + SEC_OSAL_Log(SEC_LOG_TRACE, "IDRPeriod : %d\n", h263Param.IDRPeriod); + SEC_OSAL_Log(SEC_LOG_TRACE, "SliceMode : %d\n", h263Param.SliceMode); + SEC_OSAL_Log(SEC_LOG_TRACE, "RandomIntraMBRefresh : %d\n", h263Param.RandomIntraMBRefresh); + SEC_OSAL_Log(SEC_LOG_TRACE, "EnableFRMRateControl : %d\n", h263Param.EnableFRMRateControl); + SEC_OSAL_Log(SEC_LOG_TRACE, "Bitrate : %d\n", h263Param.Bitrate); + SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp : %d\n", h263Param.FrameQp); + SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp_P : %d\n", h263Param.FrameQp_P); + SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMax : %d\n", h263Param.QSCodeMax); + SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMin : %d\n", h263Param.QSCodeMin); + SEC_OSAL_Log(SEC_LOG_TRACE, "CBRPeriodRf : %d\n", h263Param.CBRPeriodRf); + SEC_OSAL_Log(SEC_LOG_TRACE, "PadControlOn : %d\n", h263Param.PadControlOn); + SEC_OSAL_Log(SEC_LOG_TRACE, "LumaPadVal : %d\n", h263Param.LumaPadVal); + SEC_OSAL_Log(SEC_LOG_TRACE, "CbPadVal : %d\n", h263Param.CbPadVal); + SEC_OSAL_Log(SEC_LOG_TRACE, "CrPadVal : %d\n", h263Param.CrPadVal); + + /* H.263 specific parameters */ + SEC_OSAL_Log(SEC_LOG_TRACE, "FrameRate : %d\n", h263Param.FrameRate); +} + +void Set_Mpeg4Enc_Param(SSBSIP_MFC_ENC_MPEG4_PARAM *pMpeg4Param, SEC_OMX_BASECOMPONENT *pSECComponent) +{ + SEC_OMX_BASEPORT *pSECInputPort = NULL; + SEC_OMX_BASEPORT *pSECOutputPort = NULL; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + + pMpeg4Param->codecType = MPEG4_ENC; + pMpeg4Param->SourceWidth = pSECOutputPort->portDefinition.format.video.nFrameWidth; + pMpeg4Param->SourceHeight = pSECOutputPort->portDefinition.format.video.nFrameHeight; + pMpeg4Param->IDRPeriod = pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1; + pMpeg4Param->SliceMode = 0; + pMpeg4Param->RandomIntraMBRefresh = 0; + pMpeg4Param->EnableFRMRateControl = 1; /* 0: disable, 1: enable */ + pMpeg4Param->Bitrate = pSECOutputPort->portDefinition.format.video.nBitrate; + pMpeg4Param->FrameQp = 20; + pMpeg4Param->FrameQp_P = 20; + pMpeg4Param->QSCodeMax = 30; + pMpeg4Param->QSCodeMin = 10; + pMpeg4Param->CBRPeriodRf = 10; + pMpeg4Param->PadControlOn = 0; /* 0: Use boundary pixel, 1: Use the below setting value */ + pMpeg4Param->LumaPadVal = 0; + pMpeg4Param->CbPadVal = 0; + pMpeg4Param->CrPadVal = 0; + + pMpeg4Param->ProfileIDC = OMXMpeg4ProfileToMFCProfile(pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].eProfile); + pMpeg4Param->LevelIDC = OMXMpeg4LevelToMFCLevel(pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].eLevel); + pMpeg4Param->FrameQp_B = 20; + pMpeg4Param->TimeIncreamentRes = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16; + pMpeg4Param->VopTimeIncreament = 1; + pMpeg4Param->SliceArgument = 0; /* MB number or byte number */ + pMpeg4Param->NumberBFrames = 0; /* 0(not used) ~ 2 */ + pMpeg4Param->DisableQpelME = 1; + + SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->eControlRate: 0x%x", pSECOutputPort->eControlRate); + switch (pSECOutputPort->eControlRate) { + case OMX_Video_ControlRateDisable: + /* TBD */ + break; + case OMX_Video_ControlRateVariable: + /* TBD */ + break; + default: + break; + } + + Mpeg4PrintParams(*pMpeg4Param); +} + +void Set_H263Enc_Param(SSBSIP_MFC_ENC_H263_PARAM *pH263Param, SEC_OMX_BASECOMPONENT *pSECComponent) +{ + SEC_OMX_BASEPORT *pSECInputPort = NULL; + SEC_OMX_BASEPORT *pSECOutputPort = NULL; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + + pH263Param->codecType = H263_ENC; + pH263Param->SourceWidth = pSECOutputPort->portDefinition.format.video.nFrameWidth; + pH263Param->SourceHeight = pSECOutputPort->portDefinition.format.video.nFrameHeight; + pH263Param->IDRPeriod = pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1; + pH263Param->SliceMode = 0; + pH263Param->RandomIntraMBRefresh = 0; + pH263Param->EnableFRMRateControl = 1; /* 0: disable, 1: enable */ + pH263Param->Bitrate = pSECOutputPort->portDefinition.format.video.nBitrate; + pH263Param->FrameQp = 20; + pH263Param->FrameQp_P = 20; + pH263Param->QSCodeMax = 30; + pH263Param->QSCodeMin = 10; + pH263Param->CBRPeriodRf = 10; + pH263Param->PadControlOn = 0; /* 0: Use boundary pixel, 1: Use the below setting value */ + pH263Param->LumaPadVal = 0; + pH263Param->CbPadVal = 0; + pH263Param->CrPadVal = 0; + + pH263Param->FrameRate = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16; + + SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->eControlRate: 0x%x", pSECOutputPort->eControlRate); + switch (pSECOutputPort->eControlRate) { + case OMX_Video_ControlRateDisable: + /* TBD */ + break; + case OMX_Video_ControlRateVariable: + /* TBD */ + break; + default: + break; + } + + H263PrintParams(*pH263Param); +} + +OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_GetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nParamIndex, + OMX_INOUT OMX_PTR pComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL || pComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + switch (nParamIndex) { + case OMX_IndexParamVideoMpeg4: + { + OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pDstMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstMpeg4Param->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + pSrcMpeg4Param = &pMpeg4Enc->mpeg4Component[pDstMpeg4Param->nPortIndex]; + + SEC_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); + } + break; + case OMX_IndexParamVideoH263: + { + OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pDstH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstH263Param->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + pSrcH263Param = &pMpeg4Enc->h263Component[pDstH263Param->nPortIndex]; + + SEC_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); + } + break; + case OMX_IndexParamStandardComponentRole: + { + OMX_S32 codecType; + OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure; + + ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + codecType = ((SEC_MPEG4ENC_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType; + if (codecType == CODEC_TYPE_MPEG4) + SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_MPEG4_ENC_ROLE); + else + SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_H263_ENC_ROLE); + } + break; + case OMX_IndexParamVideoProfileLevelQuerySupported: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; + SEC_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL; + OMX_U32 maxProfileLevelNum = 0; + OMX_S32 codecType; + + ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + codecType = ((SEC_MPEG4ENC_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType; + if (codecType == CODEC_TYPE_MPEG4) { + pProfileLevel = supportedMPEG4ProfileLevels; + maxProfileLevelNum = sizeof(supportedMPEG4ProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL); + } else { + pProfileLevel = supportedH263ProfileLevels; + maxProfileLevelNum = sizeof(supportedH263ProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL); + } + + if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) { + ret = OMX_ErrorNoMore; + goto EXIT; + } + + pProfileLevel += pDstProfileLevel->nProfileIndex; + pDstProfileLevel->eProfile = pProfileLevel->profile; + pDstProfileLevel->eLevel = pProfileLevel->level; + } + break; + case OMX_IndexParamVideoProfileLevelCurrent: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL; + OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + OMX_S32 codecType; + + ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + codecType = pMpeg4Enc->hMFCMpeg4Handle.codecType; + if (codecType == CODEC_TYPE_MPEG4) { + pSrcMpeg4Param = &pMpeg4Enc->mpeg4Component[pDstProfileLevel->nPortIndex]; + pDstProfileLevel->eProfile = pSrcMpeg4Param->eProfile; + pDstProfileLevel->eLevel = pSrcMpeg4Param->eLevel; + } else { + pSrcH263Param = &pMpeg4Enc->h263Component[pDstProfileLevel->nPortIndex]; + pDstProfileLevel->eProfile = pSrcH263Param->eProfile; + pDstProfileLevel->eLevel = pSrcH263Param->eLevel; + } + } + break; + case OMX_IndexParamVideoErrorCorrection: + { + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pDstErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + pSrcErrorCorrectionType = &pMpeg4Enc->errorCorrectionType[OUTPUT_PORT_INDEX]; + + pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; + pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; + pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; + pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; + pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; + } + break; + default: + ret = SEC_OMX_VideoEncodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); + break; + } +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_SetParameter( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR pComponentParameterStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL || pComponentParameterStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + switch (nIndex) { + case OMX_IndexParamVideoMpeg4: + { + OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL; + OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcMpeg4Param->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + pDstMpeg4Param = &pMpeg4Enc->mpeg4Component[pSrcMpeg4Param->nPortIndex]; + + SEC_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE)); + } + break; + case OMX_IndexParamVideoH263: + { + OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL; + OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcH263Param->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + pDstH263Param = &pMpeg4Enc->h263Component[pSrcH263Param->nPortIndex]; + + SEC_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE)); + } + break; + case OMX_IndexParamStandardComponentRole: + { + OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; + + ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) { + ret = OMX_ErrorIncorrectStateOperation; + goto EXIT; + } + + if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_MPEG4_ENC_ROLE)) { + pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; + //((SEC_MPEG4ENC_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_MPEG4; + } else if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_H263_ENC_ROLE)) { + pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; + //((SEC_MPEG4ENC_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_H263; + } else { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + } + break; + case OMX_IndexParamVideoProfileLevelCurrent: + { + OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL; + OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + OMX_S32 codecType; + + ret = SEC_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + codecType = pMpeg4Enc->hMFCMpeg4Handle.codecType; + if (codecType == CODEC_TYPE_MPEG4) { + /* + * To do: Check validity of profile & level parameters + */ + + pDstMpeg4Param = &pMpeg4Enc->mpeg4Component[pSrcProfileLevel->nPortIndex]; + pDstMpeg4Param->eProfile = pSrcProfileLevel->eProfile; + pDstMpeg4Param->eLevel = pSrcProfileLevel->eLevel; + } else { + /* + * To do: Check validity of profile & level parameters + */ + + pDstH263Param = &pMpeg4Enc->h263Component[pSrcProfileLevel->nPortIndex]; + pDstH263Param->eProfile = pSrcProfileLevel->eProfile; + pDstH263Param->eLevel = pSrcProfileLevel->eLevel; + } + } + break; + case OMX_IndexParamVideoErrorCorrection: + { + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + if (pSrcErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + pDstErrorCorrectionType = &pMpeg4Enc->errorCorrectionType[OUTPUT_PORT_INDEX]; + + pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; + pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; + pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; + pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; + pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; + } + break; + default: + ret = SEC_OMX_VideoEncodeSetParameter(hComponent, nIndex, pComponentParameterStructure); + break; + } +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_SetConfig( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR pComponentConfigStructure) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + + FunctionIn(); + + if (hComponent == NULL || pComponentConfigStructure == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid) { + ret = OMX_ErrorInvalidState; + goto EXIT; + } + + switch (nIndex) { + default: + ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure); + break; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_ComponentRoleEnum( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_OUT OMX_U8 *cRole, + OMX_IN OMX_U32 nIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + OMX_S32 codecType; + + FunctionIn(); + + if ((hComponent == NULL) || (cRole == NULL)) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (nIndex != (MAX_COMPONENT_ROLE_NUM - 1)) { + ret = OMX_ErrorNoMore; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pSECComponent->currentState == OMX_StateInvalid ) { + ret = OMX_StateInvalid; + goto EXIT; + } + + codecType = ((SEC_MPEG4ENC_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType; + if (codecType == CODEC_TYPE_MPEG4) + SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_MPEG4_ENC_ROLE); + else + SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_H263_ENC_ROLE); + +EXIT: + FunctionOut(); + + return ret; +} + +/* MFC Init */ +OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_Init(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *pSECPort = NULL; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + OMX_HANDLETYPE hMFCHandle = NULL; + OMX_S32 returnCodec = 0; + + FunctionIn(); + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC = OMX_FALSE; + pSECComponent->bUseFlagEOF = OMX_FALSE; + pSECComponent->bSaveFlagEOS = OMX_FALSE; + + /* MFC(Multi Format Codec) encoder and CMM(Codec Memory Management) driver open */ + hMFCHandle = SsbSipMfcEncOpen(); + if (hMFCHandle == NULL) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle = hMFCHandle; + + /* set MFC ENC VIDEO PARAM and initialize MFC encoder instance */ + if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) { + Set_Mpeg4Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.mpeg4MFCParam), pSECComponent); + returnCodec = SsbSipMfcEncInit(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.mpeg4MFCParam)); + } else { + Set_H263Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam), pSECComponent); + returnCodec = SsbSipMfcEncInit(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam)); + } + if (returnCodec != MFC_RET_OK) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + + /* allocate encoder's input buffer */ + returnCodec = SsbSipMfcEncGetInBuf(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.inputInfo)); + if (returnCodec != MFC_RET_OK) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + + pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YPhyAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YPhyAddr; + pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CPhyAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CPhyAddr; + pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YVirAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr; + pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CVirAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr; + pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YSize = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YSize; + pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CSize = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CSize; + + SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); + SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); + pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp = 0; + +EXIT: + FunctionOut(); + + return ret; +} + +/* MFC Terminate */ +OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + OMX_HANDLETYPE hMFCHandle = NULL; + + FunctionIn(); + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; + + if (hMFCHandle != NULL) { + SsbSipMfcEncClose(hMFCHandle); + pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle = NULL; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_MFC_Mpeg4_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + OMX_HANDLETYPE hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; + SSBSIP_MFC_ENC_INPUT_INFO *pInputInfo = &(pMpeg4Enc->hMFCMpeg4Handle.inputInfo); + SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo; + SEC_OMX_BASEPORT *pSECPort = NULL; + MFC_ENC_ADDR_INFO addrInfo; + OMX_U32 oneFrameSize = pInputData->dataLen; + OMX_S32 returnCodec = 0; + + FunctionIn(); + + if (pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC == OMX_FALSE) { + returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo); + if (returnCodec != MFC_RET_OK) + { + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, returnCodec); + ret = OMX_ErrorUndefined; + goto EXIT; + } + + pOutputData->dataBuffer = outputInfo.StrmVirAddr; + pOutputData->allocSize = outputInfo.headerSize; + pOutputData->dataLen = outputInfo.headerSize; + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG; + pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; + + pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC = OMX_TRUE; + + if (pOutputData->dataLen > 0) { + ret = OMX_ErrorNone; + goto EXIT; + } else { + ret = OMX_ErrorInputDataEncodeYet; + goto EXIT; + } + } + + if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) && + (pSECComponent->bUseFlagEOF == OMX_FALSE)) { + pSECComponent->bUseFlagEOF = OMX_TRUE; + } + + pSECComponent->timeStamp[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp; + pSECComponent->nFlags[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags; + SsbSipMfcEncSetConfig(hMFCHandle, MFC_ENC_SETCONF_FRAME_TAG, &(pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp)); + pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp++; + if (pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp >= MAX_TIMESTAMP) + pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp = 0; + + if (oneFrameSize <= 0) { + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + + ret = OMX_ErrorNone; + goto EXIT; + } + + pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + if (pSECPort->portDefinition.format.video.eColorFormat == SEC_OMX_COLOR_FormatNV12PhysicalAddress) { + /* input data from Real camera */ +#define USE_FIMC_FRAME_BUFFER +#ifdef USE_FIMC_FRAME_BUFFER + SEC_OSAL_Memcpy(&addrInfo.pAddrY, pInputData->dataBuffer, sizeof(addrInfo.pAddrY)); + SEC_OSAL_Memcpy(&addrInfo.pAddrC, pInputData->dataBuffer + sizeof(addrInfo.pAddrY), sizeof(addrInfo.pAddrC)); + pInputInfo->YPhyAddr = addrInfo.pAddrY; + pInputInfo->CPhyAddr = addrInfo.pAddrC; + returnCodec = SsbSipMfcEncSetInBuf(hMFCHandle, pInputInfo); + if (returnCodec != MFC_RET_OK) { + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncSetInBuf failed, ret:%d", __FUNCTION__, returnCodec); + ret = OMX_ErrorUndefined; + goto EXIT; + } +#else + OMX_U32 width, height; + + width = pSECPort->portDefinition.format.video.nFrameWidth; + height = pSECPort->portDefinition.format.video.nFrameHeight; + + SEC_OSAL_Memcpy(pInputInfo->YVirAddr, pInputData->dataBuffer, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height))); + SEC_OSAL_Memcpy(pInputInfo->CVirAddr, pInputData->dataBuffer + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)), ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2))); +#endif + } + + returnCodec = SsbSipMfcEncExe(hMFCHandle); + if (returnCodec == MFC_RET_OK) { + OMX_S32 indexTimestamp = 0; + + returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo); + + if ((SsbSipMfcEncGetConfig(hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) || + (((indexTimestamp < 0) || (indexTimestamp > MAX_TIMESTAMP)))) { + pOutputData->timeStamp = pInputData->timeStamp; + pOutputData->nFlags = pInputData->nFlags; + } else { + pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp]; + pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp]; + } + + if (returnCodec == MFC_RET_OK) { + /** Fill Output Buffer **/ + pOutputData->dataBuffer = outputInfo.StrmVirAddr; + pOutputData->allocSize = outputInfo.dataSize; + pOutputData->dataLen = outputInfo.dataSize; + pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; + if (outputInfo.frameType == MFC_FRAME_TYPE_I_FRAME) + pOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; + + ret = OMX_ErrorNone; + } else { + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, returnCodec); + ret = OMX_ErrorUndefined; + } + } else { + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncExe failed, ret:%d", __FUNCTION__, returnCodec); + ret = OMX_ErrorUndefined; + } + +EXIT: + FunctionOut(); + + return ret; +} + +/* MFC Encode */ +OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + SEC_OMX_BASEPORT *pInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + SEC_OMX_BASEPORT *pOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + + FunctionIn(); + + if ((!CHECK_PORT_ENABLED(pInputPort)) || (!CHECK_PORT_ENABLED(pOutputPort)) || + (!CHECK_PORT_POPULATED(pInputPort)) || (!CHECK_PORT_POPULATED(pOutputPort))) { + goto EXIT; + } + if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) { + goto EXIT; + } + + ret = SEC_MFC_Mpeg4_Encode(pOMXComponent, pInputData, pOutputData); + if (ret != OMX_ErrorNone) { + if (ret == OMX_ErrorInputDataEncodeYet) { + pOutputData->usedDataLen = 0; + pOutputData->remainDataLen = pOutputData->dataLen; + } else { + pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, + pSECComponent->callbackData, + OMX_EventError, ret, 0, NULL); + } + } else { + pInputData->usedDataLen += pInputData->dataLen; + pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen; + pInputData->dataLen -= pInputData->usedDataLen; + pInputData->usedDataLen = 0; + + pOutputData->usedDataLen = 0; + pOutputData->remainDataLen = pOutputData->dataLen; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_OMX_BASEPORT *pSECPort = NULL; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + OMX_S32 codecType = -1; + int i = 0; + + FunctionIn(); + + if ((hComponent == NULL) || (componentName == NULL)) { + ret = OMX_ErrorBadParameter; + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: parameters are null, ret: %X", __FUNCTION__, ret); + goto EXIT; + } + if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_MPEG4_ENC, componentName) == 0) { + codecType = CODEC_TYPE_MPEG4; + } else if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_H263_ENC, componentName) == 0) { + codecType = CODEC_TYPE_H263; + } else { + ret = OMX_ErrorBadParameter; + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName(%s) error, ret: %X", __FUNCTION__, componentName, ret); + goto EXIT; + } + + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = SEC_OMX_VideoEncodeComponentInit(pOMXComponent); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_OMX_VideoDecodeComponentInit error, ret: %X", __FUNCTION__, ret); + goto EXIT; + } + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pSECComponent->codecType = HW_VIDEO_CODEC; + + pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); + if (pSECComponent->componentName == NULL) { + SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent); + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName alloc error, ret: %X", __FUNCTION__, ret); + goto EXIT; + } + SEC_OSAL_Memset(pSECComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); + + pMpeg4Enc = SEC_OSAL_Malloc(sizeof(SEC_MPEG4ENC_HANDLE)); + if (pMpeg4Enc == NULL) { + SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent); + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_MPEG4ENC_HANDLE alloc error, ret: %X", __FUNCTION__, ret); + goto EXIT; + } + SEC_OSAL_Memset(pMpeg4Enc, 0, sizeof(SEC_MPEG4ENC_HANDLE)); + pSECComponent->hCodecHandle = (OMX_HANDLETYPE)pMpeg4Enc; + pMpeg4Enc->hMFCMpeg4Handle.codecType = codecType; + + if (codecType == CODEC_TYPE_MPEG4) + SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_MPEG4_ENC); + else + SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_H263_ENC); + + /* Set componentVersion */ + pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; + pSECComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; + pSECComponent->componentVersion.s.nRevision = REVISION_NUMBER; + pSECComponent->componentVersion.s.nStep = STEP_NUMBER; + /* Set specVersion */ + pSECComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; + pSECComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; + pSECComponent->specVersion.s.nRevision = REVISION_NUMBER; + pSECComponent->specVersion.s.nStep = STEP_NUMBER; + + /* Android CapabilityFlags */ + pSECComponent->capabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_FALSE; + pSECComponent->capabilityFlags.iOMXComponentSupportsPartialFrames = OMX_FALSE; + pSECComponent->capabilityFlags.iOMXComponentUsesNALStartCodes = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE; + pSECComponent->capabilityFlags.iOMXComponentUsesFullAVCFrames = OMX_TRUE; + + /* Input port */ + pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX]; + pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; + pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; + pSECPort->portDefinition.format.video.nBitrate = 64000; + pSECPort->portDefinition.format.video.xFramerate= (15 << 16); + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; + pSECPort->portDefinition.format.video.pNativeRender = 0; + pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; + SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video"); + pSECPort->portDefinition.format.video.eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress;//OMX_COLOR_FormatYUV420SemiPlanar; + pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; + pSECPort->portDefinition.bEnabled = OMX_TRUE; + + /* Output port */ + pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX]; + pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; + pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; + pSECPort->portDefinition.format.video.nBitrate = 64000; + pSECPort->portDefinition.format.video.xFramerate= (15 << 16); + if (codecType == CODEC_TYPE_MPEG4) { + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; + SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/mpeg4"); + } else { + pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; + SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); + SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/h263"); + } + pSECPort->portDefinition.format.video.pNativeRender = 0; + pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; + pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; + pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; + pSECPort->portDefinition.bEnabled = OMX_TRUE; + + if (codecType == CODEC_TYPE_MPEG4) { + for(i = 0; i < ALL_PORT_NUM; i++) { + INIT_SET_SIZE_VERSION(&pMpeg4Enc->mpeg4Component[i], OMX_VIDEO_PARAM_MPEG4TYPE); + pMpeg4Enc->mpeg4Component[i].nPortIndex = i; + pMpeg4Enc->mpeg4Component[i].eProfile = OMX_VIDEO_MPEG4ProfileSimple; + pMpeg4Enc->mpeg4Component[i].eLevel = OMX_VIDEO_MPEG4Level4; + + pMpeg4Enc->mpeg4Component[i].nPFrames = 10; + pMpeg4Enc->mpeg4Component[i].nBFrames = 0; /* No support for B frames */ + pMpeg4Enc->mpeg4Component[i].nMaxPacketSize = 256; /* Default value */ + pMpeg4Enc->mpeg4Component[i].nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP; + pMpeg4Enc->mpeg4Component[i].bGov = OMX_FALSE; + + } + } else { + for(i = 0; i < ALL_PORT_NUM; i++) { + INIT_SET_SIZE_VERSION(&pMpeg4Enc->h263Component[i], OMX_VIDEO_PARAM_H263TYPE); + pMpeg4Enc->h263Component[i].nPortIndex = i; + pMpeg4Enc->h263Component[i].eProfile = OMX_VIDEO_H263ProfileBaseline; + pMpeg4Enc->h263Component[i].eLevel = OMX_VIDEO_H263Level45; + + pMpeg4Enc->h263Component[i].nPFrames = 20; + pMpeg4Enc->h263Component[i].nBFrames = 0; /* No support for B frames */ + pMpeg4Enc->h263Component[i].bPLUSPTYPEAllowed = OMX_FALSE; + pMpeg4Enc->h263Component[i].nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP; + pMpeg4Enc->h263Component[i].bForceRoundingTypeToZero = OMX_TRUE; + pMpeg4Enc->h263Component[i].nPictureHeaderRepetition = 0; + pMpeg4Enc->h263Component[i].nGOBHeaderInterval = 0; + } + } + + pOMXComponent->GetParameter = &SEC_MFC_Mpeg4Enc_GetParameter; + pOMXComponent->SetParameter = &SEC_MFC_Mpeg4Enc_SetParameter; + pOMXComponent->SetConfig = &SEC_MFC_Mpeg4Enc_SetConfig; + pOMXComponent->ComponentRoleEnum = &SEC_MFC_Mpeg4Enc_ComponentRoleEnum; + pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit; + + pSECComponent->sec_mfc_componentInit = &SEC_MFC_Mpeg4Enc_Init; + pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_Mpeg4Enc_Terminate; + pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_Mpeg4Enc_bufferProcess; + pSECComponent->sec_checkInputFrame = NULL; + + pSECComponent->currentState = OMX_StateLoaded; + + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + SEC_OMX_BASECOMPONENT *pSECComponent = NULL; + SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL; + + FunctionIn(); + + if (hComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + SEC_OSAL_Free(pSECComponent->componentName); + pSECComponent->componentName = NULL; + + pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)pSECComponent->hCodecHandle; + if (pMpeg4Enc != NULL) { + SEC_OSAL_Free(pMpeg4Enc); + pMpeg4Enc = pSECComponent->hCodecHandle = NULL; + } + + ret = SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.h b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.h new file mode 100644 index 0000000..d4f9038 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.h @@ -0,0 +1,76 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Mpeg4enc.h + * @brief + * @author Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_MPEG4_ENC_COMPONENT +#define SEC_OMX_MPEG4_ENC_COMPONENT + +#include "SEC_OMX_Def.h" +#include "OMX_Component.h" +#include "SsbSipMfcApi.h" + + +typedef enum _CODEC_TYPE +{ + CODEC_TYPE_H263, + CODEC_TYPE_MPEG4 +} CODEC_TYPE; + +typedef struct _SEC_MFC_MPEG4ENC_HANDLE +{ + OMX_HANDLETYPE hMFCHandle; + SSBSIP_MFC_ENC_MPEG4_PARAM mpeg4MFCParam; + SSBSIP_MFC_ENC_H263_PARAM h263MFCParam; + SSBSIP_MFC_ENC_INPUT_INFO inputInfo; + OMX_U32 indexTimestamp; + OMX_BOOL bConfiguredMFC; + CODEC_TYPE codecType; +} SEC_MFC_MPEG4ENC_HANDLE; + +typedef struct _SEC_MPEG4ENC_HANDLE +{ + /* OMX Codec specific */ + OMX_VIDEO_PARAM_H263TYPE h263Component[ALL_PORT_NUM]; + OMX_VIDEO_PARAM_MPEG4TYPE mpeg4Component[ALL_PORT_NUM]; + OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE errorCorrectionType[ALL_PORT_NUM]; + + /* SEC MFC Codec specific */ + SEC_MFC_MPEG4ENC_HANDLE hMFCMpeg4Handle; +} SEC_MPEG4ENC_HANDLE; + + +#ifdef __cplusplus +extern "C" { +#endif + + +OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName); + OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent); + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c new file mode 100644 index 0000000..20e4eb8 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c @@ -0,0 +1,64 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 library_register.c + * @brief + * @author Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + + +#include +#include +#include +#include + +#include "SEC_OSAL_Memory.h" +#include "SEC_OSAL_ETC.h" +#include "library_register.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_MPEG4_ENC" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent) +{ + FunctionIn(); + + if (ppSECComponent == NULL) + goto EXIT; + + /* component 1 - video encoder MPEG4 */ + SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPOMENT_MPEG4_ENC); + SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPOMENT_MPEG4_ENC_ROLE); + ppSECComponent[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM; + + /* component 2 - video encoder H.263 */ + SEC_OSAL_Strcpy(ppSECComponent[1]->componentName, SEC_OMX_COMPOMENT_H263_ENC); + SEC_OSAL_Strcpy(ppSECComponent[1]->roles[0], SEC_OMX_COMPOMENT_H263_ENC_ROLE); + ppSECComponent[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM; + +EXIT: + FunctionOut(); + return MAX_COMPONENT_NUM; +} + diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.h b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.h new file mode 100644 index 0000000..3b23011 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.h @@ -0,0 +1,59 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 library_register.h + * @brief + * @author Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_MPEG4_ENC_REG +#define SEC_OMX_MPEG4_ENC_REG + +#include "SEC_OMX_Def.h" +#include "OMX_Component.h" +#include "SEC_OMX_Component_Register.h" + + +#define OSCL_EXPORT_REF __attribute__((visibility("default"))) +#define MAX_COMPONENT_NUM 2 +#define MAX_COMPONENT_ROLE_NUM 1 + +/* MPEG4 */ +#define SEC_OMX_COMPOMENT_MPEG4_ENC "OMX.SEC.MPEG4.Encoder" +#define SEC_OMX_COMPOMENT_MPEG4_ENC_ROLE "video_encoder.mpeg4" + +/* H.263 */ +#define SEC_OMX_COMPOMENT_H263_ENC "OMX.SEC.H263.Encoder" +#define SEC_OMX_COMPOMENT_H263_ENC_ROLE "video_encoder.h263" + + +#ifdef __cplusplus +extern "C" { +#endif + +OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent); + +#ifdef __cplusplus +}; +#endif + +#endif + diff --git a/sec_mm/sec_omx/sec_omx_core/Android.mk b/sec_mm/sec_omx/sec_omx_core/Android.mk new file mode 100644 index 0000000..cb01274 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_core/Android.mk @@ -0,0 +1,25 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := SEC_OMX_Component_Register.c \ + SEC_OMX_Core.c + +LOCAL_PRELINK_MODULE := false +LOCAL_MODULE := libSEC_OMX_Core.aries + +LOCAL_CFLAGS := + +LOCAL_ARM_MODE := arm + +LOCAL_STATIC_LIBRARIES := libsecosal.aries libsecbasecomponent.aries +LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils + +LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ + $(SEC_OMX_INC)/sec \ + $(SEC_OMX_TOP)/sec_osal \ + $(SEC_OMX_TOP)/sec_omx_component/common + +include $(BUILD_SHARED_LIBRARY) + diff --git a/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.c b/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.c new file mode 100644 index 0000000..1464397 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.c @@ -0,0 +1,269 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Component_Register.c + * @brief SEC OpenMAX IL Component Register + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "OMX_Component.h" +#include "SEC_OSAL_Memory.h" +#include "SEC_OSAL_ETC.h" +#include "SEC_OSAL_Library.h" +#include "SEC_OMX_Component_Register.h" +#include "SEC_OMX_Macros.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_COMP_REGS" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +#define REGISTRY_FILENAME "secomxregistry" + + +OMX_ERRORTYPE SEC_OMX_Component_Register(SEC_OMX_COMPONENT_REGLIST **compList, OMX_U32 *compNum) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + int componentNum = 0, roleNum = 0, totalCompNum = 0; + int read; + char *omxregistryfile = NULL; + char *line = NULL; + char *libName; + FILE *omxregistryfp; + size_t len; + OMX_HANDLETYPE soHandle; + const char *errorMsg; + int (*SEC_OMX_COMPONENT_Library_Register)(SECRegisterComponentType **secComponents); + SECRegisterComponentType **secComponentsTemp; + SEC_OMX_COMPONENT_REGLIST *componentList; + + FunctionIn(); + + omxregistryfile = SEC_OSAL_Malloc(strlen("/system/etc/") + strlen(REGISTRY_FILENAME) + 2); + SEC_OSAL_Strcpy(omxregistryfile, "/system/etc/"); + SEC_OSAL_Strcat(omxregistryfile, REGISTRY_FILENAME); + + omxregistryfp = fopen(omxregistryfile, "r"); + if (omxregistryfp == NULL) { + ret = OMX_ErrorUndefined; + goto EXIT; + } + SEC_OSAL_Free(omxregistryfile); + + fseek(omxregistryfp, 0, 0); + componentList = (SEC_OMX_COMPONENT_REGLIST *)SEC_OSAL_Malloc(sizeof(SEC_OMX_COMPONENT_REGLIST) * MAX_OMX_COMPONENT_NUM); + SEC_OSAL_Memset(componentList, 0, sizeof(SEC_OMX_COMPONENT_REGLIST) * MAX_OMX_COMPONENT_NUM); + libName = SEC_OSAL_Malloc(MAX_OMX_COMPONENT_LIBNAME_SIZE); + + while ((read = getline(&line, &len, omxregistryfp)) != -1) { + if ((*line == 'l') && (*(line + 1) == 'i') && (*(line + 2) == 'b') && + (*(line + 3) == 'O') && (*(line + 4) == 'M') && (*(line + 5) == 'X')) { + SEC_OSAL_Memset(libName, 0, MAX_OMX_COMPONENT_LIBNAME_SIZE); + SEC_OSAL_Strncpy(libName, line, SEC_OSAL_Strlen(line)-1); + SEC_OSAL_Log(SEC_LOG_TRACE, "libName : %s", libName); + + if ((soHandle = SEC_OSAL_dlopen(libName, RTLD_NOW)) != NULL) { + SEC_OSAL_dlerror(); /* clear error*/ + if ((SEC_OMX_COMPONENT_Library_Register = SEC_OSAL_dlsym(soHandle, "SEC_OMX_COMPONENT_Library_Register")) != NULL) { + int i = 0, j = 0; + + componentNum = (*SEC_OMX_COMPONENT_Library_Register)(NULL); + secComponentsTemp = (SECRegisterComponentType **)SEC_OSAL_Malloc(sizeof(SECRegisterComponentType*) * componentNum); + for (i = 0; i < componentNum; i++) { + secComponentsTemp[i] = SEC_OSAL_Malloc(sizeof(SECRegisterComponentType)); + SEC_OSAL_Memset(secComponentsTemp[i], 0, sizeof(SECRegisterComponentType)); + } + (*SEC_OMX_COMPONENT_Library_Register)(secComponentsTemp); + + for (i = 0; i < componentNum; i++) { + SEC_OSAL_Strcpy(componentList[totalCompNum].component.componentName, secComponentsTemp[i]->componentName); + for (j = 0; j < secComponentsTemp[i]->totalRoleNum; j++) + SEC_OSAL_Strcpy(componentList[totalCompNum].component.roles[j], secComponentsTemp[i]->roles[j]); + componentList[totalCompNum].component.totalRoleNum = secComponentsTemp[i]->totalRoleNum; + + SEC_OSAL_Strcpy(componentList[totalCompNum].libName, libName); + + totalCompNum++; + } + for (i = 0; i < componentNum; i++) { + SEC_OSAL_Free(secComponentsTemp[i]); + } + + SEC_OSAL_Free(secComponentsTemp); + } else { + if ((errorMsg = SEC_OSAL_dlerror()) != NULL) + SEC_OSAL_Log(SEC_LOG_WARNING, "dlsym failed: %s", errorMsg); + } + SEC_OSAL_dlclose(soHandle); + } else { + SEC_OSAL_Log(SEC_LOG_WARNING, "dlopen failed: %s", SEC_OSAL_dlerror()); + } + } else { + /* not a component name line. skip */ + continue; + } + } + + SEC_OSAL_Free(libName); + fclose(omxregistryfp); + + *compList = componentList; + *compNum = totalCompNum; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_Component_Unregister(SEC_OMX_COMPONENT_REGLIST *componentList) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + + SEC_OSAL_Memset(componentList, 0, sizeof(SEC_OMX_COMPONENT_REGLIST) * MAX_OMX_COMPONENT_NUM); + SEC_OSAL_Free(componentList); + +EXIT: + return ret; +} + +OMX_ERRORTYPE SEC_OMX_ComponentAPICheck(OMX_COMPONENTTYPE component) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + + if ((NULL == component.GetComponentVersion) || + (NULL == component.SendCommand) || + (NULL == component.GetParameter) || + (NULL == component.SetParameter) || + (NULL == component.GetConfig) || + (NULL == component.SetConfig) || + (NULL == component.GetExtensionIndex) || + (NULL == component.GetState) || + (NULL == component.ComponentTunnelRequest) || + (NULL == component.UseBuffer) || + (NULL == component.AllocateBuffer) || + (NULL == component.FreeBuffer) || + (NULL == component.EmptyThisBuffer) || + (NULL == component.FillThisBuffer) || + (NULL == component.SetCallbacks) || + (NULL == component.ComponentDeInit) || + (NULL == component.UseEGLImage) || + (NULL == component.ComponentRoleEnum)) + ret = OMX_ErrorInvalidComponent; + else + ret = OMX_ErrorNone; + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_ComponentLoad(SEC_OMX_COMPONENT *sec_component) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_HANDLETYPE libHandle; + OMX_COMPONENTTYPE *pOMXComponent; + + FunctionIn(); + + OMX_ERRORTYPE (*SEC_OMX_ComponentInit)(OMX_HANDLETYPE hComponent, OMX_STRING componentName); + + libHandle = SEC_OSAL_dlopen(sec_component->libName, RTLD_NOW); + if (!libHandle) { + ret = OMX_ErrorInvalidComponentName; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInvalidComponentName, Line:%d", __LINE__); + goto EXIT; + } + + SEC_OMX_ComponentInit = SEC_OSAL_dlsym(libHandle, "SEC_OMX_ComponentInit"); + if (!SEC_OMX_ComponentInit) { + SEC_OSAL_dlclose(libHandle); + ret = OMX_ErrorInvalidComponent; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInvalidComponent, Line:%d", __LINE__); + goto EXIT; + } + + pOMXComponent = (OMX_COMPONENTTYPE *)SEC_OSAL_Malloc(sizeof(OMX_COMPONENTTYPE)); + INIT_SET_SIZE_VERSION(pOMXComponent, OMX_COMPONENTTYPE); + ret = (*SEC_OMX_ComponentInit)((OMX_HANDLETYPE)pOMXComponent, sec_component->componentName); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Free(pOMXComponent); + SEC_OSAL_dlclose(libHandle); + ret = OMX_ErrorInvalidComponent; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInvalidComponent, Line:%d", __LINE__); + goto EXIT; + } else { + if (SEC_OMX_ComponentAPICheck(*pOMXComponent) != OMX_ErrorNone) { + SEC_OSAL_Free(pOMXComponent); + SEC_OSAL_dlclose(libHandle); + if (NULL != pOMXComponent->ComponentDeInit) + pOMXComponent->ComponentDeInit(pOMXComponent); + ret = OMX_ErrorInvalidComponent; + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInvalidComponent, Line:%d", __LINE__); + goto EXIT; + } + sec_component->libHandle = libHandle; + sec_component->pOMXComponent = pOMXComponent; + ret = OMX_ErrorNone; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OMX_ComponentUnload(SEC_OMX_COMPONENT *sec_component) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + + FunctionIn(); + + if (!sec_component) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + pOMXComponent = sec_component->pOMXComponent; + if (pOMXComponent != NULL) { + pOMXComponent->ComponentDeInit(pOMXComponent); + SEC_OSAL_Free(pOMXComponent); + sec_component->pOMXComponent = NULL; + } + + if (sec_component->libHandle != NULL) { + SEC_OSAL_dlclose(sec_component->libHandle); + sec_component->libHandle = NULL; + } + +EXIT: + FunctionOut(); + + return ret; +} diff --git a/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.h b/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.h new file mode 100644 index 0000000..66580bd --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Component_Register.h @@ -0,0 +1,75 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Component_Register.h + * @brief SEC OpenMAX IL Component Register + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_COMPONENT_REG +#define SEC_OMX_COMPONENT_REG + +#include "SEC_OMX_Def.h" +#include "OMX_Types.h" +#include "OMX_Core.h" +#include "OMX_Component.h" + + +typedef struct _SECRegisterComponentType +{ + OMX_U8 componentName[MAX_OMX_COMPONENT_NAME_SIZE]; + OMX_U8 roles[MAX_OMX_COMPONENT_ROLE_NUM][MAX_OMX_COMPONENT_ROLE_SIZE]; + OMX_U32 totalRoleNum; +} SECRegisterComponentType; + +typedef struct _SEC_OMX_COMPONENT_REGLIST +{ + SECRegisterComponentType component; + OMX_U8 libName[MAX_OMX_COMPONENT_LIBNAME_SIZE]; +} SEC_OMX_COMPONENT_REGLIST; + +struct SEC_OMX_COMPONENT; +typedef struct _SEC_OMX_COMPONENT +{ + OMX_U8 componentName[MAX_OMX_COMPONENT_NAME_SIZE]; + OMX_U8 libName[MAX_OMX_COMPONENT_LIBNAME_SIZE]; + OMX_HANDLETYPE libHandle; + OMX_COMPONENTTYPE *pOMXComponent; + struct SEC_OMX_COMPONENT *nextOMXComp; +} SEC_OMX_COMPONENT; + + +#ifdef __cplusplus +extern "C" { +#endif + + +OMX_ERRORTYPE SEC_OMX_Component_Register(SEC_OMX_COMPONENT_REGLIST **compList, OMX_U32 *compNum); +OMX_ERRORTYPE SEC_OMX_Component_Unregister(SEC_OMX_COMPONENT_REGLIST *componentList); +OMX_ERRORTYPE SEC_OMX_ComponentLoad(SEC_OMX_COMPONENT *sec_component); +OMX_ERRORTYPE SEC_OMX_ComponentUnload(SEC_OMX_COMPONENT *sec_component); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.c b/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.c new file mode 100644 index 0000000..fe84d8d --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.c @@ -0,0 +1,354 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Core.c + * @brief SEC OpenMAX IL Core + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * HyeYeon Chung (hyeon.chung@samsung.com) + * Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include + +#include "SEC_OMX_Core.h" +#include "SEC_OMX_Component_Register.h" +#include "SEC_OSAL_Memory.h" +#include "SEC_OMX_Resourcemanager.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_OMX_CORE" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +static int gInitialized = 0; +static int gComponentNum = 0; + +static SEC_OMX_COMPONENT_REGLIST *gComponentList = NULL; +static SEC_OMX_COMPONENT *gLoadComponentList = NULL; +static OMX_HANDLETYPE ghLoadComponentListMutex = NULL; + + +OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_Init(void) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + + FunctionIn(); + + if (gInitialized == 0) { + if (SEC_OMX_Component_Register(&gComponentList, &gComponentNum)) { + ret = OMX_ErrorInsufficientResources; + SEC_OSAL_Log(SEC_LOG_ERROR, "SEC_OMX_Init : %s", "OMX_ErrorInsufficientResources"); + goto EXIT; + } + + SEC_OMX_ResourceManager_Init(); + + SEC_OSAL_MutexCreate(&ghLoadComponentListMutex); + + gInitialized = 1; + SEC_OSAL_Log(SEC_LOG_TRACE, "SEC_OMX_Init : %s", "OMX_ErrorNone"); + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_Deinit(void) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + + FunctionIn(); + + SEC_OSAL_MutexTerminate(ghLoadComponentListMutex); + ghLoadComponentListMutex = NULL; + + SEC_OMX_ResourceManager_Deinit(); + + if (OMX_ErrorNone != SEC_OMX_Component_Unregister(gComponentList)) { + ret = OMX_ErrorUndefined; + goto EXIT; + } + gComponentList = NULL; + gComponentNum = 0; + gInitialized = 0; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_ComponentNameEnum( + OMX_OUT OMX_STRING cComponentName, + OMX_IN OMX_U32 nNameLength, + OMX_IN OMX_U32 nIndex) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + + FunctionIn(); + + if (nIndex >= gComponentNum) { + ret = OMX_ErrorNoMore; + goto EXIT; + } + + sprintf(cComponentName, "%s", gComponentList[nIndex].component.componentName); + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_GetHandle( + OMX_OUT OMX_HANDLETYPE *pHandle, + OMX_IN OMX_STRING cComponentName, + OMX_IN OMX_PTR pAppData, + OMX_IN OMX_CALLBACKTYPE *pCallBacks) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_COMPONENT *loadComponent; + SEC_OMX_COMPONENT *currentComponent; + int i = 0; + + FunctionIn(); + + if (gInitialized != 1) { + ret = OMX_ErrorNotReady; + goto EXIT; + } + + if ((pHandle == NULL) || (cComponentName == NULL) || (pCallBacks == NULL)) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + SEC_OSAL_Log(SEC_LOG_TRACE, "ComponentName : %s", cComponentName); + + for (i = 0; i < gComponentNum; i++) { + if (SEC_OSAL_Strcmp(cComponentName, gComponentList[i].component.componentName) == 0) { + loadComponent = SEC_OSAL_Malloc(sizeof(SEC_OMX_COMPONENT)); + SEC_OSAL_Memset(loadComponent, 0, sizeof(SEC_OMX_COMPONENT)); + + SEC_OSAL_Strcpy(loadComponent->libName, gComponentList[i].libName); + SEC_OSAL_Strcpy(loadComponent->componentName, gComponentList[i].component.componentName); + ret = SEC_OMX_ComponentLoad(loadComponent); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Free(loadComponent); + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); + goto EXIT; + } + + ret = loadComponent->pOMXComponent->SetCallbacks(loadComponent->pOMXComponent, pCallBacks, pAppData); + if (ret != OMX_ErrorNone) { + SEC_OMX_ComponentUnload(loadComponent); + SEC_OSAL_Free(loadComponent); + SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); + goto EXIT; + } + + SEC_OSAL_MutexLock(ghLoadComponentListMutex); + if (gLoadComponentList == NULL) { + gLoadComponentList = loadComponent; + } else { + currentComponent = gLoadComponentList; + while (currentComponent->nextOMXComp != NULL) { + currentComponent = currentComponent->nextOMXComp; + } + currentComponent->nextOMXComp = loadComponent; + } + SEC_OSAL_MutexUnlock(ghLoadComponentListMutex); + + *pHandle = loadComponent->pOMXComponent; + ret = OMX_ErrorNone; + SEC_OSAL_Log(SEC_LOG_TRACE, "SEC_OMX_GetHandle : %s", "OMX_ErrorNone"); + goto EXIT; + } + } + + ret = OMX_ErrorComponentNotFound; + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_OMX_COMPONENT *currentComponent; + SEC_OMX_COMPONENT *deleteComponent; + + FunctionIn(); + + if (gInitialized != 1) { + ret = OMX_ErrorNotReady; + goto EXIT; + } + + if (!hComponent) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + SEC_OSAL_MutexLock(ghLoadComponentListMutex); + currentComponent = gLoadComponentList; + if (gLoadComponentList->pOMXComponent == hComponent) { + deleteComponent = gLoadComponentList; + gLoadComponentList = gLoadComponentList->nextOMXComp; + } else { + while ((currentComponent != NULL) && (((SEC_OMX_COMPONENT *)(currentComponent->nextOMXComp))->pOMXComponent != hComponent)) + currentComponent = currentComponent->nextOMXComp; + + if (((SEC_OMX_COMPONENT *)(currentComponent->nextOMXComp))->pOMXComponent == hComponent) { + deleteComponent = currentComponent->nextOMXComp; + currentComponent->nextOMXComp = deleteComponent->nextOMXComp; + } else if (currentComponent == NULL) { + ret = OMX_ErrorComponentNotFound; + SEC_OSAL_MutexUnlock(ghLoadComponentListMutex); + goto EXIT; + } + } + SEC_OSAL_MutexUnlock(ghLoadComponentListMutex); + + SEC_OMX_ComponentUnload(deleteComponent); + SEC_OSAL_Free(deleteComponent); + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_SetupTunnel( + OMX_IN OMX_HANDLETYPE hOutput, + OMX_IN OMX_U32 nPortOutput, + OMX_IN OMX_HANDLETYPE hInput, + OMX_IN OMX_U32 nPortInput) +{ + OMX_ERRORTYPE ret = OMX_ErrorNotImplemented; + +EXIT: + return ret; +} + +OMX_API OMX_ERRORTYPE SEC_OMX_GetContentPipe( + OMX_OUT OMX_HANDLETYPE *hPipe, + OMX_IN OMX_STRING szURI) +{ + OMX_ERRORTYPE ret = OMX_ErrorNotImplemented; + +EXIT: + return ret; +} + +OMX_API OMX_ERRORTYPE SEC_OMX_GetComponentsOfRole ( + OMX_IN OMX_STRING role, + OMX_INOUT OMX_U32 *pNumComps, + OMX_INOUT OMX_U8 **compNames) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + int max_role_num = 0; + OMX_STRING RoleString[MAX_OMX_COMPONENT_ROLE_SIZE]; + int i = 0, j = 0; + + FunctionIn(); + + if (gInitialized != 1) { + ret = OMX_ErrorNotReady; + goto EXIT; + } + + *pNumComps = 0; + + for (i = 0; i < MAX_OMX_COMPONENT_NUM; i++) { + max_role_num = gComponentList[i].component.totalRoleNum; + + for (j = 0; j < max_role_num; j++) { + if (SEC_OSAL_Strcmp(gComponentList[i].component.roles[j], role) == 0) { + if (compNames != NULL) { + SEC_OSAL_Strcpy((OMX_STRING)compNames[*pNumComps], gComponentList[i].component.componentName); + } + *pNumComps = (*pNumComps + 1); + } + } + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_API OMX_ERRORTYPE SEC_OMX_GetRolesOfComponent ( + OMX_IN OMX_STRING compName, + OMX_INOUT OMX_U32 *pNumRoles, + OMX_OUT OMX_U8 **roles) +{ + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_BOOL detectComp = OMX_FALSE; + int compNum = 0, totalRoleNum = 0; + int i = 0; + + FunctionIn(); + + if (gInitialized != 1) { + ret = OMX_ErrorNotReady; + goto EXIT; + } + + for (i = 0; i < MAX_OMX_COMPONENT_NUM; i++) { + if (gComponentList != NULL) { + if (SEC_OSAL_Strcmp(gComponentList[i].component.componentName, compName) == 0) { + *pNumRoles = totalRoleNum = gComponentList[i].component.totalRoleNum; + compNum = i; + detectComp = OMX_TRUE; + break; + } + } else { + ret = OMX_ErrorUndefined; + goto EXIT; + } + } + + if (detectComp == OMX_FALSE) { + *pNumRoles = 0; + ret = OMX_ErrorComponentNotFound; + goto EXIT; + } + + if (roles != NULL) { + for (i = 0; i < totalRoleNum; i++) { + SEC_OSAL_Strcpy(roles[i], gComponentList[compNum].component.roles[i]); + } + } + +EXIT: + FunctionOut(); + + return ret; +} diff --git a/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.h b/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.h new file mode 100644 index 0000000..87f561c --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_core/SEC_OMX_Core.h @@ -0,0 +1,78 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Core.h + * @brief SEC OpenMAX IL Core + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * HyeYeon Chung (hyeon.chung@samsung.com) + * Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_CORE +#define SEC_OMX_CORE + +#include "SEC_OMX_Def.h" +#include "OMX_Types.h" +#include "OMX_Core.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +SEC_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_Init(void); +SEC_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_Deinit(void); +SEC_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_ComponentNameEnum( + OMX_OUT OMX_STRING cComponentName, + OMX_IN OMX_U32 nNameLength, + OMX_IN OMX_U32 nIndex); +SEC_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_GetHandle( + OMX_OUT OMX_HANDLETYPE *pHandle, + OMX_IN OMX_STRING cComponentName, + OMX_IN OMX_PTR pAppData, + OMX_IN OMX_CALLBACKTYPE *pCallBacks); +SEC_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_FreeHandle( + OMX_IN OMX_HANDLETYPE hComponent); +SEC_EXPORT_REF OMX_API OMX_ERRORTYPE OMX_APIENTRY SEC_OMX_SetupTunnel( + OMX_IN OMX_HANDLETYPE hOutput, + OMX_IN OMX_U32 nPortOutput, + OMX_IN OMX_HANDLETYPE hInput, + OMX_IN OMX_U32 nPortInput); +SEC_EXPORT_REF OMX_API OMX_ERRORTYPE SEC_OMX_GetContentPipe( + OMX_OUT OMX_HANDLETYPE *hPipe, + OMX_IN OMX_STRING szURI); +SEC_EXPORT_REF OMX_API OMX_ERRORTYPE SEC_OMX_GetComponentsOfRole( + OMX_IN OMX_STRING role, + OMX_INOUT OMX_U32 *pNumComps, + OMX_INOUT OMX_U8 **compNames); +SEC_EXPORT_REF OMX_API OMX_ERRORTYPE SEC_OMX_GetRolesOfComponent( + OMX_IN OMX_STRING compName, + OMX_INOUT OMX_U32 *pNumRoles, + OMX_OUT OMX_U8 **roles); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/sec_mm/sec_omx/sec_omx_core/secomxregistry b/sec_mm/sec_omx/sec_omx_core/secomxregistry new file mode 100644 index 0000000..cc762e6 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_core/secomxregistry @@ -0,0 +1,4 @@ +libOMX.SEC.AVC.Decoder.aries.so +libOMX.SEC.M4V.Decoder.aries.so +libOMX.SEC.AVC.Encoder.aries.so +libOMX.SEC.M4V.Encoder.aries.so diff --git a/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Audio.h b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Audio.h new file mode 100644 index 0000000..04f1a99 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Audio.h @@ -0,0 +1,1311 @@ +/* + * Copyright (c) 2008 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. + * + */ + +/** @file OMX_Audio.h - OpenMax IL version 1.1.2 + * The structures needed by Audio components to exchange + * parameters and configuration data with the componenmilts. + */ + +#ifndef OMX_Audio_h +#define OMX_Audio_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 + +/** @defgroup midi MIDI + * @ingroup audio + */ + +/** @defgroup effects Audio effects + * @ingroup audio + */ + +/** @defgroup audio OpenMAX IL Audio Domain + * Structures for OpenMAX IL Audio domain + * @{ + */ + +/** Enumeration used to define the possible audio codings. + * If "OMX_AUDIO_CodingUnused" is selected, the coding selection must + * be done in a vendor specific way. Since this is for an audio + * processing element this enum is relevant. However, for another + * type of component other enums would be in this area. + */ +typedef enum OMX_AUDIO_CODINGTYPE { + OMX_AUDIO_CodingUnused = 0, /**< Placeholder value when coding is N/A */ + OMX_AUDIO_CodingAutoDetect, /**< auto detection of audio format */ + OMX_AUDIO_CodingPCM, /**< Any variant of PCM coding */ + OMX_AUDIO_CodingADPCM, /**< Any variant of ADPCM encoded data */ + OMX_AUDIO_CodingAMR, /**< Any variant of AMR encoded data */ + OMX_AUDIO_CodingGSMFR, /**< Any variant of GSM fullrate (i.e. GSM610) */ + OMX_AUDIO_CodingGSMEFR, /**< Any variant of GSM Enhanced Fullrate encoded data*/ + OMX_AUDIO_CodingGSMHR, /**< Any variant of GSM Halfrate encoded data */ + OMX_AUDIO_CodingPDCFR, /**< Any variant of PDC Fullrate encoded data */ + OMX_AUDIO_CodingPDCEFR, /**< Any variant of PDC Enhanced Fullrate encoded data */ + OMX_AUDIO_CodingPDCHR, /**< Any variant of PDC Halfrate encoded data */ + OMX_AUDIO_CodingTDMAFR, /**< Any variant of TDMA Fullrate encoded data (TIA/EIA-136-420) */ + OMX_AUDIO_CodingTDMAEFR, /**< Any variant of TDMA Enhanced Fullrate encoded data (TIA/EIA-136-410) */ + OMX_AUDIO_CodingQCELP8, /**< Any variant of QCELP 8kbps encoded data */ + OMX_AUDIO_CodingQCELP13, /**< Any variant of QCELP 13kbps encoded data */ + OMX_AUDIO_CodingEVRC, /**< Any variant of EVRC encoded data */ + OMX_AUDIO_CodingSMV, /**< Any variant of SMV encoded data */ + OMX_AUDIO_CodingG711, /**< Any variant of G.711 encoded data */ + OMX_AUDIO_CodingG723, /**< Any variant of G.723 dot 1 encoded data */ + OMX_AUDIO_CodingG726, /**< Any variant of G.726 encoded data */ + OMX_AUDIO_CodingG729, /**< Any variant of G.729 encoded data */ + OMX_AUDIO_CodingAAC, /**< Any variant of AAC encoded data */ + OMX_AUDIO_CodingMP3, /**< Any variant of MP3 encoded data */ + OMX_AUDIO_CodingSBC, /**< Any variant of SBC encoded data */ + OMX_AUDIO_CodingVORBIS, /**< Any variant of VORBIS encoded data */ + OMX_AUDIO_CodingWMA, /**< Any variant of WMA encoded data */ + OMX_AUDIO_CodingRA, /**< Any variant of RA encoded data */ + OMX_AUDIO_CodingMIDI, /**< Any variant of MIDI encoded data */ + OMX_AUDIO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_CodingMax = 0x7FFFFFFF +} OMX_AUDIO_CODINGTYPE; + + +/** The PortDefinition structure is used to define all of the parameters + * necessary for the compliant component to setup an input or an output audio + * path. If additional information is needed to define the parameters of the + * port (such as frequency), additional structures must be sent such as the + * OMX_AUDIO_PARAM_PCMMODETYPE structure to supply the extra parameters for the port. + */ +typedef struct OMX_AUDIO_PORTDEFINITIONTYPE { + OMX_STRING cMIMEType; /**< MIME type of data for the port */ + OMX_NATIVE_DEVICETYPE pNativeRender; /** < platform specific reference + for an output device, + otherwise this field is 0 */ + OMX_BOOL bFlagErrorConcealment; /**< Turns on error concealment if it is + supported by the OMX component */ + OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this + port (e.g. PCM, AMR, MP3, etc) */ +} OMX_AUDIO_PORTDEFINITIONTYPE; + + +/** Port format parameter. This structure is used to enumerate + * the various data input/output format supported by the port. + */ +typedef struct OMX_AUDIO_PARAM_PORTFORMATTYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nPortIndex; /**< Indicates which port to set */ + OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */ + OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this port (e.g. PCM, AMR, MP3, etc) */ +} OMX_AUDIO_PARAM_PORTFORMATTYPE; + + +/** PCM mode type */ +typedef enum OMX_AUDIO_PCMMODETYPE { + OMX_AUDIO_PCMModeLinear = 0, /**< Linear PCM encoded data */ + OMX_AUDIO_PCMModeALaw, /**< A law PCM encoded data (G.711) */ + OMX_AUDIO_PCMModeMULaw, /**< Mu law PCM encoded data (G.711) */ + OMX_AUDIO_PCMModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_PCMModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_PCMModeMax = 0x7FFFFFFF +} OMX_AUDIO_PCMMODETYPE; + + +typedef enum OMX_AUDIO_CHANNELTYPE { + OMX_AUDIO_ChannelNone = 0x0, /**< Unused or empty */ + OMX_AUDIO_ChannelLF = 0x1, /**< Left front */ + OMX_AUDIO_ChannelRF = 0x2, /**< Right front */ + OMX_AUDIO_ChannelCF = 0x3, /**< Center front */ + OMX_AUDIO_ChannelLS = 0x4, /**< Left surround */ + OMX_AUDIO_ChannelRS = 0x5, /**< Right surround */ + OMX_AUDIO_ChannelLFE = 0x6, /**< Low frequency effects */ + OMX_AUDIO_ChannelCS = 0x7, /**< Back surround */ + OMX_AUDIO_ChannelLR = 0x8, /**< Left rear. */ + OMX_AUDIO_ChannelRR = 0x9, /**< Right rear. */ + OMX_AUDIO_ChannelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_ChannelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_ChannelMax = 0x7FFFFFFF +} OMX_AUDIO_CHANNELTYPE; + +#define OMX_AUDIO_MAXCHANNELS 16 /**< maximum number distinct audio channels that a buffer may contain */ +#define OMX_MIN_PCMPAYLOAD_MSEC 5 /**< Minimum audio buffer payload size for uncompressed (PCM) audio */ + +/** PCM format description */ +typedef struct OMX_AUDIO_PARAM_PCMMODETYPE { + OMX_U32 nSize; /**< Size of this structure, in Bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nPortIndex; /**< port that this structure applies to */ + OMX_U32 nChannels; /**< Number of channels (e.g. 2 for stereo) */ + OMX_NUMERICALDATATYPE eNumData; /**< indicates PCM data as signed or unsigned */ + OMX_ENDIANTYPE eEndian; /**< indicates PCM data as little or big endian */ + OMX_BOOL bInterleaved; /**< True for normal interleaved data; false for + non-interleaved data (e.g. block data) */ + OMX_U32 nBitPerSample; /**< Bit per sample */ + OMX_U32 nSamplingRate; /**< Sampling rate of the source data. Use 0 for + variable or unknown sampling rate. */ + OMX_AUDIO_PCMMODETYPE ePCMMode; /**< PCM mode enumeration */ + OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMap[i] */ + +} OMX_AUDIO_PARAM_PCMMODETYPE; + + +/** Audio channel mode. This is used by both AAC and MP3, although the names are more appropriate + * for the MP3. For example, JointStereo for MP3 is CouplingChannels for AAC. + */ +typedef enum OMX_AUDIO_CHANNELMODETYPE { + OMX_AUDIO_ChannelModeStereo = 0, /**< 2 channels, the bitrate allocation between those + two channels changes accordingly to each channel information */ + OMX_AUDIO_ChannelModeJointStereo, /**< mode that takes advantage of what is common between + 2 channels for higher compression gain */ + OMX_AUDIO_ChannelModeDual, /**< 2 mono-channels, each channel is encoded with half + the bitrate of the overall bitrate */ + OMX_AUDIO_ChannelModeMono, /**< Mono channel mode */ + OMX_AUDIO_ChannelModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_ChannelModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_ChannelModeMax = 0x7FFFFFFF +} OMX_AUDIO_CHANNELMODETYPE; + + +typedef enum OMX_AUDIO_MP3STREAMFORMATTYPE { + OMX_AUDIO_MP3StreamFormatMP1Layer3 = 0, /**< MP3 Audio MPEG 1 Layer 3 Stream format */ + OMX_AUDIO_MP3StreamFormatMP2Layer3, /**< MP3 Audio MPEG 2 Layer 3 Stream format */ + OMX_AUDIO_MP3StreamFormatMP2_5Layer3, /**< MP3 Audio MPEG2.5 Layer 3 Stream format */ + OMX_AUDIO_MP3StreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_MP3StreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_MP3StreamFormatMax = 0x7FFFFFFF +} OMX_AUDIO_MP3STREAMFORMATTYPE; + +/** MP3 params */ +typedef struct OMX_AUDIO_PARAM_MP3TYPE { + 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_U32 nChannels; /**< Number of channels */ + OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable + rate or unknown bit rates */ + OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for + variable or unknown sampling rate. */ + OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should + limit the audio signal. Use 0 to let encoder decide */ + OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */ + OMX_AUDIO_MP3STREAMFORMATTYPE eFormat; /**< MP3 stream format */ +} OMX_AUDIO_PARAM_MP3TYPE; + + +typedef enum OMX_AUDIO_AACSTREAMFORMATTYPE { + OMX_AUDIO_AACStreamFormatMP2ADTS = 0, /**< AAC Audio Data Transport Stream 2 format */ + OMX_AUDIO_AACStreamFormatMP4ADTS, /**< AAC Audio Data Transport Stream 4 format */ + OMX_AUDIO_AACStreamFormatMP4LOAS, /**< AAC Low Overhead Audio Stream format */ + OMX_AUDIO_AACStreamFormatMP4LATM, /**< AAC Low overhead Audio Transport Multiplex */ + OMX_AUDIO_AACStreamFormatADIF, /**< AAC Audio Data Interchange Format */ + OMX_AUDIO_AACStreamFormatMP4FF, /**< AAC inside MPEG-4/ISO File Format */ + OMX_AUDIO_AACStreamFormatRAW, /**< AAC Raw Format */ + OMX_AUDIO_AACStreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_AACStreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_AACStreamFormatMax = 0x7FFFFFFF +} OMX_AUDIO_AACSTREAMFORMATTYPE; + + +/** AAC mode type. Note that the term profile is used with the MPEG-2 + * standard and the term object type and profile is used with MPEG-4 */ +typedef enum OMX_AUDIO_AACPROFILETYPE{ + OMX_AUDIO_AACObjectNull = 0, /**< Null, not used */ + OMX_AUDIO_AACObjectMain = 1, /**< AAC Main object */ + OMX_AUDIO_AACObjectLC, /**< AAC Low Complexity object (AAC profile) */ + OMX_AUDIO_AACObjectSSR, /**< AAC Scalable Sample Rate object */ + OMX_AUDIO_AACObjectLTP, /**< AAC Long Term Prediction object */ + OMX_AUDIO_AACObjectHE, /**< AAC High Efficiency (object type SBR, HE-AAC profile) */ + OMX_AUDIO_AACObjectScalable, /**< AAC Scalable object */ + OMX_AUDIO_AACObjectERLC = 17, /**< ER AAC Low Complexity object (Error Resilient AAC-LC) */ + OMX_AUDIO_AACObjectLD = 23, /**< AAC Low Delay object (Error Resilient) */ + OMX_AUDIO_AACObjectHE_PS = 29, /**< AAC High Efficiency with Parametric Stereo coding (HE-AAC v2, object type PS) */ + OMX_AUDIO_AACObjectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_AACObjectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_AACObjectMax = 0x7FFFFFFF +} OMX_AUDIO_AACPROFILETYPE; + + +/** AAC tool usage (for nAACtools in OMX_AUDIO_PARAM_AACPROFILETYPE). + * Required for encoder configuration and optional as decoder info output. + * For MP3, OMX_AUDIO_CHANNELMODETYPE is sufficient. */ +#define OMX_AUDIO_AACToolNone 0x00000000 /**< no AAC tools allowed (encoder config) or active (decoder info output) */ +#define OMX_AUDIO_AACToolMS 0x00000001 /**< MS: Mid/side joint coding tool allowed or active */ +#define OMX_AUDIO_AACToolIS 0x00000002 /**< IS: Intensity stereo tool allowed or active */ +#define OMX_AUDIO_AACToolTNS 0x00000004 /**< TNS: Temporal Noise Shaping tool allowed or active */ +#define OMX_AUDIO_AACToolPNS 0x00000008 /**< PNS: MPEG-4 Perceptual Noise substitution tool allowed or active */ +#define OMX_AUDIO_AACToolLTP 0x00000010 /**< LTP: MPEG-4 Long Term Prediction tool allowed or active */ +#define OMX_AUDIO_AACToolAll 0x7FFFFFFF /**< all AAC tools allowed or active (*/ + +/** MPEG-4 AAC error resilience (ER) tool usage (for nAACERtools in OMX_AUDIO_PARAM_AACPROFILETYPE). + * Required for ER encoder configuration and optional as decoder info output */ +#define OMX_AUDIO_AACERNone 0x00000000 /**< no AAC ER tools allowed/used */ +#define OMX_AUDIO_AACERVCB11 0x00000001 /**< VCB11: Virtual Code Books for AAC section data */ +#define OMX_AUDIO_AACERRVLC 0x00000002 /**< RVLC: Reversible Variable Length Coding */ +#define OMX_AUDIO_AACERHCR 0x00000004 /**< HCR: Huffman Codeword Reordering */ +#define OMX_AUDIO_AACERAll 0x7FFFFFFF /**< all AAC ER tools allowed/used */ + + +/** AAC params */ +typedef struct OMX_AUDIO_PARAM_AACPROFILETYPE { + OMX_U32 nSize; /**< Size of this structure, in Bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nPortIndex; /**< Port that this structure applies to */ + OMX_U32 nChannels; /**< Number of channels */ + OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for + variable or unknown sampling rate. */ + OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable + rate or unknown bit rates */ + OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should + limit the audio signal. Use 0 to let encoder decide */ + OMX_U32 nFrameLength; /**< Frame length (in audio samples per channel) of the codec. + Can be 1024 or 960 (AAC-LC), 2048 (HE-AAC), 480 or 512 (AAC-LD). + Use 0 to let encoder decide */ + OMX_U32 nAACtools; /**< AAC tool usage */ + OMX_U32 nAACERtools; /**< MPEG-4 AAC error resilience tool usage */ + OMX_AUDIO_AACPROFILETYPE eAACProfile; /**< AAC profile enumeration */ + OMX_AUDIO_AACSTREAMFORMATTYPE eAACStreamFormat; /**< AAC stream format enumeration */ + OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */ +} OMX_AUDIO_PARAM_AACPROFILETYPE; + + +/** VORBIS params */ +typedef struct OMX_AUDIO_PARAM_VORBISTYPE { + 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_U32 nChannels; /**< Number of channels */ + OMX_U32 nBitRate; /**< Bit rate of the encoded data data. Use 0 for variable + rate or unknown bit rates. Encoding is set to the + bitrate closest to specified value (in bps) */ + OMX_U32 nMinBitRate; /**< Sets minimum bitrate (in bps). */ + OMX_U32 nMaxBitRate; /**< Sets maximum bitrate (in bps). */ + + OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for + variable or unknown sampling rate. */ + OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should + limit the audio signal. Use 0 to let encoder decide */ + OMX_S32 nQuality; /**< Sets encoding quality to n, between -1 (low) and 10 (high). + In the default mode of operation, teh quality level is 3. + Normal quality range is 0 - 10. */ + OMX_BOOL bManaged; /**< Set bitrate management mode. This turns off the + normal VBR encoding, but allows hard or soft bitrate + constraints to be enforced by the encoder. This mode can + be slower, and may also be lower quality. It is + primarily useful for streaming. */ + OMX_BOOL bDownmix; /**< Downmix input from stereo to mono (has no effect on + non-stereo streams). Useful for lower-bitrate encoding. */ +} OMX_AUDIO_PARAM_VORBISTYPE; + + +/** WMA Version */ +typedef enum OMX_AUDIO_WMAFORMATTYPE { + OMX_AUDIO_WMAFormatUnused = 0, /**< format unused or unknown */ + OMX_AUDIO_WMAFormat7, /**< Windows Media Audio format 7 */ + OMX_AUDIO_WMAFormat8, /**< Windows Media Audio format 8 */ + OMX_AUDIO_WMAFormat9, /**< Windows Media Audio format 9 */ + OMX_AUDIO_WMAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_WMAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_WMAFormatMax = 0x7FFFFFFF +} OMX_AUDIO_WMAFORMATTYPE; + + +/** WMA Profile */ +typedef enum OMX_AUDIO_WMAPROFILETYPE { + OMX_AUDIO_WMAProfileUnused = 0, /**< profile unused or unknown */ + OMX_AUDIO_WMAProfileL1, /**< Windows Media audio version 9 profile L1 */ + OMX_AUDIO_WMAProfileL2, /**< Windows Media audio version 9 profile L2 */ + OMX_AUDIO_WMAProfileL3, /**< Windows Media audio version 9 profile L3 */ + OMX_AUDIO_WMAProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_WMAProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_WMAProfileMax = 0x7FFFFFFF +} OMX_AUDIO_WMAPROFILETYPE; + + +/** WMA params */ +typedef struct OMX_AUDIO_PARAM_WMATYPE { + 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_U16 nChannels; /**< Number of channels */ + OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable + rate or unknown bit rates */ + OMX_AUDIO_WMAFORMATTYPE eFormat; /**< Version of WMA stream / data */ + OMX_AUDIO_WMAPROFILETYPE eProfile; /**< Profile of WMA stream / data */ + OMX_U32 nSamplingRate; /**< Sampling rate of the source data */ + OMX_U16 nBlockAlign; /**< is the block alignment, or block size, in bytes of the audio codec */ + OMX_U16 nEncodeOptions; /**< WMA Type-specific data */ + OMX_U32 nSuperBlockAlign; /**< WMA Type-specific data */ +} OMX_AUDIO_PARAM_WMATYPE; + +/** + * RealAudio format + */ +typedef enum OMX_AUDIO_RAFORMATTYPE { + OMX_AUDIO_RAFormatUnused = 0, /**< Format unused or unknown */ + OMX_AUDIO_RA8, /**< RealAudio 8 codec */ + OMX_AUDIO_RA9, /**< RealAudio 9 codec */ + OMX_AUDIO_RA10_AAC, /**< MPEG-4 AAC codec for bitrates of more than 128kbps */ + OMX_AUDIO_RA10_CODEC, /**< RealAudio codec for bitrates less than 128 kbps */ + OMX_AUDIO_RA10_LOSSLESS, /**< RealAudio Lossless */ + OMX_AUDIO_RA10_MULTICHANNEL, /**< RealAudio Multichannel */ + OMX_AUDIO_RA10_VOICE, /**< RealAudio Voice for bitrates below 15 kbps */ + OMX_AUDIO_RAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_RAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_RAFormatMax = 0x7FFFFFFF +} OMX_AUDIO_RAFORMATTYPE; + +/** RA (Real Audio) params */ +typedef struct OMX_AUDIO_PARAM_RATYPE { + OMX_U32 nSize; /**< Size of this structure, in Bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nPortIndex; /**< Port that this structure applies to */ + OMX_U32 nChannels; /**< Number of channels */ + OMX_U32 nSamplingRate; /**< is the sampling rate of the source data */ + OMX_U32 nBitsPerFrame; /**< is the value for bits per frame */ + OMX_U32 nSamplePerFrame; /**< is the value for samples per frame */ + OMX_U32 nCouplingQuantBits; /**< is the number of coupling quantization bits in the stream */ + OMX_U32 nCouplingStartRegion; /**< is the coupling start region in the stream */ + OMX_U32 nNumRegions; /**< is the number of regions value */ + OMX_AUDIO_RAFORMATTYPE eFormat; /**< is the RealAudio audio format */ +} OMX_AUDIO_PARAM_RATYPE; + + +/** SBC Allocation Method Type */ +typedef enum OMX_AUDIO_SBCALLOCMETHODTYPE { + OMX_AUDIO_SBCAllocMethodLoudness, /**< Loudness allocation method */ + OMX_AUDIO_SBCAllocMethodSNR, /**< SNR allocation method */ + OMX_AUDIO_SBCAllocMethodKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_SBCAllocMethodVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_SBCAllocMethodMax = 0x7FFFFFFF +} OMX_AUDIO_SBCALLOCMETHODTYPE; + + +/** SBC params */ +typedef struct OMX_AUDIO_PARAM_SBCTYPE { + 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_U32 nChannels; /**< Number of channels */ + OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable + rate or unknown bit rates */ + OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for + variable or unknown sampling rate. */ + OMX_U32 nBlocks; /**< Number of blocks */ + OMX_U32 nSubbands; /**< Number of subbands */ + OMX_U32 nBitPool; /**< Bitpool value */ + OMX_BOOL bEnableBitrate; /**< Use bitrate value instead of bitpool */ + OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */ + OMX_AUDIO_SBCALLOCMETHODTYPE eSBCAllocType; /**< SBC Allocation method type */ +} OMX_AUDIO_PARAM_SBCTYPE; + + +/** ADPCM stream format parameters */ +typedef struct OMX_AUDIO_PARAM_ADPCMTYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_U32 nBitsPerSample; /**< Number of bits in each sample */ + OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for + variable or unknown sampling rate. */ +} OMX_AUDIO_PARAM_ADPCMTYPE; + + +/** G723 rate */ +typedef enum OMX_AUDIO_G723RATE { + OMX_AUDIO_G723ModeUnused = 0, /**< AMRNB Mode unused / unknown */ + OMX_AUDIO_G723ModeLow, /**< 5300 bps */ + OMX_AUDIO_G723ModeHigh, /**< 6300 bps */ + OMX_AUDIO_G723ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_G723ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_G723ModeMax = 0x7FFFFFFF +} OMX_AUDIO_G723RATE; + + +/** G723 - Sample rate must be 8 KHz */ +typedef struct OMX_AUDIO_PARAM_G723TYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ + OMX_AUDIO_G723RATE eBitRate; /**< todo: Should this be moved to a config? */ + OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ + OMX_BOOL bPostFilter; /**< Enable Post Filter */ +} OMX_AUDIO_PARAM_G723TYPE; + + +/** ITU G726 (ADPCM) rate */ +typedef enum OMX_AUDIO_G726MODE { + OMX_AUDIO_G726ModeUnused = 0, /**< G726 Mode unused / unknown */ + OMX_AUDIO_G726Mode16, /**< 16 kbps */ + OMX_AUDIO_G726Mode24, /**< 24 kbps */ + OMX_AUDIO_G726Mode32, /**< 32 kbps, most common rate, also G721 */ + OMX_AUDIO_G726Mode40, /**< 40 kbps */ + OMX_AUDIO_G726ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_G726ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_G726ModeMax = 0x7FFFFFFF +} OMX_AUDIO_G726MODE; + + +/** G.726 stream format parameters - must be at 8KHz */ +typedef struct OMX_AUDIO_PARAM_G726TYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_AUDIO_G726MODE eG726Mode; +} OMX_AUDIO_PARAM_G726TYPE; + + +/** G729 coder type */ +typedef enum OMX_AUDIO_G729TYPE { + OMX_AUDIO_G729 = 0, /**< ITU G.729 encoded data */ + OMX_AUDIO_G729A, /**< ITU G.729 annex A encoded data */ + OMX_AUDIO_G729B, /**< ITU G.729 with annex B encoded data */ + OMX_AUDIO_G729AB, /**< ITU G.729 annexes A and B encoded data */ + OMX_AUDIO_G729KhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_G729VendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_G729Max = 0x7FFFFFFF +} OMX_AUDIO_G729TYPE; + + +/** G729 stream format parameters - fixed 6KHz sample rate */ +typedef struct OMX_AUDIO_PARAM_G729TYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ + OMX_AUDIO_G729TYPE eBitType; +} OMX_AUDIO_PARAM_G729TYPE; + + +/** AMR Frame format */ +typedef enum OMX_AUDIO_AMRFRAMEFORMATTYPE { + OMX_AUDIO_AMRFrameFormatConformance = 0, /**< Frame Format is AMR Conformance + (Standard) Format */ + OMX_AUDIO_AMRFrameFormatIF1, /**< Frame Format is AMR Interface + Format 1 */ + OMX_AUDIO_AMRFrameFormatIF2, /**< Frame Format is AMR Interface + Format 2*/ + OMX_AUDIO_AMRFrameFormatFSF, /**< Frame Format is AMR File Storage + Format */ + OMX_AUDIO_AMRFrameFormatRTPPayload, /**< Frame Format is AMR Real-Time + Transport Protocol Payload Format */ + OMX_AUDIO_AMRFrameFormatITU, /**< Frame Format is ITU Format (added at Motorola request) */ + OMX_AUDIO_AMRFrameFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_AMRFrameFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_AMRFrameFormatMax = 0x7FFFFFFF +} OMX_AUDIO_AMRFRAMEFORMATTYPE; + + +/** AMR band mode */ +typedef enum OMX_AUDIO_AMRBANDMODETYPE { + OMX_AUDIO_AMRBandModeUnused = 0, /**< AMRNB Mode unused / unknown */ + OMX_AUDIO_AMRBandModeNB0, /**< AMRNB Mode 0 = 4750 bps */ + OMX_AUDIO_AMRBandModeNB1, /**< AMRNB Mode 1 = 5150 bps */ + OMX_AUDIO_AMRBandModeNB2, /**< AMRNB Mode 2 = 5900 bps */ + OMX_AUDIO_AMRBandModeNB3, /**< AMRNB Mode 3 = 6700 bps */ + OMX_AUDIO_AMRBandModeNB4, /**< AMRNB Mode 4 = 7400 bps */ + OMX_AUDIO_AMRBandModeNB5, /**< AMRNB Mode 5 = 7950 bps */ + OMX_AUDIO_AMRBandModeNB6, /**< AMRNB Mode 6 = 10200 bps */ + OMX_AUDIO_AMRBandModeNB7, /**< AMRNB Mode 7 = 12200 bps */ + OMX_AUDIO_AMRBandModeWB0, /**< AMRWB Mode 0 = 6600 bps */ + OMX_AUDIO_AMRBandModeWB1, /**< AMRWB Mode 1 = 8850 bps */ + OMX_AUDIO_AMRBandModeWB2, /**< AMRWB Mode 2 = 12650 bps */ + OMX_AUDIO_AMRBandModeWB3, /**< AMRWB Mode 3 = 14250 bps */ + OMX_AUDIO_AMRBandModeWB4, /**< AMRWB Mode 4 = 15850 bps */ + OMX_AUDIO_AMRBandModeWB5, /**< AMRWB Mode 5 = 18250 bps */ + OMX_AUDIO_AMRBandModeWB6, /**< AMRWB Mode 6 = 19850 bps */ + OMX_AUDIO_AMRBandModeWB7, /**< AMRWB Mode 7 = 23050 bps */ + OMX_AUDIO_AMRBandModeWB8, /**< AMRWB Mode 8 = 23850 bps */ + OMX_AUDIO_AMRBandModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_AMRBandModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_AMRBandModeMax = 0x7FFFFFFF +} OMX_AUDIO_AMRBANDMODETYPE; + + +/** AMR Discontinuous Transmission mode */ +typedef enum OMX_AUDIO_AMRDTXMODETYPE { + OMX_AUDIO_AMRDTXModeOff = 0, /**< AMR Discontinuous Transmission Mode is disabled */ + OMX_AUDIO_AMRDTXModeOnVAD1, /**< AMR Discontinuous Transmission Mode using + Voice Activity Detector 1 (VAD1) is enabled */ + OMX_AUDIO_AMRDTXModeOnVAD2, /**< AMR Discontinuous Transmission Mode using + Voice Activity Detector 2 (VAD2) is enabled */ + OMX_AUDIO_AMRDTXModeOnAuto, /**< The codec will automatically select between + Off, VAD1 or VAD2 modes */ + + OMX_AUDIO_AMRDTXasEFR, /**< DTX as EFR instead of AMR standard (3GPP 26.101, frame type =8,9,10) */ + + OMX_AUDIO_AMRDTXModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_AMRDTXModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_AMRDTXModeMax = 0x7FFFFFFF +} OMX_AUDIO_AMRDTXMODETYPE; + + +/** AMR params */ +typedef struct OMX_AUDIO_PARAM_AMRTYPE { + 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_U32 nChannels; /**< Number of channels */ + OMX_U32 nBitRate; /**< Bit rate read only field */ + OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode; /**< AMR Band Mode enumeration */ + OMX_AUDIO_AMRDTXMODETYPE eAMRDTXMode; /**< AMR DTX Mode enumeration */ + OMX_AUDIO_AMRFRAMEFORMATTYPE eAMRFrameFormat; /**< AMR frame format enumeration */ +} OMX_AUDIO_PARAM_AMRTYPE; + + +/** GSM_FR (ETSI 06.10, 3GPP 46.010) stream format parameters */ +typedef struct OMX_AUDIO_PARAM_GSMFRTYPE { + 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_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ + OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ +} OMX_AUDIO_PARAM_GSMFRTYPE; + + +/** GSM-HR (ETSI 06.20, 3GPP 46.020) stream format parameters */ +typedef struct OMX_AUDIO_PARAM_GSMHRTYPE { + 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_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ + OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ +} OMX_AUDIO_PARAM_GSMHRTYPE; + + +/** GSM-EFR (ETSI 06.60, 3GPP 46.060) stream format parameters */ +typedef struct OMX_AUDIO_PARAM_GSMEFRTYPE { + 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_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ + OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ +} OMX_AUDIO_PARAM_GSMEFRTYPE; + + +/** TDMA FR (TIA/EIA-136-420, VSELP 7.95kbps coder) stream format parameters */ +typedef struct OMX_AUDIO_PARAM_TDMAFRTYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ + OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ +} OMX_AUDIO_PARAM_TDMAFRTYPE; + + +/** TDMA EFR (TIA/EIA-136-410, ACELP 7.4kbps coder) stream format parameters */ +typedef struct OMX_AUDIO_PARAM_TDMAEFRTYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ + OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ +} OMX_AUDIO_PARAM_TDMAEFRTYPE; + + +/** PDC FR ( RCR-27, VSELP 6.7kbps coder) stream format parameters */ +typedef struct OMX_AUDIO_PARAM_PDCFRTYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ + OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ +} OMX_AUDIO_PARAM_PDCFRTYPE; + + +/** PDC EFR ( RCR-27, ACELP 6.7kbps coder) stream format parameters */ +typedef struct OMX_AUDIO_PARAM_PDCEFRTYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ + OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ +} OMX_AUDIO_PARAM_PDCEFRTYPE; + +/** PDC HR ( RCR-27, PSI-CELP 3.45kbps coder) stream format parameters */ +typedef struct OMX_AUDIO_PARAM_PDCHRTYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ + OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ +} OMX_AUDIO_PARAM_PDCHRTYPE; + + +/** CDMA Rate types */ +typedef enum OMX_AUDIO_CDMARATETYPE { + OMX_AUDIO_CDMARateBlank = 0, /**< CDMA encoded frame is blank */ + OMX_AUDIO_CDMARateFull, /**< CDMA encoded frame in full rate */ + OMX_AUDIO_CDMARateHalf, /**< CDMA encoded frame in half rate */ + OMX_AUDIO_CDMARateQuarter, /**< CDMA encoded frame in quarter rate */ + OMX_AUDIO_CDMARateEighth, /**< CDMA encoded frame in eighth rate (DTX)*/ + OMX_AUDIO_CDMARateErasure, /**< CDMA erasure frame */ + OMX_AUDIO_CDMARateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_CDMARateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_CDMARateMax = 0x7FFFFFFF +} OMX_AUDIO_CDMARATETYPE; + + +/** QCELP8 (TIA/EIA-96, up to 8kbps coder) stream format parameters */ +typedef struct OMX_AUDIO_PARAM_QCELP8TYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable + rate or unknown bit rates */ + OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */ + OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */ + OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */ +} OMX_AUDIO_PARAM_QCELP8TYPE; + + +/** QCELP13 ( CDMA, EIA/TIA-733, 13.3kbps coder) stream format parameters */ +typedef struct OMX_AUDIO_PARAM_QCELP13TYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */ + OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */ + OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */ +} OMX_AUDIO_PARAM_QCELP13TYPE; + + +/** EVRC ( CDMA, EIA/TIA-127, RCELP up to 8.55kbps coder) stream format parameters */ +typedef struct OMX_AUDIO_PARAM_EVRCTYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_AUDIO_CDMARATETYPE eCDMARate; /**< actual Frame rate */ + OMX_BOOL bRATE_REDUCon; /**< RATE_REDUCtion is requested for this frame */ + OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */ + OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */ + OMX_BOOL bHiPassFilter; /**< Enable encoder's High Pass Filter */ + OMX_BOOL bNoiseSuppressor; /**< Enable encoder's noise suppressor pre-processing */ + OMX_BOOL bPostFilter; /**< Enable decoder's post Filter */ +} OMX_AUDIO_PARAM_EVRCTYPE; + + +/** SMV ( up to 8.55kbps coder) stream format parameters */ +typedef struct OMX_AUDIO_PARAM_SMVTYPE { + 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_U32 nChannels; /**< Number of channels in the data stream (not + necessarily the same as the number of channels + to be rendered. */ + OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */ + OMX_BOOL bRATE_REDUCon; /**< RATE_REDUCtion is requested for this frame */ + OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 ??*/ + OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 ??*/ + OMX_BOOL bHiPassFilter; /**< Enable encoder's High Pass Filter ??*/ + OMX_BOOL bNoiseSuppressor; /**< Enable encoder's noise suppressor pre-processing */ + OMX_BOOL bPostFilter; /**< Enable decoder's post Filter ??*/ +} OMX_AUDIO_PARAM_SMVTYPE; + + +/** MIDI Format + * @ingroup midi + */ +typedef enum OMX_AUDIO_MIDIFORMATTYPE +{ + OMX_AUDIO_MIDIFormatUnknown = 0, /**< MIDI Format unknown or don't care */ + OMX_AUDIO_MIDIFormatSMF0, /**< Standard MIDI File Type 0 */ + OMX_AUDIO_MIDIFormatSMF1, /**< Standard MIDI File Type 1 */ + OMX_AUDIO_MIDIFormatSMF2, /**< Standard MIDI File Type 2 */ + OMX_AUDIO_MIDIFormatSPMIDI, /**< SP-MIDI */ + OMX_AUDIO_MIDIFormatXMF0, /**< eXtensible Music Format type 0 */ + OMX_AUDIO_MIDIFormatXMF1, /**< eXtensible Music Format type 1 */ + OMX_AUDIO_MIDIFormatMobileXMF, /**< Mobile XMF (eXtensible Music Format type 2) */ + OMX_AUDIO_MIDIFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_MIDIFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_MIDIFormatMax = 0x7FFFFFFF +} OMX_AUDIO_MIDIFORMATTYPE; + + +/** MIDI params + * @ingroup midi + */ +typedef struct OMX_AUDIO_PARAM_MIDITYPE { + 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_U32 nFileSize; /**< size of the MIDI file in bytes, where the entire + MIDI file passed in, otherwise if 0x0, the MIDI data + is merged and streamed (instead of passed as an + entire MIDI file) */ + OMX_BU32 sMaxPolyphony; /**< Specifies the maximum simultaneous polyphonic + voices. A value of zero indicates that the default + polyphony of the device is used */ + OMX_BOOL bLoadDefaultSound; /**< Whether to load default sound + bank at initialization */ + OMX_AUDIO_MIDIFORMATTYPE eMidiFormat; /**< Version of the MIDI file */ +} OMX_AUDIO_PARAM_MIDITYPE; + + +/** Type of the MIDI sound bank + * @ingroup midi + */ +typedef enum OMX_AUDIO_MIDISOUNDBANKTYPE { + OMX_AUDIO_MIDISoundBankUnused = 0, /**< unused/unknown soundbank type */ + OMX_AUDIO_MIDISoundBankDLS1, /**< DLS version 1 */ + OMX_AUDIO_MIDISoundBankDLS2, /**< DLS version 2 */ + OMX_AUDIO_MIDISoundBankMobileDLSBase, /**< Mobile DLS, using the base functionality */ + OMX_AUDIO_MIDISoundBankMobileDLSPlusOptions, /**< Mobile DLS, using the specification-defined optional feature set */ + OMX_AUDIO_MIDISoundBankKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_MIDISoundBankVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_MIDISoundBankMax = 0x7FFFFFFF +} OMX_AUDIO_MIDISOUNDBANKTYPE; + + +/** Bank Layout describes how bank MSB & LSB are used in the DLS instrument definitions sound bank + * @ingroup midi + */ +typedef enum OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE { + OMX_AUDIO_MIDISoundBankLayoutUnused = 0, /**< unused/unknown soundbank type */ + OMX_AUDIO_MIDISoundBankLayoutGM, /**< GS layout (based on bank MSB 0x00) */ + OMX_AUDIO_MIDISoundBankLayoutGM2, /**< General MIDI 2 layout (using MSB 0x78/0x79, LSB 0x00) */ + OMX_AUDIO_MIDISoundBankLayoutUser, /**< Does not conform to any bank numbering standards */ + OMX_AUDIO_MIDISoundBankLayoutKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_MIDISoundBankLayoutVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_MIDISoundBankLayoutMax = 0x7FFFFFFF +} OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE; + + +/** MIDI params to load/unload user soundbank + * @ingroup midi + */ +typedef struct OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE { + 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_U32 nDLSIndex; /**< DLS file index to be loaded */ + OMX_U32 nDLSSize; /**< Size in bytes */ + OMX_PTR pDLSData; /**< Pointer to DLS file data */ + OMX_AUDIO_MIDISOUNDBANKTYPE eMidiSoundBank; /**< Midi sound bank type enumeration */ + OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE eMidiSoundBankLayout; /**< Midi sound bank layout enumeration */ +} OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE; + + +/** Structure for Live MIDI events and MIP messages. + * (MIP = Maximum Instantaneous Polyphony; part of the SP-MIDI standard.) + * @ingroup midi + */ +typedef struct OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE { + 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_U32 nMidiEventSize; /**< Size of immediate MIDI events or MIP message in bytes */ + OMX_U8 nMidiEvents[1]; /**< MIDI event array to be rendered immediately, or an + array for the MIP message buffer, where the size is + indicated by nMidiEventSize */ +} OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE; + + +/** MIDI sound bank/ program pair in a given channel + * @ingroup midi + */ +typedef struct OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE { + 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_U32 nChannel; /**< Valid channel values range from 1 to 16 */ + OMX_U16 nIDProgram; /**< Valid program ID range is 1 to 128 */ + OMX_U16 nIDSoundBank; /**< Sound bank ID */ + OMX_U32 nUserSoundBankIndex;/**< User soundbank index, easier to access soundbanks + by index if multiple banks are present */ +} OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE; + + +/** MIDI control + * @ingroup midi + */ +typedef struct OMX_AUDIO_CONFIG_MIDICONTROLTYPE { + 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_BS32 sPitchTransposition; /**< Pitch transposition in semitones, stored as Q22.10 + format based on JAVA MMAPI (JSR-135) requirement */ + OMX_BU32 sPlayBackRate; /**< Relative playback rate, stored as Q14.17 fixed-point + number based on JSR-135 requirement */ + OMX_BU32 sTempo ; /**< Tempo in beats per minute (BPM), stored as Q22.10 + fixed-point number based on JSR-135 requirement */ + OMX_U32 nMaxPolyphony; /**< Specifies the maximum simultaneous polyphonic + voices. A value of zero indicates that the default + polyphony of the device is used */ + OMX_U32 nNumRepeat; /**< Number of times to repeat playback */ + OMX_U32 nStopTime; /**< Time in milliseconds to indicate when playback + will stop automatically. Set to zero if not used */ + OMX_U16 nChannelMuteMask; /**< 16 bit mask for channel mute status */ + OMX_U16 nChannelSoloMask; /**< 16 bit mask for channel solo status */ + OMX_U32 nTrack0031MuteMask; /**< 32 bit mask for track mute status. Note: This is for tracks 0-31 */ + OMX_U32 nTrack3263MuteMask; /**< 32 bit mask for track mute status. Note: This is for tracks 32-63 */ + OMX_U32 nTrack0031SoloMask; /**< 32 bit mask for track solo status. Note: This is for tracks 0-31 */ + OMX_U32 nTrack3263SoloMask; /**< 32 bit mask for track solo status. Note: This is for tracks 32-63 */ + +} OMX_AUDIO_CONFIG_MIDICONTROLTYPE; + + +/** MIDI Playback States + * @ingroup midi + */ +typedef enum OMX_AUDIO_MIDIPLAYBACKSTATETYPE { + OMX_AUDIO_MIDIPlayBackStateUnknown = 0, /**< Unknown state or state does not map to + other defined states */ + OMX_AUDIO_MIDIPlayBackStateClosedEngaged, /**< No MIDI resource is currently open. + The MIDI engine is currently processing + MIDI events. */ + OMX_AUDIO_MIDIPlayBackStateParsing, /**< A MIDI resource is open and is being + primed. The MIDI engine is currently + processing MIDI events. */ + OMX_AUDIO_MIDIPlayBackStateOpenEngaged, /**< A MIDI resource is open and primed but + not playing. The MIDI engine is currently + processing MIDI events. The transition to + this state is only possible from the + OMX_AUDIO_MIDIPlayBackStatePlaying state, + when the 'playback head' reaches the end + of media data or the playback stops due + to stop time set.*/ + OMX_AUDIO_MIDIPlayBackStatePlaying, /**< A MIDI resource is open and currently + playing. The MIDI engine is currently + processing MIDI events.*/ + OMX_AUDIO_MIDIPlayBackStatePlayingPartially, /**< Best-effort playback due to SP-MIDI/DLS + resource constraints */ + OMX_AUDIO_MIDIPlayBackStatePlayingSilently, /**< Due to system resource constraints and + SP-MIDI content constraints, there is + no audible MIDI content during playback + currently. The situation may change if + resources are freed later.*/ + OMX_AUDIO_MIDIPlayBackStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_MIDIPlayBackStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_MIDIPlayBackStateMax = 0x7FFFFFFF +} OMX_AUDIO_MIDIPLAYBACKSTATETYPE; + + +/** MIDI status + * @ingroup midi + */ +typedef struct OMX_AUDIO_CONFIG_MIDISTATUSTYPE { + 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_U16 nNumTracks; /**< Number of MIDI tracks in the file, read only field. + NOTE: May not return a meaningful value until the entire + file is parsed and buffered. */ + OMX_U32 nDuration; /**< The length of the currently open MIDI resource + in milliseconds. NOTE: May not return a meaningful value + until the entire file is parsed and buffered. */ + OMX_U32 nPosition; /**< Current Position of the MIDI resource being played + in milliseconds */ + OMX_BOOL bVibra; /**< Does Vibra track exist? NOTE: May not return a meaningful + value until the entire file is parsed and buffered. */ + OMX_U32 nNumMetaEvents; /**< Total number of MIDI Meta Events in the currently + open MIDI resource. NOTE: May not return a meaningful value + until the entire file is parsed and buffered. */ + OMX_U32 nNumActiveVoices; /**< Number of active voices in the currently playing + MIDI resource. NOTE: May not return a meaningful value until + the entire file is parsed and buffered. */ + OMX_AUDIO_MIDIPLAYBACKSTATETYPE eMIDIPlayBackState; /**< MIDI playback state enumeration, read only field */ +} OMX_AUDIO_CONFIG_MIDISTATUSTYPE; + + +/** MIDI Meta Event structure one per Meta Event. + * MIDI Meta Events are like audio metadata, except that they are interspersed + * with the MIDI content throughout the file and are not localized in the header. + * As such, it is necessary to retrieve information about these Meta Events from + * the engine, as it encounters these Meta Events within the MIDI content. + * For example, SMF files can have up to 14 types of MIDI Meta Events (copyright, + * author, default tempo, etc.) scattered throughout the file. + * @ingroup midi + */ +typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE{ + 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_U32 nIndex; /**< Index of Meta Event */ + OMX_U8 nMetaEventType; /**< Meta Event Type, 7bits (i.e. 0 - 127) */ + OMX_U32 nMetaEventSize; /**< size of the Meta Event in bytes */ + OMX_U32 nTrack; /**< track number for the meta event */ + OMX_U32 nPosition; /**< Position of the meta-event in milliseconds */ +} OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE; + + +/** MIDI Meta Event Data structure - one per Meta Event. + * @ingroup midi + */ +typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE{ + 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_U32 nIndex; /**< Index of Meta Event */ + OMX_U32 nMetaEventSize; /**< size of the Meta Event in bytes */ + OMX_U8 nData[1]; /**< array of one or more bytes of meta data + as indicated by the nMetaEventSize field */ +} OMX_AUDIO_CONFIG__MIDIMETAEVENTDATATYPE; + + +/** Audio Volume adjustment for a port */ +typedef struct OMX_AUDIO_CONFIG_VOLUMETYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nPortIndex; /**< Port index indicating which port to + set. Select the input port to set + just that port's volume. Select the + output port to adjust the master + volume. */ + OMX_BOOL bLinear; /**< Is the volume to be set in linear (0.100) + or logarithmic scale (mB) */ + OMX_BS32 sVolume; /**< Volume linear setting in the 0..100 range, OR + Volume logarithmic setting for this port. The values + for volume are in mB (millibels = 1/100 dB) relative + to a gain of 1 (e.g. the output is the same as the + input level). Values are in mB from nMax + (maximum volume) to nMin mB (typically negative). + Since the volume is "voltage" + and not a "power", it takes a setting of + -600 mB to decrease the volume by 1/2. If + a component cannot accurately set the + volume to the requested value, it must + set the volume to the closest value BELOW + the requested value. When getting the + volume setting, the current actual volume + must be returned. */ +} OMX_AUDIO_CONFIG_VOLUMETYPE; + + +/** Audio Volume adjustment for a channel */ +typedef struct OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nPortIndex; /**< Port index indicating which port to + set. Select the input port to set + just that port's volume. Select the + output port to adjust the master + volume. */ + OMX_U32 nChannel; /**< channel to select from 0 to N-1, + using OMX_ALL to apply volume settings + to all channels */ + OMX_BOOL bLinear; /**< Is the volume to be set in linear (0.100) or + logarithmic scale (mB) */ + OMX_BS32 sVolume; /**< Volume linear setting in the 0..100 range, OR + Volume logarithmic setting for this port. + The values for volume are in mB + (millibels = 1/100 dB) relative to a gain + of 1 (e.g. the output is the same as the + input level). Values are in mB from nMax + (maximum volume) to nMin mB (typically negative). + Since the volume is "voltage" + and not a "power", it takes a setting of + -600 mB to decrease the volume by 1/2. If + a component cannot accurately set the + volume to the requested value, it must + set the volume to the closest value BELOW + the requested value. When getting the + volume setting, the current actual volume + must be returned. */ + OMX_BOOL bIsMIDI; /**< TRUE if nChannel refers to a MIDI channel, + FALSE otherwise */ +} OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE; + + +/** Audio balance setting */ +typedef struct OMX_AUDIO_CONFIG_BALANCETYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nPortIndex; /**< Port index indicating which port to + set. Select the input port to set + just that port's balance. Select the + output port to adjust the master + balance. */ + OMX_S32 nBalance; /**< balance setting for this port + (-100 to 100, where -100 indicates + all left, and no right */ +} OMX_AUDIO_CONFIG_BALANCETYPE; + + +/** Audio Port mute */ +typedef struct OMX_AUDIO_CONFIG_MUTETYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nPortIndex; /**< Port index indicating which port to + set. Select the input port to set + just that port's mute. Select the + output port to adjust the master + mute. */ + OMX_BOOL bMute; /**< Mute setting for this port */ +} OMX_AUDIO_CONFIG_MUTETYPE; + + +/** Audio Channel mute */ +typedef struct OMX_AUDIO_CONFIG_CHANNELMUTETYPE { + 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_U32 nChannel; /**< channel to select from 0 to N-1, + using OMX_ALL to apply mute settings + to all channels */ + OMX_BOOL bMute; /**< Mute setting for this channel */ + OMX_BOOL bIsMIDI; /**< TRUE if nChannel refers to a MIDI channel, + FALSE otherwise */ +} OMX_AUDIO_CONFIG_CHANNELMUTETYPE; + + + +/** Enable / Disable for loudness control, which boosts bass and to a + * smaller extent high end frequencies to compensate for hearing + * ability at the extreme ends of the audio spectrum + */ +typedef struct OMX_AUDIO_CONFIG_LOUDNESSTYPE { + 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_BOOL bLoudness; /**< Enable/disable for loudness */ +} OMX_AUDIO_CONFIG_LOUDNESSTYPE; + + +/** Enable / Disable for bass, which controls low frequencies + */ +typedef struct OMX_AUDIO_CONFIG_BASSTYPE { + 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_BOOL bEnable; /**< Enable/disable for bass control */ + OMX_S32 nBass; /**< bass setting for the port, as a + continuous value from -100 to 100 + (0 means no change in bass level)*/ +} OMX_AUDIO_CONFIG_BASSTYPE; + + +/** Enable / Disable for treble, which controls high frequencies tones + */ +typedef struct OMX_AUDIO_CONFIG_TREBLETYPE { + 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_BOOL bEnable; /**< Enable/disable for treble control */ + OMX_S32 nTreble; /**< treble setting for the port, as a + continuous value from -100 to 100 + (0 means no change in treble level) */ +} OMX_AUDIO_CONFIG_TREBLETYPE; + + +/** An equalizer is typically used for two reasons: to compensate for an + * sub-optimal frequency response of a system to make it sound more natural + * or to create intentionally some unnatural coloring to the sound to create + * an effect. + * @ingroup effects + */ +typedef struct OMX_AUDIO_CONFIG_EQUALIZERTYPE { + 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_BOOL bEnable; /**< Enable/disable for equalizer */ + OMX_BU32 sBandIndex; /**< Band number to be set. Upper Limit is + N-1, where N is the number of bands, lower limit is 0 */ + OMX_BU32 sCenterFreq; /**< Center frequecies in Hz. This is a + read only element and is used to determine + the lower, center and upper frequency of + this band. */ + OMX_BS32 sBandLevel; /**< band level in millibels */ +} OMX_AUDIO_CONFIG_EQUALIZERTYPE; + + +/** Stereo widening mode type + * @ingroup effects + */ +typedef enum OMX_AUDIO_STEREOWIDENINGTYPE { + OMX_AUDIO_StereoWideningHeadphones, /**< Stereo widening for loudspeakers */ + OMX_AUDIO_StereoWideningLoudspeakers, /**< Stereo widening for closely spaced loudspeakers */ + OMX_AUDIO_StereoWideningKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_StereoWideningVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_StereoWideningMax = 0x7FFFFFFF +} OMX_AUDIO_STEREOWIDENINGTYPE; + + +/** Control for stereo widening, which is a special 2-channel + * case of the audio virtualizer effect. For example, for 5.1-channel + * output, it translates to virtual surround sound. + * @ingroup effects + */ +typedef struct OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE { + 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_BOOL bEnable; /**< Enable/disable for stereo widening control */ + OMX_AUDIO_STEREOWIDENINGTYPE eWideningType; /**< Stereo widening algorithm type */ + OMX_U32 nStereoWidening; /**< stereo widening setting for the port, + as a continuous value from 0 to 100 */ +} OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE; + + +/** The chorus effect (or ``choralizer'') is any signal processor which makes + * one sound source (such as a voice) sound like many such sources singing + * (or playing) in unison. Since performance in unison is never exact, chorus + * effects simulate this by making independently modified copies of the input + * signal. Modifications may include (1) delay, (2) frequency shift, and + * (3) amplitude modulation. + * @ingroup effects + */ +typedef struct OMX_AUDIO_CONFIG_CHORUSTYPE { + 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_BOOL bEnable; /**< Enable/disable for chorus */ + OMX_BU32 sDelay; /**< average delay in milliseconds */ + OMX_BU32 sModulationRate; /**< rate of modulation in millihertz */ + OMX_U32 nModulationDepth; /**< depth of modulation as a percentage of + delay (i.e. 0 to 100) */ + OMX_BU32 nFeedback; /**< Feedback from chorus output to input in percentage */ +} OMX_AUDIO_CONFIG_CHORUSTYPE; + + +/** Reverberation is part of the reflected sound that follows the early + * reflections. In a typical room, this consists of a dense succession of + * echoes whose energy decays exponentially. The reverberation effect structure + * as defined here includes both (early) reflections as well as (late) reverberations. + * @ingroup effects + */ +typedef struct OMX_AUDIO_CONFIG_REVERBERATIONTYPE { + 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_BOOL bEnable; /**< Enable/disable for reverberation control */ + OMX_BS32 sRoomLevel; /**< Intensity level for the whole room effect + (i.e. both early reflections and late + reverberation) in millibels */ + OMX_BS32 sRoomHighFreqLevel; /**< Attenuation at high frequencies + relative to the intensity at low + frequencies in millibels */ + OMX_BS32 sReflectionsLevel; /**< Intensity level of early reflections + (relative to room value), in millibels */ + OMX_BU32 sReflectionsDelay; /**< Delay time of the first reflection relative + to the direct path, in milliseconds */ + OMX_BS32 sReverbLevel; /**< Intensity level of late reverberation + relative to room level, in millibels */ + OMX_BU32 sReverbDelay; /**< Time delay from the first early reflection + to the beginning of the late reverberation + section, in milliseconds */ + OMX_BU32 sDecayTime; /**< Late reverberation decay time at low + frequencies, in milliseconds */ + OMX_BU32 nDecayHighFreqRatio; /**< Ratio of high frequency decay time relative + to low frequency decay time in percent */ + OMX_U32 nDensity; /**< Modal density in the late reverberation decay, + in percent (i.e. 0 - 100) */ + OMX_U32 nDiffusion; /**< Echo density in the late reverberation decay, + in percent (i.e. 0 - 100) */ + OMX_BU32 sReferenceHighFreq; /**< Reference high frequency in Hertz. This is + the frequency used as the reference for all + the high-frequency settings above */ + +} OMX_AUDIO_CONFIG_REVERBERATIONTYPE; + + +/** Possible settings for the Echo Cancelation structure to use + * @ingroup effects + */ +typedef enum OMX_AUDIO_ECHOCANTYPE { + OMX_AUDIO_EchoCanOff = 0, /**< Echo Cancellation is disabled */ + OMX_AUDIO_EchoCanNormal, /**< Echo Cancellation normal operation - + echo from plastics and face */ + OMX_AUDIO_EchoCanHFree, /**< Echo Cancellation optimized for + Hands Free operation */ + OMX_AUDIO_EchoCanCarKit, /**< Echo Cancellation optimized for + Car Kit (longer echo) */ + OMX_AUDIO_EchoCanKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_AUDIO_EchoCanVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_AUDIO_EchoCanMax = 0x7FFFFFFF +} OMX_AUDIO_ECHOCANTYPE; + + +/** Enable / Disable for echo cancelation, which removes undesired echo's + * from the audio + * @ingroup effects + */ +typedef struct OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE { + 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_AUDIO_ECHOCANTYPE eEchoCancelation; /**< Echo cancelation settings */ +} OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE; + + +/** Enable / Disable for noise reduction, which undesired noise from + * the audio + * @ingroup effects + */ +typedef struct OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE { + 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_BOOL bNoiseReduction; /**< Enable/disable for noise reduction */ +} OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE; + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif +/* File EOF */ + diff --git a/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Component.h b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Component.h new file mode 100644 index 0000000..d595640 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Component.h @@ -0,0 +1,579 @@ +/* + * Copyright (c) 2008 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_Component.h - OpenMax IL version 1.1.2 + * The OMX_Component header file contains the definitions used to define + * the public interface of a component. This header file is intended to + * be used by both the application and the component. + */ + +#ifndef OMX_Component_h +#define OMX_Component_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 +#include +#include +#include + +/** @ingroup comp */ +typedef enum OMX_PORTDOMAINTYPE { + OMX_PortDomainAudio, + OMX_PortDomainVideo, + OMX_PortDomainImage, + OMX_PortDomainOther, + OMX_PortDomainKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_PortDomainVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_PortDomainMax = 0x7ffffff +} OMX_PORTDOMAINTYPE; + +/** @ingroup comp */ +typedef struct OMX_PARAM_PORTDEFINITIONTYPE { + OMX_U32 nSize; /**< Size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nPortIndex; /**< Port number the structure applies to */ + OMX_DIRTYPE eDir; /**< Direction (input or output) of this port */ + OMX_U32 nBufferCountActual; /**< The actual number of buffers allocated on this port */ + OMX_U32 nBufferCountMin; /**< The minimum number of buffers this port requires */ + OMX_U32 nBufferSize; /**< Size, in bytes, for buffers to be used for this channel */ + OMX_BOOL bEnabled; /**< Ports default to enabled and are enabled/disabled by + OMX_CommandPortEnable/OMX_CommandPortDisable. + When disabled a port is unpopulated. A disabled port + is not populated with buffers on a transition to IDLE. */ + OMX_BOOL bPopulated; /**< Port is populated with all of its buffers as indicated by + nBufferCountActual. A disabled port is always unpopulated. + An enabled port is populated on a transition to OMX_StateIdle + and unpopulated on a transition to loaded. */ + OMX_PORTDOMAINTYPE eDomain; /**< Domain of the port. Determines the contents of metadata below. */ + union { + OMX_AUDIO_PORTDEFINITIONTYPE audio; + OMX_VIDEO_PORTDEFINITIONTYPE video; + OMX_IMAGE_PORTDEFINITIONTYPE image; + OMX_OTHER_PORTDEFINITIONTYPE other; + } format; + OMX_BOOL bBuffersContiguous; + OMX_U32 nBufferAlignment; +} OMX_PARAM_PORTDEFINITIONTYPE; + +/** @ingroup comp */ +typedef struct OMX_PARAM_U32TYPE { + OMX_U32 nSize; /**< Size of this structure, in Bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nPortIndex; /**< port that this structure applies to */ + OMX_U32 nU32; /**< U32 value */ +} OMX_PARAM_U32TYPE; + +/** @ingroup rpm */ +typedef enum OMX_SUSPENSIONPOLICYTYPE { + OMX_SuspensionDisabled, /**< No suspension; v1.0 behavior */ + OMX_SuspensionEnabled, /**< Suspension allowed */ + OMX_SuspensionPolicyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_SuspensionPolicyStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_SuspensionPolicyMax = 0x7fffffff +} OMX_SUSPENSIONPOLICYTYPE; + +/** @ingroup rpm */ +typedef struct OMX_PARAM_SUSPENSIONPOLICYTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_SUSPENSIONPOLICYTYPE ePolicy; +} OMX_PARAM_SUSPENSIONPOLICYTYPE; + +/** @ingroup rpm */ +typedef enum OMX_SUSPENSIONTYPE { + OMX_NotSuspended, /**< component is not suspended */ + OMX_Suspended, /**< component is suspended */ + OMX_SuspensionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_SuspensionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_SuspendMax = 0x7FFFFFFF +} OMX_SUSPENSIONTYPE; + +/** @ingroup rpm */ +typedef struct OMX_PARAM_SUSPENSIONTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_SUSPENSIONTYPE eType; +} OMX_PARAM_SUSPENSIONTYPE ; + +typedef struct OMX_CONFIG_BOOLEANTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_BOOL bEnabled; +} OMX_CONFIG_BOOLEANTYPE; + +/* Parameter specifying the content uri to use. */ +/** @ingroup cp */ +typedef struct OMX_PARAM_CONTENTURITYPE +{ + OMX_U32 nSize; /**< size of the structure in bytes, including + actual URI name */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U8 contentURI[1]; /**< The URI name */ +} OMX_PARAM_CONTENTURITYPE; + +/* Parameter specifying the pipe to use. */ +/** @ingroup cp */ +typedef struct OMX_PARAM_CONTENTPIPETYPE +{ + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_HANDLETYPE hPipe; /**< The pipe handle*/ +} OMX_PARAM_CONTENTPIPETYPE; + +/** @ingroup rpm */ +typedef struct OMX_RESOURCECONCEALMENTTYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_BOOL bResourceConcealmentForbidden; /**< disallow the use of resource concealment + methods (like degrading algorithm quality to + lower resource consumption or functional bypass) + on a component as a resolution to resource conflicts. */ +} OMX_RESOURCECONCEALMENTTYPE; + + +/** @ingroup metadata */ +typedef enum OMX_METADATACHARSETTYPE { + OMX_MetadataCharsetUnknown = 0, + OMX_MetadataCharsetASCII, + OMX_MetadataCharsetBinary, + OMX_MetadataCharsetCodePage1252, + OMX_MetadataCharsetUTF8, + OMX_MetadataCharsetJavaConformantUTF8, + OMX_MetadataCharsetUTF7, + OMX_MetadataCharsetImapUTF7, + OMX_MetadataCharsetUTF16LE, + OMX_MetadataCharsetUTF16BE, + OMX_MetadataCharsetGB12345, + OMX_MetadataCharsetHZGB2312, + OMX_MetadataCharsetGB2312, + OMX_MetadataCharsetGB18030, + OMX_MetadataCharsetGBK, + OMX_MetadataCharsetBig5, + OMX_MetadataCharsetISO88591, + OMX_MetadataCharsetISO88592, + OMX_MetadataCharsetISO88593, + OMX_MetadataCharsetISO88594, + OMX_MetadataCharsetISO88595, + OMX_MetadataCharsetISO88596, + OMX_MetadataCharsetISO88597, + OMX_MetadataCharsetISO88598, + OMX_MetadataCharsetISO88599, + OMX_MetadataCharsetISO885910, + OMX_MetadataCharsetISO885913, + OMX_MetadataCharsetISO885914, + OMX_MetadataCharsetISO885915, + OMX_MetadataCharsetShiftJIS, + OMX_MetadataCharsetISO2022JP, + OMX_MetadataCharsetISO2022JP1, + OMX_MetadataCharsetISOEUCJP, + OMX_MetadataCharsetSMS7Bit, + OMX_MetadataCharsetKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_MetadataCharsetVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_MetadataCharsetTypeMax= 0x7FFFFFFF +} OMX_METADATACHARSETTYPE; + +/** @ingroup metadata */ +typedef enum OMX_METADATASCOPETYPE +{ + OMX_MetadataScopeAllLevels, + OMX_MetadataScopeTopLevel, + OMX_MetadataScopePortLevel, + OMX_MetadataScopeNodeLevel, + OMX_MetadataScopeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_MetadataScopeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_MetadataScopeTypeMax = 0x7fffffff +} OMX_METADATASCOPETYPE; + +/** @ingroup metadata */ +typedef enum OMX_METADATASEARCHMODETYPE +{ + OMX_MetadataSearchValueSizeByIndex, + OMX_MetadataSearchItemByIndex, + OMX_MetadataSearchNextItemByKey, + OMX_MetadataSearchKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_MetadataSearchVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_MetadataSearchTypeMax = 0x7fffffff +} OMX_METADATASEARCHMODETYPE; +/** @ingroup metadata */ +typedef struct OMX_CONFIG_METADATAITEMCOUNTTYPE +{ + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_METADATASCOPETYPE eScopeMode; + OMX_U32 nScopeSpecifier; + OMX_U32 nMetadataItemCount; +} OMX_CONFIG_METADATAITEMCOUNTTYPE; + +/** @ingroup metadata */ +typedef struct OMX_CONFIG_METADATAITEMTYPE +{ + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_METADATASCOPETYPE eScopeMode; + OMX_U32 nScopeSpecifier; + OMX_U32 nMetadataItemIndex; + OMX_METADATASEARCHMODETYPE eSearchMode; + OMX_METADATACHARSETTYPE eKeyCharset; + OMX_U8 nKeySizeUsed; + OMX_U8 nKey[128]; + OMX_METADATACHARSETTYPE eValueCharset; + OMX_STRING sLanguageCountry; + OMX_U32 nValueMaxSize; + OMX_U32 nValueSizeUsed; + OMX_U8 nValue[1]; +} OMX_CONFIG_METADATAITEMTYPE; + +/* @ingroup metadata */ +typedef struct OMX_CONFIG_CONTAINERNODECOUNTTYPE +{ + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_BOOL bAllKeys; + OMX_U32 nParentNodeID; + OMX_U32 nNumNodes; +} OMX_CONFIG_CONTAINERNODECOUNTTYPE; + +/** @ingroup metadata */ +typedef struct OMX_CONFIG_CONTAINERNODEIDTYPE +{ + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_BOOL bAllKeys; + OMX_U32 nParentNodeID; + OMX_U32 nNodeIndex; + OMX_U32 nNodeID; + OMX_STRING cNodeName; + OMX_BOOL bIsLeafType; +} OMX_CONFIG_CONTAINERNODEIDTYPE; + +/** @ingroup metadata */ +typedef struct OMX_PARAM_METADATAFILTERTYPE +{ + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_BOOL bAllKeys; /* if true then this structure refers to all keys and + * the three key fields below are ignored */ + OMX_METADATACHARSETTYPE eKeyCharset; + OMX_U32 nKeySizeUsed; + OMX_U8 nKey [128]; + OMX_U32 nLanguageCountrySizeUsed; + OMX_U8 nLanguageCountry[128]; + OMX_BOOL bEnabled; /* if true then key is part of filter (e.g. + * retained for query later). If false then + * key is not part of filter */ +} OMX_PARAM_METADATAFILTERTYPE; + +/** The OMX_HANDLETYPE structure defines the component handle. The component + * handle is used to access all of the component's public methods and also + * contains pointers to the component's private data area. The component + * handle is initialized by the OMX core (with help from the component) + * during the process of loading the component. After the component is + * successfully loaded, the application can safely access any of the + * component's public functions (although some may return an error because + * the state is inappropriate for the access). + * + * @ingroup comp + */ +typedef struct OMX_COMPONENTTYPE +{ + /** The size of this structure, in bytes. It is the responsibility + of the allocator of this structure to fill in this value. Since + this structure is allocated by the GetHandle function, this + function will fill in this value. */ + OMX_U32 nSize; + + /** nVersion is the version of the OMX specification that the structure + is built against. It is the responsibility of the creator of this + structure to initialize this value and every user of this structure + should verify that it knows how to use the exact version of + this structure found herein. */ + OMX_VERSIONTYPE nVersion; + + /** pComponentPrivate is a pointer to the component private data area. + This member is allocated and initialized by the component when the + component is first loaded. The application should not access this + data area. */ + OMX_PTR pComponentPrivate; + + /** pApplicationPrivate is a pointer that is a parameter to the + OMX_GetHandle method, and contains an application private value + provided by the IL client. This application private data is + returned to the IL Client by OMX in all callbacks */ + OMX_PTR pApplicationPrivate; + + /** refer to OMX_GetComponentVersion in OMX_core.h or the OMX IL + specification for details on the GetComponentVersion method. + */ + OMX_ERRORTYPE (*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); + + /** refer to OMX_SendCommand in OMX_core.h or the OMX IL + specification for details on the SendCommand method. + */ + OMX_ERRORTYPE (*SendCommand)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_COMMANDTYPE Cmd, + OMX_IN OMX_U32 nParam1, + OMX_IN OMX_PTR pCmdData); + + /** refer to OMX_GetParameter in OMX_core.h or the OMX IL + specification for details on the GetParameter method. + */ + OMX_ERRORTYPE (*GetParameter)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nParamIndex, + OMX_INOUT OMX_PTR pComponentParameterStructure); + + + /** refer to OMX_SetParameter in OMX_core.h or the OMX IL + specification for details on the SetParameter method. + */ + OMX_ERRORTYPE (*SetParameter)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR pComponentParameterStructure); + + + /** refer to OMX_GetConfig in OMX_core.h or the OMX IL + specification for details on the GetConfig method. + */ + OMX_ERRORTYPE (*GetConfig)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_INOUT OMX_PTR pComponentConfigStructure); + + + /** refer to OMX_SetConfig in OMX_core.h or the OMX IL + specification for details on the SetConfig method. + */ + OMX_ERRORTYPE (*SetConfig)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_INDEXTYPE nIndex, + OMX_IN OMX_PTR pComponentConfigStructure); + + + /** refer to OMX_GetExtensionIndex in OMX_core.h or the OMX IL + specification for details on the GetExtensionIndex method. + */ + OMX_ERRORTYPE (*GetExtensionIndex)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_STRING cParameterName, + OMX_OUT OMX_INDEXTYPE* pIndexType); + + + /** refer to OMX_GetState in OMX_core.h or the OMX IL + specification for details on the GetState method. + */ + OMX_ERRORTYPE (*GetState)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_OUT OMX_STATETYPE* pState); + + + /** The ComponentTunnelRequest method will interact with another OMX + component to determine if tunneling is possible and to setup the + tunneling. The return codes for this method can be used to + determine if tunneling is not possible, or if tunneling is not + supported. + + Base profile components (i.e. non-interop) do not support this + method and should return OMX_ErrorNotImplemented + + The interop profile component MUST support tunneling to another + interop profile component with a compatible port parameters. + A component may also support proprietary communication. + + If proprietary communication is supported the negotiation of + proprietary communication is done outside of OMX in a vendor + specific way. It is only required that the proper result be + returned and the details of how the setup is done is left + to the component implementation. + + When this method is invoked when nPort in an output port, the + component will: + 1. Populate the pTunnelSetup structure with the output port's + requirements and constraints for the tunnel. + + When this method is invoked when nPort in an input port, the + component will: + 1. Query the necessary parameters from the output port to + determine if the ports are compatible for tunneling + 2. If the ports are compatible, the component should store + the tunnel step provided by the output port + 3. Determine which port (either input or output) is the buffer + supplier, and call OMX_SetParameter on the output port to + indicate this selection. + + The component will return from this call within 5 msec. + + @param [in] hComp + Handle of the component to be accessed. This is the component + handle returned by the call to the OMX_GetHandle method. + @param [in] nPort + nPort is used to select the port on the component to be used + for tunneling. + @param [in] hTunneledComp + Handle of the component to tunnel with. This is the component + handle returned by the call to the OMX_GetHandle method. When + this parameter is 0x0 the component should setup the port for + communication with the application / IL Client. + @param [in] nPortOutput + nPortOutput is used indicate the port the component should + tunnel with. + @param [in] pTunnelSetup + Pointer to the tunnel setup structure. When nPort is an output port + the component should populate the fields of this structure. When + When nPort is an input port the component should review the setup + provided by the component with the output port. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup tun + */ + + OMX_ERRORTYPE (*ComponentTunnelRequest)( + OMX_IN OMX_HANDLETYPE hComp, + OMX_IN OMX_U32 nPort, + OMX_IN OMX_HANDLETYPE hTunneledComp, + OMX_IN OMX_U32 nTunneledPort, + OMX_INOUT OMX_TUNNELSETUPTYPE* pTunnelSetup); + + /** refer to OMX_UseBuffer in OMX_core.h or the OMX IL + specification for details on the UseBuffer method. + @ingroup buf + */ + OMX_ERRORTYPE (*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); + + /** refer to OMX_AllocateBuffer in OMX_core.h or the OMX IL + specification for details on the AllocateBuffer method. + @ingroup buf + */ + OMX_ERRORTYPE (*AllocateBuffer)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_INOUT OMX_BUFFERHEADERTYPE** ppBuffer, + OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_PTR pAppPrivate, + OMX_IN OMX_U32 nSizeBytes); + + /** refer to OMX_FreeBuffer in OMX_core.h or the OMX IL + specification for details on the FreeBuffer method. + @ingroup buf + */ + OMX_ERRORTYPE (*FreeBuffer)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); + + /** refer to OMX_EmptyThisBuffer in OMX_core.h or the OMX IL + specification for details on the EmptyThisBuffer method. + @ingroup buf + */ + OMX_ERRORTYPE (*EmptyThisBuffer)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); + + /** refer to OMX_FillThisBuffer in OMX_core.h or the OMX IL + specification for details on the FillThisBuffer method. + @ingroup buf + */ + OMX_ERRORTYPE (*FillThisBuffer)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); + + /** The SetCallbacks method is used by the core to specify the callback + structure from the application to the component. This is a blocking + call. The component will return from this call within 5 msec. + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the GetHandle function. + @param [in] pCallbacks + pointer to an OMX_CALLBACKTYPE structure used to provide the + callback information to the component + @param [in] pAppData + pointer to an application defined value. It is anticipated that + the application will pass a pointer to a data structure or a "this + pointer" in this area to allow the callback (in the application) + to determine the context of the call + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + */ + OMX_ERRORTYPE (*SetCallbacks)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_CALLBACKTYPE* pCallbacks, + OMX_IN OMX_PTR pAppData); + + /** ComponentDeInit method is used to deinitialize the component + providing a means to free any resources allocated at component + initialization. NOTE: After this call the component handle is + not valid for further use. + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the GetHandle function. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + */ + OMX_ERRORTYPE (*ComponentDeInit)( + OMX_IN OMX_HANDLETYPE hComponent); + + /** @ingroup buf */ + OMX_ERRORTYPE (*UseEGLImage)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, + OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_PTR pAppPrivate, + OMX_IN void* eglImage); + + OMX_ERRORTYPE (*ComponentRoleEnum)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_OUT OMX_U8 *cRole, + OMX_IN OMX_U32 nIndex); + +} OMX_COMPONENTTYPE; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif +/* File EOF */ diff --git a/sec_mm/sec_omx/sec_omx_include/khronos/OMX_ContentPipe.h b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_ContentPipe.h new file mode 100644 index 0000000..5f6310c --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_ContentPipe.h @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2008 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_ContentPipe.h - OpenMax IL version 1.1.2 + * The OMX_ContentPipe header file contains the definitions used to define + * the public interface for content piples. This header file is intended to + * be used by the component. + */ + +#ifndef OMX_CONTENTPIPE_H +#define OMX_CONTENTPIPE_H + +#ifndef KD_EACCES +/* OpenKODE error codes. CPResult values may be zero (indicating success + or one of the following values) */ +#define KD_EACCES (1) +#define KD_EADDRINUSE (2) +#define KD_EAGAIN (5) +#define KD_EBADF (7) +#define KD_EBUSY (8) +#define KD_ECONNREFUSED (9) +#define KD_ECONNRESET (10) +#define KD_EDEADLK (11) +#define KD_EDESTADDRREQ (12) +#define KD_ERANGE (35) +#define KD_EEXIST (13) +#define KD_EFBIG (14) +#define KD_EHOSTUNREACH (15) +#define KD_EINVAL (17) +#define KD_EIO (18) +#define KD_EISCONN (20) +#define KD_EISDIR (21) +#define KD_EMFILE (22) +#define KD_ENAMETOOLONG (23) +#define KD_ENOENT (24) +#define KD_ENOMEM (25) +#define KD_ENOSPC (26) +#define KD_ENOSYS (27) +#define KD_ENOTCONN (28) +#define KD_EPERM (33) +#define KD_ETIMEDOUT (36) +#define KD_EILSEQ (19) +#endif + +/** Map types from OMX standard types only here so interface is as generic as possible. */ +typedef OMX_U32 CPresult; +typedef char * CPstring; +typedef void * CPhandle; +typedef OMX_U32 CPuint; +typedef OMX_S32 CPint; +typedef char CPbyte; +typedef OMX_BOOL CPbool; + +/** enumeration of origin types used in the CP_PIPETYPE's Seek function + * @ingroup cp + */ +typedef enum CP_ORIGINTYPE { + CP_OriginBegin, + CP_OriginCur, + CP_OriginEnd, + CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + CP_OriginVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + CP_OriginMax = 0X7FFFFFFF +} CP_ORIGINTYPE; + +/** enumeration of contact access types used in the CP_PIPETYPE's Open function + * @ingroup cp + */ +typedef enum CP_ACCESSTYPE { + CP_AccessRead, + CP_AccessWrite, + CP_AccessReadWrite , + CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + CP_AccessVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + CP_AccessMax = 0X7FFFFFFF +} CP_ACCESSTYPE; + +/** enumeration of results returned by the CP_PIPETYPE's CheckAvailableBytes function + * @ingroup cp + */ +typedef enum CP_CHECKBYTESRESULTTYPE +{ + CP_CheckBytesOk, /**< There are at least the request number + of bytes available */ + CP_CheckBytesNotReady, /**< The pipe is still retrieving bytes + and presently lacks sufficient bytes. + Client will be called when they are + sufficient bytes are available. */ + CP_CheckBytesInsufficientBytes , /**< The pipe has retrieved all bytes + but those available are less than those + requested */ + CP_CheckBytesAtEndOfStream, /**< The pipe has reached the end of stream + and no more bytes are available. */ + CP_CheckBytesOutOfBuffers, /**< All read/write buffers are currently in use. */ + CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + CP_CheckBytesVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + CP_CheckBytesMax = 0X7FFFFFFF +} CP_CHECKBYTESRESULTTYPE; + +/** enumeration of content pipe events sent to the client callback. + * @ingroup cp + */ +typedef enum CP_EVENTTYPE{ + CP_BytesAvailable, /** bytes requested in a CheckAvailableBytes call are now available*/ + CP_Overflow, /** enumeration of content pipe events sent to the client callback*/ + CP_PipeDisconnected , /** enumeration of content pipe events sent to the client callback*/ + CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + CP_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + CP_EventMax = 0X7FFFFFFF +} CP_EVENTTYPE; + +/** content pipe definition + * @ingroup cp + */ +typedef struct CP_PIPETYPE +{ + /** Open a content stream for reading or writing. */ + CPresult (*Open)( CPhandle* hContent, CPstring szURI, CP_ACCESSTYPE eAccess ); + + /** Close a content stream. */ + CPresult (*Close)( CPhandle hContent ); + + /** Create a content source and open it for writing. */ + CPresult (*Create)( CPhandle *hContent, CPstring szURI ); + + /** Check the that specified number of bytes are available for reading or writing (depending on access type).*/ + CPresult (*CheckAvailableBytes)( CPhandle hContent, CPuint nBytesRequested, CP_CHECKBYTESRESULTTYPE *eResult ); + + /** Seek to certain position in the content relative to the specified origin. */ + CPresult (*SetPosition)( CPhandle hContent, CPint nOffset, CP_ORIGINTYPE eOrigin); + + /** Retrieve the current position relative to the start of the content. */ + CPresult (*GetPosition)( CPhandle hContent, CPuint *pPosition); + + /** Retrieve data of the specified size from the content stream (advance content pointer by size of data). + Note: pipe client provides pointer. This function is appropriate for small high frequency reads. */ + CPresult (*Read)( CPhandle hContent, CPbyte *pData, CPuint nSize); + + /** Retrieve a buffer allocated by the pipe that contains the requested number of bytes. + Buffer contains the next block of bytes, as specified by nSize, of the content. nSize also + returns the size of the block actually read. Content pointer advances the by the returned size. + Note: pipe provides pointer. This function is appropriate for large reads. The client must call + ReleaseReadBuffer when done with buffer. + + In some cases the requested block may not reside in contiguous memory within the + pipe implementation. For instance if the pipe leverages a circular buffer then the requested + block may straddle the boundary of the circular buffer. By default a pipe implementation + performs a copy in this case to provide the block to the pipe client in one contiguous buffer. + If, however, the client sets bForbidCopy, then the pipe returns only those bytes preceding the memory + boundary. Here the client may retrieve the data in segments over successive calls. */ + CPresult (*ReadBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint *nSize, CPbool bForbidCopy); + + /** Release a buffer obtained by ReadBuffer back to the pipe. */ + CPresult (*ReleaseReadBuffer)(CPhandle hContent, CPbyte *pBuffer); + + /** Write data of the specified size to the content (advance content pointer by size of data). + Note: pipe client provides pointer. This function is appropriate for small high frequency writes. */ + CPresult (*Write)( CPhandle hContent, CPbyte *data, CPuint nSize); + + /** Retrieve a buffer allocated by the pipe used to write data to the content. + Client will fill buffer with output data. Note: pipe provides pointer. This function is appropriate + for large writes. The client must call WriteBuffer when done it has filled the buffer with data.*/ + CPresult (*GetWriteBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint nSize); + + /** Deliver a buffer obtained via GetWriteBuffer to the pipe. Pipe will write the + the contents of the buffer to content and advance content pointer by the size of the buffer */ + CPresult (*WriteBuffer)( CPhandle hContent, CPbyte *pBuffer, CPuint nFilledSize); + + /** Register a per-handle client callback with the content pipe. */ + CPresult (*RegisterCallback)( CPhandle hContent, CPresult (*ClientCallback)(CP_EVENTTYPE eEvent, CPuint iParam)); + +} CP_PIPETYPE; + +#endif + diff --git a/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Core.h b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Core.h new file mode 100644 index 0000000..a076f2f --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Core.h @@ -0,0 +1,1431 @@ +/* + * Copyright (c) 2008 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_Core.h - OpenMax IL version 1.1.2 + * The OMX_Core header file contains the definitions used by both the + * application and the component to access common items. + */ + +#ifndef OMX_Core_h +#define OMX_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 + + +/** The OMX_COMMANDTYPE enumeration is used to specify the action in the + * OMX_SendCommand macro. + * @ingroup core + */ +typedef enum OMX_COMMANDTYPE +{ + OMX_CommandStateSet, /**< Change the component state */ + OMX_CommandFlush, /**< Flush the data queue(s) of a component */ + OMX_CommandPortDisable, /**< Disable a port on a component. */ + OMX_CommandPortEnable, /**< Enable a port on a component. */ + OMX_CommandMarkBuffer, /**< Mark a component/buffer for observation */ + OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_CommandMax = 0X7FFFFFFF +} OMX_COMMANDTYPE; + + + +/** The OMX_STATETYPE enumeration is used to indicate or change the component + * state. This enumeration reflects the current state of the component when + * used with the OMX_GetState macro or becomes the parameter in a state change + * command when used with the OMX_SendCommand macro. + * + * The component will be in the Loaded state after the component is initially + * loaded into memory. In the Loaded state, the component is not allowed to + * allocate or hold resources other than to build it's internal parameter + * and configuration tables. The application will send one or more + * SetParameters/GetParameters and SetConfig/GetConfig commands to the + * component and the component will record each of these parameter and + * configuration changes for use later. When the application sends the + * Idle command, the component will acquire the resources needed for the + * specified configuration and will transition to the idle state if the + * allocation is successful. If the component cannot successfully + * transition to the idle state for any reason, the state of the component + * shall be fully rolled back to the Loaded state (e.g. all allocated + * resources shall be released). When the component receives the command + * to go to the Executing state, it shall begin processing buffers by + * sending all input buffers it holds to the application. While + * the component is in the Idle state, the application may also send the + * Pause command. If the component receives the pause command while in the + * Idle state, the component shall send all input buffers it holds to the + * application, but shall not begin processing buffers. This will allow the + * application to prefill buffers. + * + * @ingroup comp + */ + +typedef enum OMX_STATETYPE +{ + OMX_StateInvalid, /**< component has detected that it's internal data + structures are corrupted to the point that + it cannot determine it's state properly */ + OMX_StateLoaded, /**< component has been loaded but has not completed + initialization. The OMX_SetParameter macro + and the OMX_GetParameter macro are the only + valid macros allowed to be sent to the + component in this state. */ + OMX_StateIdle, /**< component initialization has been completed + successfully and the component is ready to + to start. */ + OMX_StateExecuting, /**< component has accepted the start command and + is processing data (if data is available) */ + OMX_StatePause, /**< component has received pause command */ + OMX_StateWaitForResources, /**< component is waiting for resources, either after + preemption or before it gets the resources requested. + See specification for complete details. */ + OMX_StateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_StateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_StateMax = 0X7FFFFFFF +} OMX_STATETYPE; + +/** The OMX_ERRORTYPE enumeration defines the standard OMX Errors. These + * errors should cover most of the common failure cases. However, + * vendors are free to add additional error messages of their own as + * long as they follow these rules: + * 1. Vendor error messages shall be in the range of 0x90000000 to + * 0x9000FFFF. + * 2. Vendor error messages shall be defined in a header file provided + * with the component. No error messages are allowed that are + * not defined. + */ +typedef enum OMX_ERRORTYPE +{ + OMX_ErrorNone = 0, + + /** There were insufficient resources to perform the requested operation */ + OMX_ErrorInsufficientResources = (OMX_S32) 0x80001000, + + /** There was an error, but the cause of the error could not be determined */ + OMX_ErrorUndefined = (OMX_S32) 0x80001001, + + /** The component name string was not valid */ + OMX_ErrorInvalidComponentName = (OMX_S32) 0x80001002, + + /** No component with the specified name string was found */ + OMX_ErrorComponentNotFound = (OMX_S32) 0x80001003, + + /** The component specified did not have a "OMX_ComponentInit" or + "OMX_ComponentDeInit entry point */ + OMX_ErrorInvalidComponent = (OMX_S32) 0x80001004, + + /** One or more parameters were not valid */ + OMX_ErrorBadParameter = (OMX_S32) 0x80001005, + + /** The requested function is not implemented */ + OMX_ErrorNotImplemented = (OMX_S32) 0x80001006, + + /** The buffer was emptied before the next buffer was ready */ + OMX_ErrorUnderflow = (OMX_S32) 0x80001007, + + /** The buffer was not available when it was needed */ + OMX_ErrorOverflow = (OMX_S32) 0x80001008, + + /** The hardware failed to respond as expected */ + OMX_ErrorHardware = (OMX_S32) 0x80001009, + + /** The component is in the state OMX_StateInvalid */ + OMX_ErrorInvalidState = (OMX_S32) 0x8000100A, + + /** Stream is found to be corrupt */ + OMX_ErrorStreamCorrupt = (OMX_S32) 0x8000100B, + + /** Ports being connected are not compatible */ + OMX_ErrorPortsNotCompatible = (OMX_S32) 0x8000100C, + + /** Resources allocated to an idle component have been + lost resulting in the component returning to the loaded state */ + OMX_ErrorResourcesLost = (OMX_S32) 0x8000100D, + + /** No more indicies can be enumerated */ + OMX_ErrorNoMore = (OMX_S32) 0x8000100E, + + /** The component detected a version mismatch */ + OMX_ErrorVersionMismatch = (OMX_S32) 0x8000100F, + + /** The component is not ready to return data at this time */ + OMX_ErrorNotReady = (OMX_S32) 0x80001010, + + /** There was a timeout that occurred */ + OMX_ErrorTimeout = (OMX_S32) 0x80001011, + + /** This error occurs when trying to transition into the state you are already in */ + OMX_ErrorSameState = (OMX_S32) 0x80001012, + + /** Resources allocated to an executing or paused component have been + preempted, causing the component to return to the idle state */ + OMX_ErrorResourcesPreempted = (OMX_S32) 0x80001013, + + /** A non-supplier port sends this error to the IL client (via the EventHandler callback) + during the allocation of buffers (on a transition from the LOADED to the IDLE state or + on a port restart) when it deems that it has waited an unusually long time for the supplier + to send it an allocated buffer via a UseBuffer call. */ + OMX_ErrorPortUnresponsiveDuringAllocation = (OMX_S32) 0x80001014, + + /** A non-supplier port sends this error to the IL client (via the EventHandler callback) + during the deallocation of buffers (on a transition from the IDLE to LOADED state or + on a port stop) when it deems that it has waited an unusually long time for the supplier + to request the deallocation of a buffer header via a FreeBuffer call. */ + OMX_ErrorPortUnresponsiveDuringDeallocation = (OMX_S32) 0x80001015, + + /** A supplier port sends this error to the IL client (via the EventHandler callback) + during the stopping of a port (either on a transition from the IDLE to LOADED + state or a port stop) when it deems that it has waited an unusually long time for + the non-supplier to return a buffer via an EmptyThisBuffer or FillThisBuffer call. */ + OMX_ErrorPortUnresponsiveDuringStop = (OMX_S32) 0x80001016, + + /** Attempting a state transtion that is not allowed */ + OMX_ErrorIncorrectStateTransition = (OMX_S32) 0x80001017, + + /* Attempting a command that is not allowed during the present state. */ + OMX_ErrorIncorrectStateOperation = (OMX_S32) 0x80001018, + + /** The values encapsulated in the parameter or config structure are not supported. */ + OMX_ErrorUnsupportedSetting = (OMX_S32) 0x80001019, + + /** The parameter or config indicated by the given index is not supported. */ + OMX_ErrorUnsupportedIndex = (OMX_S32) 0x8000101A, + + /** The port index supplied is incorrect. */ + OMX_ErrorBadPortIndex = (OMX_S32) 0x8000101B, + + /** The port has lost one or more of its buffers and it thus unpopulated. */ + OMX_ErrorPortUnpopulated = (OMX_S32) 0x8000101C, + + /** Component suspended due to temporary loss of resources */ + OMX_ErrorComponentSuspended = (OMX_S32) 0x8000101D, + + /** Component suspended due to an inability to acquire dynamic resources */ + OMX_ErrorDynamicResourcesUnavailable = (OMX_S32) 0x8000101E, + + /** When the macroblock error reporting is enabled the component returns new error + for every frame that has errors */ + OMX_ErrorMbErrorsInFrame = (OMX_S32) 0x8000101F, + + /** A component reports this error when it cannot parse or determine the format of an input stream. */ + OMX_ErrorFormatNotDetected = (OMX_S32) 0x80001020, + + /** The content open operation failed. */ + OMX_ErrorContentPipeOpenFailed = (OMX_S32) 0x80001021, + + /** The content creation operation failed. */ + OMX_ErrorContentPipeCreationFailed = (OMX_S32) 0x80001022, + + /** Separate table information is being used */ + OMX_ErrorSeperateTablesUsed = (OMX_S32) 0x80001023, + + /** Tunneling is unsupported by the component*/ + OMX_ErrorTunnelingUnsupported = (OMX_S32) 0x80001024, + + OMX_ErrorKhronosExtensions = (OMX_S32)0x8F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_ErrorVendorStartUnused = (OMX_S32)0x90000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_ErrorMax = 0x7FFFFFFF +} OMX_ERRORTYPE; + +/** @ingroup core */ +typedef OMX_ERRORTYPE (* OMX_COMPONENTINITTYPE)(OMX_IN OMX_HANDLETYPE hComponent); + +/** @ingroup core */ +typedef struct OMX_COMPONENTREGISTERTYPE +{ + const char * pName; /* Component name, 128 byte limit (including '\0') applies */ + OMX_COMPONENTINITTYPE pInitialize; /* Component instance initialization function */ +} OMX_COMPONENTREGISTERTYPE; + +/** @ingroup core */ +extern OMX_COMPONENTREGISTERTYPE OMX_ComponentRegistered[]; + +/** @ingroup rpm */ +typedef struct OMX_PRIORITYMGMTTYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nGroupPriority; /**< Priority of the component group */ + OMX_U32 nGroupID; /**< ID of the component group */ +} OMX_PRIORITYMGMTTYPE; + +/* Component name and Role names are limited to 128 characters including the terminating '\0'. */ +#define OMX_MAX_STRINGNAME_SIZE 128 + +/** @ingroup comp */ +typedef struct OMX_PARAM_COMPONENTROLETYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U8 cRole[OMX_MAX_STRINGNAME_SIZE]; /**< name of standard component which defines component role */ +} OMX_PARAM_COMPONENTROLETYPE; + +/** End of Stream Buffer Flag: + * + * A component sets EOS when it has no more data to emit on a particular + * output port. Thus an output port shall set EOS on the last buffer it + * emits. A component's determination of when an output port should + * cease sending data is implemenation specific. + * @ingroup buf + */ + +#define OMX_BUFFERFLAG_EOS 0x00000001 + +/** Start Time Buffer Flag: + * + * The source of a stream (e.g. a demux component) sets the STARTTIME + * flag on the buffer that contains the starting timestamp for the + * stream. The starting timestamp corresponds to the first data that + * should be displayed at startup or after a seek. + * The first timestamp of the stream is not necessarily the start time. + * For instance, in the case of a seek to a particular video frame, + * the target frame may be an interframe. Thus the first buffer of + * the stream will be the intra-frame preceding the target frame and + * the starttime will occur with the target frame (with any other + * required frames required to reconstruct the target intervening). + * + * The STARTTIME flag is directly associated with the buffer's + * timestamp ' thus its association to buffer data and its + * propagation is identical to the timestamp's. + * + * When a Sync Component client receives a buffer with the + * STARTTIME flag it shall perform a SetConfig on its sync port + * using OMX_ConfigTimeClientStartTime and passing the buffer's + * timestamp. + * + * @ingroup buf + */ + +#define OMX_BUFFERFLAG_STARTTIME 0x00000002 + + + +/** Decode Only Buffer Flag: + * + * The source of a stream (e.g. a demux component) sets the DECODEONLY + * flag on any buffer that should shall be decoded but should not be + * displayed. This flag is used, for instance, when a source seeks to + * a target interframe that requires the decode of frames preceding the + * target to facilitate the target's reconstruction. In this case the + * source would emit the frames preceding the target downstream + * but mark them as decode only. + * + * The DECODEONLY is associated with buffer data and propagated in a + * manner identical to the buffer timestamp. + * + * A component that renders data should ignore all buffers with + * the DECODEONLY flag set. + * + * @ingroup buf + */ + +#define OMX_BUFFERFLAG_DECODEONLY 0x00000004 + + +/* Data Corrupt Flag: This flag is set when the IL client believes the data in the associated buffer is corrupt + * @ingroup buf + */ + +#define OMX_BUFFERFLAG_DATACORRUPT 0x00000008 + +/* End of Frame: The buffer contains exactly one end of frame and no data + * occurs after the end of frame. This flag is an optional hint. The absence + * of this flag does not imply the absence of an end of frame within the buffer. + * @ingroup buf +*/ +#define OMX_BUFFERFLAG_ENDOFFRAME 0x00000010 + +/* Sync Frame Flag: This flag is set when the buffer content contains a coded sync frame ' + * a frame that has no dependency on any other frame information + * @ingroup buf + */ +#define OMX_BUFFERFLAG_SYNCFRAME 0x00000020 + +/* Extra data present flag: there is extra data appended to the data stream + * residing in the buffer + * @ingroup buf + */ +#define OMX_BUFFERFLAG_EXTRADATA 0x00000040 + +/** Codec Config Buffer Flag: +* OMX_BUFFERFLAG_CODECCONFIG is an optional flag that is set by an +* output port when all bytes in the buffer form part or all of a set of +* codec specific configuration data. Examples include SPS/PPS nal units +* for OMX_VIDEO_CodingAVC or AudioSpecificConfig data for +* OMX_AUDIO_CodingAAC. Any component that for a given stream sets +* OMX_BUFFERFLAG_CODECCONFIG shall not mix codec configuration bytes +* with frame data in the same buffer, and shall send all buffers +* containing codec configuration bytes before any buffers containing +* frame data that those configurations bytes describe. +* If the stream format for a particular codec has a frame specific +* header at the start of each frame, for example OMX_AUDIO_CodingMP3 or +* OMX_AUDIO_CodingAAC in ADTS mode, then these shall be presented as +* normal without setting OMX_BUFFERFLAG_CODECCONFIG. + * @ingroup buf + */ +#define OMX_BUFFERFLAG_CODECCONFIG 0x00000080 + + + +/** @ingroup buf */ +typedef struct OMX_BUFFERHEADERTYPE +{ + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U8* pBuffer; /**< Pointer to actual block of memory + that is acting as the buffer */ + OMX_U32 nAllocLen; /**< size of the buffer allocated, in bytes */ + OMX_U32 nFilledLen; /**< number of bytes currently in the + buffer */ + OMX_U32 nOffset; /**< start offset of valid data in bytes from + the start of the buffer */ + OMX_PTR pAppPrivate; /**< pointer to any data the application + wants to associate with this buffer */ + OMX_PTR pPlatformPrivate; /**< pointer to any data the platform + wants to associate with this buffer */ + OMX_PTR pInputPortPrivate; /**< pointer to any data the input port + wants to associate with this buffer */ + OMX_PTR pOutputPortPrivate; /**< pointer to any data the output port + wants to associate with this buffer */ + OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will generate a + mark event upon processing this buffer. */ + OMX_PTR pMarkData; /**< Application specific data associated with + the mark sent on a mark event to disambiguate + this mark from others. */ + OMX_U32 nTickCount; /**< Optional entry that the component and + application can update with a tick count + when they access the component. This + value should be in microseconds. Since + this is a value relative to an arbitrary + starting point, this value cannot be used + to determine absolute time. This is an + optional entry and not all components + will update it.*/ + OMX_TICKS nTimeStamp; /**< Timestamp corresponding to the sample + starting at the first logical sample + boundary in the buffer. Timestamps of + successive samples within the buffer may + be inferred by adding the duration of the + of the preceding buffer to the timestamp + of the preceding buffer.*/ + OMX_U32 nFlags; /**< buffer specific flags */ + OMX_U32 nOutputPortIndex; /**< The index of the output port (if any) using + this buffer */ + OMX_U32 nInputPortIndex; /**< The index of the input port (if any) using + this buffer */ +} OMX_BUFFERHEADERTYPE; + +/** The OMX_EXTRADATATYPE enumeration is used to define the + * possible extra data payload types. + * NB: this enum is binary backwards compatible with the previous + * OMX_EXTRADATA_QUANT define. This should be replaced with + * OMX_ExtraDataQuantization. + */ +typedef enum OMX_EXTRADATATYPE +{ + OMX_ExtraDataNone = 0, /**< Indicates that no more extra data sections follow */ + OMX_ExtraDataQuantization, /**< The data payload contains quantization data */ + OMX_ExtraDataKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_ExtraDataVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_ExtraDataMax = 0x7FFFFFFF +} OMX_EXTRADATATYPE; + + +typedef struct OMX_OTHER_EXTRADATATYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_EXTRADATATYPE eType; /* Extra Data type */ + OMX_U32 nDataSize; /* Size of the supporting data to follow */ + OMX_U8 data[1]; /* Supporting data hint */ +} OMX_OTHER_EXTRADATATYPE; + +/** @ingroup comp */ +typedef struct OMX_PORT_PARAM_TYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nPorts; /**< The number of ports for this component */ + OMX_U32 nStartPortNumber; /** first port number for this type of port */ +} OMX_PORT_PARAM_TYPE; + +/** @ingroup comp */ +typedef enum OMX_EVENTTYPE +{ + OMX_EventCmdComplete, /**< component has sucessfully completed a command */ + OMX_EventError, /**< component has detected an error condition */ + OMX_EventMark, /**< component has detected a buffer mark */ + OMX_EventPortSettingsChanged, /**< component is reported a port settings change */ + OMX_EventBufferFlag, /**< component has detected an EOS */ + OMX_EventResourcesAcquired, /**< component has been granted resources and is + automatically starting the state change from + OMX_StateWaitForResources to OMX_StateIdle. */ + OMX_EventComponentResumed, /**< Component resumed due to reacquisition of resources */ + OMX_EventDynamicResourcesAvailable, /**< Component has acquired previously unavailable dynamic resources */ + OMX_EventPortFormatDetected, /**< Component has detected a supported format. */ + OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_EventMax = 0x7FFFFFFF +} OMX_EVENTTYPE; + +typedef struct OMX_CALLBACKTYPE +{ + /** The EventHandler method is used to notify the application when an + event of interest occurs. Events are defined in the OMX_EVENTTYPE + enumeration. Please see that enumeration for details of what will + be returned for each type of event. Callbacks should not return + an error to the component, so if an error occurs, the application + shall handle it internally. This is a blocking call. + + The application should return from this call within 5 msec to avoid + blocking the component for an excessively long period of time. + + @param hComponent + handle of the component to access. This is the component + handle returned by the call to the GetHandle function. + @param pAppData + pointer to an application defined value that was provided in the + pAppData parameter to the OMX_GetHandle method for the component. + This application defined value is provided so that the application + can have a component specific context when receiving the callback. + @param eEvent + Event that the component wants to notify the application about. + @param nData1 + nData will be the OMX_ERRORTYPE for an error event and will be + an OMX_COMMANDTYPE for a command complete event and OMX_INDEXTYPE for a OMX_PortSettingsChanged event. + @param nData2 + nData2 will hold further information related to the event. Can be OMX_STATETYPE for + a OMX_CommandStateSet command or port index for a OMX_PortSettingsChanged event. + Default value is 0 if not used. ) + @param pEventData + Pointer to additional event-specific data (see spec for meaning). + */ + + OMX_ERRORTYPE (*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); + + /** The EmptyBufferDone method is used to return emptied buffers from an + input port back to the application for reuse. This is a blocking call + so the application should not attempt to refill the buffers during this + call, but should queue them and refill them in another thread. There + is no error return, so the application shall handle any errors generated + internally. + + The application should return from this call within 5 msec. + + @param hComponent + handle of the component to access. This is the component + handle returned by the call to the GetHandle function. + @param pAppData + pointer to an application defined value that was provided in the + pAppData parameter to the OMX_GetHandle method for the component. + This application defined value is provided so that the application + can have a component specific context when receiving the callback. + @param pBuffer + pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer + or AllocateBuffer indicating the buffer that was emptied. + @ingroup buf + */ + OMX_ERRORTYPE (*EmptyBufferDone)( + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_PTR pAppData, + OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); + + /** The FillBufferDone method is used to return filled buffers from an + output port back to the application for emptying and then reuse. + This is a blocking call so the application should not attempt to + empty the buffers during this call, but should queue the buffers + and empty them in another thread. There is no error return, so + the application shall handle any errors generated internally. The + application shall also update the buffer header to indicate the + number of bytes placed into the buffer. + + The application should return from this call within 5 msec. + + @param hComponent + handle of the component to access. This is the component + handle returned by the call to the GetHandle function. + @param pAppData + pointer to an application defined value that was provided in the + pAppData parameter to the OMX_GetHandle method for the component. + This application defined value is provided so that the application + can have a component specific context when receiving the callback. + @param pBuffer + pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer + or AllocateBuffer indicating the buffer that was filled. + @ingroup buf + */ + OMX_ERRORTYPE (*FillBufferDone)( + OMX_OUT OMX_HANDLETYPE hComponent, + OMX_OUT OMX_PTR pAppData, + OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer); + +} OMX_CALLBACKTYPE; + +/** The OMX_BUFFERSUPPLIERTYPE enumeration is used to dictate port supplier + preference when tunneling between two ports. + @ingroup tun buf +*/ +typedef enum OMX_BUFFERSUPPLIERTYPE +{ + OMX_BufferSupplyUnspecified = 0x0, /**< port supplying the buffers is unspecified, + or don't care */ + OMX_BufferSupplyInput, /**< input port supplies the buffers */ + OMX_BufferSupplyOutput, /**< output port supplies the buffers */ + OMX_BufferSupplyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_BufferSupplyVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_BufferSupplyMax = 0x7FFFFFFF +} OMX_BUFFERSUPPLIERTYPE; + + +/** buffer supplier parameter + * @ingroup tun + */ +typedef struct OMX_PARAM_BUFFERSUPPLIERTYPE { + 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_BUFFERSUPPLIERTYPE eBufferSupplier; /**< buffer supplier */ +} OMX_PARAM_BUFFERSUPPLIERTYPE; + + +/**< indicates that buffers received by an input port of a tunnel + may not modify the data in the buffers + @ingroup tun + */ +#define OMX_PORTTUNNELFLAG_READONLY 0x00000001 + + +/** The OMX_TUNNELSETUPTYPE structure is used to pass data from an output + port to an input port as part the two ComponentTunnelRequest calls + resulting from a OMX_SetupTunnel call from the IL Client. + @ingroup tun + */ +typedef struct OMX_TUNNELSETUPTYPE +{ + OMX_U32 nTunnelFlags; /**< bit flags for tunneling */ + OMX_BUFFERSUPPLIERTYPE eSupplier; /**< supplier preference */ +} OMX_TUNNELSETUPTYPE; + +/* OMX Component headers is included to enable the core to use + macros for functions into the component for OMX release 1.0. + Developers should not access any structures or data from within + the component header directly */ +/* TO BE REMOVED - #include */ + +/** GetComponentVersion will return information about the component. + This is a blocking call. This macro will go directly from the + application to the component (via a core macro). The + component will return from this call within 5 msec. + @param [in] hComponent + handle of component to execute the command + @param [out] pComponentName + pointer to an empty string of length 128 bytes. The component + will write its name into this string. The name will be + terminated by a single zero byte. The name of a component will + be 127 bytes or less to leave room for the trailing zero byte. + An example of a valid component name is "OMX.ABC.ChannelMixer\0". + @param [out] pComponentVersion + pointer to an OMX Version structure that the component will fill + in. The component will fill in a value that indicates the + component version. NOTE: the component version is NOT the same + as the OMX Specification version (found in all structures). The + component version is defined by the vendor of the component and + its value is entirely up to the component vendor. + @param [out] pSpecVersion + pointer to an OMX Version structure that the component will fill + in. The SpecVersion is the version of the specification that the + component was built against. Please note that this value may or + may not match the structure's version. For example, if the + component was built against the 2.0 specification, but the + application (which creates the structure is built against the + 1.0 specification the versions would be different. + @param [out] pComponentUUID + pointer to the UUID of the component which will be filled in by + the component. The UUID is a unique identifier that is set at + RUN time for the component and is unique to each instantion of + the component. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp + */ +#define OMX_GetComponentVersion( \ + hComponent, \ + pComponentName, \ + pComponentVersion, \ + pSpecVersion, \ + pComponentUUID) \ + ((OMX_COMPONENTTYPE*)hComponent)->GetComponentVersion( \ + hComponent, \ + pComponentName, \ + pComponentVersion, \ + pSpecVersion, \ + pComponentUUID) /* Macro End */ + + +/** Send a command to the component. This call is a non-blocking call. + The component should check the parameters and then queue the command + to the component thread to be executed. The component thread shall + send the EventHandler() callback at the conclusion of the command. + This macro will go directly from the application to the component (via + a core macro). The component will return from this call within 5 msec. + + When the command is "OMX_CommandStateSet" the component will queue a + state transition to the new state idenfied in nParam. + + When the command is "OMX_CommandFlush", to flush a port's buffer queues, + the command will force the component to return all buffers NOT CURRENTLY + BEING PROCESSED to the application, in the order in which the buffers + were received. + + When the command is "OMX_CommandPortDisable" or + "OMX_CommandPortEnable", the component's port (given by the value of + nParam) will be stopped or restarted. + + When the command "OMX_CommandMarkBuffer" is used to mark a buffer, the + pCmdData will point to a OMX_MARKTYPE structure containing the component + handle of the component to examine the buffer chain for the mark. nParam1 + contains the index of the port on which the buffer mark is applied. + + Specification text for more details. + + @param [in] hComponent + handle of component to execute the command + @param [in] Cmd + Command for the component to execute + @param [in] nParam + Parameter for the command to be executed. When Cmd has the value + OMX_CommandStateSet, value is a member of OMX_STATETYPE. When Cmd has + the value OMX_CommandFlush, value of nParam indicates which port(s) + to flush. -1 is used to flush all ports a single port index will + only flush that port. When Cmd has the value "OMX_CommandPortDisable" + or "OMX_CommandPortEnable", the component's port is given by + the value of nParam. When Cmd has the value "OMX_CommandMarkBuffer" + the components pot is given by the value of nParam. + @param [in] pCmdData + Parameter pointing to the OMX_MARKTYPE structure when Cmd has the value + "OMX_CommandMarkBuffer". + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp + */ +#define OMX_SendCommand( \ + hComponent, \ + Cmd, \ + nParam, \ + pCmdData) \ + ((OMX_COMPONENTTYPE*)hComponent)->SendCommand( \ + hComponent, \ + Cmd, \ + nParam, \ + pCmdData) /* Macro End */ + + +/** The OMX_GetParameter macro will get one of the current parameter + settings from the component. This macro cannot only be invoked when + the component is in the OMX_StateInvalid state. The nParamIndex + parameter is used to indicate which structure is being requested from + the component. The application shall allocate the correct structure + and shall fill in the structure size and version information before + invoking this macro. When the parameter applies to a port, the + caller shall fill in the appropriate nPortIndex value indicating the + port on which the parameter applies. If the component has not had + any settings changed, then the component should return a set of + valid DEFAULT parameters for the component. This is a blocking + call. + + The component should return from this call within 20 msec. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the OMX_GetHandle function. + @param [in] nParamIndex + Index of the structure to be filled. This value is from the + OMX_INDEXTYPE enumeration. + @param [in,out] pComponentParameterStructure + Pointer to application allocated structure to be filled by the + component. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp + */ +#define OMX_GetParameter( \ + hComponent, \ + nParamIndex, \ + pComponentParameterStructure) \ + ((OMX_COMPONENTTYPE*)hComponent)->GetParameter( \ + hComponent, \ + nParamIndex, \ + pComponentParameterStructure) /* Macro End */ + + +/** The OMX_SetParameter macro will send an initialization parameter + structure to a component. Each structure shall be sent one at a time, + in a separate invocation of the macro. This macro can only be + invoked when the component is in the OMX_StateLoaded state, or the + port is disabled (when the parameter applies to a port). The + nParamIndex parameter is used to indicate which structure is being + passed to the component. The application shall allocate the + correct structure and shall fill in the structure size and version + information (as well as the actual data) before invoking this macro. + The application is free to dispose of this structure after the call + as the component is required to copy any data it shall retain. This + is a blocking call. + + The component should return from this call within 20 msec. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the OMX_GetHandle function. + @param [in] nIndex + Index of the structure to be sent. This value is from the + OMX_INDEXTYPE enumeration. + @param [in] pComponentParameterStructure + pointer to application allocated structure to be used for + initialization by the component. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp + */ +#define OMX_SetParameter( \ + hComponent, \ + nParamIndex, \ + pComponentParameterStructure) \ + ((OMX_COMPONENTTYPE*)hComponent)->SetParameter( \ + hComponent, \ + nParamIndex, \ + pComponentParameterStructure) /* Macro End */ + + +/** The OMX_GetConfig macro will get one of the configuration structures + from a component. This macro can be invoked anytime after the + component has been loaded. The nParamIndex call parameter is used to + indicate which structure is being requested from the component. The + application shall allocate the correct structure and shall fill in the + structure size and version information before invoking this macro. + If the component has not had this configuration parameter sent before, + then the component should return a set of valid DEFAULT values for the + component. This is a blocking call. + + The component should return from this call within 5 msec. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the OMX_GetHandle function. + @param [in] nIndex + Index of the structure to be filled. This value is from the + OMX_INDEXTYPE enumeration. + @param [in,out] pComponentConfigStructure + pointer to application allocated structure to be filled by the + component. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp +*/ +#define OMX_GetConfig( \ + hComponent, \ + nConfigIndex, \ + pComponentConfigStructure) \ + ((OMX_COMPONENTTYPE*)hComponent)->GetConfig( \ + hComponent, \ + nConfigIndex, \ + pComponentConfigStructure) /* Macro End */ + + +/** The OMX_SetConfig macro will send one of the configuration + structures to a component. Each structure shall be sent one at a time, + each in a separate invocation of the macro. This macro can be invoked + anytime after the component has been loaded. The application shall + allocate the correct structure and shall fill in the structure size + and version information (as well as the actual data) before invoking + this macro. The application is free to dispose of this structure after + the call as the component is required to copy any data it shall retain. + This is a blocking call. + + The component should return from this call within 5 msec. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the OMX_GetHandle function. + @param [in] nConfigIndex + Index of the structure to be sent. This value is from the + OMX_INDEXTYPE enumeration above. + @param [in] pComponentConfigStructure + pointer to application allocated structure to be used for + initialization by the component. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp + */ +#define OMX_SetConfig( \ + hComponent, \ + nConfigIndex, \ + pComponentConfigStructure) \ + ((OMX_COMPONENTTYPE*)hComponent)->SetConfig( \ + hComponent, \ + nConfigIndex, \ + pComponentConfigStructure) /* Macro End */ + + +/** The OMX_GetExtensionIndex macro will invoke a component to translate + a vendor specific configuration or parameter string into an OMX + structure index. There is no requirement for the vendor to support + this command for the indexes already found in the OMX_INDEXTYPE + enumeration (this is done to save space in small components). The + component shall support all vendor supplied extension indexes not found + in the master OMX_INDEXTYPE enumeration. This is a blocking call. + + The component should return from this call within 5 msec. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the GetHandle function. + @param [in] cParameterName + OMX_STRING that shall be less than 128 characters long including + the trailing null byte. This is the string that will get + translated by the component into a configuration index. + @param [out] pIndexType + a pointer to a OMX_INDEXTYPE to receive the index value. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp + */ +#define OMX_GetExtensionIndex( \ + hComponent, \ + cParameterName, \ + pIndexType) \ + ((OMX_COMPONENTTYPE*)hComponent)->GetExtensionIndex( \ + hComponent, \ + cParameterName, \ + pIndexType) /* Macro End */ + + +/** The OMX_GetState macro will invoke the component to get the current + state of the component and place the state value into the location + pointed to by pState. + + The component should return from this call within 5 msec. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the OMX_GetHandle function. + @param [out] pState + pointer to the location to receive the state. The value returned + is one of the OMX_STATETYPE members + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp + */ +#define OMX_GetState( \ + hComponent, \ + pState) \ + ((OMX_COMPONENTTYPE*)hComponent)->GetState( \ + hComponent, \ + pState) /* Macro End */ + + +/** The OMX_UseBuffer macro will request that the component use + a buffer (and allocate its own buffer header) already allocated + by another component, or by the IL Client. This is a blocking + call. + + The component should return from this call within 20 msec. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the OMX_GetHandle function. + @param [out] ppBuffer + pointer to an OMX_BUFFERHEADERTYPE structure used to receive the + pointer to the buffer header + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp buf + */ + +#define OMX_UseBuffer( \ + hComponent, \ + ppBufferHdr, \ + nPortIndex, \ + pAppPrivate, \ + nSizeBytes, \ + pBuffer) \ + ((OMX_COMPONENTTYPE*)hComponent)->UseBuffer( \ + hComponent, \ + ppBufferHdr, \ + nPortIndex, \ + pAppPrivate, \ + nSizeBytes, \ + pBuffer) + + +/** The OMX_AllocateBuffer macro will request that the component allocate + a new buffer and buffer header. The component will allocate the + buffer and the buffer header and return a pointer to the buffer + header. This is a blocking call. + + The component should return from this call within 5 msec. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the OMX_GetHandle function. + @param [out] ppBuffer + pointer to an OMX_BUFFERHEADERTYPE structure used to receive + the pointer to the buffer header + @param [in] nPortIndex + nPortIndex is used to select the port on the component the buffer will + be used with. The port can be found by using the nPortIndex + value as an index into the Port Definition array of the component. + @param [in] pAppPrivate + pAppPrivate is used to initialize the pAppPrivate member of the + buffer header structure. + @param [in] nSizeBytes + size of the buffer to allocate. Used when bAllocateNew is true. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp buf + */ +#define OMX_AllocateBuffer( \ + hComponent, \ + ppBuffer, \ + nPortIndex, \ + pAppPrivate, \ + nSizeBytes) \ + ((OMX_COMPONENTTYPE*)hComponent)->AllocateBuffer( \ + hComponent, \ + ppBuffer, \ + nPortIndex, \ + pAppPrivate, \ + nSizeBytes) /* Macro End */ + + +/** The OMX_FreeBuffer macro will release a buffer header from the component + which was allocated using either OMX_AllocateBuffer or OMX_UseBuffer. If + the component allocated the buffer (see the OMX_UseBuffer macro) then + the component shall free the buffer and buffer header. This is a + blocking call. + + The component should return from this call within 20 msec. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the OMX_GetHandle function. + @param [in] nPortIndex + nPortIndex is used to select the port on the component the buffer will + be used with. + @param [in] pBuffer + pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer + or AllocateBuffer. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp buf + */ +#define OMX_FreeBuffer( \ + hComponent, \ + nPortIndex, \ + pBuffer) \ + ((OMX_COMPONENTTYPE*)hComponent)->FreeBuffer( \ + hComponent, \ + nPortIndex, \ + pBuffer) /* Macro End */ + + +/** The OMX_EmptyThisBuffer macro will send a buffer full of data to an + input port of a component. The buffer will be emptied by the component + and returned to the application via the EmptyBufferDone call back. + This is a non-blocking call in that the component will record the buffer + and return immediately and then empty the buffer, later, at the proper + time. As expected, this macro may be invoked only while the component + is in the OMX_StateExecuting. If nPortIndex does not specify an input + port, the component shall return an error. + + The component should return from this call within 5 msec. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the OMX_GetHandle function. + @param [in] pBuffer + pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer + or AllocateBuffer. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp buf + */ +#define OMX_EmptyThisBuffer( \ + hComponent, \ + pBuffer) \ + ((OMX_COMPONENTTYPE*)hComponent)->EmptyThisBuffer( \ + hComponent, \ + pBuffer) /* Macro End */ + + +/** The OMX_FillThisBuffer macro will send an empty buffer to an + output port of a component. The buffer will be filled by the component + and returned to the application via the FillBufferDone call back. + This is a non-blocking call in that the component will record the buffer + and return immediately and then fill the buffer, later, at the proper + time. As expected, this macro may be invoked only while the component + is in the OMX_ExecutingState. If nPortIndex does not specify an output + port, the component shall return an error. + + The component should return from this call within 5 msec. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the OMX_GetHandle function. + @param [in] pBuffer + pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer + or AllocateBuffer. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp buf + */ +#define OMX_FillThisBuffer( \ + hComponent, \ + pBuffer) \ + ((OMX_COMPONENTTYPE*)hComponent)->FillThisBuffer( \ + hComponent, \ + pBuffer) /* Macro End */ + + + +/** The OMX_UseEGLImage macro will request that the component use + a EGLImage provided by EGL (and allocate its own buffer header) + This is a blocking call. + + The component should return from this call within 20 msec. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the OMX_GetHandle function. + @param [out] ppBuffer + pointer to an OMX_BUFFERHEADERTYPE structure used to receive the + pointer to the buffer header. Note that the memory location used + for this buffer is NOT visible to the IL Client. + @param [in] nPortIndex + nPortIndex is used to select the port on the component the buffer will + be used with. The port can be found by using the nPortIndex + value as an index into the Port Definition array of the component. + @param [in] pAppPrivate + pAppPrivate is used to initialize the pAppPrivate member of the + buffer header structure. + @param [in] eglImage + eglImage contains the handle of the EGLImage to use as a buffer on the + specified port. The component is expected to validate properties of + the EGLImage against the configuration of the port to ensure the component + can use the EGLImage as a buffer. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup comp buf + */ +#define OMX_UseEGLImage( \ + hComponent, \ + ppBufferHdr, \ + nPortIndex, \ + pAppPrivate, \ + eglImage) \ + ((OMX_COMPONENTTYPE*)hComponent)->UseEGLImage( \ + hComponent, \ + ppBufferHdr, \ + nPortIndex, \ + pAppPrivate, \ + eglImage) + +/** The OMX_Init method is used to initialize the OMX core. It shall be the + first call made into OMX and it should only be executed one time without + an interviening OMX_Deinit call. + + The core should return from this call within 20 msec. + + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup core + */ +OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Init(void); + + +/** The OMX_Deinit method is used to deinitialize the OMX core. It shall be + the last call made into OMX. In the event that the core determines that + thare are components loaded when this call is made, the core may return + with an error rather than try to unload the components. + + The core should return from this call within 20 msec. + + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup core + */ +OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Deinit(void); + + +/** The OMX_ComponentNameEnum method will enumerate through all the names of + recognised valid components in the system. This function is provided + as a means to detect all the components in the system run-time. There is + no strict ordering to the enumeration order of component names, although + each name will only be enumerated once. If the OMX core supports run-time + installation of new components, it is only requried to detect newly + installed components when the first call to enumerate component names + is made (i.e. when nIndex is 0x0). + + The core should return from this call in 20 msec. + + @param [out] cComponentName + pointer to a null terminated string with the component name. The + names of the components are strings less than 127 bytes in length + plus the trailing null for a maximum size of 128 bytes. An example + of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0". Names are + assigned by the vendor, but shall start with "OMX." and then have + the Vendor designation next. + @param [in] nNameLength + number of characters in the cComponentName string. With all + component name strings restricted to less than 128 characters + (including the trailing null) it is recomended that the caller + provide a input string for the cComponentName of 128 characters. + @param [in] nIndex + number containing the enumeration index for the component. + Multiple calls to OMX_ComponentNameEnum with increasing values + of nIndex will enumerate through the component names in the + system until OMX_ErrorNoMore is returned. The value of nIndex + is 0 to (N-1), where N is the number of valid installed components + in the system. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. When the value of nIndex exceeds the number of + components in the system minus 1, OMX_ErrorNoMore will be + returned. Otherwise the appropriate OMX error will be returned. + @ingroup core + */ +OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum( + OMX_OUT OMX_STRING cComponentName, + OMX_IN OMX_U32 nNameLength, + OMX_IN OMX_U32 nIndex); + + +/** The OMX_GetHandle method will locate the component specified by the + component name given, load that component into memory and then invoke + the component's methods to create an instance of the component. + + The core should return from this call within 20 msec. + + @param [out] pHandle + pointer to an OMX_HANDLETYPE pointer to be filled in by this method. + @param [in] cComponentName + pointer to a null terminated string with the component name. The + names of the components are strings less than 127 bytes in length + plus the trailing null for a maximum size of 128 bytes. An example + of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0". Names are + assigned by the vendor, but shall start with "OMX." and then have + the Vendor designation next. + @param [in] pAppData + pointer to an application defined value that will be returned + during callbacks so that the application can identify the source + of the callback. + @param [in] pCallBacks + pointer to a OMX_CALLBACKTYPE structure that will be passed to the + component to initialize it with. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup core + */ +OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle( + OMX_OUT OMX_HANDLETYPE* pHandle, + OMX_IN OMX_STRING cComponentName, + OMX_IN OMX_PTR pAppData, + OMX_IN OMX_CALLBACKTYPE* pCallBacks); + + +/** The OMX_FreeHandle method will free a handle allocated by the OMX_GetHandle + method. If the component reference count goes to zero, the component will + be unloaded from memory. + + The core should return from this call within 20 msec when the component is + in the OMX_StateLoaded state. + + @param [in] hComponent + Handle of the component to be accessed. This is the component + handle returned by the call to the GetHandle function. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + @ingroup core + */ +OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle( + OMX_IN OMX_HANDLETYPE hComponent); + + + +/** The OMX_SetupTunnel method will handle the necessary calls to the components + to setup the specified tunnel the two components. NOTE: This is + an actual method (not a #define macro). This method will make calls into + the component ComponentTunnelRequest method to do the actual tunnel + connection. + + The ComponentTunnelRequest method on both components will be called. + This method shall not be called unless the component is in the + OMX_StateLoaded state except when the ports used for the tunnel are + disabled. In this case, the component may be in the OMX_StateExecuting, + OMX_StatePause, or OMX_StateIdle states. + + The core should return from this call within 20 msec. + + @param [in] hOutput + Handle of the component to be accessed. Also this is the handle + of the component whose port, specified in the nPortOutput parameter + will be used the source for the tunnel. This is the component handle + returned by the call to the OMX_GetHandle function. There is a + requirement that hOutput be the source for the data when + tunelling (i.e. nPortOutput is an output port). If 0x0, the component + specified in hInput will have it's port specified in nPortInput + setup for communication with the application / IL client. + @param [in] nPortOutput + nPortOutput is used to select the source port on component to be + used in the tunnel. + @param [in] hInput + This is the component to setup the tunnel with. This is the handle + of the component whose port, specified in the nPortInput parameter + will be used the destination for the tunnel. This is the component handle + returned by the call to the OMX_GetHandle function. There is a + requirement that hInput be the destination for the data when + tunelling (i.e. nPortInut is an input port). If 0x0, the component + specified in hOutput will have it's port specified in nPortPOutput + setup for communication with the application / IL client. + @param [in] nPortInput + nPortInput is used to select the destination port on component to be + used in the tunnel. + @return OMX_ERRORTYPE + If the command successfully executes, the return code will be + OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. + When OMX_ErrorNotImplemented is returned, one or both components is + a non-interop component and does not support tunneling. + + On failure, the ports of both components are setup for communication + with the application / IL Client. + @ingroup core tun + */ +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); + +/** @ingroup cp */ +OMX_API OMX_ERRORTYPE OMX_GetContentPipe( + OMX_OUT OMX_HANDLETYPE *hPipe, + OMX_IN OMX_STRING szURI); + +/** The OMX_GetComponentsOfRole method will return the number of components that support the given + role and (if the compNames field is non-NULL) the names of those components. The call will fail if + an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the + client should: + * first call this function with the compNames field NULL to determine the number of component names + * second call this function with the compNames field pointing to an array of names allocated + according to the number returned by the first call. + + The core should return from this call within 5 msec. + + @param [in] role + This is generic standard component name consisting only of component class + name and the type within that class (e.g. 'audio_decoder.aac'). + @param [inout] pNumComps + This is used both as input and output. + + If compNames is NULL, the input is ignored and the output specifies how many components support + the given role. + + If compNames is not NULL, on input it bounds the size of the input structure and + on output, it specifies the number of components string names listed within the compNames parameter. + @param [inout] compNames + If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings which accepts + a list of the names of all physical components that implement the specified standard component name. + Each name is NULL terminated. numComps indicates the number of names. + @ingroup core + */ +OMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole ( + OMX_IN OMX_STRING role, + OMX_INOUT OMX_U32 *pNumComps, + OMX_INOUT OMX_U8 **compNames); + +/** The OMX_GetRolesOfComponent method will return the number of roles supported by the given + component and (if the roles field is non-NULL) the names of those roles. The call will fail if + an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the + client should: + * first call this function with the roles field NULL to determine the number of role names + * second call this function with the roles field pointing to an array of names allocated + according to the number returned by the first call. + + The core should return from this call within 5 msec. + + @param [in] compName + This is the name of the component being queried about. + @param [inout] pNumRoles + This is used both as input and output. + + If roles is NULL, the input is ignored and the output specifies how many roles the component supports. + + If compNames is not NULL, on input it bounds the size of the input structure and + on output, it specifies the number of roles string names listed within the roles parameter. + @param [out] roles + If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings + which accepts a list of the names of all standard components roles implemented on the + specified component name. numComps indicates the number of names. + @ingroup core + */ +OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent ( + OMX_IN OMX_STRING compName, + OMX_INOUT OMX_U32 *pNumRoles, + OMX_OUT OMX_U8 **roles); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif +/* File EOF */ + diff --git a/sec_mm/sec_omx/sec_omx_include/khronos/OMX_IVCommon.h b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_IVCommon.h new file mode 100644 index 0000000..4c4995c --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_IVCommon.h @@ -0,0 +1,920 @@ +/** + * Copyright (c) 2008 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. + * + */ + +/** + * @file OMX_IVCommon.h - OpenMax IL version 1.1.2 + * The structures needed by Video and Image components to exchange + * parameters and configuration data with the components. + */ +#ifndef OMX_IVCommon_h +#define OMX_IVCommon_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 + +/** @defgroup iv OpenMAX IL Imaging and Video Domain + * Common structures for OpenMAX IL Imaging and Video domains + * @{ + */ + + +/** + * Enumeration defining possible uncompressed image/video formats. + * + * ENUMS: + * Unused : Placeholder value when format is N/A + * Monochrome : black and white + * 8bitRGB332 : Red 7:5, Green 4:2, Blue 1:0 + * 12bitRGB444 : Red 11:8, Green 7:4, Blue 3:0 + * 16bitARGB4444 : Alpha 15:12, Red 11:8, Green 7:4, Blue 3:0 + * 16bitARGB1555 : Alpha 15, Red 14:10, Green 9:5, Blue 4:0 + * 16bitRGB565 : Red 15:11, Green 10:5, Blue 4:0 + * 16bitBGR565 : Blue 15:11, Green 10:5, Red 4:0 + * 18bitRGB666 : Red 17:12, Green 11:6, Blue 5:0 + * 18bitARGB1665 : Alpha 17, Red 16:11, Green 10:5, Blue 4:0 + * 19bitARGB1666 : Alpha 18, Red 17:12, Green 11:6, Blue 5:0 + * 24bitRGB888 : Red 24:16, Green 15:8, Blue 7:0 + * 24bitBGR888 : Blue 24:16, Green 15:8, Red 7:0 + * 24bitARGB1887 : Alpha 23, Red 22:15, Green 14:7, Blue 6:0 + * 25bitARGB1888 : Alpha 24, Red 23:16, Green 15:8, Blue 7:0 + * 32bitBGRA8888 : Blue 31:24, Green 23:16, Red 15:8, Alpha 7:0 + * 32bitARGB8888 : Alpha 31:24, Red 23:16, Green 15:8, Blue 7:0 + * YUV411Planar : U,Y are subsampled by a factor of 4 horizontally + * YUV411PackedPlanar : packed per payload in planar slices + * YUV420Planar : Three arrays Y,U,V. + * YUV420PackedPlanar : packed per payload in planar slices + * YUV420SemiPlanar : Two arrays, one is all Y, the other is U and V + * YUV422Planar : Three arrays Y,U,V. + * YUV422PackedPlanar : packed per payload in planar slices + * YUV422SemiPlanar : Two arrays, one is all Y, the other is U and V + * YCbYCr : Organized as 16bit YUYV (i.e. YCbYCr) + * YCrYCb : Organized as 16bit YVYU (i.e. YCrYCb) + * CbYCrY : Organized as 16bit UYVY (i.e. CbYCrY) + * CrYCbY : Organized as 16bit VYUY (i.e. CrYCbY) + * YUV444Interleaved : Each pixel contains equal parts YUV + * RawBayer8bit : SMIA camera output format + * RawBayer10bit : SMIA camera output format + * RawBayer8bitcompressed : SMIA camera output format + */ +typedef enum OMX_COLOR_FORMATTYPE { + OMX_COLOR_FormatUnused, + OMX_COLOR_FormatMonochrome, + OMX_COLOR_Format8bitRGB332, + OMX_COLOR_Format12bitRGB444, + OMX_COLOR_Format16bitARGB4444, + OMX_COLOR_Format16bitARGB1555, + OMX_COLOR_Format16bitRGB565, + OMX_COLOR_Format16bitBGR565, + OMX_COLOR_Format18bitRGB666, + OMX_COLOR_Format18bitARGB1665, + OMX_COLOR_Format19bitARGB1666, + OMX_COLOR_Format24bitRGB888, + OMX_COLOR_Format24bitBGR888, + OMX_COLOR_Format24bitARGB1887, + OMX_COLOR_Format25bitARGB1888, + OMX_COLOR_Format32bitBGRA8888, + OMX_COLOR_Format32bitARGB8888, + OMX_COLOR_FormatYUV411Planar, + OMX_COLOR_FormatYUV411PackedPlanar, + OMX_COLOR_FormatYUV420Planar, + OMX_COLOR_FormatYUV420PackedPlanar, + OMX_COLOR_FormatYUV420SemiPlanar, + OMX_COLOR_FormatYUV422Planar, + OMX_COLOR_FormatYUV422PackedPlanar, + OMX_COLOR_FormatYUV422SemiPlanar, + OMX_COLOR_FormatYCbYCr, + OMX_COLOR_FormatYCrYCb, + OMX_COLOR_FormatCbYCrY, + OMX_COLOR_FormatCrYCbY, + OMX_COLOR_FormatYUV444Interleaved, + OMX_COLOR_FormatRawBayer8bit, + OMX_COLOR_FormatRawBayer10bit, + OMX_COLOR_FormatRawBayer8bitcompressed, + OMX_COLOR_FormatL2, + OMX_COLOR_FormatL4, + OMX_COLOR_FormatL8, + OMX_COLOR_FormatL16, + OMX_COLOR_FormatL24, + OMX_COLOR_FormatL32, + OMX_COLOR_FormatYUV420PackedSemiPlanar, + OMX_COLOR_FormatYUV422PackedSemiPlanar, + OMX_COLOR_Format18BitBGR666, + OMX_COLOR_Format24BitARGB6666, + OMX_COLOR_Format24BitABGR6666, + OMX_COLOR_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_COLOR_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_COLOR_FormatMax = 0x7FFFFFFF +} OMX_COLOR_FORMATTYPE; + + +/** + * Defines the matrix for conversion from RGB to YUV or vice versa. + * iColorMatrix should be initialized with the fixed point values + * used in converting between formats. + */ +typedef struct OMX_CONFIG_COLORCONVERSIONTYPE { + 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_S32 xColorMatrix[3][3]; /**< Stored in signed Q16 format */ + OMX_S32 xColorOffset[4]; /**< Stored in signed Q16 format */ +}OMX_CONFIG_COLORCONVERSIONTYPE; + + +/** + * Structure defining percent to scale each frame dimension. For example: + * To make the width 50% larger, use fWidth = 1.5 and to make the width + * 1/2 the original size, use fWidth = 0.5 + */ +typedef struct OMX_CONFIG_SCALEFACTORTYPE { + 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_S32 xWidth; /**< Fixed point value stored as Q16 */ + OMX_S32 xHeight; /**< Fixed point value stored as Q16 */ +}OMX_CONFIG_SCALEFACTORTYPE; + + +/** + * Enumeration of possible image filter types + */ +typedef enum OMX_IMAGEFILTERTYPE { + OMX_ImageFilterNone, + OMX_ImageFilterNoise, + OMX_ImageFilterEmboss, + OMX_ImageFilterNegative, + OMX_ImageFilterSketch, + OMX_ImageFilterOilPaint, + OMX_ImageFilterHatch, + OMX_ImageFilterGpen, + OMX_ImageFilterAntialias, + OMX_ImageFilterDeRing, + OMX_ImageFilterSolarize, + OMX_ImageFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_ImageFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_ImageFilterMax = 0x7FFFFFFF +} OMX_IMAGEFILTERTYPE; + + +/** + * Image filter configuration + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eImageFilter : Image filter type enumeration + */ +typedef struct OMX_CONFIG_IMAGEFILTERTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_IMAGEFILTERTYPE eImageFilter; +} OMX_CONFIG_IMAGEFILTERTYPE; + + +/** + * Customized U and V for color enhancement + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * bColorEnhancement : Enable/disable color enhancement + * nCustomizedU : Practical values: 16-240, range: 0-255, value set for + * U component + * nCustomizedV : Practical values: 16-240, range: 0-255, value set for + * V component + */ +typedef struct OMX_CONFIG_COLORENHANCEMENTTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_BOOL bColorEnhancement; + OMX_U8 nCustomizedU; + OMX_U8 nCustomizedV; +} OMX_CONFIG_COLORENHANCEMENTTYPE; + + +/** + * Define color key and color key mask + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nARGBColor : 32bit Alpha, Red, Green, Blue Color + * nARGBMask : 32bit Mask for Alpha, Red, Green, Blue channels + */ +typedef struct OMX_CONFIG_COLORKEYTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nARGBColor; + OMX_U32 nARGBMask; +} OMX_CONFIG_COLORKEYTYPE; + + +/** + * List of color blend types for pre/post processing + * + * ENUMS: + * None : No color blending present + * AlphaConstant : Function is (alpha_constant * src) + + * (1 - alpha_constant) * dst) + * AlphaPerPixel : Function is (alpha * src) + (1 - alpha) * dst) + * Alternate : Function is alternating pixels from src and dst + * And : Function is (src & dst) + * Or : Function is (src | dst) + * Invert : Function is ~src + */ +typedef enum OMX_COLORBLENDTYPE { + OMX_ColorBlendNone, + OMX_ColorBlendAlphaConstant, + OMX_ColorBlendAlphaPerPixel, + OMX_ColorBlendAlternate, + OMX_ColorBlendAnd, + OMX_ColorBlendOr, + OMX_ColorBlendInvert, + OMX_ColorBlendKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_ColorBlendVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_ColorBlendMax = 0x7FFFFFFF +} OMX_COLORBLENDTYPE; + + +/** + * Color blend configuration + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nRGBAlphaConstant : Constant global alpha values when global alpha is used + * eColorBlend : Color blend type enumeration + */ +typedef struct OMX_CONFIG_COLORBLENDTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nRGBAlphaConstant; + OMX_COLORBLENDTYPE eColorBlend; +} OMX_CONFIG_COLORBLENDTYPE; + + +/** + * Hold frame dimension + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nWidth : Frame width in pixels + * nHeight : Frame height in pixels + */ +typedef struct OMX_FRAMESIZETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nWidth; + OMX_U32 nHeight; +} OMX_FRAMESIZETYPE; + + +/** + * Rotation configuration + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nRotation : +/- integer rotation value + */ +typedef struct OMX_CONFIG_ROTATIONTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_S32 nRotation; +} OMX_CONFIG_ROTATIONTYPE; + + +/** + * Possible mirroring directions for pre/post processing + * + * ENUMS: + * None : No mirroring + * Vertical : Vertical mirroring, flip on X axis + * Horizontal : Horizontal mirroring, flip on Y axis + * Both : Both vertical and horizontal mirroring + */ +typedef enum OMX_MIRRORTYPE { + OMX_MirrorNone = 0, + OMX_MirrorVertical, + OMX_MirrorHorizontal, + OMX_MirrorBoth, + OMX_MirrorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_MirrorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_MirrorMax = 0x7FFFFFFF +} OMX_MIRRORTYPE; + + +/** + * Mirroring configuration + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eMirror : Mirror type enumeration + */ +typedef struct OMX_CONFIG_MIRRORTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_MIRRORTYPE eMirror; +} OMX_CONFIG_MIRRORTYPE; + + +/** + * Position information only + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nX : X coordinate for the point + * nY : Y coordinate for the point + */ +typedef struct OMX_CONFIG_POINTTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_S32 nX; + OMX_S32 nY; +} OMX_CONFIG_POINTTYPE; + + +/** + * Frame size plus position + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nLeft : X Coordinate of the top left corner of the rectangle + * nTop : Y Coordinate of the top left corner of the rectangle + * nWidth : Width of the rectangle + * nHeight : Height of the rectangle + */ +typedef struct OMX_CONFIG_RECTTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_S32 nLeft; + OMX_S32 nTop; + OMX_U32 nWidth; + OMX_U32 nHeight; +} OMX_CONFIG_RECTTYPE; + + +/** + * Deblocking state; it is required to be set up before starting the codec + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * bDeblocking : Enable/disable deblocking mode + */ +typedef struct OMX_PARAM_DEBLOCKINGTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_BOOL bDeblocking; +} OMX_PARAM_DEBLOCKINGTYPE; + + +/** + * Stabilization state + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * bStab : Enable/disable frame stabilization state + */ +typedef struct OMX_CONFIG_FRAMESTABTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_BOOL bStab; +} OMX_CONFIG_FRAMESTABTYPE; + + +/** + * White Balance control type + * + * STRUCT MEMBERS: + * SunLight : Referenced in JSR-234 + * Flash : Optimal for device's integrated flash + */ +typedef enum OMX_WHITEBALCONTROLTYPE { + OMX_WhiteBalControlOff = 0, + OMX_WhiteBalControlAuto, + OMX_WhiteBalControlSunLight, + OMX_WhiteBalControlCloudy, + OMX_WhiteBalControlShade, + OMX_WhiteBalControlTungsten, + OMX_WhiteBalControlFluorescent, + OMX_WhiteBalControlIncandescent, + OMX_WhiteBalControlFlash, + OMX_WhiteBalControlHorizon, + OMX_WhiteBalControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_WhiteBalControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_WhiteBalControlMax = 0x7FFFFFFF +} OMX_WHITEBALCONTROLTYPE; + + +/** + * White Balance control configuration + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eWhiteBalControl : White balance enumeration + */ +typedef struct OMX_CONFIG_WHITEBALCONTROLTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_WHITEBALCONTROLTYPE eWhiteBalControl; +} OMX_CONFIG_WHITEBALCONTROLTYPE; + + +/** + * Exposure control type + */ +typedef enum OMX_EXPOSURECONTROLTYPE { + OMX_ExposureControlOff = 0, + OMX_ExposureControlAuto, + OMX_ExposureControlNight, + OMX_ExposureControlBackLight, + OMX_ExposureControlSpotLight, + OMX_ExposureControlSports, + OMX_ExposureControlSnow, + OMX_ExposureControlBeach, + OMX_ExposureControlLargeAperture, + OMX_ExposureControlSmallApperture, + OMX_ExposureControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_ExposureControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_ExposureControlMax = 0x7FFFFFFF +} OMX_EXPOSURECONTROLTYPE; + + +/** + * White Balance control configuration + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eExposureControl : Exposure control enumeration + */ +typedef struct OMX_CONFIG_EXPOSURECONTROLTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_EXPOSURECONTROLTYPE eExposureControl; +} OMX_CONFIG_EXPOSURECONTROLTYPE; + + +/** + * Defines sensor supported mode. + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nFrameRate : Single shot mode is indicated by a 0 + * bOneShot : Enable for single shot, disable for streaming + * sFrameSize : Framesize + */ +typedef struct OMX_PARAM_SENSORMODETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nFrameRate; + OMX_BOOL bOneShot; + OMX_FRAMESIZETYPE sFrameSize; +} OMX_PARAM_SENSORMODETYPE; + + +/** + * Defines contrast level + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nContrast : Values allowed for contrast -100 to 100, zero means no change + */ +typedef struct OMX_CONFIG_CONTRASTTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_S32 nContrast; +} OMX_CONFIG_CONTRASTTYPE; + + +/** + * Defines brightness level + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nBrightness : 0-100% + */ +typedef struct OMX_CONFIG_BRIGHTNESSTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nBrightness; +} OMX_CONFIG_BRIGHTNESSTYPE; + + +/** + * Defines backlight level configuration for a video sink, e.g. LCD panel + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nBacklight : Values allowed for backlight 0-100% + * nTimeout : Number of milliseconds before backlight automatically turns + * off. A value of 0x0 disables backight timeout + */ +typedef struct OMX_CONFIG_BACKLIGHTTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nBacklight; + OMX_U32 nTimeout; +} OMX_CONFIG_BACKLIGHTTYPE; + + +/** + * Defines setting for Gamma + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nGamma : Values allowed for gamma -100 to 100, zero means no change + */ +typedef struct OMX_CONFIG_GAMMATYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_S32 nGamma; +} OMX_CONFIG_GAMMATYPE; + + +/** + * Define for setting saturation + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nSaturation : Values allowed for saturation -100 to 100, zero means + * no change + */ +typedef struct OMX_CONFIG_SATURATIONTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_S32 nSaturation; +} OMX_CONFIG_SATURATIONTYPE; + + +/** + * Define for setting Lightness + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nLightness : Values allowed for lightness -100 to 100, zero means no + * change + */ +typedef struct OMX_CONFIG_LIGHTNESSTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_S32 nLightness; +} OMX_CONFIG_LIGHTNESSTYPE; + + +/** + * Plane blend configuration + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Index of input port associated with the plane. + * nDepth : Depth of the plane in relation to the screen. Higher + * numbered depths are "behind" lower number depths. + * This number defaults to the Port Index number. + * nAlpha : Transparency blending component for the entire plane. + * See blending modes for more detail. + */ +typedef struct OMX_CONFIG_PLANEBLENDTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nDepth; + OMX_U32 nAlpha; +} OMX_CONFIG_PLANEBLENDTYPE; + + +/** + * Define interlace type + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * bEnable : Enable control variable for this functionality + * (see below) + * nInterleavePortIndex : Index of input or output port associated with + * the interleaved plane. + * pPlanarPortIndexes[4] : Index of input or output planar ports. + */ +typedef struct OMX_PARAM_INTERLEAVETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_BOOL bEnable; + OMX_U32 nInterleavePortIndex; +} OMX_PARAM_INTERLEAVETYPE; + + +/** + * Defines the picture effect used for an input picture + */ +typedef enum OMX_TRANSITIONEFFECTTYPE { + OMX_EffectNone, + OMX_EffectFadeFromBlack, + OMX_EffectFadeToBlack, + OMX_EffectUnspecifiedThroughConstantColor, + OMX_EffectDissolve, + OMX_EffectWipe, + OMX_EffectUnspecifiedMixOfTwoScenes, + OMX_EffectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_EffectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_EffectMax = 0x7FFFFFFF +} OMX_TRANSITIONEFFECTTYPE; + + +/** + * Structure used to configure current transition effect + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eEffect : Effect to enable + */ +typedef struct OMX_CONFIG_TRANSITIONEFFECTTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_TRANSITIONEFFECTTYPE eEffect; +} OMX_CONFIG_TRANSITIONEFFECTTYPE; + + +/** + * Defines possible data unit types for encoded video data. The data unit + * types are used both for encoded video input for playback as well as + * encoded video output from recording. + */ +typedef enum OMX_DATAUNITTYPE { + OMX_DataUnitCodedPicture, + OMX_DataUnitVideoSegment, + OMX_DataUnitSeveralSegments, + OMX_DataUnitArbitraryStreamSection, + OMX_DataUnitKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_DataUnitVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_DataUnitMax = 0x7FFFFFFF +} OMX_DATAUNITTYPE; + + +/** + * Defines possible encapsulation types for coded video data unit. The + * encapsulation information is used both for encoded video input for + * playback as well as encoded video output from recording. + */ +typedef enum OMX_DATAUNITENCAPSULATIONTYPE { + OMX_DataEncapsulationElementaryStream, + OMX_DataEncapsulationGenericPayload, + OMX_DataEncapsulationRtpPayload, + OMX_DataEncapsulationKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_DataEncapsulationVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_DataEncapsulationMax = 0x7FFFFFFF +} OMX_DATAUNITENCAPSULATIONTYPE; + + +/** + * Structure used to configure the type of being decoded/encoded + */ +typedef struct OMX_PARAM_DATAUNITTYPE { + 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_DATAUNITTYPE eUnitType; + OMX_DATAUNITENCAPSULATIONTYPE eEncapsulationType; +} OMX_PARAM_DATAUNITTYPE; + + +/** + * Defines dither types + */ +typedef enum OMX_DITHERTYPE { + OMX_DitherNone, + OMX_DitherOrdered, + OMX_DitherErrorDiffusion, + OMX_DitherOther, + OMX_DitherKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_DitherVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_DitherMax = 0x7FFFFFFF +} OMX_DITHERTYPE; + + +/** + * Structure used to configure current type of dithering + */ +typedef struct OMX_CONFIG_DITHERTYPE { + 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_DITHERTYPE eDither; /**< Type of dithering to use */ +} OMX_CONFIG_DITHERTYPE; + +typedef struct OMX_CONFIG_CAPTUREMODETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; /**< Port that this structure applies to */ + OMX_BOOL bContinuous; /**< If true then ignore frame rate and emit capture + * data as fast as possible (otherwise obey port's frame rate). */ + OMX_BOOL bFrameLimited; /**< If true then terminate capture after the port emits the + * specified number of frames (otherwise the port does not + * terminate the capture until instructed to do so by the client). + * Even if set, the client may manually terminate the capture prior + * to reaching the limit. */ + OMX_U32 nFrameLimit; /**< Limit on number of frames emitted during a capture (only + * valid if bFrameLimited is set). */ +} OMX_CONFIG_CAPTUREMODETYPE; + +typedef enum OMX_METERINGTYPE { + + OMX_MeteringModeAverage, /**< Center-weighted average metering. */ + OMX_MeteringModeSpot, /**< Spot (partial) metering. */ + OMX_MeteringModeMatrix, /**< Matrix or evaluative metering. */ + + OMX_MeteringKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_MeteringVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_EVModeMax = 0x7fffffff +} OMX_METERINGTYPE; + +typedef struct OMX_CONFIG_EXPOSUREVALUETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_METERINGTYPE eMetering; + OMX_S32 xEVCompensation; /**< Fixed point value stored as Q16 */ + OMX_U32 nApertureFNumber; /**< e.g. nApertureFNumber = 2 implies "f/2" - Q16 format */ + OMX_BOOL bAutoAperture; /**< Whether aperture number is defined automatically */ + OMX_U32 nShutterSpeedMsec; /**< Shutterspeed in milliseconds */ + OMX_BOOL bAutoShutterSpeed; /**< Whether shutter speed is defined automatically */ + OMX_U32 nSensitivity; /**< e.g. nSensitivity = 100 implies "ISO 100" */ + OMX_BOOL bAutoSensitivity; /**< Whether sensitivity is defined automatically */ +} OMX_CONFIG_EXPOSUREVALUETYPE; + +/** + * Focus region configuration + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * bCenter : Use center region as focus region of interest + * bLeft : Use left region as focus region of interest + * bRight : Use right region as focus region of interest + * bTop : Use top region as focus region of interest + * bBottom : Use bottom region as focus region of interest + * bTopLeft : Use top left region as focus region of interest + * bTopRight : Use top right region as focus region of interest + * bBottomLeft : Use bottom left region as focus region of interest + * bBottomRight : Use bottom right region as focus region of interest + */ +typedef struct OMX_CONFIG_FOCUSREGIONTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_BOOL bCenter; + OMX_BOOL bLeft; + OMX_BOOL bRight; + OMX_BOOL bTop; + OMX_BOOL bBottom; + OMX_BOOL bTopLeft; + OMX_BOOL bTopRight; + OMX_BOOL bBottomLeft; + OMX_BOOL bBottomRight; +} OMX_CONFIG_FOCUSREGIONTYPE; + +/** + * Focus Status type + */ +typedef enum OMX_FOCUSSTATUSTYPE { + OMX_FocusStatusOff = 0, + OMX_FocusStatusRequest, + OMX_FocusStatusReached, + OMX_FocusStatusUnableToReach, + OMX_FocusStatusLost, + OMX_FocusStatusKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_FocusStatusVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_FocusStatusMax = 0x7FFFFFFF +} OMX_FOCUSSTATUSTYPE; + +/** + * Focus status configuration + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eFocusStatus : Specifies the focus status + * bCenterStatus : Use center region as focus region of interest + * bLeftStatus : Use left region as focus region of interest + * bRightStatus : Use right region as focus region of interest + * bTopStatus : Use top region as focus region of interest + * bBottomStatus : Use bottom region as focus region of interest + * bTopLeftStatus : Use top left region as focus region of interest + * bTopRightStatus : Use top right region as focus region of interest + * bBottomLeftStatus : Use bottom left region as focus region of interest + * bBottomRightStatus : Use bottom right region as focus region of interest + */ +typedef struct OMX_PARAM_FOCUSSTATUSTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_FOCUSSTATUSTYPE eFocusStatus; + OMX_BOOL bCenterStatus; + OMX_BOOL bLeftStatus; + OMX_BOOL bRightStatus; + OMX_BOOL bTopStatus; + OMX_BOOL bBottomStatus; + OMX_BOOL bTopLeftStatus; + OMX_BOOL bTopRightStatus; + OMX_BOOL bBottomLeftStatus; + OMX_BOOL bBottomRightStatus; +} OMX_PARAM_FOCUSSTATUSTYPE; + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif +/* File EOF */ diff --git a/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Image.h b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Image.h new file mode 100644 index 0000000..a6d4666 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Image.h @@ -0,0 +1,328 @@ +/** + * Copyright (c) 2008 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. + */ + +/** + * @file OMX_Image.h - OpenMax IL version 1.1.2 + * The structures needed by Image components to exchange parameters and + * configuration data with the components. + */ +#ifndef OMX_Image_h +#define OMX_Image_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 + +/** @defgroup imaging OpenMAX IL Imaging Domain + * @ingroup iv + * Structures for OpenMAX IL Imaging domain + * @{ + */ + +/** + * Enumeration used to define the possible image compression coding. + */ +typedef enum OMX_IMAGE_CODINGTYPE { + OMX_IMAGE_CodingUnused, /**< Value when format is N/A */ + OMX_IMAGE_CodingAutoDetect, /**< Auto detection of image format */ + OMX_IMAGE_CodingJPEG, /**< JPEG/JFIF image format */ + OMX_IMAGE_CodingJPEG2K, /**< JPEG 2000 image format */ + OMX_IMAGE_CodingEXIF, /**< EXIF image format */ + OMX_IMAGE_CodingTIFF, /**< TIFF image format */ + OMX_IMAGE_CodingGIF, /**< Graphics image format */ + OMX_IMAGE_CodingPNG, /**< PNG image format */ + OMX_IMAGE_CodingLZW, /**< LZW image format */ + OMX_IMAGE_CodingBMP, /**< Windows Bitmap format */ + OMX_IMAGE_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_IMAGE_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_IMAGE_CodingMax = 0x7FFFFFFF +} OMX_IMAGE_CODINGTYPE; + + +/** + * Data structure used to define an image path. The number of image paths + * for input and output will vary by type of the image component. + * + * Input (aka Source) : Zero Inputs, one Output, + * Splitter : One Input, 2 or more Outputs, + * Processing Element : One Input, one output, + * Mixer : 2 or more inputs, one output, + * Output (aka Sink) : One Input, zero outputs. + * + * The PortDefinition structure is used to define all of the parameters + * necessary for the compliant component to setup an input or an output + * image path. If additional vendor specific data is required, it should + * be transmitted to the component using the CustomCommand function. + * Compliant components will prepopulate this structure with optimal + * values during the OMX_GetParameter() command. + * + * STRUCT MEMBERS: + * cMIMEType : MIME type of data for the port + * pNativeRender : Platform specific reference for a display if a + * sync, otherwise this field is 0 + * nFrameWidth : Width of frame to be used on port if + * uncompressed format is used. Use 0 for + * unknown, don't care or variable + * nFrameHeight : Height of frame to be used on port if + * uncompressed format is used. Use 0 for + * unknown, don't care or variable + * nStride : Number of bytes per span of an image (i.e. + * indicates the number of bytes to get from + * span N to span N+1, where negative stride + * indicates the image is bottom up + * nSliceHeight : Height used when encoding in slices + * bFlagErrorConcealment : Turns on error concealment if it is supported by + * the OMX component + * eCompressionFormat : Compression format used in this instance of + * the component. When OMX_IMAGE_CodingUnused is + * specified, eColorFormat is valid + * eColorFormat : Decompressed format used by this component + * pNativeWindow : Platform specific reference for a window object if a + * display sink , otherwise this field is 0x0. + */ +typedef struct OMX_IMAGE_PORTDEFINITIONTYPE { + OMX_STRING cMIMEType; + OMX_NATIVE_DEVICETYPE pNativeRender; + OMX_U32 nFrameWidth; + OMX_U32 nFrameHeight; + OMX_S32 nStride; + OMX_U32 nSliceHeight; + OMX_BOOL bFlagErrorConcealment; + OMX_IMAGE_CODINGTYPE eCompressionFormat; + OMX_COLOR_FORMATTYPE eColorFormat; + OMX_NATIVE_WINDOWTYPE pNativeWindow; +} OMX_IMAGE_PORTDEFINITIONTYPE; + + +/** + * Port format parameter. This structure is used to enumerate the various + * data input/output format supported by the port. + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Indicates which port to set + * nIndex : Indicates the enumeration index for the format from + * 0x0 to N-1 + * eCompressionFormat : Compression format used in this instance of the + * component. When OMX_IMAGE_CodingUnused is specified, + * eColorFormat is valid + * eColorFormat : Decompressed format used by this component + */ +typedef struct OMX_IMAGE_PARAM_PORTFORMATTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nIndex; + OMX_IMAGE_CODINGTYPE eCompressionFormat; + OMX_COLOR_FORMATTYPE eColorFormat; +} OMX_IMAGE_PARAM_PORTFORMATTYPE; + + +/** + * Flash control type + * + * ENUMS + * Torch : Flash forced constantly on + */ +typedef enum OMX_IMAGE_FLASHCONTROLTYPE { + OMX_IMAGE_FlashControlOn = 0, + OMX_IMAGE_FlashControlOff, + OMX_IMAGE_FlashControlAuto, + OMX_IMAGE_FlashControlRedEyeReduction, + OMX_IMAGE_FlashControlFillin, + OMX_IMAGE_FlashControlTorch, + OMX_IMAGE_FlashControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_IMAGE_FlashControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_IMAGE_FlashControlMax = 0x7FFFFFFF +} OMX_IMAGE_FLASHCONTROLTYPE; + + +/** + * Flash control configuration + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eFlashControl : Flash control type + */ +typedef struct OMX_IMAGE_PARAM_FLASHCONTROLTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_IMAGE_FLASHCONTROLTYPE eFlashControl; +} OMX_IMAGE_PARAM_FLASHCONTROLTYPE; + + +/** + * Focus control type + */ +typedef enum OMX_IMAGE_FOCUSCONTROLTYPE { + OMX_IMAGE_FocusControlOn = 0, + OMX_IMAGE_FocusControlOff, + OMX_IMAGE_FocusControlAuto, + OMX_IMAGE_FocusControlAutoLock, + OMX_IMAGE_FocusControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_IMAGE_FocusControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_IMAGE_FocusControlMax = 0x7FFFFFFF +} OMX_IMAGE_FOCUSCONTROLTYPE; + + +/** + * Focus control configuration + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eFocusControl : Focus control + * nFocusSteps : Focus can take on values from 0 mm to infinity. + * Interest is only in number of steps over this range. + * nFocusStepIndex : Current focus step index + */ +typedef struct OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_IMAGE_FOCUSCONTROLTYPE eFocusControl; + OMX_U32 nFocusSteps; + OMX_U32 nFocusStepIndex; +} OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE; + + +/** + * Q Factor for JPEG compression, which controls the tradeoff between image + * quality and size. Q Factor provides a more simple means of controlling + * JPEG compression quality, without directly programming Quantization + * tables for chroma and luma + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nQFactor : JPEG Q factor value in the range of 1-100. A factor of 1 + * produces the smallest, worst quality images, and a factor + * of 100 produces the largest, best quality images. A + * typical default is 75 for small good quality images + */ +typedef struct OMX_IMAGE_PARAM_QFACTORTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nQFactor; +} OMX_IMAGE_PARAM_QFACTORTYPE; + +/** + * Quantization table type + */ + +typedef enum OMX_IMAGE_QUANTIZATIONTABLETYPE { + OMX_IMAGE_QuantizationTableLuma = 0, + OMX_IMAGE_QuantizationTableChroma, + OMX_IMAGE_QuantizationTableChromaCb, + OMX_IMAGE_QuantizationTableChromaCr, + OMX_IMAGE_QuantizationTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_IMAGE_QuantizationTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_IMAGE_QuantizationTableMax = 0x7FFFFFFF +} OMX_IMAGE_QUANTIZATIONTABLETYPE; + +/** + * JPEG quantization tables are used to determine DCT compression for + * YUV data, as an alternative to specifying Q factor, providing exact + * control of compression + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eQuantizationTable : Quantization table type + * nQuantizationMatrix[64] : JPEG quantization table of coefficients stored + * in increasing columns then by rows of data (i.e. + * row 1, ... row 8). Quantization values are in + * the range 0-255 and stored in linear order + * (i.e. the component will zig-zag the + * quantization table data if required internally) + */ +typedef struct OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_IMAGE_QUANTIZATIONTABLETYPE eQuantizationTable; + OMX_U8 nQuantizationMatrix[64]; +} OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE; + + +/** + * Huffman table type, the same Huffman table is applied for chroma and + * luma component + */ +typedef enum OMX_IMAGE_HUFFMANTABLETYPE { + OMX_IMAGE_HuffmanTableAC = 0, + OMX_IMAGE_HuffmanTableDC, + OMX_IMAGE_HuffmanTableACLuma, + OMX_IMAGE_HuffmanTableACChroma, + OMX_IMAGE_HuffmanTableDCLuma, + OMX_IMAGE_HuffmanTableDCChroma, + OMX_IMAGE_HuffmanTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_IMAGE_HuffmanTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_IMAGE_HuffmanTableMax = 0x7FFFFFFF +} OMX_IMAGE_HUFFMANTABLETYPE; + +/** + * JPEG Huffman table + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eHuffmanTable : Huffman table type + * nNumberOfHuffmanCodeOfLength[16] : 0-16, number of Huffman codes of each + * possible length + * nHuffmanTable[256] : 0-255, the size used for AC and DC + * HuffmanTable are 16 and 162 + */ +typedef struct OMX_IMAGE_PARAM_HUFFMANTTABLETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_IMAGE_HUFFMANTABLETYPE eHuffmanTable; + OMX_U8 nNumberOfHuffmanCodeOfLength[16]; + OMX_U8 nHuffmanTable[256]; +}OMX_IMAGE_PARAM_HUFFMANTTABLETYPE; + +/** @} */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif +/* File EOF */ diff --git a/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Index.h b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Index.h new file mode 100644 index 0000000..44d4ea7 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Index.h @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2008 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. + * + */ + +/** @file OMX_Index.h - OpenMax IL version 1.1.2 + * The OMX_Index header file contains the definitions for both applications + * and components . + */ + + +#ifndef OMX_Index_h +#define OMX_Index_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 + + +/** The OMX_INDEXTYPE enumeration is used to select a structure when either + * getting or setting parameters and/or configuration data. Each entry in + * this enumeration maps to an OMX specified structure. When the + * OMX_GetParameter, OMX_SetParameter, OMX_GetConfig or OMX_SetConfig methods + * are used, the second parameter will always be an entry from this enumeration + * and the third entry will be the structure shown in the comments for the entry. + * For example, if the application is initializing a cropping function, the + * OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop as the second parameter + * and would send a pointer to an initialized OMX_RECTTYPE structure as the + * third parameter. + * + * The enumeration entries named with the OMX_Config prefix are sent using + * the OMX_SetConfig command and the enumeration entries named with the + * OMX_PARAM_ prefix are sent using the OMX_SetParameter command. + */ +typedef enum OMX_INDEXTYPE { + + OMX_IndexComponentStartUnused = 0x01000000, + OMX_IndexParamPriorityMgmt, /**< reference: OMX_PRIORITYMGMTTYPE */ + OMX_IndexParamAudioInit, /**< reference: OMX_PORT_PARAM_TYPE */ + OMX_IndexParamImageInit, /**< reference: OMX_PORT_PARAM_TYPE */ + OMX_IndexParamVideoInit, /**< reference: OMX_PORT_PARAM_TYPE */ + OMX_IndexParamOtherInit, /**< reference: OMX_PORT_PARAM_TYPE */ + OMX_IndexParamNumAvailableStreams, /**< reference: OMX_PARAM_U32TYPE */ + OMX_IndexParamActiveStream, /**< reference: OMX_PARAM_U32TYPE */ + OMX_IndexParamSuspensionPolicy, /**< reference: OMX_PARAM_SUSPENSIONPOLICYTYPE */ + OMX_IndexParamComponentSuspended, /**< reference: OMX_PARAM_SUSPENSIONTYPE */ + OMX_IndexConfigCapturing, /**< reference: OMX_CONFIG_BOOLEANTYPE */ + OMX_IndexConfigCaptureMode, /**< reference: OMX_CONFIG_CAPTUREMODETYPE */ + OMX_IndexAutoPauseAfterCapture, /**< reference: OMX_CONFIG_BOOLEANTYPE */ + OMX_IndexParamContentURI, /**< reference: OMX_PARAM_CONTENTURITYPE */ + OMX_IndexParamCustomContentPipe, /**< reference: OMX_PARAM_CONTENTPIPETYPE */ + OMX_IndexParamDisableResourceConcealment, /**< reference: OMX_RESOURCECONCEALMENTTYPE */ + OMX_IndexConfigMetadataItemCount, /**< reference: OMX_CONFIG_METADATAITEMCOUNTTYPE */ + OMX_IndexConfigContainerNodeCount, /**< reference: OMX_CONFIG_CONTAINERNODECOUNTTYPE */ + OMX_IndexConfigMetadataItem, /**< reference: OMX_CONFIG_METADATAITEMTYPE */ + OMX_IndexConfigCounterNodeID, /**< reference: OMX_CONFIG_CONTAINERNODEIDTYPE */ + OMX_IndexParamMetadataFilterType, /**< reference: OMX_PARAM_METADATAFILTERTYPE */ + OMX_IndexParamMetadataKeyFilter, /**< reference: OMX_PARAM_METADATAFILTERTYPE */ + OMX_IndexConfigPriorityMgmt, /**< reference: OMX_PRIORITYMGMTTYPE */ + OMX_IndexParamStandardComponentRole, /**< reference: OMX_PARAM_COMPONENTROLETYPE */ + + OMX_IndexPortStartUnused = 0x02000000, + OMX_IndexParamPortDefinition, /**< reference: OMX_PARAM_PORTDEFINITIONTYPE */ + OMX_IndexParamCompBufferSupplier, /**< reference: OMX_PARAM_BUFFERSUPPLIERTYPE */ + OMX_IndexReservedStartUnused = 0x03000000, + + /* Audio parameters and configurations */ + OMX_IndexAudioStartUnused = 0x04000000, + OMX_IndexParamAudioPortFormat, /**< reference: OMX_AUDIO_PARAM_PORTFORMATTYPE */ + OMX_IndexParamAudioPcm, /**< reference: OMX_AUDIO_PARAM_PCMMODETYPE */ + OMX_IndexParamAudioAac, /**< reference: OMX_AUDIO_PARAM_AACPROFILETYPE */ + OMX_IndexParamAudioRa, /**< reference: OMX_AUDIO_PARAM_RATYPE */ + OMX_IndexParamAudioMp3, /**< reference: OMX_AUDIO_PARAM_MP3TYPE */ + OMX_IndexParamAudioAdpcm, /**< reference: OMX_AUDIO_PARAM_ADPCMTYPE */ + OMX_IndexParamAudioG723, /**< reference: OMX_AUDIO_PARAM_G723TYPE */ + OMX_IndexParamAudioG729, /**< reference: OMX_AUDIO_PARAM_G729TYPE */ + OMX_IndexParamAudioAmr, /**< reference: OMX_AUDIO_PARAM_AMRTYPE */ + OMX_IndexParamAudioWma, /**< reference: OMX_AUDIO_PARAM_WMATYPE */ + OMX_IndexParamAudioSbc, /**< reference: OMX_AUDIO_PARAM_SBCTYPE */ + OMX_IndexParamAudioMidi, /**< reference: OMX_AUDIO_PARAM_MIDITYPE */ + OMX_IndexParamAudioGsm_FR, /**< reference: OMX_AUDIO_PARAM_GSMFRTYPE */ + OMX_IndexParamAudioMidiLoadUserSound, /**< reference: OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE */ + OMX_IndexParamAudioG726, /**< reference: OMX_AUDIO_PARAM_G726TYPE */ + OMX_IndexParamAudioGsm_EFR, /**< reference: OMX_AUDIO_PARAM_GSMEFRTYPE */ + OMX_IndexParamAudioGsm_HR, /**< reference: OMX_AUDIO_PARAM_GSMHRTYPE */ + OMX_IndexParamAudioPdc_FR, /**< reference: OMX_AUDIO_PARAM_PDCFRTYPE */ + OMX_IndexParamAudioPdc_EFR, /**< reference: OMX_AUDIO_PARAM_PDCEFRTYPE */ + OMX_IndexParamAudioPdc_HR, /**< reference: OMX_AUDIO_PARAM_PDCHRTYPE */ + OMX_IndexParamAudioTdma_FR, /**< reference: OMX_AUDIO_PARAM_TDMAFRTYPE */ + OMX_IndexParamAudioTdma_EFR, /**< reference: OMX_AUDIO_PARAM_TDMAEFRTYPE */ + OMX_IndexParamAudioQcelp8, /**< reference: OMX_AUDIO_PARAM_QCELP8TYPE */ + OMX_IndexParamAudioQcelp13, /**< reference: OMX_AUDIO_PARAM_QCELP13TYPE */ + OMX_IndexParamAudioEvrc, /**< reference: OMX_AUDIO_PARAM_EVRCTYPE */ + OMX_IndexParamAudioSmv, /**< reference: OMX_AUDIO_PARAM_SMVTYPE */ + OMX_IndexParamAudioVorbis, /**< reference: OMX_AUDIO_PARAM_VORBISTYPE */ + + OMX_IndexConfigAudioMidiImmediateEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE */ + OMX_IndexConfigAudioMidiControl, /**< reference: OMX_AUDIO_CONFIG_MIDICONTROLTYPE */ + OMX_IndexConfigAudioMidiSoundBankProgram, /**< reference: OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE */ + OMX_IndexConfigAudioMidiStatus, /**< reference: OMX_AUDIO_CONFIG_MIDISTATUSTYPE */ + OMX_IndexConfigAudioMidiMetaEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE */ + OMX_IndexConfigAudioMidiMetaEventData, /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE */ + OMX_IndexConfigAudioVolume, /**< reference: OMX_AUDIO_CONFIG_VOLUMETYPE */ + OMX_IndexConfigAudioBalance, /**< reference: OMX_AUDIO_CONFIG_BALANCETYPE */ + OMX_IndexConfigAudioChannelMute, /**< reference: OMX_AUDIO_CONFIG_CHANNELMUTETYPE */ + OMX_IndexConfigAudioMute, /**< reference: OMX_AUDIO_CONFIG_MUTETYPE */ + OMX_IndexConfigAudioLoudness, /**< reference: OMX_AUDIO_CONFIG_LOUDNESSTYPE */ + OMX_IndexConfigAudioEchoCancelation, /**< reference: OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE */ + OMX_IndexConfigAudioNoiseReduction, /**< reference: OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE */ + OMX_IndexConfigAudioBass, /**< reference: OMX_AUDIO_CONFIG_BASSTYPE */ + OMX_IndexConfigAudioTreble, /**< reference: OMX_AUDIO_CONFIG_TREBLETYPE */ + OMX_IndexConfigAudioStereoWidening, /**< reference: OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE */ + OMX_IndexConfigAudioChorus, /**< reference: OMX_AUDIO_CONFIG_CHORUSTYPE */ + OMX_IndexConfigAudioEqualizer, /**< reference: OMX_AUDIO_CONFIG_EQUALIZERTYPE */ + OMX_IndexConfigAudioReverberation, /**< reference: OMX_AUDIO_CONFIG_REVERBERATIONTYPE */ + OMX_IndexConfigAudioChannelVolume, /**< reference: OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE */ + + /* Image specific parameters and configurations */ + OMX_IndexImageStartUnused = 0x05000000, + OMX_IndexParamImagePortFormat, /**< reference: OMX_IMAGE_PARAM_PORTFORMATTYPE */ + OMX_IndexParamFlashControl, /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */ + OMX_IndexConfigFocusControl, /**< reference: OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE */ + OMX_IndexParamQFactor, /**< reference: OMX_IMAGE_PARAM_QFACTORTYPE */ + OMX_IndexParamQuantizationTable, /**< reference: OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE */ + OMX_IndexParamHuffmanTable, /**< reference: OMX_IMAGE_PARAM_HUFFMANTTABLETYPE */ + OMX_IndexConfigFlashControl, /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */ + + /* Video specific parameters and configurations */ + OMX_IndexVideoStartUnused = 0x06000000, + OMX_IndexParamVideoPortFormat, /**< reference: OMX_VIDEO_PARAM_PORTFORMATTYPE */ + OMX_IndexParamVideoQuantization, /**< reference: OMX_VIDEO_PARAM_QUANTIZATIONTYPE */ + OMX_IndexParamVideoFastUpdate, /**< reference: OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE */ + OMX_IndexParamVideoBitrate, /**< reference: OMX_VIDEO_PARAM_BITRATETYPE */ + OMX_IndexParamVideoMotionVector, /**< reference: OMX_VIDEO_PARAM_MOTIONVECTORTYPE */ + OMX_IndexParamVideoIntraRefresh, /**< reference: OMX_VIDEO_PARAM_INTRAREFRESHTYPE */ + OMX_IndexParamVideoErrorCorrection, /**< reference: OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE */ + OMX_IndexParamVideoVBSMC, /**< reference: OMX_VIDEO_PARAM_VBSMCTYPE */ + OMX_IndexParamVideoMpeg2, /**< reference: OMX_VIDEO_PARAM_MPEG2TYPE */ + OMX_IndexParamVideoMpeg4, /**< reference: OMX_VIDEO_PARAM_MPEG4TYPE */ + OMX_IndexParamVideoWmv, /**< reference: OMX_VIDEO_PARAM_WMVTYPE */ + OMX_IndexParamVideoRv, /**< reference: OMX_VIDEO_PARAM_RVTYPE */ + OMX_IndexParamVideoAvc, /**< reference: OMX_VIDEO_PARAM_AVCTYPE */ + OMX_IndexParamVideoH263, /**< reference: OMX_VIDEO_PARAM_H263TYPE */ + OMX_IndexParamVideoProfileLevelQuerySupported, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */ + OMX_IndexParamVideoProfileLevelCurrent, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */ + OMX_IndexConfigVideoBitrate, /**< reference: OMX_VIDEO_CONFIG_BITRATETYPE */ + OMX_IndexConfigVideoFramerate, /**< reference: OMX_CONFIG_FRAMERATETYPE */ + OMX_IndexConfigVideoIntraVOPRefresh, /**< reference: OMX_CONFIG_INTRAREFRESHVOPTYPE */ + OMX_IndexConfigVideoIntraMBRefresh, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */ + OMX_IndexConfigVideoMBErrorReporting, /**< reference: OMX_CONFIG_MBERRORREPORTINGTYPE */ + OMX_IndexParamVideoMacroblocksPerFrame, /**< reference: OMX_PARAM_MACROBLOCKSTYPE */ + OMX_IndexConfigVideoMacroBlockErrorMap, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */ + OMX_IndexParamVideoSliceFMO, /**< reference: OMX_VIDEO_PARAM_AVCSLICEFMO */ + OMX_IndexConfigVideoAVCIntraPeriod, /**< reference: OMX_VIDEO_CONFIG_AVCINTRAPERIOD */ + OMX_IndexConfigVideoNalSize, /**< reference: OMX_VIDEO_CONFIG_NALSIZE */ + + /* Image & Video common Configurations */ + OMX_IndexCommonStartUnused = 0x07000000, + OMX_IndexParamCommonDeblocking, /**< reference: OMX_PARAM_DEBLOCKINGTYPE */ + OMX_IndexParamCommonSensorMode, /**< reference: OMX_PARAM_SENSORMODETYPE */ + OMX_IndexParamCommonInterleave, /**< reference: OMX_PARAM_INTERLEAVETYPE */ + OMX_IndexConfigCommonColorFormatConversion, /**< reference: OMX_CONFIG_COLORCONVERSIONTYPE */ + OMX_IndexConfigCommonScale, /**< reference: OMX_CONFIG_SCALEFACTORTYPE */ + OMX_IndexConfigCommonImageFilter, /**< reference: OMX_CONFIG_IMAGEFILTERTYPE */ + OMX_IndexConfigCommonColorEnhancement, /**< reference: OMX_CONFIG_COLORENHANCEMENTTYPE */ + OMX_IndexConfigCommonColorKey, /**< reference: OMX_CONFIG_COLORKEYTYPE */ + OMX_IndexConfigCommonColorBlend, /**< reference: OMX_CONFIG_COLORBLENDTYPE */ + OMX_IndexConfigCommonFrameStabilisation,/**< reference: OMX_CONFIG_FRAMESTABTYPE */ + OMX_IndexConfigCommonRotate, /**< reference: OMX_CONFIG_ROTATIONTYPE */ + OMX_IndexConfigCommonMirror, /**< reference: OMX_CONFIG_MIRRORTYPE */ + OMX_IndexConfigCommonOutputPosition, /**< reference: OMX_CONFIG_POINTTYPE */ + OMX_IndexConfigCommonInputCrop, /**< reference: OMX_CONFIG_RECTTYPE */ + OMX_IndexConfigCommonOutputCrop, /**< reference: OMX_CONFIG_RECTTYPE */ + OMX_IndexConfigCommonDigitalZoom, /**< reference: OMX_CONFIG_SCALEFACTORTYPE */ + OMX_IndexConfigCommonOpticalZoom, /**< reference: OMX_CONFIG_SCALEFACTORTYPE*/ + OMX_IndexConfigCommonWhiteBalance, /**< reference: OMX_CONFIG_WHITEBALCONTROLTYPE */ + OMX_IndexConfigCommonExposure, /**< reference: OMX_CONFIG_EXPOSURECONTROLTYPE */ + OMX_IndexConfigCommonContrast, /**< reference: OMX_CONFIG_CONTRASTTYPE */ + OMX_IndexConfigCommonBrightness, /**< reference: OMX_CONFIG_BRIGHTNESSTYPE */ + OMX_IndexConfigCommonBacklight, /**< reference: OMX_CONFIG_BACKLIGHTTYPE */ + OMX_IndexConfigCommonGamma, /**< reference: OMX_CONFIG_GAMMATYPE */ + OMX_IndexConfigCommonSaturation, /**< reference: OMX_CONFIG_SATURATIONTYPE */ + OMX_IndexConfigCommonLightness, /**< reference: OMX_CONFIG_LIGHTNESSTYPE */ + OMX_IndexConfigCommonExclusionRect, /**< reference: OMX_CONFIG_RECTTYPE */ + OMX_IndexConfigCommonDithering, /**< reference: OMX_CONFIG_DITHERTYPE */ + OMX_IndexConfigCommonPlaneBlend, /**< reference: OMX_CONFIG_PLANEBLENDTYPE */ + OMX_IndexConfigCommonExposureValue, /**< reference: OMX_CONFIG_EXPOSUREVALUETYPE */ + OMX_IndexConfigCommonOutputSize, /**< reference: OMX_FRAMESIZETYPE */ + OMX_IndexParamCommonExtraQuantData, /**< reference: OMX_OTHER_EXTRADATATYPE */ + OMX_IndexConfigCommonFocusRegion, /**< reference: OMX_CONFIG_FOCUSREGIONTYPE */ + OMX_IndexConfigCommonFocusStatus, /**< reference: OMX_PARAM_FOCUSSTATUSTYPE */ + OMX_IndexConfigCommonTransitionEffect, /**< reference: OMX_CONFIG_TRANSITIONEFFECTTYPE */ + + /* Reserved Configuration range */ + OMX_IndexOtherStartUnused = 0x08000000, + OMX_IndexParamOtherPortFormat, /**< reference: OMX_OTHER_PARAM_PORTFORMATTYPE */ + OMX_IndexConfigOtherPower, /**< reference: OMX_OTHER_CONFIG_POWERTYPE */ + OMX_IndexConfigOtherStats, /**< reference: OMX_OTHER_CONFIG_STATSTYPE */ + + + /* Reserved Time range */ + OMX_IndexTimeStartUnused = 0x09000000, + OMX_IndexConfigTimeScale, /**< reference: OMX_TIME_CONFIG_SCALETYPE */ + OMX_IndexConfigTimeClockState, /**< reference: OMX_TIME_CONFIG_CLOCKSTATETYPE */ + OMX_IndexConfigTimeActiveRefClock, /**< reference: OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE */ + OMX_IndexConfigTimeCurrentMediaTime, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */ + OMX_IndexConfigTimeCurrentWallTime, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */ + OMX_IndexConfigTimeCurrentAudioReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */ + OMX_IndexConfigTimeCurrentVideoReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */ + OMX_IndexConfigTimeMediaTimeRequest, /**< reference: OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE (write only) */ + OMX_IndexConfigTimeClientStartTime, /** + + +/** + * Enumeration of possible data types which match to multiple domains or no + * domain at all. For types which are vendor specific, a value above + * OMX_OTHER_VENDORTSTART should be used. + */ +typedef enum OMX_OTHER_FORMATTYPE { + OMX_OTHER_FormatTime = 0, /**< Transmission of various timestamps, elapsed time, + time deltas, etc */ + OMX_OTHER_FormatPower, /**< Perhaps used for enabling/disabling power + management, setting clocks? */ + OMX_OTHER_FormatStats, /**< Could be things such as frame rate, frames + dropped, etc */ + OMX_OTHER_FormatBinary, /**< Arbitrary binary data */ + OMX_OTHER_FormatVendorReserved = 1000, /**< Starting value for vendor specific + formats */ + + OMX_OTHER_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_OTHER_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_OTHER_FormatMax = 0x7FFFFFFF +} OMX_OTHER_FORMATTYPE; + +/** + * Enumeration of seek modes. + */ +typedef enum OMX_TIME_SEEKMODETYPE { + OMX_TIME_SeekModeFast = 0, /**< Prefer seeking to an approximation + * of the requested seek position over + * the actual seek position if it + * results in a faster seek. */ + OMX_TIME_SeekModeAccurate, /**< Prefer seeking to the actual seek + * position over an approximation + * of the requested seek position even + * if it results in a slower seek. */ + OMX_TIME_SeekModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_TIME_SeekModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_TIME_SeekModeMax = 0x7FFFFFFF +} OMX_TIME_SEEKMODETYPE; + +/* Structure representing the seekmode of the component */ +typedef struct OMX_TIME_CONFIG_SEEKMODETYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_TIME_SEEKMODETYPE eType; /**< The seek mode */ +} OMX_TIME_CONFIG_SEEKMODETYPE; + +/** Structure representing a time stamp used with the following configs + * on the Clock Component (CC): + * + * OMX_IndexConfigTimeCurrentWallTime: query of the CC’s current wall + * time + * OMX_IndexConfigTimeCurrentMediaTime: query of the CC’s current media + * time + * OMX_IndexConfigTimeCurrentAudioReference and + * OMX_IndexConfigTimeCurrentVideoReference: audio/video reference + * clock sending SC its reference time + * OMX_IndexConfigTimeClientStartTime: a Clock Component client sends + * this structure to the Clock Component via a SetConfig on its + * client port when it receives a buffer with + * OMX_BUFFERFLAG_STARTTIME set. It must use the timestamp + * specified by that buffer for nStartTimestamp. + * + * It’s also used with the following config on components in general: + * + * OMX_IndexConfigTimePosition: IL client querying component position + * (GetConfig) or commanding a component to seek to the given location + * (SetConfig) + */ +typedef struct OMX_TIME_CONFIG_TIMESTAMPTYPE { + 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_TICKS nTimestamp; /**< timestamp .*/ +} OMX_TIME_CONFIG_TIMESTAMPTYPE; + +/** Enumeration of possible reference clocks to the media time. */ +typedef enum OMX_TIME_UPDATETYPE { + OMX_TIME_UpdateRequestFulfillment, /**< Update is the fulfillment of a media time request. */ + OMX_TIME_UpdateScaleChanged, /**< Update was generated because the scale chagned. */ + OMX_TIME_UpdateClockStateChanged, /**< Update was generated because the clock state changed. */ + OMX_TIME_UpdateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_TIME_UpdateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_TIME_UpdateMax = 0x7FFFFFFF +} OMX_TIME_UPDATETYPE; + +/** Enumeration of possible reference clocks to the media time. */ +typedef enum OMX_TIME_REFCLOCKTYPE { + OMX_TIME_RefClockNone, /**< Use no references. */ + OMX_TIME_RefClockAudio, /**< Use references sent through OMX_IndexConfigTimeCurrentAudioReference */ + OMX_TIME_RefClockVideo, /**< Use references sent through OMX_IndexConfigTimeCurrentVideoReference */ + OMX_TIME_RefClockKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_TIME_RefClockVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_TIME_RefClockMax = 0x7FFFFFFF +} OMX_TIME_REFCLOCKTYPE; + +/** Enumeration of clock states. */ +typedef enum OMX_TIME_CLOCKSTATE { + OMX_TIME_ClockStateRunning, /**< Clock running. */ + OMX_TIME_ClockStateWaitingForStartTime, /**< Clock waiting until the + * prescribed clients emit their + * start time. */ + OMX_TIME_ClockStateStopped, /**< Clock stopped. */ + OMX_TIME_ClockStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_TIME_ClockStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_TIME_ClockStateMax = 0x7FFFFFFF +} OMX_TIME_CLOCKSTATE; + +/** Structure representing a media time request to the clock component. + * + * A client component sends this structure to the Clock Component via a SetConfig + * on its client port to specify a media timestamp the Clock Component + * should emit. The Clock Component should fulfill the request by sending a + * OMX_TIME_MEDIATIMETYPE when its media clock matches the requested + * timestamp. + * + * The client may require a media time request be fulfilled slightly + * earlier than the media time specified. In this case the client specifies + * an offset which is equal to the difference between wall time corresponding + * to the requested media time and the wall time when it will be + * fulfilled. + * + * A client component may uses these requests and the OMX_TIME_MEDIATIMETYPE to + * time events according to timestamps. If a client must perform an operation O at + * a time T (e.g. deliver a video frame at its corresponding timestamp), it makes a + * media time request at T (perhaps specifying an offset to ensure the request fulfillment + * is a little early). When the clock component passes the resulting OMX_TIME_MEDIATIMETYPE + * structure back to the client component, the client may perform operation O (perhaps having + * to wait a slight amount more time itself as specified by the return values). + */ + +typedef struct OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE { + 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_PTR pClientPrivate; /**< Client private data to disabiguate this media time + * from others (e.g. the number of the frame to deliver). + * Duplicated in the media time structure that fulfills + * this request. A value of zero is reserved for time scale + * updates. */ + OMX_TICKS nMediaTimestamp; /**< Media timestamp requested.*/ + OMX_TICKS nOffset; /**< Amount of wall clock time by which this + * request should be fulfilled early */ +} OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE; + +/**< Structure sent from the clock component client either when fulfilling + * a media time request or when the time scale has changed. + * + * In the former case the Clock Component fills this structure and times its emission + * to a client component (via the client port) according to the corresponding media + * time request sent by the client. The Clock Component should time the emission to occur + * when the requested timestamp matches the Clock Component's media time but also the + * prescribed offset early. + * + * Upon scale changes the clock component clears the nClientPrivate data, sends the current + * media time and sets the nScale to the new scale via the client port. It emits a + * OMX_TIME_MEDIATIMETYPE to all clients independent of any requests. This allows clients to + * alter processing to accomodate scaling. For instance a video component might skip inter-frames + * in the case of extreme fastforward. Likewise an audio component might add or remove samples + * from an audio frame to scale audio data. + * + * It is expected that some clock components may not be able to fulfill requests + * at exactly the prescribed time. This is acceptable so long as the request is + * fulfilled at least as early as described and not later. This structure provides + * fields the client may use to wait for the remaining time. + * + * The client may use either the nOffset or nWallTimeAtMedia fields to determine the + * wall time until the nMediaTimestamp actually occurs. In the latter case the + * client can get a more accurate value for offset by getting the current wall + * from the cloc component and subtracting it from nWallTimeAtMedia. + */ + +typedef struct OMX_TIME_MEDIATIMETYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nClientPrivate; /**< Client private data to disabiguate this media time + * from others. Copied from the media time request. + * A value of zero is reserved for time scale updates. */ + OMX_TIME_UPDATETYPE eUpdateType; /**< Reason for the update */ + OMX_TICKS nMediaTimestamp; /**< Media time requested. If no media time was + * requested then this is the current media time. */ + OMX_TICKS nOffset; /**< Amount of wall clock time by which this + * request was actually fulfilled early */ + + OMX_TICKS nWallTimeAtMediaTime; /**< Wall time corresponding to nMediaTimeStamp. + * A client may compare this value to current + * media time obtained from the Clock Component to determine + * the wall time until the media timestamp is really + * current. */ + OMX_S32 xScale; /**< Current media time scale in Q16 format. */ + OMX_TIME_CLOCKSTATE eState; /* Seeking Change. Added 7/12.*/ + /**< State of the media time. */ +} OMX_TIME_MEDIATIMETYPE; + +/** Structure representing the current media time scale factor. Applicable only to clock + * component, other components see scale changes via OMX_TIME_MEDIATIMETYPE buffers sent via + * the clock component client ports. Upon recieving this config the clock component changes + * the rate by which the media time increases or decreases effectively implementing trick modes. + */ +typedef struct OMX_TIME_CONFIG_SCALETYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_S32 xScale; /**< This is a value in Q16 format which is used for + * scaling the media time */ +} OMX_TIME_CONFIG_SCALETYPE; + +/** Bits used to identify a clock port. Used in OMX_TIME_CONFIG_CLOCKSTATETYPE’s nWaitMask field */ +#define OMX_CLOCKPORT0 0x00000001 +#define OMX_CLOCKPORT1 0x00000002 +#define OMX_CLOCKPORT2 0x00000004 +#define OMX_CLOCKPORT3 0x00000008 +#define OMX_CLOCKPORT4 0x00000010 +#define OMX_CLOCKPORT5 0x00000020 +#define OMX_CLOCKPORT6 0x00000040 +#define OMX_CLOCKPORT7 0x00000080 + +/** Structure representing the current mode of the media clock. + * IL Client uses this config to change or query the mode of the + * media clock of the clock component. Applicable only to clock + * component. + * + * On a SetConfig if eState is OMX_TIME_ClockStateRunning media time + * starts immediately at the prescribed start time. If + * OMX_TIME_ClockStateWaitingForStartTime the Clock Component ignores + * the given nStartTime and waits for all clients specified in the + * nWaitMask to send starttimes (via + * OMX_IndexConfigTimeClientStartTime). The Clock Component then starts + * the media clock using the earliest start time supplied. */ +typedef struct OMX_TIME_CONFIG_CLOCKSTATETYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version + * information */ + OMX_TIME_CLOCKSTATE eState; /**< State of the media time. */ + OMX_TICKS nStartTime; /**< Start time of the media time. */ + OMX_TICKS nOffset; /**< Time to offset the media time by + * (e.g. preroll). Media time will be + * reported to be nOffset ticks earlier. + */ + OMX_U32 nWaitMask; /**< Mask of OMX_CLOCKPORT values. */ +} OMX_TIME_CONFIG_CLOCKSTATETYPE; + +/** Structure representing the reference clock currently being used to + * compute media time. IL client uses this config to change or query the + * clock component's active reference clock */ +typedef struct OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_TIME_REFCLOCKTYPE eClock; /**< Reference clock used to compute media time */ +} OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE; + +/** Descriptor for setting specifics of power type. + * Note: this structure is listed for backwards compatibility. */ +typedef struct OMX_OTHER_CONFIG_POWERTYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_BOOL bEnablePM; /**< Flag to enable Power Management */ +} OMX_OTHER_CONFIG_POWERTYPE; + + +/** Descriptor for setting specifics of stats type. + * Note: this structure is listed for backwards compatibility. */ +typedef struct OMX_OTHER_CONFIG_STATSTYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + /* what goes here */ +} OMX_OTHER_CONFIG_STATSTYPE; + + +/** + * The PortDefinition structure is used to define all of the parameters + * necessary for the compliant component to setup an input or an output other + * path. + */ +typedef struct OMX_OTHER_PORTDEFINITIONTYPE { + OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */ +} OMX_OTHER_PORTDEFINITIONTYPE; + +/** Port format parameter. This structure is used to enumerate + * the various data input/output format supported by the port. + */ +typedef struct OMX_OTHER_PARAM_PORTFORMATTYPE { + OMX_U32 nSize; /**< size of the structure in bytes */ + OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ + OMX_U32 nPortIndex; /**< Indicates which port to set */ + OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */ + OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */ +} OMX_OTHER_PARAM_PORTFORMATTYPE; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif +/* File EOF */ diff --git a/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Types.h b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Types.h new file mode 100644 index 0000000..31be916 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Types.h @@ -0,0 +1,347 @@ +/* + * Copyright (c) 2008 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_Types.h - OpenMax IL version 1.1.2 + * The OMX_Types header file contains the primitive type definitions used by + * the core, the application and the component. This file may need to be + * modified to be used on systems that do not have "char" set to 8 bits, + * "short" set to 16 bits and "long" set to 32 bits. + */ + +#ifndef OMX_Types_h +#define OMX_Types_h + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** The OMX_API and OMX_APIENTRY are platform specific definitions used + * to declare OMX function prototypes. They are modified to meet the + * requirements for a particular platform */ +#ifdef __SYMBIAN32__ +# ifdef __OMX_EXPORTS +# define OMX_API __declspec(dllexport) +# else +# ifdef _WIN32 +# define OMX_API __declspec(dllexport) +# else +# define OMX_API __declspec(dllimport) +# endif +# endif +#else +# ifdef _WIN32 +# ifdef __OMX_EXPORTS +# define OMX_API __declspec(dllexport) +# else +# define OMX_API __declspec(dllimport) +# endif +# else +# ifdef __OMX_EXPORTS +# define OMX_API +# else +# define OMX_API extern +# endif +# endif +#endif + +#ifndef OMX_APIENTRY +#define OMX_APIENTRY +#endif + +/** OMX_IN is used to identify inputs to an OMX function. This designation + will also be used in the case of a pointer that points to a parameter + that is used as an output. */ +#ifndef OMX_IN +#define OMX_IN +#endif + +/** OMX_OUT is used to identify outputs from an OMX function. This + designation will also be used in the case of a pointer that points + to a parameter that is used as an input. */ +#ifndef OMX_OUT +#define OMX_OUT +#endif + + +/** OMX_INOUT is used to identify parameters that may be either inputs or + outputs from an OMX function at the same time. This designation will + also be used in the case of a pointer that points to a parameter that + is used both as an input and an output. */ +#ifndef OMX_INOUT +#define OMX_INOUT +#endif + +/** OMX_ALL is used to as a wildcard to select all entities of the same type + * when specifying the index, or referring to a object by an index. (i.e. + * use OMX_ALL to indicate all N channels). When used as a port index + * for a config or parameter this OMX_ALL denotes that the config or + * parameter applies to the entire component not just one port. */ +#define OMX_ALL 0xFFFFFFFF + +/** In the following we define groups that help building doxygen documentation */ + +/** @defgroup core OpenMAX IL core + * Functions and structure related to the OMX IL core + */ + + /** @defgroup comp OpenMAX IL component + * Functions and structure related to the OMX IL component + */ + +/** @defgroup rpm Resource and Policy Management + * Structures for resource and policy management of components + */ + +/** @defgroup buf Buffer Management + * Buffer handling functions and structures + */ + +/** @defgroup tun Tunneling + * @ingroup core comp + * Structures and functions to manage tunnels among component ports + */ + +/** @defgroup cp Content Pipes + * @ingroup core + */ + + /** @defgroup metadata Metadata handling + * + */ + +/** OMX_U8 is an 8 bit unsigned quantity that is byte aligned */ +typedef unsigned char OMX_U8; + +/** OMX_S8 is an 8 bit signed quantity that is byte aligned */ +typedef signed char OMX_S8; + +/** OMX_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */ +typedef unsigned short OMX_U16; + +/** OMX_S16 is a 16 bit signed quantity that is 16 bit word aligned */ +typedef signed short OMX_S16; + +/** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */ +typedef unsigned long OMX_U32; + +/** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */ +typedef signed long OMX_S32; + + +/* Users with compilers that cannot accept the "long long" designation should + define the OMX_SKIP64BIT macro. It should be noted that this may cause + some components to fail to compile if the component was written to require + 64 bit integral types. However, these components would NOT compile anyway + since the compiler does not support the way the component was written. +*/ +#ifndef OMX_SKIP64BIT +#ifdef __SYMBIAN32__ +/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ +typedef unsigned long long OMX_U64; + +/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */ +typedef signed long long OMX_S64; + +#elif defined(WIN32) + +/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ +typedef unsigned __int64 OMX_U64; + +/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */ +typedef signed __int64 OMX_S64; + +#else /* WIN32 */ + +/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ +typedef unsigned long long OMX_U64; + +/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */ +typedef signed long long OMX_S64; + +#endif /* WIN32 */ +#endif + + +/** The OMX_BOOL type is intended to be used to represent a true or a false + value when passing parameters to and from the OMX core and components. The + OMX_BOOL is a 32 bit quantity and is aligned on a 32 bit word boundary. + */ +typedef enum OMX_BOOL { + OMX_FALSE = 0, + OMX_TRUE = !OMX_FALSE, + OMX_BOOL_MAX = 0x7FFFFFFF +} OMX_BOOL; + +/** The OMX_PTR type is intended to be used to pass pointers between the OMX + applications and the OMX Core and components. This is a 32 bit pointer and + is aligned on a 32 bit boundary. + */ +typedef void* OMX_PTR; + +/** The OMX_STRING type is intended to be used to pass "C" type strings between + the application and the core and component. The OMX_STRING type is a 32 + bit pointer to a zero terminated string. The pointer is word aligned and + the string is byte aligned. + */ +typedef char* OMX_STRING; + +/** The OMX_BYTE type is intended to be used to pass arrays of bytes such as + buffers between the application and the component and core. The OMX_BYTE + type is a 32 bit pointer to a zero terminated string. The pointer is word + aligned and the string is byte aligned. + */ +typedef unsigned char* OMX_BYTE; + +/** OMX_UUIDTYPE is a very long unique identifier to uniquely identify + at runtime. This identifier should be generated by a component in a way + that guarantees that every instance of the identifier running on the system + is unique. */ +typedef unsigned char OMX_UUIDTYPE[128]; + +/** The OMX_DIRTYPE enumeration is used to indicate if a port is an input or + an output port. This enumeration is common across all component types. + */ +typedef enum OMX_DIRTYPE +{ + OMX_DirInput, /**< Port is an input port */ + OMX_DirOutput, /**< Port is an output port */ + OMX_DirMax = 0x7FFFFFFF +} OMX_DIRTYPE; + +/** The OMX_ENDIANTYPE enumeration is used to indicate the bit ordering + for numerical data (i.e. big endian, or little endian). + */ +typedef enum OMX_ENDIANTYPE +{ + OMX_EndianBig, /**< big endian */ + OMX_EndianLittle, /**< little endian */ + OMX_EndianMax = 0x7FFFFFFF +} OMX_ENDIANTYPE; + + +/** The OMX_NUMERICALDATATYPE enumeration is used to indicate if data + is signed or unsigned + */ +typedef enum OMX_NUMERICALDATATYPE +{ + OMX_NumericalDataSigned, /**< signed data */ + OMX_NumericalDataUnsigned, /**< unsigned data */ + OMX_NumercialDataMax = 0x7FFFFFFF +} OMX_NUMERICALDATATYPE; + + +/** Unsigned bounded value type */ +typedef struct OMX_BU32 { + OMX_U32 nValue; /**< actual value */ + OMX_U32 nMin; /**< minimum for value (i.e. nValue >= nMin) */ + OMX_U32 nMax; /**< maximum for value (i.e. nValue <= nMax) */ +} OMX_BU32; + + +/** Signed bounded value type */ +typedef struct OMX_BS32 { + OMX_S32 nValue; /**< actual value */ + OMX_S32 nMin; /**< minimum for value (i.e. nValue >= nMin) */ + OMX_S32 nMax; /**< maximum for value (i.e. nValue <= nMax) */ +} OMX_BS32; + + +/** Structure representing some time or duration in microseconds. This structure + * must be interpreted as a signed 64 bit value. The quantity is signed to accommodate + * negative deltas and preroll scenarios. The quantity is represented in microseconds + * to accomodate high resolution timestamps (e.g. DVD presentation timestamps based + * on a 90kHz clock) and to allow more accurate and synchronized delivery (e.g. + * individual audio samples delivered at 192 kHz). The quantity is 64 bit to + * accommodate a large dynamic range (signed 32 bit values would allow only for plus + * or minus 35 minutes). + * + * Implementations with limited precision may convert the signed 64 bit value to + * a signed 32 bit value internally but risk loss of precision. + */ +#ifndef OMX_SKIP64BIT +typedef OMX_S64 OMX_TICKS; +#else +typedef struct OMX_TICKS +{ + OMX_U32 nLowPart; /** low bits of the signed 64 bit tick value */ + OMX_U32 nHighPart; /** high bits of the signed 64 bit tick value */ +} OMX_TICKS; +#endif +#define OMX_TICKS_PER_SECOND 1000000 + +/** Define the public interface for the OMX Handle. The core will not use + this value internally, but the application should only use this value. + */ +typedef void* OMX_HANDLETYPE; + +typedef struct OMX_MARKTYPE +{ + OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will + generate a mark event upon + processing the mark. */ + OMX_PTR pMarkData; /**< Application specific data associated with + the mark sent on a mark event to disambiguate + this mark from others. */ +} OMX_MARKTYPE; + + +/** OMX_NATIVE_DEVICETYPE is used to map a OMX video port to the + * platform & operating specific object used to reference the display + * or can be used by a audio port for native audio rendering */ +typedef void* OMX_NATIVE_DEVICETYPE; + +/** OMX_NATIVE_WINDOWTYPE is used to map a OMX video port to the + * platform & operating specific object used to reference the window */ +typedef void* OMX_NATIVE_WINDOWTYPE; + +/** The OMX_VERSIONTYPE union is used to specify the version for + a structure or component. For a component, the version is entirely + specified by the component vendor. Components doing the same function + from different vendors may or may not have the same version. For + structures, the version shall be set by the entity that allocates the + structure. For structures specified in the OMX 1.1 specification, the + value of the version shall be set to 1.1.0.0 in all cases. Access to the + OMX_VERSIONTYPE can be by a single 32 bit access (e.g. by nVersion) or + by accessing one of the structure elements to, for example, check only + the Major revision. + */ +typedef union OMX_VERSIONTYPE +{ + struct + { + OMX_U8 nVersionMajor; /**< Major version accessor element */ + OMX_U8 nVersionMinor; /**< Minor version accessor element */ + OMX_U8 nRevision; /**< Revision version accessor element */ + OMX_U8 nStep; /**< Step version accessor element */ + } s; + OMX_U32 nVersion; /**< 32 bit value to make accessing the + version easily done in a single word + size copy/compare operation */ +} OMX_VERSIONTYPE; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif +/* File EOF */ diff --git a/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Video.h b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Video.h new file mode 100644 index 0000000..163e450 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_include/khronos/OMX_Video.h @@ -0,0 +1,1060 @@ +/** + * Copyright (c) 2008 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. + * + */ + +/** + * @file OMX_Video.h - OpenMax IL version 1.1.2 + * The structures is needed by Video components to exchange parameters + * and configuration data with OMX components. + */ +#ifndef OMX_Video_h +#define OMX_Video_h + +/** @defgroup video OpenMAX IL Video Domain + * @ingroup iv + * Structures for OpenMAX IL Video domain + * @{ + */ + +#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 + + +/** + * Enumeration used to define the possible video compression codings. + * NOTE: This essentially refers to file extensions. If the coding is + * being used to specify the ENCODE type, then additional work + * must be done to configure the exact flavor of the compression + * to be used. For decode cases where the user application can + * not differentiate between MPEG-4 and H.264 bit streams, it is + * up to the codec to handle this. + */ +typedef enum OMX_VIDEO_CODINGTYPE { + OMX_VIDEO_CodingUnused, /**< Value when coding is N/A */ + OMX_VIDEO_CodingAutoDetect, /**< Autodetection of coding type */ + OMX_VIDEO_CodingMPEG2, /**< AKA: H.262 */ + OMX_VIDEO_CodingH263, /**< H.263 */ + OMX_VIDEO_CodingMPEG4, /**< MPEG-4 */ + OMX_VIDEO_CodingWMV, /**< all versions of Windows Media Video */ + OMX_VIDEO_CodingRV, /**< all versions of Real Video */ + OMX_VIDEO_CodingAVC, /**< H.264/AVC */ + OMX_VIDEO_CodingMJPEG, /**< Motion JPEG */ + OMX_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_CodingMax = 0x7FFFFFFF +} OMX_VIDEO_CODINGTYPE; + + +/** + * Data structure used to define a video path. The number of Video paths for + * input and output will vary by type of the Video component. + * + * Input (aka Source) : zero Inputs, one Output, + * Splitter : one Input, 2 or more Outputs, + * Processing Element : one Input, one output, + * Mixer : 2 or more inputs, one output, + * Output (aka Sink) : one Input, zero outputs. + * + * The PortDefinition structure is used to define all of the parameters + * necessary for the compliant component to setup an input or an output video + * path. If additional vendor specific data is required, it should be + * transmitted to the component using the CustomCommand function. Compliant + * components will prepopulate this structure with optimal values during the + * GetDefaultInitParams command. + * + * STRUCT MEMBERS: + * cMIMEType : MIME type of data for the port + * pNativeRender : Platform specific reference for a display if a + * sync, otherwise this field is 0 + * nFrameWidth : Width of frame to be used on channel if + * uncompressed format is used. Use 0 for unknown, + * don't care or variable + * nFrameHeight : Height of frame to be used on channel if + * uncompressed format is used. Use 0 for unknown, + * don't care or variable + * nStride : Number of bytes per span of an image + * (i.e. indicates the number of bytes to get + * from span N to span N+1, where negative stride + * indicates the image is bottom up + * nSliceHeight : Height used when encoding in slices + * nBitrate : Bit rate of frame to be used on channel if + * compressed format is used. Use 0 for unknown, + * don't care or variable + * xFramerate : Frame rate to be used on channel if uncompressed + * format is used. Use 0 for unknown, don't care or + * variable. Units are Q16 frames per second. + * bFlagErrorConcealment : Turns on error concealment if it is supported by + * the OMX component + * eCompressionFormat : Compression format used in this instance of the + * component. When OMX_VIDEO_CodingUnused is + * specified, eColorFormat is used + * eColorFormat : Decompressed format used by this component + * pNativeWindow : Platform specific reference for a window object if a + * display sink , otherwise this field is 0x0. + */ +typedef struct OMX_VIDEO_PORTDEFINITIONTYPE { + OMX_STRING cMIMEType; + OMX_NATIVE_DEVICETYPE pNativeRender; + OMX_U32 nFrameWidth; + OMX_U32 nFrameHeight; + OMX_S32 nStride; + OMX_U32 nSliceHeight; + OMX_U32 nBitrate; + OMX_U32 xFramerate; + OMX_BOOL bFlagErrorConcealment; + OMX_VIDEO_CODINGTYPE eCompressionFormat; + OMX_COLOR_FORMATTYPE eColorFormat; + OMX_NATIVE_WINDOWTYPE pNativeWindow; +} OMX_VIDEO_PORTDEFINITIONTYPE; + +/** + * Port format parameter. This structure is used to enumerate the various + * data input/output format supported by the port. + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Indicates which port to set + * nIndex : Indicates the enumeration index for the format from + * 0x0 to N-1 + * eCompressionFormat : Compression format used in this instance of the + * component. When OMX_VIDEO_CodingUnused is specified, + * eColorFormat is used + * eColorFormat : Decompressed format used by this component + * xFrameRate : Indicates the video frame rate in Q16 format + */ +typedef struct OMX_VIDEO_PARAM_PORTFORMATTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nIndex; + OMX_VIDEO_CODINGTYPE eCompressionFormat; + OMX_COLOR_FORMATTYPE eColorFormat; + OMX_U32 xFramerate; +} OMX_VIDEO_PARAM_PORTFORMATTYPE; + + +/** + * This is a structure for configuring video compression quantization + * parameter values. Codecs may support different QP values for different + * frame types. + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version info + * nPortIndex : Port that this structure applies to + * nQpI : QP value to use for index frames + * nQpP : QP value to use for P frames + * nQpB : QP values to use for bidirectional frames + */ +typedef struct OMX_VIDEO_PARAM_QUANTIZATIONTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nQpI; + OMX_U32 nQpP; + OMX_U32 nQpB; +} OMX_VIDEO_PARAM_QUANTIZATIONTYPE; + + +/** + * Structure for configuration of video fast update parameters. + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version info + * nPortIndex : Port that this structure applies to + * bEnableVFU : Enable/Disable video fast update + * nFirstGOB : Specifies the number of the first macroblock row + * nFirstMB : specifies the first MB relative to the specified first GOB + * nNumMBs : Specifies the number of MBs to be refreshed from nFirstGOB + * and nFirstMB + */ +typedef struct OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_BOOL bEnableVFU; + OMX_U32 nFirstGOB; + OMX_U32 nFirstMB; + OMX_U32 nNumMBs; +} OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE; + + +/** + * Enumeration of possible bitrate control types + */ +typedef enum OMX_VIDEO_CONTROLRATETYPE { + OMX_Video_ControlRateDisable, + OMX_Video_ControlRateVariable, + OMX_Video_ControlRateConstant, + OMX_Video_ControlRateVariableSkipFrames, + OMX_Video_ControlRateConstantSkipFrames, + OMX_Video_ControlRateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_Video_ControlRateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_Video_ControlRateMax = 0x7FFFFFFF +} OMX_VIDEO_CONTROLRATETYPE; + + +/** + * Structure for configuring bitrate mode of a codec. + * + * STRUCT MEMBERS: + * nSize : Size of the struct in bytes + * nVersion : OMX spec version info + * nPortIndex : Port that this struct applies to + * eControlRate : Control rate type enum + * nTargetBitrate : Target bitrate to encode with + */ +typedef struct OMX_VIDEO_PARAM_BITRATETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_VIDEO_CONTROLRATETYPE eControlRate; + OMX_U32 nTargetBitrate; +} OMX_VIDEO_PARAM_BITRATETYPE; + + +/** + * Enumeration of possible motion vector (MV) types + */ +typedef enum OMX_VIDEO_MOTIONVECTORTYPE { + OMX_Video_MotionVectorPixel, + OMX_Video_MotionVectorHalfPel, + OMX_Video_MotionVectorQuarterPel, + OMX_Video_MotionVectorEighthPel, + OMX_Video_MotionVectorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_Video_MotionVectorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_Video_MotionVectorMax = 0x7FFFFFFF +} OMX_VIDEO_MOTIONVECTORTYPE; + + +/** + * Structure for configuring the number of motion vectors used as well + * as their accuracy. + * + * STRUCT MEMBERS: + * nSize : Size of the struct in bytes + * nVersion : OMX spec version info + * nPortIndex : port that this structure applies to + * eAccuracy : Enumerated MV accuracy + * bUnrestrictedMVs : Allow unrestricted MVs + * bFourMV : Allow use of 4 MVs + * sXSearchRange : Search range in horizontal direction for MVs + * sYSearchRange : Search range in vertical direction for MVs + */ +typedef struct OMX_VIDEO_PARAM_MOTIONVECTORTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_VIDEO_MOTIONVECTORTYPE eAccuracy; + OMX_BOOL bUnrestrictedMVs; + OMX_BOOL bFourMV; + OMX_S32 sXSearchRange; + OMX_S32 sYSearchRange; +} OMX_VIDEO_PARAM_MOTIONVECTORTYPE; + + +/** + * Enumeration of possible methods to use for Intra Refresh + */ +typedef enum OMX_VIDEO_INTRAREFRESHTYPE { + OMX_VIDEO_IntraRefreshCyclic, + OMX_VIDEO_IntraRefreshAdaptive, + OMX_VIDEO_IntraRefreshBoth, + OMX_VIDEO_IntraRefreshKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_IntraRefreshVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_IntraRefreshMax = 0x7FFFFFFF +} OMX_VIDEO_INTRAREFRESHTYPE; + + +/** + * Structure for configuring intra refresh mode + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eRefreshMode : Cyclic, Adaptive, or Both + * nAirMBs : Number of intra macroblocks to refresh in a frame when + * AIR is enabled + * nAirRef : Number of times a motion marked macroblock has to be + * intra coded + * nCirMBs : Number of consecutive macroblocks to be coded as "intra" + * when CIR is enabled + */ +typedef struct OMX_VIDEO_PARAM_INTRAREFRESHTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_VIDEO_INTRAREFRESHTYPE eRefreshMode; + OMX_U32 nAirMBs; + OMX_U32 nAirRef; + OMX_U32 nCirMBs; +} OMX_VIDEO_PARAM_INTRAREFRESHTYPE; + + +/** + * Structure for enabling various error correction methods for video + * compression. + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * bEnableHEC : Enable/disable header extension codes (HEC) + * bEnableResync : Enable/disable resynchronization markers + * nResynchMarkerSpacing : Resynch markers interval (in bits) to be + * applied in the stream + * bEnableDataPartitioning : Enable/disable data partitioning + * bEnableRVLC : Enable/disable reversible variable length + * coding + */ +typedef struct OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_BOOL bEnableHEC; + OMX_BOOL bEnableResync; + OMX_U32 nResynchMarkerSpacing; + OMX_BOOL bEnableDataPartitioning; + OMX_BOOL bEnableRVLC; +} OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE; + + +/** + * Configuration of variable block-size motion compensation (VBSMC) + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * b16x16 : Enable inter block search 16x16 + * b16x8 : Enable inter block search 16x8 + * b8x16 : Enable inter block search 8x16 + * b8x8 : Enable inter block search 8x8 + * b8x4 : Enable inter block search 8x4 + * b4x8 : Enable inter block search 4x8 + * b4x4 : Enable inter block search 4x4 + */ +typedef struct OMX_VIDEO_PARAM_VBSMCTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_BOOL b16x16; + OMX_BOOL b16x8; + OMX_BOOL b8x16; + OMX_BOOL b8x8; + OMX_BOOL b8x4; + OMX_BOOL b4x8; + OMX_BOOL b4x4; +} OMX_VIDEO_PARAM_VBSMCTYPE; + + +/** + * H.263 profile types, each profile indicates support for various + * performance bounds and different annexes. + * + * ENUMS: + * Baseline : Baseline Profile: H.263 (V1), no optional modes + * H320 Coding : H.320 Coding Efficiency Backward Compatibility + * Profile: H.263+ (V2), includes annexes I, J, L.4 + * and T + * BackwardCompatible : Backward Compatibility Profile: H.263 (V1), + * includes annex F + * ISWV2 : Interactive Streaming Wireless Profile: H.263+ + * (V2), includes annexes I, J, K and T + * ISWV3 : Interactive Streaming Wireless Profile: H.263++ + * (V3), includes profile 3 and annexes V and W.6.3.8 + * HighCompression : Conversational High Compression Profile: H.263++ + * (V3), includes profiles 1 & 2 and annexes D and U + * Internet : Conversational Internet Profile: H.263++ (V3), + * includes profile 5 and annex K + * Interlace : Conversational Interlace Profile: H.263++ (V3), + * includes profile 5 and annex W.6.3.11 + * HighLatency : High Latency Profile: H.263++ (V3), includes + * profile 6 and annexes O.1 and P.5 + */ +typedef enum OMX_VIDEO_H263PROFILETYPE { + OMX_VIDEO_H263ProfileBaseline = 0x01, + OMX_VIDEO_H263ProfileH320Coding = 0x02, + OMX_VIDEO_H263ProfileBackwardCompatible = 0x04, + OMX_VIDEO_H263ProfileISWV2 = 0x08, + OMX_VIDEO_H263ProfileISWV3 = 0x10, + OMX_VIDEO_H263ProfileHighCompression = 0x20, + OMX_VIDEO_H263ProfileInternet = 0x40, + OMX_VIDEO_H263ProfileInterlace = 0x80, + OMX_VIDEO_H263ProfileHighLatency = 0x100, + OMX_VIDEO_H263ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_H263ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_H263ProfileMax = 0x7FFFFFFF +} OMX_VIDEO_H263PROFILETYPE; + + +/** + * H.263 level types, each level indicates support for various frame sizes, + * bit rates, decoder frame rates. + */ +typedef enum OMX_VIDEO_H263LEVELTYPE { + OMX_VIDEO_H263Level10 = 0x01, + OMX_VIDEO_H263Level20 = 0x02, + OMX_VIDEO_H263Level30 = 0x04, + OMX_VIDEO_H263Level40 = 0x08, + OMX_VIDEO_H263Level45 = 0x10, + OMX_VIDEO_H263Level50 = 0x20, + OMX_VIDEO_H263Level60 = 0x40, + OMX_VIDEO_H263Level70 = 0x80, + OMX_VIDEO_H263LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_H263LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_H263LevelMax = 0x7FFFFFFF +} OMX_VIDEO_H263LEVELTYPE; + + +/** + * Specifies the picture type. These values should be OR'd to signal all + * pictures types which are allowed. + * + * ENUMS: + * Generic Picture Types: I, P and B + * H.263 Specific Picture Types: SI and SP + * H.264 Specific Picture Types: EI and EP + * MPEG-4 Specific Picture Types: S + */ +typedef enum OMX_VIDEO_PICTURETYPE { + OMX_VIDEO_PictureTypeI = 0x01, + OMX_VIDEO_PictureTypeP = 0x02, + OMX_VIDEO_PictureTypeB = 0x04, + OMX_VIDEO_PictureTypeSI = 0x08, + OMX_VIDEO_PictureTypeSP = 0x10, + OMX_VIDEO_PictureTypeEI = 0x11, + OMX_VIDEO_PictureTypeEP = 0x12, + OMX_VIDEO_PictureTypeS = 0x14, + OMX_VIDEO_PictureTypeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_PictureTypeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_PictureTypeMax = 0x7FFFFFFF +} OMX_VIDEO_PICTURETYPE; + + +/** + * H.263 Params + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nPFrames : Number of P frames between each I frame + * nBFrames : Number of B frames between each I frame + * eProfile : H.263 profile(s) to use + * eLevel : H.263 level(s) to use + * bPLUSPTYPEAllowed : Indicating that it is allowed to use PLUSPTYPE + * (specified in the 1998 version of H.263) to + * indicate custom picture sizes or clock + * frequencies + * nAllowedPictureTypes : Specifies the picture types allowed in the + * bitstream + * bForceRoundingTypeToZero : value of the RTYPE bit (bit 6 of MPPTYPE) is + * not constrained. It is recommended to change + * the value of the RTYPE bit for each reference + * picture in error-free communication + * nPictureHeaderRepetition : Specifies the frequency of picture header + * repetition + * nGOBHeaderInterval : Specifies the interval of non-empty GOB + * headers in units of GOBs + */ +typedef struct OMX_VIDEO_PARAM_H263TYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nPFrames; + OMX_U32 nBFrames; + OMX_VIDEO_H263PROFILETYPE eProfile; + OMX_VIDEO_H263LEVELTYPE eLevel; + OMX_BOOL bPLUSPTYPEAllowed; + OMX_U32 nAllowedPictureTypes; + OMX_BOOL bForceRoundingTypeToZero; + OMX_U32 nPictureHeaderRepetition; + OMX_U32 nGOBHeaderInterval; +} OMX_VIDEO_PARAM_H263TYPE; + + +/** + * MPEG-2 profile types, each profile indicates support for various + * performance bounds and different annexes. + */ +typedef enum OMX_VIDEO_MPEG2PROFILETYPE { + OMX_VIDEO_MPEG2ProfileSimple = 0, /**< Simple Profile */ + OMX_VIDEO_MPEG2ProfileMain, /**< Main Profile */ + OMX_VIDEO_MPEG2Profile422, /**< 4:2:2 Profile */ + OMX_VIDEO_MPEG2ProfileSNR, /**< SNR Profile */ + OMX_VIDEO_MPEG2ProfileSpatial, /**< Spatial Profile */ + OMX_VIDEO_MPEG2ProfileHigh, /**< High Profile */ + OMX_VIDEO_MPEG2ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_MPEG2ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_MPEG2ProfileMax = 0x7FFFFFFF +} OMX_VIDEO_MPEG2PROFILETYPE; + + +/** + * MPEG-2 level types, each level indicates support for various frame + * sizes, bit rates, decoder frame rates. No need + */ +typedef enum OMX_VIDEO_MPEG2LEVELTYPE { + OMX_VIDEO_MPEG2LevelLL = 0, /**< Low Level */ + OMX_VIDEO_MPEG2LevelML, /**< Main Level */ + OMX_VIDEO_MPEG2LevelH14, /**< High 1440 */ + OMX_VIDEO_MPEG2LevelHL, /**< High Level */ + OMX_VIDEO_MPEG2LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_MPEG2LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_MPEG2LevelMax = 0x7FFFFFFF +} OMX_VIDEO_MPEG2LEVELTYPE; + + +/** + * MPEG-2 params + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nPFrames : Number of P frames between each I frame + * nBFrames : Number of B frames between each I frame + * eProfile : MPEG-2 profile(s) to use + * eLevel : MPEG-2 levels(s) to use + */ +typedef struct OMX_VIDEO_PARAM_MPEG2TYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nPFrames; + OMX_U32 nBFrames; + OMX_VIDEO_MPEG2PROFILETYPE eProfile; + OMX_VIDEO_MPEG2LEVELTYPE eLevel; +} OMX_VIDEO_PARAM_MPEG2TYPE; + + +/** + * MPEG-4 profile types, each profile indicates support for various + * performance bounds and different annexes. + * + * ENUMS: + * - Simple Profile, Levels 1-3 + * - Simple Scalable Profile, Levels 1-2 + * - Core Profile, Levels 1-2 + * - Main Profile, Levels 2-4 + * - N-bit Profile, Level 2 + * - Scalable Texture Profile, Level 1 + * - Simple Face Animation Profile, Levels 1-2 + * - Simple Face and Body Animation (FBA) Profile, Levels 1-2 + * - Basic Animated Texture Profile, Levels 1-2 + * - Hybrid Profile, Levels 1-2 + * - Advanced Real Time Simple Profiles, Levels 1-4 + * - Core Scalable Profile, Levels 1-3 + * - Advanced Coding Efficiency Profile, Levels 1-4 + * - Advanced Core Profile, Levels 1-2 + * - Advanced Scalable Texture, Levels 2-3 + */ +typedef enum OMX_VIDEO_MPEG4PROFILETYPE { + OMX_VIDEO_MPEG4ProfileSimple = 0x01, + OMX_VIDEO_MPEG4ProfileSimpleScalable = 0x02, + OMX_VIDEO_MPEG4ProfileCore = 0x04, + OMX_VIDEO_MPEG4ProfileMain = 0x08, + OMX_VIDEO_MPEG4ProfileNbit = 0x10, + OMX_VIDEO_MPEG4ProfileScalableTexture = 0x20, + OMX_VIDEO_MPEG4ProfileSimpleFace = 0x40, + OMX_VIDEO_MPEG4ProfileSimpleFBA = 0x80, + OMX_VIDEO_MPEG4ProfileBasicAnimated = 0x100, + OMX_VIDEO_MPEG4ProfileHybrid = 0x200, + OMX_VIDEO_MPEG4ProfileAdvancedRealTime = 0x400, + OMX_VIDEO_MPEG4ProfileCoreScalable = 0x800, + OMX_VIDEO_MPEG4ProfileAdvancedCoding = 0x1000, + OMX_VIDEO_MPEG4ProfileAdvancedCore = 0x2000, + OMX_VIDEO_MPEG4ProfileAdvancedScalable = 0x4000, + OMX_VIDEO_MPEG4ProfileAdvancedSimple = 0x8000, + OMX_VIDEO_MPEG4ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_MPEG4ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_MPEG4ProfileMax = 0x7FFFFFFF +} OMX_VIDEO_MPEG4PROFILETYPE; + + +/** + * MPEG-4 level types, each level indicates support for various frame + * sizes, bit rates, decoder frame rates. No need + */ +typedef enum OMX_VIDEO_MPEG4LEVELTYPE { + OMX_VIDEO_MPEG4Level0 = 0x01, /**< Level 0 */ + OMX_VIDEO_MPEG4Level0b = 0x02, /**< Level 0b */ + OMX_VIDEO_MPEG4Level1 = 0x04, /**< Level 1 */ + OMX_VIDEO_MPEG4Level2 = 0x08, /**< Level 2 */ + OMX_VIDEO_MPEG4Level3 = 0x10, /**< Level 3 */ + OMX_VIDEO_MPEG4Level4 = 0x20, /**< Level 4 */ + OMX_VIDEO_MPEG4Level4a = 0x40, /**< Level 4a */ + OMX_VIDEO_MPEG4Level5 = 0x80, /**< Level 5 */ + OMX_VIDEO_MPEG4LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_MPEG4LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_MPEG4LevelMax = 0x7FFFFFFF +} OMX_VIDEO_MPEG4LEVELTYPE; + + +/** + * MPEG-4 configuration. This structure handles configuration options + * which are specific to MPEG4 algorithms + * + * 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 (H263+ + * Annex K). Put zero if not used + * bSVH : Enable Short Video Header mode + * bGov : Flag to enable GOV + * nPFrames : Number of P frames between each I frame (also called + * GOV period) + * nBFrames : Number of B frames between each I frame + * nIDCVLCThreshold : Value of intra DC VLC threshold + * bACPred : Flag to use ac prediction + * nMaxPacketSize : Maximum size of packet in bytes. + * nTimeIncRes : Used to pass VOP time increment resolution for MPEG4. + * Interpreted as described in MPEG4 standard. + * eProfile : MPEG-4 profile(s) to use. + * eLevel : MPEG-4 level(s) to use. + * nAllowedPictureTypes : Specifies the picture types allowed in the bitstream + * nHeaderExtension : Specifies the number of consecutive video packet + * headers within a VOP + * bReversibleVLC : Specifies whether reversible variable length coding + * is in use + */ +typedef struct OMX_VIDEO_PARAM_MPEG4TYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nSliceHeaderSpacing; + OMX_BOOL bSVH; + OMX_BOOL bGov; + OMX_U32 nPFrames; + OMX_U32 nBFrames; + OMX_U32 nIDCVLCThreshold; + OMX_BOOL bACPred; + OMX_U32 nMaxPacketSize; + OMX_U32 nTimeIncRes; + OMX_VIDEO_MPEG4PROFILETYPE eProfile; + OMX_VIDEO_MPEG4LEVELTYPE eLevel; + OMX_U32 nAllowedPictureTypes; + OMX_U32 nHeaderExtension; + OMX_BOOL bReversibleVLC; +} OMX_VIDEO_PARAM_MPEG4TYPE; + + +/** + * WMV Versions + */ +typedef enum OMX_VIDEO_WMVFORMATTYPE { + OMX_VIDEO_WMVFormatUnused = 0x01, /**< Format unused or unknown */ + OMX_VIDEO_WMVFormat7 = 0x02, /**< Windows Media Video format 7 */ + OMX_VIDEO_WMVFormat8 = 0x04, /**< Windows Media Video format 8 */ + OMX_VIDEO_WMVFormat9 = 0x08, /**< Windows Media Video format 9 */ + OMX_VIDEO_WMFFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_WMFFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_WMVFormatMax = 0x7FFFFFFF +} OMX_VIDEO_WMVFORMATTYPE; + + +/** + * WMV Params + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eFormat : Version of WMV stream / data + */ +typedef struct OMX_VIDEO_PARAM_WMVTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_VIDEO_WMVFORMATTYPE eFormat; +} OMX_VIDEO_PARAM_WMVTYPE; + + +/** + * Real Video Version + */ +typedef enum OMX_VIDEO_RVFORMATTYPE { + OMX_VIDEO_RVFormatUnused = 0, /**< Format unused or unknown */ + OMX_VIDEO_RVFormat8, /**< Real Video format 8 */ + OMX_VIDEO_RVFormat9, /**< Real Video format 9 */ + OMX_VIDEO_RVFormatG2, /**< Real Video Format G2 */ + OMX_VIDEO_RVFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_RVFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_RVFormatMax = 0x7FFFFFFF +} OMX_VIDEO_RVFORMATTYPE; + + +/** + * Real Video Params + * + * STUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * eFormat : Version of RV stream / data + * nBitsPerPixel : Bits per pixel coded in the frame + * nPaddedWidth : Padded width in pixel of a video frame + * nPaddedHeight : Padded Height in pixels of a video frame + * nFrameRate : Rate of video in frames per second + * nBitstreamFlags : Flags which internal information about the bitstream + * nBitstreamVersion : Bitstream version + * nMaxEncodeFrameSize: Max encoded frame size + * bEnablePostFilter : Turn on/off post filter + * bEnableTemporalInterpolation : Turn on/off temporal interpolation + * bEnableLatencyMode : When enabled, the decoder does not display a decoded + * frame until it has detected that no enhancement layer + * frames or dependent B frames will be coming. This + * detection usually occurs when a subsequent non-B + * frame is encountered + */ +typedef struct OMX_VIDEO_PARAM_RVTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_VIDEO_RVFORMATTYPE eFormat; + OMX_U16 nBitsPerPixel; + OMX_U16 nPaddedWidth; + OMX_U16 nPaddedHeight; + OMX_U32 nFrameRate; + OMX_U32 nBitstreamFlags; + OMX_U32 nBitstreamVersion; + OMX_U32 nMaxEncodeFrameSize; + OMX_BOOL bEnablePostFilter; + OMX_BOOL bEnableTemporalInterpolation; + OMX_BOOL bEnableLatencyMode; +} OMX_VIDEO_PARAM_RVTYPE; + + +/** + * AVC profile types, each profile indicates support for various + * performance bounds and different annexes. + */ +typedef enum OMX_VIDEO_AVCPROFILETYPE { + OMX_VIDEO_AVCProfileBaseline = 0x01, /**< Baseline profile */ + OMX_VIDEO_AVCProfileMain = 0x02, /**< Main profile */ + OMX_VIDEO_AVCProfileExtended = 0x04, /**< Extended profile */ + OMX_VIDEO_AVCProfileHigh = 0x08, /**< High profile */ + OMX_VIDEO_AVCProfileHigh10 = 0x10, /**< High 10 profile */ + OMX_VIDEO_AVCProfileHigh422 = 0x20, /**< High 4:2:2 profile */ + OMX_VIDEO_AVCProfileHigh444 = 0x40, /**< High 4:4:4 profile */ + OMX_VIDEO_AVCProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_AVCProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_AVCProfileMax = 0x7FFFFFFF +} OMX_VIDEO_AVCPROFILETYPE; + + +/** + * AVC level types, each level indicates support for various frame sizes, + * bit rates, decoder frame rates. No need + */ +typedef enum OMX_VIDEO_AVCLEVELTYPE { + OMX_VIDEO_AVCLevel1 = 0x01, /**< Level 1 */ + OMX_VIDEO_AVCLevel1b = 0x02, /**< Level 1b */ + OMX_VIDEO_AVCLevel11 = 0x04, /**< Level 1.1 */ + OMX_VIDEO_AVCLevel12 = 0x08, /**< Level 1.2 */ + OMX_VIDEO_AVCLevel13 = 0x10, /**< Level 1.3 */ + OMX_VIDEO_AVCLevel2 = 0x20, /**< Level 2 */ + OMX_VIDEO_AVCLevel21 = 0x40, /**< Level 2.1 */ + OMX_VIDEO_AVCLevel22 = 0x80, /**< Level 2.2 */ + OMX_VIDEO_AVCLevel3 = 0x100, /**< Level 3 */ + OMX_VIDEO_AVCLevel31 = 0x200, /**< Level 3.1 */ + OMX_VIDEO_AVCLevel32 = 0x400, /**< Level 3.2 */ + OMX_VIDEO_AVCLevel4 = 0x800, /**< Level 4 */ + OMX_VIDEO_AVCLevel41 = 0x1000, /**< Level 4.1 */ + OMX_VIDEO_AVCLevel42 = 0x2000, /**< Level 4.2 */ + OMX_VIDEO_AVCLevel5 = 0x4000, /**< Level 5 */ + OMX_VIDEO_AVCLevel51 = 0x8000, /**< Level 5.1 */ + OMX_VIDEO_AVCLevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_AVCLevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_AVCLevelMax = 0x7FFFFFFF +} OMX_VIDEO_AVCLEVELTYPE; + + +/** + * AVC loop filter modes + * + * OMX_VIDEO_AVCLoopFilterEnable : Enable + * OMX_VIDEO_AVCLoopFilterDisable : Disable + * OMX_VIDEO_AVCLoopFilterDisableSliceBoundary : Disabled on slice boundaries + */ +typedef enum OMX_VIDEO_AVCLOOPFILTERTYPE { + OMX_VIDEO_AVCLoopFilterEnable = 0, + OMX_VIDEO_AVCLoopFilterDisable, + OMX_VIDEO_AVCLoopFilterDisableSliceBoundary, + OMX_VIDEO_AVCLoopFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_AVCLoopFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_AVCLoopFilterMax = 0x7FFFFFFF +} OMX_VIDEO_AVCLOOPFILTERTYPE; + + +/** + * AVC 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_VIDEO_PARAM_AVCTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nSliceHeaderSpacing; + OMX_U32 nPFrames; + OMX_U32 nBFrames; + OMX_BOOL bUseHadamard; + OMX_U32 nRefFrames; + OMX_U32 nRefIdx10ActiveMinus1; + OMX_U32 nRefIdx11ActiveMinus1; + OMX_BOOL bEnableUEP; + OMX_BOOL bEnableFMO; + OMX_BOOL bEnableASO; + OMX_BOOL bEnableRS; + OMX_VIDEO_AVCPROFILETYPE eProfile; + OMX_VIDEO_AVCLEVELTYPE eLevel; + 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_AVCLOOPFILTERTYPE eLoopFilterMode; +} OMX_VIDEO_PARAM_AVCTYPE; + +typedef struct OMX_VIDEO_PARAM_PROFILELEVELTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 eProfile; /**< type is OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263PROFILETYPE, + or OMX_VIDEO_MPEG4PROFILETYPE depending on context */ + OMX_U32 eLevel; /**< type is OMX_VIDEO_AVCLEVELTYPE, OMX_VIDEO_H263LEVELTYPE, + or OMX_VIDEO_MPEG4PROFILETYPE depending on context */ + OMX_U32 nProfileIndex; /**< Used to query for individual profile support information, + This parameter is valid only for + OMX_IndexParamVideoProfileLevelQuerySupported index, + For all other indices this parameter is to be ignored. */ +} OMX_VIDEO_PARAM_PROFILELEVELTYPE; + +/** + * Structure for dynamically configuring bitrate mode of a codec. + * + * STRUCT MEMBERS: + * nSize : Size of the struct in bytes + * nVersion : OMX spec version info + * nPortIndex : Port that this struct applies to + * nEncodeBitrate : Target average bitrate to be generated in bps + */ +typedef struct OMX_VIDEO_CONFIG_BITRATETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nEncodeBitrate; +} OMX_VIDEO_CONFIG_BITRATETYPE; + +/** + * Defines Encoder Frame Rate setting + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * xEncodeFramerate : Encoding framerate represented in Q16 format + */ +typedef struct OMX_CONFIG_FRAMERATETYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 xEncodeFramerate; /* Q16 format */ +} OMX_CONFIG_FRAMERATETYPE; + +typedef struct OMX_CONFIG_INTRAREFRESHVOPTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_BOOL IntraRefreshVOP; +} OMX_CONFIG_INTRAREFRESHVOPTYPE; + +typedef struct OMX_CONFIG_MACROBLOCKERRORMAPTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nErrMapSize; /* Size of the Error Map in bytes */ + OMX_U8 ErrMap[1]; /* Error map hint */ +} OMX_CONFIG_MACROBLOCKERRORMAPTYPE; + +typedef struct OMX_CONFIG_MBERRORREPORTINGTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_BOOL bEnabled; +} OMX_CONFIG_MBERRORREPORTINGTYPE; + +typedef struct OMX_PARAM_MACROBLOCKSTYPE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nMacroblocks; +} OMX_PARAM_MACROBLOCKSTYPE; + +/** + * AVC Slice Mode modes + * + * OMX_VIDEO_SLICEMODE_AVCDefault : Normal frame encoding, one slice per frame + * OMX_VIDEO_SLICEMODE_AVCMBSlice : NAL mode, number of MBs per frame + * OMX_VIDEO_SLICEMODE_AVCByteSlice : NAL mode, number of bytes per frame + */ +typedef enum OMX_VIDEO_AVCSLICEMODETYPE { + OMX_VIDEO_SLICEMODE_AVCDefault = 0, + OMX_VIDEO_SLICEMODE_AVCMBSlice, + OMX_VIDEO_SLICEMODE_AVCByteSlice, + OMX_VIDEO_SLICEMODE_AVCKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ + OMX_VIDEO_SLICEMODE_AVCVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ + OMX_VIDEO_SLICEMODE_AVCLevelMax = 0x7FFFFFFF +} OMX_VIDEO_AVCSLICEMODETYPE; + +/** + * AVC FMO Slice Mode Params + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nNumSliceGroups : Specifies the number of slice groups + * nSliceGroupMapType : Specifies the type of slice groups + * eSliceMode : Specifies the type of slice + */ +typedef struct OMX_VIDEO_PARAM_AVCSLICEFMO { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U8 nNumSliceGroups; + OMX_U8 nSliceGroupMapType; + OMX_VIDEO_AVCSLICEMODETYPE eSliceMode; +} OMX_VIDEO_PARAM_AVCSLICEFMO; + +/** + * AVC IDR Period Configs + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nIDRPeriod : Specifies periodicity of IDR frames + * nPFrames : Specifies internal of coding Intra frames + */ +typedef struct OMX_VIDEO_CONFIG_AVCINTRAPERIOD { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nIDRPeriod; + OMX_U32 nPFrames; +} OMX_VIDEO_CONFIG_AVCINTRAPERIOD; + +/** + * AVC NAL Size Configs + * + * STRUCT MEMBERS: + * nSize : Size of the structure in bytes + * nVersion : OMX specification version information + * nPortIndex : Port that this structure applies to + * nNaluBytes : Specifies the NAL unit size + */ +typedef struct OMX_VIDEO_CONFIG_NALSIZE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_U32 nNaluBytes; +} OMX_VIDEO_CONFIG_NALSIZE; + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif +/* File EOF */ + diff --git a/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h b/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h new file mode 100644 index 0000000..10dd94d --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h @@ -0,0 +1,138 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Def.h + * @brief SEC_OMX specific define + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_DEF +#define SEC_OMX_DEF + +#include "OMX_Types.h" +#include "OMX_IVCommon.h" + +#define VERSIONMAJOR_NUMBER 1 +#define VERSIONMINOR_NUMBER 0 +#define REVISION_NUMBER 0 +#define STEP_NUMBER 0 + + +#define MAX_OMX_COMPONENT_NUM 20 +#define MAX_OMX_COMPONENT_ROLE_NUM 10 +#define MAX_OMX_COMPONENT_NAME_SIZE OMX_MAX_STRINGNAME_SIZE +#define MAX_OMX_COMPONENT_ROLE_SIZE OMX_MAX_STRINGNAME_SIZE +#define MAX_OMX_COMPONENT_LIBNAME_SIZE OMX_MAX_STRINGNAME_SIZE * 2 +#define MAX_OMX_MIMETYPE_SIZE OMX_MAX_STRINGNAME_SIZE + +#define MAX_TIMESTAMP 16 +#define MAX_FLAGS 16 + + +typedef enum _SEC_CODEC_TYPE +{ + SW_CODEC, + HW_VIDEO_CODEC, + HW_AUDIO_CODEC +} SEC_CODEC_TYPE; + +typedef struct _SEC_OMX_PRIORITYMGMTTYPE +{ + OMX_U32 nGroupPriority; /* the value 0 represents the highest priority */ + /* for a group of components */ + OMX_U32 nGroupID; +} SEC_OMX_PRIORITYMGMTTYPE; + +typedef enum _SEC_OMX_INDEXTYPE +{ + OMX_IndexVendorThumbnailMode = 0x7F000001, + OMX_COMPONENT_CAPABILITY_TYPE_INDEX = 0xFF7A347 /*for Android*/ +} SEC_OMX_INDEXTYPE; + +typedef enum _SEC_OMX_ERRORTYPE +{ + OMX_ErrorNoEOF = 0x90000001, + OMX_ErrorInputDataDecodeYet, + OMX_ErrorInputDataEncodeYet, + OMX_ErrorMFCInit +} SEC_OMX_ERRORTYPE; + +typedef enum _SEC_OMX_COMMANDTYPE +{ + SEC_OMX_CommandComponentDeInit = 0x7F000001, + SEC_OMX_CommandEmptyBuffer, + SEC_OMX_CommandFillBuffer +} SEC_OMX_COMMANDTYPE; + +typedef enum _SEC_OMX_TRANS_STATETYPE { + SEC_OMX_TransStateInvalid, + SEC_OMX_TransStateLoadedToIdle, + SEC_OMX_TransStateIdleToExecuting, + SEC_OMX_TransStateExecutingToIdle, + SEC_OMX_TransStateIdleToLoaded, + SEC_OMX_TransStateMax = 0X7FFFFFFF +} SEC_OMX_TRANS_STATETYPE; + +typedef enum _SEC_OMX_COLOR_FORMATTYPE { +#ifndef USE_SAMSUNG_COLORFORMAT + SEC_OMX_COLOR_FormatNV12PhysicalAddress = OMX_COLOR_FormatYUV420SemiPlanar +#else + SEC_OMX_COLOR_FormatNV12PhysicalAddress = 0x7F000001 /**< Reserved region for introducing Vendor Extensions */ +#endif +}SEC_OMX_COLOR_FORMATTYPE; + +typedef enum _SEC_OMX_SUPPORTFORMAT_TYPE +{ + supportFormat_1 = 0x00, + supportFormat_2, + supportFormat_3, + supportFormat_4 +} SEC_OMX_SUPPORTFORMAT_TYPE; + + +/* for Android */ +typedef struct _OMXComponentCapabilityFlagsType +{ + /* OMX COMPONENT CAPABILITY RELATED MEMBERS */ + OMX_BOOL iIsOMXComponentMultiThreaded; + OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc; + OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc; + OMX_BOOL iOMXComponentSupportsMovableInputBuffers; + OMX_BOOL iOMXComponentSupportsPartialFrames; + OMX_BOOL iOMXComponentUsesNALStartCodes; + OMX_BOOL iOMXComponentCanHandleIncompleteFrames; + OMX_BOOL iOMXComponentUsesFullAVCFrames; +} OMXComponentCapabilityFlagsType; + +typedef struct _SEC_OMX_VIDEO_PROFILELEVEL +{ + OMX_S32 profile; + OMX_S32 level; +} SEC_OMX_VIDEO_PROFILELEVEL; + + +#ifndef __OMX_EXPORTS +#define __OMX_EXPORTS +#define SEC_EXPORT_REF __attribute__((visibility("default"))) +#define SEC_IMPORT_REF __attribute__((visibility("default"))) +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h b/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h new file mode 100644 index 0000000..b3bfda6 --- /dev/null +++ b/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h @@ -0,0 +1,64 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OMX_Macros.h + * @brief Macros + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OMX_MACROS +#define SEC_OMX_MACROS + +#include "SEC_OMX_Def.h" +#include "SEC_OSAL_Memory.h" + + +/* + * MACROS + */ +#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5) +#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7) +#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13) + +#define INIT_SET_SIZE_VERSION(_struct_, _structType_) \ + do { \ + SEC_OSAL_Memset((_struct_), 0, sizeof(_structType_)); \ + (_struct_)->nSize = sizeof(_structType_); \ + (_struct_)->nVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; \ + (_struct_)->nVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; \ + (_struct_)->nVersion.s.nRevision = REVISION_NUMBER; \ + (_struct_)->nVersion.s.nStep = STEP_NUMBER; \ + } while (0) + +/* + * Port Specific + */ +#define SEC_TUNNEL_ESTABLISHED 0x0001 +#define SEC_TUNNEL_IS_SUPPLIER 0x0002 + +#define CHECK_PORT_BEING_FLUSHED(port) (port->bIsPortFlushed == OMX_TRUE) +#define CHECK_PORT_BEING_DISABLED(port) (port->bIsPortDisabled == OMX_TRUE) +#define CHECK_PORT_ENABLED(port) (port->portDefinition.bEnabled == OMX_TRUE) +#define CHECK_PORT_POPULATED(port) (port->portDefinition.bPopulated == OMX_TRUE) +#define CHECK_PORT_TUNNELED(port) (port->tunnelFlags & SEC_TUNNEL_ESTABLISHED) +#define CHECK_PORT_BUFFER_SUPPLIER(port) (port->tunnelFlags & SEC_TUNNEL_IS_SUPPLIER) + +#endif diff --git a/sec_mm/sec_omx/sec_osal/Android.mk b/sec_mm/sec_omx/sec_osal/Android.mk new file mode 100644 index 0000000..b474876 --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/Android.mk @@ -0,0 +1,29 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_SRC_FILES := \ + SEC_OSAL_Event.c \ + SEC_OSAL_Queue.c \ + SEC_OSAL_ETC.c \ + SEC_OSAL_Mutex.c \ + SEC_OSAL_Thread.c \ + SEC_OSAL_Memory.c \ + SEC_OSAL_Semaphore.c \ + SEC_OSAL_Library.c \ + SEC_OSAL_Log.c + +LOCAL_PRELINK_MODULE := false +LOCAL_MODULE := libsecosal.aries + +LOCAL_CFLAGS := + +LOCAL_STATIC_LIBRARIES := +LOCAL_SHARED_LIBRARIES := libcutils libutils + +LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \ + $(SEC_OMX_INC)/sec \ + $(SEC_OMX_TOP)/sec_osal + +include $(BUILD_STATIC_LIBRARY) diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.c b/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.c new file mode 100644 index 0000000..66f8355 --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.c @@ -0,0 +1,144 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_ETC.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include + +#include "SEC_OSAL_Memory.h" +#include "SEC_OSAL_ETC.h" + + +#ifndef HAVE_GETLINE +ssize_t getline(char **ppLine, size_t *pLen, FILE *pStream) +{ + char *pCurrentPointer = NULL; + size_t const chunk = 512; + + size_t defaultBufferSize = chunk + 1; + size_t retSize = 0; + + if (*ppLine == NULL) { + *ppLine = (char *)malloc(defaultBufferSize); + if (*ppLine == NULL) { + retSize = -1; + goto EXIT; + } + *pLen = defaultBufferSize; + } + else { + if (*pLen < defaultBufferSize) { + *ppLine = (char *)realloc(*ppLine, defaultBufferSize); + if (*ppLine == NULL) { + retSize = -1; + goto EXIT; + } + *pLen = defaultBufferSize; + } + } + + while (1) { + size_t i; + size_t j = 0; + size_t readByte = 0; + + pCurrentPointer = *ppLine + readByte; + + i = fread(pCurrentPointer, 1, chunk, pStream); + if (i < chunk && ferror(pStream)) { + retSize = -1; + goto EXIT; + } + while (j < i) { + ++j; + if (*pCurrentPointer++ == (char)'\n') { + *pCurrentPointer = '\0'; + if (j != i) { + if (fseek(pStream, j - i, SEEK_CUR)) { + retSize = -1; + goto EXIT; + } + if (feof(pStream)) + clearerr(pStream); + } + readByte += j; + retSize = readByte; + goto EXIT; + } + } + + readByte += j; + if (feof(pStream)) { + if (readByte) { + retSize = readByte; + goto EXIT; + } + if (!i) { + retSize = -1; + goto EXIT; + } + } + + i = ((readByte + (chunk * 2)) / chunk) * chunk; + if (i != *pLen) { + *ppLine = (char *)realloc(*ppLine, i); + if (*ppLine == NULL) { + retSize = -1; + goto EXIT; + } + *pLen = i; + } + } + +EXIT: + return retSize; +} +#endif /* HAVE_GETLINE */ + +OMX_PTR SEC_OSAL_Strcpy(OMX_PTR dest, OMX_PTR src) +{ + return strcpy(dest, src); +} + +OMX_PTR SEC_OSAL_Strncpy(OMX_PTR dest, OMX_PTR src, size_t num) +{ + return strncpy(dest, src, num); +} + +OMX_S32 SEC_OSAL_Strcmp(OMX_PTR str1, OMX_PTR str2) +{ + return strcmp(str1, str2); +} + +OMX_PTR SEC_OSAL_Strcat(OMX_PTR dest, OMX_PTR src) +{ + return strcat(dest, src); +} + +size_t SEC_OSAL_Strlen(const char *str) +{ + return strlen(str); +} diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.h new file mode 100644 index 0000000..6c6ede7 --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_ETC.h @@ -0,0 +1,48 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_ETC.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OSAL_ETC +#define SEC_OSAL_ETC + +#include "OMX_Types.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +OMX_PTR SEC_OSAL_Strcpy(OMX_PTR dest, OMX_PTR src); +OMX_PTR SEC_OSAL_Strncpy(OMX_PTR dest, OMX_PTR src, size_t num); +OMX_S32 SEC_OSAL_Strcmp(OMX_PTR str1, OMX_PTR str2); +OMX_PTR SEC_OSAL_Strcat(OMX_PTR dest, OMX_PTR src); +size_t SEC_OSAL_Strlen(const char *str); +ssize_t getline(char **ppLine, size_t *len, FILE *stream); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.c b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.c new file mode 100644 index 0000000..51b3ca2 --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.c @@ -0,0 +1,217 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Event.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + + +#include +#include +#include +#include +#include + +#include "SEC_OSAL_Memory.h" +#include "SEC_OSAL_Mutex.h" +#include "SEC_OSAL_Event.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_OSAL_EVENT" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +OMX_ERRORTYPE SEC_OSAL_SignalCreate(OMX_HANDLETYPE *eventHandle) +{ + SEC_OSAL_THREADEVENT *event; + OMX_ERRORTYPE ret = OMX_ErrorNone; + + event = (SEC_OSAL_THREADEVENT *)SEC_OSAL_Malloc(sizeof(SEC_OSAL_THREADEVENT)); + if (!event) { + ret = OMX_ErrorInsufficientResources; + goto EXIT; + } + + SEC_OSAL_Memset(event, 0, sizeof(SEC_OSAL_THREADEVENT)); + event->signal = OMX_FALSE; + + ret = SEC_OSAL_MutexCreate(&event->mutex); + if (ret != OMX_ErrorNone) { + SEC_OSAL_Free(event); + goto EXIT; + } + + if (pthread_cond_init(&event->condition, NULL)) { + SEC_OSAL_MutexTerminate(event->mutex); + SEC_OSAL_Free(event); + ret = OMX_ErrorUndefined; + goto EXIT; + } + + *eventHandle = (OMX_HANDLETYPE)event; + ret = OMX_ErrorNone; + +EXIT: + return ret; +} + +OMX_ERRORTYPE SEC_OSAL_SignalTerminate(OMX_HANDLETYPE eventHandle) +{ + SEC_OSAL_THREADEVENT *event = (SEC_OSAL_THREADEVENT *)eventHandle; + OMX_ERRORTYPE ret = OMX_ErrorNone; + + if (!event) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + ret = SEC_OSAL_MutexLock(event->mutex); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + if (pthread_cond_destroy(&event->condition)) { + ret = OMX_ErrorUndefined; + goto EXIT; + } + + ret = SEC_OSAL_MutexUnlock(event->mutex); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorUndefined; + goto EXIT; + } + + ret = SEC_OSAL_MutexTerminate(event->mutex); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorUndefined; + goto EXIT; + } + + SEC_OSAL_Free(event); + +EXIT: + return ret; +} + +OMX_ERRORTYPE SEC_OSAL_SignalReset(OMX_HANDLETYPE eventHandle) +{ + SEC_OSAL_THREADEVENT *event = (SEC_OSAL_THREADEVENT *)eventHandle; + OMX_ERRORTYPE ret = OMX_ErrorNone; + + if (!event) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + ret = SEC_OSAL_MutexLock(event->mutex); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + event->signal = OMX_FALSE; + + SEC_OSAL_MutexUnlock(event->mutex); + +EXIT: + return ret; +} + +OMX_ERRORTYPE SEC_OSAL_SignalSet(OMX_HANDLETYPE eventHandle) +{ + SEC_OSAL_THREADEVENT *event = (SEC_OSAL_THREADEVENT *)eventHandle; + OMX_ERRORTYPE ret = OMX_ErrorNone; + + if (!event) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + ret = SEC_OSAL_MutexLock(event->mutex); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + event->signal = OMX_TRUE; + pthread_cond_signal(&event->condition); + + SEC_OSAL_MutexUnlock(event->mutex); + +EXIT: + return ret; +} + +OMX_ERRORTYPE SEC_OSAL_SignalWait(OMX_HANDLETYPE eventHandle, OMX_U32 ms) +{ + SEC_OSAL_THREADEVENT *event = (SEC_OSAL_THREADEVENT *)eventHandle; + OMX_ERRORTYPE ret = OMX_ErrorNone; + struct timespec timeout; + struct timeval now; + int funcret = 0; + OMX_U32 tv_us; + + FunctionIn(); + + if (!event) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + gettimeofday(&now, NULL); + + tv_us = now.tv_usec + ms * 1000; + timeout.tv_sec = now.tv_sec + tv_us / 1000000; + timeout.tv_nsec = (tv_us % 1000000) * 1000; + + ret = SEC_OSAL_MutexLock(event->mutex); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + if (ms == 0) { + if (!event->signal) + ret = OMX_ErrorTimeout; + } else if (ms == DEF_MAX_WAIT_TIME) { + while (!event->signal) + pthread_cond_wait(&event->condition, (pthread_mutex_t *)(event->mutex)); + ret = OMX_ErrorNone; + } else { + while (!event->signal) { + funcret = pthread_cond_timedwait(&event->condition, (pthread_mutex_t *)(event->mutex), &timeout); + if ((!event->signal) && (funcret == ETIMEDOUT)) { + ret = OMX_ErrorTimeout; + break; + } + } + } + + SEC_OSAL_MutexUnlock(event->mutex); + +EXIT: + FunctionOut(); + + return ret; +} diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.h new file mode 100644 index 0000000..640d2cc --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Event.h @@ -0,0 +1,61 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Event.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OSAL_EVENT +#define SEC_OSAL_EVENT + +#include +#include "OMX_Types.h" +#include "OMX_Core.h" + + +#define DEF_MAX_WAIT_TIME 0xFFFFFFFF + +typedef struct _SEC_OSAL_THREADEVENT +{ + OMX_BOOL signal; + OMX_HANDLETYPE mutex; + pthread_cond_t condition; +} SEC_OSAL_THREADEVENT; + + +#ifdef __cplusplus +extern "C" { +#endif + + +OMX_ERRORTYPE SEC_OSAL_SignalCreate(OMX_HANDLETYPE *eventHandle); +OMX_ERRORTYPE SEC_OSAL_SignalTerminate(OMX_HANDLETYPE eventHandle); +OMX_ERRORTYPE SEC_OSAL_SignalReset(OMX_HANDLETYPE eventHandle); +OMX_ERRORTYPE SEC_OSAL_SignalSet(OMX_HANDLETYPE eventHandle); +OMX_ERRORTYPE SEC_OSAL_SignalWait(OMX_HANDLETYPE eventHandle, OMX_U32 ms); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.c b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.c new file mode 100644 index 0000000..06ac712 --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.c @@ -0,0 +1,54 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Library.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + + +#include +#include +#include +#include + +#include "SEC_OSAL_Library.h" + + +void *SEC_OSAL_dlopen(const char *filename, int flag) +{ + return dlopen(filename, flag); +} + +void *SEC_OSAL_dlsym(void *handle, const char *symbol) +{ + return dlsym(handle, symbol); +} + +int SEC_OSAL_dlclose(void *handle) +{ + return dlclose(handle); +} + +const char *SEC_OSAL_dlerror(void) +{ + return dlerror(); +} diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.h new file mode 100644 index 0000000..687cecd --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Library.h @@ -0,0 +1,46 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Library.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OSAL_LIBRARY +#define SEC_OSAL_LIBRARY + +#include "OMX_Types.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +void *SEC_OSAL_dlopen(const char *filename, int flag); +void *SEC_OSAL_dlsym(void *handle, const char *symbol); +int SEC_OSAL_dlclose(void *handle); +const char *SEC_OSAL_dlerror(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.c b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.c new file mode 100644 index 0000000..bae4974 --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.c @@ -0,0 +1,53 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Log.c + * @brief + * @author Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include + +#include "SEC_OSAL_Log.h" + + +void _SEC_OSAL_Log(SEC_LOG_LEVEL logLevel, const char *tag, const char *msg, ...) +{ + va_list argptr; + + va_start(argptr, msg); + + switch (logLevel) { + case SEC_LOG_TRACE: + __android_log_vprint(ANDROID_LOG_DEBUG, tag, msg, argptr); + break; + case SEC_LOG_WARNING: + __android_log_vprint(ANDROID_LOG_WARN, tag, msg, argptr); + break; + case SEC_LOG_ERROR: + __android_log_vprint(ANDROID_LOG_ERROR, tag, msg, argptr); + break; + default: + __android_log_vprint(ANDROID_LOG_VERBOSE, tag, msg, argptr); + } + + va_end(argptr); +} diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.h new file mode 100644 index 0000000..2f8a6ce --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Log.h @@ -0,0 +1,78 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Log.h + * @brief + * @author Yunji Kim (yunji.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + * 2010.8.27 : Add trace function + */ + +#ifndef SEC_OSAL_LOG +#define SEC_OSAL_LOG + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef SEC_LOG_OFF +#define SEC_LOG +#endif + +#ifndef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_LOG" +#endif + +#ifdef SEC_TRACE_ON +#define SEC_TRACE +#endif + +typedef enum _LOG_LEVEL +{ + SEC_LOG_TRACE, + SEC_LOG_WARNING, + SEC_LOG_ERROR +} SEC_LOG_LEVEL; + +#ifdef SEC_LOG +#define SEC_OSAL_Log(a, ...) ((void)_SEC_OSAL_Log(a, SEC_LOG_TAG, __VA_ARGS__)) +#else +#define SEC_OSAL_Log(a, ...) \ + do { \ + if (a == SEC_LOG_ERROR) \ + ((void)_SEC_OSAL_Log(a, SEC_LOG_TAG, __VA_ARGS__)); \ + } while (0) +#endif + +#ifdef SEC_TRACE +#define FunctionIn() _SEC_OSAL_Log(SEC_LOG_TRACE, SEC_LOG_TAG, "%s In , Line: %d", __FUNCTION__, __LINE__) +#define FunctionOut() _SEC_OSAL_Log(SEC_LOG_TRACE, SEC_LOG_TAG, "%s Out , Line: %d", __FUNCTION__, __LINE__) +#else +#define FunctionIn() ((void *)0) +#define FunctionOut() ((void *)0) +#endif + +extern void _SEC_OSAL_Log(SEC_LOG_LEVEL logLevel, const char *tag, const char *msg, ...); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.c b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.c new file mode 100644 index 0000000..3579d92 --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.c @@ -0,0 +1,71 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Memory.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include + +#include "SEC_OSAL_Memory.h" + +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +static int mem_cnt = 0; + +OMX_PTR SEC_OSAL_Malloc(OMX_U32 size) +{ + mem_cnt++; + SEC_OSAL_Log(SEC_LOG_TRACE, "alloc count: %d", mem_cnt); + + return (OMX_PTR)malloc(size); +} + +void SEC_OSAL_Free(OMX_PTR addr) +{ + mem_cnt--; + SEC_OSAL_Log(SEC_LOG_TRACE, "free count: %d", mem_cnt); + + if (addr) + free(addr); + + return; +} + +OMX_PTR SEC_OSAL_Memset(OMX_PTR dest, OMX_S32 c, OMX_S32 n) +{ + return memset(dest, c, n); +} + +OMX_PTR SEC_OSAL_Memcpy(OMX_PTR dest, OMX_PTR src, OMX_S32 n) +{ + return memcpy(dest, src, n); +} + +OMX_PTR SEC_OSAL_Memmove(OMX_PTR dest, OMX_PTR src, OMX_S32 n) +{ + return memmove(dest, src, n); +} diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.h new file mode 100644 index 0000000..3a12838 --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Memory.h @@ -0,0 +1,47 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Memory.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OSAL_MEMORY +#define SEC_OSAL_MEMORY + +#include "OMX_Types.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +OMX_PTR SEC_OSAL_Malloc(OMX_U32 size); +void SEC_OSAL_Free(OMX_PTR addr); +OMX_PTR SEC_OSAL_Memset(OMX_PTR dest, OMX_S32 c, OMX_S32 n); +OMX_PTR SEC_OSAL_Memcpy(OMX_PTR dest, OMX_PTR src, OMX_S32 n); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.c b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.c new file mode 100644 index 0000000..146809c --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.c @@ -0,0 +1,91 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Mutex.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include +#include + +#include "SEC_OSAL_Memory.h" +#include "SEC_OSAL_Mutex.h" + + +OMX_ERRORTYPE SEC_OSAL_MutexCreate(OMX_HANDLETYPE *mutexHandle) +{ + pthread_mutex_t *mutex; + + mutex = (pthread_mutex_t *)SEC_OSAL_Malloc(sizeof(pthread_mutex_t)); + if (!mutex) + return OMX_ErrorInsufficientResources; + + if (pthread_mutex_init(mutex, NULL) != 0) + return OMX_ErrorUndefined; + + *mutexHandle = (OMX_HANDLETYPE)mutex; + return OMX_ErrorNone; +} + +OMX_ERRORTYPE SEC_OSAL_MutexTerminate(OMX_HANDLETYPE mutexHandle) +{ + pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle; + + if (mutex == NULL) + return OMX_ErrorBadParameter; + + if (pthread_mutex_destroy(mutex) != 0) + return OMX_ErrorUndefined; + + SEC_OSAL_Free(mutex); + return OMX_ErrorNone; +} + +OMX_ERRORTYPE SEC_OSAL_MutexLock(OMX_HANDLETYPE mutexHandle) +{ + pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle; + int result; + + if (mutex == NULL) + return OMX_ErrorBadParameter; + + if (pthread_mutex_lock(mutex) != 0) + return OMX_ErrorUndefined; + + return OMX_ErrorNone; +} + +OMX_ERRORTYPE SEC_OSAL_MutexUnlock(OMX_HANDLETYPE mutexHandle) +{ + pthread_mutex_t *mutex = (pthread_mutex_t *)mutexHandle; + int result; + + if (mutex == NULL) + return OMX_ErrorBadParameter; + + if (pthread_mutex_unlock(mutex) != 0) + return OMX_ErrorUndefined; + + return OMX_ErrorNone; +} diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.h new file mode 100644 index 0000000..70dcd9d --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Mutex.h @@ -0,0 +1,47 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Mutex.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create +*/ + +#ifndef SEC_OSAL_MUTEX +#define SEC_OSAL_MUTEX + +#include "OMX_Types.h" +#include "OMX_Core.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +OMX_ERRORTYPE SEC_OSAL_MutexCreate(OMX_HANDLETYPE *mutexHandle); +OMX_ERRORTYPE SEC_OSAL_MutexTerminate(OMX_HANDLETYPE mutexHandle); +OMX_ERRORTYPE SEC_OSAL_MutexLock(OMX_HANDLETYPE mutexHandle); +OMX_ERRORTYPE SEC_OSAL_MutexUnlock(OMX_HANDLETYPE mutexHandle); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.c b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.c new file mode 100644 index 0000000..7a6c024 --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.c @@ -0,0 +1,174 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Queue.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + + +#include +#include +#include + +#include "SEC_OSAL_Memory.h" +#include "SEC_OSAL_Mutex.h" +#include "SEC_OSAL_Queue.h" + + +OMX_ERRORTYPE SEC_OSAL_QueueCreate(SEC_QUEUE *queueHandle) +{ + int i = 0; + SEC_QElem *newqelem = NULL; + SEC_QElem *currentqelem = NULL; + SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle; + + OMX_ERRORTYPE ret = OMX_ErrorNone; + + if (!queue) + return OMX_ErrorBadParameter; + + ret = SEC_OSAL_MutexCreate(&queue->qMutex); + if (ret != OMX_ErrorNone) + return ret; + + queue->first = (SEC_QElem *)SEC_OSAL_Malloc(sizeof(SEC_QElem)); + if (queue->first == NULL) + return OMX_ErrorInsufficientResources; + + SEC_OSAL_Memset(queue->first, 0, sizeof(SEC_QElem)); + currentqelem = queue->last = queue->first; + queue->numElem = 0; + + for (i = 0; i < (MAX_QUEUE_ELEMENTS - 2); i++) { + newqelem = (SEC_QElem *)SEC_OSAL_Malloc(sizeof(SEC_QElem)); + if (newqelem == NULL) { + while (queue->first != NULL) { + currentqelem = queue->first->qNext; + SEC_OSAL_Free((OMX_PTR)queue->first); + queue->first = currentqelem; + } + return OMX_ErrorInsufficientResources; + } else { + SEC_OSAL_Memset(newqelem, 0, sizeof(SEC_QElem)); + currentqelem->qNext = newqelem; + currentqelem = newqelem; + } + } + + currentqelem->qNext = queue->first; + + return OMX_ErrorNone; +} + +OMX_ERRORTYPE SEC_OSAL_QueueTerminate(SEC_QUEUE *queueHandle) +{ + int i = 0; + SEC_QElem *currentqelem = NULL; + SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle; + OMX_ERRORTYPE ret = OMX_ErrorNone; + + if (!queue) + return OMX_ErrorBadParameter; + + for ( i = 0; i < (MAX_QUEUE_ELEMENTS - 2); i++) { + currentqelem = queue->first->qNext; + SEC_OSAL_Free(queue->first); + queue->first = currentqelem; + } + + if(queue->first) { + SEC_OSAL_Free(queue->first); + queue->first = NULL; + } + + ret = SEC_OSAL_MutexTerminate(queue->qMutex); + + return ret; +} + +int SEC_OSAL_Queue(SEC_QUEUE *queueHandle, void *data) +{ + SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle; + if (queue == NULL) + return -1; + + SEC_OSAL_MutexLock(queue->qMutex); + + if ((queue->last->data != NULL) || (queue->numElem >= MAX_QUEUE_ELEMENTS)) { + SEC_OSAL_MutexUnlock(queue->qMutex); + return -1; + } + queue->last->data = data; + queue->last = queue->last->qNext; + queue->numElem++; + + SEC_OSAL_MutexUnlock(queue->qMutex); + return 0; +} + +void *SEC_OSAL_Dequeue(SEC_QUEUE *queueHandle) +{ + void *data = NULL; + SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle; + if (queue == NULL) + return NULL; + + SEC_OSAL_MutexLock(queue->qMutex); + + if ((queue->first->data == NULL) || (queue->numElem <= 0)) { + SEC_OSAL_MutexUnlock(queue->qMutex); + return NULL; + } + data = queue->first->data; + queue->first->data = NULL; + queue->first = queue->first->qNext; + queue->numElem--; + + SEC_OSAL_MutexUnlock(queue->qMutex); + return data; +} + +int SEC_OSAL_GetElemNum(SEC_QUEUE *queueHandle) +{ + int ElemNum = 0; + SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle; + if (queue == NULL) + return -1; + + SEC_OSAL_MutexLock(queue->qMutex); + ElemNum = queue->numElem; + SEC_OSAL_MutexUnlock(queue->qMutex); + return ElemNum; +} + +int SEC_OSAL_SetElemNum(SEC_QUEUE *queueHandle, int ElemNum) +{ + SEC_QUEUE *queue = (SEC_QUEUE *)queueHandle; + if (queue == NULL) + return -1; + + SEC_OSAL_MutexLock(queue->qMutex); + queue->numElem = ElemNum; + SEC_OSAL_MutexUnlock(queue->qMutex); + return ElemNum; +} + diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h new file mode 100644 index 0000000..68910cc --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h @@ -0,0 +1,67 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Queue.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OSAL_QUEUE +#define SEC_OSAL_QUEUE + +#include "OMX_Types.h" +#include "OMX_Core.h" + + +#define MAX_QUEUE_ELEMENTS 10 + +struct SEC_QElem; +typedef struct _SEC_QElem +{ + void *data; + struct SEC_QElem *qNext; +} SEC_QElem; + +typedef struct _SEC_QUEUE +{ + SEC_QElem *first; + SEC_QElem *last; + int numElem; + OMX_HANDLETYPE qMutex; +} SEC_QUEUE; + + +#ifdef __cplusplus +extern "C" { +#endif + +OMX_ERRORTYPE SEC_OSAL_QueueCreate(SEC_QUEUE *queueHandle); +OMX_ERRORTYPE SEC_OSAL_QueueTerminate(SEC_QUEUE *queueHandle); +int SEC_OSAL_Queue(SEC_QUEUE *queueHandle, void *data); +void *SEC_OSAL_Dequeue(SEC_QUEUE *queueHandle); +int SEC_OSAL_GetElemNum(SEC_QUEUE *queueHandle); +int SEC_OSAL_SetElemNum(SEC_QUEUE *queueHandle, int ElemNum); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c new file mode 100644 index 0000000..17a29a0 --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c @@ -0,0 +1,132 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Semaphore.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include +#include +#include + +#include "SEC_OSAL_Memory.h" +#include "SEC_OSAL_Semaphore.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_LOG_SEMA" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +OMX_ERRORTYPE SEC_OSAL_SemaphoreCreate(OMX_HANDLETYPE *semaphoreHandle) +{ + sem_t *sema; + + sema = (sem_t *)SEC_OSAL_Malloc(sizeof(sema)); + if (!sema) + return OMX_ErrorInsufficientResources; + + if (sem_init(sema, 0, 0) != 0) + return OMX_ErrorUndefined; + + *semaphoreHandle = (OMX_HANDLETYPE)sema; + return OMX_ErrorNone; +} + +OMX_ERRORTYPE SEC_OSAL_SemaphoreTerminate(OMX_HANDLETYPE semaphoreHandle) +{ + sem_t *sema = (sem_t *)semaphoreHandle; + + if (sema == NULL) + return OMX_ErrorBadParameter; + + if (sem_destroy(sema) != 0) + return OMX_ErrorUndefined; + + SEC_OSAL_Free(sema); + return OMX_ErrorNone; +} + +OMX_ERRORTYPE SEC_OSAL_SemaphoreWait(OMX_HANDLETYPE semaphoreHandle) +{ + sem_t *sema = (sem_t *)semaphoreHandle; + + FunctionIn(); + + if (sema == NULL) + return OMX_ErrorBadParameter; + + if (sem_wait(sema) != 0) + return OMX_ErrorUndefined; + + FunctionOut(); + + return OMX_ErrorNone; +} + +OMX_ERRORTYPE SEC_OSAL_SemaphorePost(OMX_HANDLETYPE semaphoreHandle) +{ + sem_t *sema = (sem_t *)semaphoreHandle; + + FunctionIn(); + + if (sema == NULL) + return OMX_ErrorBadParameter; + + if (sem_post(sema) != 0) + return OMX_ErrorUndefined; + + FunctionOut(); + + return OMX_ErrorNone; +} + +OMX_ERRORTYPE SEC_OSAL_Set_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 val) +{ + sem_t *sema = (sem_t *)semaphoreHandle; + + if (sema == NULL) + return OMX_ErrorBadParameter; + + if (sem_init(sema, 0, val) != 0) + return OMX_ErrorUndefined; + + return OMX_ErrorNone; +} + +OMX_ERRORTYPE SEC_OSAL_Get_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 *val) +{ + sem_t *sema = (sem_t *)semaphoreHandle; + OMX_U32 semaVal = 0; + + if (sema == NULL) + return OMX_ErrorBadParameter; + + if (sem_getvalue(sema, &semaVal) != 0) + return OMX_ErrorUndefined; + + *val = semaVal; + + return OMX_ErrorNone; +} diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.h new file mode 100644 index 0000000..f23d3d6 --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.h @@ -0,0 +1,49 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Semaphore.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OSAL_SEMAPHORE +#define SEC_OSAL_SEMAPHORE + +#include "OMX_Types.h" +#include "OMX_Core.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +OMX_ERRORTYPE SEC_OSAL_SemaphoreCreate(OMX_HANDLETYPE *semaphoreHandle); +OMX_ERRORTYPE SEC_OSAL_SemaphoreTerminate(OMX_HANDLETYPE semaphoreHandle); +OMX_ERRORTYPE SEC_OSAL_SemaphoreWait(OMX_HANDLETYPE semaphoreHandle); +OMX_ERRORTYPE SEC_OSAL_SemaphorePost(OMX_HANDLETYPE semaphoreHandle); +OMX_ERRORTYPE SEC_OSAL_Set_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 val); +OMX_ERRORTYPE SEC_OSAL_Get_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 *val); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c new file mode 100644 index 0000000..d488885 --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c @@ -0,0 +1,153 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Thread.c + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#include +#include +#include +#include +#include +#include + +#include "SEC_OSAL_Memory.h" +#include "SEC_OSAL_Thread.h" + +#undef SEC_LOG_TAG +#define SEC_LOG_TAG "SEC_LOG_THREAD" +#define SEC_LOG_OFF +#include "SEC_OSAL_Log.h" + + +typedef struct _SEC_THREAD_HANDLE_TYPE +{ + pthread_t pthread; + pthread_attr_t attr; + struct sched_param schedparam; + int stack_size; +} SEC_THREAD_HANDLE_TYPE; + + +OMX_ERRORTYPE SEC_OSAL_ThreadCreate(OMX_HANDLETYPE *threadHandle, OMX_PTR function_name, OMX_PTR argument) +{ + FunctionIn(); + + int result = 0; + int detach_ret = 0; + SEC_THREAD_HANDLE_TYPE *thread; + OMX_ERRORTYPE ret = OMX_ErrorNone; + + thread = SEC_OSAL_Malloc(sizeof(SEC_THREAD_HANDLE_TYPE)); + SEC_OSAL_Memset(thread, 0, sizeof(SEC_THREAD_HANDLE_TYPE)); + + pthread_attr_init(&thread->attr); + if (thread->stack_size != 0) + pthread_attr_setstacksize(&thread->attr, thread->stack_size); + + /* set priority */ + if (thread->schedparam.sched_priority != 0) + pthread_attr_setschedparam(&thread->attr, &thread->schedparam); + + detach_ret = pthread_attr_setdetachstate(&thread->attr, PTHREAD_CREATE_JOINABLE); + if (detach_ret != 0) { + ret = OMX_ErrorUndefined; + goto EXIT; + } + + result = pthread_create(&thread->pthread, &thread->attr, function_name, (void *)argument); + /* pthread_setschedparam(thread->pthread, SCHED_RR, &thread->schedparam); */ + + switch (result) { + case 0: + *threadHandle = (OMX_HANDLETYPE)thread; + ret = OMX_ErrorNone; + break; + case EAGAIN: + *threadHandle = NULL; + ret = OMX_ErrorInsufficientResources; + break; + default: + *threadHandle = NULL; + ret = OMX_ErrorUndefined; + break; + } + +EXIT: + FunctionOut(); + + return ret; +} + +OMX_ERRORTYPE SEC_OSAL_ThreadTerminate(OMX_HANDLETYPE threadHandle) +{ + FunctionIn(); + + OMX_ERRORTYPE ret = OMX_ErrorNone; + SEC_THREAD_HANDLE_TYPE *thread = (SEC_THREAD_HANDLE_TYPE *)threadHandle; + + if (!thread) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + if (pthread_join(thread->pthread, NULL) != 0) { + ret = OMX_ErrorUndefined; + goto EXIT; + } + + SEC_OSAL_Free(thread); + ret = OMX_ErrorNone; + +EXIT: + FunctionOut(); + + return ret; + +} + +OMX_ERRORTYPE SEC_OSAL_ThreadCancle(OMX_HANDLETYPE threadHandle) +{ + SEC_THREAD_HANDLE_TYPE *thread = (SEC_THREAD_HANDLE_TYPE *)threadHandle; + + if (!thread) + return OMX_ErrorBadParameter; + + /* thread_cancel(thread->pthread); */ + pthread_exit(thread->pthread); + pthread_join(thread->pthread, NULL); + + SEC_OSAL_Free(thread); + return OMX_ErrorNone; +} + +void SEC_OSAL_TheadExit(void *value_ptr) +{ + pthread_exit(value_ptr); + return; +} + +void SEC_OSAL_SleepMillisec(OMX_U32 ms) +{ + usleep(ms * 1000); + return; +} diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h new file mode 100644 index 0000000..b932aef --- /dev/null +++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h @@ -0,0 +1,48 @@ +/* + * + * Copyright 2010 Samsung Electronics S.LSI Co. LTD + * + * 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 SEC_OSAL_Thread.h + * @brief + * @author SeungBeom Kim (sbcrux.kim@samsung.com) + * @version 1.0 + * @history + * 2010.7.15 : Create + */ + +#ifndef SEC_OSAL_THREAD +#define SEC_OSAL_THREAD + +#include "OMX_Types.h" +#include "OMX_Core.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +OMX_ERRORTYPE SEC_OSAL_ThreadCreate(OMX_HANDLETYPE *threadHandle, OMX_PTR function_name, OMX_PTR argument); +OMX_ERRORTYPE SEC_OSAL_ThreadTerminate(OMX_HANDLETYPE threadHandle); +OMX_ERRORTYPE SEC_OSAL_ThreadCancle(OMX_HANDLETYPE threadHandle); +void SEC_OSAL_TheadExit(void *value_ptr); +void SEC_OSAL_SleepMillisec(OMX_U32 ms); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/shbootimg.mk b/shbootimg.mk new file mode 100644 index 0000000..16bb51f --- /dev/null +++ b/shbootimg.mk @@ -0,0 +1,7 @@ +INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img +$(INSTALLED_BOOTIMAGE_TARGET): device/samsung/aries-common/mkshbootimg.py \ + $(TARGET_RECOVERY_COMPRESSED_INITRAMFS) \ + $(BUILT_COMPRESSED_INITRAMFS_TARGET) \ + $(TARGET_PREBUILT_KERNEL) + $(call pretty,"Boot image: $@") + $(hide) ./device/samsung/aries-common/mkshbootimg.py $@ $(TARGET_PREBUILT_KERNEL) $(BUILT_COMPRESSED_INITRAMFS_TARGET) $(TARGET_RECOVERY_COMPRESSED_INITRAMFS) -- cgit v1.1