summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk13
-rwxr-xr-xBoardConfig.mk8
-rwxr-xr-xBoardConfigCommon.mk21
-rw-r--r--CleanSpec.mk7
-rw-r--r--[-rwxr-xr-x]bcm4329.kobin267700 -> 276245 bytes
-rw-r--r--device.mk5
-rw-r--r--device_base.mk62
-rwxr-xr-xextract-files.sh48
-rw-r--r--full_crespo.mk19
-rw-r--r--gps.conf6
-rwxr-xr-xgps.xml40
-rw-r--r--herring-keypad.kl6
-rw-r--r--include/hal_public.h171
-rwxr-xr-xinclude/sec_format.h43
-rwxr-xr-xinclude/sec_lcd.h49
-rw-r--r--include/sec_utils.h331
-rwxr-xr-xinit.herring.rc38
-rw-r--r--init.herring.usb.rc44
-rw-r--r--[-rwxr-xr-x]kernelbin2858444 -> 3203472 bytes
-rw-r--r--libaudio/Android.mk70
-rw-r--r--libaudio/AudioHardware.cpp1110
-rw-r--r--libaudio/AudioHardware.h157
-rw-r--r--libaudio/AudioPolicyManager.cpp2
-rw-r--r--libaudio/AudioPolicyManager.h2
-rw-r--r--libaudio/EchoReference.cpp376
-rw-r--r--libaudio/EchoReference.h118
-rw-r--r--libaudio/README7
-rw-r--r--libaudio/ReSampler.cpp171
-rw-r--r--libaudio/ReSampler.h80
-rw-r--r--libaudio/alsa_audio.h77
-rw-r--r--libaudio/alsa_mixer.c371
-rw-r--r--libaudio/alsa_pcm.c405
-rw-r--r--libaudio/amix.c78
-rw-r--r--libaudio/aplay.c140
-rw-r--r--libaudio/arec.c128
-rw-r--r--libaudio/asound.h814
-rw-r--r--libcamera/Android.mk29
-rwxr-xr-xlibcamera/SecCamera.cpp122
-rw-r--r--libcamera/SecCamera.h21
-rwxr-xr-x[-rw-r--r--]libcamera/SecCameraHWInterface.cpp1255
-rw-r--r--libcamera/SecCameraHWInterface.h82
-rw-r--r--libhwcomposer/Android.mk (renamed from liboverlay/Android.mk)8
-rw-r--r--libhwcomposer/SecHWC.cpp530
-rw-r--r--libhwcomposer/SecHWCUtils.cpp871
-rw-r--r--libhwcomposer/SecHWCUtils.h139
-rwxr-xr-xliblight/Android.mk4
-rw-r--r--liboverlay/overlay.cpp1490
-rw-r--r--liboverlay/v4l2_utils.c783
-rw-r--r--liboverlay/v4l2_utils.h75
-rw-r--r--libs3cjpeg/Android.mk2
-rw-r--r--libsensors/Android.mk7
-rw-r--r--libstagefrighthw/Android.mk1
-rw-r--r--media_profiles.xml100
-rw-r--r--mxt224_ts_input.idc33
-rw-r--r--mxt224_ts_input.kcm15
-rw-r--r--mxt224_ts_input.kl18
-rwxr-xr-xnvram_net.txt58
-rw-r--r--overlay/frameworks/base/core/res/res/values/config.xml37
-rw-r--r--overlay/frameworks/base/core/res/res/xml/storage_list.xml44
-rw-r--r--overlay/frameworks/base/packages/SystemUI/res/values/config.xml29
-rw-r--r--overlay/packages/apps/Contacts/res/values/config.xml21
-rw-r--r--overlay/packages/apps/Launcher2/res/drawable-hdpi/wallpaper_shuttle.jpgbin0 -> 154313 bytes
-rw-r--r--overlay/packages/apps/Launcher2/res/drawable-hdpi/wallpaper_shuttle_small.jpgbin0 -> 8190 bytes
-rw-r--r--overlay/packages/apps/Launcher2/res/values-hdpi/wallpapers.xml1
-rw-r--r--overlay/packages/apps/Launcher2/res/values/config.xml3
-rw-r--r--overlay/packages/apps/Phone/res/values/config.xml13
-rw-r--r--overlay/packages/apps/Settings/res/values/bools.xml21
-rw-r--r--samsung_mfc_fw.binbin0 -> 300352 bytes
-rw-r--r--sec_mm/sec_omx/sec_codecs/Android.mk2
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/Android.mk36
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/color_space_convertor.c1092
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_deinterleave_memcpy.s128
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_interleave_memcpy.s133
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_nv12t_yuv420_uv_neon.s768
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_nv12t_yuv420_y_neon.s680
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_yuv420_nv12t_uv_neon.s573
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_yuv420_nv12t_y_neon.s451
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/Android.mk2
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/dec/src/SsbSipMfcDecAPI.c170
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/Android.mk2
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/enc/src/SsbSipMfcEncAPI.c27
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/SsbSipMfcApi.h23
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/color_space_convertor.h176
-rw-r--r--sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/mfc_interface.h4
-rw-r--r--sec_mm/sec_omx/sec_omx_component/common/Android.mk2
-rw-r--r--sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c14
-rw-r--r--sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c6
-rw-r--r--sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h8
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c100
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h9
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk9
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c344
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c4
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h4
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk7
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c297
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c8
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h8
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c114
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.h9
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk9
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c216
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c18
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.h4
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk7
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c250
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c26
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.h8
-rw-r--r--sec_mm/sec_omx/sec_omx_core/Android.mk2
-rw-r--r--sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h106
-rw-r--r--sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h26
-rw-r--r--sec_mm/sec_omx/sec_osal/Android.mk18
-rw-r--r--sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp450
-rw-r--r--sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.h64
-rw-r--r--sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h5
-rw-r--r--sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c2
-rw-r--r--sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c4
-rw-r--r--sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h4
-rw-r--r--self-extractors/Android.mk0
-rw-r--r--self-extractors/PART112
-rw-r--r--self-extractors/PART222
-rw-r--r--self-extractors/PART312
-rw-r--r--self-extractors/PROLOGUE2
-rw-r--r--self-extractors/akm/COPYRIGHT1
-rw-r--r--self-extractors/akm/LICENSE218
-rw-r--r--self-extractors/akm/staging/BoardConfigCrespo.mk13
-rw-r--r--self-extractors/akm/staging/device-crespo.mk19
-rw-r--r--self-extractors/broadcom/COPYRIGHT1
-rw-r--r--self-extractors/broadcom/LICENSE218
-rw-r--r--self-extractors/broadcom/staging/BoardConfigCrespo.mk13
-rw-r--r--self-extractors/broadcom/staging/device-crespo.mk21
-rw-r--r--self-extractors/cypress/COPYRIGHT1
-rw-r--r--self-extractors/cypress/LICENSE1
-rw-r--r--self-extractors/cypress/staging/BoardConfigCrespo.mk13
-rw-r--r--self-extractors/cypress/staging/device-crespo.mk19
-rwxr-xr-xself-extractors/generate-packages.sh138
-rw-r--r--self-extractors/imgtec/COPYRIGHT1
-rw-r--r--self-extractors/imgtec/LICENSE218
-rw-r--r--self-extractors/imgtec/staging/BoardConfigCrespo.mk13
-rw-r--r--self-extractors/imgtec/staging/device-crespo.mk31
-rw-r--r--self-extractors/nxp/COPYRIGHT1
-rw-r--r--self-extractors/nxp/LICENSE218
-rw-r--r--self-extractors/nxp/staging/BoardConfigCrespo.mk13
-rw-r--r--self-extractors/nxp/staging/device-crespo.mk19
-rw-r--r--self-extractors/root/BoardConfigVendor.mk23
-rw-r--r--self-extractors/root/device-vendor.mk23
-rw-r--r--self-extractors/samsung/COPYRIGHT1
-rw-r--r--self-extractors/samsung/LICENSE225
-rw-r--r--self-extractors/samsung/staging/BoardConfigCrespo.mk13
-rw-r--r--self-extractors/samsung/staging/device-crespo.mk24
-rw-r--r--self-extractors/widevine/COPYRIGHT1
-rw-r--r--self-extractors/widevine/LICENSE1
-rw-r--r--self-extractors/widevine/staging/BoardConfigCrespo.mk13
-rw-r--r--self-extractors/widevine/staging/device-crespo.mk24
-rwxr-xr-xsetup-makefiles.sh52
-rw-r--r--setup_fs.c75
-rw-r--r--ueventd.herring.rc2
-rwxr-xr-xunzip-files.sh48
-rw-r--r--vold.fstab5
159 files changed, 12504 insertions, 6522 deletions
diff --git a/Android.mk b/Android.mk
index f21c56c..8f1acc5 100644
--- a/Android.mk
+++ b/Android.mk
@@ -14,17 +14,4 @@
LOCAL_PATH := $(call my-dir)
-ifneq ($(filter crespo crespo4g,$(TARGET_DEVICE)),)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := setup_fs.c
-LOCAL_MODULE := setup_fs
-LOCAL_MODULE_TAGS := optional
-#LOCAL_SHARED_LIBRARIES += libext4_utils libz
-include $(BUILD_EXECUTABLE)
-
-endif
-
-ifneq ($(TARGET_SIMULATOR),true)
include $(call all-makefiles-under,$(LOCAL_PATH))
-endif
diff --git a/BoardConfig.mk b/BoardConfig.mk
index e198b9b..2927c72 100755
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -17,14 +17,6 @@
# Product-specific compile-time definitions.
#
-# Set this up here so that BoardConfigVendor.mk can override it
-BOARD_USES_GENERIC_AUDIO := false
-
-BOARD_USES_LIBSECRIL_STUB := true
-
-BOARD_NO_PAGE_FLIPPING := true
-BOARD_NO_32BPP := true
-
# Use the non-open-source parts, if they're present
-include vendor/samsung/crespo/BoardConfigVendor.mk
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
index 0465312..61d04a4 100755
--- a/BoardConfigCommon.mk
+++ b/BoardConfigCommon.mk
@@ -38,22 +38,25 @@ TARGET_SEC_INTERNAL_STORAGE := false
TARGET_ARCH_VARIANT := armv7-a-neon
ARCH_ARM_HAVE_TLS_REGISTER := true
-USE_CAMERA_STUB := false
-ifeq ($(USE_CAMERA_STUB),false)
-BOARD_CAMERA_LIBRARIES := libcamera
-endif
+# USE_CAMERA_STUB := true
+# ifeq ($(USE_CAMERA_STUB),false)
+# BOARD_CAMERA_LIBRARIES := libcamera
+# endif
BOARD_USES_HGL := true
##BOARD_USES_OVERLAY := true
+BOARD_USES_GENERIC_AUDIO := false
DEFAULT_FB_NUM := 2
-BOARD_NAND_PAGE_SIZE := 4096 -s 128
+BOARD_NAND_PAGE_SIZE := 4096
+BOARD_NAND_SPARE_SIZE := 128
BOARD_KERNEL_BASE := 0x30000000
BOARD_KERNEL_PAGESIZE := 4096
BOARD_KERNEL_CMDLINE := console=ttyFIQ0 no_console_suspend
+TARGET_RECOVERY_PIXEL_FORMAT := "BGRA_8888"
TARGET_RECOVERY_UI_LIB := librecovery_ui_crespo
TARGET_RELEASETOOLS_EXTENSIONS := device/samsung/crespo
@@ -63,12 +66,14 @@ BOARD_USERDATAIMAGE_PARTITION_SIZE := 1073741824
BOARD_FLASH_BLOCK_SIZE := 4096
# Connectivity - Wi-Fi
-WPA_SUPPLICANT_VERSION := VER_0_6_X
+WPA_SUPPLICANT_VERSION := VER_0_8_X
BOARD_WPA_SUPPLICANT_DRIVER := WEXT
BOARD_WLAN_DEVICE := bcm4329
+BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_wext
WIFI_DRIVER_MODULE_PATH := "/system/modules/bcm4329.ko"
-WIFI_DRIVER_FW_STA_PATH := "/vendor/firmware/fw_bcm4329.bin"
-WIFI_DRIVER_FW_AP_PATH := "/vendor/firmware/fw_bcm4329_apsta.bin"
+WIFI_DRIVER_FW_PATH_STA := "/vendor/firmware/fw_bcm4329.bin"
+WIFI_DRIVER_FW_PATH_AP := "/vendor/firmware/fw_bcm4329_apsta.bin"
WIFI_DRIVER_MODULE_NAME := "bcm4329"
WIFI_DRIVER_MODULE_ARG := "iface_name=wlan0 firmware_path=/vendor/firmware/fw_bcm4329.bin nvram_path=/vendor/firmware/nvram_net.txt"
+USE_OPENGL_RENDERER := true
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 6921642..39a44eb 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -58,3 +58,10 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/product/crespo/system/etc/asound
$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/crespo/system/usr/share/alsa)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/crespo/obj/PACKAGING/systemimage_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/crespo/obj/SHARED_LIBRARIES/libaudio_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/crespo/system/lib/hw/camera.s5pc110.so)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/crespo/obj/lib/camera.s5pc110.so)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/crespo/obj/SHARED_LIBRARIES/camera.s5pc110_intermediates/LINKED/camera.s5pc110.so)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/crespo/symbols/system/lib/hw/camera.s5pc110.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/Tag.apk)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/crespo/obj/STATIC_LIBRARIES/libaudioutils_intermediates)
diff --git a/bcm4329.ko b/bcm4329.ko
index ab50d3f..81f0cf4 100755..100644
--- a/bcm4329.ko
+++ b/bcm4329.ko
Binary files differ
diff --git a/device.mk b/device.mk
index 6969b16..b028f3c 100644
--- a/device.mk
+++ b/device.mk
@@ -38,6 +38,11 @@
PRODUCT_COPY_FILES := \
frameworks/base/data/etc/android.hardware.telephony.gsm.xml:system/etc/permissions/android.hardware.telephony.gsm.xml
+# GPS config
+PRODUCT_COPY_FILES += \
+ device/samsung/crespo/gps.xml:system/vendor/etc/gps.xml \
+ device/samsung/crespo/gps.conf:system/etc/gps.conf
+
$(call inherit-product, device/samsung/crespo/device_base.mk)
# See comment at the top of this file. This is where the other
diff --git a/device_base.mk b/device_base.mk
index c0ca072..a443a89 100644
--- a/device_base.mk
+++ b/device_base.mk
@@ -49,6 +49,7 @@ PRODUCT_COPY_FILES := \
# Init files
PRODUCT_COPY_FILES += \
device/samsung/crespo/init.herring.rc:root/init.herring.rc \
+ device/samsung/crespo/init.herring.usb.rc:root/init.herring.usb.rc \
device/samsung/crespo/ueventd.herring.rc:root/ueventd.herring.rc
# Prebuilt kl and kcm keymaps
@@ -60,7 +61,21 @@ PRODUCT_COPY_FILES += \
device/samsung/crespo/cypress-touchkey.kl:system/usr/keylayout/cypress-touchkey.kl \
device/samsung/crespo/cypress-touchkey.kcm:system/usr/keychars/cypress-touchkey.kcm \
device/samsung/crespo/sec_jack.kl:system/usr/keylayout/sec_jack.kl \
- device/samsung/crespo/sec_jack.kcm:system/usr/keychars/sec_jack.kcm
+ device/samsung/crespo/sec_jack.kcm:system/usr/keychars/sec_jack.kcm \
+ device/samsung/crespo/mxt224_ts_input.kl:system/usr/keylayout/mxt224_ts_input.kl \
+ device/samsung/crespo/mxt224_ts_input.kcm:system/usr/keychars/mxt224_ts_input.kcm
+
+#Bluetooth setup
+PRODUCT_COPY_FILES += \
+ system/bluetooth/data/main.conf:system/etc/bluetooth/main.conf \
+
+#NVRAM setup
+PRODUCT_COPY_FILES += \
+ device/samsung/crespo/nvram_net.txt:system/vendor/firmware/nvram_net.txt
+
+#MFC Firmware
+PRODUCT_COPY_FILES += \
+ device/samsung/crespo/samsung_mfc_fw.bin:system/vendor/firmware/samsung_mfc_fw.bin
# Generated kcm keymaps
PRODUCT_PACKAGES := \
@@ -91,8 +106,19 @@ PRODUCT_PACKAGES += \
# Misc other modules
PRODUCT_PACKAGES += \
lights.s5pc110 \
- overlay.s5pc110 \
- sensors.herring
+ hwcomposer.s5pc110 \
+ sensors.herring
+
+# Camera
+PRODUCT_PACKAGES += \
+ camera.herring
+
+# audio
+PRODUCT_PACKAGES += \
+ audio_policy.herring \
+ audio.primary.herring \
+ audio.a2dp.default \
+ libaudioutils
# Libs
PRODUCT_PACKAGES += \
@@ -100,19 +126,21 @@ PRODUCT_PACKAGES += \
libstagefrighthw \
com.android.future.usb.accessory
-# NFC
-PRODUCT_PACKAGES += \
- libnfc \
- libnfc_jni \
- Nfc \
- Tag
-
# Input device calibration files
PRODUCT_COPY_FILES += \
device/samsung/crespo/mxt224_ts_input.idc:system/usr/idc/mxt224_ts_input.idc
+# for bugmailer
+ifneq ($(TARGET_BUILD_VARIANT),user)
+ PRODUCT_PACKAGES += send_bug
+ PRODUCT_COPY_FILES += \
+ system/extras/bugmailer/bugmailer.sh:system/bin/bugmailer.sh \
+ system/extras/bugmailer/send_bug:system/bin/send_bug
+endif
+
# These are the hardware-specific features
PRODUCT_COPY_FILES += \
+ device/sample/nxp/com.nxp.mifare.xml:system/etc/permissions/com.nxp.mifare.xml \
frameworks/base/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml \
frameworks/base/data/etc/android.hardware.camera.flash-autofocus.xml:system/etc/permissions/android.hardware.camera.flash-autofocus.xml \
frameworks/base/data/etc/android.hardware.camera.front.xml:system/etc/permissions/android.hardware.camera.front.xml \
@@ -139,17 +167,17 @@ PRODUCT_PROPERTY_OVERRIDES += \
wifi.interface=wlan0 \
wifi.supplicant_scan_interval=15
+# Set default USB interface
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ persist.sys.usb.config=mass_storage
+
include frameworks/base/build/phone-hdpi-512-dalvik-heap.mk
# we have enough storage space to hold precise GC data
PRODUCT_TAGS += dalvik.gc.type-precise
-# Screen density is actually considered a locale (since it is taken into account
-# the the build-time selection of resources). The product definitions including
-# this file must pay attention to the fact that the first entry in the final
-# PRODUCT_LOCALES expansion must not be a density.
-PRODUCT_LOCALES := hdpi
-
+# Screen size is "normal", density is "hdpi"
+PRODUCT_AAPT_CONFIG := normal hdpi
ifeq ($(TARGET_PREBUILT_WIFI_MODULE),)
LOCAL_WIFI_MODULE := device/samsung/crespo/bcm4329.ko
@@ -168,3 +196,5 @@ endif
PRODUCT_COPY_FILES += \
$(LOCAL_KERNEL):kernel
+
+$(call inherit-product-if-exists, vendor/nxp/pn544/nxp-pn544-fw-vendor.mk)
diff --git a/extract-files.sh b/extract-files.sh
index ae73d55..38a4021 100755
--- a/extract-files.sh
+++ b/extract-files.sh
@@ -20,18 +20,19 @@ DEVICE=crespo
MANUFACTURER=samsung
mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
-adb pull /system/etc/gps.conf ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/gps.conf
-adb pull /system/lib/libpn544_fw.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libpn544_fw.so
+adb pull /system/etc/permissions/com.google.widevine.software.drm.xml ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/com.google.widevine.software.drm.xml
+adb pull /system/lib/drm/libdrmwvmplugin.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libdrmwvmplugin.so
adb pull /system/lib/libsecril-client.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libsecril-client.so
+adb pull /system/lib/libwvdrm_L3.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libwvdrm_L3.so
+adb pull /system/lib/libwvm.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libwvm.so
+adb pull /system/lib/libWVStreamControlAPI_L3.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libWVStreamControlAPI_L3.so
adb pull /system/vendor/bin/gpsd ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/gpsd
chmod 755 ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/gpsd
adb pull /system/vendor/bin/pvrsrvinit ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/pvrsrvinit
chmod 755 ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/pvrsrvinit
-adb pull /system/vendor/etc/gps.xml ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/gps.xml
adb pull /system/vendor/firmware/bcm4329.hcd ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/bcm4329.hcd
adb pull /system/vendor/firmware/cypress-touchkey.bin ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/cypress-touchkey.bin
-adb pull /system/vendor/firmware/nvram_net.txt ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/nvram_net.txt
-adb pull /system/vendor/firmware/samsung_mfc_fw.bin ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/samsung_mfc_fw.bin
+adb pull /system/vendor/firmware/libpn544_fw.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libpn544_fw.so
adb pull /system/vendor/lib/egl/libEGL_POWERVR_SGX540_120.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libEGL_POWERVR_SGX540_120.so
adb pull /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libGLESv1_CM_POWERVR_SGX540_120.so
adb pull /system/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libGLESv2_POWERVR_SGX540_120.so
@@ -71,16 +72,17 @@ PRODUCT_COPY_FILES := \\
# All the blobs necessary for crespo
PRODUCT_COPY_FILES += \\
- vendor/__MANUFACTURER__/__DEVICE__/proprietary/gps.conf:system/etc/gps.conf \\
- vendor/__MANUFACTURER__/__DEVICE__/proprietary/libpn544_fw.so:system/lib/libpn544_fw.so \\
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/com.google.widevine.software.drm.xml:system/etc/permissions/com.google.widevine.software.drm.xml \\
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/libdrmwvmplugin.so:system/lib/drm/libdrmwvmplugin.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libsecril-client.so:system/lib/libsecril-client.so \\
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/libwvdrm_L3.so:system/lib/libwvdrm_L3.so \\
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/libwvm.so:system/lib/libwvm.so \\
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/libWVStreamControlAPI_L3.so:system/lib/libWVStreamControlAPI_L3.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/gpsd:system/vendor/bin/gpsd \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/pvrsrvinit:system/vendor/bin/pvrsrvinit \\
- vendor/__MANUFACTURER__/__DEVICE__/proprietary/gps.xml:system/vendor/etc/gps.xml \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/bcm4329.hcd:system/vendor/firmware/bcm4329.hcd \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/cypress-touchkey.bin:system/vendor/firmware/cypress-touchkey.bin \\
- vendor/__MANUFACTURER__/__DEVICE__/proprietary/nvram_net.txt:system/vendor/firmware/nvram_net.txt \\
- vendor/__MANUFACTURER__/__DEVICE__/proprietary/samsung_mfc_fw.bin:system/vendor/firmware/samsung_mfc_fw.bin \\
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/libpn544_fw.so:system/vendor/firmware/libpn544_fw.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libEGL_POWERVR_SGX540_120.so:system/vendor/lib/egl/libEGL_POWERVR_SGX540_120.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libGLESv1_CM_POWERVR_SGX540_120.so:system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libGLESv2_POWERVR_SGX540_120.so:system/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so \\
@@ -96,6 +98,32 @@ PRODUCT_COPY_FILES += \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libsrv_init.so:system/vendor/lib/libsrv_init.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libsrv_um.so:system/vendor/lib/libsrv_um.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libusc.so:system/vendor/lib/libusc.so
+
+
+EOF
+
+(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/Android.mk
+# Copyright (C) 2011 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.
+
+# This file is generated by device/__MANUFACTURER__/__DEVICE__/extract-files.sh - DO NOT EDIT
+
+ifeq (\$(TARGET_DEVICE),crespo)
+LOCAL_PATH:=\$(call my-dir)
+
+endif
+
EOF
./setup-makefiles.sh
diff --git a/full_crespo.mk b/full_crespo.mk
index 68b8216..65a9fe2 100644
--- a/full_crespo.mk
+++ b/full_crespo.mk
@@ -22,6 +22,25 @@
# Get the long list of APNs
PRODUCT_COPY_FILES := device/sample/etc/apns-full-conf.xml:system/etc/apns-conf.xml
+# Camera
+PRODUCT_PACKAGES := \
+ Camera
+
+# NFC
+PRODUCT_PACKAGES += \
+ libnfc \
+ libnfc_jni \
+ Nfc \
+ Tag
+
+# Live Wallpapers
+PRODUCT_PACKAGES += \
+ LiveWallpapers \
+ LiveWallpapersPicker \
+ MagicSmokeWallpapers \
+ VisualizationWallpapers \
+ librs_jni
+
# Inherit from those products. Most specific first.
$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk)
# This is where we'd set a backup provider if we had one
diff --git a/gps.conf b/gps.conf
new file mode 100644
index 0000000..bd431a6
--- /dev/null
+++ b/gps.conf
@@ -0,0 +1,6 @@
+NTP_SERVER=north-america.pool.ntp.org
+XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
+XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
+XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
+SUPL_HOST=supl.google.com
+SUPL_PORT=7276
diff --git a/gps.xml b/gps.xml
new file mode 100755
index 0000000..15b7cc6
--- /dev/null
+++ b/gps.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<glgps xmlns="http://www.glpals.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.glpals.com/ glconfig.xsd" >
+ <!--HAL Confguration -->
+ <hal
+ acPortName="/dev/s3c2410_serial1" lBaudRate="115200" cLogEnabled="false" cLogEnableInitState="false" acLogDirectory="/data/gps/log/" ltoFileName="lto2.dat"
+ enhanced-assisted="false" cp-enhanced-assisted="true" TISEnabled="false" RILEnabled="true" LPmode="false" cp-cold-start="false" cp-guard-time-sec="2"
+ arp-supl-enable="true" arp-supl-cap-msb="true" arp-supl-cap-msa="true" arp-supl-cap-ecid="false"
+ acSuplServer="supl.google.com" SuplPort="7276"
+ LbsEnable="true" LbsLocal="false" LbsServer="bcmls2.glpals.com" LbsPort="7275" LbsSyncLto="true" LbsSyncCells="true" LbsWlanEnable="false"
+ LbsSyncLtoThresholdDays="3"
+ gpioNStdbyPath="/sys/class/sec/gps/GPS_PWR_EN/value"
+ gpioNResetPath="/sys/class/sec/gps/GPS_nRST/value"
+ gpioDelayMs="250"
+ lcsApiSockName="/dev/socket/gps"
+ acNvStoDir="/data/gps/"
+ />
+
+ <!-- Parameters passed to GlEngine -->
+ <!--gll
+ LogPriMask="LOG_DEBUG"
+ LogFacMask="LOG_GLLAPI | LOG_DEVIA | LOG_NMEA | LOG_RAWDATA | LOG_DEVMS | LOG_ASIC_IO | LOG_BBTEST | LOG_DEVET | LOG_MESM | LOG_DEVKF | LOG_DEVJG | LOG_DEVMR"
+ FrqPlan="FRQ_PLAN_10MHZ_2PPM_10MHZ_100PPB" FrqPlan="FRQ_PLAN_10MHZ_2PPM" "FRQ_PLAN_16_8MHZ_2PPM"
+ RfType="GL_RF_PALS7" "GL_RF_BARRACUDA" "GL_RF_2075_LN22" "GL_RF_2075_BRCM" "GL_RF_PALS7_BRCM" "GL_RF_BARRACUDA_BRCM" "GL_RF_BARRACUDA_EXT_LNA"
+ NOTE: "GL_RF_BARRACUDA_EXT_LNA" should be used for BAS
+ LbsEnable="true" LbsLocal="true" LbsServer="bcmlbsqa1.glpals.com" LbsPort="7275" LbsSyncTimeSec = "60" LbsSyncLto="true" LbsSyncCells="true"
+ /-->
+
+ <!-- NOTE: BrcmRFwildBase, BrcmRFclkDiv, anBrcmRFclkRefHz only needed for Broadcom RF front end test chips
+ ( i.e. GL_RF_2075_BRCM and GL_RF_PALS7_BRCM ) -->
+
+ <gll
+ LogPriMask="LOG_DEBUG"
+ LogFacMask="LOG_GLLAPI | LOG_DEVIA | LOG_NMEA | LOG_RAWDATA | LOG_DEVMS | LOG_ASIC_IO | LOG_BBTEST | LOG_DEVET | LOG_MESM | LOG_DEVKF | LOG_DEVJG | LOG_DEVMR"
+ FrqPlan="FRQ_PLAN_26MHZ_2PPM_26MHZ_300PPB"
+ RfType="GL_RF_4751_DANUBE_EXT_LNA"
+ WarmStandbyTimeout1Seconds="5"
+ WarmStandbyTimeout2Seconds="10"
+ >
+ </gll>
+</glgps>
diff --git a/herring-keypad.kl b/herring-keypad.kl
index 320a340..6dd0ebd 100644
--- a/herring-keypad.kl
+++ b/herring-keypad.kl
@@ -12,6 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-114 VOLUME_DOWN WAKE
-115 VOLUME_UP WAKE
-116 POWER WAKE
+key 114 VOLUME_DOWN WAKE
+key 115 VOLUME_UP WAKE
+key 116 POWER WAKE
diff --git a/include/hal_public.h b/include/hal_public.h
new file mode 100644
index 0000000..60f33a9
--- /dev/null
+++ b/include/hal_public.h
@@ -0,0 +1,171 @@
+/* Copyright (c) Imagination Technologies Ltd.
+ *
+ * The contents of this file are subject to the MIT license as set out below.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef HAL_PUBLIC_H
+#define HAL_PUBLIC_H
+
+/* Authors of third party hardware composer (HWC) modules will need to include
+ * this header to access functionality in the gralloc and framebuffer HALs.
+ */
+
+#include <hardware/gralloc.h>
+
+#define ALIGN(x,a) (((x) + (a) - 1L) & ~((a) - 1L))
+#define HW_ALIGN 32
+
+/* This can be tuned down as appropriate for the SOC.
+ *
+ * IMG formats are usually a single sub-alloc.
+ * Some OEM video formats are two sub-allocs (Y, UV planes).
+ * Future OEM video formats might be three sub-allocs (Y, U, V planes).
+ */
+#define MAX_SUB_ALLOCS 3
+
+typedef struct
+{
+ native_handle_t base;
+
+ /* These fields can be sent cross process. They are also valid
+ * to duplicate within the same process.
+ *
+ * A table is stored within psPrivateData on gralloc_module_t (this
+ * is obviously per-process) which maps stamps to a mapped
+ * PVRSRV_CLIENT_MEM_INFO in that process. Each map entry has a lock
+ * count associated with it, satisfying the requirements of the
+ * Android API. This also prevents us from leaking maps/allocations.
+ *
+ * This table has entries inserted either by alloc()
+ * (alloc_device_t) or map() (gralloc_module_t). Entries are removed
+ * by free() (alloc_device_t) and unmap() (gralloc_module_t).
+ *
+ * As a special case for framebuffer_device_t, framebuffer_open()
+ * will add and framebuffer_close() will remove from this table.
+ */
+
+#define IMG_NATIVE_HANDLE_NUMFDS MAX_SUB_ALLOCS
+ /* The `fd' field is used to "export" a meminfo to another process.
+ * Therefore, it is allocated by alloc_device_t, and consumed by
+ * gralloc_module_t. The framebuffer_device_t does not need a handle,
+ * and the special value IMG_FRAMEBUFFER_FD is used instead.
+ */
+ int fd[MAX_SUB_ALLOCS];
+
+#define IMG_NATIVE_HANDLE_NUMINTS ((sizeof(unsigned long long) / sizeof(int)) + 5)
+ /* A KERNEL unique identifier for any exported kernel meminfo. Each
+ * exported kernel meminfo will have a unique stamp, but note that in
+ * userspace, several meminfos across multiple processes could have
+ * the same stamp. As the native_handle can be dup(2)'d, there could be
+ * multiple handles with the same stamp but different file descriptors.
+ */
+ unsigned long long ui64Stamp;
+
+ /* This is used for buffer usage validation when locking a buffer,
+ * and also in WSEGL (for the composition bypass feature).
+ */
+ int usage;
+
+ //int dummy;
+ /* In order to do efficient cache flushes we need the buffer dimensions
+ * and format. These are available on the ANativeWindowBuffer,
+ * but the platform doesn't pass them down to the graphics HAL.
+ *
+ * These fields are also used in the composition bypass. In this
+ * capacity, these are the "real" values for the backing allocation.
+ */
+ int iWidth;
+ int iHeight;
+ int iFormat;
+ unsigned int uiBpp;
+}
+__attribute__((aligned(sizeof(int)),packed)) IMG_native_handle_t;
+
+typedef struct
+{
+ framebuffer_device_t base;
+
+ /* The HWC was loaded. post() is no longer responsible for presents */
+ int bBypassPost;
+
+ /* Custom-blit components in lieu of overlay hardware */
+ int (*Blit)(framebuffer_device_t *device, buffer_handle_t src,
+ buffer_handle_t dest, int w, int h, int x, int y);
+
+ /* HWC path for present posts */
+ int (*Post2)(framebuffer_device_t *fb, buffer_handle_t *buffers,
+ int num_buffers, void *data, int data_length);
+}
+IMG_framebuffer_device_public_t;
+
+typedef struct IMG_gralloc_module_public_t
+{
+ gralloc_module_t base;
+
+ /* If the framebuffer has been opened, this will point to the
+ * framebuffer device data required by the allocator, WSEGL
+ * modules and composerhal.
+ */
+ IMG_framebuffer_device_public_t *psFrameBufferDevice;
+
+ int (*GetPhyAddrs)(struct IMG_gralloc_module_public_t const* module,
+ buffer_handle_t handle,
+ unsigned int auiPhyAddr[MAX_SUB_ALLOCS]);
+ /* Custom-blit components in lieu of overlay hardware */
+ int (*Blit)(struct IMG_gralloc_module_public_t const *module,
+ buffer_handle_t src,
+ void *dest[MAX_SUB_ALLOCS], int format);
+
+ int (*Blit2)(struct IMG_gralloc_module_public_t const *module,
+ buffer_handle_t src, buffer_handle_t dest,
+ int w, int h, int x, int y);
+}
+IMG_gralloc_module_public_t;
+
+typedef struct
+{
+ int l, t, w, h;
+}
+IMG_write_lock_rect_t;
+
+typedef struct IMG_buffer_format_public_t
+{
+ /* Buffer formats are returned as a linked list */
+ struct IMG_buffer_format_public_t *psNext;
+
+ /* HAL_PIXEL_FORMAT_... enumerant */
+ int iHalPixelFormat;
+
+ /* WSEGL_PIXELFORMAT_... enumerant */
+ int iWSEGLPixelFormat;
+
+ /* Friendly name for format */
+ const char *const szName;
+
+ /* Bits (not bytes) per pixel */
+ unsigned int uiBpp;
+
+ /* GPU output format (creates EGLConfig for format) */
+ int bGPURenderable;
+}
+IMG_buffer_format_public_t;
+
+#endif /* HAL_PUBLIC_H */
diff --git a/include/sec_format.h b/include/sec_format.h
new file mode 100755
index 0000000..99a47bf
--- /dev/null
+++ b/include/sec_format.h
@@ -0,0 +1,43 @@
+/*
+ * 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 _SEC_FORMAT_H_
+#define _SEC_FORMAT_H_
+
+/* enum related to pixel format */
+
+enum {
+ HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x100,
+ HAL_PIXEL_FORMAT_YCbCr_420_P = 0x101,
+ HAL_PIXEL_FORMAT_YCbCr_420_I = 0x102,
+ HAL_PIXEL_FORMAT_CbYCrY_422_I = 0x103,
+ HAL_PIXEL_FORMAT_CbYCrY_420_I = 0x104,
+ HAL_PIXEL_FORMAT_YCbCr_422_P = 0x105,
+ HAL_PIXEL_FORMAT_YCrCb_422_SP = 0x106,
+ // support custom format for zero copy
+ HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP = 0x110,
+ HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP = 0x111,
+ HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED = 0x112,
+ HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP = 0x113,
+ HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP = 0x114,
+ HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I = 0x115,
+ HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I = 0x116,
+ HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I = 0x117,
+ HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I = 0x118,
+ HAL_PIXEL_FORMAT_CUSTOM_MAX
+};
+
+#endif
diff --git a/include/sec_lcd.h b/include/sec_lcd.h
new file mode 100755
index 0000000..b5451b7
--- /dev/null
+++ b/include/sec_lcd.h
@@ -0,0 +1,49 @@
+/*
+ * 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 _SEC_FB_LCD_
+#define _SEC_FB_LCD_
+
+/*
+ * S T R U C T U R E S F O R C U S T O M I O C T L S
+ *
+*/
+struct secfb_user_window {
+ int x;
+ int y;
+};
+
+/*
+ * C U S T O M I O C T L S
+ *
+*/
+
+#define FBIO_WAITFORVSYNC _IO ('F', 32)
+#define SECFB_WIN_POSITION _IOW ('F', 203, struct secfb_user_window)
+
+
+#define DEFAULT_LCD_WIDTH (480)
+#define DEFAULT_LCD_HEIGHT (800)
+#define DEFAULT_LCD_BPP (32)
+
+/***************** LCD frame buffer *****************/
+#define FB0_NAME "/dev/fb0"
+#define FB1_NAME "/dev/fb1"
+#define FB2_NAME "/dev/fb2"
+#define FB3_NAME "/dev/fb3"
+#define FB4_NAME "/dev/fb4"
+
+#endif
diff --git a/include/sec_utils.h b/include/sec_utils.h
new file mode 100644
index 0000000..80b4493
--- /dev/null
+++ b/include/sec_utils.h
@@ -0,0 +1,331 @@
+/*
+ * 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 __SAMSUNG_SYSLSI_SEC_COMMON_H__
+#define __SAMSUNG_SYSLSI_SEC_COMMON_H__
+
+//---------------------------------------------------------//
+// Include
+//---------------------------------------------------------//
+
+#include <hardware/hardware.h>
+#include "sec_format.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <linux/videodev2.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+//---------------------------------------------------------//
+// Common structure //
+//---------------------------------------------------------//
+struct ADDRS {
+ unsigned int addr_y;
+ unsigned int addr_cbcr;
+ unsigned int buf_idx;
+ unsigned int reserved;
+};
+
+//---------------------------------------------------------//
+// Common function //
+//---------------------------------------------------------//
+inline int HAL_PIXEL_FORMAT_2_V4L2_PIX(int HAL_PIXEL_FORMAT)
+{
+ int V4L2_PIX = -1;
+
+ switch (HAL_PIXEL_FORMAT) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ V4L2_PIX = V4L2_PIX_FMT_RGB32;
+ break;
+
+ case HAL_PIXEL_FORMAT_RGB_888:
+ V4L2_PIX = V4L2_PIX_FMT_RGB24;
+ break;
+
+ case HAL_PIXEL_FORMAT_RGB_565:
+ V4L2_PIX = V4L2_PIX_FMT_RGB565;
+ break;
+
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ //V4L2_PIX = V4L2_PIX_FMT_BGR32; // this is not proper on fimc.
+ V4L2_PIX = V4L2_PIX_FMT_RGB32;
+ break;
+
+ case HAL_PIXEL_FORMAT_RGBA_5551:
+ V4L2_PIX = V4L2_PIX_FMT_RGB555X;
+ break;
+
+ case HAL_PIXEL_FORMAT_RGBA_4444:
+ V4L2_PIX = V4L2_PIX_FMT_RGB444;
+ break;
+
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_YCbCr_420_P:
+ V4L2_PIX = V4L2_PIX_FMT_YUV420;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP:
+ V4L2_PIX = V4L2_PIX_FMT_NV61;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP:
+ V4L2_PIX = V4L2_PIX_FMT_NV12;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I:
+ V4L2_PIX = V4L2_PIX_FMT_YUYV;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCbCr_422_P:
+ V4L2_PIX = V4L2_PIX_FMT_YUV422P;
+ break;
+
+ case HAL_PIXEL_FORMAT_CbYCrY_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I:
+ V4L2_PIX = V4L2_PIX_FMT_UYVY;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCrCb_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP:
+ V4L2_PIX = V4L2_PIX_FMT_NV16;
+ break;
+
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP:
+ V4L2_PIX = V4L2_PIX_FMT_NV21;
+ break;
+
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
+ V4L2_PIX = V4L2_PIX_FMT_NV12T;
+ break;
+
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I:
+ V4L2_PIX = V4L2_PIX_FMT_YVYU;
+ break;
+
+ case HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I:
+ V4L2_PIX = V4L2_PIX_FMT_VYUY;
+ break;
+
+ default:
+ LOGE("%s::unmatched HAL_PIXEL_FORMAT color_space(0x%x)\n",
+ __func__, HAL_PIXEL_FORMAT);
+ break;
+ }
+
+ return V4L2_PIX;
+}
+
+inline int V4L2_PIX_2_HAL_PIXEL_FORMAT(int V4L2_PIX)
+{
+ int HAL_PIXEL_FORMAT = -1;
+
+ switch (V4L2_PIX) {
+ case V4L2_PIX_FMT_RGB32:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGBA_8888;
+ //HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGBX_8888;
+ break;
+
+ case V4L2_PIX_FMT_RGB24:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGB_888;
+ break;
+
+ case V4L2_PIX_FMT_RGB565:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGB_565;
+ break;
+
+ case V4L2_PIX_FMT_BGR32:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_BGRA_8888;
+ break;
+
+ case V4L2_PIX_FMT_RGB555X:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGBA_5551;
+ break;
+
+ case V4L2_PIX_FMT_RGB444:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_RGBA_4444;
+ break;
+
+ case V4L2_PIX_FMT_YUV420:
+ //HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_YV12;
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_YCbCr_420_P;
+ break;
+
+ case V4L2_PIX_FMT_NV16:
+ //HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_YCrCb_422_SP;
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP;
+ break;
+
+ case V4L2_PIX_FMT_NV12:
+ //HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_YCrCb_420_SP;
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP;
+ break;
+
+ case V4L2_PIX_FMT_YUYV:
+ //HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_YCbCr_422_I;
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I;
+ break;
+
+ case V4L2_PIX_FMT_YUV422P:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_YCbCr_422_P;
+ break;
+
+ case V4L2_PIX_FMT_UYVY:
+ //HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CbYCrY_422_I;
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I;
+ break;
+
+ case V4L2_PIX_FMT_NV21:
+ //HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_YCbCr_420_SP;
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP;
+ break;
+
+ case V4L2_PIX_FMT_NV12T:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED;
+ break;
+
+ case V4L2_PIX_FMT_NV61:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP;
+ break;
+
+ case V4L2_PIX_FMT_YVYU:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I;
+ break;
+
+ case V4L2_PIX_FMT_VYUY:
+ HAL_PIXEL_FORMAT = HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I;
+ break;
+
+ default:
+ LOGE("%s::unmatched V4L2_PIX color_space(%d)\n",
+ __func__, V4L2_PIX);
+ break;
+ }
+
+ return HAL_PIXEL_FORMAT;
+}
+
+#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 GET_32BPP_FRAME_SIZE(w, h) (((w) * (h)) << 2)
+#define GET_24BPP_FRAME_SIZE(w, h) (((w) * (h)) * 3)
+#define GET_16BPP_FRAME_SIZE(w, h) (((w) * (h)) << 1)
+
+inline unsigned int FRAME_SIZE(int HAL_PIXEL_FORMAT, int w, int h)
+{
+ unsigned int frame_size = 0;
+ unsigned int size = 0;
+
+ switch (HAL_PIXEL_FORMAT) {
+ // 16bpp
+ case HAL_PIXEL_FORMAT_RGB_565:
+ case HAL_PIXEL_FORMAT_RGBA_5551:
+ //case HAL_PIXEL_FORMAT_ARGB_1555:
+ //case HAL_PIXEL_FORMAT_BGRA_5551:
+ //case HAL_PIXEL_FORMAT_ABGR_1555:
+
+ //case HAL_PIXEL_FORMAT_RGBX_5551:
+ //case HAL_PIXEL_FORMAT_XRGB_1555:
+ //case HAL_PIXEL_FORMAT_BGRX_5551:
+ //case HAL_PIXEL_FORMAT_XBGR_1555:
+
+ case HAL_PIXEL_FORMAT_RGBA_4444:
+ //case HAL_PIXEL_FORMAT_ARGB_4444:
+ //case HAL_PIXEL_FORMAT_BGRA_4444:
+ //case HAL_PIXEL_FORMAT_ABGR_4444:
+
+ //case HAL_PIXEL_FORMAT_RGBX_4444:
+ //case HAL_PIXEL_FORMAT_XRGB_4444:
+ //case HAL_PIXEL_FORMAT_BGRX_4444:
+ //case HAL_PIXEL_FORMAT_XBGR_4444:
+ frame_size = GET_16BPP_FRAME_SIZE(w, h);
+ break;
+
+ // 24bpp
+ case HAL_PIXEL_FORMAT_RGB_888:
+ frame_size = GET_24BPP_FRAME_SIZE(w, h);
+ break;
+
+ // 32bpp
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ //case HAL_PIXEL_FORMAT_ARGB_8888:
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ //case HAL_PIXEL_FORMAT_ABGR_8888:
+
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ //case HAL_PIXEL_FORMAT_XRGB_8888:
+ //case HAL_PIXEL_FORMAT_BGRX_8888:
+ //case HAL_PIXEL_FORMAT_XBGR_8888:
+ frame_size = GET_32BPP_FRAME_SIZE(w, h);
+ break;
+
+ // 12bpp
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_420_P:
+ case HAL_PIXEL_FORMAT_YCbCr_420_I:
+ case HAL_PIXEL_FORMAT_CbYCrY_420_I:
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP:
+ size = w * h;
+ // frame_size = width * height * 3 / 2;
+ // sw5771.park : very curious...
+ // frame_size = size + ((size / 4) * 2);
+ frame_size = size + ((size >> 2) << 1);
+ break;
+
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED:
+ frame_size = ALIGN_TO_8KB(ALIGN_TO_128B(w) * ALIGN_TO_32B(h))
+ + ALIGN_TO_8KB(ALIGN_TO_128B(w) * ALIGN_TO_32B(h >> 1));
+ break;
+
+ // 16bpp
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ case HAL_PIXEL_FORMAT_YCbCr_422_P:
+ case HAL_PIXEL_FORMAT_CbYCrY_422_I:
+ case HAL_PIXEL_FORMAT_YCrCb_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I:
+ case HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I:
+ frame_size = GET_16BPP_FRAME_SIZE(w, h);
+ break;
+
+ default:
+ LOGD("%s::no matching source colorformat(0x%x), w(%d), h(%d) fail\n",
+ __func__, HAL_PIXEL_FORMAT, w, h);
+ break;
+ }
+
+ return frame_size;
+}
+
+#endif //__SAMSUNG_SYSLSI_SEC_COMMON_H__
diff --git a/init.herring.rc b/init.herring.rc
index 98596c6..551e66b 100755
--- a/init.herring.rc
+++ b/init.herring.rc
@@ -1,3 +1,5 @@
+import init.herring.usb.rc
+
on boot
mount debugfs /sys/kernel/debug /sys/kernel/debug
@@ -6,16 +8,14 @@ on boot
setprop ro.radio.noril yes
setprop ro.bt.bdaddr_path "/efs/bluetooth/bt_addr"
+ setprop ro.crypto.keyfile.userdata /efs/userdata_footer
+
# fake some battery state
setprop status.battery.state Slow
setprop status.battery.level 5
setprop status.battery.level_raw 50
setprop status.battery.level_scale 9
-# wi-fi
- mkdir /data/misc/wifi/sockets 0770 wifi wifi
- mkdir /data/misc/dhcp 0770 dhcp dhcp
-
# phone
setprop ro.telephony.call_ring.multiple 0
@@ -35,7 +35,11 @@ on fs
chmod 770 /efs/bluetooth
chmod 770 /efs/imei
mount ext4 /dev/block/platform/s3c-sdhci.0/by-name/system /system wait ro
- mount ext4 /dev/block/platform/s3c-sdhci.0/by-name/userdata /data wait noatime nosuid nodev
+ mount ext4 /dev/block/platform/s3c-sdhci.0/by-name/userdata /data wait noatime nosuid nodev nomblk_io_submit
+
+ export EXTERNAL_STORAGE /mnt/sdcard
+ mkdir /mnt/sdcard 0000 system system
+ symlink /mnt/sdcard /sdcard
# permissions for bluetooth.
chown bluetooth bluetooth /efs/bluetooth
@@ -58,24 +62,35 @@ on fs
# Permissions for System Server and daemons.
chown system system /sys/class/backlight/s5p_bl/brightness
+on post-fs-data
+# wi-fi
+ mkdir /data/misc/wifi/sockets 0770 wifi wifi
+ mkdir /data/misc/dhcp 0770 dhcp dhcp
+
+ setprop vold.post_fs_data_done 1
+
service gpsd /system/vendor/bin/gpsd -c /vendor/etc/gps.xml
+ class main
socket gps seqpacket 0660 gps system
user gps
group system inet
# create filesystems if necessary
service setup_fs /system/bin/setup_fs /dev/block/platform/s3c-sdhci.0/by-name/userdata
+ class core
user root
group root
oneshot
# 3D init
service pvrsrvinit /system/vendor/bin/pvrsrvinit
+ class core
user root
group root
oneshot
-service wpa_supplicant /system/bin/wpa_supplicant -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
+service wpa_supplicant /system/bin/wpa_supplicant -Dwext -iwlan0
+ class main
socket wpa_wlan0 dgram 0660 wifi wifi
disabled
oneshot
@@ -83,48 +98,57 @@ service wpa_supplicant /system/bin/wpa_supplicant -Dwext -iwlan0 -c/data/misc/wi
# DHCPCD
# wi-fi
service dhcpcd_wlan0 /system/bin/dhcpcd -ABKL
+ class main
disabled
oneshot
# wimax
service dhcpcd_uwbr0 /system/bin/dhcpcd -ABKL
+ class main
disabled
oneshot
# bluetooth
service dhcpcd_bnep0 /system/bin/dhcpcd -ABKL
+ class main
disabled
oneshot
# IP Renew
# wi-fi
service iprenew_wlan0 /system/bin/dhcpcd -n
+ class main
disabled
oneshot
# wimax
service iprenew_uwbr0 /system/bin/dhcpcd -n
+ class main
disabled
oneshot
# bluetooth
service iprenew_bnep0 /system/bin/dhcpcd -n
+ class main
disabled
oneshot
service hciattach /system/bin/brcm_patchram_plus --enable_hci --enable_lpm \
--baudrate 3000000 --patchram /vendor/firmware/bcm4329.hcd /dev/s3c2410_serial0
+ class main
user bluetooth
group bluetooth net_bt_admin
disabled
oneshot
# bugreport is triggered by holding down volume down, volume up and power
-service bugreport /system/bin/dumpstate -d -v -o /sdcard/bugreports/bugreport
+service bugreport /system/bin/bugmailer.sh -v
+ class main
disabled
oneshot
keycodes 114 115 116
service wimax_route /system/bin/route add default dev uwbr0
+ class main
disabled
oneshot
diff --git a/init.herring.usb.rc b/init.herring.usb.rc
new file mode 100644
index 0000000..b06a46e
--- /dev/null
+++ b/init.herring.usb.rc
@@ -0,0 +1,44 @@
+on boot
+ write /sys/class/android_usb/android0/iManufacturer $ro.product.manufacturer
+ write /sys/class/android_usb/android0/iProduct $ro.product.model
+ write /sys/class/android_usb/android0/iSerial $ro.serialno
+ write /sys/class/android_usb/android0/f_mass_storage/inquiry_string "Google Nexus S 0100"
+ write /sys/class/android_usb/android0/f_rndis/manufacturer Samsung
+ write /sys/class/android_usb/android0/f_rndis/vendorID 18d1
+ write /sys/class/android_usb/android0/f_rndis/wceis 1
+
+on property:sys.usb.config=mass_storage
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor 18d1
+ write /sys/class/android_usb/android0/idProduct 4e21
+ write /sys/class/android_usb/android0/functions $sys.usb.config
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state $sys.usb.config
+
+on property:sys.usb.config=mass_storage,adb
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor 18d1
+ write /sys/class/android_usb/android0/idProduct 4e22
+ write /sys/class/android_usb/android0/functions $sys.usb.config
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state $sys.usb.config
+
+on property:sys.usb.config=rndis
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor 18d1
+ write /sys/class/android_usb/android0/idProduct 4e23
+ write /sys/class/android_usb/android0/functions $sys.usb.config
+ write /sys/class/android_usb/android0/bDeviceClass 224
+ write /sys/class/android_usb/android0/enable 1
+ setprop sys.usb.state $sys.usb.config
+
+on property:sys.usb.config=rndis,adb
+ write /sys/class/android_usb/android0/enable 0
+ write /sys/class/android_usb/android0/idVendor 18d1
+ write /sys/class/android_usb/android0/idProduct 4e24
+ write /sys/class/android_usb/android0/functions $sys.usb.config
+ write /sys/class/android_usb/android0/bDeviceClass 224
+ write /sys/class/android_usb/android0/enable 1
+ start adbd
+ setprop sys.usb.state $sys.usb.config
diff --git a/kernel b/kernel
index 2dcbc70..114dcb8 100755..100644
--- a/kernel
+++ b/kernel
Binary files differ
diff --git a/libaudio/Android.mk b/libaudio/Android.mk
index 726859b..cbb925c 100644
--- a/libaudio/Android.mk
+++ b/libaudio/Android.mk
@@ -1,53 +1,41 @@
LOCAL_PATH:= $(call my-dir)
-ifneq ($(filter crespo crespo4g,$(TARGET_DEVICE)),)
-
-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)
+LOCAL_SRC_FILES:= \
+ AudioHardware.cpp
+
+LOCAL_MODULE := audio.primary.herring
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_STATIC_LIBRARIES:= libmedia_helper
+LOCAL_SHARED_LIBRARIES:= \
+ libutils \
+ libhardware_legacy \
+ libtinyalsa \
+ libaudioutils
+
+LOCAL_WHOLE_STATIC_LIBRARIES := libaudiohw_legacy
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SHARED_LIBRARIES += libdl
+LOCAL_C_INCLUDES += \
+ external/tinyalsa/include \
+ system/media/audio_effects/include \
+ system/media/audio_utils/include
-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 $(BUILD_SHARED_LIBRARY)
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)
+LOCAL_SRC_FILES := AudioPolicyManager.cpp
+LOCAL_SHARED_LIBRARIES := libcutils libutils libmedia
+LOCAL_STATIC_LIBRARIES := libmedia_helper
+LOCAL_WHOLE_STATIC_LIBRARIES := libaudiopolicy_legacy
+LOCAL_MODULE := audio_policy.herring
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_MODULE_TAGS := optional
-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)
-endif
+include $(BUILD_SHARED_LIBRARY)
diff --git a/libaudio/AudioHardware.cpp b/libaudio/AudioHardware.cpp
index eee5f17..a189510 100644
--- a/libaudio/AudioHardware.cpp
+++ b/libaudio/AudioHardware.cpp
@@ -17,7 +17,6 @@
#include <math.h>
//#define LOG_NDEBUG 0
-
#define LOG_TAG "AudioHardware"
#include <utils/Log.h>
@@ -34,17 +33,22 @@
#include "AudioHardware.h"
#include <media/AudioRecord.h>
-#include <hardware_legacy/power.h>
+#include <audio_effects/effect_aec.h>
extern "C" {
-#include "alsa_audio.h"
+#include <tinyalsa/asoundlib.h>
}
-namespace android {
+namespace android_audio_legacy {
-const uint32_t AudioHardware::inputSamplingRates[] = {
- 8000, 11025, 16000, 22050, 44100
+const uint32_t AudioHardware::inputConfigTable[][AudioHardware::INPUT_CONFIG_CNT] = {
+ {8000, 4},
+ {11025, 4},
+ {16000, 2},
+ {22050, 2},
+ {32000, 1},
+ {44100, 1}
};
// trace driver operations for dump
@@ -92,6 +96,7 @@ AudioHardware::AudioHardware() :
mSecRilLibHandle(NULL),
mRilClient(0),
mActivatedCP(false),
+ mEchoReference(NULL),
mDriverOp(DRV_NONE)
{
loadRILD();
@@ -242,6 +247,7 @@ AudioStreamOut* AudioHardware::openOutputStream(
void AudioHardware::closeOutputStream(AudioStreamOut* out) {
sp <AudioStreamOutALSA> spOut;
+ sp<AudioStreamInALSA> spIn;
{
Mutex::Autolock lock(mLock);
if (mOutput == 0 || mOutput.get() != out) {
@@ -250,7 +256,16 @@ void AudioHardware::closeOutputStream(AudioStreamOut* out) {
}
spOut = mOutput;
mOutput.clear();
+ if (mEchoReference != NULL) {
+ spIn = getActiveInput_l();
+ }
+ }
+ if (spIn != 0) {
+ // this will safely release the echo reference by calling releaseEchoReference()
+ // after placing the active input in standby
+ spIn->standby();
}
+
spOut.clear();
}
@@ -361,8 +376,10 @@ status_t AudioHardware::setMode(int mode)
status = AudioHardwareBase::setMode(mode);
LOGV("setMode() : new %d, old %d", mMode, prevMode);
if (status == NO_ERROR) {
+ bool modeNeedsCPActive = mMode == AudioSystem::MODE_IN_CALL ||
+ mMode == AudioSystem::MODE_RINGTONE;
// activate call clock in radio when entering in call or ringtone mode
- if (prevMode == AudioSystem::MODE_NORMAL)
+ if (modeNeedsCPActive)
{
if ((!mActivatedCP) && (mSecRilLibHandle) && (connectRILDIfRequired() == OK)) {
setCallClockSync(mRilClient, SOUND_CLOCK_START);
@@ -387,16 +404,16 @@ status_t AudioHardware::setMode(int mode)
setVoiceVolume_l(mVoiceVol);
mInCallAudioMode = true;
}
- if (mMode == AudioSystem::MODE_NORMAL && mInCallAudioMode) {
+ if (mMode != AudioSystem::MODE_IN_CALL && mInCallAudioMode) {
setInputSource_l(mInputSource);
if (mMixer != NULL) {
TRACE_DRIVER_IN(DRV_MIXER_GET)
- struct mixer_ctl *ctl= mixer_get_control(mMixer, "Playback Path", 0);
+ struct mixer_ctl *ctl= mixer_get_ctl_by_name(mMixer, "Playback Path");
TRACE_DRIVER_OUT
if (ctl != NULL) {
LOGV("setMode() reset Playback Path to RCV");
TRACE_DRIVER_IN(DRV_MIXER_SEL)
- mixer_ctl_select(ctl, "RCV");
+ mixer_ctl_set_enum_by_string(ctl, "RCV");
TRACE_DRIVER_OUT
}
}
@@ -416,7 +433,7 @@ status_t AudioHardware::setMode(int mode)
mInCallAudioMode = false;
}
- if (mMode == AudioSystem::MODE_NORMAL) {
+ if (!modeNeedsCPActive) {
if(mActivatedCP)
mActivatedCP = false;
}
@@ -533,8 +550,8 @@ size_t AudioHardware::getInputBufferSize(uint32_t sampleRate, int format, int ch
LOGW("getInputBufferSize bad channel count: %d", channelCount);
return 0;
}
- if (sampleRate != 8000 && sampleRate != 11025 && sampleRate != 16000 &&
- sampleRate != 22050 && sampleRate != 44100) {
+
+ if (sampleRate != getInputSampleRate(sampleRate)) {
LOGW("getInputBufferSize bad sample rate: %d", sampleRate);
return 0;
}
@@ -736,13 +753,13 @@ status_t AudioHardware::setIncallPath_l(uint32_t device)
if (mMixer != NULL) {
TRACE_DRIVER_IN(DRV_MIXER_GET)
- struct mixer_ctl *ctl= mixer_get_control(mMixer, "Voice Call Path", 0);
+ struct mixer_ctl *ctl= mixer_get_ctl_by_name(mMixer, "Voice Call Path");
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));
+ mixer_ctl_set_enum_by_string(ctl, getVoiceRouteFromDevice(device));
TRACE_DRIVER_OUT
}
}
@@ -762,14 +779,22 @@ struct pcm *AudioHardware::openPcmOut_l()
}
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;
+ struct pcm_config config = {
+ channels : 2,
+ rate : AUDIO_HW_OUT_SAMPLERATE,
+ period_size : AUDIO_HW_OUT_PERIOD_SZ,
+ period_count : AUDIO_HW_OUT_PERIOD_CNT,
+ format : PCM_FORMAT_S16_LE,
+ start_threshold : 0,
+ stop_threshold : 0,
+ silence_threshold : 0,
+ };
TRACE_DRIVER_IN(DRV_PCM_OPEN)
- mPcm = pcm_open(flags);
+ mPcm = pcm_open(0, 0, flags, &config);
TRACE_DRIVER_OUT
- if (!pcm_ready(mPcm)) {
- LOGE("openPcmOut_l() cannot open pcm_out driver: %s\n", pcm_error(mPcm));
+ if (!pcm_is_ready(mPcm)) {
+ LOGE("openPcmOut_l() cannot open pcm_out driver: %s\n", pcm_get_error(mPcm));
TRACE_DRIVER_IN(DRV_PCM_CLOSE)
pcm_close(mPcm);
TRACE_DRIVER_OUT
@@ -806,7 +831,7 @@ struct mixer *AudioHardware::openMixer_l()
return NULL;
}
TRACE_DRIVER_IN(DRV_MIXER_OPEN)
- mMixer = mixer_open();
+ mMixer = mixer_open(0);
TRACE_DRIVER_OUT
if (mMixer == NULL) {
LOGE("openMixer_l() cannot open mixer");
@@ -913,16 +938,17 @@ const char *AudioHardware::getInputRouteFromDevice(uint32_t device)
uint32_t AudioHardware::getInputSampleRate(uint32_t sampleRate)
{
- uint32_t i;
+ size_t i;
uint32_t prevDelta;
uint32_t delta;
+ size_t size = sizeof(inputConfigTable)/sizeof(uint32_t)/INPUT_CONFIG_CNT;
- for (i = 0, prevDelta = 0xFFFFFFFF; i < sizeof(inputSamplingRates)/sizeof(uint32_t); i++, prevDelta = delta) {
- delta = abs(sampleRate - inputSamplingRates[i]);
+ for (i = 0, prevDelta = 0xFFFFFFFF; i < size; i++, prevDelta = delta) {
+ delta = abs(sampleRate - inputConfigTable[i][INPUT_CONFIG_SAMPLE_RATE]);
if (delta > prevDelta) break;
}
// i is always > 0 here
- return inputSamplingRates[i-1];
+ return inputConfigTable[i-1][INPUT_CONFIG_SAMPLE_RATE];
}
// getActiveInput_l() must be called with mLock held
@@ -949,7 +975,7 @@ status_t AudioHardware::setInputSource_l(audio_source source)
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);
+ struct mixer_ctl *ctl= mixer_get_ctl_by_name(mMixer, "Input Source");
TRACE_DRIVER_OUT
if (ctl == NULL) {
return NO_INIT;
@@ -973,9 +999,9 @@ status_t AudioHardware::setInputSource_l(audio_source source)
default:
return NO_INIT;
}
- LOGV("mixer_ctl_select, Input Source, (%s)", sourceName);
+ LOGV("mixer_ctl_set_enum_by_string, Input Source, (%s)", sourceName);
TRACE_DRIVER_IN(DRV_MIXER_SEL)
- mixer_ctl_select(ctl, sourceName);
+ mixer_ctl_set_enum_by_string(ctl, sourceName);
TRACE_DRIVER_OUT
}
}
@@ -985,6 +1011,42 @@ status_t AudioHardware::setInputSource_l(audio_source source)
return NO_ERROR;
}
+struct echo_reference_itfe *AudioHardware::getEchoReference(audio_format_t format,
+ uint32_t channelCount,
+ uint32_t samplingRate)
+{
+ LOGV("AudioHardware::getEchoReference %p", mEchoReference);
+ releaseEchoReference(mEchoReference);
+ if (mOutput != NULL) {
+ uint32_t wrChannelCount = popcount(mOutput->channels());
+ uint32_t wrSampleRate = mOutput->sampleRate();
+
+ int status = create_echo_reference(AUDIO_FORMAT_PCM_16_BIT,
+ channelCount,
+ samplingRate,
+ AUDIO_FORMAT_PCM_16_BIT,
+ wrChannelCount,
+ wrSampleRate,
+ &mEchoReference);
+ if (status == 0) {
+ mOutput->addEchoReference(mEchoReference);
+ }
+ }
+ return mEchoReference;
+}
+
+void AudioHardware::releaseEchoReference(struct echo_reference_itfe *reference)
+{
+ LOGV("AudioHardware::releaseEchoReference %p", mEchoReference);
+ if (mEchoReference != NULL && reference == mEchoReference) {
+ if (mOutput != NULL) {
+ mOutput->removeEchoReference(reference);
+ }
+ release_echo_reference(mEchoReference);
+ mEchoReference = NULL;
+ }
+}
+
//------------------------------------------------------------------------------
// AudioStreamOutALSA
@@ -994,7 +1056,7 @@ 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)
+ mDriverOp(DRV_NONE), mStandbyCnt(0), mSleepReq(false), mEchoReference(NULL)
{
}
@@ -1040,9 +1102,40 @@ AudioHardware::AudioStreamOutALSA::~AudioStreamOutALSA()
standby();
}
+int AudioHardware::AudioStreamOutALSA::getPlaybackDelay(size_t frames,
+ struct echo_reference_buffer *buffer)
+{
+ size_t kernelFr;
+
+ int rc = pcm_get_htimestamp(mPcm, &kernelFr, &buffer->time_stamp);
+ if (rc < 0) {
+ buffer->time_stamp.tv_sec = 0;
+ buffer->time_stamp.tv_nsec = 0;
+ buffer->delay_ns = 0;
+ LOGV("getPlaybackDelay(): pcm_get_htimestamp error, setting playbackTimestamp to 0");
+ return rc;
+ }
+
+ kernelFr = pcm_get_buffer_size(mPcm) - kernelFr;
+
+ // adjust render time stamp with delay added by current driver buffer.
+ // Add the duration of current frame as we want the render time of the last
+ // sample being written.
+ long delayNs = (long)(((int64_t)(kernelFr + frames)* 1000000000) /AUDIO_HW_OUT_SAMPLERATE);
+
+ LOGV("AudioStreamOutALSA::getPlaybackDelay delayNs: [%ld], "\
+ "kernelFr:[%d], frames:[%d], buffSize:[%d], time_stamp:[%ld].[%ld]",
+ delayNs, (int)kernelFr, (int)frames, pcm_get_buffer_size(mPcm),
+ (long)buffer->time_stamp.tv_sec, buffer->time_stamp.tv_nsec);
+
+ buffer->delay_ns = delayNs;
+
+ return 0;
+}
+
ssize_t AudioHardware::AudioStreamOutALSA::write(const void* buffer, size_t bytes)
{
- // LOGV("AudioStreamOutALSA::write(%p, %u)", buffer, bytes);
+ LOGV("-----AudioStreamInALSA::write(%p, %d) START", buffer, (int)bytes);
status_t status = NO_INIT;
const uint8_t* p = static_cast<const uint8_t*>(buffer);
int ret;
@@ -1063,8 +1156,6 @@ ssize_t AudioHardware::AudioStreamOutALSA::write(const void* buffer, size_t byte
AutoMutex hwLock(mHardware->lock());
LOGD("AudioHardware pcm playback is exiting standby.");
- acquire_wake_lock (PARTIAL_WAKE_LOCK, "AudioOutLock");
-
sp<AudioStreamInALSA> spIn = mHardware->getActiveInput_l();
while (spIn != 0) {
int cnt = spIn->prepareLock();
@@ -1096,29 +1187,37 @@ ssize_t AudioHardware::AudioStreamOutALSA::write(const void* buffer, size_t byte
spIn->unlock();
}
if (mPcm == NULL) {
- release_wake_lock("AudioOutLock");
goto Error;
}
mStandby = false;
}
+ if (mEchoReference != NULL) {
+ struct echo_reference_buffer b;
+ b.raw = (void *)buffer;
+ b.frame_count = bytes / frameSize();
+
+ getPlaybackDelay(bytes / frameSize(), &b);
+ mEchoReference->write(mEchoReference, &b);
+ }
+
TRACE_DRIVER_IN(DRV_PCM_WRITE)
ret = pcm_write(mPcm,(void*) p, bytes);
TRACE_DRIVER_OUT
if (ret == 0) {
+ LOGV("-----AudioStreamInALSA::write(%p, %d) END", buffer, (int)bytes);
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());
-
+ LOGE("AudioStreamOutALSA::write END WITH ERROR !!!!!!!!!(%p, %u)", buffer, bytes);
return status;
}
@@ -1147,7 +1246,10 @@ void AudioHardware::AudioStreamOutALSA::doStandby_l()
if (!mStandby) {
LOGD("AudioHardware pcm playback is going to standby.");
- release_wake_lock("AudioOutLock");
+ // stop echo reference capture
+ if (mEchoReference != NULL) {
+ mEchoReference->write(mEchoReference, NULL);
+ }
mStandby = true;
}
@@ -1179,7 +1281,7 @@ status_t AudioHardware::AudioStreamOutALSA::open_l()
if (mMixer) {
LOGV("open playback normal");
TRACE_DRIVER_IN(DRV_MIXER_GET)
- mRouteCtl = mixer_get_control(mMixer, "Playback Path", 0);
+ mRouteCtl = mixer_get_ctl_by_name(mMixer, "Playback Path");
TRACE_DRIVER_OUT
}
if (mHardware->mode() != AudioSystem::MODE_IN_CALL) {
@@ -1187,7 +1289,7 @@ status_t AudioHardware::AudioStreamOutALSA::open_l()
LOGV("write() wakeup setting route %s", route);
if (mRouteCtl) {
TRACE_DRIVER_IN(DRV_MIXER_SEL)
- mixer_ctl_select(mRouteCtl, route);
+ mixer_ctl_set_enum_by_string(mRouteCtl, route);
TRACE_DRIVER_OUT
}
}
@@ -1317,6 +1419,24 @@ void AudioHardware::AudioStreamOutALSA::unlock() {
mLock.unlock();
}
+void AudioHardware::AudioStreamOutALSA::addEchoReference(struct echo_reference_itfe *reference)
+{
+ LOGV("AudioStreamOutALSA::addEchoReference %p", mEchoReference);
+ if (mEchoReference == NULL) {
+ mEchoReference = reference;
+ }
+}
+
+void AudioHardware::AudioStreamOutALSA::removeEchoReference(struct echo_reference_itfe *reference)
+{
+ LOGV("AudioStreamOutALSA::removeEchoReference %p", mEchoReference);
+ if (mEchoReference == reference) {
+ mEchoReference->write(mEchoReference, NULL);
+ mEchoReference = NULL;
+ }
+}
+
+
//------------------------------------------------------------------------------
// AudioStreamInALSA
//------------------------------------------------------------------------------
@@ -1325,8 +1445,10 @@ 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)
+ mDownSampler(NULL), mReadStatus(NO_ERROR), mInputBuf(NULL),
+ mDriverOp(DRV_NONE), mStandbyCnt(0), mSleepReq(false),
+ mProcBuf(NULL), mProcBufSize(0), mRefBuf(NULL), mRefBufSize(0),
+ mEchoReference(NULL), mNeedEchoReference(false)
{
}
@@ -1363,38 +1485,283 @@ status_t AudioHardware::AudioStreamInALSA::set(
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;
+ mBufferProvider.mProvider.get_next_buffer = getNextBufferStatic;
+ mBufferProvider.mProvider.release_buffer = releaseBufferStatic;
+ mBufferProvider.mInputStream = this;
+ int status = create_resampler(AUDIO_HW_OUT_SAMPLERATE,
+ mSampleRate,
+ mChannelCount,
+ RESAMPLER_QUALITY_VOIP,
+ &mBufferProvider.mProvider,
+ &mDownSampler);
+ if (status != 0) {
LOGW("AudioStreamInALSA::set() downsampler init failed: %d", status);
+ mDownSampler = NULL;
return status;
}
-
- mPcmIn = new int16_t[AUDIO_HW_IN_PERIOD_SZ * mChannelCount];
}
+ mInputBuf = 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;
+ release_resampler(mDownSampler);
+ }
+ delete[] mInputBuf;
+ delete[] mProcBuf;
+}
+
+// readFrames() reads frames from kernel driver, down samples to capture rate if necessary
+// and output the number of frames requested to the buffer specified
+ssize_t AudioHardware::AudioStreamInALSA::readFrames(void* buffer, ssize_t frames)
+{
+ ssize_t framesWr = 0;
+ while (framesWr < frames) {
+ size_t framesRd = frames - framesWr;
+ if (mDownSampler != NULL) {
+ mDownSampler->resample_from_provider(mDownSampler,
+ (int16_t *)((char *)buffer + framesWr * frameSize()),
+ &framesRd);
+ } else {
+ struct resampler_buffer buf = {
+ { raw : NULL, },
+ frame_count : framesRd,
+ };
+ getNextBuffer(&buf);
+ if (buf.raw != NULL) {
+ memcpy((char *)buffer + framesWr * frameSize(),
+ buf.raw,
+ buf.frame_count * frameSize());
+ framesRd = buf.frame_count;
+ }
+ releaseBuffer(&buf);
+ }
+ // mReadStatus is updated by getNextBuffer() also called by
+ // mDownSampler->resample_from_provider()
+ if (mReadStatus != 0) {
+ return mReadStatus;
+ }
+ framesWr += framesRd;
+ }
+ return framesWr;
+}
+
+// processFrames() reads frames from kernel driver (via readFrames()), calls the active
+// audio pre processings and output the number of frames requested to the buffer specified
+ssize_t AudioHardware::AudioStreamInALSA::processFrames(void* buffer, ssize_t frames)
+{
+ ssize_t framesWr = 0;
+ while (framesWr < frames) {
+ // first reload enough frames at the end of process input buffer
+ if (mProcFramesIn < (size_t)frames) {
+ // expand process input buffer if necessary
+ if (mProcBufSize < (size_t)frames) {
+ mProcBufSize = (size_t)frames;
+ mProcBuf = (int16_t *)realloc(mProcBuf,
+ mProcBufSize * mChannelCount * sizeof(int16_t));
+ LOGV("processFrames(): mProcBuf %p size extended to %d frames",
+ mProcBuf, mProcBufSize);
+ }
+ ssize_t framesRd = readFrames(mProcBuf + mProcFramesIn * mChannelCount,
+ frames - mProcFramesIn);
+ if (framesRd < 0) {
+ framesWr = framesRd;
+ break;
+ }
+ mProcFramesIn += framesRd;
+ }
+
+ if (mEchoReference != NULL) {
+ pushEchoReference(mProcFramesIn);
}
+
+ //inBuf.frameCount and outBuf.frameCount indicate respectively the maximum number of frames
+ //to be consumed and produced by process()
+ audio_buffer_t inBuf = {
+ mProcFramesIn,
+ {mProcBuf}
+ };
+ audio_buffer_t outBuf = {
+ frames - framesWr,
+ {(int16_t *)buffer + framesWr * mChannelCount}
+ };
+
+ for (size_t i = 0; i < mPreprocessors.size(); i++) {
+ (*mPreprocessors[i])->process(mPreprocessors[i],
+ &inBuf,
+ &outBuf);
+ }
+
+ // process() has updated the number of frames consumed and produced in
+ // inBuf.frameCount and outBuf.frameCount respectively
+ // move remaining frames to the beginning of mProcBuf
+ mProcFramesIn -= inBuf.frameCount;
+ if (mProcFramesIn) {
+ memcpy(mProcBuf,
+ mProcBuf + inBuf.frameCount * mChannelCount,
+ mProcFramesIn * mChannelCount * sizeof(int16_t));
+ }
+
+ // if not enough frames were passed to process(), read more and retry.
+ if (outBuf.frameCount == 0) {
+ continue;
+ }
+ framesWr += outBuf.frameCount;
}
+ return framesWr;
+}
+
+int32_t AudioHardware::AudioStreamInALSA::updateEchoReference(size_t frames)
+{
+ struct echo_reference_buffer b;
+ b.delay_ns = 0;
+
+ LOGV("updateEchoReference1 START, frames = [%d], mRefFramesIn = [%d], b.frame_count = [%d]",
+ frames, mRefFramesIn, frames - mRefFramesIn);
+ if (mRefFramesIn < frames) {
+ if (mRefBufSize < frames) {
+ mRefBufSize = frames;
+ mRefBuf = (int16_t *)realloc(mRefBuf,
+ mRefBufSize * mChannelCount * sizeof(int16_t));
+ }
+
+ b.frame_count = frames - mRefFramesIn;
+ b.raw = (void *)(mRefBuf + mRefFramesIn * mChannelCount);
+
+ getCaptureDelay(frames, &b);
+
+ if (mEchoReference->read(mEchoReference, &b) == NO_ERROR)
+ {
+ mRefFramesIn += b.frame_count;
+ LOGV("updateEchoReference2: mRefFramesIn:[%d], mRefBufSize:[%d], "\
+ "frames:[%d], b.frame_count:[%d]", mRefFramesIn, mRefBufSize,frames,b.frame_count);
+ }
+
+ }else{
+ LOGV("updateEchoReference3: NOT enough frames to read ref buffer");
+ }
+ return b.delay_ns;
+}
+
+void AudioHardware::AudioStreamInALSA::pushEchoReference(size_t frames)
+{
+ // read frames from echo reference buffer and update echo delay
+ // mRefFramesIn is updated with frames available in mRefBuf
+ int32_t delayUs = (int32_t)(updateEchoReference(frames)/1000);
+
+ if (mRefFramesIn < frames) {
+ frames = mRefFramesIn;
+ }
+
+ audio_buffer_t refBuf = {
+ frames,
+ {mRefBuf}
+ };
+
+ for (size_t i = 0; i < mPreprocessors.size(); i++) {
+ if ((*mPreprocessors[i])->process_reverse == NULL) {
+ continue;
+ }
+ (*mPreprocessors[i])->process_reverse(mPreprocessors[i],
+ &refBuf,
+ NULL);
+ setPreProcessorEchoDelay(mPreprocessors[i], delayUs);
+ }
+
+ mRefFramesIn -= refBuf.frameCount;
+ if (mRefFramesIn) {
+ LOGV("pushEchoReference5: shifting mRefBuf down by = %d frames", mRefFramesIn);
+ memcpy(mRefBuf,
+ mRefBuf + refBuf.frameCount * mChannelCount,
+ mRefFramesIn * mChannelCount * sizeof(int16_t));
+ }
+}
+
+status_t AudioHardware::AudioStreamInALSA::setPreProcessorEchoDelay(effect_handle_t handle,
+ int32_t delayUs)
+{
+ uint32_t buf[sizeof(effect_param_t) / sizeof(uint32_t) + 2];
+ effect_param_t *param = (effect_param_t *)buf;
+
+ param->psize = sizeof(uint32_t);
+ param->vsize = sizeof(uint32_t);
+ *(uint32_t *)param->data = AEC_PARAM_ECHO_DELAY;
+ *((int32_t *)param->data + 1) = delayUs;
+
+ LOGV("setPreProcessorEchoDelay: %d us", delayUs);
+
+ return setPreprocessorParam(handle, param);
+}
+
+status_t AudioHardware::AudioStreamInALSA::setPreprocessorParam(effect_handle_t handle,
+ effect_param_t *param)
+{
+ uint32_t size = sizeof(int);
+ uint32_t psize = ((param->psize - 1) / sizeof(int) + 1) * sizeof(int) + param->vsize;
+
+ status_t status = (*handle)->command(handle,
+ EFFECT_CMD_SET_PARAM,
+ sizeof (effect_param_t) + psize,
+ param,
+ &size,
+ &param->status);
+ if (status == NO_ERROR) {
+ status = param->status;
+ }
+ return status;
+}
+
+void AudioHardware::AudioStreamInALSA::getCaptureDelay(size_t frames,
+ struct echo_reference_buffer *buffer)
+{
+
+ // read frames available in kernel driver buffer
+ size_t kernelFr;
+ struct timespec tstamp;
+
+ if (pcm_get_htimestamp(mPcm, &kernelFr, &tstamp) < 0) {
+ buffer->time_stamp.tv_sec = 0;
+ buffer->time_stamp.tv_nsec = 0;
+ buffer->delay_ns = 0;
+ LOGW("read getCaptureDelay(): pcm_htimestamp error");
+ return;
+ }
+
+ // read frames available in audio HAL input buffer
+ // add number of frames being read as we want the capture time of first sample in current
+ // buffer
+ long bufDelay = (long)(((int64_t)(mInputFramesIn + mProcFramesIn) * 1000000000)
+ / AUDIO_HW_IN_SAMPLERATE);
+ // add delay introduced by resampler
+ long rsmpDelay = 0;
+ if (mDownSampler) {
+ rsmpDelay = mDownSampler->delay_ns(mDownSampler);
+ }
+
+ long kernelDelay = (long)(((int64_t)kernelFr * 1000000000) / AUDIO_HW_IN_SAMPLERATE);
+
+ // correct capture time stamp
+ long delayNs = kernelDelay + bufDelay + rsmpDelay;
+
+ buffer->time_stamp = tstamp;
+ buffer->delay_ns = delayNs;
+ LOGV("AudioStreamInALSA::getCaptureDelay TimeStamp = [%ld].[%ld], delayCaptureNs: [%d],"\
+ " kernelDelay:[%ld], bufDelay:[%ld], rsmpDelay:[%ld], kernelFr:[%d], "\
+ "mInputFramesIn:[%d], mProcFramesIn:[%d], frames:[%d]",
+ buffer->time_stamp.tv_sec , buffer->time_stamp.tv_nsec, buffer->delay_ns,
+ kernelDelay, bufDelay, rsmpDelay, kernelFr, mInputFramesIn, mProcFramesIn, frames);
+
}
ssize_t AudioHardware::AudioStreamInALSA::read(void* buffer, ssize_t bytes)
{
- // LOGV("AudioStreamInALSA::read(%p, %u)", buffer, bytes);
+ LOGV("-----AudioStreamInALSA::read(%p, %d) START", buffer, (int)bytes);
status_t status = NO_INIT;
- int ret;
if (mHardware == NULL) return NO_INIT;
@@ -1411,38 +1778,38 @@ ssize_t AudioHardware::AudioStreamInALSA::read(void* buffer, ssize_t bytes)
AutoMutex hwLock(mHardware->lock());
LOGD("AudioHardware pcm capture is exiting standby.");
- acquire_wake_lock (PARTIAL_WAKE_LOCK, "AudioInLock");
-
sp<AudioStreamOutALSA> 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->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()) {
+ break;
}
+ spOut->unlock();
+ spOut = mHardware->output();
}
- // 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();
+ if (!spOut->checkStandby()) {
+ LOGV("AudioStreamInALSA::read() force output standby");
+ spOut->close_l();
+ if (spOut->open_l() != NO_ERROR) {
+ spOut->doStandby_l();
+ }
+ }
+ LOGV("AudioStreamInALSA exit standby mNeedEchoReference %d mEchoReference %p",
+ mNeedEchoReference, mEchoReference);
+ if (mNeedEchoReference && mEchoReference == NULL) {
+ mEchoReference = mHardware->getEchoReference(AUDIO_FORMAT_PCM_16_BIT,
+ mChannelCount,
+ mSampleRate);
}
spOut->unlock();
}
@@ -1450,38 +1817,27 @@ ssize_t AudioHardware::AudioStreamInALSA::read(void* buffer, ssize_t bytes)
open_l();
if (mPcm == NULL) {
- release_wake_lock("AudioInLock");
goto Error;
}
mStandby = false;
}
+ size_t framesRq = bytes / mChannelCount/sizeof(int16_t);
+ ssize_t framesRd;
- 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();
+ if (mPreprocessors.size() == 0) {
+ framesRd = readFrames(buffer, framesRq);
} else {
- TRACE_DRIVER_IN(DRV_PCM_READ)
- ret = pcm_read(mPcm, buffer, bytes);
- TRACE_DRIVER_OUT
+ framesRd = processFrames(buffer, framesRq);
}
- if (ret == 0) {
- return bytes;
+ if (framesRd >= 0) {
+ LOGV("-----AudioStreamInALSA::read(%p, %d) END", buffer, (int)bytes);
+ return framesRd * mChannelCount * sizeof(int16_t);
}
- LOGW("read error: %d", ret);
- status = ret;
+ LOGW("read error: %d", (int)framesRd);
+ status = framesRd;
}
Error:
@@ -1490,7 +1846,7 @@ Error:
// Simulate audio output timing in case of error
usleep((((bytes * 1000) / frameSize()) * 1000) / sampleRate());
-
+ LOGE("-----AudioStreamInALSA::read(%p, %d) END ERROR", buffer, (int)bytes);
return status;
}
@@ -1518,7 +1874,24 @@ void AudioHardware::AudioStreamInALSA::doStandby_l()
if (!mStandby) {
LOGD("AudioHardware pcm capture is going to standby.");
- release_wake_lock("AudioInLock");
+ if (mEchoReference != NULL) {
+ // stop reading from echo reference
+ mEchoReference->read(mEchoReference, NULL);
+ // Mutex acquisition order is always out -> in -> hw
+ sp<AudioStreamOutALSA> spOut = mHardware->output();
+ if (spOut != 0) {
+ spOut->prepareLock();
+ mHardware->lock().unlock();
+ mLock.unlock();
+ spOut->lock();
+ mLock.lock();
+ mHardware->lock().lock();
+ mHardware->releaseEchoReference(mEchoReference);
+ spOut->unlock();
+ }
+ mEchoReference = NULL;
+ }
+
mStandby = true;
}
close_l();
@@ -1538,24 +1911,36 @@ void AudioHardware::AudioStreamInALSA::close_l()
TRACE_DRIVER_OUT
mPcm = NULL;
}
+
+ delete[] mProcBuf;
+ mProcBuf = NULL;
+ mProcBufSize = 0;
+ delete[] mRefBuf;
+ mRefBuf = NULL;
+ mRefBufSize = 0;
}
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;
+
+ struct pcm_config config = {
+ channels : mChannelCount,
+ rate : AUDIO_HW_IN_SAMPLERATE,
+ period_size : AUDIO_HW_IN_PERIOD_SZ,
+ period_count : AUDIO_HW_IN_PERIOD_CNT,
+ format : PCM_FORMAT_S16_LE,
+ start_threshold : 0,
+ stop_threshold : 0,
+ silence_threshold : 0,
+ };
LOGV("open pcm_in driver");
TRACE_DRIVER_IN(DRV_PCM_OPEN)
- mPcm = pcm_open(flags);
+ mPcm = pcm_open(0, 0, flags, &config);
TRACE_DRIVER_OUT
- if (!pcm_ready(mPcm)) {
- LOGE("cannot open pcm_in driver: %s\n", pcm_error(mPcm));
+ if (!pcm_is_ready(mPcm)) {
+ LOGE("cannot open pcm_in driver: %s\n", pcm_get_error(mPcm));
TRACE_DRIVER_IN(DRV_PCM_CLOSE)
pcm_close(mPcm);
TRACE_DRIVER_OUT
@@ -1564,14 +1949,19 @@ status_t AudioHardware::AudioStreamInALSA::open_l()
}
if (mDownSampler != NULL) {
- mInPcmInBuf = 0;
- mDownSampler->reset();
+ mDownSampler->reset(mDownSampler);
}
+ mInputFramesIn = 0;
+
+ mProcBufSize = 0;
+ mProcFramesIn = 0;
+ mRefBufSize = 0;
+ mRefFramesIn = 0;
mMixer = mHardware->openMixer_l();
if (mMixer) {
TRACE_DRIVER_IN(DRV_MIXER_GET)
- mRouteCtl = mixer_get_control(mMixer, "Capture MIC Path", 0);
+ mRouteCtl = mixer_get_ctl_by_name(mMixer, "Capture MIC Path");
TRACE_DRIVER_OUT
}
@@ -1580,7 +1970,7 @@ status_t AudioHardware::AudioStreamInALSA::open_l()
LOGV("read() wakeup setting route %s", route);
if (mRouteCtl) {
TRACE_DRIVER_IN(DRV_MIXER_SEL)
- mixer_ctl_select(mRouteCtl, route);
+ mixer_ctl_set_enum_by_string(mRouteCtl, route);
TRACE_DRIVER_OUT
}
}
@@ -1693,58 +2083,123 @@ String8 AudioHardware::AudioStreamInALSA::getParameters(const String8& keys)
return param.toString();
}
-status_t AudioHardware::AudioStreamInALSA::getNextBuffer(AudioHardware::BufferProvider::Buffer* buffer)
+status_t AudioHardware::AudioStreamInALSA::addAudioEffect(effect_handle_t effect)
+{
+ LOGV("AudioStreamInALSA::addAudioEffect() %p", effect);
+
+ effect_descriptor_t desc;
+ status_t status = (*effect)->get_descriptor(effect, &desc);
+ if (status == 0) {
+ if (memcmp(&desc.type, FX_IID_AEC, sizeof(effect_uuid_t)) == 0) {
+ LOGV("AudioStreamInALSA::addAudioEffect() mNeedEchoReference true");
+ mNeedEchoReference = true;
+ standby();
+ }
+ LOGV("AudioStreamInALSA::addAudioEffect() name %s", desc.name);
+ } else {
+ LOGV("AudioStreamInALSA::addAudioEffect() get_descriptor() error");
+ }
+
+ AutoMutex lock(mLock);
+ mPreprocessors.add(effect);
+ return NO_ERROR;
+}
+
+status_t AudioHardware::AudioStreamInALSA::removeAudioEffect(effect_handle_t effect)
+{
+ status_t status = INVALID_OPERATION;
+ LOGV("AudioStreamInALSA::removeAudioEffect() %p", effect);
+ {
+ AutoMutex lock(mLock);
+ for (size_t i = 0; i < mPreprocessors.size(); i++) {
+ if (mPreprocessors[i] == effect) {
+ mPreprocessors.removeAt(i);
+ status = NO_ERROR;
+ break;
+ }
+ }
+ }
+
+ if (status == NO_ERROR) {
+ effect_descriptor_t desc;
+ if ((*effect)->get_descriptor(effect, &desc) == 0) {
+ if (memcmp(&desc.type, FX_IID_AEC, sizeof(effect_uuid_t)) == 0) {
+ LOGV("AudioStreamInALSA::removeAudioEffect() mNeedEchoReference false");
+ mNeedEchoReference = false;
+ standby();
+ }
+ }
+ }
+
+ return status;
+}
+
+extern "C" {
+int AudioHardware::AudioStreamInALSA::getNextBufferStatic(
+ struct resampler_buffer_provider *provider,
+ struct resampler_buffer* buffer)
+{
+ ResamplerBufferProvider *bufferProvider = (ResamplerBufferProvider *)provider;
+ return bufferProvider->mInputStream->getNextBuffer(buffer);
+}
+
+void AudioHardware::AudioStreamInALSA::releaseBufferStatic(
+ struct resampler_buffer_provider *provider,
+ struct resampler_buffer* buffer)
+{
+ ResamplerBufferProvider *bufferProvider = (ResamplerBufferProvider *)provider;
+ return bufferProvider->mInputStream->releaseBuffer(buffer);
+}
+
+}; // extern "C"
+
+status_t AudioHardware::AudioStreamInALSA::getNextBuffer(struct resampler_buffer *buffer)
{
if (mPcm == NULL) {
buffer->raw = NULL;
- buffer->frameCount = 0;
+ buffer->frame_count = 0;
mReadStatus = NO_INIT;
return NO_INIT;
}
- if (mInPcmInBuf == 0) {
+ if (mInputFramesIn == 0) {
TRACE_DRIVER_IN(DRV_PCM_READ)
- mReadStatus = pcm_read(mPcm,(void*) mPcmIn, AUDIO_HW_IN_PERIOD_SZ * frameSize());
+ mReadStatus = pcm_read(mPcm,(void*) mInputBuf, AUDIO_HW_IN_PERIOD_SZ * frameSize());
TRACE_DRIVER_OUT
if (mReadStatus != 0) {
buffer->raw = NULL;
- buffer->frameCount = 0;
+ buffer->frame_count = 0;
return mReadStatus;
}
- mInPcmInBuf = AUDIO_HW_IN_PERIOD_SZ;
+ mInputFramesIn = AUDIO_HW_IN_PERIOD_SZ;
}
- buffer->frameCount = (buffer->frameCount > mInPcmInBuf) ? mInPcmInBuf : buffer->frameCount;
- buffer->i16 = mPcmIn + (AUDIO_HW_IN_PERIOD_SZ - mInPcmInBuf) * mChannelCount;
+ buffer->frame_count = (buffer->frame_count > mInputFramesIn) ? mInputFramesIn:buffer->frame_count;
+ buffer->i16 = mInputBuf + (AUDIO_HW_IN_PERIOD_SZ - mInputFramesIn) * mChannelCount;
return mReadStatus;
}
-void AudioHardware::AudioStreamInALSA::releaseBuffer(Buffer* buffer)
+void AudioHardware::AudioStreamInALSA::releaseBuffer(struct resampler_buffer *buffer)
{
- mInPcmInBuf -= buffer->frameCount;
+ mInputFramesIn -= buffer->frame_count;
}
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;
- }
+ size_t i;
+ size_t size = sizeof(inputConfigTable)/sizeof(uint32_t)/INPUT_CONFIG_CNT;
- return (AUDIO_HW_IN_PERIOD_SZ*channelCount*sizeof(int16_t)) / ratio ;
+ for (i = 0; i < size; i++) {
+ if (sampleRate == inputConfigTable[i][INPUT_CONFIG_SAMPLE_RATE]) {
+ return (AUDIO_HW_IN_PERIOD_SZ*channelCount*sizeof(int16_t)) /
+ inputConfigTable[i][INPUT_CONFIG_BUFFER_RATIO];
+ }
+ }
+ // this should never happen as getBufferSize() is always called after getInputSampleRate()
+ // that checks for valid sampling rates.
+ LOGE("AudioStreamInALSA::getBufferSize() invalid sampling rate %d", sampleRate);
+ return 0;
}
int AudioHardware::AudioStreamInALSA::prepareLock()
@@ -1766,375 +2221,6 @@ void AudioHardware::AudioStreamInALSA::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
//------------------------------------------------------------------------------
diff --git a/libaudio/AudioHardware.h b/libaudio/AudioHardware.h
index fb94e95..1148478 100644
--- a/libaudio/AudioHardware.h
+++ b/libaudio/AudioHardware.h
@@ -25,16 +25,27 @@
#include <hardware_legacy/AudioHardwareBase.h>
#include <media/mediarecorder.h>
+#include <hardware/audio_effect.h>
#include "secril-client.h"
+#include <audio_utils/resampler.h>
+#include <audio_utils/echo_reference.h>
+
extern "C" {
struct pcm;
struct mixer;
struct mixer_ctl;
};
-namespace android {
+namespace android_audio_legacy {
+ using android::AutoMutex;
+ using android::Mutex;
+ using android::RefBase;
+ using android::SortedVector;
+ using android::sp;
+ using android::String16;
+ using android::Vector;
// TODO: determine actual audio DSP and hardware latency
// Additionnal latency introduced by audio DSP and hardware in ms
@@ -46,24 +57,20 @@ namespace android {
// 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_SZ 448
#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
+#define AUDIO_HW_IN_SAMPLERATE 44100
// 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
+#define AUDIO_HW_IN_PERIOD_SZ 448
+#define AUDIO_HW_IN_PERIOD_CNT 4
// Default audio input buffer size in bytes (8kHz mono)
#define AUDIO_HW_IN_PERIOD_BYTES ((AUDIO_HW_IN_PERIOD_SZ*sizeof(int16_t))/8)
@@ -72,6 +79,7 @@ class AudioHardware : public AudioHardwareBase
{
class AudioStreamOutALSA;
class AudioStreamInALSA;
+
public:
// input path names used to translate from input sources to driver paths
@@ -133,6 +141,11 @@ public:
sp <AudioStreamOutALSA> output() { return mOutput; }
+ struct echo_reference_itfe *getEchoReference(audio_format_t format,
+ uint32_t channelCount,
+ uint32_t samplingRate);
+ void releaseEchoReference(struct echo_reference_itfe *reference);
+
protected:
virtual status_t dump(int fd, const Vector<String16>& args);
@@ -174,12 +187,23 @@ private:
int (*setCallClockSync)(HRilClient, SoundClockCondition);
void loadRILD(void);
status_t connectRILDIfRequired(void);
+ struct echo_reference_itfe *mEchoReference;
// trace driver operations for dump
int mDriverOp;
static uint32_t checkInputSampleRate(uint32_t sampleRate);
- static const uint32_t inputSamplingRates[];
+
+ // column index in inputConfigTable[][]
+ enum {
+ INPUT_CONFIG_SAMPLE_RATE,
+ INPUT_CONFIG_BUFFER_RATIO,
+ INPUT_CONFIG_CNT
+ };
+
+ // contains the list of valid sampling rates for input streams as well as the ratio
+ // between the kernel buffer size and audio hal buffer size for each sampling rate
+ static const uint32_t inputConfigTable[][INPUT_CONFIG_CNT];
class AudioStreamOutALSA : public AudioStreamOut, public RefBase
{
@@ -224,8 +248,14 @@ private:
void lock();
void unlock();
+ void addEchoReference(struct echo_reference_itfe *reference);
+ void removeEchoReference(struct echo_reference_itfe *reference);
+
private:
+ int computeEchoReferenceDelay(size_t frames, struct timespec *echoRefRenderTime);
+ int getPlaybackDelay(size_t frames, struct echo_reference_buffer *buffer);
+
Mutex mLock;
AudioHardware* mHardware;
struct pcm *mPcm;
@@ -241,65 +271,10 @@ private:
int mDriverOp;
int mStandbyCnt;
bool mSleepReq;
+ struct echo_reference_itfe *mEchoReference;
};
- 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
+ class AudioStreamInALSA : public AudioStreamIn, public RefBase
{
public:
@@ -323,6 +298,9 @@ private:
virtual status_t setParameters(const String8& keyValuePairs);
virtual String8 getParameters(const String8& keys);
virtual unsigned int getInputFramesLost() const { return 0; }
+ virtual status_t addAudioEffect(effect_handle_t effect);
+ virtual status_t removeAudioEffect(effect_handle_t effect);
+
uint32_t device() { return mDevices; }
void doStandby_l();
void close_l();
@@ -331,15 +309,36 @@ private:
static size_t getBufferSize(uint32_t sampleRate, int channelCount);
- // BufferProvider
- virtual status_t getNextBuffer(BufferProvider::Buffer* buffer);
- virtual void releaseBuffer(BufferProvider::Buffer* buffer);
+ // resampler_buffer_provider
+ static int getNextBufferStatic(struct resampler_buffer_provider *provider,
+ struct resampler_buffer* buffer);
+ static void releaseBufferStatic(struct resampler_buffer_provider *provider,
+ struct resampler_buffer* buffer);
int prepareLock();
void lock();
void unlock();
- private:
+ private:
+
+ struct ResamplerBufferProvider {
+ struct resampler_buffer_provider mProvider;
+ AudioStreamInALSA *mInputStream;
+ };
+
+ ssize_t readFrames(void* buffer, ssize_t frames);
+ ssize_t processFrames(void* buffer, ssize_t frames);
+ int32_t updateEchoReference(size_t frames);
+ void pushEchoReference(size_t frames);
+ void updateEchoDelay(size_t frames, struct timespec *echoRefRenderTime);
+ void getCaptureDelay(size_t frames, struct echo_reference_buffer *buffer);
+ status_t setPreProcessorEchoDelay(effect_handle_t handle, int32_t delayUs);
+ status_t setPreprocessorParam(effect_handle_t handle, effect_param_t *param);
+
+ // BufferProvider
+ status_t getNextBuffer(struct resampler_buffer* buffer);
+ void releaseBuffer(struct resampler_buffer* buffer);
+
Mutex mLock;
AudioHardware* mHardware;
struct pcm *mPcm;
@@ -352,14 +351,24 @@ private:
uint32_t mChannelCount;
uint32_t mSampleRate;
size_t mBufferSize;
- DownSampler *mDownSampler;
+ struct resampler_itfe *mDownSampler;
+ struct ResamplerBufferProvider mBufferProvider;
status_t mReadStatus;
- size_t mInPcmInBuf;
- int16_t *mPcmIn;
+ size_t mInputFramesIn;
+ int16_t *mInputBuf;
// trace driver operations for dump
int mDriverOp;
int mStandbyCnt;
bool mSleepReq;
+ SortedVector<effect_handle_t> mPreprocessors;
+ int16_t *mProcBuf;
+ size_t mProcBufSize;
+ size_t mProcFramesIn;
+ int16_t *mRefBuf;
+ size_t mRefBufSize;
+ size_t mRefFramesIn;
+ struct echo_reference_itfe *mEchoReference;
+ bool mNeedEchoReference;
};
};
diff --git a/libaudio/AudioPolicyManager.cpp b/libaudio/AudioPolicyManager.cpp
index c53d1e9..bfa6c00 100644
--- a/libaudio/AudioPolicyManager.cpp
+++ b/libaudio/AudioPolicyManager.cpp
@@ -20,7 +20,7 @@
#include "AudioPolicyManager.h"
#include <media/mediarecorder.h>
-namespace android {
+namespace android_audio_legacy {
diff --git a/libaudio/AudioPolicyManager.h b/libaudio/AudioPolicyManager.h
index 03141e5..d660e78 100644
--- a/libaudio/AudioPolicyManager.h
+++ b/libaudio/AudioPolicyManager.h
@@ -23,7 +23,7 @@
#include <hardware_legacy/AudioPolicyManagerBase.h>
-namespace android {
+namespace android_audio_legacy {
class AudioPolicyManager: public AudioPolicyManagerBase
{
diff --git a/libaudio/EchoReference.cpp b/libaudio/EchoReference.cpp
new file mode 100644
index 0000000..2c10062
--- /dev/null
+++ b/libaudio/EchoReference.cpp
@@ -0,0 +1,376 @@
+/*
+** Copyright 2011, 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 "EchoReference"
+
+#include <utils/Log.h>
+#include "EchoReference.h"
+
+namespace android_audio_legacy {
+
+//------------------------------------------------------------------------------
+// Echo reference buffer
+//------------------------------------------------------------------------------
+
+EchoReference::EchoReference(audio_format_t rdFormat,
+ uint32_t rdChannelCount,
+ uint32_t rdSamplingRate,
+ audio_format_t wrFormat,
+ uint32_t wrChannelCount,
+ uint32_t wrSamplingRate)
+: mStatus (NO_INIT), mState(ECHOREF_IDLE),
+ mRdFormat(rdFormat), mRdChannelCount(rdChannelCount), mRdSamplingRate(rdSamplingRate),
+ mWrFormat(wrFormat), mWrChannelCount(wrChannelCount), mWrSamplingRate(wrSamplingRate),
+ mBuffer(NULL), mBufSize(0), mFramesIn(0), mWrBuf(NULL), mWrBufSize(0), mWrFramesIn(0),
+ mDownSampler(NULL)
+{
+ LOGV("EchoReference cstor");
+ if (rdFormat != AUDIO_FORMAT_PCM_16_BIT ||
+ rdFormat != wrFormat) {
+ LOGW("EchoReference cstor bad format rd %d, wr %d", rdFormat, wrFormat);
+ mStatus = BAD_VALUE;
+ return;
+ }
+ if ((rdChannelCount != 1 && rdChannelCount != 2) ||
+ wrChannelCount != 2) {
+ LOGW("EchoReference cstor bad channel count rd %d, wr %d", rdChannelCount, wrChannelCount);
+ mStatus = BAD_VALUE;
+ return;
+ }
+
+ if (wrSamplingRate < rdSamplingRate) {
+ LOGW("EchoReference cstor bad smp rate rd %d, wr %d", rdSamplingRate, wrSamplingRate);
+ mStatus = BAD_VALUE;
+ return;
+ }
+
+ mRdFrameSize = audio_bytes_per_sample(rdFormat) * rdChannelCount;
+ mWrFrameSize = audio_bytes_per_sample(wrFormat) * wrChannelCount;
+ mStatus = NO_ERROR;
+}
+
+
+EchoReference::~EchoReference() {
+ LOGV("EchoReference dstor");
+ reset_l();
+ delete mDownSampler;
+}
+
+status_t EchoReference::write(Buffer *buffer)
+{
+ if (mStatus != NO_ERROR) {
+ LOGV("EchoReference::write() ERROR, exiting early");
+ return mStatus;
+ }
+
+ AutoMutex _l(mLock);
+
+ if (buffer == NULL) {
+ LOGV("EchoReference::write() stop write");
+ mState &= ~ECHOREF_WRITING;
+ reset_l();
+ return NO_ERROR;
+ }
+
+ LOGV("EchoReference::write() START trying to write %d frames", buffer->frameCount);
+ LOGV("EchoReference::write() playbackTimestamp:[%lld].[%lld], mPlaybackDelay:[%ld]",
+ (int64_t)buffer->timeStamp.tv_sec,
+ (int64_t)buffer->timeStamp.tv_nsec, mPlaybackDelay);
+
+ //LOGV("EchoReference::write() %d frames", buffer->frameCount);
+ // discard writes until a valid time stamp is provided.
+
+ if ((buffer->timeStamp.tv_sec == 0) && (buffer->timeStamp.tv_nsec == 0) &&
+ (mWrRenderTime.tv_sec == 0) && (mWrRenderTime.tv_nsec == 0)) {
+ return NO_ERROR;
+ }
+
+ if ((mState & ECHOREF_WRITING) == 0) {
+ LOGV("EchoReference::write() start write");
+ if (mDownSampler != NULL) {
+ mDownSampler->reset();
+ }
+ mState |= ECHOREF_WRITING;
+ }
+
+ if ((mState & ECHOREF_READING) == 0) {
+ return NO_ERROR;
+ }
+
+ mWrRenderTime.tv_sec = buffer->timeStamp.tv_sec;
+ mWrRenderTime.tv_nsec = buffer->timeStamp.tv_nsec;
+
+ mPlaybackDelay = buffer->delayNs;
+
+ void *srcBuf;
+ size_t inFrames;
+ // do stereo to mono and down sampling if necessary
+ if (mRdChannelCount != mWrChannelCount ||
+ mRdSamplingRate != mWrSamplingRate) {
+ if (mWrBufSize < buffer->frameCount) {
+ mWrBufSize = buffer->frameCount;
+ //max buffer size is normally function of read sampling rate but as write sampling rate
+ //is always more than read sampling rate this works
+ mWrBuf = realloc(mWrBuf, mWrBufSize * mRdFrameSize);
+ }
+
+ inFrames = buffer->frameCount;
+ if (mRdChannelCount != mWrChannelCount) {
+ // must be stereo to mono
+ int16_t *src16 = (int16_t *)buffer->raw;
+ int16_t *dst16 = (int16_t *)mWrBuf;
+ size_t frames = buffer->frameCount;
+ while (frames--) {
+ *dst16++ = (int16_t)(((int32_t)*src16 + (int32_t)*(src16 + 1)) >> 1);
+ src16 += 2;
+ }
+ }
+ if (mWrSamplingRate != mRdSamplingRate) {
+ if (mDownSampler == NULL) {
+ LOGV("EchoReference::write() new ReSampler(%d, %d)",
+ mWrSamplingRate, mRdSamplingRate);
+ mDownSampler = new ReSampler(mWrSamplingRate,
+ mRdSamplingRate,
+ mRdChannelCount,
+ this);
+
+ }
+ // mWrSrcBuf and mWrFramesIn are used by getNexBuffer() called by the resampler
+ // to get new frames
+ if (mRdChannelCount != mWrChannelCount) {
+ mWrSrcBuf = mWrBuf;
+ } else {
+ mWrSrcBuf = buffer->raw;
+ }
+ mWrFramesIn = buffer->frameCount;
+ // inFrames is always more than we need here to get frames remaining from previous runs
+ // inFrames is updated by resample() with the number of frames produced
+ LOGV("EchoReference::write() ReSampling(%d, %d)",
+ mWrSamplingRate, mRdSamplingRate);
+ mDownSampler->resample((int16_t *)mWrBuf, &inFrames);
+ LOGV_IF(mWrFramesIn != 0,
+ "EchoReference::write() mWrFramesIn not 0 (%d) after resampler",
+ mWrFramesIn);
+ }
+ srcBuf = mWrBuf;
+ } else {
+ inFrames = buffer->frameCount;
+ srcBuf = buffer->raw;
+ }
+
+ if (mFramesIn + inFrames > mBufSize) {
+ LOGV("EchoReference::write() increasing buffer size from %d to %d",
+ mBufSize, mFramesIn + inFrames);
+ mBufSize = mFramesIn + inFrames;
+ mBuffer = realloc(mBuffer, mBufSize * mRdFrameSize);
+ }
+ memcpy((char *)mBuffer + mFramesIn * mRdFrameSize,
+ srcBuf,
+ inFrames * mRdFrameSize);
+ mFramesIn += inFrames;
+
+ LOGV("EchoReference::write_log() inFrames:[%d], mFramesInOld:[%d], "\
+ "mFramesInNew:[%d], mBufSize:[%d], mWrRenderTime:[%lld].[%lld], mPlaybackDelay:[%ld]",
+ inFrames, mFramesIn - inFrames, mFramesIn, mBufSize, (int64_t)mWrRenderTime.tv_sec,
+ (int64_t)mWrRenderTime.tv_nsec, mPlaybackDelay);
+
+ mCond.signal();
+ LOGV("EchoReference::write() END");
+ return NO_ERROR;
+}
+
+status_t EchoReference::read(EchoReference::Buffer *buffer)
+{
+ if (mStatus != NO_ERROR) {
+ return mStatus;
+ }
+ AutoMutex _l(mLock);
+
+ if (buffer == NULL) {
+ LOGV("EchoReference::read() stop read");
+ mState &= ~ECHOREF_READING;
+ return NO_ERROR;
+ }
+
+ LOGV("EchoReference::read() START, delayCapture:[%ld],mFramesIn:[%d],buffer->frameCount:[%d]",
+ buffer->delayNs, mFramesIn, buffer->frameCount);
+
+ if ((mState & ECHOREF_READING) == 0) {
+ LOGV("EchoReference::read() start read");
+ reset_l();
+ mState |= ECHOREF_READING;
+ }
+
+ if ((mState & ECHOREF_WRITING) == 0) {
+ memset(buffer->raw, 0, mRdFrameSize * buffer->frameCount);
+ buffer->delayNs = 0;
+ return NO_ERROR;
+ }
+
+// LOGV("EchoReference::read() %d frames", buffer->frameCount);
+
+ // allow some time for new frames to arrive if not enough frames are ready for read
+ if (mFramesIn < buffer->frameCount) {
+ uint32_t timeoutMs = (uint32_t)((1000 * buffer->frameCount) / mRdSamplingRate / 2);
+
+ mCond.waitRelative(mLock, milliseconds(timeoutMs));
+ if (mFramesIn < buffer->frameCount) {
+ LOGV("EchoReference::read() waited %d ms but still not enough frames"\
+ " mFramesIn: %d, buffer->frameCount = %d",
+ timeoutMs, mFramesIn, buffer->frameCount);
+ buffer->frameCount = mFramesIn;
+ }
+ }
+
+ int64_t timeDiff;
+ struct timespec tmp;
+
+ if ((mWrRenderTime.tv_sec == 0 && mWrRenderTime.tv_nsec == 0) ||
+ (buffer->timeStamp.tv_sec == 0 && buffer->timeStamp.tv_nsec == 0)) {
+ LOGV("read: NEW:timestamp is zero---------setting timeDiff = 0, "\
+ "not updating delay this time");
+ timeDiff = 0;
+ } else {
+ if (buffer->timeStamp.tv_nsec < mWrRenderTime.tv_nsec) {
+ tmp.tv_sec = buffer->timeStamp.tv_sec - mWrRenderTime.tv_sec - 1;
+ tmp.tv_nsec = 1000000000 + buffer->timeStamp.tv_nsec - mWrRenderTime.tv_nsec;
+ } else {
+ tmp.tv_sec = buffer->timeStamp.tv_sec - mWrRenderTime.tv_sec;
+ tmp.tv_nsec = buffer->timeStamp.tv_nsec - mWrRenderTime.tv_nsec;
+ }
+ timeDiff = (((int64_t)tmp.tv_sec * 1000000000 + tmp.tv_nsec));
+
+ int64_t expectedDelayNs = mPlaybackDelay + buffer->delayNs - timeDiff;
+
+ LOGV("expectedDelayNs[%lld] = mPlaybackDelay[%ld] + delayCapture[%ld] - timeDiff[%lld]",
+ expectedDelayNs, mPlaybackDelay, buffer->delayNs, timeDiff);
+
+ if (expectedDelayNs > 0) {
+ int64_t delayNs = ((int64_t)mFramesIn * 1000000000) / mRdSamplingRate;
+
+ delayNs -= expectedDelayNs;
+
+ if (abs(delayNs) >= sMinDelayUpdate) {
+ if (delayNs < 0) {
+ size_t previousFrameIn = mFramesIn;
+ mFramesIn = (expectedDelayNs * mRdSamplingRate)/1000000000;
+ int offset = mFramesIn - previousFrameIn;
+ LOGV("EchoReference::readlog: delayNs = NEGATIVE and ENOUGH : "\
+ "setting %d frames to zero mFramesIn: %d, previousFrameIn = %d",
+ offset, mFramesIn, previousFrameIn);
+
+ if (mFramesIn > mBufSize) {
+ mBufSize = mFramesIn;
+ mBuffer = realloc(mBuffer, mFramesIn * mRdFrameSize);
+ LOGV("EchoReference::read: increasing buffer size to %d", mBufSize);
+ }
+
+ if (offset > 0)
+ memset((char *)mBuffer + previousFrameIn * mRdFrameSize,
+ 0, offset * mRdFrameSize);
+ } else {
+ size_t previousFrameIn = mFramesIn;
+ int framesInInt = (int)(((int64_t)expectedDelayNs *
+ (int64_t)mRdSamplingRate)/1000000000);
+ int offset = previousFrameIn - framesInInt;
+
+ LOGV("EchoReference::readlog: delayNs = POSITIVE/ENOUGH :previousFrameIn: %d,"\
+ "framesInInt: [%d], offset:[%d], buffer->frameCount:[%d]",
+ previousFrameIn, framesInInt, offset, buffer->frameCount);
+
+ if (framesInInt < (int)buffer->frameCount) {
+ if (framesInInt > 0) {
+ memset((char *)mBuffer + framesInInt * mRdFrameSize,
+ 0, (buffer->frameCount-framesInInt) * mRdFrameSize);
+ LOGV("EchoReference::read: pushing [%d] zeros into ref buffer",
+ (buffer->frameCount-framesInInt));
+ } else {
+ LOGV("framesInInt = %d", framesInInt);
+ }
+ framesInInt = buffer->frameCount;
+ } else {
+ if (offset > 0) {
+ memcpy(mBuffer, (char *)mBuffer + (offset * mRdFrameSize),
+ framesInInt * mRdFrameSize);
+ LOGV("EchoReference::read: shifting ref buffer by [%d]",framesInInt);
+ }
+ }
+ mFramesIn = (size_t)framesInInt;
+ }
+ } else {
+ LOGV("EchoReference::read: NOT ENOUGH samples to update %lld", delayNs);
+ }
+ } else {
+ LOGV("NEGATIVE expectedDelayNs[%lld] = "\
+ "mPlaybackDelay[%ld] + delayCapture[%ld] - timeDiff[%lld]",
+ expectedDelayNs, mPlaybackDelay, buffer->delayNs, timeDiff);
+ }
+ }
+
+ memcpy(buffer->raw,
+ (char *)mBuffer,
+ buffer->frameCount * mRdFrameSize);
+
+ mFramesIn -= buffer->frameCount;
+ memcpy(mBuffer,
+ (char *)mBuffer + buffer->frameCount * mRdFrameSize,
+ mFramesIn * mRdFrameSize);
+
+ // As the reference buffer is now time aligned to the microphone signal there is a zero delay
+ buffer->delayNs = 0;
+
+ LOGV("EchoReference::read() END %d frames, total frames in %d",
+ buffer->frameCount, mFramesIn);
+
+ mCond.signal();
+ return NO_ERROR;
+}
+
+void EchoReference::reset_l() {
+ LOGV("EchoReference::reset_l()");
+ free(mBuffer);
+ mBuffer = NULL;
+ mBufSize = 0;
+ mFramesIn = 0;
+ free(mWrBuf);
+ mWrBuf = NULL;
+ mWrBufSize = 0;
+ mWrRenderTime.tv_sec = 0;
+ mWrRenderTime.tv_nsec = 0;
+}
+
+status_t EchoReference::getNextBuffer(ReSampler::BufferProvider::Buffer* buffer)
+{
+ if (mWrSrcBuf == NULL || mWrFramesIn == 0) {
+ buffer->raw = NULL;
+ buffer->frameCount = 0;
+ return NOT_ENOUGH_DATA;
+ }
+
+ buffer->frameCount = (buffer->frameCount > mWrFramesIn) ? mWrFramesIn : buffer->frameCount;
+ // this is mRdChannelCount here as we resample after stereo to mono conversion if any
+ buffer->i16 = (int16_t *)mWrSrcBuf + (mWrBufSize - mWrFramesIn) * mRdChannelCount;
+
+ return 0;
+}
+
+void EchoReference::releaseBuffer(ReSampler::BufferProvider::Buffer* buffer)
+{
+ mWrFramesIn -= buffer->frameCount;
+}
+
+}; // namespace android_audio_legacy
diff --git a/libaudio/EchoReference.h b/libaudio/EchoReference.h
new file mode 100644
index 0000000..b82cd11
--- /dev/null
+++ b/libaudio/EchoReference.h
@@ -0,0 +1,118 @@
+/*
+** Copyright 2011, 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_ECHO_REFERENCE_H
+#define ANDROID_ECHO_REFERENCE_H
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <utils/threads.h>
+#include <hardware_legacy/AudioSystemLegacy.h>
+#include "ReSampler.h"
+
+namespace android_audio_legacy {
+using android::Mutex;
+using android::AutoMutex;
+
+class EchoReference : public ReSampler::BufferProvider {
+
+public:
+
+ EchoReference(audio_format_t rdFormat,
+ uint32_t rdChannelCount,
+ uint32_t rdSamplingRate,
+ audio_format_t wrFormat,
+ uint32_t wrChannelCount,
+ uint32_t wrSamplingRate);
+ virtual ~EchoReference();
+
+ // echo reference state: it field indicating if read, write or both are active.
+ enum state {
+ ECHOREF_IDLE = 0x00, // idle
+ ECHOREF_READING = 0x01, // reading is active
+ ECHOREF_WRITING = 0x02 // writing is active
+ };
+
+ // Buffer descriptor used by read() and write() methods, including the time stamp and delay.
+ class Buffer {
+ public:
+ void *raw; // pointer to audio frame
+ size_t frameCount; // number of frames in buffer
+ int32_t delayNs; // delay for this buffer (see comment below)
+ struct timespec timeStamp; // time stamp for this buffer (see comment below)
+ };
+ // when used for EchoReference::write():
+ // + as input:
+ // - delayNs is the delay introduced by playback buffers
+ // - timeStamp is the time stamp corresponding to the delay calculation
+ // + as output:
+ // unused
+ // when used for EchoReference::read():
+ // + as input:
+ // - delayNs is the delay introduced by capture buffers
+ // - timeStamp is the time stamp corresponding to the delay calculation
+ // + as output:
+ // - delayNs is the delay between the returned frames and the capture time derived from
+ // delay and time stamp indicated as input. This delay is to be communicated to the AEC.
+ // - frameCount is updated with the actual number of frames returned
+
+
+ // BufferProvider
+ status_t getNextBuffer(ReSampler::BufferProvider::Buffer* buffer);
+ void releaseBuffer(ReSampler::BufferProvider::Buffer* buffer);
+
+ status_t initCheck() { return mStatus; }
+
+ status_t read(Buffer *buffer);
+ status_t write(Buffer *buffer);
+
+
+private:
+
+ void reset_l();
+
+ status_t mStatus; // init status
+ uint32_t mState; // active state: reading, writing or both
+ audio_format_t mRdFormat; // read sample format
+ uint32_t mRdChannelCount; // read number of channels
+ uint32_t mRdSamplingRate; // read sampling rate
+ size_t mRdFrameSize; // read frame size (bytes per sample)
+ audio_format_t mWrFormat; // write sample format
+ uint32_t mWrChannelCount; // write number of channels
+ uint32_t mWrSamplingRate; // write sampling rate
+ size_t mWrFrameSize; // write frame size (bytes per sample)
+ void *mBuffer; // main buffer
+ size_t mBufSize; // main buffer size in frames
+ size_t mFramesIn; // number of frames in main buffer
+ void *mWrBuf; // buffer for input conversions
+ size_t mWrBufSize; // size of conversion buffer in frames
+ size_t mWrFramesIn; // number of frames in conversion buffer
+ void *mWrSrcBuf; // resampler input buf (either mWrBuf or buffer used by write()
+ struct timespec mWrRenderTime; // latest render time indicated by write()
+ int32_t mPlaybackDelay;
+
+ uint32_t mRdDurationUs; // Duration of last buffer read (used for mCond wait timeout)
+ android::Mutex mLock; // Mutex protecting read/write concurrency
+ android::Condition mCond; // Condition signaled when data is ready to read
+ ReSampler *mDownSampler; // input resampler
+
+ static const int sMinDelayUpdate = 62500; // delay jump threshold to update ref buffer
+ // 0.5 samples at 8kHz in nsecs
+};
+
+}; // namespace android
+
+#endif // ANDROID_ECHO_REFERENCE_H
diff --git a/libaudio/README b/libaudio/README
new file mode 100644
index 0000000..d446f90
--- /dev/null
+++ b/libaudio/README
@@ -0,0 +1,7 @@
+The code in this library is implemented according to legacy audio HAL scheme:
+ - use of AudioHardwareInterface C++ interface.
+ - use of C++ classes in frameworks/base.
+
+It should not be used as an example for newer audio HALs implementations.
+
+
diff --git a/libaudio/ReSampler.cpp b/libaudio/ReSampler.cpp
new file mode 100644
index 0000000..aa1d5e0
--- /dev/null
+++ b/libaudio/ReSampler.cpp
@@ -0,0 +1,171 @@
+/*
+** Copyright 2011, 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 "ReSampler"
+
+#include <utils/Log.h>
+#include "ReSampler.h"
+
+namespace android_audio_legacy {
+
+
+//------------------------------------------------------------------------------
+// speex based resampler
+//------------------------------------------------------------------------------
+
+#define RESAMPLER_QUALITY 2
+
+ReSampler::ReSampler(uint32_t inSampleRate,
+ uint32_t outSampleRate,
+ uint32_t channelCount,
+ BufferProvider* provider)
+ : mStatus(NO_INIT), mSpeexResampler(NULL), mProvider(provider),
+ mInSampleRate(inSampleRate), mOutSampleRate(outSampleRate), mChannelCount(channelCount),
+ mInBuf(NULL), mInBufSize(0)
+{
+ LOGV("ReSampler() cstor %p In SR %d Out SR %d channels %d",
+ this, mInSampleRate, mOutSampleRate, mChannelCount);
+
+ if (mProvider == NULL) {
+ return;
+ }
+
+ int error;
+ mSpeexResampler = speex_resampler_init(channelCount,
+ inSampleRate,
+ outSampleRate,
+ RESAMPLER_QUALITY,
+ &error);
+ if (mSpeexResampler == NULL) {
+ LOGW("ReSampler: Cannot create speex resampler: %s", speex_resampler_strerror(error));
+ return;
+ }
+
+ reset();
+
+ int frames = speex_resampler_get_input_latency(mSpeexResampler);
+ mSpeexDelayNs = (int32_t)((1000000000 * (int64_t)frames) / mInSampleRate);
+ frames = speex_resampler_get_output_latency(mSpeexResampler);
+ mSpeexDelayNs += (int32_t)((1000000000 * (int64_t)frames) / mOutSampleRate);
+
+ mStatus = NO_ERROR;
+}
+
+ReSampler::~ReSampler()
+{
+ free(mInBuf);
+
+ if (mSpeexResampler != NULL) {
+ speex_resampler_destroy(mSpeexResampler);
+ }
+}
+
+void ReSampler::reset()
+{
+ mFramesIn = 0;
+ mFramesRq = 0;
+
+ if (mSpeexResampler != NULL) {
+ speex_resampler_reset_mem(mSpeexResampler);
+ }
+}
+
+int32_t ReSampler::delayNs()
+{
+ int32_t delay = (int32_t)((1000000000 * (int64_t)mFramesIn) / mInSampleRate);
+ delay += mSpeexDelayNs;
+
+ return delay;
+}
+
+// outputs a number of frames less or equal to *outFrameCount and updates *outFrameCount
+// with the actual number of frames produced.
+int ReSampler::resample(int16_t *out, size_t *outFrameCount)
+{
+ if (mStatus != NO_ERROR) {
+ return mStatus;
+ }
+
+ if (out == NULL || outFrameCount == NULL) {
+ return BAD_VALUE;
+ }
+
+ size_t framesRq = *outFrameCount;
+ // update and cache the number of frames needed at the input sampling rate to produce
+ // the number of frames requested at the output sampling rate
+ if (framesRq != mFramesRq) {
+ mFramesNeeded = (framesRq * mOutSampleRate) / mInSampleRate + 1;
+ mFramesRq = framesRq;
+ }
+
+ size_t framesWr = 0;
+ size_t inFrames = 0;
+ while (framesWr < framesRq) {
+ if (mFramesIn < mFramesNeeded) {
+ // make sure that the number of frames present in mInBuf (mFramesIn) is at least
+ // the number of frames needed to produce the number of frames requested at
+ // the output sampling rate
+ if (mInBufSize < mFramesNeeded) {
+ mInBufSize = mFramesNeeded;
+ mInBuf = (int16_t *)realloc(mInBuf, mInBufSize * mChannelCount * sizeof(int16_t));
+ }
+ BufferProvider::Buffer buf;
+ buf.frameCount = mFramesNeeded - mFramesIn;
+ mProvider->getNextBuffer(&buf);
+ if (buf.raw == NULL) {
+ break;
+ }
+ memcpy(mInBuf + mFramesIn * mChannelCount,
+ buf.raw,
+ buf.frameCount * mChannelCount * sizeof(int16_t));
+ mFramesIn += buf.frameCount;
+ mProvider->releaseBuffer(&buf);
+ }
+
+ size_t outFrames = framesRq - framesWr;
+ inFrames = mFramesIn;
+ if (mChannelCount == 1) {
+ speex_resampler_process_int(mSpeexResampler,
+ 0,
+ mInBuf,
+ &inFrames,
+ out + framesWr * mChannelCount,
+ &outFrames);
+ } else {
+ speex_resampler_process_interleaved_int(mSpeexResampler,
+ mInBuf,
+ &inFrames,
+ out + framesWr * mChannelCount,
+ &outFrames);
+ }
+ framesWr += outFrames;
+ mFramesIn -= inFrames;
+ LOGW_IF((framesWr != framesRq) && (mFramesIn != 0),
+ "ReSampler::resample() remaining %d frames in and %d frames out",
+ mFramesIn, (framesRq - framesWr));
+ }
+ if (mFramesIn) {
+ memmove(mInBuf,
+ mInBuf + inFrames * mChannelCount,
+ mFramesIn * mChannelCount * sizeof(int16_t));
+ }
+ *outFrameCount = framesWr;
+
+ return NO_ERROR;
+}
+
+}; // namespace android_audio_legacy
diff --git a/libaudio/ReSampler.h b/libaudio/ReSampler.h
new file mode 100644
index 0000000..f531900
--- /dev/null
+++ b/libaudio/ReSampler.h
@@ -0,0 +1,80 @@
+/*
+** 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_RESAMPLER_H
+#define ANDROID_RESAMPLER_H
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <hardware_legacy/AudioSystemLegacy.h>
+#include "speex/speex_resampler.h"
+
+namespace android_audio_legacy {
+
+class ReSampler {
+public:
+
+ 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;
+ };
+
+ ReSampler(uint32_t inSampleRate,
+ uint32_t outSampleRate,
+ uint32_t channelCount,
+ BufferProvider* provider);
+
+ virtual ~ReSampler();
+
+ status_t initCheck() { return mStatus; }
+ void reset();
+ int resample(int16_t* out, size_t *outFrameCount);
+ int32_t delayNs();
+
+
+private:
+ status_t mStatus; // init status
+ SpeexResamplerState *mSpeexResampler; // handle on speex resampler
+ BufferProvider* mProvider; // buffer provider installed by client
+ uint32_t mInSampleRate; // input sampling rate
+ uint32_t mOutSampleRate; // output sampling rate
+ uint32_t mChannelCount; // number of channels
+ int16_t *mInBuf; // input buffer
+ size_t mInBufSize; // input buffer size
+ size_t mFramesIn; // number of frames in input buffer
+ size_t mFramesRq; // cached number of output frames
+ size_t mFramesNeeded; // minimum number of input frames to produce mFramesRq
+ // output frames
+ int32_t mSpeexDelayNs; // delay introduced by speex resampler in ns
+};
+
+}; // namespace android_audio_legacy
+
+#endif // ANDROID_RESAMPLER_H
diff --git a/libaudio/alsa_audio.h b/libaudio/alsa_audio.h
deleted file mode 100644
index 3cb86d9..0000000
--- a/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/libaudio/alsa_mixer.c b/libaudio/alsa_mixer.c
deleted file mode 100644
index 3036ef8..0000000
--- a/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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <ctype.h>
-
-#include <linux/ioctl.h>
-#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
deleted file mode 100644
index 5673391..0000000
--- a/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 <cutils/log.h>
-#include <cutils/config_utils.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-
-#include <linux/ioctl.h>
-
-#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(&params);
- param_set_mask(&params, SNDRV_PCM_HW_PARAM_ACCESS,
- SNDRV_PCM_ACCESS_RW_INTERLEAVED);
- param_set_mask(&params, SNDRV_PCM_HW_PARAM_FORMAT,
- SNDRV_PCM_FORMAT_S16_LE);
- param_set_mask(&params, SNDRV_PCM_HW_PARAM_SUBFORMAT,
- SNDRV_PCM_SUBFORMAT_STD);
- param_set_min(&params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, period_sz);
- param_set_int(&params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, 16);
- param_set_int(&params, SNDRV_PCM_HW_PARAM_FRAME_BITS,
- (flags & PCM_MONO) ? 16 : 32);
- param_set_int(&params, SNDRV_PCM_HW_PARAM_CHANNELS,
- (flags & PCM_MONO) ? 1 : 2);
- param_set_int(&params, SNDRV_PCM_HW_PARAM_PERIODS, period_cnt);
- param_set_int(&params, SNDRV_PCM_HW_PARAM_RATE, 44100);
-
- if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_HW_PARAMS, &params)) {
- oops(pcm, errno, "cannot set hw params");
- goto fail;
- }
- param_dump(&params);
-
- 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
deleted file mode 100644
index d978caa..0000000
--- a/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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <ctype.h>
-
-#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
deleted file mode 100644
index 0ac0ac0..0000000
--- a/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 <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <string.h>
-
-#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 <file>\n");
- return -1;
- }
-
- return play_wav(argv[1]);
-}
-
diff --git a/libaudio/arec.c b/libaudio/arec.c
deleted file mode 100644
index b1e9eda..0000000
--- a/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 <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <string.h>
-
-#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 <file>\n");
- return -1;
- }
-
- return rec_wav(argv[1]);
-}
-
diff --git a/libaudio/asound.h b/libaudio/asound.h
deleted file mode 100644
index 6a17f29..0000000
--- a/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 <linux/types.h>
-
-#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/libcamera/Android.mk b/libcamera/Android.mk
index 79f4e3c..1ade091 100644
--- a/libcamera/Android.mk
+++ b/libcamera/Android.mk
@@ -1,42 +1,25 @@
ifneq ($(filter crespo crespo4g,$(TARGET_DEVICE)),)
-# 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)
+# HAL module implemenation stored in
+# hw/<COPYPIX_HARDWARE_MODULE_ID>.<ro.product.board>.so
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../libs3cjpeg
-
LOCAL_SRC_FILES:= \
- SecCamera.cpp \
- SecCameraHWInterface.cpp
+ SecCamera.cpp SecCameraHWInterface.cpp
-
-LOCAL_SHARED_LIBRARIES:= libutils libui liblog libbinder libcutils
+LOCAL_SHARED_LIBRARIES:= libutils libcutils libbinder liblog libcamera_client libhardware
LOCAL_SHARED_LIBRARIES+= libs3cjpeg
-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 := camera.herring
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
endif
-endif
diff --git a/libcamera/SecCamera.cpp b/libcamera/SecCamera.cpp
index 4d0705a..48cf02e 100755
--- a/libcamera/SecCamera.cpp
+++ b/libcamera/SecCamera.cpp
@@ -122,24 +122,6 @@ static int get_pixel_depth(unsigned int fmt)
#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;
@@ -546,6 +528,8 @@ static int fimc_v4l2_s_parm(int fp, struct v4l2_streamparm *streamparm)
SecCamera::SecCamera() :
m_flag_init(0),
m_camera_id(CAMERA_ID_BACK),
+ m_cam_fd(-1),
+ m_cam_fd2(-1),
m_preview_v4lformat(V4L2_PIX_FMT_NV21),
m_preview_width (0),
m_preview_height (0),
@@ -609,12 +593,6 @@ SecCamera::SecCamera() :
LOGV("%s :", __func__);
}
-int SecCamera::flagCreate(void) const
-{
- LOGV("%s : : %d", __func__, m_flag_init);
- return m_flag_init;
-}
-
SecCamera::~SecCamera()
{
LOGV("%s :", __func__);
@@ -632,43 +610,12 @@ int SecCamera::initCamera(int index)
*/
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;
- }
- }
+ LOGV("%s: open(%s) --> m_cam_fd %d", __FUNCTION__, CAMERA_DEV_NAME, m_cam_fd);
LOGE("initCamera: m_cam_fd(%d), m_jpeg_fd(%d)", m_cam_fd, m_jpeg_fd);
@@ -680,50 +627,11 @@ int SecCamera::initCamera(int index)
CHECK(ret);
m_cam_fd2 = open(CAMERA_DEV_NAME2, O_RDWR);
+ LOGV("%s: open(%s) --> m_cam_fd2 = %d", __FUNCTION__, CAMERA_DEV_NAME2, m_cam_fd2);
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);
@@ -755,6 +663,7 @@ int SecCamera::initCamera(int index)
setExifFixedAttribute();
m_flag_init = 1;
+ LOGI("%s : initialized", __FUNCTION__);
}
return 0;
}
@@ -789,18 +698,9 @@ void SecCamera::DeinitCamera()
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;
}
+ else LOGI("%s : already deinitialized", __FUNCTION__);
}
@@ -1527,7 +1427,7 @@ int SecCamera::getSnapshotAndJpeg(unsigned char *yuv_buf, unsigned char *jpeg_bu
memcpy(pInBuf, yuv_buf, snapshot_size);
setExifChangedAttribute();
- jpgEnc.encode(output_size, &mExifInfo);
+ jpgEnc.encode(output_size, NULL);
uint64_t outbuf_size;
unsigned char *pOutBuf = (unsigned char *)jpgEnc.getOutBuf(&outbuf_size);
@@ -2746,9 +2646,7 @@ int SecCamera::setDataLineCheck(int chk_dataline)
return -1;
}
- if (m_chk_dataline != chk_dataline) {
- m_chk_dataline = chk_dataline;
- }
+ m_chk_dataline = chk_dataline;
return 0;
}
@@ -3124,7 +3022,7 @@ inline int SecCamera::m_frameSize(int format, int width, int height)
return size;
}
-status_t SecCamera::dump(int fd, const Vector<String16> &args)
+status_t SecCamera::dump(int fd)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -3136,7 +3034,7 @@ status_t SecCamera::dump(int fd, const Vector<String16> &args)
}
double SecCamera::jpeg_ratio = 0.7;
-int SecCamera::interleaveDataSize = 4261248;
+int SecCamera::interleaveDataSize = 5242880;
int SecCamera::jpegLineLength = 636;
}; // namespace android
diff --git a/libcamera/SecCamera.h b/libcamera/SecCamera.h
index c87a0f4..551eb03 100644
--- a/libcamera/SecCamera.h
+++ b/libcamera/SecCamera.h
@@ -33,12 +33,13 @@
#include <sys/poll.h>
#include <sys/stat.h>
+#include <utils/RefBase.h>
#include <linux/videodev2.h>
#include <videodev2_samsung.h>
-#include "JpegEncoder.h"
+#include <utils/String8.h>
-#include <camera/CameraHardwareInterface.h>
+#include "JpegEncoder.h"
namespace android {
@@ -144,8 +145,7 @@ namespace android {
#define BPP 2
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
-#define MAX_BUFFERS 11
-
+#define MAX_BUFFERS 9 // 11
/*
* V 4 L 2 F I M C E X T E N S I O N S
*
@@ -200,8 +200,7 @@ struct camsensor_date_info {
unsigned int date;
};
-
-class SecCamera {
+class SecCamera : public virtual RefBase {
public:
enum CAMERA_ID {
@@ -272,17 +271,14 @@ public:
} gpsInfoAltitude;
SecCamera();
- ~SecCamera();
+ virtual ~SecCamera();
static SecCamera* createInstance(void)
{
static SecCamera singleton;
return &singleton;
}
- status_t dump(int fd, const Vector<String16>& args);
-
- int flagCreate(void) const;
-
+ status_t dump(int fd);
int getCameraId(void);
@@ -490,9 +486,6 @@ private:
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;
diff --git a/libcamera/SecCameraHWInterface.cpp b/libcamera/SecCameraHWInterface.cpp
index 8ca648c..875fbcd 100644..100755
--- a/libcamera/SecCameraHWInterface.cpp
+++ b/libcamera/SecCameraHWInterface.cpp
@@ -24,13 +24,8 @@
#include <utils/threads.h>
#include <fcntl.h>
#include <sys/mman.h>
-
-#if defined(BOARD_USES_OVERLAY)
-#include <hardware/overlay.h>
-#include <ui/Overlay.h>
-#define CACHEABLE_BUFFERS 0x1
-#define ALL_BUFFERS_FLUSHED -66
-#endif
+#include <camera/Camera.h>
+#include <media/stagefright/MetadataBufferType.h>
#define VIDEO_COMMENT_MARKER_H 0xFFBE
#define VIDEO_COMMENT_MARKER_L 0xFFBF
@@ -44,9 +39,23 @@
#define BACK_CAMERA_INFINITY_FOCUS_DISTANCES_STR "0.10,1.20,Infinity"
#define FRONT_CAMERA_FOCUS_DISTANCES_STR "0.20,0.25,Infinity"
+// FIXME:
+// -- The actual preview color is set to YV12. The preview frames
+// returned via preview callback must be generated by color
+// conversion if the requested preview color format for the
+// preview frames is _not_ YV12. The reason that YV12 is used
+// for actual preview is because that is the only color format
+// supported by gralloc. Matching the preview cor format with
+// gralloc color format improves performance since no color
+// conversion is needed for preview.
+//
+// -- we only support two preview color formats that client
+// applications can set: NV21 and YUV420/YV12.
+
namespace android {
struct addrs {
+ uint32_t type; // make sure that this is 4 byte.
unsigned int addr_y;
unsigned int addr_cbcr;
unsigned int buf_index;
@@ -62,21 +71,15 @@ struct addrs_cap {
static const int INITIAL_SKIP_FRAME = 3;
static const int EFFECT_SKIP_FRAME = 1;
-CameraHardwareSec::CameraHardwareSec(int cameraId)
+gralloc_module_t const* CameraHardwareSec::mGrallocHal;
+
+CameraHardwareSec::CameraHardwareSec(int cameraId, camera_device_t *dev)
:
mCaptureInProgress(false),
mParameters(),
- mPreviewHeap(0),
- mRawHeap(0),
- mRecordHeap(0),
- mJpegHeap(0),
- mSecCamera(NULL),
+ mFrameSizeDelta(0),
mCameraSensorName(NULL),
mSkipFrame(0),
-#if defined(BOARD_USES_OVERLAY)
- mUseOverlay(false),
- mOverlayBufferIdx(0),
-#endif
mNotifyCb(0),
mDataCb(0),
mDataCbTimestamp(0),
@@ -85,15 +88,23 @@ CameraHardwareSec::CameraHardwareSec(int cameraId)
mRecordRunning(false),
mPostViewWidth(0),
mPostViewHeight(0),
- mPostViewSize(0)
+ mPostViewSize(0),
+ mHalDevice(dev)
{
LOGV("%s :", __func__);
int ret = 0;
+ mPreviewWindow = NULL;
mSecCamera = SecCamera::createInstance();
- if (mSecCamera == NULL) {
- LOGE("ERR(%s):Fail on mSecCamera object creation", __func__);
+ mRawHeap = NULL;
+ mPreviewHeap = NULL;
+ mRecordHeap = NULL;
+
+ if (!mGrallocHal) {
+ ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&mGrallocHal);
+ if (ret)
+ LOGE("ERR(%s):Fail on loading gralloc HAL", __func__);
}
ret = mSecCamera->initCamera(cameraId);
@@ -101,30 +112,10 @@ CameraHardwareSec::CameraHardwareSec(int cameraId)
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;
@@ -133,11 +124,17 @@ CameraHardwareSec::CameraHardwareSec(int cameraId)
* create the thread but it is initially in stopped state.
*/
mPreviewRunning = false;
+ mPreviewStartDeferred = false;
mPreviewThread = new PreviewThread(this);
mAutoFocusThread = new AutoFocusThread(this);
mPictureThread = new PictureThread(this);
}
+int CameraHardwareSec::getCameraId() const
+{
+ return mSecCamera->getCameraId();
+}
+
void CameraHardwareSec::initDefaultParameters(int cameraId)
{
if (mSecCamera == NULL) {
@@ -180,20 +177,20 @@ void CameraHardwareSec::initDefaultParameters(int cameraId)
&snapshot_max_height) < 0)
LOGE("getSnapshotMaxSize fail (%d / %d) \n",
snapshot_max_width, snapshot_max_height);
-
- p.setPreviewFormat(CameraParameters::PIXEL_FORMAT_YUV420SP);
+ String8 previewColorString;
+ previewColorString = CameraParameters::PIXEL_FORMAT_YUV420SP;
+ previewColorString.append(",");
+ previewColorString.append(CameraParameters::PIXEL_FORMAT_YUV420P);
+ p.setPreviewFormat(CameraParameters::PIXEL_FORMAT_YUV420SP); mFrameSizeDelta = 16;
+ p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS, previewColorString.string());
+ p.set(CameraParameters::KEY_VIDEO_FRAME_FORMAT, CameraParameters::PIXEL_FORMAT_YUV420P);
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;
@@ -361,34 +358,90 @@ void CameraHardwareSec::initDefaultParameters(int cameraId)
CameraHardwareSec::~CameraHardwareSec()
{
- LOGV("%s :", __func__);
-
- singleton.clear();
+ LOGV("%s", __func__);
+ mSecCamera->DeinitCamera();
}
-status_t CameraHardwareSec::setPreviewWindow(const sp<ANativeWindow>& buf)
+status_t CameraHardwareSec::setPreviewWindow(preview_stream_ops *w)
{
- return NO_ERROR;
-}
+ int min_bufs;
-sp<IMemoryHeap> CameraHardwareSec::getPreviewHeap() const
-{
- return mPreviewHeap;
-}
+ mPreviewWindow = w;
+ LOGV("%s: mPreviewWindow %p", __func__, mPreviewWindow);
-sp<IMemoryHeap> CameraHardwareSec::getRawHeap() const
-{
- return mRawHeap;
+ if (!w) {
+ LOGE("preview window is NULL!");
+ return OK;
+ }
+
+ mPreviewLock.lock();
+
+ if (mPreviewRunning && !mPreviewStartDeferred) {
+ LOGI("stop preview (window change)");
+ stopPreviewInternal();
+ }
+
+ if (w->get_min_undequeued_buffer_count(w, &min_bufs)) {
+ LOGE("%s: could not retrieve min undequeued buffer count", __func__);
+ return INVALID_OPERATION;
+ }
+
+ if (min_bufs >= kBufferCount) {
+ LOGE("%s: min undequeued buffer count %d is too high (expecting at most %d)", __func__,
+ min_bufs, kBufferCount - 1);
+ }
+
+ LOGV("%s: setting buffer count to %d", __func__, kBufferCount);
+ if (w->set_buffer_count(w, kBufferCount)) {
+ LOGE("%s: could not set buffer count", __func__);
+ return INVALID_OPERATION;
+ }
+
+ int preview_width;
+ int preview_height;
+ mParameters.getPreviewSize(&preview_width, &preview_height);
+ int hal_pixel_format = HAL_PIXEL_FORMAT_YV12;
+
+ const char *str_preview_format = mParameters.getPreviewFormat();
+ LOGV("%s: preview format %s", __func__, str_preview_format);
+ mFrameSizeDelta = 16;
+
+ if (w->set_usage(w, GRALLOC_USAGE_SW_WRITE_OFTEN)) {
+ LOGE("%s: could not set usage on gralloc buffer", __func__);
+ return INVALID_OPERATION;
+ }
+
+ if (w->set_buffers_geometry(w,
+ preview_width, preview_height,
+ hal_pixel_format)) {
+ LOGE("%s: could not set buffers geometry to %s",
+ __func__, str_preview_format);
+ return INVALID_OPERATION;
+ }
+
+ if (mPreviewRunning && mPreviewStartDeferred) {
+ LOGV("start/resume preview");
+ status_t ret = startPreviewInternal();
+ if (ret == OK) {
+ mPreviewStartDeferred = false;
+ mPreviewCondition.signal();
+ }
+ }
+ mPreviewLock.unlock();
+
+ return OK;
}
-void CameraHardwareSec::setCallbacks(notify_callback notify_cb,
- data_callback data_cb,
- data_callback_timestamp data_cb_timestamp,
- void *user)
+void CameraHardwareSec::setCallbacks(camera_notify_callback notify_cb,
+ camera_data_callback data_cb,
+ camera_data_timestamp_callback data_cb_timestamp,
+ camera_request_memory get_memory,
+ void *user)
{
mNotifyCb = notify_cb;
mDataCb = data_cb;
mDataCbTimestamp = data_cb_timestamp;
+ mGetMemoryCb = get_memory;
mCallbackCookie = user;
}
@@ -397,6 +450,7 @@ 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);
}
@@ -460,10 +514,14 @@ int CameraHardwareSec::previewThread()
LOGE("ERR(%s):Fail on SecCamera->getPreview()", __func__);
return UNKNOWN_ERROR;
}
+
+// LOGV("%s: index %d", __func__, index);
+
mSkipFrameLock.lock();
if (mSkipFrame > 0) {
mSkipFrame--;
mSkipFrameLock.unlock();
+ LOGV("%s: index %d skipping frame", __func__, index);
return NO_ERROR;
}
mSkipFrameLock.unlock();
@@ -474,7 +532,8 @@ int CameraHardwareSec::previewThread()
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);
+ LOGE("ERR(%s):Fail on SecCamera getPhyAddr Y addr = %0x C addr = %0x",
+ __func__, phyYAddr, phyCAddr);
return UNKNOWN_ERROR;
}
@@ -482,37 +541,95 @@ int CameraHardwareSec::previewThread()
mSecCamera->getPreviewSize(&width, &height, &frame_size);
- offset = (frame_size + 16) * index;
- sp<MemoryBase> buffer = new MemoryBase(mPreviewHeap, offset, frame_size);
+ offset = (frame_size + mFrameSizeDelta) * index;
- memcpy(static_cast<unsigned char *>(mPreviewHeap->base()) + (offset + frame_size ), &phyYAddr, 4);
- memcpy(static_cast<unsigned char *>(mPreviewHeap->base()) + (offset + frame_size + 4), &phyCAddr, 4);
-
-#if defined(BOARD_USES_OVERLAY)
- if (mUseOverlay) {
- int ret;
- overlay_buffer_t overlay_buffer;
+#if 0 // FIXME: this does not seem to be necessary. Is it?
+ memcpy((char *)mPreviewHeap->data + offset + frame_size,
+ &phyYAddr, 4);
+ memcpy((char *)mPreviewHeap->data + offset + frame_size + 4,
+ &phyCAddr, 4);
+#endif
- mOverlayBufferIdx ^= 1;
- memcpy(static_cast<unsigned char*>(mPreviewHeap->base()) + offset + frame_size + sizeof(phyYAddr) + sizeof(phyCAddr),
- &mOverlayBufferIdx, sizeof(mOverlayBufferIdx));
+ if (mPreviewWindow && mGrallocHal) {
+ buffer_handle_t *buf_handle;
+ int stride;
+ if (0 != mPreviewWindow->dequeue_buffer(mPreviewWindow, &buf_handle, &stride)) {
+ LOGE("Could not dequeue gralloc buffer!\n");
+ goto callbacks;
+ }
- ret = mOverlay->queueBuffer((void*)(static_cast<unsigned char *>(mPreviewHeap->base()) + (offset + frame_size)));
+ void *vaddr;
+ if (!mGrallocHal->lock(mGrallocHal,
+ *buf_handle,
+ GRALLOC_USAGE_SW_WRITE_OFTEN,
+ 0, 0, width, height, &vaddr)) {
+ char *frame = ((char *)mPreviewHeap->data) + offset;
+ int total = frame_size + mFrameSizeDelta;
+
+ // the code below assumes YUV, not RGB
+ {
+ int h;
+ char *src = frame;
+ char *ptr = (char *)vaddr;
+
+ // Copy the Y plane, while observing the stride
+ for (h = 0; h < height; h++) {
+ memcpy(ptr, src, width);
+ ptr += stride;
+ src += width;
+ }
- 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__);
+ {
+ // U
+ char *v = ptr;
+ ptr += stride * height / 4;
+ for (h = 0; h < height / 2; h++) {
+ memcpy(ptr, src, width / 2);
+ ptr += stride / 2;
+ src += width / 2;
+ }
+ // V
+ ptr = v;
+ for (h = 0; h < height / 2; h++) {
+ memcpy(ptr, src, width / 2);
+ ptr += stride / 2;
+ src += width / 2;
+ }
+ }
}
- }
- }
-#endif
+ mGrallocHal->unlock(mGrallocHal, *buf_handle);
+ }
+ else
+ LOGE("%s: could not obtain gralloc buffer", __func__);
+
+ if (0 != mPreviewWindow->enqueue_buffer(mPreviewWindow, buf_handle)) {
+ LOGE("Could not enqueue gralloc buffer!\n");
+ goto callbacks;
+ }
+ }
+
+callbacks:
// Notify the client of a new frame.
if (mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME) {
- mDataCb(CAMERA_MSG_PREVIEW_FRAME, buffer, mCallbackCookie);
+ const char * preview_format = mParameters.getPreviewFormat();
+ if (!strcmp(preview_format, CameraParameters::PIXEL_FORMAT_YUV420SP)) {
+ // Color conversion from YUV420 to NV21
+ char *vu = ((char *)mPreviewHeap->data) + offset + width * height;
+ const int uv_size = (width * height) >> 1;
+ char saved_uv[uv_size];
+ memcpy(saved_uv, vu, uv_size);
+ char *u = saved_uv;
+ char *v = u + (uv_size >> 1);
+
+ int h = 0;
+ while (h < width * height / 4) {
+ *vu++ = *v++;
+ *vu++ = *u++;
+ ++h;
+ }
+ }
+ mDataCb(CAMERA_MSG_PREVIEW_FRAME, mPreviewHeap, index, NULL, mCallbackCookie);
}
Mutex::Autolock lock(mRecordLock);
@@ -527,20 +644,22 @@ int CameraHardwareSec::previewThread()
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);
+ LOGE("ERR(%s):Fail on SecCamera getRectPhyAddr Y addr = %0x C addr = %0x", __func__,
+ phyYAddr, phyCAddr);
return UNKNOWN_ERROR;
}
- addrs = (struct addrs *)mRecordHeap->base();
+ addrs = (struct addrs *)mRecordHeap->data;
- sp<MemoryBase> buffer = new MemoryBase(mRecordHeap, index * sizeof(struct addrs), sizeof(struct addrs));
+ addrs[index].type = kMetadataBufferTypeCameraSource;
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);
+ mDataCbTimestamp(timestamp, CAMERA_MSG_VIDEO_FRAME,
+ mRecordHeap, index, mCallbackCookie);
} else {
mSecCamera->releaseRecordFrame(index);
}
@@ -555,10 +674,8 @@ status_t CameraHardwareSec::startPreview()
LOGV("%s :", __func__);
- Mutex::Autolock lock(mStateLock);
- if (mCaptureInProgress) {
- LOGE("%s : capture in progress, not allowed", __func__);
- return INVALID_OPERATION;
+ if (waitCaptureCompletion() != NO_ERROR) {
+ return TIMED_OUT;
}
mPreviewLock.lock();
@@ -569,96 +686,78 @@ status_t CameraHardwareSec::startPreview()
return INVALID_OPERATION;
}
- setSkipFrame(INITIAL_SKIP_FRAME);
-
- ret = mSecCamera->startPreview();
- LOGV("%s : mSecCamera->startPreview() returned %d", __func__, ret);
+ mPreviewRunning = true;
+ mPreviewStartDeferred = false;
- if (ret < 0) {
- LOGE("ERR(%s):Fail on mSecCamera->startPreview()", __func__);
- return -1; //UNKNOWN_ERROR;
+ if (!mPreviewWindow) {
+ LOGI("%s : deferring", __func__);
+ mPreviewStartDeferred = true;
+ mPreviewLock.unlock();
+ return NO_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);
+ ret = startPreviewInternal();
+ if (ret == OK)
+ mPreviewCondition.signal();
- mPreviewRunning = true;
- mPreviewCondition.signal();
mPreviewLock.unlock();
-
- return NO_ERROR;
-}
-
-#if defined(BOARD_USES_OVERLAY)
-bool CameraHardwareSec::useOverlay()
-{
- LOGV("%s: returning true", __func__);
- return true;
+ return ret;
}
-status_t CameraHardwareSec::setOverlay(const sp<Overlay> &overlay)
+status_t CameraHardwareSec::startPreviewInternal()
{
- LOGV("%s :", __func__);
+ LOGV("%s", __func__);
- int overlayWidth = 0;
- int overlayHeight = 0;
- int overlayFrameSize = 0;
+ int ret = mSecCamera->startPreview();
+ LOGV("%s : mSecCamera->startPreview() returned %d", __func__, ret);
- if (overlay == NULL) {
- LOGV("%s : overlay == NULL", __func__);
- goto setOverlayFail;
+ if (ret < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->startPreview()", __func__);
+ return UNKNOWN_ERROR;
}
- LOGV("%s : overlay = %p", __func__, overlay->getHandleRef());
- if (overlay->getHandleRef()== NULL && mUseOverlay == true) {
- if (mOverlay != 0)
- mOverlay->destroy();
+ setSkipFrame(INITIAL_SKIP_FRAME);
- mOverlay = NULL;
- mUseOverlay = false;
+ int width, height, frame_size;
- return NO_ERROR;
- }
+ mSecCamera->getPreviewSize(&width, &height, &frame_size);
- if (overlay->getStatus() != NO_ERROR) {
- LOGE("ERR(%s):overlay->getStatus() fail", __func__);
- goto setOverlayFail;
+ LOGD("mPreviewHeap(fd(%d), size(%d), width(%d), height(%d))",
+ mSecCamera->getCameraFd(), frame_size + mFrameSizeDelta, width, height);
+ if (mPreviewHeap) {
+ mPreviewHeap->release(mPreviewHeap);
+ mPreviewHeap = 0;
}
- mSecCamera->getPreviewSize(&overlayWidth, &overlayHeight, &overlayFrameSize);
+ mPreviewHeap = mGetMemoryCb((int)mSecCamera->getCameraFd(),
+ frame_size + mFrameSizeDelta,
+ kBufferCount,
+ 0); // no cookie
- 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;
+ mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize);
+ LOGV("CameraHardwareSec: mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d",
+ mPostViewWidth,mPostViewHeight,mPostViewSize);
return NO_ERROR;
+}
-setOverlayFail :
- if (mOverlay != 0)
- mOverlay->destroy();
- mOverlay = 0;
-
- mUseOverlay = false;
+void CameraHardwareSec::stopPreviewInternal()
+{
+ LOGV("%s :", __func__);
- return UNKNOWN_ERROR;
+ /* request that the preview thread stop. */
+ if (mPreviewRunning) {
+ mPreviewRunning = false;
+ if (!mPreviewStartDeferred) {
+ mPreviewCondition.signal();
+ /* wait until preview thread is stopped */
+ mPreviewStoppedCondition.wait(mPreviewLock);
+ }
+ else
+ LOGV("%s : preview running but deferred, doing nothing", __func__);
+ } else
+ LOGI("%s : preview not running, doing nothing", __func__);
}
-#endif
void CameraHardwareSec::stopPreview()
{
@@ -666,14 +765,7 @@ void CameraHardwareSec::stopPreview()
/* 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__);
- }
+ stopPreviewInternal();
mPreviewLock.unlock();
}
@@ -692,6 +784,16 @@ status_t CameraHardwareSec::startRecording()
Mutex::Autolock lock(mRecordLock);
+ if (mRecordHeap) {
+ mRecordHeap->release(mRecordHeap);
+ mRecordHeap = 0;
+ }
+ mRecordHeap = mGetMemoryCb(-1, sizeof(struct addrs), kBufferCount, NULL);
+ if (!mRecordHeap) {
+ LOGE("ERR(%s): Record heap creation fail", __func__);
+ return UNKNOWN_ERROR;
+ }
+
if (mRecordRunning == false) {
if (mSecCamera->startRecord() < 0) {
LOGE("ERR(%s):Fail on mSecCamera->startRecord()", __func__);
@@ -724,12 +826,9 @@ bool CameraHardwareSec::recordingEnabled()
return mRecordRunning;
}
-void CameraHardwareSec::releaseRecordingFrame(const sp<IMemory>& mem)
+void CameraHardwareSec::releaseRecordingFrame(const void *opaque)
{
- ssize_t offset;
- sp<IMemoryHeap> heap = mem->getMemory(&offset, NULL);
- struct addrs *addrs = (struct addrs *)((uint8_t *)heap->base() + offset);
-
+ struct addrs *addrs = (struct addrs *)opaque;
mSecCamera->releaseRecordFrame(addrs->buf_index);
}
@@ -959,6 +1058,8 @@ int CameraHardwareSec::pictureThread()
int mPostViewWidth, mPostViewHeight, mPostViewSize;
int mThumbWidth, mThumbHeight, mThumbSize;
int cap_width, cap_height, cap_frame_size;
+ int JpegImageSize, JpegExifSize;
+ bool isLSISensor = false;
unsigned int output_size = 0;
@@ -974,58 +1075,52 @@ int CameraHardwareSec::pictureThread()
LOG_TIME_DEFINE(0)
LOG_TIME_START(0)
- sp<MemoryBase> buffer = new MemoryBase(mRawHeap, 0, mPostViewSize + 8);
+// sp<MemoryBase> buffer = new MemoryBase(mRawHeap, 0, mPostViewSize + 8);
- struct addrs_cap *addrs = (struct addrs_cap *)mRawHeap->base();
+ struct addrs_cap *addrs = (struct addrs_cap *)mRawHeap->data;
addrs[0].width = mPostViewWidth;
addrs[0].height = mPostViewHeight;
LOGV("[5B] mPostViewWidth = %d mPostViewHeight = %d\n",mPostViewWidth,mPostViewHeight);
- sp<MemoryHeapBase> JpegHeap = new MemoryHeapBase(mJpegHeapSize);
+ camera_memory_t *JpegHeap = mGetMemoryCb(-1, mJpegHeapSize, 1, 0);
sp<MemoryHeapBase> PostviewHeap = new MemoryHeapBase(mPostViewSize);
sp<MemoryHeapBase> ThumbnailHeap = new MemoryHeapBase(mThumbSize);
- if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE) {
- LOG_TIME_DEFINE(1)
- LOG_TIME_START(1)
+ 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();
+ int picture_size, picture_width, picture_height;
+ mSecCamera->getSnapshotSize(&picture_width, &picture_height, &picture_size);
+ int picture_format = mSecCamera->getSnapshotPixelFormat();
- unsigned int phyAddr;
+ 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);
- }
+ // 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");
+ 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;
+ goto out;
}
-
- LOG_TIME_END(1)
- LOG_CAMERA("getSnapshotAndJpeg interval: %lu us", LOG_TIME(1));
+ } else {
+ if (mSecCamera->getSnapshotAndJpeg((unsigned char*)PostviewHeap->base(),
+ (unsigned char*)JpegHeap->data, &output_size) < 0) {
+ ret = UNKNOWN_ERROR;
+ goto out;
+ }
+ LOGI("snapshotandjpeg done\n");
}
- int JpegImageSize, JpegExifSize;
- bool isLSISensor = false;
+ LOG_TIME_END(1)
+ LOG_CAMERA("getSnapshotAndJpeg interval: %lu us", LOG_TIME(1));
if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) {
isLSISensor = !strncmp((const char*)mCameraSensorName, "S5K4ECGX", 8);
@@ -1033,16 +1128,19 @@ int CameraHardwareSec::pictureThread()
LOGI("== Camera Sensor Detect %s - Samsung LSI SOC 5M ==\n", mCameraSensorName);
// LSI 5M SOC
if (!SplitFrame(jpeg_data, SecCamera::getInterleaveDataSize(),
- SecCamera::getJpegLineLength(),
- mPostViewWidth * 2, mPostViewWidth,
- JpegHeap->base(), &JpegImageSize,
- PostviewHeap->base(), &mPostViewSize))
- return UNKNOWN_ERROR;
+ SecCamera::getJpegLineLength(),
+ mPostViewWidth * 2, mPostViewWidth,
+ JpegHeap->data, &JpegImageSize,
+ PostviewHeap->base(), &mPostViewSize)) {
+ ret = UNKNOWN_ERROR;
+ goto out;
+ }
} else {
LOGI("== Camera Sensor Detect %s Sony SOC 5M ==\n", mCameraSensorName);
- decodeInterleaveData(jpeg_data, SecCamera::getInterleaveDataSize(), mPostViewWidth, mPostViewHeight,
- &JpegImageSize, JpegHeap->base(), PostviewHeap->base());
-
+ decodeInterleaveData(jpeg_data,
+ SecCamera::getInterleaveDataSize(),
+ mPostViewWidth, mPostViewHeight,
+ &JpegImageSize, JpegHeap->data, PostviewHeap->base());
}
} else {
JpegImageSize = static_cast<int>(output_size);
@@ -1050,70 +1148,36 @@ int CameraHardwareSec::pictureThread()
scaleDownYuv422((char *)PostviewHeap->base(), mPostViewWidth, mPostViewHeight,
(char *)ThumbnailHeap->base(), mThumbWidth, mThumbHeight);
- memcpy(mRawHeap->base(),PostviewHeap->base(), postviewHeapSize);
-
-#if defined(BOARD_USES_OVERLAY)
- /* Put postview image to Overlay */
- unsigned int index = 0;
- unsigned int offset = ((mPostViewWidth*mPostViewHeight*3/2) + 16) * index;
- unsigned int overlay_header[4];
-
- // Only show postview image if size is VGA since sensor cannot deliver
- // any other sizes.
- int previewWidth, previewHeight, previewSize;
- mSecCamera->getPreviewSize(&previewWidth, &previewHeight, &previewSize);
- if ((previewWidth != 640) || (previewHeight != 480))
- goto PostviewOverlayEnd;
-
- mOverlayBufferIdx ^= 1;
- overlay_header[0]= mSecCamera->getPhyAddrY(index);
- overlay_header[1]= overlay_header[0] + mPostViewWidth*mPostViewHeight;
- overlay_header[2]= mOverlayBufferIdx;
-
- YUY2toNV21(mRawHeap->base(), (void*)(static_cast<unsigned char *>(mPreviewHeap->base()) + offset),
- mPostViewWidth, mPostViewHeight);
-
- memcpy(static_cast<unsigned char*>(mPreviewHeap->base()) + offset + (mPostViewWidth*mPostViewHeight * 3 / 2),
- overlay_header, 16);
+ memcpy(mRawHeap->data, PostviewHeap->base(), postviewHeapSize);
- ret = mOverlay->queueBuffer((void*)(static_cast<unsigned char *>(mPreviewHeap->base()) + offset +
- (mPostViewWidth*mPostViewHeight * 3 / 2)));
-
- if (ret == -1) {
- LOGE("ERR(%s):overlay queueBuffer fail", __func__);
- } else if (ret != ALL_BUFFERS_FLUSHED) {
- overlay_buffer_t overlay_buffer;
- ret = mOverlay->dequeueBuffer(&overlay_buffer);
- if (ret == -1) {
- LOGE("ERR(%s):overlay dequeueBuffer fail", __func__);
- }
- }
-
-PostviewOverlayEnd:
-#endif
if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE) {
- mDataCb(CAMERA_MSG_RAW_IMAGE, buffer, mCallbackCookie);
+ mDataCb(CAMERA_MSG_RAW_IMAGE, mRawHeap, 0, NULL, mCallbackCookie);
+ } else if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE_NOTIFY) {
+ mNotifyCb(CAMERA_MSG_RAW_IMAGE_NOTIFY, 0, 0, mCallbackCookie);
}
+
if (mMsgEnabled & CAMERA_MSG_COMPRESSED_IMAGE) {
- sp<MemoryHeapBase> ExifHeap = new MemoryHeapBase(EXIF_FILE_SIZE + JPG_STREAM_BUF_SIZE);
- JpegExifSize = mSecCamera->getExif((unsigned char *)ExifHeap->base(),
- (unsigned char *)ThumbnailHeap->base());
+ camera_memory_t *ExifHeap =
+ mGetMemoryCb(-1, EXIF_FILE_SIZE + JPG_STREAM_BUF_SIZE, 1, 0);
+ JpegExifSize = mSecCamera->getExif((unsigned char *)ExifHeap->data,
+ (unsigned char *)ThumbnailHeap->base());
LOGV("JpegExifSize=%d", JpegExifSize);
if (JpegExifSize < 0) {
ret = UNKNOWN_ERROR;
+ ExifHeap->release(ExifHeap);
goto out;
}
- unsigned char *ExifStart = (unsigned char *)JpegHeap->base() + 2;
- unsigned char *ImageStart = ExifStart + JpegExifSize;
-
- memmove(ImageStart, ExifStart, JpegImageSize - 2);
- memcpy(ExifStart, ExifHeap->base(), JpegExifSize);
- sp<MemoryBase> mem = new MemoryBase(JpegHeap, 0, JpegImageSize + JpegExifSize);
-
- mDataCb(CAMERA_MSG_COMPRESSED_IMAGE, mem, mCallbackCookie);
+ camera_memory_t *mem = mGetMemoryCb(-1, JpegImageSize + JpegExifSize, 1, 0);
+ uint8_t *ptr = (uint8_t *) mem->data;
+ memcpy(ptr, JpegHeap->data, 2); ptr += 2;
+ memcpy(ptr, ExifHeap->data, JpegExifSize); ptr += JpegExifSize;
+ memcpy(ptr, (uint8_t *) JpegHeap->data + 2, JpegImageSize - 2);
+ mDataCb(CAMERA_MSG_COMPRESSED_IMAGE, mem, 0, NULL, mCallbackCookie);
+ mem->release(mem);
+ ExifHeap->release(ExifHeap);
}
LOG_TIME_END(0)
@@ -1122,37 +1186,71 @@ PostviewOverlayEnd:
LOGV("%s : pictureThread end", __func__);
out:
- mStateLock.lock();
+ JpegHeap->release(JpegHeap);
+ mSecCamera->endSnapshot();
+ mCaptureLock.lock();
mCaptureInProgress = false;
- mStateLock.unlock();
+ mCaptureCondition.broadcast();
+ mCaptureLock.unlock();
return ret;
}
+status_t CameraHardwareSec::waitCaptureCompletion() {
+ // 5 seconds timeout
+ nsecs_t endTime = 5000000000LL + systemTime(SYSTEM_TIME_MONOTONIC);
+ Mutex::Autolock lock(mCaptureLock);
+ while (mCaptureInProgress) {
+ nsecs_t remainingTime = endTime - systemTime(SYSTEM_TIME_MONOTONIC);
+ if (remainingTime <= 0) {
+ LOGE("Timed out waiting picture thread.");
+ return TIMED_OUT;
+ }
+ LOGD("Waiting for picture thread to complete.");
+ mCaptureCondition.waitRelative(mCaptureLock, remainingTime);
+ }
+ return NO_ERROR;
+}
+
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 (!mRawHeap) {
+ int rawHeapSize = mPostViewSize;
+ LOGV("mRawHeap : MemoryHeapBase(previewHeapSize(%d))", rawHeapSize);
+ mRawHeap = mGetMemoryCb(-1, rawHeapSize, 1, 0);
+ if (!mRawHeap) {
+ LOGE("ERR(%s): Raw heap creation fail", __func__);
+ }
+ }
+
+ if (waitCaptureCompletion() != NO_ERROR) {
+ return TIMED_OUT;
}
if (mPictureThread->run("CameraPictureThread", PRIORITY_DEFAULT) != NO_ERROR) {
LOGE("%s : couldn't run picture thread", __func__);
return INVALID_OPERATION;
}
+ mCaptureLock.lock();
mCaptureInProgress = true;
+ mCaptureLock.unlock();
return NO_ERROR;
}
status_t CameraHardwareSec::cancelPicture()
{
- mPictureThread->requestExitAndWait();
+ LOGV("%s", __func__);
+
+ if (mPictureThread.get()) {
+ LOGV("%s: waiting for picture thread to exit", __func__);
+ mPictureThread->requestExitAndWait();
+ LOGV("%s: picture thread has exited", __func__);
+ }
return NO_ERROR;
}
@@ -1212,7 +1310,7 @@ bool CameraHardwareSec::SplitFrame(unsigned char *pFrame, int dwSize,
LOGV("===========SplitFrame Start==============");
if (NULL == pFrame || 0 >= dwSize) {
- LOGE("There is no contents.\r\n");
+ LOGE("There is no contents (pFrame=%p, dwSize=%d", pFrame, dwSize);
return false;
}
@@ -1387,14 +1485,15 @@ int CameraHardwareSec::decodeInterleaveData(unsigned char *pInterleaveData,
return ret;
}
-status_t CameraHardwareSec::dump(int fd, const Vector<String16>& args) const
+status_t CameraHardwareSec::dump(int fd) const
{
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
+ const Vector<String16> args;
if (mSecCamera != 0) {
- mSecCamera->dump(fd, args);
+ mSecCamera->dump(fd);
mParameters.dump(fd, args);
mInternalParameters.dump(fd, args);
snprintf(buffer, 255, " preview running(%s)\n", mPreviewRunning?"true": "false");
@@ -1420,6 +1519,33 @@ bool CameraHardwareSec::isSupportedPreviewSize(const int width,
return false;
}
+bool CameraHardwareSec::isSupportedParameter(const char * const parm,
+ const char * const supported_parm) const
+{
+ const char *pStart;
+ const char *pEnd;
+
+ if (!parm || !supported_parm)
+ return false;
+
+ pStart = supported_parm;
+
+ while (true) {
+ pEnd = strchr(pStart, ',');
+ if (!pEnd) {
+ if (!strcmp(parm, pStart))
+ return true;
+ else
+ return false;
+ }
+ if (!strncmp(parm, pStart, pEnd - pStart)) {
+ return true;
+ }
+ pStart = pEnd + 1;
+ }
+ /* NOTREACHED */
+}
+
status_t CameraHardwareSec::setParameters(const CameraParameters& params)
{
LOGV("%s :", __func__);
@@ -1427,16 +1553,11 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params)
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
+ * up the sensor quite a bit so return error.
*/
- mStateLock.lock();
- if (mCaptureInProgress) {
- mStateLock.unlock();
- LOGE("%s : capture in progress, not allowed", __func__);
- return UNKNOWN_ERROR;
+ if (waitCaptureCompletion() != NO_ERROR) {
+ return TIMED_OUT;
}
- mStateLock.unlock();
// preview size
int new_preview_width = 0;
@@ -1446,44 +1567,54 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params)
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 (strcmp(new_str_preview_format, CameraParameters::PIXEL_FORMAT_YUV420SP) &&
+ strcmp(new_str_preview_format, CameraParameters::PIXEL_FORMAT_YUV420P)) {
+ LOGE("Unsupported preview color format: %s", new_str_preview_format);
+ return BAD_VALUE;
+ }
+
if (0 < new_preview_width && 0 < new_preview_height &&
new_str_preview_format != NULL &&
isSupportedPreviewSize(new_preview_width, new_preview_height)) {
- 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
+ int new_preview_format = V4L2_PIX_FMT_YUV420;
+ mFrameSizeDelta = 16;
+
+ int current_preview_width, current_preview_height, current_frame_size;
+ mSecCamera->getPreviewSize(&current_preview_width,
+ &current_preview_height,
+ &current_frame_size);
+ int current_pixel_format = mSecCamera->getPreviewPixelFormat();
+
+ if (current_preview_width != new_preview_width ||
+ current_preview_height != new_preview_height ||
+ current_pixel_format != new_preview_format) {
+ 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 {
+ if (mPreviewWindow) {
+ if (mPreviewRunning && !mPreviewStartDeferred) {
+ LOGE("ERR(%s): preview is running, cannot change size and format!",
+ __func__);
+ ret = INVALID_OPERATION;
+ }
+
+ LOGV("%s: mPreviewWindow (%p) set_buffers_geometry", __func__, mPreviewWindow);
+ LOGV("%s: mPreviewWindow->set_buffers_geometry (%p)", __func__,
+ mPreviewWindow->set_buffers_geometry);
+ mPreviewWindow->set_buffers_geometry(mPreviewWindow,
+ new_preview_width, new_preview_height,
+ new_preview_format);
+ LOGV("%s: DONE mPreviewWindow (%p) set_buffers_geometry", __func__, mPreviewWindow);
+ }
- 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
+ else LOGV("%s: preview size and format has not changed", __func__);
} else {
LOGE("%s: Invalid preview size(%dx%d)",
__func__, new_preview_width, new_preview_height);
@@ -1497,6 +1628,7 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params)
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) {
+ LOGV("%s: setSnapshotSize", __func__);
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);
@@ -1514,6 +1646,8 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params)
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_RGBA8888))
+ new_picture_format = V4L2_PIX_FMT_RGB32;
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"))
@@ -1671,13 +1805,13 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params)
ret = UNKNOWN_ERROR;
}
- if (new_scene_mode_str != NULL) {
+ const char *new_focus_mode_str = params.get(CameraParameters::KEY_FOCUS_MODE);
+
+ if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) {
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,
@@ -1685,6 +1819,7 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params)
if (!strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_AUTO)) {
new_scene_mode = SCENE_MODE_NONE;
+ mParameters.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "on,off,auto,torch");
} else {
// defaults for non-auto scene modes
if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) {
@@ -1696,36 +1831,52 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params)
CameraParameters::SCENE_MODE_PORTRAIT)) {
new_scene_mode = SCENE_MODE_PORTRAIT;
new_flash_mode_str = CameraParameters::FLASH_MODE_AUTO;
+ mParameters.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "auto");
} else if (!strcmp(new_scene_mode_str,
CameraParameters::SCENE_MODE_LANDSCAPE)) {
new_scene_mode = SCENE_MODE_LANDSCAPE;
+ new_flash_mode_str = CameraParameters::FLASH_MODE_OFF;
+ mParameters.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "off");
} else if (!strcmp(new_scene_mode_str,
CameraParameters::SCENE_MODE_SPORTS)) {
new_scene_mode = SCENE_MODE_SPORTS;
+ new_flash_mode_str = CameraParameters::FLASH_MODE_OFF;
+ mParameters.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "off");
} 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;
+ mParameters.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "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;
+ new_flash_mode_str = CameraParameters::FLASH_MODE_OFF;
+ mParameters.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "off");
} else if (!strcmp(new_scene_mode_str,
CameraParameters::SCENE_MODE_SUNSET)) {
new_scene_mode = SCENE_MODE_SUNSET;
+ new_flash_mode_str = CameraParameters::FLASH_MODE_OFF;
+ mParameters.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "off");
} 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");
+ new_flash_mode_str = CameraParameters::FLASH_MODE_OFF;
+ mParameters.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "off");
} else if (!strcmp(new_scene_mode_str,
CameraParameters::SCENE_MODE_FIREWORKS)) {
new_scene_mode = SCENE_MODE_FIREWORKS;
+ new_flash_mode_str = CameraParameters::FLASH_MODE_OFF;
+ mParameters.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "off");
} else if (!strcmp(new_scene_mode_str,
CameraParameters::SCENE_MODE_CANDLELIGHT)) {
new_scene_mode = SCENE_MODE_CANDLE_LIGHT;
+ new_flash_mode_str = CameraParameters::FLASH_MODE_OFF;
+ mParameters.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "off");
} else {
LOGE("%s::unmatched scene_mode(%s)",
__func__, new_scene_mode_str); //action, night-portrait, theatre, steadyphoto
@@ -1805,6 +1956,12 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params)
mParameters.set(CameraParameters::KEY_SCENE_MODE, new_scene_mode_str);
}
}
+ } else {
+ if (!isSupportedParameter(new_focus_mode_str,
+ mParameters.get(CameraParameters::KEY_SUPPORTED_FOCUS_MODES))) {
+ LOGE("%s: Unsupported focus mode: %s", __func__, new_focus_mode_str);
+ ret = UNKNOWN_ERROR;
+ }
}
// ---------------------------------------------------------------------------
@@ -2080,7 +2237,7 @@ status_t CameraHardwareSec::sendCommand(int32_t command, int32_t arg1, int32_t a
void CameraHardwareSec::release()
{
- LOGV("%s :", __func__);
+ 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
@@ -2116,51 +2273,36 @@ void CameraHardwareSec::release()
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 (mRawHeap) {
+ mRawHeap->release(mRawHeap);
+ mRawHeap = 0;
}
-
- if (mRecordHeap != NULL)
- mRecordHeap.clear();
-
-#if defined(BOARD_USES_OVERLAY)
- if (mUseOverlay) {
- mOverlay->destroy();
- mUseOverlay = false;
- mOverlay = NULL;
+ if (mPreviewHeap) {
+ mPreviewHeap->release(mPreviewHeap);
+ mPreviewHeap = 0;
+ }
+ if (mRecordHeap) {
+ mRecordHeap->release(mRecordHeap);
+ mRecordHeap = 0;
}
-#endif
- /* close after all the heaps are cleared since those
+ /* close after all the heaps are cleared since those
* could have dup'd our file descriptor.
*/
mSecCamera->DeinitCamera();
- mSecCamera = NULL;
-
}
-wp<CameraHardwareInterface> CameraHardwareSec::singleton;
-
-sp<CameraHardwareInterface> CameraHardwareSec::createInstance(int cameraId)
+status_t CameraHardwareSec::storeMetaDataInBuffers(bool enable)
{
- LOGV("%s :", __func__);
- if (singleton != 0) {
- sp<CameraHardwareInterface> hardware = singleton.promote();
- if (hardware != 0) {
- return hardware;
- }
+ // FIXME:
+ // metadata buffer mode can be turned on or off.
+ // Samsung needs to fix this.
+ if (!enable) {
+ LOGE("Non-metadata buffer mode is not supported!");
+ return INVALID_OPERATION;
}
- sp<CameraHardwareInterface> hardware(new CameraHardwareSec(cameraId));
- singleton = hardware;
- return hardware;
+ return OK;
}
static CameraInfo sCameraInfo[] = {
@@ -2174,19 +2316,408 @@ static CameraInfo sCameraInfo[] = {
}
};
-extern "C" int HAL_getNumberOfCameras()
+/** Close this device */
+
+static camera_device_t *g_cam_device;
+
+static int HAL_camera_device_close(struct hw_device_t* device)
+{
+ LOGI("%s", __func__);
+ if (device) {
+ camera_device_t *cam_device = (camera_device_t *)device;
+ delete static_cast<CameraHardwareSec *>(cam_device->priv);
+ free(cam_device);
+ g_cam_device = 0;
+ }
+ return 0;
+}
+
+static inline CameraHardwareSec *obj(struct camera_device *dev)
+{
+ return reinterpret_cast<CameraHardwareSec *>(dev->priv);
+}
+
+/** Set the preview_stream_ops to which preview frames are sent */
+static int HAL_camera_device_set_preview_window(struct camera_device *dev,
+ struct preview_stream_ops *buf)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->setPreviewWindow(buf);
+}
+
+/** Set the notification and data callbacks */
+static void HAL_camera_device_set_callbacks(struct camera_device *dev,
+ camera_notify_callback notify_cb,
+ camera_data_callback data_cb,
+ camera_data_timestamp_callback data_cb_timestamp,
+ camera_request_memory get_memory,
+ void* user)
+{
+ LOGV("%s", __func__);
+ obj(dev)->setCallbacks(notify_cb, data_cb, data_cb_timestamp,
+ get_memory,
+ user);
+}
+
+/**
+ * The following three functions all take a msg_type, which is a bitmask of
+ * the messages defined in include/ui/Camera.h
+ */
+
+/**
+ * Enable a message, or set of messages.
+ */
+static void HAL_camera_device_enable_msg_type(struct camera_device *dev, int32_t msg_type)
+{
+ LOGV("%s", __func__);
+ obj(dev)->enableMsgType(msg_type);
+}
+
+/**
+ * Disable a message, or a set of messages.
+ *
+ * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera
+ * HAL should not rely on its client to call releaseRecordingFrame() to
+ * release video recording frames sent out by the cameral HAL before and
+ * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL
+ * clients must not modify/access any video recording frame after calling
+ * disableMsgType(CAMERA_MSG_VIDEO_FRAME).
+ */
+static void HAL_camera_device_disable_msg_type(struct camera_device *dev, int32_t msg_type)
{
+ LOGV("%s", __func__);
+ obj(dev)->disableMsgType(msg_type);
+}
+
+/**
+ * Query whether a message, or a set of messages, is enabled. Note that
+ * this is operates as an AND, if any of the messages queried are off, this
+ * will return false.
+ */
+static int HAL_camera_device_msg_type_enabled(struct camera_device *dev, int32_t msg_type)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->msgTypeEnabled(msg_type);
+}
+
+/**
+ * Start preview mode.
+ */
+static int HAL_camera_device_start_preview(struct camera_device *dev)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->startPreview();
+}
+
+/**
+ * Stop a previously started preview.
+ */
+static void HAL_camera_device_stop_preview(struct camera_device *dev)
+{
+ LOGV("%s", __func__);
+ obj(dev)->stopPreview();
+}
+
+/**
+ * Returns true if preview is enabled.
+ */
+static int HAL_camera_device_preview_enabled(struct camera_device *dev)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->previewEnabled();
+}
+
+/**
+ * Request the camera HAL to store meta data or real YUV data in the video
+ * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If
+ * it is not called, the default camera HAL behavior is to store real YUV
+ * data in the video buffers.
+ *
+ * This method should be called before startRecording() in order to be
+ * effective.
+ *
+ * If meta data is stored in the video buffers, it is up to the receiver of
+ * the video buffers to interpret the contents and to find the actual frame
+ * data with the help of the meta data in the buffer. How this is done is
+ * outside of the scope of this method.
+ *
+ * Some camera HALs may not support storing meta data in the video buffers,
+ * but all camera HALs should support storing real YUV data in the video
+ * buffers. If the camera HAL does not support storing the meta data in the
+ * video buffers when it is requested to do do, INVALID_OPERATION must be
+ * returned. It is very useful for the camera HAL to pass meta data rather
+ * than the actual frame data directly to the video encoder, since the
+ * amount of the uncompressed frame data can be very large if video size is
+ * large.
+ *
+ * @param enable if true to instruct the camera HAL to store
+ * meta data in the video buffers; false to instruct
+ * the camera HAL to store real YUV data in the video
+ * buffers.
+ *
+ * @return OK on success.
+ */
+static int HAL_camera_device_store_meta_data_in_buffers(struct camera_device *dev, int enable)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->storeMetaDataInBuffers(enable);
+}
+
+/**
+ * Start record mode. When a record image is available, a
+ * CAMERA_MSG_VIDEO_FRAME message is sent with the corresponding
+ * frame. Every record frame must be released by a camera HAL client via
+ * releaseRecordingFrame() before the client calls
+ * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls
+ * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
+ * responsibility to manage the life-cycle of the video recording frames,
+ * and the client must not modify/access any video recording frames.
+ */
+static int HAL_camera_device_start_recording(struct camera_device *dev)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->startRecording();
+}
+
+/**
+ * Stop a previously started recording.
+ */
+static void HAL_camera_device_stop_recording(struct camera_device *dev)
+{
+ LOGV("%s", __func__);
+ obj(dev)->stopRecording();
+}
+
+/**
+ * Returns true if recording is enabled.
+ */
+static int HAL_camera_device_recording_enabled(struct camera_device *dev)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->recordingEnabled();
+}
+
+/**
+ * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME.
+ *
+ * It is camera HAL client's responsibility to release video recording
+ * frames sent out by the camera HAL before the camera HAL receives a call
+ * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to
+ * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
+ * responsibility to manage the life-cycle of the video recording frames.
+ */
+static void HAL_camera_device_release_recording_frame(struct camera_device *dev,
+ const void *opaque)
+{
+ LOGV("%s", __func__);
+ obj(dev)->releaseRecordingFrame(opaque);
+}
+
+/**
+ * Start auto focus, the notification callback routine is called with
+ * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() will be
+ * called again if another auto focus is needed.
+ */
+static int HAL_camera_device_auto_focus(struct camera_device *dev)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->autoFocus();
+}
+
+/**
+ * Cancels auto-focus function. If the auto-focus is still in progress,
+ * this function will cancel it. Whether the auto-focus is in progress or
+ * not, this function will return the focus position to the default. If
+ * the camera does not support auto-focus, this is a no-op.
+ */
+static int HAL_camera_device_cancel_auto_focus(struct camera_device *dev)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->cancelAutoFocus();
+}
+
+/**
+ * Take a picture.
+ */
+static int HAL_camera_device_take_picture(struct camera_device *dev)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->takePicture();
+}
+
+/**
+ * Cancel a picture that was started with takePicture. Calling this method
+ * when no picture is being taken is a no-op.
+ */
+static int HAL_camera_device_cancel_picture(struct camera_device *dev)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->cancelPicture();
+}
+
+/**
+ * Set the camera parameters. This returns BAD_VALUE if any parameter is
+ * invalid or not supported.
+ */
+static int HAL_camera_device_set_parameters(struct camera_device *dev,
+ const char *parms)
+{
+ LOGV("%s", __func__);
+ String8 str(parms);
+ CameraParameters p(str);
+ return obj(dev)->setParameters(p);
+}
+
+/** Return the camera parameters. */
+char *HAL_camera_device_get_parameters(struct camera_device *dev)
+{
+ LOGV("%s", __func__);
+ String8 str;
+ CameraParameters parms = obj(dev)->getParameters();
+ str = parms.flatten();
+ return strdup(str.string());
+}
+
+void HAL_camera_device_put_parameters(struct camera_device *dev, char *parms)
+{
+ LOGV("%s", __func__);
+ free(parms);
+}
+
+/**
+ * Send command to camera driver.
+ */
+static int HAL_camera_device_send_command(struct camera_device *dev,
+ int32_t cmd, int32_t arg1, int32_t arg2)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->sendCommand(cmd, arg1, arg2);
+}
+
+/**
+ * Release the hardware resources owned by this object. Note that this is
+ * *not* done in the destructor.
+ */
+static void HAL_camera_device_release(struct camera_device *dev)
+{
+ LOGV("%s", __func__);
+ obj(dev)->release();
+}
+
+/**
+ * Dump state of the camera hardware
+ */
+static int HAL_camera_device_dump(struct camera_device *dev, int fd)
+{
+ LOGV("%s", __func__);
+ return obj(dev)->dump(fd);
+}
+
+static int HAL_getNumberOfCameras()
+{
+ LOGV("%s", __func__);
return sizeof(sCameraInfo) / sizeof(sCameraInfo[0]);
}
-extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo *cameraInfo)
+static int HAL_getCameraInfo(int cameraId, struct camera_info *cameraInfo)
{
+ LOGV("%s", __func__);
memcpy(cameraInfo, &sCameraInfo[cameraId], sizeof(CameraInfo));
+ return 0;
}
-extern "C" sp<CameraHardwareInterface> HAL_openCameraHardware(int cameraId)
+#define SET_METHOD(m) m : HAL_camera_device_##m
+
+static camera_device_ops_t camera_device_ops = {
+ SET_METHOD(set_preview_window),
+ SET_METHOD(set_callbacks),
+ SET_METHOD(enable_msg_type),
+ SET_METHOD(disable_msg_type),
+ SET_METHOD(msg_type_enabled),
+ SET_METHOD(start_preview),
+ SET_METHOD(stop_preview),
+ SET_METHOD(preview_enabled),
+ SET_METHOD(store_meta_data_in_buffers),
+ SET_METHOD(start_recording),
+ SET_METHOD(stop_recording),
+ SET_METHOD(recording_enabled),
+ SET_METHOD(release_recording_frame),
+ SET_METHOD(auto_focus),
+ SET_METHOD(cancel_auto_focus),
+ SET_METHOD(take_picture),
+ SET_METHOD(cancel_picture),
+ SET_METHOD(set_parameters),
+ SET_METHOD(get_parameters),
+ SET_METHOD(put_parameters),
+ SET_METHOD(send_command),
+ SET_METHOD(release),
+ SET_METHOD(dump),
+};
+
+#undef SET_METHOD
+
+static int HAL_camera_device_open(const struct hw_module_t* module,
+ const char *id,
+ struct hw_device_t** device)
{
- return CameraHardwareSec::createInstance(cameraId);
+ LOGV("%s", __func__);
+
+ int cameraId = atoi(id);
+ if (cameraId < 0 || cameraId >= HAL_getNumberOfCameras()) {
+ LOGE("Invalid camera ID %s", id);
+ return -EINVAL;
+ }
+
+ if (g_cam_device) {
+ if (obj(g_cam_device)->getCameraId() == cameraId) {
+ LOGV("returning existing camera ID %s", id);
+ goto done;
+ } else {
+ LOGE("Cannot open camera %d. camera %d is already running!",
+ cameraId, obj(g_cam_device)->getCameraId());
+ return -ENOSYS;
+ }
+ }
+
+ g_cam_device = (camera_device_t *)malloc(sizeof(camera_device_t));
+ if (!g_cam_device)
+ return -ENOMEM;
+
+ g_cam_device->common.tag = HARDWARE_DEVICE_TAG;
+ g_cam_device->common.version = 1;
+ g_cam_device->common.module = const_cast<hw_module_t *>(module);
+ g_cam_device->common.close = HAL_camera_device_close;
+
+ g_cam_device->ops = &camera_device_ops;
+
+ LOGI("%s: open camera %s", __func__, id);
+
+ g_cam_device->priv = new CameraHardwareSec(cameraId, g_cam_device);
+
+done:
+ *device = (hw_device_t *)g_cam_device;
+ LOGI("%s: opened camera %s (%p)", __func__, id, *device);
+ return 0;
+}
+
+static hw_module_methods_t camera_module_methods = {
+ open : HAL_camera_device_open
+};
+
+extern "C" {
+ struct camera_module HAL_MODULE_INFO_SYM = {
+ common : {
+ tag : HARDWARE_MODULE_TAG,
+ version_major : 1,
+ version_minor : 0,
+ id : CAMERA_HARDWARE_MODULE_ID,
+ name : "Crespo camera HAL",
+ author : "Samsung Corporation",
+ methods : &camera_module_methods,
+ },
+ get_number_of_cameras : HAL_getNumberOfCameras,
+ get_camera_info : HAL_getCameraInfo
+ };
}
}; // namespace android
diff --git a/libcamera/SecCameraHWInterface.h b/libcamera/SecCameraHWInterface.h
index 97c0a35..3254b7b 100644
--- a/libcamera/SecCameraHWInterface.h
+++ b/libcamera/SecCameraHWInterface.h
@@ -21,20 +21,20 @@
#include "SecCamera.h"
#include <utils/threads.h>
-#include <camera/CameraHardwareInterface.h>
+#include <utils/RefBase.h>
#include <binder/MemoryBase.h>
#include <binder/MemoryHeapBase.h>
-#include <utils/threads.h>
+#include <hardware/camera.h>
+#include <hardware/gralloc.h>
+#include <camera/CameraParameters.h>
namespace android {
-class CameraHardwareSec : public CameraHardwareInterface {
+ class CameraHardwareSec : public virtual RefBase {
public:
- virtual sp<IMemoryHeap> getPreviewHeap() const;
- virtual sp<IMemoryHeap> getRawHeap() const;
-
- virtual void setCallbacks(notify_callback notify_cb,
- data_callback data_cb,
- data_callback_timestamp data_cb_timestamp,
+ virtual void setCallbacks(camera_notify_callback notify_cb,
+ camera_data_callback data_cb,
+ camera_data_timestamp_callback data_cb_timestamp,
+ camera_request_memory get_memory,
void *user);
virtual void enableMsgType(int32_t msgType);
@@ -42,37 +42,33 @@ public:
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> &overlay);
-#endif
virtual void stopPreview();
virtual bool previewEnabled();
virtual status_t startRecording();
virtual void stopRecording();
virtual bool recordingEnabled();
- virtual void releaseRecordingFrame(const sp<IMemory> &mem);
+ virtual void releaseRecordingFrame(const void *opaque);
virtual status_t autoFocus();
virtual status_t cancelAutoFocus();
virtual status_t takePicture();
virtual status_t cancelPicture();
- virtual status_t dump(int fd, const Vector<String16> &args) const;
+ virtual status_t dump(int fd) 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 status_t setPreviewWindow(const sp<ANativeWindow>& buf);
+ virtual status_t sendCommand(int32_t command, int32_t arg1, int32_t arg2);
+ virtual status_t setPreviewWindow(preview_stream_ops *w);
+ virtual status_t storeMetaDataInBuffers(bool enable);
virtual void release();
- static sp<CameraHardwareInterface> createInstance(int cameraId);
+ inline int getCameraId() const;
-private:
- CameraHardwareSec(int cameraId);
+ CameraHardwareSec(int cameraId, camera_device_t *dev);
virtual ~CameraHardwareSec();
-
- static wp<CameraHardwareInterface> singleton;
+private:
+ status_t startPreviewInternal();
+ void stopPreviewInternal();
static const int kBufferCount = MAX_BUFFERS;
static const int kBufferCountForRecord = MAX_BUFFERS;
@@ -100,7 +96,6 @@ private:
mHardware(hw) { }
virtual bool threadLoop() {
mHardware->pictureThread();
- mHardware->mSecCamera->endSnapshot();
return false;
}
};
@@ -159,6 +154,9 @@ private:
void setSkipFrame(int frame);
bool isSupportedPreviewSize(const int width,
const int height) const;
+ bool isSupportedParameter(const char * const parm,
+ const char * const supported_parm) const;
+ status_t waitCaptureCompletion();
/* used by auto focus thread to block until it's told to run */
mutable Mutex mFocusLock;
mutable Condition mFocusCondition;
@@ -169,36 +167,33 @@ private:
mutable Condition mPreviewCondition;
mutable Condition mPreviewStoppedCondition;
bool mPreviewRunning;
+ bool mPreviewStartDeferred;
bool mExitPreviewThread;
- /* used to guard threading state */
- mutable Mutex mStateLock;
+ preview_stream_ops *mPreviewWindow;
+
+ /* used to guard mCaptureInProgress */
+ mutable Mutex mCaptureLock;
+ mutable Condition mCaptureCondition;
CameraParameters mParameters;
CameraParameters mInternalParameters;
- sp<MemoryHeapBase> mPreviewHeap;
- sp<MemoryHeapBase> mRawHeap;
- sp<MemoryHeapBase> mRecordHeap;
- sp<MemoryHeapBase> mJpegHeap;
- sp<MemoryBase> mBuffers[kBufferCount];
- sp<MemoryBase> mRecordBuffers[kBufferCountForRecord];
+ int mFrameSizeDelta;
+ camera_memory_t *mPreviewHeap;
+ camera_memory_t *mRawHeap;
+ camera_memory_t *mRecordHeap;
- SecCamera *mSecCamera;
+ SecCamera *mSecCamera;
const __u8 *mCameraSensorName;
mutable Mutex mSkipFrameLock;
int mSkipFrame;
-#if defined(BOARD_USES_OVERLAY)
- sp<Overlay> mOverlay;
- bool mUseOverlay;
- int mOverlayBufferIdx;
-#endif
-
- notify_callback mNotifyCb;
- data_callback mDataCb;
- data_callback_timestamp mDataCbTimestamp;
+ camera_notify_callback mNotifyCb;
+ camera_data_callback mDataCb;
+ camera_data_timestamp_callback mDataCbTimestamp;
+ camera_request_memory mGetMemoryCb;
void *mCallbackCookie;
int32_t mMsgEnabled;
@@ -210,6 +205,9 @@ private:
int mPostViewSize;
Vector<Size> mSupportedPreviewSizes;
+
+ camera_device_t *mHalDevice;
+ static gralloc_module_t const* mGrallocHal;
};
}; // namespace android
diff --git a/liboverlay/Android.mk b/libhwcomposer/Android.mk
index 7973ed3..cfdd5f8 100644
--- a/liboverlay/Android.mk
+++ b/libhwcomposer/Android.mk
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-ifeq ($(BOARD_USES_OVERLAY),true)
+ifneq ($(filter crespo crespo4g,$(TARGET_DEVICE)),)
LOCAL_PATH:= $(call my-dir)
# HAL module implemenation, not prelinked and stored in
@@ -21,14 +21,14 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
-LOCAL_SHARED_LIBRARIES := liblog libcutils
+LOCAL_SHARED_LIBRARIES := liblog libcutils libEGL libhardware
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../include
-LOCAL_SRC_FILES := v4l2_utils.c overlay.cpp
+LOCAL_SRC_FILES := SecHWCUtils.cpp SecHWC.cpp
-LOCAL_MODULE := overlay.$(TARGET_BOARD_PLATFORM)
+LOCAL_MODULE := hwcomposer.$(TARGET_BOARD_PLATFORM)
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/libhwcomposer/SecHWC.cpp b/libhwcomposer/SecHWC.cpp
new file mode 100644
index 0000000..cbed30d
--- /dev/null
+++ b/libhwcomposer/SecHWC.cpp
@@ -0,0 +1,530 @@
+/*
+ * 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.
+ */
+
+/*
+ *
+ * @author Rama, Meka(v.meka@samsung.com)
+ Sangwoo, Park(sw5771.park@samsung.com)
+ Jamie Oh (jung-min.oh@samsung.com)
+ * @date 2011-07-28
+ *
+ */
+
+#include <cutils/log.h>
+#include <cutils/atomic.h>
+#include <EGL/egl.h>
+#include "SecHWCUtils.h"
+
+static IMG_gralloc_module_public_t *gpsGrallocModule;
+
+static int hwc_device_open(const struct hw_module_t* module, const char* name,
+ struct hw_device_t** device);
+
+static struct hw_module_methods_t hwc_module_methods = {
+ open: hwc_device_open
+};
+
+hwc_module_t HAL_MODULE_INFO_SYM = {
+ common: {
+ tag: HARDWARE_MODULE_TAG,
+ version_major: 1,
+ version_minor: 0,
+ id: HWC_HARDWARE_MODULE_ID,
+ name: "Samsung S5PC11X hwcomposer module",
+ author: "SAMSUNG",
+ methods: &hwc_module_methods,
+ }
+};
+
+static void dump_layer(hwc_layer_t const* l) {
+ LOGD("\ttype=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, {%d,%d,%d,%d}, {%d,%d,%d,%d}",
+ l->compositionType, l->flags, l->handle, l->transform, l->blending,
+ l->sourceCrop.left,
+ l->sourceCrop.top,
+ l->sourceCrop.right,
+ l->sourceCrop.bottom,
+ l->displayFrame.left,
+ l->displayFrame.top,
+ l->displayFrame.right,
+ l->displayFrame.bottom);
+}
+
+static int set_src_dst_info(hwc_layer_t *cur,
+ struct hwc_win_info_t *win,
+ struct sec_img *src_img,
+ struct sec_img *dst_img,
+ struct sec_rect *src_rect,
+ struct sec_rect *dst_rect,
+ int win_idx)
+{
+ IMG_native_handle_t *prev_handle = (IMG_native_handle_t *)(cur->handle);
+
+ // set src image
+ src_img->w = prev_handle->iWidth;
+ src_img->h = prev_handle->iHeight;
+ src_img->format = prev_handle->iFormat;
+ src_img->base = NULL;
+ src_img->offset = 0;
+ src_img->mem_id =0;
+
+ src_img->mem_type = HWC_PHYS_MEM_TYPE;
+ src_img->w = (src_img->w + 15) & (~15);
+ src_img->h = (src_img->h + 1) & (~1) ;
+
+ //set src rect
+ src_rect->x = SEC_MAX(cur->sourceCrop.left, 0);
+ src_rect->y = SEC_MAX(cur->sourceCrop.top, 0);
+ src_rect->w = SEC_MAX(cur->sourceCrop.right - cur->sourceCrop.left, 0);
+ src_rect->w = SEC_MIN(src_rect->w, src_img->w - src_rect->x);
+ src_rect->h = SEC_MAX(cur->sourceCrop.bottom - cur->sourceCrop.top, 0);
+ src_rect->h = SEC_MIN(src_rect->h, src_img->h - src_rect->y);
+
+ //set dst image
+ dst_img->w = win->lcd_info.xres;
+ dst_img->h = win->lcd_info.yres;
+
+ switch (win->lcd_info.bits_per_pixel) {
+ case 32:
+ dst_img->format = HAL_PIXEL_FORMAT_RGBX_8888;
+ break;
+ default:
+ dst_img->format = HAL_PIXEL_FORMAT_RGB_565;
+ break;
+ }
+
+ dst_img->base = win->addr[win->buf_index];
+ dst_img->offset = 0;
+ dst_img->mem_id = 0;
+ dst_img->mem_type = HWC_PHYS_MEM_TYPE;
+
+ //set dst rect
+ //fimc dst image will be stored from left top corner
+ dst_rect->x = 0;
+ dst_rect->y = 0;
+ dst_rect->w = win->rect_info.w;
+ dst_rect->h = win->rect_info.h;
+
+ LOGV("%s::sr_x %d sr_y %d sr_w %d sr_h %d dr_x %d dr_y %d dr_w %d dr_h %d ",
+ __func__, src_rect->x, src_rect->y, src_rect->w, src_rect->h,
+ dst_rect->x, dst_rect->y, dst_rect->w, dst_rect->h);
+
+ return 0;
+}
+
+static int get_hwc_compos_decision(hwc_layer_t* cur)
+{
+ if(cur->flags & HWC_SKIP_LAYER || !cur->handle) {
+ LOGV("%s::is_skip_layer %d cur->handle %x",
+ __func__, cur->flags & HWC_SKIP_LAYER, (uint32_t)cur->handle);
+ return HWC_FRAMEBUFFER;
+ }
+
+ IMG_native_handle_t *prev_handle = (IMG_native_handle_t *)(cur->handle);
+ int compositionType = HWC_FRAMEBUFFER;
+
+ /* check here....if we have any resolution constraints */
+ if (((cur->sourceCrop.right - cur->sourceCrop.left) < 16) ||
+ ((cur->sourceCrop.bottom - cur->sourceCrop.top) < 8))
+ return compositionType;
+
+ if ((cur->transform == HAL_TRANSFORM_ROT_90) ||
+ (cur->transform == HAL_TRANSFORM_ROT_270)) {
+ if(((cur->displayFrame.right - cur->displayFrame.left) < 4)||
+ ((cur->displayFrame.bottom - cur->displayFrame.top) < 8))
+ return compositionType;
+ } else if (((cur->displayFrame.right - cur->displayFrame.left) < 8) ||
+ ((cur->displayFrame.bottom - cur->displayFrame.top) < 4))
+ return compositionType;
+
+ if((prev_handle->usage & GRALLOC_USAGE_PHYS_CONTIG) &&
+ (cur->blending = HWC_BLENDING_NONE))
+ compositionType = HWC_OVERLAY;
+ else
+ compositionType = HWC_FRAMEBUFFER;
+
+ LOGV("%s::compositionType %d bpp %d format %x usage %x",
+ __func__,compositionType, prev_handle->uiBpp, prev_handle->iFormat,
+ prev_handle->usage & GRALLOC_USAGE_PHYS_CONTIG);
+
+ return compositionType;
+}
+
+static int assign_overlay_window(struct hwc_context_t *ctx,
+ hwc_layer_t *cur,
+ int win_idx,
+ int layer_idx)
+{
+ struct hwc_win_info_t *win;
+ sec_rect rect;
+ int ret = 0;
+
+ if(NUM_OF_WIN <= win_idx)
+ return -1;
+
+ win = &ctx->win[win_idx];
+
+ rect.x = SEC_MAX(cur->displayFrame.left, 0);
+ rect.y = SEC_MAX(cur->displayFrame.top, 0);
+ rect.w = SEC_MIN(cur->displayFrame.right - rect.x, win->lcd_info.xres - rect.x);
+ rect.h = SEC_MIN(cur->displayFrame.bottom - rect.y, win->lcd_info.yres - rect.y);
+ win->set_win_flag = 0;
+
+ if((rect.x != win->rect_info.x) || (rect.y != win->rect_info.y) ||
+ (rect.w != win->rect_info.w) || (rect.h != win->rect_info.h)){
+ win->rect_info.x = rect.x;
+ win->rect_info.y = rect.y;
+ win->rect_info.w = rect.w;
+ win->rect_info.h = rect.h;
+ win->set_win_flag = 1;
+ win->layer_prev_buf = 0;
+ }
+
+ win->layer_index = layer_idx;
+ win->status = HWC_WIN_RESERVED;
+
+ LOGV("%s:: win_x %d win_y %d win_w %d win_h %d lay_idx %d win_idx %d",
+ __func__, win->rect_info.x, win->rect_info.y, win->rect_info.w,
+ win->rect_info.h, win->layer_index, win_idx );
+
+ return 0;
+}
+
+static void reset_win_rect_info(hwc_win_info_t *win)
+{
+ win->rect_info.x = 0;
+ win->rect_info.y = 0;
+ win->rect_info.w = 0;
+ win->rect_info.h = 0;
+ return;
+}
+
+static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list)
+{
+
+ struct hwc_context_t* ctx = (struct hwc_context_t*)dev;
+ int overlay_win_cnt = 0;
+ int compositionType = 0;
+ int ret;
+
+ //if geometry is not changed, there is no need to do any work here
+ if( !list || (!(list->flags & HWC_GEOMETRY_CHANGED)))
+ return 0;
+
+ //all the windows are free here....
+ for (int i = 0; i < NUM_OF_WIN; i++) {
+ ctx->win[i].status = HWC_WIN_FREE;
+ ctx->win[i].buf_index = 0;
+ }
+ ctx->num_of_hwc_layer = 0;
+ ctx->num_of_fb_layer = 0;
+ LOGV("%s:: hwc_prepare list->numHwLayers %d", __func__, list->numHwLayers);
+
+ for (int i = 0; i < list->numHwLayers ; i++) {
+ hwc_layer_t* cur = &list->hwLayers[i];
+
+ if (overlay_win_cnt < NUM_OF_WIN) {
+ compositionType = get_hwc_compos_decision(cur);
+
+ if (compositionType == HWC_FRAMEBUFFER) {
+ cur->compositionType = HWC_FRAMEBUFFER;
+ ctx->num_of_fb_layer++;
+ } else {
+ ret = assign_overlay_window(ctx, cur, overlay_win_cnt, i);
+ if (ret != 0) {
+ cur->compositionType = HWC_FRAMEBUFFER;
+ ctx->num_of_fb_layer++;
+ continue;
+ }
+
+ cur->compositionType = HWC_OVERLAY;
+ cur->hints = HWC_HINT_CLEAR_FB;
+ overlay_win_cnt++;
+ ctx->num_of_hwc_layer++;
+ }
+ } else {
+ cur->compositionType = HWC_FRAMEBUFFER;
+ ctx->num_of_fb_layer++;
+ }
+ }
+
+ if(list->numHwLayers != (ctx->num_of_fb_layer + ctx->num_of_hwc_layer))
+ LOGV("%s:: numHwLayers %d num_of_fb_layer %d num_of_hwc_layer %d ",
+ __func__, list->numHwLayers, ctx->num_of_fb_layer,
+ ctx->num_of_hwc_layer);
+
+ if (overlay_win_cnt < NUM_OF_WIN) {
+ //turn off the free windows
+ for (int i = overlay_win_cnt; i < NUM_OF_WIN; i++) {
+ window_hide(&ctx->win[i]);
+ reset_win_rect_info(&ctx->win[i]);
+ }
+ }
+ return 0;
+}
+
+static int hwc_set(hwc_composer_device_t *dev,
+ hwc_display_t dpy,
+ hwc_surface_t sur,
+ hwc_layer_list_t* list)
+{
+ struct hwc_context_t *ctx = (struct hwc_context_t *)dev;
+ unsigned int phyAddr[MAX_NUM_PLANES];
+ int skipped_window_mask = 0;
+ hwc_layer_t* cur;
+ struct hwc_win_info_t *win;
+ int ret;
+ struct sec_img src_img;
+ struct sec_img dst_img;
+ struct sec_rect src_rect;
+ struct sec_rect dst_rect;
+
+ if (!list) {
+ /* turn off the all windows */
+ for (int i = 0; i < NUM_OF_WIN; i++) {
+ window_hide(&ctx->win[i]);
+ reset_win_rect_info(&ctx->win[i]);
+ ctx->win[i].status = HWC_WIN_FREE;
+ }
+ ctx->num_of_hwc_layer = 0;
+ return 0;
+ }
+
+ if(ctx->num_of_hwc_layer > NUM_OF_WIN)
+ ctx->num_of_hwc_layer = NUM_OF_WIN;
+
+ if (0 < ctx->num_of_fb_layer) {
+ EGLBoolean sucess = eglSwapBuffers((EGLDisplay)dpy, (EGLSurface)sur);
+ if (!sucess) {
+ return HWC_EGL_ERROR;
+ }
+ }
+
+ /* compose hardware layers here */
+ for (uint32_t i = 0; i < ctx->num_of_hwc_layer; i++) {
+ win = &ctx->win[i];
+ if (win->status == HWC_WIN_RESERVED) {
+ cur = &list->hwLayers[win->layer_index];
+
+ if (cur->compositionType == HWC_OVERLAY) {
+ /* Skip duplicate frame rendering */
+ if (win->layer_prev_buf == (uint32_t)cur->handle)
+ continue;
+
+ win->layer_prev_buf = (uint32_t)cur->handle;
+
+ ret = gpsGrallocModule->GetPhyAddrs(gpsGrallocModule,
+ cur->handle, phyAddr);
+ if (ret) {
+ LOGE("%s::GetPhyAddrs fail : ret=%d\n", __func__, ret);
+ skipped_window_mask |= (1 << i);
+ continue;
+ }
+
+ /* initialize the src & dist context for fimc */
+ set_src_dst_info (cur, win, &src_img, &dst_img, &src_rect,
+ &dst_rect, i);
+
+ ret = runFimc(ctx, &src_img, &src_rect, &dst_img, &dst_rect,
+ phyAddr, cur->transform);
+ if (ret < 0){
+ LOGE("%s::runFimc fail : ret=%d\n", __func__, ret);
+ skipped_window_mask |= (1 << i);
+ continue;
+ }
+
+ if (win->set_win_flag == 1) {
+ /* turnoff the window and set the window position with new conf... */
+ if (window_set_pos(win) < 0) {
+ LOGE("%s::window_set_pos is failed : %s", __func__,
+ strerror(errno));
+ skipped_window_mask |= (1 << i);
+ continue;
+ }
+ win->set_win_flag = 0;
+ }
+
+ window_pan_display(win);
+
+ win->buf_index = (win->buf_index + 1) % NUM_OF_WIN_BUF;
+
+ if(win->power_state == 0)
+ window_show(win);
+
+ } else {
+ LOGE("%s:: error : layer %d compositionType should have been \
+ HWC_OVERLAY", __func__, win->layer_index);
+ skipped_window_mask |= (1 << i);
+ continue;
+ }
+ } else {
+ LOGE("%s:: error : window status should have been HWC_WIN_RESERVED \
+ by now... ", __func__);
+ skipped_window_mask |= (1 << i);
+ continue;
+ }
+ }
+
+ if (skipped_window_mask) {
+ //turn off the free windows
+ for (int i = 0; i < NUM_OF_WIN; i++) {
+ if (skipped_window_mask & (1 << i))
+ window_hide(&ctx->win[i]);
+ }
+ }
+
+ return 0;
+}
+
+static int hwc_device_close(struct hw_device_t *dev)
+{
+ struct hwc_context_t* ctx = (struct hwc_context_t*)dev;
+ int ret = 0;
+ int i;
+
+ if (ctx) {
+ if (destroyFimc(&ctx->fimc) < 0) {
+ LOGE("%s::destroyFimc fail", __func__);
+ ret = -1;
+ }
+
+ for (i = 0; i < NUM_OF_WIN; i++) {
+ if (window_close(&ctx->win[i]) < 0) {
+ LOGE("%s::window_close() fail", __func__);
+ ret = -1;
+ }
+ }
+
+ free(ctx);
+ }
+ return ret;
+}
+
+static int hwc_device_open(const struct hw_module_t* module, const char* name,
+ struct hw_device_t** device)
+{
+ int status = 0;
+ struct hwc_win_info_t *win;
+
+ if(hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
+ (const hw_module_t**)&gpsGrallocModule))
+ return -EINVAL;
+
+ if(strcmp(gpsGrallocModule->base.common.author, "Imagination Technologies"))
+ return -EINVAL;
+
+ if (strcmp(name, HWC_HARDWARE_COMPOSER))
+ return -EINVAL;
+
+ struct hwc_context_t *dev;
+ dev = (hwc_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<hw_module_t*>(module);
+ dev->device.common.close = hwc_device_close;
+
+ dev->device.prepare = hwc_prepare;
+ dev->device.set = hwc_set;
+
+ *device = &dev->device.common;
+
+ /* initializing */
+ memset(&(dev->fimc), 0, sizeof(s5p_fimc_t));
+ dev->fimc.dev_fd = -1;
+
+ /* open WIN0 & WIN1 here */
+ for (int i = 0; i < NUM_OF_WIN; i++) {
+ if (window_open(&(dev->win[i]), i) < 0) {
+ LOGE("%s:: Failed to open window %d device ", __func__, i);
+ status = -EINVAL;
+ goto err;
+ }
+ }
+
+ if (window_get_global_lcd_info(dev->win[0].fd, &dev->lcd_info) < 0) {
+ LOGE("%s::window_get_global_lcd_info is failed : %s",
+ __func__, strerror(errno));
+ status = -EINVAL;
+ goto err;
+ }
+
+ dev->lcd_info.yres_virtual = dev->lcd_info.yres * NUM_OF_WIN_BUF;
+
+ /* initialize the window context */
+ for (int i = 0; i < NUM_OF_WIN; i++) {
+ win = &dev->win[i];
+ memcpy(&win->lcd_info, &dev->lcd_info, sizeof(struct fb_var_screeninfo));
+ memcpy(&win->var_info, &dev->lcd_info, sizeof(struct fb_var_screeninfo));
+
+ win->rect_info.x = 0;
+ win->rect_info.y = 0;
+ win->rect_info.w = win->var_info.xres;
+ win->rect_info.h = win->var_info.yres;
+
+ if (window_set_pos(win) < 0) {
+ LOGE("%s::window_set_pos is failed : %s",
+ __func__, strerror(errno));
+ status = -EINVAL;
+ goto err;
+ }
+
+ if (window_get_info(win) < 0) {
+ LOGE("%s::window_get_info is failed : %s",
+ __func__, strerror(errno));
+ status = -EINVAL;
+ goto err;
+ }
+
+ win->size = win->fix_info.line_length * win->var_info.yres;
+
+ if (!win->fix_info.smem_start){
+ LOGE("%s:: win-%d failed to get the reserved memory", __func__, i);
+ status = -EINVAL;
+ goto err;
+ }
+
+ for (int j = 0; j < NUM_OF_WIN_BUF; j++) {
+ win->addr[j] = win->fix_info.smem_start + (win->size * j);
+ LOGI("%s::win-%d add[%d] %x ", __func__, i, j, win->addr[j]);
+ }
+ }
+
+ /* open pp */
+ if (createFimc(&dev->fimc) < 0) {
+ LOGE("%s::creatFimc() fail", __func__);
+ status = -EINVAL;
+ goto err;
+ }
+
+ LOGD("%s:: success\n", __func__);
+
+ return 0;
+
+err:
+ if (destroyFimc(&dev->fimc) < 0)
+ LOGE("%s::destroyFimc() fail", __func__);
+
+ for (int i = 0; i < NUM_OF_WIN; i++) {
+ if (window_close(&dev->win[i]) < 0)
+ LOGE("%s::window_close() fail", __func__);
+ }
+
+ return status;
+}
diff --git a/libhwcomposer/SecHWCUtils.cpp b/libhwcomposer/SecHWCUtils.cpp
new file mode 100644
index 0000000..7c89f47
--- /dev/null
+++ b/libhwcomposer/SecHWCUtils.cpp
@@ -0,0 +1,871 @@
+/*
+ * 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.
+ */
+
+/*
+ *
+ * @author Rama, Meka(v.meka@samsung.com)
+ Sangwoo, Park(sw5771.park@samsung.com)
+ Jamie Oh (jung-min.oh@samsung.com)
+ * @date 2011-07-28
+ *
+ */
+
+#include "SecHWCUtils.h"
+
+int window_open(struct hwc_win_info_t *win, int id)
+{
+ char name[64];
+
+ char const * const device_template = "/dev/graphics/fb%u";
+ /* window & FB maping
+ fb0 -> win-id : 2
+ fb1 -> win-id : 3
+ fb2 -> win-id : 4
+ fb3 -> win-id : 0
+ fb4 -> win_id : 1
+ it is pre assumed that ...win0 or win1 is used here..
+ */
+ switch (id) {
+ case 0:
+ case 1:
+ break;
+ default:
+ LOGE("%s::id(%d) is weird", __func__, id);
+ goto error;
+ }
+
+ snprintf(name, 64, device_template, (id + 3)%5);
+
+ win->fd = open(name, O_RDWR);
+ if (win->fd < 0) {
+ LOGE("%s::Failed to open window device (%s) : %s",
+ __func__, strerror(errno), device_template);
+ goto error;
+ }
+
+ return 0;
+
+error:
+ if (0 <= win->fd)
+ close(win->fd);
+ win->fd = -1;
+
+ return -1;
+}
+
+int window_close(struct hwc_win_info_t *win)
+{
+ int ret = 0;
+
+ if (0 <= win->fd)
+ ret = close(win->fd);
+ win->fd = -1;
+
+ return ret;
+}
+
+int window_set_pos(struct hwc_win_info_t *win)
+{
+ struct secfb_user_window window;
+
+ /* before changing the screen configuration...powerdown the window */
+ if(window_hide(win) != 0)
+ return -1;
+
+ win->var_info.xres = win->rect_info.w;
+ win->var_info.yres = win->rect_info.h;
+
+ win->var_info.activate &= ~FB_ACTIVATE_MASK;
+ win->var_info.activate |= FB_ACTIVATE_FORCE;
+
+ if (ioctl(win->fd, FBIOPUT_VSCREENINFO, &(win->var_info)) < 0) {
+ LOGE("%s::FBIOPUT_VSCREENINFO(%d, %d) fail",
+ __func__, win->rect_info.w, win->rect_info.h);
+ return -1;
+ }
+
+ window.x = win->rect_info.x;
+ window.y = win->rect_info.y;
+
+ if (ioctl(win->fd, SECFB_WIN_POSITION, &window) < 0) {
+ LOGE("%s::S3CFB_WIN_POSITION(%d, %d) fail",
+ __func__, window.x, window.y);
+ return -1;
+ }
+
+ return 0;
+}
+
+int window_get_info(struct hwc_win_info_t *win)
+{
+ if (ioctl(win->fd, FBIOGET_FSCREENINFO, &win->fix_info) < 0) {
+ LOGE("FBIOGET_FSCREENINFO failed : %s", strerror(errno));
+ goto error;
+ }
+
+ return 0;
+
+error:
+ win->fix_info.smem_start = 0;
+
+ return -1;
+}
+
+int window_pan_display(struct hwc_win_info_t *win)
+{
+ struct fb_var_screeninfo *lcd_info = &(win->lcd_info);
+
+ lcd_info->yoffset = lcd_info->yres * win->buf_index;
+
+ if (ioctl(win->fd, FBIOPAN_DISPLAY, lcd_info) < 0) {
+ LOGE("%s::FBIOPAN_DISPLAY(%d / %d / %d) fail(%s)",
+ __func__, lcd_info->yres, win->buf_index, lcd_info->yres_virtual,
+ strerror(errno));
+ return -1;
+ }
+ return 0;
+}
+
+int window_show(struct hwc_win_info_t *win)
+{
+ if(win->power_state == 0) {
+ if (ioctl(win->fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) {
+ LOGE("%s: FBIOBLANK failed : (%d:%s)", __func__, win->fd,
+ strerror(errno));
+ return -1;
+ }
+ win->power_state = 1;
+ }
+ return 0;
+}
+
+int window_hide(struct hwc_win_info_t *win)
+{
+ if (win->power_state == 1) {
+ if (ioctl(win->fd, FBIOBLANK, FB_BLANK_POWERDOWN) < 0) {
+ LOGE("%s::FBIOBLANK failed : (%d:%s)",
+ __func__, win->fd, strerror(errno));
+ return -1;
+ }
+ win->power_state = 0;
+ }
+ return 0;
+}
+
+int window_get_global_lcd_info(int fd, struct fb_var_screeninfo *lcd_info)
+{
+ if (ioctl(fd, FBIOGET_VSCREENINFO, lcd_info) < 0) {
+ LOGE("FBIOGET_VSCREENINFO failed : %s", strerror(errno));
+ return -1;
+ }
+
+ if (lcd_info->xres == 0) {
+ lcd_info->xres = DEFAULT_LCD_WIDTH;
+ lcd_info->xres_virtual = DEFAULT_LCD_WIDTH;
+ }
+
+ if (lcd_info->yres == 0) {
+ lcd_info->yres = DEFAULT_LCD_HEIGHT;
+ lcd_info->yres_virtual = DEFAULT_LCD_HEIGHT * NUM_OF_WIN_BUF;
+ }
+
+ if (lcd_info->bits_per_pixel == 0)
+ lcd_info->bits_per_pixel = DEFAULT_LCD_BPP;
+
+ return 0;
+}
+
+int fimc_v4l2_set_src(int fd, unsigned int hw_ver, s5p_fimc_img_info *src)
+{
+ struct v4l2_format fmt;
+ struct v4l2_cropcap cropcap;
+ struct v4l2_crop crop;
+ struct v4l2_requestbuffers req;
+
+ /*
+ * To set size & format for source image (DMA-INPUT)
+ */
+ fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ fmt.fmt.pix.width = src->full_width;
+ fmt.fmt.pix.height = src->full_height;
+ fmt.fmt.pix.pixelformat = src->color_space;
+ fmt.fmt.pix.field = V4L2_FIELD_NONE;
+
+ if (ioctl (fd, VIDIOC_S_FMT, &fmt) < 0) {
+ LOGE("VIDIOC_S_FMT failed : errno=%d (%s) : fd=%d", errno,
+ strerror(errno), fd);
+ return -1;
+ }
+
+ /*
+ * crop input size
+ */
+ crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ if (0x50 == hw_ver) {
+ crop.c.left = src->start_x;
+ crop.c.top = src->start_y;
+ } else {
+ crop.c.left = 0;
+ crop.c.top = 0;
+ }
+ crop.c.width = src->width;
+ crop.c.height = src->height;
+ if (ioctl(fd, VIDIOC_S_CROP, &crop) < 0) {
+ LOGE("Error in video VIDIOC_S_CROP (%d, %d, %d, %d)",
+ crop.c.left, crop.c.top, crop.c.width, crop.c.height);
+ return -1;
+ }
+
+ /*
+ * input buffer type
+ */
+ req.count = 1;
+ req.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ req.memory = V4L2_MEMORY_USERPTR;
+
+ if (ioctl (fd, VIDIOC_REQBUFS, &req) < 0) {
+ LOGE("Error in VIDIOC_REQBUFS");
+ return -1;
+ }
+
+ return 0;
+}
+
+int fimc_v4l2_set_dst(int fd,
+ s5p_fimc_img_info *dst,
+ int rotation,
+ int flag_h_flip,
+ int flag_v_flip,
+ unsigned int addr)
+{
+ struct v4l2_format sFormat;
+ struct v4l2_control vc;
+ struct v4l2_framebuffer fbuf;
+
+ /*
+ * set rotation configuration
+ */
+ vc.id = V4L2_CID_HFLIP;
+ vc.value = flag_h_flip;
+ if (ioctl(fd, VIDIOC_S_CTRL, &vc) < 0) {
+ LOGE("Error in video VIDIOC_S_CTRL - flag_h_flip (%d)", flag_h_flip);
+ return -1;
+ }
+
+ vc.id = V4L2_CID_VFLIP;
+ vc.value = flag_v_flip;
+ if (ioctl(fd, VIDIOC_S_CTRL, &vc) < 0) {
+ LOGE("Error in video VIDIOC_S_CTRL - flag_v_flip (%d)", flag_v_flip);
+ return -1;
+ }
+
+ vc.id = V4L2_CID_ROTATION;
+ vc.value = rotation;
+ if (ioctl(fd, VIDIOC_S_CTRL, &vc) < 0) {
+ LOGE("Error in video VIDIOC_S_CTRL - rotation (%d)", rotation);
+ return -1;
+ }
+
+ /*
+ * set size, format & address for destination image (DMA-OUTPUT)
+ */
+ if (ioctl (fd, VIDIOC_G_FBUF, &fbuf) < 0) {
+ LOGE("Error in video VIDIOC_G_FBUF");
+ return -1;
+ }
+
+ fbuf.base = (void *)addr;
+ fbuf.fmt.width = dst->full_width;
+ fbuf.fmt.height = dst->full_height;
+ fbuf.fmt.pixelformat = dst->color_space;
+ if (ioctl (fd, VIDIOC_S_FBUF, &fbuf) < 0) {
+ LOGE("Error in video VIDIOC_S_FBUF 0x%x %d %d %d",
+ (void *)addr, dst->full_width, dst->full_height,
+ dst->color_space);
+ return -1;
+ }
+
+ /*
+ * set destination window
+ */
+ sFormat.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
+ sFormat.fmt.win.w.left = dst->start_x;
+ sFormat.fmt.win.w.top = dst->start_y;
+ sFormat.fmt.win.w.width = dst->width;
+ sFormat.fmt.win.w.height = dst->height;
+ if (ioctl(fd, VIDIOC_S_FMT, &sFormat) < 0) {
+ LOGE("Error in video VIDIOC_S_FMT %d %d %d %d",
+ dst->start_x, dst->start_y, dst->width, dst->height);
+ return -1;
+ }
+
+ return 0;
+}
+
+int fimc_v4l2_stream_on(int fd, enum v4l2_buf_type type)
+{
+ if (ioctl (fd, VIDIOC_STREAMON, &type) < 0) {
+ LOGE("Error in VIDIOC_STREAMON");
+ return -1;
+ }
+
+ return 0;
+}
+
+int fimc_v4l2_queue(int fd, struct fimc_buf *fimc_buf)
+{
+ struct v4l2_buffer buf;
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ buf.memory = V4L2_MEMORY_USERPTR;
+ buf.m.userptr = (unsigned long)fimc_buf;
+ buf.length = 0;
+ buf.index = 0;
+
+ if (ioctl (fd, VIDIOC_QBUF, &buf) < 0) {
+ LOGE("Error in VIDIOC_QBUF");
+ return -1;
+ }
+
+ return 0;
+}
+
+int fimc_v4l2_dequeue(int fd)
+{
+ struct v4l2_buffer buf;
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ buf.memory = V4L2_MEMORY_USERPTR;
+
+ if (ioctl (fd, VIDIOC_DQBUF, &buf) < 0) {
+ LOGE("Error in VIDIOC_DQBUF");
+ return -1;
+ }
+
+ return buf.index;
+}
+
+int fimc_v4l2_stream_off(int fd)
+{
+ enum v4l2_buf_type type;
+ type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+
+ if (ioctl (fd, VIDIOC_STREAMOFF, &type) < 0) {
+ LOGE("Error in VIDIOC_STREAMOFF");
+ return -1;
+ }
+
+ return 0;
+}
+
+int fimc_v4l2_clr_buf(int fd)
+{
+ struct v4l2_requestbuffers req;
+
+ req.count = 0;
+ req.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ req.memory = V4L2_MEMORY_USERPTR;
+
+ if (ioctl (fd, VIDIOC_REQBUFS, &req) < 0) {
+ LOGE("Error in VIDIOC_REQBUFS");
+ }
+
+ return 0;
+}
+
+int fimc_handle_oneshot(int fd, struct fimc_buf *fimc_buf)
+{
+ if (fimc_v4l2_stream_on(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT) < 0) {
+ LOGE("Fail : v4l2_stream_on()");
+ return -1;
+ }
+
+ if (fimc_v4l2_queue(fd, fimc_buf) < 0) {
+ LOGE("Fail : v4l2_queue()");
+ return -1;
+ }
+
+ if (fimc_v4l2_dequeue(fd) < 0) {
+ LOGE("Fail : v4l2_dequeue()");
+ return -1;
+ }
+
+ if (fimc_v4l2_stream_off(fd) < 0) {
+ LOGE("Fail : v4l2_stream_off()");
+ return -1;
+ }
+
+ if (fimc_v4l2_clr_buf(fd) < 0) {
+ LOGE("Fail : v4l2_clr_buf()");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int get_src_phys_addr(struct hwc_context_t *ctx,
+ sec_img *src_img,
+ unsigned int *phyAddr)
+{
+ s5p_fimc_t *fimc = &ctx->fimc;
+
+ if(src_img->mem_type == HWC_PHYS_MEM_TYPE) {
+ switch(src_img->format) {
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ fimc->params.src.buf_addr_phy_rgb_y = phyAddr[0];
+ fimc->params.src.buf_addr_phy_cb = phyAddr[1];
+ break;
+ default:
+ LOGE("%s format error (format=0x%x)", __func__,
+ src_img->format);
+ return -1;
+ }
+ } else {
+ LOGE("%s mem_type error (mem_type=%d)", __func__, src_img->mem_type);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int get_dst_phys_addr(struct hwc_context_t *ctx,
+ sec_img *dst_img)
+{
+ unsigned int dst_phys_addr = 0;
+
+ if (HWC_PHYS_MEM_TYPE == dst_img->mem_type && 0 != dst_img->base)
+ dst_phys_addr = dst_img->base;
+ else {
+ LOGE("%s::get_dst_phys_addr fail ", __func__);
+ dst_phys_addr = 0;
+ }
+ return dst_phys_addr;
+}
+
+static inline int rotateValueHAL2PP(unsigned char transform,
+ int *flag_h_flip,
+ int *flag_v_flip)
+{
+ int rotate_result = 0;
+ int rotate_flag = transform & 0x7;
+
+ switch (rotate_flag) {
+ case HAL_TRANSFORM_ROT_90:
+ rotate_result = 90;
+ break;
+ case HAL_TRANSFORM_ROT_180:
+ rotate_result = 180;
+ break;
+ case HAL_TRANSFORM_ROT_270:
+ rotate_result = 270;
+ break;
+ }
+
+ switch (rotate_flag) {
+ case HAL_TRANSFORM_FLIP_H:
+ *flag_h_flip = 1;
+ *flag_v_flip = 0;
+ break;
+ case HAL_TRANSFORM_FLIP_V:
+ *flag_h_flip = 0;
+ *flag_v_flip = 1;
+ break;
+ default:
+ *flag_h_flip = 0;
+ *flag_v_flip = 0;
+ break;
+ }
+
+ return rotate_result;
+}
+
+static inline int multipleOfN(int number, int N)
+{
+ int result = number;
+ switch (N) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+ case 128:
+ case 256:
+ result = (number - (number & (N-1)));
+ break;
+ default:
+ result = number - (number % N);
+ break;
+ }
+ return result;
+}
+
+static inline int widthOfPP(unsigned int ver,
+ int pp_color_format,
+ int number)
+{
+ if (0x50 == ver) {
+ switch(pp_color_format) {
+ /* 422 1/2/3 plane */
+ case V4L2_PIX_FMT_YUYV:
+ case V4L2_PIX_FMT_UYVY:
+ case V4L2_PIX_FMT_NV61:
+ case V4L2_PIX_FMT_NV16:
+ case V4L2_PIX_FMT_YUV422P:
+
+ /* 420 2/3 plane */
+ case V4L2_PIX_FMT_NV21:
+ case V4L2_PIX_FMT_NV12:
+ case V4L2_PIX_FMT_NV12T:
+ case V4L2_PIX_FMT_YUV420:
+ return multipleOfN(number, 2);
+
+ default :
+ return number;
+ }
+ } else {
+ switch(pp_color_format) {
+ case V4L2_PIX_FMT_RGB565:
+ return multipleOfN(number, 8);
+
+ case V4L2_PIX_FMT_RGB32:
+ return multipleOfN(number, 4);
+
+ case V4L2_PIX_FMT_YUYV:
+ case V4L2_PIX_FMT_UYVY:
+ return multipleOfN(number, 4);
+
+ case V4L2_PIX_FMT_NV61:
+ case V4L2_PIX_FMT_NV16:
+ return multipleOfN(number, 8);
+
+ case V4L2_PIX_FMT_YUV422P:
+ return multipleOfN(number, 16);
+
+ case V4L2_PIX_FMT_NV21:
+ case V4L2_PIX_FMT_NV12:
+ case V4L2_PIX_FMT_NV12T:
+ return multipleOfN(number, 8);
+
+ case V4L2_PIX_FMT_YUV420:
+ return multipleOfN(number, 16);
+
+ default :
+ return number;
+ }
+ }
+ return number;
+}
+
+static inline int heightOfPP(int pp_color_format,
+ int number)
+{
+ switch(pp_color_format) {
+ case V4L2_PIX_FMT_NV21:
+ case V4L2_PIX_FMT_NV12:
+ case V4L2_PIX_FMT_NV12T:
+ case V4L2_PIX_FMT_YUV420:
+ return multipleOfN(number, 2);
+
+ default :
+ return number;
+ }
+ return number;
+}
+
+static int runcFimcCore(struct hwc_context_t *ctx,
+ sec_img *src_img,
+ sec_rect *src_rect,
+ uint32_t src_color_space,
+ unsigned int dst_phys_addr,
+ sec_img *dst_img,
+ sec_rect *dst_rect,
+ uint32_t dst_color_space,
+ int transform)
+{
+ s5p_fimc_t * fimc = &ctx->fimc;
+ s5p_fimc_params_t * params = &(fimc->params);
+
+ unsigned int frame_size = 0;
+ struct fimc_buf fimc_src_buf;
+
+ int src_bpp, src_planes;
+ int flag_h_flip = 0;
+ int flag_v_flip = 0;
+ int rotate_value = rotateValueHAL2PP(transform, &flag_h_flip, &flag_v_flip);
+
+ /* set post processor configuration */
+ params->src.full_width = src_img->w;
+ params->src.full_height = src_img->h;
+ params->src.start_x = src_rect->x;
+ params->src.start_y = src_rect->y;
+ params->src.width = widthOfPP(fimc->hw_ver, src_color_space, src_rect->w);
+ params->src.height = heightOfPP(src_color_space, src_rect->h);
+ params->src.color_space = src_color_space;
+
+
+ /* check minimum */
+ if (src_rect->w < 16 || src_rect->h < 8) {
+ LOGE("%s src size is not supported by fimc : f_w=%d f_h=%d x=%d y=%d \
+ w=%d h=%d (ow=%d oh=%d) format=0x%x", __func__,
+ params->src.full_width, params->src.full_height,
+ params->src.start_x, params->src.start_y, params->src.width,
+ params->src.height, src_rect->w, src_rect->h,
+ params->src.color_space);
+ return -1;
+ }
+
+switch (rotate_value) {
+ case 0:
+ params->dst.full_width = dst_img->w;
+ params->dst.full_height = dst_img->h;
+
+ params->dst.start_x = dst_rect->x;
+ params->dst.start_y = dst_rect->y;
+
+ params->dst.width =
+ widthOfPP(fimc->hw_ver, dst_color_space, dst_rect->w);
+ params->dst.height = heightOfPP(dst_color_space, dst_rect->h);
+ break;
+ case 90:
+ params->dst.full_width = dst_img->h;
+ params->dst.full_height = dst_img->w;
+
+ params->dst.start_x = dst_rect->y;
+ params->dst.start_y = dst_img->w - (dst_rect->x + dst_rect->w);
+
+ params->dst.width =
+ widthOfPP(fimc->hw_ver, dst_color_space, dst_rect->h);
+ params->dst.height =
+ widthOfPP(fimc->hw_ver, dst_color_space, dst_rect->w);
+
+ if (0x50 > fimc->hw_ver)
+ params->dst.start_y += (dst_rect->w - params->dst.height);
+ break;
+ case 180:
+ params->dst.full_width = dst_img->w;
+ params->dst.full_height = dst_img->h;
+
+ params->dst.start_x = dst_img->w - (dst_rect->x + dst_rect->w);
+ params->dst.start_y = dst_img->h - (dst_rect->y + dst_rect->h);
+
+ params->dst.width =
+ widthOfPP(fimc->hw_ver, dst_color_space, dst_rect->w);
+ params->dst.height = heightOfPP(dst_color_space, dst_rect->h);
+ break;
+ case 270:
+ params->dst.full_width = dst_img->h;
+ params->dst.full_height = dst_img->w;
+
+ params->dst.start_x = dst_img->h - (dst_rect->y + dst_rect->h);
+ params->dst.start_y = dst_rect->x;
+
+ params->dst.width =
+ widthOfPP(fimc->hw_ver, dst_color_space, dst_rect->h);
+ params->dst.height =
+ widthOfPP(fimc->hw_ver, dst_color_space, dst_rect->w);
+
+ if (0x50 > fimc->hw_ver)
+ params->dst.start_y += (dst_rect->w - params->dst.height);
+ break;
+ }
+
+
+ params->dst.color_space = dst_color_space;
+
+ /* check minimum */
+ if (dst_rect->w < 8 || dst_rect->h < 4) {
+ LOGE("%s dst size is not supported by fimc : \
+ f_w=%d f_h=%d x=%d y=%d w=%d h=%d (ow=%d oh=%d) format=0x%x",
+ __func__, params->dst.full_width, params->dst.full_height,
+ params->dst.start_x, params->dst.start_y, params->dst.width,
+ params->dst.height, dst_rect->w, dst_rect->h,
+ params->dst.color_space);
+ return -1;
+ }
+
+ /* check scaling limit
+ * the scaling limie must not be more than MAX_RESIZING_RATIO_LIMIT
+ */
+ if (((src_rect->w > dst_rect->w) &&
+ ((src_rect->w / dst_rect->w) > MAX_RESIZING_RATIO_LIMIT)) ||
+ ((dst_rect->w > src_rect->w) &&
+ ((dst_rect->w / src_rect->w) > MAX_RESIZING_RATIO_LIMIT))) {
+ LOGE("%s over scaling limit : src.w=%d dst.w=%d (limit=%d)",
+ __func__, src_rect->w, dst_rect->w, MAX_RESIZING_RATIO_LIMIT);
+ return -1;
+ }
+
+
+ /* set configuration related to destination (DMA-OUT)
+ * - set input format & size
+ * - crop input size
+ * - set input buffer
+ * - set buffer type (V4L2_MEMORY_USERPTR)
+ */
+ if (fimc_v4l2_set_dst(fimc->dev_fd,
+ &params->dst,
+ rotate_value,
+ flag_h_flip,
+ flag_v_flip,
+ dst_phys_addr) < 0) {
+ return -1;
+ }
+
+ /* set configuration related to source (DMA-INPUT)
+ * - set input format & size
+ * - crop input size
+ * - set input buffer
+ * - set buffer type (V4L2_MEMORY_USERPTR)
+ */
+ if (fimc_v4l2_set_src(fimc->dev_fd, fimc->hw_ver, &params->src) < 0)
+ return -1;
+
+ /* set input dma address (Y/RGB, Cb, Cr) */
+ switch (src_img->format) {
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ /* for video display zero copy case */
+ fimc_src_buf.base[0] = params->src.buf_addr_phy_rgb_y;
+ fimc_src_buf.base[1] = params->src.buf_addr_phy_cb;
+ break;
+
+ default:
+ /* set source image */
+ fimc_src_buf.base[0] = params->src.buf_addr_phy_rgb_y;
+ break;
+ }
+
+ if (fimc_handle_oneshot(fimc->dev_fd, &fimc_src_buf) < 0) {
+ fimc_v4l2_clr_buf(fimc->dev_fd);
+ return -1;
+ }
+
+ return 0;
+}
+
+int createFimc(s5p_fimc_t *fimc)
+{
+ struct v4l2_capability cap;
+ struct v4l2_format fmt;
+ struct v4l2_control vc;
+
+ #define PP_DEVICE_DEV_NAME "/dev/video1"
+
+ /* open device file */
+ if(fimc->dev_fd < 0) {
+ fimc->dev_fd = open(PP_DEVICE_DEV_NAME, O_RDWR);
+
+ if (fimc->dev_fd < 0) {
+ LOGE("%s::Post processor open error (%d)", __func__, errno);
+ goto err;
+ }
+ }
+
+ /* check capability */
+ if (ioctl(fimc->dev_fd, VIDIOC_QUERYCAP, &cap) < 0) {
+ LOGE("VIDIOC_QUERYCAP failed");
+ goto err;
+ }
+
+ if (!(cap.capabilities & V4L2_CAP_STREAMING)) {
+ LOGE("%d has no streaming support", fimc->dev_fd);
+ goto err;
+ }
+
+ if (!(cap.capabilities & V4L2_CAP_VIDEO_OUTPUT)) {
+ LOGE("%d is no video output", fimc->dev_fd);
+ goto err;
+ }
+
+ /*
+ * malloc fimc_outinfo structure
+ */
+ fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+ if (ioctl(fimc->dev_fd, VIDIOC_G_FMT, &fmt) < 0) {
+ LOGE("%s::Error in video VIDIOC_G_FMT", __func__);
+ goto err;
+ }
+
+ vc.id = V4L2_CID_FIMC_VERSION;
+ vc.value = 0;
+
+ if (ioctl(fimc->dev_fd, VIDIOC_G_CTRL, &vc) < 0) {
+ LOGE("%s::Error in video VIDIOC_G_CTRL", __func__);
+ goto err;
+ }
+ fimc->hw_ver = vc.value;
+
+ return 0;
+
+err:
+ if (0 <= fimc->dev_fd)
+ close(fimc->dev_fd);
+ fimc->dev_fd = -1;
+
+ return -1;
+}
+
+int destroyFimc(s5p_fimc_t *fimc)
+{
+ if (fimc->out_buf.virt_addr != NULL) {
+ fimc->out_buf.virt_addr = NULL;
+ fimc->out_buf.length = 0;
+ }
+
+ /* close */
+ if (0 <= fimc->dev_fd)
+ close(fimc->dev_fd);
+ fimc->dev_fd = -1;
+
+ return 0;
+}
+
+int runFimc(struct hwc_context_t *ctx,
+ struct sec_img *src_img,
+ struct sec_rect *src_rect,
+ struct sec_img *dst_img,
+ struct sec_rect *dst_rect,
+ unsigned int *phyAddr,
+ uint32_t transform)
+{
+ s5p_fimc_t *fimc = &ctx->fimc;
+ unsigned int dst_phys_addr = 0;
+ int32_t src_color_space;
+ int32_t dst_color_space;
+
+ /* 1 : source address and size */
+
+ if(0 > get_src_phys_addr(ctx, src_img, phyAddr))
+ return -1;
+
+ /* 2 : destination address and size */
+ if(0 == (dst_phys_addr = get_dst_phys_addr(ctx, dst_img)))
+ return -2;
+
+ /* check whether fimc supports the src format */
+ if (0 > (src_color_space = HAL_PIXEL_FORMAT_2_V4L2_PIX(src_img->format)))
+ return -3;
+
+ if (0 > (dst_color_space = HAL_PIXEL_FORMAT_2_V4L2_PIX(dst_img->format)))
+ return -4;
+
+ if(runcFimcCore(ctx, src_img, src_rect, (uint32_t)src_color_space,
+ dst_phys_addr, dst_img, dst_rect, (uint32_t)dst_color_space, transform) < 0)
+ return -5;
+
+ return 0;
+}
diff --git a/libhwcomposer/SecHWCUtils.h b/libhwcomposer/SecHWCUtils.h
new file mode 100644
index 0000000..7715cb4
--- /dev/null
+++ b/libhwcomposer/SecHWCUtils.h
@@ -0,0 +1,139 @@
+/*
+ * 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.
+ */
+
+/*
+ *
+ * @author Rama, Meka(v.meka@samsung.com)
+ Sangwoo, Park(sw5771.park@samsung.com)
+ Jamie, Oh (jung-min.oh@samsung.com)
+ * @date 2011-07-28
+ *
+ */
+
+#ifndef ANDROID_SEC_HWC_UTILS_H_
+#define ANDROID_SEC_HWC_UTILS_H_
+#include <fcntl.h>
+#include <errno.h>
+#include <cutils/log.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include "linux/fb.h"
+#include <linux/videodev.h>
+
+#include <hardware/gralloc.h>
+#include <hardware/hardware.h>
+#include <hardware/hwcomposer.h>
+
+#include "s5p_fimc.h"
+#include "sec_lcd.h"
+#include "sec_format.h"
+#include "sec_utils.h"
+#include "hal_public.h"
+
+#define GRALLOC_USAGE_PHYS_CONTIG GRALLOC_USAGE_PRIVATE_1
+
+#define NUM_OF_WIN (1)
+#define NUM_OF_WIN_BUF (3)
+#define NUM_OF_MEM_OBJ (1)
+#define MAX_NUM_PLANES (3)
+
+#define MAX_RESIZING_RATIO_LIMIT (63)
+
+struct sec_rect {
+ uint32_t x;
+ uint32_t y;
+ uint32_t w;
+ uint32_t h;
+};
+
+struct sec_img {
+ uint32_t w;
+ uint32_t h;
+ uint32_t format;
+ uint32_t base;
+ uint32_t offset;
+ int mem_id;
+ int mem_type;
+};
+
+inline int SEC_MIN(int x, int y) {
+ return ((x < y) ? x : y);
+}
+
+inline int SEC_MAX(int x, int y) {
+ return ((x > y) ? x : y);
+}
+
+struct hwc_win_info_t {
+ int fd;
+ int size;
+ sec_rect rect_info;
+ uint32_t addr[NUM_OF_WIN_BUF];
+ int buf_index;
+ int power_state;
+ int blending;
+ int layer_index;
+ uint32_t layer_prev_buf;
+ int set_win_flag;
+ int status;
+ int vsync;
+
+ struct fb_fix_screeninfo fix_info;
+ struct fb_var_screeninfo var_info;
+ struct fb_var_screeninfo lcd_info;
+};
+
+enum {
+ HWC_WIN_FREE = 0,
+ HWC_WIN_RESERVED,
+};
+
+enum {
+ HWC_UNKNOWN_MEM_TYPE = 0,
+ HWC_PHYS_MEM_TYPE,
+ HWC_VIRT_MEM_TYPE,
+};
+
+struct hwc_context_t {
+ hwc_composer_device_t device;
+
+ /* our private state goes below here */
+ struct hwc_win_info_t win[NUM_OF_WIN];
+ struct fb_var_screeninfo lcd_info;
+ s5p_fimc_t fimc;
+ unsigned int num_of_fb_layer;
+ unsigned int num_of_hwc_layer;
+};
+
+int window_open(struct hwc_win_info_t *win, int id);
+int window_close(struct hwc_win_info_t *win);
+int window_set_pos(struct hwc_win_info_t *win);
+int window_get_info(struct hwc_win_info_t *win);
+int window_pan_display(struct hwc_win_info_t *win);
+int window_show(struct hwc_win_info_t *win);
+int window_hide(struct hwc_win_info_t *win);
+int window_get_global_lcd_info(int fd, struct fb_var_screeninfo *lcd_info);
+
+int createFimc(s5p_fimc_t *fimc);
+int destroyFimc(s5p_fimc_t *fimc);
+int runFimc(struct hwc_context_t *ctx,
+ struct sec_img *src_img, struct sec_rect *src_rect,
+ struct sec_img *dst_img, struct sec_rect *dst_rect,
+ unsigned int *phyAddr,
+ uint32_t transform);
+#endif /* ANDROID_SEC_HWC_UTILS_H_*/
+
diff --git a/liblight/Android.mk b/liblight/Android.mk
index d10b586..b799a63 100755
--- a/liblight/Android.mk
+++ b/liblight/Android.mk
@@ -15,13 +15,13 @@
ifneq ($(filter crespo crespo4g,$(TARGET_DEVICE)),)
LOCAL_PATH:= $(call my-dir)
-# HAL module implemenation, not prelinked and stored in
+# HAL module implemenation stored in
# hw/<COPYPIX_HARDWARE_MODULE_ID>.<ro.board.platform>.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
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
deleted file mode 100644
index 6220106..0000000
--- a/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 <hardware/hardware.h>
-#include <hardware/overlay.h>
-
-extern "C" {
-#include "v4l2_utils.h"
-}
-
-#include <pthread.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#include <linux/videodev.h>
-
-#include <cutils/log.h>
-#include <cutils/ashmem.h>
-#include <cutils/atomic.h>
-
-#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<const struct handle_t *>(overlay)->format;
-}
-
-static int handle_ctl_fd(const overlay_handle_t overlay) {
- return static_cast<const struct handle_t *>(overlay)->ctl_fd;
-}
-
-static int handle_shared_fd(const overlay_handle_t overlay) {
- return static_cast<const struct handle_t *>(overlay)->shared_fd;
-}
-
-static int handle_num_buffers(const overlay_handle_t overlay) {
- return static_cast<const struct handle_t *>(overlay)->num_buffers;
-}
-
-static int handle_width(const overlay_handle_t overlay) {
- return static_cast<const struct handle_t *>(overlay)->width;
-}
-
-static int handle_height(const overlay_handle_t overlay) {
- return static_cast<const struct handle_t *>(overlay)->height;
-}
-
-static int handle_shared_size(const overlay_handle_t overlay) {
- return static_cast<const struct handle_t *>(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_object *>(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) {
- LOGV("format == OVERLAY_FORMAT_DEFAULT\n");
- LOGV("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_object *>(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_object *>(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_object *>(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_object *>(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_object *>(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;
- }
-
- LOGV("Position/X%d/Y%d/W%d/H%d\n", data->posX, data->posY, data->posW,
- data->posH);
- LOGV("Adjusted Position/X%d/Y%d/W%d/H%d\n", stage->posX, stage->posY,
- stage->posW, stage->posH);
- LOGV("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<overlay_object *>(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;
-
- LOGV("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<hw_module_t*>(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<hw_module_t*>(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
deleted file mode 100644
index 5c4457b..0000000
--- a/liboverlay/v4l2_utils.c
+++ /dev/null
@@ -1,783 +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 <fcntl.h>
-#include <errno.h>
-#include <cutils/log.h>
-#include <hardware/overlay.h>
-#include <linux/videodev.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include "v4l2_utils.h"
-
-
-#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("/dev/video1", 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
deleted file mode 100644
index 02797c3..0000000
--- a/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/libs3cjpeg/Android.mk b/libs3cjpeg/Android.mk
index 7f8c823..af1f88e 100644
--- a/libs3cjpeg/Android.mk
+++ b/libs3cjpeg/Android.mk
@@ -31,7 +31,7 @@ LOCAL_MODULE:= libs3cjpeg
LOCAL_MODULE_TAGS := optional
-LOCAL_PRELINK_MODULE := false
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/libsensors/Android.mk b/libsensors/Android.mk
index 4ef72e9..b451d4a 100644
--- a/libsensors/Android.mk
+++ b/libsensors/Android.mk
@@ -15,9 +15,7 @@
LOCAL_PATH := $(call my-dir)
-ifneq ($(TARGET_SIMULATOR),true)
-
-# HAL module implemenation, not prelinked, and stored in
+# HAL module implemenation stored in
# hw/<SENSORS_HARDWARE_MODULE_ID>.<ro.product.board>.so
include $(CLEAR_VARS)
@@ -38,8 +36,5 @@ LOCAL_SRC_FILES := \
InputEventReader.cpp
LOCAL_SHARED_LIBRARIES := liblog libcutils libdl
-LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
-
-endif # !TARGET_SIMULATOR
diff --git a/libstagefrighthw/Android.mk b/libstagefrighthw/Android.mk
index 30847ee..3598451 100644
--- a/libstagefrighthw/Android.mk
+++ b/libstagefrighthw/Android.mk
@@ -18,7 +18,6 @@ LOCAL_SHARED_LIBRARIES := \
libcutils \
libui \
libdl \
- libsurfaceflinger_client
LOCAL_MODULE := libstagefrighthw
diff --git a/media_profiles.xml b/media_profiles.xml
index e57951d..576bddc 100644
--- a/media_profiles.xml
+++ b/media_profiles.xml
@@ -22,7 +22,7 @@
AudioDecoderCap)>
<!ELEMENT CamcorderProfiles (EncoderProfile+, ImageEncoding+, ImageDecoding, Camera)>
<!ELEMENT EncoderProfile (Video, Audio)>
-<!ATTLIST EncoderProfile quality (high|low) #REQUIRED>
+<!ATTLIST EncoderProfile quality (480p|qcif) #REQUIRED>
<!ATTLIST EncoderProfile fileFormat (mp4|3gp) #REQUIRED>
<!ATTLIST EncoderProfile duration (30|60) #REQUIRED>
<!ATTLIST EncoderProfile cameraId (0|1) #REQUIRED>
@@ -70,6 +70,15 @@
<!ELEMENT AudioDecoderCap EMPTY>
<!ATTLIST AudioDecoderCap name (wma) #REQUIRED>
<!ATTLIST AudioDecoderCap enabled (true|false) #REQUIRED>
+<!ELEMENT VideoEditorCap EMPTY>
+<!ATTLIST VideoEditorCap maxInputFrameWidth CDATA #REQUIRED>
+<!ATTLIST VideoEditorCap maxInputFrameHeight CDATA #REQUIRED>
+<!ATTLIST VideoEditorCap maxOutputFrameWidth CDATA #REQUIRED>
+<!ATTLIST VideoEditorCap maxOutputFrameHeight CDATA #REQUIRED>
+<!ELEMENT ExportVideoProfile EMPTY>
+<!ATTLIST ExportVideoProfile name (h264|h263|m4v) #REQUIRED>
+<!ATTLIST ExportVideoProfile profile CDATA #REQUIRED>
+<!ATTLIST ExportVideoProfile level CDATA #REQUIRED>
]>
<!--
This file is used to declare the multimedia profiles and capabilities
@@ -79,7 +88,7 @@
<!-- Each camcorder profile defines a set of predefined configuration parameters -->
<CamcorderProfiles cameraId="0">
- <EncoderProfile quality="high" fileFormat="mp4" duration="60">
+ <EncoderProfile quality="480p" fileFormat="mp4" duration="60">
<Video codec="h264"
bitRate="3000000"
width="720"
@@ -92,7 +101,7 @@
channels="1" />
</EncoderProfile>
- <EncoderProfile quality="low" fileFormat="3gp" duration="30">
+ <EncoderProfile quality="qcif" fileFormat="3gp" duration="30">
<Video codec="h264"
bitRate="256000"
width="176"
@@ -106,6 +115,33 @@
</EncoderProfile>
+ <EncoderProfile quality="timelapse480p" fileFormat="mp4" duration="60">
+ <Video codec="h264"
+ bitRate="3000000"
+ width="720"
+ height="480"
+ frameRate="30" />
+
+ <!-- Audio settings are not used for timealpse video recording -->
+ <Audio codec="aac"
+ bitRate="96000"
+ sampleRate="16000"
+ channels="1" />
+ </EncoderProfile>
+
+ <EncoderProfile quality="timelapseqcif" fileFormat="3gp" duration="30">
+ <Video codec="h264"
+ bitRate="256000"
+ width="176"
+ height="144"
+ frameRate="30" />
+ <!-- Audio settings are not used for timealpse video recording -->
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
<ImageEncoding quality="90" />
<ImageEncoding quality="80" />
<ImageEncoding quality="70" />
@@ -115,12 +151,12 @@
<CamcorderProfiles cameraId="1">
- <EncoderProfile quality="high" fileFormat="mp4" duration="60">
+ <EncoderProfile quality="480p" fileFormat="mp4" duration="60">
<Video codec="h264"
bitRate="1000000"
width="640"
height="480"
- frameRate="30" />
+ frameRate="15" />
<Audio codec="aac"
bitRate="96000"
@@ -128,12 +164,12 @@
channels="1" />
</EncoderProfile>
- <EncoderProfile quality="low" fileFormat="3gp" duration="30">
+ <EncoderProfile quality="qcif" fileFormat="3gp" duration="30">
<Video codec="h264"
bitRate="256000"
width="176"
height="144"
- frameRate="30" />
+ frameRate="15" />
<Audio codec="amrnb"
bitRate="12200"
@@ -142,6 +178,33 @@
</EncoderProfile>
+ <EncoderProfile quality="timelapse480p" fileFormat="mp4" duration="60">
+ <Video codec="h264"
+ bitRate="1000000"
+ width="640"
+ height="480"
+ frameRate="15" />
+
+ <!-- Audio settings are not used for timealpse video recording -->
+ <Audio codec="aac"
+ bitRate="96000"
+ sampleRate="16000"
+ channels="1" />
+ </EncoderProfile>
+
+ <EncoderProfile quality="timelapseqcif" fileFormat="3gp" duration="30">
+ <Video codec="h264"
+ bitRate="256000"
+ width="176"
+ height="144"
+ frameRate="15" />
+ <!-- Audio settings are not used for timealpse video recording -->
+ <Audio codec="amrnb"
+ bitRate="12200"
+ sampleRate="8000"
+ channels="1" />
+ </EncoderProfile>
+
<ImageEncoding quality="90" />
<ImageEncoding quality="80" />
<ImageEncoding quality="70" />
@@ -200,4 +263,27 @@
-->
<VideoDecoderCap name="wmv" enabled="false"/>
<AudioDecoderCap name="wma" enabled="false"/>
+ <VideoEditorCap maxInputFrameWidth="1280"
+ maxInputFrameHeight="720" maxOutputFrameWidth="1280"
+ maxOutputFrameHeight="720"/>
+ <!--
+ The VideoEditor Export codec profile and level values
+ correspond to the values in OMX_Video.h.
+ E.g. for h264, profile value 1 means OMX_VIDEO_AVCProfileBaseline
+ and level 256 means OMX_VIDEO_AVCLevel3.
+ Please note that the values are in decimal.
+ These values are for video encoder.
+ -->
+ <!--
+ Codec = h.264, Baseline profile, level 3
+ -->
+ <ExportVideoProfile name="h264" profile= "1" level="256"/>
+ <!--
+ Codec = h.263, Baseline profile, level 0
+ -->
+ <ExportVideoProfile name="h263" profile= "1" level="1"/>
+ <!--
+ Codec = mpeg4, Simple profile, level 3
+ -->
+ <ExportVideoProfile name="m4v" profile= "1" level="16"/>
</MediaSettings>
diff --git a/mxt224_ts_input.idc b/mxt224_ts_input.idc
index d258f04..4f640ef 100644
--- a/mxt224_ts_input.idc
+++ b/mxt224_ts_input.idc
@@ -15,41 +15,26 @@
#
# Input Device Calibration File for the Crespo touch screen.
#
-# These calibration values are derived from empirical measurements
-# and may not be appropriate for use with other touch screens.
-# Refer to the input device calibration documentation for more details.
-#
# Basic Parameters
touch.deviceType = touchScreen
touch.orientationAware = 1
-# Touch Size
-touch.touchSize.calibration = pressure
-
-# Tool Size
-# Driver reports tool size as an area measurement.
-#
-# Based on empirical measurements, we estimate the size of the tool
-# using size = sqrt(22 * rawToolArea + 0) * 9.2 + 0.
-touch.toolSize.calibration = area
-touch.toolSize.areaScale = 22
-touch.toolSize.areaBias = 0
-touch.toolSize.linearScale = 9.2
-touch.toolSize.linearBias = 0
-touch.toolSize.isSummed = 0
+# Size
+# Based on empirical measurements, we estimate the size of the contact
+# using size = sqrt(area) * 43 + 0.
+touch.size.calibration = area
+touch.size.scale = 43
+touch.size.bias = 0
+touch.size.isSummed = 0
# Pressure
# Driver reports signal strength as pressure.
#
-# A normal thumb touch typically registers about 100 signal strength
+# A normal thumb touch typically registers about 80 signal strength
# units although we don't expect these values to be accurate.
touch.pressure.calibration = amplitude
-touch.pressure.source = default
-touch.pressure.scale = 0.01
-
-# Size
-touch.size.calibration = normalized
+touch.pressure.scale = 0.0125
# Orientation
touch.orientation.calibration = none
diff --git a/mxt224_ts_input.kcm b/mxt224_ts_input.kcm
new file mode 100644
index 0000000..1a3cb57
--- /dev/null
+++ b/mxt224_ts_input.kcm
@@ -0,0 +1,15 @@
+# Copyright (C) 2011 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.
+
+type SPECIAL_FUNCTION
diff --git a/mxt224_ts_input.kl b/mxt224_ts_input.kl
new file mode 100644
index 0000000..bea3f40
--- /dev/null
+++ b/mxt224_ts_input.kl
@@ -0,0 +1,18 @@
+# Copyright (C) 2011 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.
+
+key 158 BACK WAKE
+key 139 MENU WAKE
+key 217 SEARCH WAKE
+key 102 HOME WAKE
diff --git a/nvram_net.txt b/nvram_net.txt
new file mode 100755
index 0000000..f27f4a4
--- /dev/null
+++ b/nvram_net.txt
@@ -0,0 +1,58 @@
+sromrev=3
+vendid=0x14e4
+devid=0x432f
+boardtype=0x569
+boardrev=0x32
+boardflags=0x200
+xtalfreq=38400
+aa2g=1
+aa5g=0
+ag0=255
+
+# 11g paparams
+pa0b0=5585,5585,5757
+pa0b1=64174,64174,64201
+pa0b2=65162,65162,65207
+pa0itssit=62
+pa0maxpwr=77
+mcs2gpo0=0xaaaa
+mcs2gpo1=0xaaaa
+ofdmpo=0x66666666
+
+# 11g rssi params
+rssismf2g=0xa,0xa,0xa
+rssismc2g=0xb,0xb,0xa
+rssisav2g=0x3,0x3,0x3
+
+bxa2g=0
+rxpo2g=2
+tri2g=98
+
+# country code
+ccode=US
+cctl=0x0
+cckdigfilttype=6
+ofdmdigfilttype=1
+
+boardnum=1
+#macaddr=00:90:4c:c5:00:34
+#macaddr=00:11:22:33:44:55
+
+#######
+nocrc=1
+
+#for mfgc
+otpimagesize=182
+
+# sdio extra configs
+hwhdr=0x05ffff031030031003100000
+
+#This generates empty F1, F2 and F3 tuple chains, and may be used if the host SDIO stack does not require the standard tuples.
+#RAW1=80 02 fe ff
+
+#This includes the standard FUNCID and FUNCE tuples in the F1, F2, F3 and common CIS.
+RAW1=80 32 fe 21 02 0c 00 22 2a 01 01 00 00 c5 0 e6 00 00 00 00 00 40 00 00 ff ff 80 00 00 00 00 00 00 00 00 00 00 c8 00 00 00 00 00 00 00 00 00 00 00 00 00 ff 20 04 D0 2 29 43 21 02 0c 00 22 04 00 20 00 5A
+
+#for BT-coexistence
+btc_params80=0
+btc_params6=10
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
index 9680997..eb71bf5 100644
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -44,6 +44,7 @@
Must be overridden in platform specific overlays -->
<integer-array name="config_autoBrightnessLevels">
+ <item>100</item>
<item>200</item>
<item>400</item>
<item>1000</item>
@@ -55,6 +56,7 @@
than the size of the config_autoBrightnessLevels array.
-->
<integer-array name="config_autoBrightnessLcdBacklightValues">
+ <item>10</item>
<item>35</item>
<item>55</item>
<item>70</item>
@@ -69,6 +71,7 @@
<integer-array name="config_autoBrightnessButtonBacklightValues">
<item>255</item>
<item>255</item>
+ <item>255</item>
<item>0</item>
<item>0</item>
<item>0</item>
@@ -85,8 +88,12 @@
<item>0</item>
<item>0</item>
<item>0</item>
+ <item>0</item>
</integer-array>
-
+
+ <!-- Minimum screen brightness allowed by the power manager. -->
+ <integer name="config_screenBrightnessDim">10</integer>
+
<!-- Component name of the default wallpaper. This will be ImageWallpaper if not
specified -->
<string name="default_wallpaper_component">com.android.wallpaper/.nexus.NexusWallpaper</string>
@@ -126,13 +133,25 @@
<item>"mobile_supl,3,0,2,60000,true"</item>
<item>"mobile_dun,4,0,4,60000,true"</item>
<item>"mobile_hipri,5,0,3,60000,true"</item>
+ <item>"bluetooth,7,7,0,-1,true"</item>
+ </string-array>
+
+ <!-- This string array should be overridden by the device to present a list of radio
+ attributes. This is used by the connectivity manager to decide which networks can coexist
+ based on the hardware -->
+ <!-- An Array of "[ConnectivityManager connectionType],
+ [# simultaneous connection types]" -->
+ <string-array translatable="false" name="radioAttributes">
+ <item>"1,1"</item>
+ <item>"0,1"</item>
+ <item>"7,1"</item>
</string-array>
<!-- List of regexpressions describing the interface (if any) that represent tetherable
USB interfaces. If the device doesn't want to support tething over USB this should
be empty. An example would be "usb.*" -->
<string-array translatable="false" name="config_tether_usb_regexs">
- <item>"usb0"</item>
+ <item>"rndis0"</item>
</string-array>
<!-- Array of allowable ConnectivityManager network types for tethering -->
@@ -152,6 +171,13 @@
<item>"wl0.1"</item>
</string-array>
+ <!-- List of regexpressions describing the interface (if any) that represent tetherable
+ bluetooth interfaces. If the device doesn't want to support tethering over bluetooth this
+ should be empty. -->
+ <string-array translatable="false" name="config_tether_bluetooth_regexs">
+ <item>"bnep\\d"</item>
+ </string-array>
+
<!-- Vibrator pattern for a very short but reliable vibration for soft keyboard tap -->
<integer-array name="config_keyboardTapVibePattern">
<item>30</item>
@@ -176,4 +202,11 @@
It is recommended that this value be no more than 250 ms.
This feature should be disabled for most devices. -->
<integer name="config_virtualKeyQuietTimeMillis">250</integer>
+
+ <!-- Boolean indicating if current platform supports bluetooth wide band
+ speech -->
+ <bool name="config_bluetooth_wide_band_speech">false</bool>
+
+ <bool name="config_ui_enableFadingMarquee">false</bool>
+
</resources>
diff --git a/overlay/frameworks/base/core/res/res/xml/storage_list.xml b/overlay/frameworks/base/core/res/res/xml/storage_list.xml
new file mode 100644
index 0000000..9670ba5
--- /dev/null
+++ b/overlay/frameworks/base/core/res/res/xml/storage_list.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2011, 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.
+*/
+-->
+
+<!-- The <device> element should contain one or more <storage> elements.
+ Exactly one of these should have the attribute primary="true".
+ This storage will be the primary external storage and should have mountPoint="/mnt/sdcard".
+ Each storage should have both a mountPoint and storageDescription attribute.
+ The following attributes are optional:
+
+ primary: (boolean) this storage is the primary external storage
+ removable: (boolean) this is removable storage (for example, a real SD card)
+ emulated: (boolean) the storage is emulated via the FUSE sdcard daemon
+ mtpReserve: (integer) number of megabytes of storage MTP should reserve for free storage
+ (used for emulated storage that is shared with system's data partition)
+ allowMassStorage: (boolean) true if this volume can be shared via USB mass storage
+ maxFileSize: (integer) maximum file size in megabytes
+
+ A storage should not have both emulated and removable set to true
+-->
+
+<StorageList xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- removable is not set in nosdcard product -->
+ <storage android:mountPoint="/mnt/sdcard"
+ android:storageDescription="@string/storage_usb"
+ android:primary="true"
+ android:allowMassStorage="true"
+ android:maxFileSize="4096" />
+</StorageList>
diff --git a/overlay/frameworks/base/packages/SystemUI/res/values/config.xml b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml
new file mode 100644
index 0000000..4d7635d
--- /dev/null
+++ b/overlay/frameworks/base/packages/SystemUI/res/values/config.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2011, 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.
+*/
+-->
+
+<!-- These resources are around just to allow their values to be customized
+ for different hardware and product builds. -->
+<resources>
+
+ <!-- Control whether status bar should distinguish HSPA data icon form UMTS
+ data icon on devices -->
+ <bool name="config_hspa_data_distinguishable">true</bool>
+
+</resources>
+
diff --git a/overlay/packages/apps/Contacts/res/values/config.xml b/overlay/packages/apps/Contacts/res/values/config.xml
deleted file mode 100644
index 6e48cd8..0000000
--- a/overlay/packages/apps/Contacts/res/values/config.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<!-- Crespo-specific Contacts app resources. -->
-<resources>
- <!-- Enable the onscreen "Dial" button in the dialer. -->
- <bool name="config_show_onscreen_dial_button">true</bool>
-</resources>
diff --git a/overlay/packages/apps/Launcher2/res/drawable-hdpi/wallpaper_shuttle.jpg b/overlay/packages/apps/Launcher2/res/drawable-hdpi/wallpaper_shuttle.jpg
new file mode 100644
index 0000000..f4a3934
--- /dev/null
+++ b/overlay/packages/apps/Launcher2/res/drawable-hdpi/wallpaper_shuttle.jpg
Binary files differ
diff --git a/overlay/packages/apps/Launcher2/res/drawable-hdpi/wallpaper_shuttle_small.jpg b/overlay/packages/apps/Launcher2/res/drawable-hdpi/wallpaper_shuttle_small.jpg
new file mode 100644
index 0000000..d580182
--- /dev/null
+++ b/overlay/packages/apps/Launcher2/res/drawable-hdpi/wallpaper_shuttle_small.jpg
Binary files differ
diff --git a/overlay/packages/apps/Launcher2/res/values-hdpi/wallpapers.xml b/overlay/packages/apps/Launcher2/res/values-hdpi/wallpapers.xml
index 6d3ec8d..40033cf 100644
--- a/overlay/packages/apps/Launcher2/res/values-hdpi/wallpapers.xml
+++ b/overlay/packages/apps/Launcher2/res/values-hdpi/wallpapers.xml
@@ -31,5 +31,6 @@
<item>wallpaper_mountains</item>
<item>wallpaper_sunset</item>
<item>wallpaper_goldengate</item>
+ <item>wallpaper_shuttle</item>
</string-array>
</resources>
diff --git a/overlay/packages/apps/Launcher2/res/values/config.xml b/overlay/packages/apps/Launcher2/res/values/config.xml
new file mode 100644
index 0000000..197889b
--- /dev/null
+++ b/overlay/packages/apps/Launcher2/res/values/config.xml
@@ -0,0 +1,3 @@
+<resources>
+ <bool name="config_hardwareAccelerated">true</bool>
+</resources>
diff --git a/overlay/packages/apps/Phone/res/values/config.xml b/overlay/packages/apps/Phone/res/values/config.xml
index 69d82c1..7d69b68 100644
--- a/overlay/packages/apps/Phone/res/values/config.xml
+++ b/overlay/packages/apps/Phone/res/values/config.xml
@@ -17,19 +17,6 @@
<!-- Crespo-specific phone app resources. -->
<resources>
- <!-- Enable the onscreen touch UI for all states of the in-call UI. -->
- <bool name="allow_incoming_call_touch_ui">true</bool>
- <bool name="allow_in_call_touch_ui">true</bool>
-
- <!-- This is a device with capacitive buttons, so disable the feature
- where BACK rejects the current incoming call. (Since it's so
- easy to press the key accidentally as you pull the phone out of
- your pocket.) -->
- <bool name="allow_back_key_to_reject_incoming_call">false</bool>
-
- <!-- Enable the onscreen "Dial" button in the emergency dialer. -->
- <bool name="config_show_onscreen_dial_button">true</bool>
-
<!-- This device implements a noise suppression device for in call audio-->
<bool name="has_in_call_noise_suppression">true</bool>
diff --git a/overlay/packages/apps/Settings/res/values/bools.xml b/overlay/packages/apps/Settings/res/values/bools.xml
deleted file mode 100644
index cc816c0..0000000
--- a/overlay/packages/apps/Settings/res/values/bools.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<resources>
- <!-- Whether or not there is a notification led that is too intrusive to be pulsing
- constantly -->
- <bool name="has_intrusive_led">false</bool>
-</resources>
diff --git a/samsung_mfc_fw.bin b/samsung_mfc_fw.bin
new file mode 100644
index 0000000..67483e0
--- /dev/null
+++ b/samsung_mfc_fw.bin
Binary files differ
diff --git a/sec_mm/sec_omx/sec_codecs/Android.mk b/sec_mm/sec_omx/sec_codecs/Android.mk
index a51a075..3c163a4 100644
--- a/sec_mm/sec_omx/sec_codecs/Android.mk
+++ b/sec_mm/sec_omx/sec_codecs/Android.mk
@@ -4,4 +4,4 @@ include $(CLEAR_VARS)
include $(SEC_CODECS)/video/mfc_c110/dec/Android.mk
include $(SEC_CODECS)/video/mfc_c110/enc/Android.mk
-
+include $(SEC_CODECS)/video/mfc_c110/csc/Android.mk \ No newline at end of file
diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/Android.mk b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/Android.mk
new file mode 100644
index 0000000..4106a68
--- /dev/null
+++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/Android.mk
@@ -0,0 +1,36 @@
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+ifeq ($(ARCH_ARM_HAVE_NEON),true)
+LOCAL_SRC_FILES := \
+ csc_yuv420_nv12t_y_neon.s \
+ csc_yuv420_nv12t_uv_neon.s \
+ csc_nv12t_yuv420_y_neon.s \
+ csc_nv12t_yuv420_uv_neon.s \
+ csc_interleave_memcpy.s \
+ csc_deinterleave_memcpy.s
+
+else
+LOCAL_SRC_FILES := \
+ color_space_convertor.c
+
+endif
+
+LOCAL_MODULE := libseccsc
+
+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/csc/color_space_convertor.c b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/color_space_convertor.c
new file mode 100644
index 0000000..c1ac638
--- /dev/null
+++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/color_space_convertor.c
@@ -0,0 +1,1092 @@
+/*
+ *
+ * Copyright 2011 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 color_space_convertor.c
+ * @brief SEC_OMX specific define
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2011.7.01 : Create
+ */
+
+#include "stdlib.h"
+#include "color_space_convertor.h"
+
+#define TILED_SIZE 64*32
+
+/*
+ * De-interleaves src to dest1, dest2
+ *
+ * @param dest1
+ * Address of de-interleaved data[out]
+ *
+ * @param dest2
+ * Address of de-interleaved data[out]
+ *
+ * @param src
+ * Address of interleaved data[in]
+ *
+ * @param src_size
+ * Size of interleaved data[in]
+ */
+void csc_deinterleave_memcpy(char *dest1, char *dest2, char *src, int src_size)
+{
+ int i = 0;
+ for(i=0; i<src_size/2; i++) {
+ dest1[i] = src[i*2];
+ dest2[i] = src[i*2+1];
+ }
+}
+
+/*
+ * Interleaves src1, src2 to dest
+ *
+ * @param dest
+ * Address of interleaved data[out]
+ *
+ * @param src1
+ * Address of de-interleaved data[in]
+ *
+ * @param src2
+ * Address of de-interleaved data[in]
+ *
+ * @param src_size
+ * Size of de-interleaved data[in]
+ */
+void csc_interleave_memcpy(char *dest, char *src1, char *src2, int src_size)
+{
+ int i = 0;
+ for(i=0; i<src_size; i++) {
+ dest[i*2] = src1[i];
+ dest[i*2+1] = src2[i];
+ }
+}
+
+/*
+ * Converts tiled data to linear.
+ * 1. Y of NV12T to Y of YUV420P
+ * 2. Y of NV12T to Y of YUV420S
+ * 3. UV of NV12T to UV of YUV420S
+ *
+ * @param yuv420_dest
+ * Y or UV plane address of YUV420[out]
+ *
+ * @param nv12t_src
+ * Y or UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ */
+void csc_tiled_to_linear(char *yuv420_dest, char *nv12t_src, int yuv420_width, int yuv420_height)
+{
+ unsigned int i, j;
+ unsigned int tiled_x_index = 0, tiled_y_index = 0;
+ unsigned int aligned_x_size = 0;
+ unsigned int tiled_offset = 0, tiled_offset1 = 0, tiled_offset2 = 0, tiled_offset3 = 0;
+ unsigned int temp1 = 0, temp2 = 0;
+
+ if (yuv420_width >= 1024) {
+ for (i=0; i<yuv420_height; i=i+1) {
+ tiled_offset = 0;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+2;
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*2;
+ tiled_offset3 = tiled_offset+2048*3;
+ temp2 = 8;
+ } else {
+ temp2 = ((yuv420_height+31)>>5)<<5;
+ /* even fomula: x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ if ((i+32)<temp2) {
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*6;
+ tiled_offset3 = tiled_offset+2048*7;
+ temp2 = 8;
+ } else {
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*2;
+ tiled_offset3 = tiled_offset+2048*3;
+ temp2 = 4;
+ }
+ }
+ temp1 = i&0x1F;
+ memcpy(yuv420_dest+yuv420_width*(i), nv12t_src+tiled_offset+64*(temp1), 64);
+ memcpy(yuv420_dest+yuv420_width*(i)+64*1, nv12t_src+tiled_offset1+64*(temp1), 64);
+ memcpy(yuv420_dest+yuv420_width*(i)+64*2, nv12t_src+tiled_offset2+64*(temp1), 64);
+ memcpy(yuv420_dest+yuv420_width*(i)+64*3, nv12t_src+tiled_offset3+64*(temp1), 64);
+
+ tiled_offset = tiled_offset+temp2*2048;
+ tiled_offset1 = tiled_offset1+temp2*2048;
+ tiled_offset2 = tiled_offset2+temp2*2048;
+ tiled_offset3 = tiled_offset3+temp2*2048;
+ memcpy(yuv420_dest+yuv420_width*(i)+64*4, nv12t_src+tiled_offset+64*(temp1), 64);
+ memcpy(yuv420_dest+yuv420_width*(i)+64*5, nv12t_src+tiled_offset1+64*(temp1), 64);
+ memcpy(yuv420_dest+yuv420_width*(i)+64*6, nv12t_src+tiled_offset2+64*(temp1), 64);
+ memcpy(yuv420_dest+yuv420_width*(i)+64*7, nv12t_src+tiled_offset3+64*(temp1), 64);
+
+ tiled_offset = tiled_offset+temp2*2048;
+ tiled_offset1 = tiled_offset1+temp2*2048;
+ tiled_offset2 = tiled_offset2+temp2*2048;
+ tiled_offset3 = tiled_offset3+temp2*2048;
+ memcpy(yuv420_dest+yuv420_width*(i)+64*8, nv12t_src+tiled_offset+64*(temp1), 64);
+ memcpy(yuv420_dest+yuv420_width*(i)+64*9, nv12t_src+tiled_offset1+64*(temp1), 64);
+ memcpy(yuv420_dest+yuv420_width*(i)+64*10, nv12t_src+tiled_offset2+64*(temp1), 64);
+ memcpy(yuv420_dest+yuv420_width*(i)+64*11, nv12t_src+tiled_offset3+64*(temp1), 64);
+
+ tiled_offset = tiled_offset+temp2*2048;
+ tiled_offset1 = tiled_offset1+temp2*2048;
+ tiled_offset2 = tiled_offset2+temp2*2048;
+ tiled_offset3 = tiled_offset3+temp2*2048;
+ memcpy(yuv420_dest+yuv420_width*(i)+64*12, nv12t_src+tiled_offset+64*(temp1), 64);
+ memcpy(yuv420_dest+yuv420_width*(i)+64*13, nv12t_src+tiled_offset1+64*(temp1), 64);
+ memcpy(yuv420_dest+yuv420_width*(i)+64*14, nv12t_src+tiled_offset2+64*(temp1), 64);
+ memcpy(yuv420_dest+yuv420_width*(i)+64*15, nv12t_src+tiled_offset3+64*(temp1), 64);
+ }
+ aligned_x_size = 1024;
+ }
+
+ if ((yuv420_width-aligned_x_size) >= 512) {
+ for (i=0; i<yuv420_height; i=i+1) {
+ tiled_offset = 0;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+2;
+ temp1 = aligned_x_size>>5;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*2;
+ tiled_offset3 = tiled_offset+2048*3;
+ temp2 = 8;
+ } else {
+ temp2 = ((yuv420_height+31)>>5)<<5;
+ /* even fomula: x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ if ((i+32)<temp2) {
+ temp1 = aligned_x_size>>5;
+ tiled_offset = tiled_offset+(temp1<<11);
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*6;
+ tiled_offset3 = tiled_offset+2048*7;
+ temp2 = 8;
+ } else {
+ temp1 = aligned_x_size>>6;
+ tiled_offset = tiled_offset+(temp1<<11);
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*2;
+ tiled_offset3 = tiled_offset+2048*3;
+ temp2 = 4;
+ }
+ }
+ temp1 = i&0x1F;
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i), nv12t_src+tiled_offset+64*(temp1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i)+64*1, nv12t_src+tiled_offset1+64*(temp1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i)+64*2, nv12t_src+tiled_offset2+64*(temp1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i)+64*3, nv12t_src+tiled_offset3+64*(temp1), 64);
+
+ tiled_offset = tiled_offset+temp2*2048;
+ tiled_offset1 = tiled_offset1+temp2*2048;
+ tiled_offset2 = tiled_offset2+temp2*2048;
+ tiled_offset3 = tiled_offset3+temp2*2048;
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i)+64*4, nv12t_src+tiled_offset+64*(temp1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i)+64*5, nv12t_src+tiled_offset1+64*(temp1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i)+64*6, nv12t_src+tiled_offset2+64*(temp1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i)+64*7, nv12t_src+tiled_offset3+64*(temp1), 64);
+ }
+ aligned_x_size = aligned_x_size+512;
+ }
+
+ if ((yuv420_width-aligned_x_size) >= 256) {
+ for (i=0; i<yuv420_height; i=i+1) {
+ tiled_offset = 0;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+2;
+ temp1 = aligned_x_size>>5;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*2;
+ tiled_offset3 = tiled_offset+2048*3;
+ } else {
+ temp2 = ((yuv420_height+31)>>5)<<5;
+ /* even fomula: x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ if ((i+32)<temp2) {
+ temp1 = aligned_x_size>>5;
+ tiled_offset = tiled_offset+(temp1<<11);
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*6;
+ tiled_offset3 = tiled_offset+2048*7;
+ } else {
+ temp1 = aligned_x_size>>6;
+ tiled_offset = tiled_offset+(temp1<<11);
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*2;
+ tiled_offset3 = tiled_offset+2048*3;
+ }
+ }
+ temp1 = i&0x1F;
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i), nv12t_src+tiled_offset+64*(temp1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i)+64*1, nv12t_src+tiled_offset1+64*(temp1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i)+64*2, nv12t_src+tiled_offset2+64*(temp1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i)+64*3, nv12t_src+tiled_offset3+64*(temp1), 64);
+ }
+ aligned_x_size = aligned_x_size+256;
+ }
+
+ if ((yuv420_width-aligned_x_size) >= 128) {
+ for (i=0; i<yuv420_height; i=i+2) {
+ tiled_offset = 0;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+2;
+ temp1 = aligned_x_size>>5;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*1;
+ } else {
+ temp2 = ((yuv420_height+31)>>5)<<5;
+ /* even fomula: x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ if ((i+32)<temp2) {
+ temp1 = aligned_x_size>>5;
+ tiled_offset = tiled_offset+(temp1<<11);
+ tiled_offset1 = tiled_offset+2048*1;
+ } else {
+ temp1 = aligned_x_size>>6;
+ tiled_offset = tiled_offset+(temp1<<11);
+ tiled_offset1 = tiled_offset+2048*1;
+ }
+ }
+ temp1 = i&0x1F;
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i), nv12t_src+tiled_offset+64*(temp1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i)+64, nv12t_src+tiled_offset1+64*(temp1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i+1), nv12t_src+tiled_offset+64*(temp1+1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i+1)+64, nv12t_src+tiled_offset1+64*(temp1+1), 64);
+ }
+ aligned_x_size = aligned_x_size+128;
+ }
+
+ if ((yuv420_width-aligned_x_size) >= 64) {
+ for (i=0; i<yuv420_height; i=i+4) {
+ tiled_offset = 0;
+ tiled_x_index = aligned_x_size>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = ((yuv420_height+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+
+ temp1 = i&0x1F;
+ temp2 = aligned_x_size&0x3F;
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i), nv12t_src+tiled_offset+temp2+64*(temp1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i+1), nv12t_src+tiled_offset+temp2+64*(temp1+1), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i+2), nv12t_src+tiled_offset+temp2+64*(temp1+2), 64);
+ memcpy(yuv420_dest+aligned_x_size+yuv420_width*(i+3), nv12t_src+tiled_offset+temp2+64*(temp1+3), 64);
+ }
+ aligned_x_size = aligned_x_size+64;
+ }
+
+ if (yuv420_width != aligned_x_size) {
+ for (i=0; i<yuv420_height; i=i+4) {
+ for (j=aligned_x_size; j<yuv420_width; j=j+4) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = ((yuv420_height+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+
+ temp1 = i&0x1F;
+ temp2 = j&0x3F;
+ memcpy(yuv420_dest+j+yuv420_width*(i), nv12t_src+tiled_offset+temp2+64*(temp1), 4);
+ memcpy(yuv420_dest+j+yuv420_width*(i+1), nv12t_src+tiled_offset+temp2+64*(temp1+1), 4);
+ memcpy(yuv420_dest+j+yuv420_width*(i+2), nv12t_src+tiled_offset+temp2+64*(temp1+2), 4);
+ memcpy(yuv420_dest+j+yuv420_width*(i+3), nv12t_src+tiled_offset+temp2+64*(temp1+3), 4);
+ }
+ }
+ }
+}
+
+/*
+ * Converts and Deinterleaves tiled data to linear
+ * 1. UV of NV12T to UV of YUV420P
+ *
+ * @param yuv420_u_dest
+ * U plane address of YUV420P[out]
+ *
+ * @param yuv420_v_dest
+ * V plane address of YUV420P[out]
+ *
+ * @param nv12t_src
+ * UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_uv_height
+ * Height/2 of YUV420[in]
+ */
+void csc_tiled_to_linear_deinterleave(char *yuv420_u_dest, char *yuv420_v_dest, char *nv12t_uv_src, int yuv420_width, int yuv420_uv_height)
+{
+ unsigned int i, j;
+ unsigned int tiled_x_index = 0, tiled_y_index = 0;
+ unsigned int aligned_x_size = 0;
+ unsigned int tiled_offset = 0, tiled_offset1 = 0, tiled_offset2 = 0, tiled_offset3 = 0;
+ unsigned int temp1 = 0, temp2 = 0;
+
+ if (yuv420_width >= 1024) {
+ for (i=0; i<yuv420_uv_height; i=i+1) {
+ tiled_offset = 0;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+2;
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*2;
+ tiled_offset3 = tiled_offset+2048*3;
+ temp2 = 8;
+ } else {
+ temp2 = ((yuv420_uv_height+31)>>5)<<5;
+ /* even fomula: x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ if ((i+32)<temp2) {
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*6;
+ tiled_offset3 = tiled_offset+2048*7;
+ temp2 = 8;
+ } else {
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*2;
+ tiled_offset3 = tiled_offset+2048*3;
+ temp2 = 4;
+ }
+ }
+ temp1 = i&0x1F;
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i), yuv420_v_dest+yuv420_width/2*(i), nv12t_uv_src+tiled_offset+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*1, yuv420_v_dest+yuv420_width/2*(i)+32*1, nv12t_uv_src+tiled_offset1+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*2, yuv420_v_dest+yuv420_width/2*(i)+32*2, nv12t_uv_src+tiled_offset2+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*3, yuv420_v_dest+yuv420_width/2*(i)+32*3, nv12t_uv_src+tiled_offset3+64*(temp1), 64);
+
+ tiled_offset = tiled_offset+temp2*2048;
+ tiled_offset1 = tiled_offset1+temp2*2048;
+ tiled_offset2 = tiled_offset2+temp2*2048;
+ tiled_offset3 = tiled_offset3+temp2*2048;
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*4, yuv420_v_dest+yuv420_width/2*(i)+32*4, nv12t_uv_src+tiled_offset+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*5, yuv420_v_dest+yuv420_width/2*(i)+32*5, nv12t_uv_src+tiled_offset1+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*6, yuv420_v_dest+yuv420_width/2*(i)+32*6, nv12t_uv_src+tiled_offset2+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*7, yuv420_v_dest+yuv420_width/2*(i)+32*7, nv12t_uv_src+tiled_offset3+64*(temp1), 64);
+
+ tiled_offset = tiled_offset+temp2*2048;
+ tiled_offset1 = tiled_offset1+temp2*2048;
+ tiled_offset2 = tiled_offset2+temp2*2048;
+ tiled_offset3 = tiled_offset3+temp2*2048;
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*8, yuv420_v_dest+yuv420_width/2*(i)+32*8, nv12t_uv_src+tiled_offset+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*9, yuv420_v_dest+yuv420_width/2*(i)+32*9, nv12t_uv_src+tiled_offset1+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*10, yuv420_v_dest+yuv420_width/2*(i)+32*10, nv12t_uv_src+tiled_offset2+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*11, yuv420_v_dest+yuv420_width/2*(i)+32*11, nv12t_uv_src+tiled_offset3+64*(temp1), 64);
+
+ tiled_offset = tiled_offset+temp2*2048;
+ tiled_offset1 = tiled_offset1+temp2*2048;
+ tiled_offset2 = tiled_offset2+temp2*2048;
+ tiled_offset3 = tiled_offset3+temp2*2048;
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*12, yuv420_v_dest+yuv420_width/2*(i)+32*12, nv12t_uv_src+tiled_offset+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*13, yuv420_v_dest+yuv420_width/2*(i)+32*13, nv12t_uv_src+tiled_offset1+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*14, yuv420_v_dest+yuv420_width/2*(i)+32*14, nv12t_uv_src+tiled_offset2+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+yuv420_width/2*(i)+32*15, yuv420_v_dest+yuv420_width/2*(i)+32*15, nv12t_uv_src+tiled_offset3+64*(temp1), 64);
+ }
+ aligned_x_size = 1024;
+ }
+
+ if ((yuv420_width-aligned_x_size) >= 512) {
+ for (i=0; i<yuv420_uv_height; i=i+1) {
+ tiled_offset = 0;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+2;
+ temp1 = aligned_x_size>>5;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*2;
+ tiled_offset3 = tiled_offset+2048*3;
+ temp2 = 8;
+ } else {
+ temp2 = ((yuv420_uv_height+31)>>5)<<5;
+ /* even fomula: x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ if ((i+32)<temp2) {
+ temp1 = aligned_x_size>>5;
+ tiled_offset = tiled_offset+(temp1<<11);
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*6;
+ tiled_offset3 = tiled_offset+2048*7;
+ temp2 = 8;
+ } else {
+ temp1 = aligned_x_size>>6;
+ tiled_offset = tiled_offset+(temp1<<11);
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*2;
+ tiled_offset3 = tiled_offset+2048*3;
+ temp2 = 4;
+ }
+ }
+ temp1 = i&0x1F;
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i), yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i), nv12t_uv_src+tiled_offset+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i)+32*1, yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i)+32*1, nv12t_uv_src+tiled_offset1+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i)+32*2, yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i)+32*2, nv12t_uv_src+tiled_offset2+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i)+32*3, yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i)+32*3, nv12t_uv_src+tiled_offset3+64*(temp1), 64);
+
+ tiled_offset = tiled_offset+temp2*2048;
+ tiled_offset1 = tiled_offset1+temp2*2048;
+ tiled_offset2 = tiled_offset2+temp2*2048;
+ tiled_offset3 = tiled_offset3+temp2*2048;
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i)+32*4, yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i)+32*4, nv12t_uv_src+tiled_offset+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i)+32*5, yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i)+32*5, nv12t_uv_src+tiled_offset1+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i)+32*6, yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i)+32*6, nv12t_uv_src+tiled_offset2+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i)+32*7, yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i)+32*7, nv12t_uv_src+tiled_offset3+64*(temp1), 64);
+ }
+ aligned_x_size = aligned_x_size+512;
+ }
+
+ if ((yuv420_width-aligned_x_size) >= 256) {
+ for (i=0; i<yuv420_uv_height; i=i+1) {
+ tiled_offset = 0;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+2;
+ temp1 = aligned_x_size>>5;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*2;
+ tiled_offset3 = tiled_offset+2048*3;
+ } else {
+ temp2 = ((yuv420_uv_height+31)>>5)<<5;
+ /* even fomula: x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ if ((i+32)<temp2) {
+ temp1 = aligned_x_size>>5;
+ tiled_offset = tiled_offset+(temp1<<11);
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*6;
+ tiled_offset3 = tiled_offset+2048*7;
+ } else {
+ temp1 = aligned_x_size>>6;
+ tiled_offset = tiled_offset+(temp1<<11);
+ tiled_offset1 = tiled_offset+2048*1;
+ tiled_offset2 = tiled_offset+2048*2;
+ tiled_offset3 = tiled_offset+2048*3;
+ }
+ }
+ temp1 = i&0x1F;
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i), yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i), nv12t_uv_src+tiled_offset+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i)+32*1, yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i)+32*1, nv12t_uv_src+tiled_offset1+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i)+32*2, yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i)+32*2, nv12t_uv_src+tiled_offset2+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i)+32*3, yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i)+32*3, nv12t_uv_src+tiled_offset3+64*(temp1), 64);
+ }
+ aligned_x_size = aligned_x_size+256;
+ }
+
+ if ((yuv420_width-aligned_x_size) >= 128) {
+ for (i=0; i<yuv420_uv_height; i=i+2) {
+ tiled_offset = 0;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+2;
+ temp1 = aligned_x_size>>5;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ tiled_offset1 = tiled_offset+2048*1;
+ } else {
+ temp2 = ((yuv420_uv_height+31)>>5)<<5;
+ /* even fomula: x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ if ((i+32)<temp2) {
+ temp1 = aligned_x_size>>5;
+ tiled_offset = tiled_offset+(temp1<<11);
+ tiled_offset1 = tiled_offset+2048*1;
+ } else {
+ temp1 = aligned_x_size>>6;
+ tiled_offset = tiled_offset+(temp1<<11);
+ tiled_offset1 = tiled_offset+2048*1;
+ }
+ }
+ temp1 = i&0x1F;
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i), yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i), nv12t_uv_src+tiled_offset+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i)+32*1, yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i)+32*1, nv12t_uv_src+tiled_offset1+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i+1), yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i+1), nv12t_uv_src+tiled_offset+64*(temp1+1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i+1)+32*1, yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i+1)+32*1, nv12t_uv_src+tiled_offset1+64*(temp1+1), 64);
+ }
+ aligned_x_size = aligned_x_size+128;
+ }
+
+ if ((yuv420_width-aligned_x_size) >= 64) {
+ for (i=0; i<yuv420_uv_height; i=i+2) {
+ tiled_offset = 0;
+ tiled_x_index = aligned_x_size>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = ((yuv420_uv_height+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+ temp1 = i&0x1F;
+ temp2 = aligned_x_size&0x3F;
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i), yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i), nv12t_uv_src+tiled_offset+64*(temp1), 64);
+ csc_deinterleave_memcpy(yuv420_u_dest+aligned_x_size/2+yuv420_width/2*(i+1), yuv420_v_dest+aligned_x_size/2+yuv420_width/2*(i+1), nv12t_uv_src+tiled_offset+64*(temp1+1), 64);
+ }
+ aligned_x_size = aligned_x_size+64;
+ }
+
+ if (yuv420_width != aligned_x_size) {
+ for (i=0; i<yuv420_uv_height; i=i+2) {
+ for (j=aligned_x_size; j<yuv420_width; j=j+4) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = ((yuv420_uv_height+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+ temp1 = i&0x1F;
+ temp2 = j&0x3F;
+ csc_deinterleave_memcpy(yuv420_u_dest+j/2+yuv420_width/2*(i), yuv420_v_dest+j/2+yuv420_width/2*(i), nv12t_uv_src+tiled_offset+temp2+64*(temp1), 4);
+ csc_deinterleave_memcpy(yuv420_u_dest+j/2+yuv420_width/2*(i+1), yuv420_v_dest+j/2+yuv420_width/2*(i+1), nv12t_uv_src+tiled_offset+temp2+64*(temp1+1), 4);
+ }
+ }
+ }
+}
+
+/*
+ * Converts linear data to tiled.
+ * 1. Y of YUV420P to Y of NV12T
+ * 2. Y of YUV420S to Y of NV12T
+ * 3. UV of YUV420S to UV of NV12T
+ *
+ * @param nv12t_dest
+ * Y or UV plane address of NV12T[out]
+ *
+ * @param yuv420_src
+ * Y or UV plane address of YUV420P(S)[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ */
+void csc_linear_to_tiled(char *nv12t_dest, char *yuv420_src, int yuv420_width, int yuv420_height)
+{
+ unsigned int i, j;
+ unsigned int tiled_x_index = 0, tiled_y_index = 0;
+ unsigned int aligned_x_size = 0, aligned_y_size = 0;
+ unsigned int tiled_offset = 0;
+ unsigned int temp1 = 0, temp2 = 0;
+
+ aligned_y_size = (yuv420_height>>5)<<5;
+ aligned_x_size = (yuv420_width>>6)<<6;
+
+ for (i=0; i<aligned_y_size; i=i+32) {
+ for (j=0; j<aligned_x_size; j=j+64) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = ((yuv420_height+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+
+ memcpy(nv12t_dest+tiled_offset, yuv420_src+j+yuv420_width*(i), 64);
+ memcpy(nv12t_dest+tiled_offset+64*1, yuv420_src+j+yuv420_width*(i+1), 64);
+ memcpy(nv12t_dest+tiled_offset+64*2, yuv420_src+j+yuv420_width*(i+2), 64);
+ memcpy(nv12t_dest+tiled_offset+64*3, yuv420_src+j+yuv420_width*(i+3), 64);
+ memcpy(nv12t_dest+tiled_offset+64*4, yuv420_src+j+yuv420_width*(i+4), 64);
+ memcpy(nv12t_dest+tiled_offset+64*5, yuv420_src+j+yuv420_width*(i+5), 64);
+ memcpy(nv12t_dest+tiled_offset+64*6, yuv420_src+j+yuv420_width*(i+6), 64);
+ memcpy(nv12t_dest+tiled_offset+64*7, yuv420_src+j+yuv420_width*(i+7), 64);
+ memcpy(nv12t_dest+tiled_offset+64*8, yuv420_src+j+yuv420_width*(i+8), 64);
+ memcpy(nv12t_dest+tiled_offset+64*9, yuv420_src+j+yuv420_width*(i+9), 64);
+ memcpy(nv12t_dest+tiled_offset+64*10, yuv420_src+j+yuv420_width*(i+10), 64);
+ memcpy(nv12t_dest+tiled_offset+64*11, yuv420_src+j+yuv420_width*(i+11), 64);
+ memcpy(nv12t_dest+tiled_offset+64*12, yuv420_src+j+yuv420_width*(i+12), 64);
+ memcpy(nv12t_dest+tiled_offset+64*13, yuv420_src+j+yuv420_width*(i+13), 64);
+ memcpy(nv12t_dest+tiled_offset+64*14, yuv420_src+j+yuv420_width*(i+14), 64);
+ memcpy(nv12t_dest+tiled_offset+64*15, yuv420_src+j+yuv420_width*(i+15), 64);
+ memcpy(nv12t_dest+tiled_offset+64*16, yuv420_src+j+yuv420_width*(i+16), 64);
+ memcpy(nv12t_dest+tiled_offset+64*17, yuv420_src+j+yuv420_width*(i+17), 64);
+ memcpy(nv12t_dest+tiled_offset+64*18, yuv420_src+j+yuv420_width*(i+18), 64);
+ memcpy(nv12t_dest+tiled_offset+64*19, yuv420_src+j+yuv420_width*(i+19), 64);
+ memcpy(nv12t_dest+tiled_offset+64*20, yuv420_src+j+yuv420_width*(i+20), 64);
+ memcpy(nv12t_dest+tiled_offset+64*21, yuv420_src+j+yuv420_width*(i+21), 64);
+ memcpy(nv12t_dest+tiled_offset+64*22, yuv420_src+j+yuv420_width*(i+22), 64);
+ memcpy(nv12t_dest+tiled_offset+64*23, yuv420_src+j+yuv420_width*(i+23), 64);
+ memcpy(nv12t_dest+tiled_offset+64*24, yuv420_src+j+yuv420_width*(i+24), 64);
+ memcpy(nv12t_dest+tiled_offset+64*25, yuv420_src+j+yuv420_width*(i+25), 64);
+ memcpy(nv12t_dest+tiled_offset+64*26, yuv420_src+j+yuv420_width*(i+26), 64);
+ memcpy(nv12t_dest+tiled_offset+64*27, yuv420_src+j+yuv420_width*(i+27), 64);
+ memcpy(nv12t_dest+tiled_offset+64*28, yuv420_src+j+yuv420_width*(i+28), 64);
+ memcpy(nv12t_dest+tiled_offset+64*29, yuv420_src+j+yuv420_width*(i+29), 64);
+ memcpy(nv12t_dest+tiled_offset+64*30, yuv420_src+j+yuv420_width*(i+30), 64);
+ memcpy(nv12t_dest+tiled_offset+64*31, yuv420_src+j+yuv420_width*(i+31), 64);
+ }
+ }
+
+ for (i=aligned_y_size; i<yuv420_height; i=i+4) {
+ for (j=0; j<aligned_x_size; j=j+64) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = ((yuv420_height+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+
+ temp1 = i&0x1F;
+ memcpy(nv12t_dest+tiled_offset+64*(temp1), yuv420_src+j+yuv420_width*(i), 64);
+ memcpy(nv12t_dest+tiled_offset+64*(temp1+1), yuv420_src+j+yuv420_width*(i+1), 64);
+ memcpy(nv12t_dest+tiled_offset+64*(temp1+2), yuv420_src+j+yuv420_width*(i+2), 64);
+ memcpy(nv12t_dest+tiled_offset+64*(temp1+3), yuv420_src+j+yuv420_width*(i+3), 64);
+ }
+ }
+
+ for (i=0; i<yuv420_height; i=i+4) {
+ for (j=aligned_x_size; j<yuv420_width; j=j+4) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = ((yuv420_height+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+
+ temp1 = i&0x1F;
+ temp2 = j&0x3F;
+ memcpy(nv12t_dest+tiled_offset+temp2+64*(temp1), yuv420_src+j+yuv420_width*(i), 4);
+ memcpy(nv12t_dest+tiled_offset+temp2+64*(temp1+1), yuv420_src+j+yuv420_width*(i+1), 4);
+ memcpy(nv12t_dest+tiled_offset+temp2+64*(temp1+2), yuv420_src+j+yuv420_width*(i+2), 4);
+ memcpy(nv12t_dest+tiled_offset+temp2+64*(temp1+3), yuv420_src+j+yuv420_width*(i+3), 4);
+ }
+ }
+}
+
+/*
+ * Converts and Interleaves linear to tiled
+ * 1. UV of YUV420P to UV of NV12T
+ *
+ * @param nv12t_uv_dest
+ * UV plane address of NV12T[out]
+ *
+ * @param yuv420p_u_src
+ * U plane address of YUV420P[in]
+ *
+ * @param yuv420p_v_src
+ * V plane address of YUV420P[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_uv_height
+ * Height/2 of YUV420[in]
+ */
+void csc_linear_to_tiled_interleave(char *nv12t_uv_dest, char *yuv420p_u_src, char *yuv420p_v_src, int yuv420_width, int yuv420_uv_height)
+{
+ unsigned int i, j;
+ unsigned int tiled_x_index = 0, tiled_y_index = 0;
+ unsigned int aligned_x_size = 0, aligned_y_size = 0;
+ unsigned int tiled_offset = 0;
+ unsigned int temp1 = 0, temp2 = 0;
+
+ aligned_y_size = (yuv420_uv_height>>5)<<5;
+ aligned_x_size = ((yuv420_width)>>6)<<6;
+
+ for (i=0; i<aligned_y_size; i=i+32) {
+ for (j=0; j<aligned_x_size; j=j+64) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = ((yuv420_uv_height+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset, yuv420p_u_src+j/2+yuv420_width/2*(i), yuv420p_v_src+j/2+yuv420_width/2*(i), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*1, yuv420p_u_src+j/2+yuv420_width/2*(i+1), yuv420p_v_src+j/2+yuv420_width/2*(i+1), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*2, yuv420p_u_src+j/2+yuv420_width/2*(i+2), yuv420p_v_src+j/2+yuv420_width/2*(i+2), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*3, yuv420p_u_src+j/2+yuv420_width/2*(i+3), yuv420p_v_src+j/2+yuv420_width/2*(i+3), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*4, yuv420p_u_src+j/2+yuv420_width/2*(i+4), yuv420p_v_src+j/2+yuv420_width/2*(i+4), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*5, yuv420p_u_src+j/2+yuv420_width/2*(i+5), yuv420p_v_src+j/2+yuv420_width/2*(i+5), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*6, yuv420p_u_src+j/2+yuv420_width/2*(i+6), yuv420p_v_src+j/2+yuv420_width/2*(i+6), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*7, yuv420p_u_src+j/2+yuv420_width/2*(i+7), yuv420p_v_src+j/2+yuv420_width/2*(i+7), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*8, yuv420p_u_src+j/2+yuv420_width/2*(i+8), yuv420p_v_src+j/2+yuv420_width/2*(i+8), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*9, yuv420p_u_src+j/2+yuv420_width/2*(i+9), yuv420p_v_src+j/2+yuv420_width/2*(i+9), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*10, yuv420p_u_src+j/2+yuv420_width/2*(i+10), yuv420p_v_src+j/2+yuv420_width/2*(i+10), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*11, yuv420p_u_src+j/2+yuv420_width/2*(i+11), yuv420p_v_src+j/2+yuv420_width/2*(i+11), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*12, yuv420p_u_src+j/2+yuv420_width/2*(i+12), yuv420p_v_src+j/2+yuv420_width/2*(i+12), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*13, yuv420p_u_src+j/2+yuv420_width/2*(i+13), yuv420p_v_src+j/2+yuv420_width/2*(i+13), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*14, yuv420p_u_src+j/2+yuv420_width/2*(i+14), yuv420p_v_src+j/2+yuv420_width/2*(i+14), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*15, yuv420p_u_src+j/2+yuv420_width/2*(i+15), yuv420p_v_src+j/2+yuv420_width/2*(i+15), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*16, yuv420p_u_src+j/2+yuv420_width/2*(i+16), yuv420p_v_src+j/2+yuv420_width/2*(i+16), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*17, yuv420p_u_src+j/2+yuv420_width/2*(i+17), yuv420p_v_src+j/2+yuv420_width/2*(i+17), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*18, yuv420p_u_src+j/2+yuv420_width/2*(i+18), yuv420p_v_src+j/2+yuv420_width/2*(i+18), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*19, yuv420p_u_src+j/2+yuv420_width/2*(i+19), yuv420p_v_src+j/2+yuv420_width/2*(i+19), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*20, yuv420p_u_src+j/2+yuv420_width/2*(i+20), yuv420p_v_src+j/2+yuv420_width/2*(i+20), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*21, yuv420p_u_src+j/2+yuv420_width/2*(i+21), yuv420p_v_src+j/2+yuv420_width/2*(i+21), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*22, yuv420p_u_src+j/2+yuv420_width/2*(i+22), yuv420p_v_src+j/2+yuv420_width/2*(i+22), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*23, yuv420p_u_src+j/2+yuv420_width/2*(i+23), yuv420p_v_src+j/2+yuv420_width/2*(i+23), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*24, yuv420p_u_src+j/2+yuv420_width/2*(i+24), yuv420p_v_src+j/2+yuv420_width/2*(i+24), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*25, yuv420p_u_src+j/2+yuv420_width/2*(i+25), yuv420p_v_src+j/2+yuv420_width/2*(i+25), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*26, yuv420p_u_src+j/2+yuv420_width/2*(i+26), yuv420p_v_src+j/2+yuv420_width/2*(i+26), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*27, yuv420p_u_src+j/2+yuv420_width/2*(i+27), yuv420p_v_src+j/2+yuv420_width/2*(i+27), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*28, yuv420p_u_src+j/2+yuv420_width/2*(i+28), yuv420p_v_src+j/2+yuv420_width/2*(i+28), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*29, yuv420p_u_src+j/2+yuv420_width/2*(i+29), yuv420p_v_src+j/2+yuv420_width/2*(i+29), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*30, yuv420p_u_src+j/2+yuv420_width/2*(i+30), yuv420p_v_src+j/2+yuv420_width/2*(i+30), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*31, yuv420p_u_src+j/2+yuv420_width/2*(i+31), yuv420p_v_src+j/2+yuv420_width/2*(i+31), 32);
+ }
+ }
+
+ for (i=aligned_y_size; i<yuv420_uv_height; i=i+4) {
+ for (j=0; j<aligned_x_size; j=j+64) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = ((yuv420_uv_height+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+ temp1 = i&0x1F;
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*(temp1), yuv420p_u_src+j/2+yuv420_width/2*(i), yuv420p_v_src+j/2+yuv420_width/2*(i), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*(temp1+1), yuv420p_u_src+j/2+yuv420_width/2*(i+1), yuv420p_v_src+j/2+yuv420_width/2*(i+1), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*(temp1+2), yuv420p_u_src+j/2+yuv420_width/2*(i+2), yuv420p_v_src+j/2+yuv420_width/2*(i+2), 32);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+64*(temp1+3), yuv420p_u_src+j/2+yuv420_width/2*(i+3), yuv420p_v_src+j/2+yuv420_width/2*(i+3), 32);
+ }
+ }
+
+ for (i=0; i<yuv420_uv_height; i=i+4) {
+ for (j=aligned_x_size; j<yuv420_width; j=j+4) {
+ tiled_offset = 0;
+ tiled_x_index = j>>6;
+ tiled_y_index = i>>5;
+ if (tiled_y_index & 0x1) {
+ /* odd fomula: 2+x+(x>>2)<<2+x_block_num*(y-1) */
+ tiled_offset = tiled_y_index-1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset+2;
+ temp1 = (tiled_x_index>>2)<<2;
+ tiled_offset = tiled_offset+temp1;
+ tiled_offset = tiled_offset<<11;
+ } else {
+ temp2 = ((yuv420_uv_height+31)>>5)<<5;
+ if ((i+32)<temp2) {
+ /* even1 fomula: x+((x+2)>>2)<<2+x_block_num*y */
+ temp1 = tiled_x_index+2;
+ temp1 = (temp1>>2)<<2;
+ tiled_offset = tiled_x_index+temp1;
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_offset+tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset<<11;
+ } else {
+ /* even2 fomula: x+x_block_num*y */
+ temp1 = ((yuv420_width+127)>>7)<<7;
+ tiled_offset = tiled_y_index*(temp1>>6);
+ tiled_offset = tiled_offset+tiled_x_index;
+ tiled_offset = tiled_offset<<11;
+ }
+ }
+ temp1 = i&0x1F;
+ temp2 = j&0x3F;
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+temp2+64*(temp1), yuv420p_u_src+j/2+yuv420_width/2*(i), yuv420p_v_src+j/2+yuv420_width/2*(i), 2);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+temp2+64*(temp1+1), yuv420p_u_src+j/2+yuv420_width/2*(i+1), yuv420p_v_src+j/2+yuv420_width/2*(i+1), 2);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+temp2+64*(temp1+2), yuv420p_u_src+j/2+yuv420_width/2*(i+2), yuv420p_v_src+j/2+yuv420_width/2*(i+2), 2);
+ csc_interleave_memcpy(nv12t_uv_dest+tiled_offset+temp2+64*(temp1+3), yuv420p_u_src+j/2+yuv420_width/2*(i+3), yuv420p_v_src+j/2+yuv420_width/2*(i+3), 2);
+ }
+ }
+}
+
diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_deinterleave_memcpy.s b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_deinterleave_memcpy.s
new file mode 100644
index 0000000..5b55080
--- /dev/null
+++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_deinterleave_memcpy.s
@@ -0,0 +1,128 @@
+/*
+ *
+ * Copyright 2011 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 csc_deinterleave_memcpy.s
+ * @brief SEC_OMX specific define
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2011.7.01 : Create
+ */
+ .arch armv7-a
+ .text
+ .global csc_deinterleave_memcpy
+ .type csc_deinterleave_memcpy, %function
+csc_deinterleave_memcpy:
+ .fnstart
+
+ @r0 dest1
+ @r1 dest2
+ @r2 src
+ @r3 src_size
+ @r4 i
+ @r5 temp1
+ @r6 temp2
+ @r7 temp3
+
+ stmfd sp!, {r4-r12,r14} @ backup registers
+
+ mov r4, #0
+ cmp r3, #256
+ blt LINEAR_SIZE_128
+
+ bic r5, r3, #0xFF
+LINEAR_SIZE_256_LOOP:
+ pld [r2, #64]
+ vld2.8 {q0, q1}, [r2]!
+ pld [r2, #64]
+ vld2.8 {q2, q3}, [r2]!
+ pld [r2, #64]
+ vld2.8 {q4, q5}, [r2]!
+ pld [r2, #64]
+ vld2.8 {q6, q7}, [r2]!
+ pld [r2, #64]
+ vld2.8 {q8, q9}, [r2]!
+ pld [r2, #64]
+ vld2.8 {q10, q11}, [r2]!
+ vld2.8 {q12, q13}, [r2]!
+ vld2.8 {q14, q15}, [r2]!
+
+ vst1.8 {q0}, [r0]!
+ vst1.8 {q2}, [r0]!
+ vst1.8 {q4}, [r0]!
+ vst1.8 {q6}, [r0]!
+ vst1.8 {q8}, [r0]!
+ vst1.8 {q10}, [r0]!
+ vst1.8 {q12}, [r0]!
+ vst1.8 {q14}, [r0]!
+
+ vst1.8 {q1}, [r1]!
+ vst1.8 {q3}, [r1]!
+ vst1.8 {q5}, [r1]!
+ vst1.8 {q7}, [r1]!
+ vst1.8 {q9}, [r1]!
+ vst1.8 {q11}, [r1]!
+ vst1.8 {q13}, [r1]!
+ vst1.8 {q15}, [r1]!
+
+ add r4, #256
+ cmp r4, r5
+ blt LINEAR_SIZE_256_LOOP
+
+LINEAR_SIZE_128:
+ sub r5, r3, r4
+ cmp r5, #64
+ blt LINEAR_SIZE_4
+ pld [r2, #64]
+ vld2.8 {q0, q1}, [r2]!
+ pld [r2, #64]
+ vld2.8 {q2, q3}, [r2]!
+ vld2.8 {q4, q5}, [r2]!
+ vld2.8 {q6, q7}, [r2]!
+
+ vst1.8 {q0}, [r0]!
+ vst1.8 {q4}, [r0]!
+ vst1.8 {q2}, [r0]!
+ vst1.8 {q6}, [r0]!
+
+ vst1.8 {q1}, [r1]!
+ vst1.8 {q3}, [r1]!
+ vst1.8 {q5}, [r1]!
+ vst1.8 {q7}, [r1]!
+
+ add r4, #128
+
+LINEAR_SIZE_4:
+ ldrb r6, [r2], #1
+ ldrb r7, [r2], #1
+ ldrb r8, [r2], #1
+ ldrb r9, [r2], #1
+
+ strb r6, [r0], #1
+ strb r8, [r0], #1
+ strb r7, [r1], #1
+ strb r9, [r1], #1
+
+ add r4, #4
+ cmp r4, r3
+ blt LINEAR_SIZE_4
+
+RESTORE_REG:
+ ldmfd sp!, {r4-r12,r15} @ restore registers
+ .fnend
+
diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_interleave_memcpy.s b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_interleave_memcpy.s
new file mode 100644
index 0000000..54f4436
--- /dev/null
+++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_interleave_memcpy.s
@@ -0,0 +1,133 @@
+/*
+ *
+ * Copyright 2011 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 csc_interleave_memcpy.s
+ * @brief SEC_OMX specific define
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2011.7.01 : Create
+ */
+ .arch armv7-a
+ .text
+ .global csc_interleave_memcpy
+ .type csc_interleave_memcpy, %function
+csc_interleave_memcpy:
+ .fnstart
+
+ @r0 dest
+ @r1 src1
+ @r2 src2
+ @r3 src_size
+ @r4 i
+ @r5 temp1
+ @r6 temp2
+ @r7 temp3
+ @r8 temp2
+ @r9 temp3
+
+ stmfd sp!, {r4-r12,r14} @ backup registers
+
+ mov r4, #0
+ cmp r3, #128
+ blt LINEAR_SIZE_64
+
+ bic r5, r3, #0x2F
+LINEAR_SIZE_128_LOOP:
+ pld [r1, #64]
+ vld1.8 {q0}, [r1]!
+ vld1.8 {q2}, [r1]!
+ vld1.8 {q4}, [r1]!
+ vld1.8 {q6}, [r1]!
+ pld [r2]
+ vld1.8 {q8}, [r1]!
+ vld1.8 {q10}, [r1]!
+ vld1.8 {q12}, [r1]!
+ vld1.8 {q14}, [r1]!
+ pld [r2, #64]
+ vld1.8 {q1}, [r2]!
+ vld1.8 {q3}, [r2]!
+ vld1.8 {q5}, [r2]!
+ vld1.8 {q7}, [r2]!
+ vld1.8 {q9}, [r2]!
+ vld1.8 {q11}, [r2]!
+ vld1.8 {q13}, [r2]!
+ vld1.8 {q15}, [r2]!
+
+ vst2.8 {q0, q1}, [r0]!
+ vst2.8 {q2, q3}, [r0]!
+ vst2.8 {q4, q5}, [r0]!
+ vst2.8 {q6, q7}, [r0]!
+ vst2.8 {q8, q9}, [r0]!
+ vst2.8 {q10, q11}, [r0]!
+ pld [r1]
+ vst2.8 {q12, q13}, [r0]!
+ vst2.8 {q14, q15}, [r0]!
+
+ add r4, #128
+ cmp r4, r5
+ blt LINEAR_SIZE_128_LOOP
+
+LINEAR_SIZE_64:
+ sub r5, r3, r4
+ cmp r5, #64
+ blt LINEAR_SIZE_2
+LINEAR_SIZE_64_LOOP:
+ pld [r2]
+ vld1.8 {q0}, [r1]!
+ vld1.8 {q2}, [r1]!
+ vld1.8 {q4}, [r1]!
+ vld1.8 {q6}, [r1]!
+ vld1.8 {q1}, [r2]!
+ vld1.8 {q3}, [r2]!
+ vld1.8 {q5}, [r2]!
+ vld1.8 {q7}, [r2]!
+
+ vst2.8 {q0, q1}, [r0]!
+ vst2.8 {q2, q3}, [r0]!
+ pld [r1]
+ vst2.8 {q4, q5}, [r0]!
+ vst2.8 {q6, q7}, [r0]!
+
+ add r4, #64
+ cmp r4, r3
+ blt LINEAR_SIZE_64_LOOP
+
+LINEAR_SIZE_2:
+ sub r5, r3, r4
+ cmp r5, #2
+ blt RESTORE_REG
+LINEAR_SIZE_2_LOOP:
+ ldrb r6, [r1], #1
+ ldrb r7, [r2], #1
+ ldrb r8, [r1], #1
+ ldrb r9, [r2], #1
+
+ strb r6, [r0], #1
+ strb r7, [r0], #1
+ strb r8, [r0], #1
+ strb r9, [r0], #1
+
+ add r4, #2
+ cmp r4, r3
+ blt LINEAR_SIZE_2_LOOP
+
+RESTORE_REG:
+ ldmfd sp!, {r4-r12,r15} @ restore registers
+ .fnend
+
diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_nv12t_yuv420_uv_neon.s b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_nv12t_yuv420_uv_neon.s
new file mode 100644
index 0000000..08e359c
--- /dev/null
+++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_nv12t_yuv420_uv_neon.s
@@ -0,0 +1,768 @@
+/*
+ *
+ * Copyright 2011 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 csc_nv12t_yuv420_uv_neon.s
+ * @brief SEC_OMX specific define
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2011.7.01 : Create
+ */
+
+/*
+ * Converts and Deinterleaves tiled data to linear
+ * 1. UV of NV12T to UV of YUV420P
+ *
+ * @param yuv420_u_dest
+ * U plane address of YUV420P[out]
+ *
+ * @param yuv420_v_dest
+ * V plane address of YUV420P[out]
+ *
+ * @param nv12t_src
+ * UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_uv_height
+ * Height/2 of YUV420[in]
+ */
+
+ .arch armv7-a
+ .text
+ .global csc_tiled_to_linear_deinterleave
+ .type csc_tiled_to_linear_deinterleave, %function
+csc_tiled_to_linear_deinterleave:
+ .fnstart
+
+ @r0 linear_u_dest
+ @r1 linear_v_dest
+ @r2 tiled_uv_src
+ @r3 linear_x_size
+ @r4 linear_y_size
+ @r5 j
+ @r6 i
+ @r7 tiled_addr
+ @r8 linear_addr
+ @r9 aligned_x_size
+ @r10 temp1
+ @r11 temp2
+ @r12 temp3
+ @r14 temp4
+
+ stmfd sp!, {r4-r12,r14} @ backup registers
+
+ ldr r4, [sp, #40] @ load linear_y_size to r4
+
+ mov r9, #0
+
+LINEAR_X_SIZE_1024:
+ cmp r3, #1024
+ blt LINEAR_X_SIZE_512
+
+ mov r6, #0
+LINEAR_X_SIZE_1024_LOOP:
+ mov r7, #0 @ tiled_offset = 0@
+ mov r5, r6, asr #5 @ tiled_y_index = i>>5@
+ and r10, r5, #0x1
+ cmp r10, #0x1
+ bne LINEAR_X_SIZE_1024_LOOP_EVEN
+LINEAR_X_SIZE_1024_LOOP_ODD:
+ sub r7, r5, #1 @ tiled_offset = tiled_y_index-1@
+ add r10, r3, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_offset*(temp1>>6)@
+ mul r7, r7, r10
+ mov r5, #8
+ mov r5, r5, lsl #11
+ sub r5, r5, #32
+ add r7, r7, #2 @ tiled_offset = tiled_offset+2@
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11@
+ add r11, r7, #2048
+ add r12, r7, #4096
+ add r14, r7, #6144
+ b LINEAR_X_SIZE_1024_LOOP_MEMCPY
+
+LINEAR_X_SIZE_1024_LOOP_EVEN:
+ add r11, r4, #31 @ temp2 = ((linear_y_size+31)>>5)<<5@
+ bic r11, r11, #0x1F
+ add r10, r3, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_y_index*(temp1>>6)@
+ mul r7, r5, r10
+ add r12, r6, #32
+ cmp r12, r11
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11@
+ add r11, r7, #2048
+ movlt r5, #8
+ addlt r12, r7, #12288
+ addlt r14, r7, #14336
+ movge r5, #4
+ addge r12, r7, #2048
+ addge r14, r7, #2048
+ mov r5, r5, lsl #11
+ sub r5, r5, #32
+
+LINEAR_X_SIZE_1024_LOOP_MEMCPY:
+ and r10, r6, #0x1F
+ mov r10, r10, lsl #6
+ add r10, r2, r10
+
+ add r7, r7, r10 @ tiled_addr = tiled_src+64*(temp1)
+ add r11, r11, r10 @ tiled_addr1 = tiled_src+64*(temp1)
+ pld [r11]
+ vld2.8 {q0, q1}, [r7]!
+ pld [r11, #32]
+ add r12, r12, r10 @ tiled_addr2 = tiled_src+64*(temp1)
+ vld2.8 {q2, q3}, [r7], r5
+ pld [r12]
+ vld2.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ add r14, r14, r10 @ tiled_addr3 = tiled_src+64*(temp1)
+ vld2.8 {q6, q7}, [r11], r5
+ pld [r14]
+ vld2.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ mov r10, r3, asr #1
+ vld2.8 {q10, q11}, [r12], r5
+ mul r10, r10, r6
+ vld2.8 {q12, q13}, [r14]!
+ vld2.8 {q14, q15}, [r14], r5
+
+ add r8, r0, r10
+ vst1.8 {q0}, [r8]!
+ vst1.8 {q2}, [r8]!
+ vst1.8 {q4}, [r8]!
+ vst1.8 {q6}, [r8]!
+ vst1.8 {q8}, [r8]!
+ vst1.8 {q10}, [r8]!
+ vst1.8 {q12}, [r8]!
+ vst1.8 {q14}, [r8]!
+
+ add r10, r1, r10
+ vst1.8 {q1}, [r10]!
+ vst1.8 {q3}, [r10]!
+ vst1.8 {q5}, [r10]!
+ vst1.8 {q7}, [r10]!
+ vst1.8 {q9}, [r10]!
+ vst1.8 {q11}, [r10]!
+ pld [r7]
+ vst1.8 {q13}, [r10]!
+ pld [r7, #32]
+ vst1.8 {q15}, [r10]!
+
+ pld [r11]
+ vld2.8 {q0, q1}, [r7]!
+ pld [r11, #32]
+ vld2.8 {q2, q3}, [r7], r5
+ pld [r12]
+ vld2.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ vld2.8 {q6, q7}, [r11], r5
+ pld [r14]
+ vld2.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ vld2.8 {q10, q11}, [r12], r5
+ vld2.8 {q12, q13}, [r14]!
+ vld2.8 {q14, q15}, [r14], r5
+
+ vst1.8 {q0}, [r8]!
+ vst1.8 {q2}, [r8]!
+ vst1.8 {q4}, [r8]!
+ vst1.8 {q6}, [r8]!
+ vst1.8 {q8}, [r8]!
+ vst1.8 {q10}, [r8]!
+ vst1.8 {q12}, [r8]!
+ vst1.8 {q14}, [r8]!
+
+ vst1.8 {q1}, [r10]!
+ vst1.8 {q3}, [r10]!
+ vst1.8 {q5}, [r10]!
+ vst1.8 {q7}, [r10]!
+ vst1.8 {q9}, [r10]!
+ vst1.8 {q11}, [r10]!
+ pld [r7]
+ vst1.8 {q13}, [r10]!
+ pld [r7, #32]
+ vst1.8 {q15}, [r10]!
+
+ pld [r11]
+ vld2.8 {q0, q1}, [r7]!
+ pld [r11, #32]
+ vld2.8 {q2, q3}, [r7], r5
+ pld [r12]
+ vld2.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ vld2.8 {q6, q7}, [r11], r5
+ pld [r14]
+ vld2.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ vld2.8 {q10, q11}, [r12], r5
+ vld2.8 {q12, q13}, [r14]!
+ vld2.8 {q14, q15}, [r14], r5
+
+ vst1.8 {q0}, [r8]!
+ vst1.8 {q2}, [r8]!
+ vst1.8 {q4}, [r8]!
+ vst1.8 {q6}, [r8]!
+ vst1.8 {q8}, [r8]!
+ vst1.8 {q10}, [r8]!
+ vst1.8 {q12}, [r8]!
+ vst1.8 {q14}, [r8]!
+
+ vst1.8 {q1}, [r10]!
+ vst1.8 {q3}, [r10]!
+ vst1.8 {q5}, [r10]!
+ vst1.8 {q7}, [r10]!
+ vst1.8 {q9}, [r10]!
+ vst1.8 {q11}, [r10]!
+ pld [r7]
+ vst1.8 {q13}, [r10]!
+ pld [r7, #32]
+ vst1.8 {q15}, [r10]!
+
+ pld [r11]
+ vld2.8 {q0, q1}, [r7]!
+ pld [r11, #32]
+ vld2.8 {q2, q3}, [r7]
+ pld [r12]
+ vld2.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ vld2.8 {q6, q7}, [r11]
+ pld [r14]
+ vld2.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ vld2.8 {q10, q11}, [r12]
+ vld2.8 {q12, q13}, [r14]!
+ vld2.8 {q14, q15}, [r14]
+
+ vst1.8 {q0}, [r8]!
+ vst1.8 {q2}, [r8]!
+ vst1.8 {q4}, [r8]!
+ vst1.8 {q6}, [r8]!
+ vst1.8 {q8}, [r8]!
+ vst1.8 {q10}, [r8]!
+ vst1.8 {q12}, [r8]!
+ vst1.8 {q14}, [r8]!
+
+ vst1.8 {q1}, [r10]!
+ vst1.8 {q3}, [r10]!
+ vst1.8 {q5}, [r10]!
+ vst1.8 {q7}, [r10]!
+ vst1.8 {q9}, [r10]!
+ vst1.8 {q11}, [r10]!
+ add r6, #1
+ vst1.8 {q13}, [r10]!
+ cmp r6, r4
+ vst1.8 {q15}, [r10]!
+
+ blt LINEAR_X_SIZE_1024_LOOP
+
+ mov r9, #1024
+
+LINEAR_X_SIZE_512:
+ sub r10, r3, r9
+ cmp r10, #512
+ blt LINEAR_X_SIZE_256
+
+ mov r6, #0
+LINEAR_X_SIZE_512_LOOP:
+ mov r7, #0 @ tiled_offset = 0@
+ mov r5, r6, asr #5 @ tiled_y_index = i>>5@
+ and r10, r5, #0x1
+ cmp r10, #0x1
+ bne LINEAR_X_SIZE_512_LOOP_EVEN
+LINEAR_X_SIZE_512_LOOP_ODD:
+ sub r7, r5, #1 @ tiled_offset = tiled_y_index-1@
+ add r10, r3, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_offset*(temp1>>6)@
+ mul r7, r7, r10
+ mov r5, #8
+ mov r5, r5, lsl #11
+ add r7, r7, #2 @ tiled_offset = tiled_offset+2@
+ mov r10, r9, asr #5
+ add r7, r7, r10
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11@
+ add r11, r7, #2048
+ add r12, r7, #4096
+ add r14, r7, #6144
+ sub r5, r5, #32
+ b LINEAR_X_SIZE_512_LOOP_MEMCPY
+
+LINEAR_X_SIZE_512_LOOP_EVEN:
+ add r11, r4, #31 @ temp2 = ((linear_y_size+31)>>5)<<5@
+ bic r11, r11, #0x1F
+ add r10, r3, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_y_index*(temp1>>6)@
+ mul r7, r5, r10
+ add r12, r6, #32
+ cmp r12, r11
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11@
+ movlt r5, #8
+ movlt r10, r9, asr #5
+ movge r10, r9, asr #6
+ add r7, r7, r10, lsl #11
+ add r11, r7, #2048
+ addlt r12, r7, #12288
+ addlt r14, r7, #14336
+ movge r5, #4
+ addge r12, r7, #4096
+ addge r14, r7, #6144
+ mov r5, r5, lsl #11
+ sub r5, r5, #32
+
+LINEAR_X_SIZE_512_LOOP_MEMCPY:
+ and r10, r6, #0x1F
+ mov r10, r10, lsl #6
+ add r10, r2, r10
+
+ add r7, r7, r10 @ tiled_addr = tiled_src+64*(temp1)
+ add r11, r11, r10 @ tiled_addr1 = tiled_src+64*(temp1)
+ pld [r11]
+ vld2.8 {q0, q1}, [r7]!
+ pld [r11, #32]
+ add r12, r12, r10 @ tiled_addr2 = tiled_src+64*(temp1)
+ vld2.8 {q2, q3}, [r7], r5
+ pld [r12]
+ vld2.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ add r14, r14, r10 @ tiled_addr3 = tiled_src+64*(temp1)
+ vld2.8 {q6, q7}, [r11], r5
+ pld [r14]
+ mov r10, r3, asr #1
+ vld2.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ mul r10, r10, r6
+ vld2.8 {q10, q11}, [r12], r5
+ add r8, r0, r10
+ vld2.8 {q12, q13}, [r14]!
+ add r8, r8, r9, asr #1
+ vld2.8 {q14, q15}, [r14], r5
+
+ vst1.8 {q0}, [r8]!
+ vst1.8 {q2}, [r8]!
+ vst1.8 {q4}, [r8]!
+ vst1.8 {q6}, [r8]!
+ vst1.8 {q8}, [r8]!
+ vst1.8 {q10}, [r8]!
+ vst1.8 {q12}, [r8]!
+ add r10, r1, r10
+ vst1.8 {q14}, [r8]!
+
+ add r10, r10, r9, asr #1
+ vst1.8 {q1}, [r10]!
+ vst1.8 {q3}, [r10]!
+ vst1.8 {q5}, [r10]!
+ vst1.8 {q7}, [r10]!
+ vst1.8 {q9}, [r10]!
+ vst1.8 {q11}, [r10]!
+ pld [r7]
+ vst1.8 {q13}, [r10]!
+ pld [r7, #32]
+ vst1.8 {q15}, [r10]!
+
+ pld [r11]
+ vld2.8 {q0, q1}, [r7]!
+ pld [r11, #32]
+ vld2.8 {q2, q3}, [r7]
+ pld [r12]
+ vld2.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ vld2.8 {q6, q7}, [r11]
+ pld [r14]
+ vld2.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ vld2.8 {q10, q11}, [r12]
+ vld2.8 {q12, q13}, [r14]!
+ vld2.8 {q14, q15}, [r14]
+
+ vst1.8 {q0}, [r8]!
+ vst1.8 {q2}, [r8]!
+ vst1.8 {q4}, [r8]!
+ vst1.8 {q6}, [r8]!
+ vst1.8 {q8}, [r8]!
+ vst1.8 {q10}, [r8]!
+ vst1.8 {q12}, [r8]!
+ vst1.8 {q14}, [r8]!
+
+ vst1.8 {q1}, [r10]!
+ vst1.8 {q3}, [r10]!
+ vst1.8 {q5}, [r10]!
+ vst1.8 {q7}, [r10]!
+ vst1.8 {q9}, [r10]!
+ vst1.8 {q11}, [r10]!
+ add r6, #1
+ vst1.8 {q13}, [r10]!
+ cmp r6, r4
+ vst1.8 {q15}, [r10]!
+
+ blt LINEAR_X_SIZE_512_LOOP
+
+ add r9, r9, #512
+
+LINEAR_X_SIZE_256:
+ sub r10, r3, r9
+ cmp r10, #256
+ blt LINEAR_X_SIZE_128
+
+ mov r6, #0
+LINEAR_X_SIZE_256_LOOP:
+ mov r7, #0 @ tiled_offset = 0@
+ mov r5, r6, asr #5 @ tiled_y_index = i>>5@
+ and r10, r5, #0x1
+ cmp r10, #0x1
+ bne LINEAR_X_SIZE_256_LOOP_EVEN
+LINEAR_X_SIZE_256_LOOP_ODD:
+ sub r7, r5, #1 @ tiled_offset = tiled_y_index-1@
+ add r10, r3, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_offset*(temp1>>6)@
+ mul r7, r7, r10
+ add r7, r7, #2 @ tiled_offset = tiled_offset+2@
+ mov r10, r9, asr #5
+ add r7, r7, r10
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11@
+ add r11, r7, #2048
+ add r12, r7, #4096
+ add r14, r7, #6144
+ b LINEAR_X_SIZE_256_LOOP_MEMCPY
+
+LINEAR_X_SIZE_256_LOOP_EVEN:
+ add r11, r4, #31 @ temp2 = ((linear_y_size+31)>>5)<<5@
+ bic r11, r11, #0x1F
+ add r10, r3, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_y_index*(temp1>>6)@
+ mul r7, r5, r10
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11@
+ add r12, r6, #32
+ cmp r12, r11
+ movlt r10, r9, asr #5
+ addlt r7, r7, r10, lsl #11
+ addlt r11, r7, #2048
+ addlt r12, r7, #12288
+ addlt r14, r7, #14336
+ movge r10, r9, asr #6
+ addge r7, r7, r10, lsl #11
+ addge r11, r7, #2048
+ addge r12, r7, #4096
+ addge r14, r7, #6144
+
+LINEAR_X_SIZE_256_LOOP_MEMCPY:
+ and r10, r6, #0x1F
+ mov r10, r10, lsl #6
+ add r10, r2, r10
+
+ add r7, r7, r10 @ tiled_addr = tiled_src+64*(temp1)
+ add r11, r11, r10 @ tiled_addr1 = tiled_src+64*(temp1)
+ pld [r11]
+ vld2.8 {q0, q1}, [r7]!
+ pld [r11, #32]
+ add r12, r12, r10 @ tiled_addr2 = tiled_src+64*(temp1)
+ vld2.8 {q2, q3}, [r7]
+ pld [r12]
+ vld2.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ add r14, r14, r10 @ tiled_addr3 = tiled_src+64*(temp1)
+ vld2.8 {q6, q7}, [r11]
+ pld [r14]
+ vld2.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ mov r10, r3, asr #1
+ vld2.8 {q10, q11}, [r12]
+ mul r10, r10, r6
+ vld2.8 {q12, q13}, [r14]!
+ add r8, r0, r10
+ vld2.8 {q14, q15}, [r14]
+
+ add r8, r8, r9, asr #1
+ vst1.8 {q0}, [r8]!
+ vst1.8 {q2}, [r8]!
+ vst1.8 {q4}, [r8]!
+ vst1.8 {q6}, [r8]!
+ vst1.8 {q8}, [r8]!
+ vst1.8 {q10}, [r8]!
+ vst1.8 {q12}, [r8]!
+ add r10, r1, r10
+ vst1.8 {q14}, [r8]!
+
+ add r10, r10, r9, asr #1
+ vst1.8 {q1}, [r10]!
+ vst1.8 {q3}, [r10]!
+ vst1.8 {q5}, [r10]!
+ vst1.8 {q7}, [r10]!
+ vst1.8 {q9}, [r10]!
+ vst1.8 {q11}, [r10]!
+ add r6, #1
+ vst1.8 {q13}, [r10]!
+ cmp r6, r4
+ vst1.8 {q15}, [r10]!
+ blt LINEAR_X_SIZE_256_LOOP
+
+ add r9, r9, #256
+
+LINEAR_X_SIZE_128:
+ sub r10, r3, r9
+ cmp r10, #128
+ blt LINEAR_X_SIZE_64
+
+ mov r6, #0
+LINEAR_X_SIZE_128_LOOP:
+ mov r7, #0 @ tiled_offset = 0@
+ mov r5, r6, asr #5 @ tiled_y_index = i>>5@
+ and r10, r5, #0x1
+ cmp r10, #0x1
+ bne LINEAR_X_SIZE_128_LOOP_EVEN
+LINEAR_X_SIZE_128_LOOP_ODD:
+ sub r7, r5, #1 @ tiled_offset = tiled_y_index-1@
+ add r10, r3, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_offset*(temp1>>6)@
+ mul r7, r7, r10
+ add r7, r7, #2 @ tiled_offset = tiled_offset+2@
+ mov r10, r9, asr #5
+ add r7, r7, r10
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11@
+ add r11, r7, #2048
+ b LINEAR_X_SIZE_128_LOOP_MEMCPY
+
+LINEAR_X_SIZE_128_LOOP_EVEN:
+ add r11, r4, #31 @ temp2 = ((linear_y_size+31)>>5)<<5@
+ bic r11, r11, #0x1F
+ add r10, r3, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_y_index*(temp1>>6)@
+ mul r7, r5, r10
+ mov r7, r7, lsl #11 @ tiled_offset = tiled_offset<<11@
+ add r12, r6, #32
+ cmp r12, r11
+ movlt r10, r9, asr #5
+ movge r10, r9, asr #6
+ add r7, r7, r10, lsl #11
+ add r11, r7, #2048
+
+LINEAR_X_SIZE_128_LOOP_MEMCPY:
+ and r10, r6, #0x1F
+ mov r10, r10, lsl #6
+ add r10, r2, r10
+
+ add r7, r7, r10 @ tiled_addr = tiled_src+64*(temp1)
+ add r11, r11, r10 @ tiled_addr1 = tiled_src+64*(temp1)
+ pld [r11]
+ vld2.8 {q0, q1}, [r7]!
+ pld [r11, #32]
+ vld2.8 {q2, q3}, [r7]!
+ pld [r7]
+ vld2.8 {q4, q5}, [r11]!
+ mov r10, r3, asr #1
+ pld [r7, #32]
+ vld2.8 {q6, q7}, [r11]!
+ mul r10, r10, r6
+ pld [r11]
+ vld2.8 {q8, q9}, [r7]!
+ add r10, r10, r9, asr #1
+ pld [r11, #32]
+ vld2.8 {q10, q11}, [r7]!
+ add r8, r0, r10
+ vld2.8 {q12, q13}, [r11]!
+ mov r14, r3, asr #1
+ vld2.8 {q14, q15}, [r11]!
+
+ sub r14, r14, #48
+ vst1.8 {q0}, [r8]!
+ vst1.8 {q2}, [r8]!
+ vst1.8 {q4}, [r8]!
+ vst1.8 {q6}, [r8], r14
+ vst1.8 {q8}, [r8]!
+ vst1.8 {q10}, [r8]!
+ vst1.8 {q12}, [r8]!
+ vst1.8 {q14}, [r8]!
+
+ add r10, r1, r10
+ vst1.8 {q1}, [r10]!
+ vst1.8 {q3}, [r10]!
+ vst1.8 {q5}, [r10]!
+ vst1.8 {q7}, [r10], r14
+ vst1.8 {q9}, [r10]!
+ vst1.8 {q11}, [r10]!
+ add r6, #2
+ vst1.8 {q13}, [r10]!
+ cmp r6, r4
+ vst1.8 {q15}, [r10]!
+
+ blt LINEAR_X_SIZE_128_LOOP
+
+ add r9, r9, #128
+
+LINEAR_X_SIZE_64:
+ sub r10, r3, r9
+ cmp r10, #64
+ blt LINEAR_X_SIZE_4
+
+ mov r5, r9
+ mov r6, #0
+
+LINEAR_X_SIZE_64_LOOP:
+ bl GET_TILED_OFFSET
+
+LINEAR_X_SIZE_64_LOOP_MEMCPY:
+ and r10, r6, #0x1F
+ mov r14, r3, asr #1
+ mov r10, r10, lsl #6
+ sub r14, r14, #16
+ add r10, r2, r10
+
+ add r7, r7, r10 @ tiled_addr = tiled_src+64*(temp1)
+ pld [r7, #64]
+ vld2.8 {q0, q1}, [r7]!
+ mov r10, r3, asr #1
+ pld [r7, #64]
+ vld2.8 {q2, q3}, [r7]!
+ mul r10, r10, r6
+ vld2.8 {q4, q5}, [r7]!
+ add r10, r10, r9, asr #1
+ vld2.8 {q6, q7}, [r7]!
+ add r8, r0, r10
+
+ vst1.8 {q0}, [r8]!
+ vst1.8 {q2}, [r8], r14
+ vst1.8 {q4}, [r8]!
+ vst1.8 {q6}, [r8], r14
+
+ add r10, r1, r10
+ vst1.8 {q1}, [r10]!
+ vst1.8 {q3}, [r10], r14
+ add r6, #2
+ vst1.8 {q5}, [r10]!
+ cmp r6, r4
+ vst1.8 {q7}, [r10], r14
+
+ blt LINEAR_X_SIZE_64_LOOP
+
+ add r9, r9, #64
+
+LINEAR_X_SIZE_4:
+ cmp r9, r3
+ beq RESTORE_REG
+
+ mov r6, #0 @ i = 0
+LINEAR_Y_SIZE_4_LOOP:
+
+ mov r5, r9 @ j = aligned_x_size
+LINEAR_X_SIZE_4_LOOP:
+
+ bl GET_TILED_OFFSET
+
+ mov r11, r3, asr #1 @ temp1 = linear_x_size/2
+ mul r11, r11, r6 @ temp1 = temp1*(i)
+ add r11, r11, r5, asr #1 @ temp1 = temp1+j/2
+ mov r12, r3, asr #1 @ temp2 = linear_x_size/2
+ sub r12, r12, #1 @ temp2 = linear_x_size-1
+
+ add r8, r0, r11 @ linear_addr = linear_dest_u+temp1
+ add r11, r1, r11 @ temp1 = linear_dest_v+temp1
+ add r7, r2, r7 @ tiled_addr = tiled_src+tiled_addr
+ and r14, r6, #0x1F @ temp3 = i&0x1F@
+ mov r14, r14, lsl #6 @ temp3 = temp3*64
+ add r7, r7, r14 @ tiled_addr = tiled_addr+temp3
+ and r14, r5, #0x3F @ temp3 = j&0x3F
+ add r7, r7, r14 @ tiled_addr = tiled_addr+temp3
+
+ ldrh r10, [r7], #2
+ ldrh r14, [r7], #62
+ strb r10, [r8], #1
+ mov r10, r10, asr #8
+ strb r10, [r11], #1
+ strb r14, [r8], r12
+ mov r14, r14, asr #8
+ strb r14, [r11], r12
+
+ ldrh r10, [r7], #2
+ ldrh r14, [r7], #62
+ strb r10, [r8], #1
+ mov r10, r10, asr #8
+ strb r10, [r11], #1
+ strb r14, [r8], r12
+ mov r14, r14, asr #8
+ strb r14, [r11], r12
+
+ add r5, r5, #4 @ j = j+4
+ cmp r5, r3 @ j<linear_x_size
+ blt LINEAR_X_SIZE_4_LOOP
+
+ add r6, r6, #2 @ i = i+4
+ cmp r6, r4 @ i<linear_y_size
+ blt LINEAR_Y_SIZE_4_LOOP
+
+RESTORE_REG:
+ ldmfd sp!, {r4-r12,r15} @ restore registers
+
+GET_TILED_OFFSET:
+ stmfd sp!, {r14}
+
+ mov r12, r6, asr #5 @ temp2 = i>>5
+ mov r11, r5, asr #6 @ temp1 = j>>6
+
+ and r14, r12, #0x1 @ if (temp2 & 0x1)
+ cmp r14, #0x1
+ bne GET_TILED_OFFSET_EVEN_FORMULA_1
+
+GET_TILED_OFFSET_ODD_FORMULA:
+ sub r7, r12, #1 @ tiled_addr = temp2-1
+ add r14, r3, #127 @ temp3 = linear_x_size+127
+ bic r14, r14, #0x7F @ temp3 = (temp3 >>7)<<7
+ mov r14, r14, asr #6 @ temp3 = temp3>>6
+ mul r7, r7, r14 @ tiled_addr = tiled_addr*temp3
+ add r7, r7, r11 @ tiled_addr = tiled_addr+temp1
+ add r7, r7, #2 @ tiled_addr = tiled_addr+2
+ bic r14, r11, #0x3 @ temp3 = (temp1>>2)<<2
+ add r7, r7, r14 @ tiled_addr = tiled_addr+temp3
+ mov r7, r7, lsl #11 @ tiled_addr = tiled_addr<<11
+ b GET_TILED_OFFSET_RETURN
+
+GET_TILED_OFFSET_EVEN_FORMULA_1:
+ add r14, r4, #31 @ temp3 = linear_y_size+31
+ bic r14, r14, #0x1F @ temp3 = (temp3>>5)<<5
+ sub r14, r14, #32 @ temp3 = temp3 - 32
+ cmp r6, r14 @ if (i<(temp3-32)) {
+ bge GET_TILED_OFFSET_EVEN_FORMULA_2
+ add r14, r11, #2 @ temp3 = temp1+2
+ bic r14, r14, #3 @ temp3 = (temp3>>2)<<2
+ add r7, r11, r14 @ tiled_addr = temp1+temp3
+ add r14, r3, #127 @ temp3 = linear_x_size+127
+ bic r14, r14, #0x7F @ temp3 = (temp3>>7)<<7
+ mov r14, r14, asr #6 @ temp3 = temp3>>6
+ mul r12, r12, r14 @ tiled_y_index = tiled_y_index*temp3
+ add r7, r7, r12 @ tiled_addr = tiled_addr+tiled_y_index
+ mov r7, r7, lsl #11 @
+ b GET_TILED_OFFSET_RETURN
+
+GET_TILED_OFFSET_EVEN_FORMULA_2:
+ add r14, r3, #127 @ temp3 = linear_x_size+127
+ bic r14, r14, #0x7F @ temp3 = (temp3>>7)<<7
+ mov r14, r14, asr #6 @ temp3 = temp3>>6
+ mul r7, r12, r14 @ tiled_addr = temp2*temp3
+ add r7, r7, r11 @ tiled_addr = tiled_addr+temp3
+ mov r7, r7, lsl #11 @ tiled_addr = tiled_addr<<11@
+
+GET_TILED_OFFSET_RETURN:
+ ldmfd sp!, {r15} @ restore registers
+ .fnend
diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_nv12t_yuv420_y_neon.s b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_nv12t_yuv420_y_neon.s
new file mode 100644
index 0000000..d71ee17
--- /dev/null
+++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_nv12t_yuv420_y_neon.s
@@ -0,0 +1,680 @@
+/*
+ *
+ * Copyright 2011 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 csc_nv12t_yuv420_y_neon.s
+ * @brief SEC_OMX specific define
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2011.7.01 : Create
+ */
+
+/*
+ * Converts tiled data to linear.
+ * 1. Y of NV12T to Y of YUV420P
+ * 2. Y of NV12T to Y of YUV420S
+ * 3. UV of NV12T to UV of YUV420S
+ *
+ * @param yuv420_dest
+ * Y or UV plane address of YUV420[out]
+ *
+ * @param nv12t_src
+ * Y or UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ */
+
+ .arch armv7-a
+ .text
+ .global csc_tiled_to_linear
+ .type csc_tiled_to_linear, %function
+csc_tiled_to_linear:
+ .fnstart
+
+ @r0 linear_dest
+ @r1 tiled_src
+ @r2 linear_x_size
+ @r3 linear_y_size
+ @r4 j
+ @r5 i
+ @r6 tiled_addr
+ @r7 linear_addr
+ @r8 aligned_x_size
+ @r9 aligned_y_size
+ @r10 temp1
+ @r11 temp2
+ @r12 temp3
+ @r14 temp4
+
+ stmfd sp!, {r4-r12,r14} @ backup registers
+
+ mov r8, #0
+ cmp r2, #1024
+ blt LINEAR_X_SIZE_512
+
+LINEAR_X_SIZE_1024:
+
+ mov r5, #0
+LINEAR_X_SIZE_1024_LOOP:
+ mov r6, #0 @ tiled_offset = 0@
+ mov r4, r5, asr #5 @ tiled_y_index = i>>5@
+ and r10, r4, #0x1
+ cmp r10, #0x1
+ bne LINEAR_X_SIZE_1024_LOOP_EVEN
+LINEAR_X_SIZE_1024_LOOP_ODD:
+ sub r6, r4, #1 @ tiled_offset = tiled_y_index-1@
+ add r10, r2, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_offset*(temp1>>6)@
+ mul r6, r6, r10
+ mov r4, #8
+ mov r4, r4, lsl #11
+ sub r4, r4, #32
+ add r6, r6, #2 @ tiled_offset = tiled_offset+2@
+ mov r6, r6, lsl #11 @ tiled_offset = tiled_offset<<11@
+ add r11, r6, #2048
+ add r12, r6, #4096
+ add r14, r6, #6144
+ b LINEAR_X_SIZE_1024_LOOP_MEMCPY
+
+LINEAR_X_SIZE_1024_LOOP_EVEN:
+ add r11, r3, #31 @ temp2 = ((linear_y_size+31)>>5)<<5@
+ bic r11, r11, #0x1F
+ add r10, r2, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_y_index*(temp1>>6)@
+ mul r6, r4, r10
+ add r12, r5, #32
+ cmp r12, r11
+ mov r6, r6, lsl #11 @ tiled_offset = tiled_offset<<11@
+ add r11, r6, #2048
+ movlt r4, #8
+ addlt r12, r6, #12288
+ addlt r14, r6, #14336
+ movge r4, #4
+ addge r12, r6, #4096
+ addge r14, r6, #6144
+ mov r4, r4, lsl #11
+ sub r4, r4, #32
+
+LINEAR_X_SIZE_1024_LOOP_MEMCPY:
+ and r10, r5, #0x1F
+ mov r10, r10, lsl #6
+ add r10, r1, r10
+
+ add r6, r6, r10 @ tiled_addr = tiled_src+64*(temp1)
+ add r11, r11, r10 @ tiled_addr1 = tiled_src+64*(temp1)
+ pld [r11]
+ vld1.8 {q0, q1}, [r6]!
+ pld [r11, #32]
+ add r12, r12, r10 @ tiled_addr2 = tiled_src+64*(temp1)
+ vld1.8 {q2, q3}, [r6], r4
+ pld [r12]
+ vld1.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ add r14, r14, r10 @ tiled_addr3 = tiled_src+64*(temp1)
+ vld1.8 {q6, q7}, [r11], r4
+ pld [r14]
+ vld1.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ mul r7, r2, r5
+ vld1.8 {q10, q11}, [r12], r4
+ add r7, r7, r0
+ vld1.8 {q12, q13}, [r14]!
+ vld1.8 {q14, q15}, [r14], r4
+
+ vst1.8 {q0, q1}, [r7]!
+ vst1.8 {q2, q3}, [r7]!
+ vst1.8 {q4, q5}, [r7]!
+ vst1.8 {q6, q7}, [r7]!
+ vst1.8 {q8, q9}, [r7]!
+ vst1.8 {q10, q11}, [r7]!
+ pld [r6]
+ vst1.8 {q12, q13}, [r7]!
+ pld [r6, #32]
+ vst1.8 {q14, q15}, [r7]!
+
+ pld [r11]
+ vld1.8 {q0, q1}, [r6]!
+ pld [r11, #32]
+ vld1.8 {q2, q3}, [r6], r4
+
+ pld [r12]
+ vld1.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ vld1.8 {q6, q7}, [r11], r4
+ pld [r14]
+ vld1.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ vld1.8 {q10, q11}, [r12], r4
+ vld1.8 {q12, q13}, [r14]!
+ vld1.8 {q14, q15}, [r14], r4
+
+ vst1.8 {q0, q1}, [r7]!
+ vst1.8 {q2, q3}, [r7]!
+ vst1.8 {q4, q5}, [r7]!
+ vst1.8 {q6, q7}, [r7]!
+ vst1.8 {q8, q9}, [r7]!
+ vst1.8 {q10, q11}, [r7]!
+ pld [r6]
+ vst1.8 {q12, q13}, [r7]!
+ pld [r6, #32]
+ vst1.8 {q14, q15}, [r7]!
+
+ pld [r11]
+ vld1.8 {q0, q1}, [r6]!
+ pld [r11, #32]
+ vld1.8 {q2, q3}, [r6], r4
+ pld [r12]
+ vld1.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ vld1.8 {q6, q7}, [r11], r4
+ pld [r14]
+ vld1.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ vld1.8 {q10, q11}, [r12], r4
+ vld1.8 {q12, q13}, [r14]!
+ vld1.8 {q14, q15}, [r14], r4
+
+ vst1.8 {q0, q1}, [r7]!
+ vst1.8 {q2, q3}, [r7]!
+ vst1.8 {q4, q5}, [r7]!
+ vst1.8 {q6, q7}, [r7]!
+ vst1.8 {q8, q9}, [r7]!
+ vst1.8 {q10, q11}, [r7]!
+ pld [r6]
+ vst1.8 {q12, q13}, [r7]!
+ pld [r6, #32]
+ vst1.8 {q14, q15}, [r7]!
+
+ pld [r11]
+ vld1.8 {q0, q1}, [r6]!
+ pld [r11, #32]
+ vld1.8 {q2, q3}, [r6]
+ pld [r12]
+ vld1.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ vld1.8 {q6, q7}, [r11]
+ pld [r14]
+ vld1.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ vld1.8 {q10, q11}, [r12]
+ vld1.8 {q12, q13}, [r14]!
+ vld1.8 {q14, q15}, [r14]
+
+ vst1.8 {q0, q1}, [r7]!
+ vst1.8 {q2, q3}, [r7]!
+ vst1.8 {q4, q5}, [r7]!
+ vst1.8 {q6, q7}, [r7]!
+ vst1.8 {q8, q9}, [r7]!
+ vst1.8 {q10, q11}, [r7]!
+ add r5, #1
+ vst1.8 {q12, q13}, [r7]!
+ cmp r5, r3
+ vst1.8 {q14, q15}, [r7]!
+
+ blt LINEAR_X_SIZE_1024_LOOP
+
+ mov r8, #1024
+
+LINEAR_X_SIZE_512:
+
+ sub r14, r2, r8
+ cmp r14, #512
+ blt LINEAR_X_SIZE_256
+
+ mov r5, #0
+LINEAR_X_SIZE_512_LOOP:
+ mov r6, #0
+ mov r4, r5, asr #5 @ tiled_y_index = i>>5
+ and r10, r4, #0x1
+ cmp r10, #0x1
+ bne LINEAR_X_SIZE_512_LOOP_EVEN
+
+LINEAR_X_SIZE_512_LOOP_ODD:
+ sub r6, r4, #1
+ add r10, r2, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_offset*(temp1>>6)@
+ mul r6, r6, r10
+ mov r4, #8
+ mov r4, r4, lsl #11
+ sub r4, r4, #32
+ add r6, r6, #2 @ tiled_offset = tiled_offset+2@
+ mov r10, r8, asr #5 @ temp1 = aligned_x_size>>5@
+ add r6, r6, r10 @ tiled_offset = tiled_offset+temp1@
+ mov r6, r6, lsl #11
+ add r11, r6, #2048
+ add r12, r6, #4096
+ add r14, r6, #6144
+ b LINEAR_X_SIZE_512_LOOP_MEMCPY
+
+LINEAR_X_SIZE_512_LOOP_EVEN:
+ add r11, r3, #31 @ temp2 = ((linear_y_size+31)>>5)<<5@
+ bic r11, r11, #0x1F
+ add r10, r2, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_y_index*(temp1>>6)@
+ mul r6, r4, r10
+ add r12, r5, #32
+ cmp r12, r11
+ mov r6, r6, lsl #11 @ tiled_offset = tiled_offset<<11@
+ movlt r4, #8
+ movlt r10, r8, asr #5 @ temp1 = aligned_x_size>>5@
+ movge r10, r8, asr #6 @ temp1 = aligned_x_size>>6@
+ add r6, r6, r10, lsl #11 @ tiled_offset = tiled_offset+(temp1<<11)@
+ add r11, r6, #2048
+ addlt r12, r6, #12288
+ addlt r14, r6, #14336
+ movge r4, #4
+ addge r12, r6, #4096
+ addge r14, r6, #6144
+ mov r4, r4, lsl #11
+ sub r4, r4, #32
+
+LINEAR_X_SIZE_512_LOOP_MEMCPY:
+ and r10, r5, #0x1F
+ mov r10, r10, lsl #6
+ add r10, r1, r10
+
+ add r6, r6, r10 @ tiled_addr = tiled_src+64*(temp1)
+ add r11, r11, r10 @ tiled_addr1 = tiled_src+64*(temp1)
+ pld [r11]
+ vld1.8 {q0, q1}, [r6]!
+ pld [r11, #32]
+ add r12, r12, r10 @ tiled_addr2 = tiled_src+64*(temp1)
+ vld1.8 {q2, q3}, [r6], r4
+ pld [r12]
+ vld1.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ add r14, r14, r10 @ tiled_addr3 = tiled_src+64*(temp1)
+ vld1.8 {q6, q7}, [r11], r4
+ pld [r14]
+ vld1.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ mul r7, r2, r5
+ vld1.8 {q10, q11}, [r12], r4
+ add r7, r7, r8
+ vld1.8 {q12, q13}, [r14]!
+ vld1.8 {q14, q15}, [r14], r4
+
+ add r7, r7, r0
+ vst1.8 {q0, q1}, [r7]!
+ vst1.8 {q2, q3}, [r7]!
+ vst1.8 {q4, q5}, [r7]!
+ vst1.8 {q6, q7}, [r7]!
+ vst1.8 {q8, q9}, [r7]!
+ vst1.8 {q10, q11}, [r7]!
+ pld [r6]
+ vst1.8 {q12, q13}, [r7]!
+ pld [r6, #32]
+ vst1.8 {q14, q15}, [r7]!
+
+ pld [r11]
+ vld1.8 {q0, q1}, [r6]!
+ pld [r11, #32]
+ vld1.8 {q2, q3}, [r6], r4
+ pld [r12]
+ vld1.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ vld1.8 {q6, q7}, [r11], r4
+ pld [r14]
+ vld1.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ vld1.8 {q10, q11}, [r12], r4
+ vld1.8 {q12, q13}, [r14]!
+ vld1.8 {q14, q15}, [r14], r4
+
+ vst1.8 {q0, q1}, [r7]!
+ vst1.8 {q2, q3}, [r7]!
+ vst1.8 {q4, q5}, [r7]!
+ vst1.8 {q6, q7}, [r7]!
+ vst1.8 {q8, q9}, [r7]!
+ vst1.8 {q10, q11}, [r7]!
+ add r5, #1
+ vst1.8 {q12, q13}, [r7]!
+ cmp r5, r3
+ vst1.8 {q14, q15}, [r7]!
+
+ blt LINEAR_X_SIZE_512_LOOP
+
+ add r8, r8, #512
+
+LINEAR_X_SIZE_256:
+
+ sub r14, r2, r8
+ cmp r14, #256
+ blt LINEAR_X_SIZE_128
+
+ mov r5, #0
+LINEAR_X_SIZE_256_LOOP:
+ mov r6, #0
+ mov r4, r5, asr #5 @ tiled_y_index = i>>5
+ and r10, r4, #0x1
+ cmp r10, #0x1
+ bne LINEAR_X_SIZE_256_LOOP_EVEN
+
+LINEAR_X_SIZE_256_LOOP_ODD:
+ sub r6, r4, #1
+ add r10, r2, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_offset*(temp1>>6)@
+ mul r6, r6, r10
+ add r6, r6, #2 @ tiled_offset = tiled_offset+2@
+ mov r10, r8, asr #5 @ temp1 = aligned_x_size>>5@
+ add r6, r6, r10 @ tiled_offset = tiled_offset+temp1@
+ mov r6, r6, lsl #11
+ add r11, r6, #2048
+ add r12, r6, #4096
+ add r14, r6, #6144
+ b LINEAR_X_SIZE_256_LOOP_MEMCPY
+
+LINEAR_X_SIZE_256_LOOP_EVEN:
+ add r11, r3, #31 @ temp2 = ((linear_y_size+31)>>5)<<5@
+ bic r11, r11, #0x1F
+ add r10, r2, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_y_index*(temp1>>6)@
+ mul r6, r4, r10
+ mov r6, r6, lsl #11 @ tiled_offset = tiled_offset<<11@
+ add r12, r5, #32
+ cmp r12, r11
+ movlt r10, r8, asr #5 @ temp1 = aligned_x_size>>5@
+ movge r10, r8, asr #6 @ temp1 = aligned_x_size>>6@
+ add r6, r6, r10, lsl #11 @ tiled_offset = tiled_offset+(temp1<<11)@
+ add r11, r6, #2048
+ addlt r12, r6, #12288
+ addlt r14, r6, #14336
+ addge r12, r6, #4096
+ addge r14, r6, #6144
+
+LINEAR_X_SIZE_256_LOOP_MEMCPY:
+ and r10, r5, #0x1F
+ mov r10, r10, lsl #6
+ add r10, r1, r10
+
+ add r6, r6, r10 @ tiled_addr = tiled_src+64*(temp1)
+ add r11, r11, r10 @ tiled_addr1 = tiled_src+64*(temp1)
+ pld [r11]
+ vld1.8 {q0, q1}, [r6]!
+ pld [r11, #32]
+ add r12, r12, r10 @ tiled_addr2 = tiled_src+64*(temp1)
+ vld1.8 {q2, q3}, [r6]
+ pld [r12]
+ vld1.8 {q4, q5}, [r11]!
+ pld [r12, #32]
+ add r14, r14, r10 @ tiled_addr3 = tiled_src+64*(temp1)
+ vld1.8 {q6, q7}, [r11]
+ pld [r14]
+ mul r7, r2, r5
+ vld1.8 {q8, q9}, [r12]!
+ pld [r14, #32]
+ add r7, r7, r8
+ vld1.8 {q10, q11}, [r12]
+ add r7, r7, r0
+ vld1.8 {q12, q13}, [r14]!
+ vld1.8 {q14, q15}, [r14]
+
+ vst1.8 {q0, q1}, [r7]!
+ vst1.8 {q2, q3}, [r7]!
+ vst1.8 {q4, q5}, [r7]!
+ vst1.8 {q6, q7}, [r7]!
+ vst1.8 {q8, q9}, [r7]!
+ vst1.8 {q10, q11}, [r7]!
+ add r5, #1
+ vst1.8 {q12, q13}, [r7]!
+ cmp r5, r3
+ vst1.8 {q14, q15}, [r7]!
+
+ blt LINEAR_X_SIZE_256_LOOP
+
+ add r8, r8, #256
+
+LINEAR_X_SIZE_128:
+
+ sub r14, r2, r8
+ cmp r14, #128
+ blt LINEAR_X_SIZE_64
+
+ mov r5, #0
+LINEAR_X_SIZE_128_LOOP:
+ mov r6, #0
+ mov r4, r5, asr #5 @ tiled_y_index = i>>5
+ and r10, r4, #0x1
+ cmp r10, #0x1
+ bne LINEAR_X_SIZE_128_LOOP_EVEN
+
+LINEAR_X_SIZE_128_LOOP_ODD:
+ sub r6, r4, #1
+ add r10, r2, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_offset*(temp1>>6)@
+ mul r6, r6, r10
+ add r6, r6, #2 @ tiled_offset = tiled_offset+2@
+ mov r10, r8, asr #5 @ temp1 = aligned_x_size>>5@
+ add r6, r6, r10 @ tiled_offset = tiled_offset+temp1@
+ mov r6, r6, lsl #11
+ add r11, r6, #2048
+ b LINEAR_X_SIZE_128_LOOP_MEMCPY
+
+LINEAR_X_SIZE_128_LOOP_EVEN:
+ add r11, r3, #31 @ temp2 = ((linear_y_size+31)>>5)<<5@
+ bic r11, r11, #0x1F
+ add r10, r2, #127 @ temp1 = ((linear_x_size+127)>>7)<<7@
+ bic r10, #0x7F
+ mov r10, r10, asr #6 @ tiled_offset = tiled_y_index*(temp1>>6)@
+ mul r6, r4, r10
+ mov r6, r6, lsl #11 @ tiled_offset = tiled_offset<<11@
+ add r12, r5, #32
+ cmp r12, r11
+ movlt r10, r8, asr #5 @ temp1 = aligned_x_size>>5@
+ movge r10, r8, asr #6 @ temp1 = aligned_x_size>>6@
+ add r6, r6, r10, lsl #11 @ tiled_offset = tiled_offset+(temp1<<11)@
+ add r11, r6, #2048
+
+LINEAR_X_SIZE_128_LOOP_MEMCPY:
+ and r10, r5, #0x1F
+ mov r10, r10, lsl #6
+ add r10, r1, r10
+
+ add r6, r6, r10 @ tiled_addr = tiled_src+64*(temp1)
+ add r11, r11, r10 @ tiled_addr1 = tiled_src+64*(temp1)
+ pld [r6, #64]
+ vld1.8 {q0, q1}, [r6]!
+ pld [r6, #64]
+ vld1.8 {q2, q3}, [r6]!
+ mul r7, r2, r5
+ pld [r11]
+ vld1.8 {q4, q5}, [r6]!
+ add r7, r7, r8
+ pld [r11, #32]
+ vld1.8 {q6, q7}, [r6]
+ add r7, r7, r0
+ pld [r11, #64]
+ vld1.8 {q8, q9}, [r11]!
+ pld [r11, #64]
+ vld1.8 {q10, q11}, [r11]!
+ vld1.8 {q12, q13}, [r11]!
+ vld1.8 {q14, q15}, [r11]
+
+ sub r9, r2, #96
+ vst1.8 {q0, q1}, [r7]!
+ vst1.8 {q2, q3}, [r7]!
+ vst1.8 {q8, q9}, [r7]!
+ vst1.8 {q10, q11}, [r7], r9
+ vst1.8 {q4, q5}, [r7]!
+ vst1.8 {q6, q7}, [r7]!
+ add r5, #2
+ vst1.8 {q12, q13}, [r7]!
+ cmp r5, r3
+ vst1.8 {q14, q15}, [r7]
+
+ blt LINEAR_X_SIZE_128_LOOP
+
+ add r8, r8, #128
+
+LINEAR_X_SIZE_64:
+
+ sub r14, r2, r8
+ cmp r14, #64
+ blt LINEAR_X_SIZE_4
+
+ mov r5, #0
+ mov r4, r8
+
+LINEAR_X_SIZE_64_LOOP:
+
+ bl GET_TILED_OFFSET
+
+ add r6, r1, r6 @ tiled_addr = tiled_src+tiled_addr
+ and r11, r5, #0x1F @ temp2 = i&0x1F
+ mov r11, r11, lsl #6 @ temp2 = 64*temp2
+ add r6, r6, r11 @ tiled_addr = tiled_addr+temp2
+
+ pld [r6, #64]
+ vld1.8 {q0, q1}, [r6]! @ store {tiled_addr}
+ mul r10, r2, r5 @ temp1 = linear_x_size*(i)
+ pld [r6, #64]
+ vld1.8 {q2, q3}, [r6]!
+ pld [r6, #64]
+ vld1.8 {q4, q5}, [r6]! @ store {tiled_addr+64*1}
+ pld [r6, #64]
+ vld1.8 {q6, q7}, [r6]!
+ pld [r6, #64]
+ vld1.8 {q8, q9}, [r6]! @ store {tiled_addr+64*2}
+ pld [r6, #64]
+ vld1.8 {q10, q11}, [r6]!
+ add r7, r0, r4 @ linear_addr = linear_dest+j
+ vld1.8 {q12, q13}, [r6]! @ store {tiled_addr+64*3}
+ add r7, r7, r10 @ linear_addr = linear_addr+temp1
+ vld1.8 {q14, q15}, [r6]!
+ sub r10, r2, #32 @ temp1 = linear_x_size-32
+
+ vst1.8 {q0, q1}, [r7]! @ load {linear_src, 64}
+ vst1.8 {q2, q3}, [r7], r10
+ vst1.8 {q4, q5}, [r7]! @ load {linear_src+linear_x_size*1, 64}
+ vst1.8 {q6, q7}, [r7], r10
+ vst1.8 {q8, q9}, [r7]! @ load {linear_src+linear_x_size*2, 64}
+ vst1.8 {q10, q11}, [r7], r10
+ add r5, #4
+ vst1.8 {q12, q13}, [r7]! @ load {linear_src+linear_x_size*3, 64}
+ cmp r5, r3
+ vst1.8 {q14, q15}, [r7], r10
+
+ blt LINEAR_X_SIZE_64_LOOP
+
+ add r8, r8, #64
+
+LINEAR_X_SIZE_4:
+ cmp r8, r2
+ beq RESTORE_REG
+
+ mov r5, #0 @ i = 0
+LINEAR_Y_SIZE_4_LOOP:
+
+ mov r4, r8 @ j = aligned_x_size
+LINEAR_X_SIZE_4_LOOP:
+
+ bl GET_TILED_OFFSET
+
+ and r10, r5, #0x1F @ temp1 = i&0x1F
+ and r11, r4, #0x3F @ temp2 = j&0x3F
+
+ add r6, r6, r1
+ add r6, r6, r11
+ add r6, r6, r10, lsl #6
+
+ ldr r10, [r6], #64
+ add r7, r0, r4
+ ldr r11, [r6], #64
+ mul r9, r2, r5
+ ldr r12, [r6], #64
+ add r7, r7, r9
+ ldr r14, [r6], #64
+
+ str r10, [r7], r2
+ str r11, [r7], r2
+ str r12, [r7], r2
+ str r14, [r7], r2
+
+ add r4, r4, #4 @ j = j+4
+ cmp r4, r2 @ j<linear_x_size
+ blt LINEAR_X_SIZE_4_LOOP
+
+ add r5, r5, #4 @ i = i+4
+ cmp r5, r3 @ i<linear_y_size
+ blt LINEAR_Y_SIZE_4_LOOP
+
+RESTORE_REG:
+ ldmfd sp!, {r4-r12,r15} @ restore registers
+
+GET_TILED_OFFSET:
+
+ mov r11, r5, asr #5 @ temp2 = i>>5
+ mov r10, r4, asr #6 @ temp1 = j>>6
+
+ and r12, r11, #0x1 @ if (temp2 & 0x1)
+ cmp r12, #0x1
+ bne GET_TILED_OFFSET_EVEN_FORMULA_1
+
+GET_TILED_OFFSET_ODD_FORMULA:
+ sub r6, r11, #1 @ tiled_addr = temp2-1
+ add r12, r2, #127 @ temp3 = linear_x_size+127
+ bic r12, r12, #0x7F @ temp3 = (temp3 >>7)<<7
+ mov r12, r12, asr #6 @ temp3 = temp3>>6
+ mul r6, r6, r12 @ tiled_addr = tiled_addr*temp3
+ add r6, r6, r10 @ tiled_addr = tiled_addr+temp1
+ add r6, r6, #2 @ tiled_addr = tiled_addr+2
+ bic r12, r10, #0x3 @ temp3 = (temp1>>2)<<2
+ add r6, r6, r12 @ tiled_addr = tiled_addr+temp3
+ mov r6, r6, lsl #11 @ tiled_addr = tiled_addr<<11
+ b GET_TILED_OFFSET_RETURN
+
+GET_TILED_OFFSET_EVEN_FORMULA_1:
+ add r12, r3, #31 @ temp3 = linear_y_size+31
+ bic r12, r12, #0x1F @ temp3 = (temp3>>5)<<5
+ sub r12, r12, #32 @ temp3 = temp3 - 32
+ cmp r5, r12 @ if (i<(temp3-32)) {
+ bge GET_TILED_OFFSET_EVEN_FORMULA_2
+ add r12, r10, #2 @ temp3 = temp1+2
+ bic r12, r12, #3 @ temp3 = (temp3>>2)<<2
+ add r6, r10, r12 @ tiled_addr = temp1+temp3
+ add r12, r2, #127 @ temp3 = linear_x_size+127
+ bic r12, r12, #0x7F @ temp3 = (temp3>>7)<<7
+ mov r12, r12, asr #6 @ temp3 = temp3>>6
+ mul r11, r11, r12 @ tiled_y_index = tiled_y_index*temp3
+ add r6, r6, r11 @ tiled_addr = tiled_addr+tiled_y_index
+ mov r6, r6, lsl #11 @
+ b GET_TILED_OFFSET_RETURN
+
+GET_TILED_OFFSET_EVEN_FORMULA_2:
+ add r12, r2, #127 @ temp3 = linear_x_size+127
+ bic r12, r12, #0x7F @ temp3 = (temp3>>7)<<7
+ mov r12, r12, asr #6 @ temp3 = temp3>>6
+ mul r6, r11, r12 @ tiled_addr = temp2*temp3
+ add r6, r6, r10 @ tiled_addr = tiled_addr+temp3
+ mov r6, r6, lsl #11 @ tiled_addr = tiled_addr<<11@
+
+GET_TILED_OFFSET_RETURN:
+ mov pc, lr
+ .fnend
+
diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_yuv420_nv12t_uv_neon.s b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_yuv420_nv12t_uv_neon.s
new file mode 100644
index 0000000..dd2c879
--- /dev/null
+++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_yuv420_nv12t_uv_neon.s
@@ -0,0 +1,573 @@
+/*
+ *
+ * Copyright 2011 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 csc_yuv420_nv12t_uv_neon.s
+ * @brief SEC_OMX specific define
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2011.7.01 : Create
+ */
+
+/*
+ * Converts and Interleaves linear to tiled
+ * 1. UV of YUV420P to UV of NV12T
+ *
+ * @param nv12t_uv_dest
+ * UV plane address of NV12T[out]
+ *
+ * @param yuv420p_u_src
+ * U plane address of YUV420P[in]
+ *
+ * @param yuv420p_v_src
+ * V plane address of YUV420P[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_uv_height
+ * Height/2 of YUV420[in]
+ */
+
+ .arch armv7-a
+ .text
+ .global csc_linear_to_tiled_interleave
+ .type csc_linear_to_tiled_interleave, %function
+csc_linear_to_tiled_interleave:
+ .fnstart
+
+ @r0 tiled_dest
+ @r1 linear_src_u
+ @r2 linear_src_v
+ @r3 linear_x_size
+ @r4 linear_y_size
+ @r5 j
+ @r6 i
+ @r7 tiled_addr
+ @r8 linear_addr
+ @r9 aligned_x_size
+ @r10 aligned_y_size
+ @r11 temp1
+ @r12 temp2
+ @r14 temp3
+
+ stmfd sp!, {r4-r12,r14} @ backup registers
+
+ ldr r4, [sp, #40] @ load linear_y_size to r4
+
+ bic r10, r4, #0x1F @ aligned_y_size = (linear_y_size>>5)<<5
+ bic r9, r3, #0x3F @ aligned_x_size = (linear_x_size>>6)<<6
+
+ mov r6, #0 @ i = 0
+LOOP_ALIGNED_Y_SIZE:
+
+ mov r5, #0 @ j = 0
+LOOP_ALIGNED_X_SIZE:
+
+ bl GET_TILED_OFFSET
+
+ mov r11, r3, asr #1 @ temp1 = linear_x_size/2
+ mul r11, r11, r6 @ temp1 = temp1*(i)
+ add r11, r11, r5, asr #1 @ temp1 = temp1+j/2
+ mov r12, r3, asr #1 @ temp2 = linear_x_size/2
+ sub r12, r12, #16 @ temp2 = linear_x_size-16
+
+ add r8, r1, r11 @ linear_addr = linear_src_u+temp1
+ add r11, r2, r11 @ temp1 = linear_src_v+temp1
+ add r7, r0, r7 @ tiled_addr = tiled_dest+tiled_addr
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]!
+ vld1.8 {q2}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]!
+ vld1.8 {q3}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]!
+ vld1.8 {q6}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]!
+ vld1.8 {q7}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q8}, [r8]!
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q9}, [r11]!
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q12}, [r8]!
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q13}, [r11]!
+ vld1.8 {q15}, [r11], r12
+
+ vst2.8 {q0, q1}, [r7]!
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]!
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]!
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]!
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]!
+ vld1.8 {q2}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]!
+ vld1.8 {q3}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]!
+ vld1.8 {q6}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]!
+ vld1.8 {q7}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q8}, [r8]!
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q9}, [r11]!
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q12}, [r8]!
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q13}, [r11]!
+ vld1.8 {q15}, [r11], r12
+
+ vst2.8 {q0, q1}, [r7]!
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]!
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]!
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]!
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]!
+ vld1.8 {q2}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]!
+ vld1.8 {q3}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]!
+ vld1.8 {q6}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]!
+ vld1.8 {q7}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q8}, [r8]!
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q9}, [r11]!
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q12}, [r8]!
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q13}, [r11]!
+ vld1.8 {q15}, [r11], r12
+
+ vst2.8 {q0, q1}, [r7]!
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]!
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]!
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]!
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]!
+ vld1.8 {q2}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]!
+ vld1.8 {q3}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]!
+ vld1.8 {q6}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]!
+ vld1.8 {q7}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q8}, [r8]!
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q9}, [r11]!
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q12}, [r8]!
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q13}, [r11]!
+ vld1.8 {q15}, [r11], r12
+
+ vst2.8 {q0, q1}, [r7]!
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]!
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]!
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]!
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]!
+ vld1.8 {q2}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]!
+ vld1.8 {q3}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]!
+ vld1.8 {q6}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]!
+ vld1.8 {q7}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q8}, [r8]!
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q9}, [r11]!
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q12}, [r8]!
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q13}, [r11]!
+ vld1.8 {q15}, [r11], r12
+
+ vst2.8 {q0, q1}, [r7]!
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]!
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]!
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]!
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]!
+ vld1.8 {q2}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]!
+ vld1.8 {q3}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]!
+ vld1.8 {q6}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]!
+ vld1.8 {q7}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q8}, [r8]!
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q9}, [r11]!
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q12}, [r8]!
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q13}, [r11]!
+ vld1.8 {q15}, [r11], r12
+
+ vst2.8 {q0, q1}, [r7]!
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]!
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]!
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]!
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]!
+ vld1.8 {q2}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]!
+ vld1.8 {q3}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]!
+ vld1.8 {q6}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]!
+ vld1.8 {q7}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q8}, [r8]!
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q9}, [r11]!
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q12}, [r8]!
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q13}, [r11]!
+ vld1.8 {q15}, [r11], r12
+
+ vst2.8 {q0, q1}, [r7]!
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]!
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]!
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]!
+ vst2.8 {q14, q15}, [r7]!
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]!
+ vld1.8 {q2}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]!
+ vld1.8 {q3}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]!
+ vld1.8 {q6}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]!
+ vld1.8 {q7}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q8}, [r8]!
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q9}, [r11]!
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q12}, [r8]!
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q13}, [r11]!
+ vld1.8 {q15}, [r11], r12
+
+ vst2.8 {q0, q1}, [r7]!
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]!
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]!
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]!
+ vst2.8 {q14, q15}, [r7]!
+
+ add r5, r5, #64 @ j = j+64
+ cmp r5, r9 @ j<aligned_x_size
+ blt LOOP_ALIGNED_X_SIZE
+
+ add r6, r6, #32 @ i = i+32
+ cmp r6, r10 @ i<aligned_y_size
+ blt LOOP_ALIGNED_Y_SIZE
+
+ ldr r4, [sp, #40] @ load linear_y_size to r4
+ cmp r6, r4
+ beq LOOP_LINEAR_Y_SIZE_2_START
+
+LOOP_LINEAR_Y_SIZE_1:
+
+ mov r5, #0 @ j = 0
+LOOP_ALIGNED_X_SIZE_1:
+
+ bl GET_TILED_OFFSET
+
+ mov r11, r3, asr #1 @ temp1 = linear_x_size/2
+ mul r11, r11, r6 @ temp1 = temp1*(i)
+ add r11, r11, r5, asr #1 @ temp1 = temp1+j/2
+ mov r12, r3, asr #1 @ temp2 = linear_x_size/2
+ sub r12, r12, #16 @ temp2 = linear_x_size-16
+
+ add r8, r1, r11 @ linear_addr = linear_src_u+temp1
+ add r11, r2, r11 @ temp1 = linear_src_v+temp1
+ add r7, r0, r7 @ tiled_addr = tiled_dest+tiled_addr
+ and r14, r6, #0x1F @ temp3 = i&0x1F@
+ mov r14, r14, lsl #6 @ temp3 = temp3*64
+ add r7, r7, r14 @ tiled_addr = tiled_addr+temp3
+
+ pld [r8, r3]
+ vld1.8 {q0}, [r8]!
+ vld1.8 {q2}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q1}, [r11]!
+ vld1.8 {q3}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q4}, [r8]!
+ vld1.8 {q6}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q5}, [r11]!
+ vld1.8 {q7}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q8}, [r8]!
+ vld1.8 {q10}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q9}, [r11]!
+ vld1.8 {q11}, [r11], r12
+ pld [r8, r3]
+ vld1.8 {q12}, [r8]!
+ vld1.8 {q14}, [r8], r12
+ pld [r11, r3]
+ vld1.8 {q13}, [r11]!
+ vld1.8 {q15}, [r11], r12
+
+ vst2.8 {q0, q1}, [r7]! @ store {tiled_addr}
+ vst2.8 {q2, q3}, [r7]!
+ vst2.8 {q4, q5}, [r7]! @ store {tiled_addr+64*1}
+ vst2.8 {q6, q7}, [r7]!
+ vst2.8 {q8, q9}, [r7]! @ store {tiled_addr+64*2}
+ vst2.8 {q10, q11}, [r7]!
+ vst2.8 {q12, q13}, [r7]! @ store {tiled_addr+64*3}
+ vst2.8 {q14, q15}, [r7]!
+
+ add r5, r5, #64 @ j = j+64
+ cmp r5, r9 @ j<aligned_x_size
+ blt LOOP_ALIGNED_X_SIZE_1
+
+ add r6, r6, #4 @ i = i+4
+ cmp r6, r4 @ i<linear_y_size
+ blt LOOP_LINEAR_Y_SIZE_1
+
+LOOP_LINEAR_Y_SIZE_2_START:
+ cmp r5, r3
+ beq RESTORE_REG
+
+ mov r6, #0 @ i = 0
+LOOP_LINEAR_Y_SIZE_2:
+
+ mov r5, r9 @ j = aligned_x_size
+LOOP_LINEAR_X_SIZE_2:
+
+ bl GET_TILED_OFFSET
+
+ mov r11, r3, asr #1 @ temp1 = linear_x_size/2
+ mul r11, r11, r6 @ temp1 = temp1*(i)
+ add r11, r11, r5, asr #1 @ temp1 = temp1+j/2
+ mov r12, r3, asr #1 @ temp2 = linear_x_size/2
+ sub r12, r12, #1 @ temp2 = linear_x_size-1
+
+ add r8, r1, r11 @ linear_addr = linear_src_u+temp1
+ add r11, r2, r11 @ temp1 = linear_src_v+temp1
+ add r7, r0, r7 @ tiled_addr = tiled_dest+tiled_addr
+ and r14, r6, #0x1F @ temp3 = i&0x1F@
+ mov r14, r14, lsl #6 @ temp3 = temp3*64
+ add r7, r7, r14 @ tiled_addr = tiled_addr+temp3
+ and r14, r5, #0x3F @ temp3 = j&0x3F
+ add r7, r7, r14 @ tiled_addr = tiled_addr+temp3
+
+ ldrb r10, [r8], #1
+ ldrb r14, [r11], #1
+ mov r14, r14, lsl #8
+ orr r10, r10, r14
+ strh r10, [r7], #2
+ ldrb r10, [r8], r12
+ ldrb r14, [r11], r12
+ mov r14, r14, lsl #8
+ orr r10, r10, r14
+ strh r10, [r7], #62
+
+ ldrb r10, [r8], #1
+ ldrb r14, [r11], #1
+ mov r14, r14, lsl #8
+ orr r10, r10, r14
+ strh r10, [r7], #2
+ ldrb r10, [r8], r12
+ ldrb r14, [r11], r12
+ mov r14, r14, lsl #8
+ orr r10, r10, r14
+ strh r10, [r7], #62
+
+ ldrb r10, [r8], #1
+ ldrb r14, [r11], #1
+ mov r14, r14, lsl #8
+ orr r10, r10, r14
+ strh r10, [r7], #2
+ ldrb r10, [r8], r12
+ ldrb r14, [r11], r12
+ mov r14, r14, lsl #8
+ orr r10, r10, r14
+ strh r10, [r7], #62
+
+ ldrb r10, [r8], #1
+ ldrb r14, [r11], #1
+ mov r14, r14, lsl #8
+ orr r10, r10, r14
+ strh r10, [r7], #2
+ ldrb r10, [r8], r12
+ ldrb r14, [r11], r12
+ mov r14, r14, lsl #8
+ orr r10, r10, r14
+ strh r10, [r7], #62
+
+ add r5, r5, #4 @ j = j+4
+ cmp r5, r3 @ j<linear_x_size
+ blt LOOP_LINEAR_X_SIZE_2
+
+ add r6, r6, #4 @ i = i+4
+ cmp r6, r4 @ i<linear_y_size
+ blt LOOP_LINEAR_Y_SIZE_2
+
+RESTORE_REG:
+ ldmfd sp!, {r4-r12,r15} @ restore registers
+
+GET_TILED_OFFSET:
+ stmfd sp!, {r14}
+
+ mov r12, r6, asr #5 @ temp2 = i>>5
+ mov r11, r5, asr #6 @ temp1 = j>>6
+
+ and r14, r12, #0x1 @ if (temp2 & 0x1)
+ cmp r14, #0x1
+ bne GET_TILED_OFFSET_EVEN_FORMULA_1
+
+GET_TILED_OFFSET_ODD_FORMULA:
+ sub r7, r12, #1 @ tiled_addr = temp2-1
+ add r14, r3, #127 @ temp3 = linear_x_size+127
+ bic r14, r14, #0x7F @ temp3 = (temp3 >>7)<<7
+ mov r14, r14, asr #6 @ temp3 = temp3>>6
+ mul r7, r7, r14 @ tiled_addr = tiled_addr*temp3
+ add r7, r7, r11 @ tiled_addr = tiled_addr+temp1
+ add r7, r7, #2 @ tiled_addr = tiled_addr+2
+ bic r14, r11, #0x3 @ temp3 = (temp1>>2)<<2
+ add r7, r7, r14 @ tiled_addr = tiled_addr+temp3
+ mov r7, r7, lsl #11 @ tiled_addr = tiled_addr<<11
+ b GET_TILED_OFFSET_RETURN
+
+GET_TILED_OFFSET_EVEN_FORMULA_1:
+ add r14, r4, #31 @ temp3 = linear_y_size+31
+ bic r14, r14, #0x1F @ temp3 = (temp3>>5)<<5
+ sub r14, r14, #32 @ temp3 = temp3 - 32
+ cmp r6, r14 @ if (i<(temp3-32)) {
+ bge GET_TILED_OFFSET_EVEN_FORMULA_2
+ add r14, r11, #2 @ temp3 = temp1+2
+ bic r14, r14, #3 @ temp3 = (temp3>>2)<<2
+ add r7, r11, r14 @ tiled_addr = temp1+temp3
+ add r14, r3, #127 @ temp3 = linear_x_size+127
+ bic r14, r14, #0x7F @ temp3 = (temp3>>7)<<7
+ mov r14, r14, asr #6 @ temp3 = temp3>>6
+ mul r12, r12, r14 @ tiled_y_index = tiled_y_index*temp3
+ add r7, r7, r12 @ tiled_addr = tiled_addr+tiled_y_index
+ mov r7, r7, lsl #11 @
+ b GET_TILED_OFFSET_RETURN
+
+GET_TILED_OFFSET_EVEN_FORMULA_2:
+ add r14, r3, #127 @ temp3 = linear_x_size+127
+ bic r14, r14, #0x7F @ temp3 = (temp3>>7)<<7
+ mov r14, r14, asr #6 @ temp3 = temp3>>6
+ mul r7, r12, r14 @ tiled_addr = temp2*temp3
+ add r7, r7, r11 @ tiled_addr = tiled_addr+temp3
+ mov r7, r7, lsl #11 @ tiled_addr = tiled_addr<<11@
+
+GET_TILED_OFFSET_RETURN:
+ ldmfd sp!, {r15} @ restore registers
+ .fnend
+
diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_yuv420_nv12t_y_neon.s b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_yuv420_nv12t_y_neon.s
new file mode 100644
index 0000000..3f8932a
--- /dev/null
+++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/csc/csc_yuv420_nv12t_y_neon.s
@@ -0,0 +1,451 @@
+/*
+ *
+ * Copyright 2011 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 csc_yuv420_nv12t_y_neon.s
+ * @brief SEC_OMX specific define
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2011.7.01 : Create
+ */
+
+/*
+ * Converts linear data to tiled.
+ * 1. Y of YUV420P to Y of NV12T
+ * 2. Y of YUV420S to Y of NV12T
+ * 3. UV of YUV420S to UV of NV12T
+ *
+ * @param nv12t_dest
+ * Y or UV plane address of NV12T[out]
+ *
+ * @param yuv420_src
+ * Y or UV plane address of YUV420P(S)[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ */
+
+ .arch armv7-a
+ .text
+ .global csc_linear_to_tiled
+ .type csc_linear_to_tiled, %function
+csc_linear_to_tiled:
+ .fnstart
+
+ @r0 tiled_dest
+ @r1 linear_src
+ @r2 linear_x_size
+ @r3 linear_y_size
+ @r4 j
+ @r5 i
+ @r6 nn(tiled_addr)
+ @r7 mm(linear_addr)
+ @r8 aligned_x_size
+ @r9 aligned_y_size
+ @r10 temp1
+ @r11 temp2
+ @r12 temp3
+ @r14 temp4
+
+ stmfd sp!, {r4-r12,r14} @ backup registers
+
+ bic r9, r3, #0x1F @ aligned_y_size = (linear_y_size>>5)<<5
+ bic r8, r2, #0x3F @ aligned_x_size = (linear_x_size>>6)<<6
+
+ mov r5, #0 @ i = 0
+LOOP_ALIGNED_Y_SIZE:
+
+ mov r4, #0 @ j = 0
+LOOP_ALIGNED_X_SIZE:
+
+ bl GET_TILED_OFFSET
+
+ mul r10, r2, r5 @ temp1 = linear_x_size*(i)
+ add r7, r1, r4 @ linear_addr = linear_src+j
+ add r7, r7, r10 @ linear_addr = linear_addr+temp1
+ sub r10, r2, #32
+
+ pld [r7, r2, lsl #1]
+ vld1.8 {q0, q1}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q4, q5}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q8, q9}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q12, q13}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q14, q15}, [r7], r10
+
+ add r6, r0, r6 @ tiled_addr = tiled_dest+tiled_addr
+
+ vst1.8 {q0, q1}, [r6]!
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]!
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]!
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]!
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2, lsl #1]
+ vld1.8 {q0, q1}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q4, q5}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q8, q9}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q12, q13}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q14, q15}, [r7], r10
+
+ vst1.8 {q0, q1}, [r6]!
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]!
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]!
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]!
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2, lsl #1]
+ vld1.8 {q0, q1}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q4, q5}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q8, q9}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q12, q13}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q14, q15}, [r7], r10
+
+ vst1.8 {q0, q1}, [r6]!
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]!
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]!
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]!
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2, lsl #1]
+ vld1.8 {q0, q1}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q4, q5}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q8, q9}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q12, q13}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q14, q15}, [r7], r10
+
+ vst1.8 {q0, q1}, [r6]!
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]!
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]!
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]!
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2, lsl #1]
+ vld1.8 {q0, q1}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q4, q5}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q8, q9}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q12, q13}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q14, q15}, [r7], r10
+
+ vst1.8 {q0, q1}, [r6]!
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]!
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]!
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]!
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2, lsl #1]
+ vld1.8 {q0, q1}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q4, q5}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q8, q9}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q12, q13}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q14, q15}, [r7], r10
+
+ vst1.8 {q0, q1}, [r6]!
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]!
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]!
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]!
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2, lsl #1]
+ vld1.8 {q0, q1}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q4, q5}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q8, q9}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q12, q13}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q14, q15}, [r7], r10
+
+ vst1.8 {q0, q1}, [r6]!
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]!
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]!
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]!
+ vst1.8 {q14, q15}, [r6]!
+
+ pld [r7, r2, lsl #1]
+ vld1.8 {q0, q1}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q4, q5}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q8, q9}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q12, q13}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q14, q15}, [r7], r10
+
+ vst1.8 {q0, q1}, [r6]!
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]!
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]!
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]!
+ vst1.8 {q14, q15}, [r6]!
+
+ add r4, r4, #64 @ j = j+64
+ cmp r4, r8 @ j<aligned_x_size
+ blt LOOP_ALIGNED_X_SIZE
+
+ add r5, r5, #32 @ i = i+32
+ cmp r5, r9 @ i<aligned_y_size
+ blt LOOP_ALIGNED_Y_SIZE
+
+ cmp r5, r3
+ beq LOOP_LINEAR_Y_SIZE_2_START
+
+LOOP_LINEAR_Y_SIZE_1:
+
+ mov r4, #0 @ j = 0
+LOOP_ALIGNED_X_SIZE_1:
+
+ bl GET_TILED_OFFSET
+
+ mul r10, r2, r5 @ temp1 = linear_x_size*(i)
+ add r7, r1, r4 @ linear_addr = linear_src+j
+ add r7, r7, r10 @ linear_addr = linear_addr+temp1
+ sub r10, r2, #32 @ temp1 = linear_x_size-32
+
+ pld [r7, r2, lsl #1]
+ vld1.8 {q0, q1}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q2, q3}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q4, q5}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q6, q7}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q8, q9}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q10, q11}, [r7], r10
+ pld [r7, r2, lsl #1]
+ vld1.8 {q12, q13}, [r7]!
+ pld [r7, r2, lsl #1]
+ vld1.8 {q14, q15}, [r7], r10
+
+ add r6, r0, r6 @ tiled_addr = tiled_dest+tiled_addr
+ and r11, r5, #0x1F @ temp2 = i&0x1F
+ mov r11, r11, lsl #6 @ temp2 = 64*temp2
+ add r6, r6, r11 @ tiled_addr = tiled_addr+temp2
+
+ vst1.8 {q0, q1}, [r6]!
+ vst1.8 {q2, q3}, [r6]!
+ vst1.8 {q4, q5}, [r6]!
+ vst1.8 {q6, q7}, [r6]!
+ vst1.8 {q8, q9}, [r6]!
+ vst1.8 {q10, q11}, [r6]!
+ vst1.8 {q12, q13}, [r6]!
+ vst1.8 {q14, q15}, [r6]!
+
+ add r4, r4, #64 @ j = j+64
+ cmp r4, r8 @ j<aligned_x_size
+ blt LOOP_ALIGNED_X_SIZE_1
+
+ add r5, r5, #4 @ i = i+4
+ cmp r5, r3 @ i<linear_y_size
+ blt LOOP_LINEAR_Y_SIZE_1
+
+LOOP_LINEAR_Y_SIZE_2_START:
+ cmp r4, r2
+ beq RESTORE_REG
+
+ mov r5, #0 @ i = 0
+LOOP_LINEAR_Y_SIZE_2:
+
+ mov r4, r8 @ j = aligned_x_size
+LOOP_LINEAR_X_SIZE_2:
+
+ bl GET_TILED_OFFSET
+
+ mul r10, r2, r5 @ temp1 = linear_x_size*(i)
+ add r7, r1, r4 @ linear_addr = linear_src+j
+ add r7, r7, r10 @ linear_addr = linear_addr+temp1
+
+ add r6, r0, r6 @ tiled_addr = tiled_dest+tiled_addr
+ and r11, r5, #0x1F @ temp2 = i&0x1F
+ mov r11, r11, lsl #6 @ temp2 = 64*temp2
+ add r6, r6, r11 @ tiled_addr = tiled_addr+temp2
+ and r11, r4, #0x3F @ temp2 = j&0x3F
+ add r6, r6, r11 @ tiled_addr = tiled_addr+temp2
+
+ ldr r10, [r7], r2
+ ldr r11, [r7], r2
+ ldr r12, [r7], r2
+ ldr r14, [r7], r2
+ str r10, [r6], #64
+ str r11, [r6], #64
+ str r12, [r6], #64
+ str r14, [r6], #64
+
+ add r4, r4, #4 @ j = j+4
+ cmp r4, r2 @ j<linear_x_size
+ blt LOOP_LINEAR_X_SIZE_2
+
+ add r5, r5, #4 @ i = i+4
+ cmp r5, r3 @ i<linear_y_size
+ blt LOOP_LINEAR_Y_SIZE_2
+
+RESTORE_REG:
+ ldmfd sp!, {r4-r12,r15} @ restore registers
+
+GET_TILED_OFFSET:
+
+ mov r11, r5, asr #5 @ temp2 = i>>5
+ mov r10, r4, asr #6 @ temp1 = j>>6
+
+ and r12, r11, #0x1 @ if (temp2 & 0x1)
+ cmp r12, #0x1
+ bne GET_TILED_OFFSET_EVEN_FORMULA_1
+
+GET_TILED_OFFSET_ODD_FORMULA:
+ sub r6, r11, #1 @ tiled_addr = temp2-1
+ add r12, r2, #127 @ temp3 = linear_x_size+127
+ bic r12, r12, #0x7F @ temp3 = (temp3 >>7)<<7
+ mov r12, r12, asr #6 @ temp3 = temp3>>6
+ mul r6, r6, r12 @ tiled_addr = tiled_addr*temp3
+ add r6, r6, r10 @ tiled_addr = tiled_addr+temp1
+ add r6, r6, #2 @ tiled_addr = tiled_addr+2
+ bic r12, r10, #0x3 @ temp3 = (temp1>>2)<<2
+ add r6, r6, r12 @ tiled_addr = tiled_addr+temp3
+ mov r6, r6, lsl #11 @ tiled_addr = tiled_addr<<11
+ b GET_TILED_OFFSET_RETURN
+
+GET_TILED_OFFSET_EVEN_FORMULA_1:
+ add r12, r3, #31 @ temp3 = linear_y_size+31
+ bic r12, r12, #0x1F @ temp3 = (temp3>>5)<<5
+ sub r12, r12, #32 @ temp3 = temp3 - 32
+ cmp r5, r12 @ if (i<(temp3-32)) {
+ bge GET_TILED_OFFSET_EVEN_FORMULA_2
+ add r12, r10, #2 @ temp3 = temp1+2
+ bic r12, r12, #3 @ temp3 = (temp3>>2)<<2
+ add r6, r10, r12 @ tiled_addr = temp1+temp3
+ add r12, r2, #127 @ temp3 = linear_x_size+127
+ bic r12, r12, #0x7F @ temp3 = (temp3>>7)<<7
+ mov r12, r12, asr #6 @ temp3 = temp3>>6
+ mul r11, r11, r12 @ tiled_y_index = tiled_y_index*temp3
+ add r6, r6, r11 @ tiled_addr = tiled_addr+tiled_y_index
+ mov r6, r6, lsl #11 @
+ b GET_TILED_OFFSET_RETURN
+
+GET_TILED_OFFSET_EVEN_FORMULA_2:
+ add r12, r2, #127 @ temp3 = linear_x_size+127
+ bic r12, r12, #0x7F @ temp3 = (temp3>>7)<<7
+ mov r12, r12, asr #6 @ temp3 = temp3>>6
+ mul r6, r11, r12 @ tiled_addr = temp2*temp3
+ add r6, r6, r10 @ tiled_addr = tiled_addr+temp3
+ mov r6, r6, lsl #11 @ tiled_addr = tiled_addr<<11@
+
+GET_TILED_OFFSET_RETURN:
+ mov pc, lr
+ .fnend
+
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
index 7d1f027..c15cd41 100644
--- 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
@@ -9,7 +9,7 @@ LOCAL_SRC_FILES := \
LOCAL_MODULE := libsecmfcdecapi
-LOCAL_PRELINK_MODULE := false
+
LOCAL_CFLAGS :=
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
index 508f290..19b63b0 100644
--- 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
@@ -503,173 +503,3 @@ SSBSIP_MFC_ERROR_CODE SsbSipMfcDecGetConfig(void *openHandle, SSBSIP_MFC_DEC_CON
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
index 735da6b..b57346b 100644
--- 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
@@ -9,7 +9,7 @@ LOCAL_SRC_FILES := \
LOCAL_MODULE := libsecmfcencapi
-LOCAL_PRELINK_MODULE := false
+
LOCAL_CFLAGS := -DUSE_FIMC_FRAME_BUFFER
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
index 2c33c5b..9216c7b 100644
--- 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
@@ -167,6 +167,7 @@ SSBSIP_MFC_ERROR_CODE SsbSipMfcEncInit(void *openHandle, void *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_frame_map = mpeg4_arg->FrameMap;
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;
@@ -218,6 +219,7 @@ SSBSIP_MFC_ERROR_CODE SsbSipMfcEncInit(void *openHandle, void *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_frame_map = mpeg4_arg->FrameMap;
EncArg.args.enc_init_mpeg4.in_RC_framerate = h263_arg->FrameRate;
EncArg.args.enc_init_mpeg4.in_RC_bitrate = h263_arg->Bitrate;
@@ -288,6 +290,7 @@ SSBSIP_MFC_ERROR_CODE SsbSipMfcEncInit(void *openHandle, void *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;
+ EncArg.args.enc_init_mpeg4.in_frame_map = mpeg4_arg->FrameMap;
/* rate control*/
EncArg.args.enc_init_h264.in_RC_frm_enable = h264_arg->EnableFRMRateControl;
@@ -422,6 +425,27 @@ SSBSIP_MFC_ERROR_CODE SsbSipMfcEncClose(void *openHandle)
return MFC_RET_OK;
}
+SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetSize(void *openHandle, SSBSIP_MFC_CODEC_TYPE codecType, int nWidth, int nHeight)
+{
+ _MFCLIB *pCTX = (_MFCLIB *)openHandle;
+
+ if (pCTX == NULL)
+ return MFC_RET_INVALID_PARAM;
+
+ if (nWidth <= 0 || nHeight <= 0)
+ return MFC_RET_INVALID_PARAM;
+ pCTX->width = nWidth;
+ pCTX->height = nHeight;
+
+ if ((H264_ENC != codecType) &&
+ (MPEG4_ENC != codecType) &&
+ (H263_ENC != codecType))
+ return MFC_RET_INVALID_PARAM;
+ pCTX->codec_type = codecType;
+
+ return MFC_RET_OK;
+}
+
SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetInBuf(void *openHandle, SSBSIP_MFC_ENC_INPUT_INFO *input_info)
{
int ret_code;
@@ -467,6 +491,9 @@ SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetInBuf(void *openHandle, SSBSIP_MFC_ENC_INPU
input_info->YVirAddr = (void*)pCTX->virFrmBuf.luma;
input_info->CVirAddr = (void*)pCTX->virFrmBuf.chroma;
+ input_info->YSize = aligned_y_size;
+ input_info->CSize = aligned_c_size;
+
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
index e083998..a07739a 100644
--- 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
@@ -23,13 +23,7 @@
#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 MMAP_BUFFER_SIZE_MMAP (70*1024*1024)
#define S5PC110_MFC_DEV_NAME "/dev/s3c-mfc"
@@ -62,6 +56,11 @@ typedef enum {
} SSBSIP_MFC_FORCE_SET_FRAME_TYPE;
typedef enum {
+ NV12_LINEAR = 0,
+ NV12_TILE
+} SSBSIP_MFC_INSTRM_MODE_TYPE;
+
+typedef enum {
MFC_DEC_SETCONF_POST_ENABLE = 1,
MFC_DEC_SETCONF_EXTRA_BUFFER_NUM,
MFC_DEC_SETCONF_DISPLAY_DELAY,
@@ -188,6 +187,7 @@ typedef struct {
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
+ int FrameMap; // [IN] Encoding input mode(tile mode or linear mode)
// H.264 specific parameters
int ProfileIDC; // [IN] profile
@@ -230,6 +230,7 @@ typedef struct {
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
+ int FrameMap; // [IN] Encoding input mode(tile mode or linear mode)
// MPEG4 specific parameters
int ProfileIDC; // [IN] profile
@@ -261,6 +262,7 @@ typedef struct {
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
+ int FrameMap; // [IN] Encoding input mode(tile mode or linear mode)
// H.263 specific parameters
int FrameRate; // [IN] rate control parameter(frame rate)
@@ -285,12 +287,6 @@ 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);
@@ -314,6 +310,7 @@ 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 SsbSipMfcEncSetSize(void *openHandle, SSBSIP_MFC_CODEC_TYPE codecType, int nWidth, int nHeight);
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);
diff --git a/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/color_space_convertor.h b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/color_space_convertor.h
new file mode 100644
index 0000000..4ad5bda
--- /dev/null
+++ b/sec_mm/sec_omx/sec_codecs/video/mfc_c110/include/color_space_convertor.h
@@ -0,0 +1,176 @@
+/*
+ *
+ * Copyright 2011 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 color_space_convertor.h
+ * @brief SEC_OMX specific define.
+ * NV12T(tiled) layout:
+ * Each element is not pixel. It is 64x32 pixel block.
+ * uv pixel block is interleaved as u v u v u v ...
+ * y1 y2 y7 y8 y9 y10 y15 y16
+ * y3 y4 y5 y6 y11 y12 y13 y14
+ * y17 y18 y23 y24 y25 y26 y31 y32
+ * y19 y20 y21 y22 y27 y28 y29 y30
+ * uv1 uv2 uv7 uv8 uv9 uv10 uv15 uv16
+ * uv3 uv4 uv5 uv6 uv11 uv12 uv13 uv14
+ * YUV420Planar(linear) layout:
+ * Each element is not pixel. It is 64x32 pixel block.
+ * y1 y2 y3 y4 y5 y6 y7 y8
+ * y9 y10 y11 y12 y13 y14 y15 y16
+ * y17 y18 y19 y20 y21 y22 y23 y24
+ * y25 y26 y27 y28 y29 y30 y31 y32
+ * u1 u2 u3 u4 u5 u6 u7 u8
+ * v1 v2 v3 v4 v5 v6 v7 v8
+ * YUV420Semiplanar(linear) layout:
+ * Each element is not pixel. It is 64x32 pixel block.
+ * uv pixel block is interleaved as u v u v u v ...
+ * y1 y2 y3 y4 y5 y6 y7 y8
+ * y9 y10 y11 y12 y13 y14 y15 y16
+ * y17 y18 y19 y20 y21 y22 y23 y24
+ * y25 y26 y27 y28 y29 y30 y31 y32
+ * uv1 uv2 uv3 uv4 uv5 uv6 uv7 uv8
+ * uv9 uv10 uv11 uv12 uv13 uv14 uv15 uv16
+ * @author ShinWon Lee (shinwon.lee@samsung.com)
+ * @version 1.0
+ * @history
+ * 2011.7.01 : Create
+ */
+
+#ifndef COLOR_SPACE_CONVERTOR_H_
+#define COLOR_SPACE_CONVERTOR_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Format Conversion API */
+/*--------------------------------------------------------------------------------*/
+/* C Code */
+/*
+ * De-interleaves src to dest1, dest2
+ *
+ * @param dest1
+ * Address of de-interleaved data[out]
+ *
+ * @param dest2
+ * Address of de-interleaved data[out]
+ *
+ * @param src
+ * Address of interleaved data[in]
+ *
+ * @param src_size
+ * Size of interleaved data[in]
+ */
+void csc_deinterleave_memcpy(char *dest1, char *dest2, char *src, int src_size);
+
+/*
+ * Interleaves src1, src2 to dest
+ *
+ * @param dest
+ * Address of interleaved data[out]
+ *
+ * @param src1
+ * Address of de-interleaved data[in]
+ *
+ * @param src2
+ * Address of de-interleaved data[in]
+ *
+ * @param src_size
+ * Size of de-interleaved data[in]
+ */
+void csc_interleave_memcpy(char *dest, char *src1, char *src2, int src_size);
+
+/*
+ * Converts tiled data to linear.
+ * 1. Y of NV12T to Y of YUV420P
+ * 2. Y of NV12T to Y of YUV420S
+ * 3. UV of NV12T to UV of YUV420S
+ *
+ * @param yuv420_dest
+ * Y or UV plane address of YUV420[out]
+ *
+ * @param nv12t_src
+ * Y or UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ */
+void csc_tiled_to_linear(char *yuv420p_y_dest, char *nv12t_y_src, int yuv420p_width, int yuv420p_y_height);
+
+/*
+ * Converts and Deinterleaves tiled data to linear
+ * 1. UV of NV12T to UV of YUV420P
+ *
+ * @param yuv420_u_dest
+ * U plane address of YUV420P[out]
+ *
+ * @param yuv420_v_dest
+ * V plane address of YUV420P[out]
+ *
+ * @param nv12t_src
+ * UV plane address of NV12T[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_uv_height
+ * Height/2 of YUV420[in]
+ */
+void csc_tiled_to_linear_deinterleave(char *yuv420p_u_dest, char *yuv420p_v_dest, char *nv12t_uv_src, int yuv420p_width, int yuv420p_uv_height);
+
+/*
+ * Converts linear data to tiled.
+ * 1. Y of YUV420P to Y of NV12T
+ * 2. Y of YUV420S to Y of NV12T
+ * 3. UV of YUV420S to UV of NV12T
+ *
+ * @param nv12t_dest
+ * Y or UV plane address of NV12T[out]
+ *
+ * @param yuv420_src
+ * Y or UV plane address of YUV420P(S)[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_height
+ * Y: Height of YUV420, UV: Height/2 of YUV420[in]
+ */
+void csc_linear_to_tiled(char *nv12t_dest, char *yuv420p_src, int yuv420p_width, int yuv420p_y_height);
+
+/*
+ * Converts and Interleaves linear to tiled
+ * 1. UV of YUV420P to UV of NV12T
+ *
+ * @param nv12t_uv_dest
+ * UV plane address of NV12T[out]
+ *
+ * @param yuv420p_u_src
+ * U plane address of YUV420P[in]
+ *
+ * @param yuv420p_v_src
+ * V plane address of YUV420P[in]
+ *
+ * @param yuv420_width
+ * Width of YUV420[in]
+ *
+ * @param yuv420_uv_height
+ * Height/2 of YUV420[in]
+ */
+void csc_linear_to_tiled_interleave(char *nv12t_uv_dest, char *yuv420p_u_src, char *yuv420p_v_src, int yuv420p_width, int yuv420p_uv_height);
+
+#endif /*COLOR_SPACE_CONVERTOR_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
index e7e23c3..f4a1f42 100644
--- 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
@@ -117,6 +117,8 @@ typedef struct {
int in_cb_pad_val;
int in_cr_pad_val;
+ int in_frame_map; /* [IN] Encoding input NV12 type linear(0) TILE(1) */
+
unsigned int in_mapped_addr;
mfc_strm_ref_buf_arg_t out_u_addr;
mfc_strm_ref_buf_arg_t out_p_addr;
@@ -158,6 +160,8 @@ typedef struct {
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 */
+ int in_frame_map; /* [IN] Encoding input NV12 type linear(0) TILE(1) */
+
unsigned int in_mapped_addr;
mfc_strm_ref_buf_arg_t out_u_addr;
mfc_strm_ref_buf_arg_t out_p_addr;
diff --git a/sec_mm/sec_omx/sec_omx_component/common/Android.mk b/sec_mm/sec_omx/sec_omx_component/common/Android.mk
index b4d5ca0..ac0516c 100644
--- a/sec_mm/sec_omx/sec_omx_component/common/Android.mk
+++ b/sec_mm/sec_omx/sec_omx_component/common/Android.mk
@@ -8,7 +8,7 @@ LOCAL_SRC_FILES := \
SEC_OMX_Baseport.c \
SEC_OMX_Resourcemanager.c
-LOCAL_PRELINK_MODULE := false
+
LOCAL_MODULE := libsecbasecomponent
LOCAL_CFLAGS :=
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
index d1b224f..170600a 100644
--- 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
@@ -179,7 +179,7 @@ static OMX_ERRORTYPE SEC_OMX_BufferProcessThread(OMX_PTR threadData)
pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
pSECComponent->sec_BufferProcess(pOMXComponent);
- SEC_OSAL_TheadExit(NULL);
+ SEC_OSAL_ThreadExit(NULL);
EXIT:
FunctionOut();
@@ -540,7 +540,7 @@ static OMX_ERRORTYPE SEC_OMX_MessageHandlerThread(OMX_PTR threadData)
}
}
- SEC_OSAL_TheadExit(NULL);
+ SEC_OSAL_ThreadExit(NULL);
EXIT:
FunctionOut();
@@ -1094,7 +1094,7 @@ OMX_ERRORTYPE SEC_OMX_SetParameter(
{
OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE *)ComponentParameterStructure;
OMX_U32 portIndex = bufferSupplier->nPortIndex;
- SEC_OMX_BASEPORT *pSECPort;
+ SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[portIndex];
if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) {
if (pSECPort->portDefinition.bEnabled == OMX_TRUE) {
@@ -1112,7 +1112,6 @@ OMX_ERRORTYPE SEC_OMX_SetParameter(
goto EXIT;
}
- pSECPort = &pSECComponent->pSECPort[portIndex];
if (bufferSupplier->eBufferSupplier == OMX_BufferSupplyUnspecified) {
ret = OMX_ErrorNone;
goto EXIT;
@@ -1215,7 +1214,7 @@ OMX_ERRORTYPE SEC_OMX_GetConfig(
ret = OMX_ErrorInvalidState;
goto EXIT;
}
- ret = OMX_ErrorNone;
+ ret = OMX_ErrorUnsupportedIndex;
EXIT:
FunctionOut();
@@ -1258,7 +1257,7 @@ OMX_ERRORTYPE SEC_OMX_SetConfig(
ret = OMX_ErrorInvalidState;
goto EXIT;
}
- ret = OMX_ErrorNone;
+ ret = OMX_ErrorUnsupportedIndex;
EXIT:
FunctionOut();
@@ -1419,7 +1418,6 @@ OMX_ERRORTYPE SEC_OMX_BaseComponent_Constructor(
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;
@@ -1482,5 +1480,3 @@ EXIT:
return ret;
}
-
-
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
index 0e0f7ea..97e00af 100644
--- 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
@@ -832,6 +832,8 @@ OMX_ERRORTYPE SEC_OMX_Port_Constructor(OMX_HANDLETYPE hComponent)
pSECInputPort->portDefinition.nBufferAlignment = 0;
pSECInputPort->markType.hMarkTargetComponent = NULL;
pSECInputPort->markType.pMarkData = NULL;
+ pSECInputPort->bUseAndroidNativeBuffer = OMX_FALSE;
+ pSECInputPort->bStoreMetaDataInBuffer = OMX_FALSE;
/* Output Port */
pSECOutputPort = &pSECPort[OUTPUT_PORT_INDEX];
@@ -940,8 +942,10 @@ OMX_ERRORTYPE SEC_OMX_Port_Constructor(OMX_HANDLETYPE hComponent)
pSECOutputPort->portDefinition.nBufferAlignment = 0;
pSECOutputPort->markType.hMarkTargetComponent = NULL;
pSECOutputPort->markType.pMarkData = NULL;
+ pSECOutputPort->bUseAndroidNativeBuffer = OMX_FALSE;
+ pSECOutputPort->bStoreMetaDataInBuffer = OMX_FALSE;
- pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
+ pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
pSECComponent->checkTimeStamp.startTimeStamp = 0;
pSECComponent->checkTimeStamp.nStartFlags = 0x0;
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
index f38226b..147f940 100644
--- 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
@@ -62,6 +62,8 @@ typedef struct _SEC_OMX_BASEPORT
OMX_BOOL bIsPortDisabled;
OMX_MARKTYPE markType;
+ OMX_CONFIG_RECTTYPE cropRectangle;
+
/* Tunnel Info */
OMX_HANDLETYPE tunneledComponent;
OMX_U32 tunneledPort;
@@ -70,6 +72,12 @@ typedef struct _SEC_OMX_BASEPORT
OMX_U32 tunnelFlags;
OMX_VIDEO_CONTROLRATETYPE eControlRate;
+
+ /* For Android Native Buffer */
+ OMX_BOOL bUseAndroidNativeBuffer;
+ /* For Android Store Meta Data inBuffer */
+ OMX_BOOL bStoreMetaDataInBuffer;
+ OMX_PTR pIMGGrallocModule;
} SEC_OMX_BASEPORT;
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
index 48705c1..30a1acb 100644
--- 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
@@ -34,15 +34,13 @@
#include "SEC_OMX_Vdec.h"
#include "SEC_OMX_Basecomponent.h"
#include "SEC_OSAL_Thread.h"
+#include "color_space_convertor.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)
{
@@ -68,6 +66,7 @@ inline void SEC_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent)
switch(secOutputPort->portDefinition.format.video.eColorFormat) {
case OMX_COLOR_FormatYUV420Planar:
case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
if (width && height)
secOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
break;
@@ -161,6 +160,8 @@ OMX_ERRORTYPE SEC_OMX_UseBuffer(
goto EXIT;
}
}
+
+ SEC_OSAL_Free(temp_bufferHeader);
ret = OMX_ErrorInsufficientResources;
EXIT:
@@ -257,6 +258,9 @@ OMX_ERRORTYPE SEC_OMX_AllocateBuffer(
goto EXIT;
}
}
+
+ SEC_OSAL_Free(temp_bufferHeader);
+ SEC_OSAL_Free(temp_buffer);
ret = OMX_ErrorInsufficientResources;
EXIT:
@@ -607,10 +611,9 @@ OMX_ERRORTYPE SEC_OutputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent)
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);
@@ -816,13 +819,6 @@ OMX_BOOL SEC_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent)
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;
@@ -833,28 +829,13 @@ OMX_BOOL SEC_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent)
/* 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;
@@ -1063,19 +1044,19 @@ OMX_ERRORTYPE SEC_OMX_VideoDecodeGetParameter(
portDefinition = &pSECPort->portDefinition;
switch (index) {
- case supportFormat_1:
+ case supportFormat_0:
portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
- portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;//OMX_COLOR_FormatYUV420SemiPlanar;
portFormat->xFramerate = portDefinition->format.video.xFramerate;
break;
- case supportFormat_2:
+ case supportFormat_1:
portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
- portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;//OMX_COLOR_FormatYUV420Planar;
portFormat->xFramerate = portDefinition->format.video.xFramerate;
break;
- case supportFormat_3:
+ case supportFormat_2:
portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
- portFormat->eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress;
+ portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12TPhysicalAddress;
portFormat->xFramerate = portDefinition->format.video.xFramerate;
break;
}
@@ -1103,6 +1084,20 @@ OMX_ERRORTYPE SEC_OMX_VideoDecodeGetParameter(
ret = OMX_ErrorNone;
}
break;
+#ifdef USE_ANDROID_EXTENSION
+ case OMX_IndexParamGetAndroidNativeBuffer:
+ {
+ if (OMX_ErrorNone != checkVersionANB(ComponentParameterStructure))
+ goto EXIT;
+
+ if (OUTPUT_PORT_INDEX != checkPortIndexANB(ComponentParameterStructure)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = getAndroidNativeBuffer(hComponent, ComponentParameterStructure);
+ }
+ break;
+#endif
default:
{
ret = SEC_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
@@ -1201,6 +1196,45 @@ OMX_ERRORTYPE SEC_OMX_VideoDecodeSetParameter(
ret = OMX_ErrorNone;
}
break;
+#ifdef USE_ANDROID_EXTENSION
+ case OMX_IndexParamEnableAndroidBuffers:
+ {
+ if (OMX_ErrorNone != checkVersionANB(ComponentParameterStructure))
+ goto EXIT;
+
+ if (OUTPUT_PORT_INDEX != checkPortIndexANB(ComponentParameterStructure)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ ret = enableAndroidNativeBuffer(hComponent, ComponentParameterStructure);
+ if (ret == OMX_ErrorNone) {
+ SEC_OMX_BASECOMPONENT *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ if (pSECPort->bUseAndroidNativeBuffer) {
+ pSECPort->portDefinition.nBufferCountActual = ANDROID_MAX_VIDEO_OUTPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferCountMin = ANDROID_MAX_VIDEO_OUTPUTBUFFER_NUM;
+ } else {
+ pSECPort->portDefinition.nBufferCountActual = MAX_VIDEO_OUTPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferCountMin = MAX_VIDEO_OUTPUTBUFFER_NUM;
+ }
+ }
+ }
+ break;
+ case OMX_IndexParamUseAndroidNativeBuffer:
+ {
+ if (OMX_ErrorNone != checkVersionANB(ComponentParameterStructure))
+ goto EXIT;
+
+ if (OUTPUT_PORT_INDEX != checkPortIndexANB(ComponentParameterStructure)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ ret = useAndroidNativeBuffer(hComponent, ComponentParameterStructure);
+ }
+ break;
+#endif
default:
{
ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
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
index b7f71da..d9e265b 100644
--- 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
@@ -40,14 +40,17 @@
#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_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 DEFAULT_MFC_INPUT_BUFFER_SIZE ((1280 * 720 * 3) / 2)
#define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 1
#define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX 3
+#ifdef USE_ANDROID_EXTENSION
+#define ANDROID_MAX_VIDEO_OUTPUTBUFFER_NUM 1
+#endif
typedef struct
{
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
index f6e6802..1248e5e 100644
--- 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
@@ -7,22 +7,23 @@ LOCAL_SRC_FILES := \
SEC_OMX_H264dec.c \
library_register.c
-LOCAL_PRELINK_MODULE := false
+
LOCAL_MODULE := libOMX.SEC.AVC.Decoder
LOCAL_CFLAGS :=
LOCAL_ARM_MODE := arm
-LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent libsecmfcdecapi
-LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent \
+ libsecmfcdecapi libseccsc
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui libhardware
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 \
+ $(SEC_OMX_COMPONENT)/video/dec
LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include
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
index 5e73b7f..f341130 100644
--- 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
@@ -35,6 +35,7 @@
#include "library_register.h"
#include "SEC_OMX_H264dec.h"
#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
#undef SEC_LOG_TAG
#define SEC_LOG_TAG "SEC_H264_DEC"
@@ -56,8 +57,6 @@ SEC_OMX_VIDEO_PROFILELEVEL supportedAVCProfileLevels[] ={
{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},
@@ -69,8 +68,6 @@ SEC_OMX_VIDEO_PROFILELEVEL supportedAVCProfileLevels[] ={
{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},
@@ -81,9 +78,7 @@ SEC_OMX_VIDEO_PROFILELEVEL supportedAVCProfileLevels[] ={
{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_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel31}};
static int Check_H264_Frame(OMX_U8 *pInputStream, int buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame)
@@ -242,7 +237,7 @@ OMX_ERRORTYPE SEC_MFC_H264Dec_GetParameter(
goto EXIT;
}
- SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_H264_DEC_ROLE);
+ SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPONENT_H264_DEC_ROLE);
}
break;
case OMX_IndexParamVideoProfileLevelQuerySupported:
@@ -401,7 +396,7 @@ OMX_ERRORTYPE SEC_MFC_H264Dec_SetParameter(
goto EXIT;
}
- if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_H264_DEC_ROLE)) {
+ if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPONENT_H264_DEC_ROLE)) {
pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
} else {
ret = OMX_ErrorBadParameter;
@@ -453,10 +448,18 @@ OMX_ERRORTYPE SEC_MFC_H264Dec_SetParameter(
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) {
+
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
- } else if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV422Planar) {
- pSECOutputPort->portDefinition.nBufferSize = width * height * 2;
+ break;
+ default:
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Color format is not support!! use default YUV size!!");
+ ret = OMX_ErrorUnsupportedSetting;
+ break;
}
}
}
@@ -519,6 +522,84 @@ EXIT:
return ret;
}
+OMX_ERRORTYPE SEC_MFC_H264Dec_GetConfig(
+ 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_IndexConfigCommonOutputCrop:
+ {
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+ OMX_CONFIG_RECTTYPE *pSrcRectType = NULL;
+ OMX_CONFIG_RECTTYPE *pDstRectType = NULL;
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+
+ if (pH264Dec->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) {
+ ret = OMX_ErrorNotReady;
+ break;
+ }
+
+ pDstRectType = (OMX_CONFIG_RECTTYPE *)pComponentConfigStructure;
+
+ if ((pDstRectType->nPortIndex != INPUT_PORT_INDEX) &&
+ (pDstRectType->nPortIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[pDstRectType->nPortIndex];
+
+ pSrcRectType = &(pSECPort->cropRectangle);
+
+ pDstRectType->nTop = pSrcRectType->nTop;
+ pDstRectType->nLeft = pSrcRectType->nLeft;
+ pDstRectType->nHeight = pSrcRectType->nHeight;
+ pDstRectType->nWidth = pSrcRectType->nWidth;
+ }
+ break;
+ default:
+ ret = SEC_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE SEC_MFC_H264Dec_SetConfig(
OMX_HANDLETYPE hComponent,
OMX_INDEXTYPE nIndex,
@@ -612,12 +693,21 @@ OMX_ERRORTYPE SEC_MFC_H264Dec_GetExtensionIndex(
goto EXIT;
}
- if (SEC_OSAL_Strcmp(cParameterName, "OMX.SEC.index.ThumbnailMode") == 0) {
+ if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
-
*pIndexType = OMX_IndexVendorThumbnailMode;
-
ret = OMX_ErrorNone;
+#ifdef USE_ANDROID_EXTENSION
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_ANB) == 0) {
+ *pIndexType = OMX_IndexParamEnableAndroidBuffers;
+ ret = OMX_ErrorNone;
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_GET_ANB) == 0) {
+ *pIndexType = OMX_IndexParamGetAndroidNativeBuffer;
+ ret = OMX_ErrorNone;
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_USE_ANB) == 0) {
+ *pIndexType = OMX_IndexParamUseAndroidNativeBuffer;
+ ret = OMX_ErrorNone;
+#endif
} else {
ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
}
@@ -628,7 +718,6 @@ EXIT:
return ret;
}
-
OMX_ERRORTYPE SEC_MFC_H264Dec_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
@@ -642,7 +731,7 @@ OMX_ERRORTYPE SEC_MFC_H264Dec_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U
goto EXIT;
}
if (nIndex == (MAX_COMPONENT_ROLE_NUM-1)) {
- SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_H264_DEC_ROLE);
+ SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPONENT_H264_DEC_ROLE);
ret = OMX_ErrorNone;
} else {
ret = OMX_ErrorNoMore;
@@ -768,6 +857,7 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
SSBSIP_MFC_IMG_RESOLUTION imgResol;
SSBSIP_MFC_CROP_INFORMATION cropInfo;
SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_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",
@@ -781,16 +871,38 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
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;
+ secOutputPort->cropRectangle.nTop = cropInfo.crop_top_offset;
+ secOutputPort->cropRectangle.nLeft = cropInfo.crop_left_offset;
+ secOutputPort->cropRectangle.nWidth = imgResol.width - cropInfo.crop_left_offset - cropInfo.crop_right_offset;
+ secOutputPort->cropRectangle.nHeight = imgResol.height - cropInfo.crop_top_offset - cropInfo.crop_bottom_offset;
+
+ pH264Dec->hMFCH264Handle.bConfiguredMFC = OMX_TRUE;
/** Update Frame Size **/
- if((secInputPort->portDefinition.format.video.nFrameWidth != actualWidth) ||
- (secInputPort->portDefinition.format.video.nFrameHeight != actualHeight)) {
+ if ((cropInfo.crop_left_offset != 0) || (cropInfo.crop_right_offset != 0) ||
+ (cropInfo.crop_top_offset != 0) || (cropInfo.crop_bottom_offset != 0)) {
+ /* change width and height information */
+ secInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ secInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ secInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ secInputPort->portDefinition.format.video.nSliceHeight = ((imgResol.height + 15) & (~15));
+
+ SEC_UpdateFrameSize(pOMXComponent);
+
+ /** Send crop info call back */
+ (*(pSECComponent->pCallbacks->EventHandler))
+ (pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventPortSettingsChanged, /* The command was completed */
+ OMX_DirOutput, /* This is the port index */
+ OMX_IndexConfigCommonOutputCrop,
+ NULL);
+ } else if((secInputPort->portDefinition.format.video.nFrameWidth != imgResol.width) ||
+ (secInputPort->portDefinition.format.video.nFrameHeight != imgResol.height)) {
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.nFrameWidth = imgResol.width;
+ secInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
secInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
secInputPort->portDefinition.format.video.nSliceHeight = ((imgResol.height + 15) & (~15));
@@ -806,7 +918,6 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
NULL);
}
- pH264Dec->hMFCH264Handle.bConfiguredMFC = OMX_TRUE;
#ifdef ADD_SPS_PPS_I_FRAME
ret = OMX_ErrorInputDataDecodeYet;
#else
@@ -824,19 +935,15 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
#ifndef FULL_FRAME_SEARCH
if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
- (pSECComponent->bUseFlagEOF == OMX_FALSE)) {
+ (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) {
+ 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));
+
returnCodec = SsbSipMfcDecExe(pH264Dec->hMFCH264Handle.hMFCHandle, oneFrameSize);
} else {
pOutputData->timeStamp = pInputData->timeStamp;
@@ -849,12 +956,15 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
SSBSIP_MFC_DEC_OUTBUF_STATUS status;
OMX_S32 indexTimestamp = 0;
+ pH264Dec->hMFCH264Handle.indexTimestamp++;
+ pH264Dec->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP;
+
status = SsbSipMfcDecGetOutBuf(pH264Dec->hMFCH264Handle.hMFCHandle, &outputInfo);
- bufWidth = (outputInfo.img_width + 15) & (~15);
- bufHeight = (outputInfo.img_height + 15) & (~15);
+ 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)))) {
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
} else {
@@ -864,27 +974,111 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
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:
+ /** Fill Output Buffer **/
+ int frameSize = bufWidth * bufHeight;
+ int imageSize = outputInfo.img_width * outputInfo.img_height;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ void *pOutputBuf[3];
+
+ int actualWidth = outputInfo.img_width;
+ int actualHeight = outputInfo.img_height;
+ int actualImageSize = imageSize;
+
+ pOutputBuf[0] = (void *)pOutputData->dataBuffer;
+ pOutputBuf[1] = (void *)pOutputData->dataBuffer + actualImageSize;
+ pOutputBuf[2] = (void *)pOutputData->dataBuffer + ((actualImageSize * 5) / 4);
+
+#ifdef USE_ANDROID_EXTENSION
+ if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE) {
+ OMX_U32 retANB = 0;
+ void *pVirAddrs[2];
+ actualWidth = (outputInfo.img_width + 15) & (~15);
+ actualImageSize = actualWidth * actualHeight;
+
+ retANB = getVADDRfromANB (pOutputData->dataBuffer,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameWidth,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameHeight,
+ pVirAddrs);
+ if (retANB != 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Error getVADDRfromANB, Error code:%d", retANB);
+ ret = OMX_ErrorOverflow;
+ goto EXIT;
+ }
+ pOutputBuf[0] = pVirAddrs[0];
+ pOutputBuf[1] = pVirAddrs[1];
+ }
+#endif
+ if ((pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_FALSE) &&
+ (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress))
+ {
+ /* if use Post copy address structure */
+ SEC_OSAL_Memcpy(pOutputBuf[0], &frameSize, sizeof(frameSize));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize), &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2;
- break;
- default:
- pOutputData->dataLen = bufWidth * bufHeight * 2;
- break;
+ } else {
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420P out");
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ actualWidth,
+ actualHeight);
+ csc_tiled_to_linear_deinterleave(
+ (unsigned char *)pOutputBuf[1],
+ (unsigned char *)pOutputBuf[2],
+ (unsigned char *)outputInfo.CVirAddr,
+ actualWidth,
+ actualHeight >> 1);
+ pOutputData->dataLen = actualImageSize * 3 / 2;
+ }
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ default:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420SP out");
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ actualWidth,
+ actualHeight);
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf[1],
+ (unsigned char *)outputInfo.CVirAddr,
+ actualWidth,
+ actualHeight >> 1);
+ pOutputData->dataLen = actualImageSize * 3 / 2;
+ }
+ break;
+ }
}
+#ifdef USE_ANDROID_EXTENSION
+ if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE)
+ putVADDRtoANB(pOutputData->dataBuffer);
+#endif
}
if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS)
pOutputData->dataLen = 0;
if ((status == MFC_GETOUTBUF_DISPLAY_ONLY) ||
- (pSECComponent->getAllDelayBuffer == OMX_TRUE)) {
+ (pSECComponent->getAllDelayBuffer == OMX_TRUE))
ret = OMX_ErrorInputDataDecodeYet;
- }
if(status == MFC_GETOUTBUF_DECODING_ONLY) {
- /* ret = OMX_ErrorInputDataDecodeYet; */
- ret = OMX_ErrorNone;
+ 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 {
+ ret = OMX_ErrorNone;
+ }
goto EXIT;
}
@@ -896,7 +1090,6 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
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;
@@ -908,64 +1101,20 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
} 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;
}
+ pOutputData->dataLen = 0;
- /* ret = OMX_ErrorUndefined; */ /* ????? */
+ /* 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();
@@ -1037,7 +1186,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
goto EXIT;
}
- if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_H264_DEC, componentName) != 0) {
+ if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_H264_DEC, componentName) != 0) {
ret = OMX_ErrorBadParameter;
SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__);
goto EXIT;
@@ -1071,7 +1220,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
SEC_OSAL_Memset(pH264Dec, 0, sizeof(SEC_H264DEC_HANDLE));
pSECComponent->hCodecHandle = (OMX_HANDLETYPE)pH264Dec;
- SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_H264_DEC);
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_H264_DEC);
/* Set componentVersion */
pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
pSECComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
@@ -1120,7 +1269,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
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.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
pSECPort->portDefinition.bEnabled = OMX_TRUE;
for(i = 0; i < ALL_PORT_NUM; i++) {
@@ -1132,6 +1281,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
pOMXComponent->GetParameter = &SEC_MFC_H264Dec_GetParameter;
pOMXComponent->SetParameter = &SEC_MFC_H264Dec_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_H264Dec_GetConfig;
pOMXComponent->SetConfig = &SEC_MFC_H264Dec_SetConfig;
pOMXComponent->GetExtensionIndex = &SEC_MFC_H264Dec_GetExtensionIndex;
pOMXComponent->ComponentRoleEnum = &SEC_MFC_H264Dec_ComponentRoleEnum;
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
index f7bcf25..ef3d672 100644
--- 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
@@ -43,8 +43,8 @@ OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType
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);
+ SEC_OSAL_Strcpy(secComponents[0]->componentName, SEC_OMX_COMPONENT_H264_DEC);
+ SEC_OSAL_Strcpy(secComponents[0]->roles[0], SEC_OMX_COMPONENT_H264_DEC_ROLE);
secComponents[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
EXIT:
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
index cdbfaa4..7a6f7a1 100644
--- 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
@@ -37,8 +37,8 @@
#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"
+#define SEC_OMX_COMPONENT_H264_DEC "OMX.SEC.AVC.Decoder"
+#define SEC_OMX_COMPONENT_H264_DEC_ROLE "video_decoder.avc"
#ifdef __cplusplus
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
index a7a6053..1e7d1e5 100644
--- 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
@@ -7,15 +7,16 @@ LOCAL_SRC_FILES := \
SEC_OMX_Mpeg4dec.c \
library_register.c
-LOCAL_PRELINK_MODULE := false
+
LOCAL_MODULE := libOMX.SEC.M4V.Decoder
LOCAL_CFLAGS :=
LOCAL_ARM_MODE := arm
-LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent libsecmfcdecapi
-LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent \
+ libsecmfcdecapi libseccsc
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui libhardware
LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
$(SEC_OMX_INC)/sec \
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
index 5074214..febb453 100644
--- 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
@@ -35,6 +35,7 @@
#include "library_register.h"
#include "SEC_OMX_Mpeg4dec.h"
#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
#undef SEC_LOG_TAG
#define SEC_LOG_TAG "SEC_MPEG4_DEC"
@@ -181,6 +182,8 @@ static int Check_H263_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag
int len, readStream;
unsigned startCode;
OMX_BOOL bFrameStart = 0;
+ unsigned pTypeMask = 0x03;
+ unsigned pType = 0;
len = 0;
bFrameStart = OMX_FALSE;
@@ -191,9 +194,13 @@ static int Check_H263_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag
startCode = 0xFFFFFFFF;
if (bFrameStart == OMX_FALSE) {
/* find PSC(Picture Start Code) : 0000 0000 0000 0000 1000 00 */
- while (((startCode << 8 >> 10) != 0x20)) {
+ while (((startCode << 8 >> 10) != 0x20) || (pType != 0x02)) {
readStream = *(pInputStream + len);
startCode = (startCode << 8) | readStream;
+
+ readStream = *(pInputStream + len + 1);
+ pType = readStream & pTypeMask;
+
len++;
if (len > buffSize)
goto EXIT;
@@ -202,9 +209,14 @@ static int Check_H263_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag
/* find next PSC */
startCode = 0xFFFFFFFF;
- while (((startCode << 8 >> 10) != 0x20)) {
+ pType = 0;
+ while (((startCode << 8 >> 10) != 0x20) || (pType != 0x02)) {
readStream = *(pInputStream + len);
startCode = (startCode << 8) | readStream;
+
+ readStream = *(pInputStream + len + 1);
+ pType = readStream & pTypeMask;
+
len++;
if (len > buffSize)
goto EXIT;
@@ -340,9 +352,9 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetParameter(
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);
+ SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPONENT_MPEG4_DEC_ROLE);
else
- SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_H263_DEC_ROLE);
+ SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPONENT_H263_DEC_ROLE);
}
break;
case OMX_IndexParamVideoProfileLevelQuerySupported:
@@ -538,10 +550,10 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetParameter(
goto EXIT;
}
- if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_MPEG4_DEC_ROLE)) {
+ if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPONENT_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)) {
+ } else if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPONENT_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 {
@@ -594,10 +606,18 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetParameter(
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) {
+
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
- } else if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV422Planar) {
- pSECOutputPort->portDefinition.nBufferSize = width * height * 2;
+ break;
+ default:
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Color format is not support!! use default YUV size!!");
+ ret = OMX_ErrorUnsupportedSetting;
+ break;
}
}
}
@@ -611,9 +631,8 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetParameter(
OMX_S32 codecType;
ret = SEC_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
- if (ret != OMX_ErrorNone) {
+ if (ret != OMX_ErrorNone)
goto EXIT;
- }
if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) {
ret = OMX_ErrorBadPortIndex;
@@ -677,6 +696,54 @@ EXIT:
return ret;
}
+OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetConfig(
+ 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) {
+ default:
+ ret = SEC_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetConfig(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
@@ -763,12 +830,21 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetExtensionIndex(
goto EXIT;
}
- if (SEC_OSAL_Strcmp(cParameterName, "OMX.SEC.index.ThumbnailMode") == 0) {
+ if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
-
*pIndexType = OMX_IndexVendorThumbnailMode;
-
ret = OMX_ErrorNone;
+#ifdef USE_ANDROID_EXTENSION
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_ANB) == 0) {
+ *pIndexType = OMX_IndexParamEnableAndroidBuffers;
+ ret = OMX_ErrorNone;
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_GET_ANB) == 0) {
+ *pIndexType = OMX_IndexParamGetAndroidNativeBuffer;
+ ret = OMX_ErrorNone;
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_USE_ANB) == 0) {
+ *pIndexType = OMX_IndexParamUseAndroidNativeBuffer;
+ ret = OMX_ErrorNone;
+#endif
} else {
ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
}
@@ -817,9 +893,9 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_ComponentRoleEnum(
codecType = ((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType;
if (codecType == CODEC_TYPE_MPEG4)
- SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_MPEG4_DEC_ROLE);
+ SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPONENT_MPEG4_DEC_ROLE);
else
- SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_H263_DEC_ROLE);
+ SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPONENT_H263_DEC_ROLE);
EXIT:
FunctionOut();
@@ -962,7 +1038,7 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
/** Update Frame Size **/
if ((pInputPort->portDefinition.format.video.nFrameWidth != imgResol.width) ||
- (pInputPort->portDefinition.format.video.nFrameHeight != imgResol.height)) {
+ (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;
@@ -1004,19 +1080,15 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
#ifndef FULL_FRAME_SEARCH
if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
- (pSECComponent->bUseFlagEOF == OMX_FALSE)) {
+ (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) {
+ pSECComponent->timeStamp[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags;
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp));
+
returnCodec = SsbSipMfcDecExe(hMFCHandle, oneFrameSize);
} else {
pOutputData->timeStamp = pInputData->timeStamp;
@@ -1029,12 +1101,15 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
SSBSIP_MFC_DEC_OUTBUF_STATUS status;
OMX_S32 indexTimestamp = 0;
+ pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp++;
+ pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp %= MAX_TIMESTAMP;
+
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)))) {
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
} else {
@@ -1044,27 +1119,111 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
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;
+ /** Fill Output Buffer **/
+ int frameSize = bufWidth * bufHeight;
+ int imageSize = outputInfo.img_width * outputInfo.img_height;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ void *pOutputBuf[3];
+
+ int actualWidth = outputInfo.img_width;
+ int actualHeight = outputInfo.img_height;
+ int actualImageSize = imageSize;
+
+ pOutputBuf[0] = (void *)pOutputData->dataBuffer;
+ pOutputBuf[1] = (void *)pOutputData->dataBuffer + actualImageSize;
+ pOutputBuf[2] = (void *)pOutputData->dataBuffer + ((actualImageSize * 5) / 4);
+
+#ifdef USE_ANDROID_EXTENSION
+ if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE) {
+ OMX_U32 retANB = 0;
+ void *pVirAddrs[2];
+ actualWidth = (outputInfo.img_width + 15) & (~15);
+ actualImageSize = actualWidth * actualHeight;
+
+ retANB = getVADDRfromANB(pOutputData->dataBuffer,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameWidth,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameHeight,
+ pVirAddrs);
+ if (retANB != 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Error getVADDRfromANB, Error code:%d", retANB);
+ ret = OMX_ErrorOverflow;
+ goto EXIT;
+ }
+ pOutputBuf[0] = pVirAddrs[0];
+ pOutputBuf[1] = pVirAddrs[1];
+ }
+#endif
+ if ((pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_FALSE) &&
+ (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress))
+ {
+ /* if use Post copy address structure */
+ SEC_OSAL_Memcpy(pOutputBuf[0], &frameSize, sizeof(frameSize));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize), &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2;
+ } else {
+ switch (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420P out");
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ actualWidth,
+ actualHeight);
+ csc_tiled_to_linear_deinterleave(
+ (unsigned char *)pOutputBuf[1],
+ (unsigned char *)pOutputBuf[2],
+ (unsigned char *)outputInfo.CVirAddr,
+ actualWidth,
+ actualHeight >> 1);
+ pOutputData->dataLen = actualImageSize * 3 / 2;
+ }
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ default:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420SP out");
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ actualWidth,
+ actualHeight);
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf[1],
+ (unsigned char *)outputInfo.CVirAddr,
+ actualWidth,
+ actualHeight >> 1);
+ pOutputData->dataLen = actualImageSize * 3 / 2;
+ }
+ break;
+ }
}
+#ifdef USE_ANDROID_EXTENSION
+ if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE)
+ putVADDRtoANB(pOutputData->dataBuffer);
+#endif
}
if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS)
pOutputData->dataLen = 0;
if ((status == MFC_GETOUTBUF_DISPLAY_ONLY) ||
- (pSECComponent->getAllDelayBuffer == OMX_TRUE)) {
+ (pSECComponent->getAllDelayBuffer == OMX_TRUE))
ret = OMX_ErrorInputDataDecodeYet;
- }
if (status == MFC_GETOUTBUF_DECODING_ONLY) {
- /* ret = OMX_ErrorInputDataDecodeYet; */
- ret = OMX_ErrorNone;
+ 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 {
+ ret = OMX_ErrorNone;
+ }
goto EXIT;
}
@@ -1076,7 +1235,6 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
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;
@@ -1088,64 +1246,20 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
} 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;
}
+ pOutputData->dataLen = 0;
- /* ret = OMX_ErrorUndefined; */ /* ????? */
+ /* 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();
@@ -1218,9 +1332,9 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
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) {
+ if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_MPEG4_DEC, componentName) == 0) {
codecType = CODEC_TYPE_MPEG4;
- } else if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_H263_DEC, componentName) == 0) {
+ } else if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_H263_DEC, componentName) == 0) {
codecType = CODEC_TYPE_H263;
} else {
ret = OMX_ErrorBadParameter;
@@ -1258,9 +1372,9 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
pMpeg4Dec->hMFCMpeg4Handle.codecType = codecType;
if (codecType == CODEC_TYPE_MPEG4)
- SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_MPEG4_DEC);
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_MPEG4_DEC);
else
- SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_H263_DEC);
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_H263_DEC);
/* Set componentVersion */
pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
@@ -1316,7 +1430,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
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.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
pSECPort->portDefinition.bEnabled = OMX_TRUE;
if (codecType == CODEC_TYPE_MPEG4) {
@@ -1337,6 +1451,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
pOMXComponent->GetParameter = &SEC_MFC_Mpeg4Dec_GetParameter;
pOMXComponent->SetParameter = &SEC_MFC_Mpeg4Dec_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_Mpeg4Dec_GetConfig;
pOMXComponent->SetConfig = &SEC_MFC_Mpeg4Dec_SetConfig;
pOMXComponent->GetExtensionIndex = &SEC_MFC_Mpeg4Dec_GetExtensionIndex;
pOMXComponent->ComponentRoleEnum = &SEC_MFC_Mpeg4Dec_ComponentRoleEnum;
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
index 89b856d..02d8d39 100644
--- 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
@@ -47,13 +47,13 @@ OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType
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);
+ SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPONENT_MPEG4_DEC);
+ SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPONENT_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);
+ SEC_OSAL_Strcpy(ppSECComponent[1]->componentName, SEC_OMX_COMPONENT_H263_DEC);
+ SEC_OSAL_Strcpy(ppSECComponent[1]->roles[0], SEC_OMX_COMPONENT_H263_DEC_ROLE);
ppSECComponent[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
EXIT:
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
index e9bcfe8..c3e5b9c 100644
--- 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
@@ -37,12 +37,12 @@
#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"
+#define SEC_OMX_COMPONENT_MPEG4_DEC "OMX.SEC.MPEG4.Decoder"
+#define SEC_OMX_COMPONENT_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"
+#define SEC_OMX_COMPONENT_H263_DEC "OMX.SEC.H263.Decoder"
+#define SEC_OMX_COMPONENT_H263_DEC_ROLE "video_decoder.h263"
#ifdef __cplusplus
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
index eff5dec..310064b 100644
--- 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
@@ -33,15 +33,13 @@
#include "SEC_OMX_Venc.h"
#include "SEC_OMX_Basecomponent.h"
#include "SEC_OSAL_Thread.h"
+#include "color_space_convertor.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)
{
@@ -160,6 +158,8 @@ OMX_ERRORTYPE SEC_OMX_UseBuffer(
goto EXIT;
}
}
+
+ SEC_OSAL_Free(temp_bufferHeader);
ret = OMX_ErrorInsufficientResources;
EXIT:
@@ -256,6 +256,9 @@ OMX_ERRORTYPE SEC_OMX_AllocateBuffer(
goto EXIT;
}
}
+
+ SEC_OSAL_Free(temp_bufferHeader);
+ SEC_OSAL_Free(temp_buffer);
ret = OMX_ErrorInsufficientResources;
EXIT:
@@ -496,10 +499,9 @@ OMX_ERRORTYPE SEC_InputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent)
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);
@@ -738,12 +740,8 @@ OMX_BOOL SEC_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent)
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 ((pSECPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV12TPhysicalAddress) &&
+ (pSECPort->bStoreMetaDataInBuffer == OMX_FALSE)) {
if (flagEOF == OMX_TRUE) {
OMX_U32 width, height;
@@ -756,11 +754,25 @@ OMX_BOOL SEC_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent)
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)));
+ switch (pSECPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ /* Real YUV420P Data */
+ csc_linear_to_tiled(inputData->specificBufferHeader.YVirAddr,
+ checkInputStream, width, height);
+ csc_linear_to_tiled_interleave(inputData->specificBufferHeader.CVirAddr,
+ checkInputStream + (width * height),
+ checkInputStream + (((width * height) * 5) / 4),
+ width, height >> 1);
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ default:
+ SEC_OSAL_Memcpy(inputData->specificBufferHeader.YVirAddr, checkInputStream, (width * height));
+ SEC_OSAL_Memcpy(inputData->specificBufferHeader.CVirAddr, checkInputStream + (width * height), (width * height / 2));
+ break;
+ }
}
}
-#endif
+
inputUseBuffer->dataLen -= copySize;
inputUseBuffer->remainDataLen -= copySize;
inputUseBuffer->usedDataLen += copySize;
@@ -795,10 +807,8 @@ OMX_BOOL SEC_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent)
}
if (inputUseBuffer->remainDataLen == 0) {
-#ifdef S5PC110_ENCODE_IN_DATA_BUFFER
if(flagEOF == OMX_FALSE)
-#endif
- SEC_InputBufferReturn(pOMXComponent);
+ SEC_InputBufferReturn(pOMXComponent);
} else {
inputUseBuffer->dataValid = OMX_TRUE;
}
@@ -864,18 +874,9 @@ OMX_BOOL SEC_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent)
/* 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");
@@ -969,12 +970,12 @@ OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent)
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);
@@ -1084,21 +1085,28 @@ OMX_ERRORTYPE SEC_OMX_VideoEncodeGetParameter(
portDefinition = &pSECPort->portDefinition;
switch (index) {
+ case supportFormat_0:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
case supportFormat_1:
portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;
- portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
break;
case supportFormat_2:
portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
- portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12TPhysicalAddress;
portFormat->xFramerate = portDefinition->format.video.xFramerate;
break;
+#ifdef USE_ANDROID_EXTENSION
case supportFormat_3:
portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
- portFormat->eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress;
- portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ portFormat->eColorFormat = OMX_COLOR_FormatAndroidOpaque;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
break;
+#endif
}
} else if (portIndex == OUTPUT_PORT_INDEX) {
supportFormatNum = OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1;
@@ -1112,7 +1120,7 @@ OMX_ERRORTYPE SEC_OMX_VideoEncodeGetParameter(
portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat;
portFormat->eColorFormat = portDefinition->format.video.eColorFormat;
- portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
}
ret = OMX_ErrorNone;
}
@@ -1137,6 +1145,31 @@ OMX_ERRORTYPE SEC_OMX_VideoEncodeGetParameter(
ret = OMX_ErrorNone;
}
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);
+
+#ifdef USE_ANDROID_EXTENSION
+ if (portIndex == 0 && pSECPort->bStoreMetaDataInBuffer == OMX_TRUE) {
+ portDefinition->nBufferSize = MAX_INPUT_METADATA_BUFFER_SIZE;
+ }
+#endif
+ }
+ break;
default:
{
ret = SEC_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
@@ -1257,6 +1290,21 @@ OMX_ERRORTYPE SEC_OMX_VideoEncodeSetParameter(
}
}
break;
+#ifdef USE_ANDROID_EXTENSION
+ case OMX_IndexParamStoreMetaDataBuffer:
+ {
+ if (OMX_ErrorNone != checkVersionANB(ComponentParameterStructure))
+ goto EXIT;
+
+ if (INPUT_PORT_INDEX != checkPortIndexANB(ComponentParameterStructure)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ ret = enableStoreMetaDataInBuffers(hComponent, ComponentParameterStructure);
+ }
+ break;
+#endif
default:
{
ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
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
index 93d2800..2c9ad54 100644
--- 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
@@ -44,9 +44,18 @@
/* (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2 */
#define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE DEFAULT_VIDEO_INPUT_BUFFER_SIZE
+#ifdef USE_ANDROID_EXTENSION
+#define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 4
+#else
#define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 3
+#endif
#define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX 1
+#ifdef USE_ANDROID_EXTENSION
+// The largest metadata buffer size advertised
+// when metadata buffer mode is used for video encoding
+#define MAX_INPUT_METADATA_BUFFER_SIZE (64)
+#endif
typedef struct
{
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
index 8f25409..a0c59b6 100644
--- 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
@@ -7,22 +7,23 @@ LOCAL_SRC_FILES := \
SEC_OMX_H264enc.c \
library_register.c
-LOCAL_PRELINK_MODULE := false
+
LOCAL_MODULE := libOMX.SEC.AVC.Encoder
LOCAL_CFLAGS :=
LOCAL_ARM_MODE := arm
-LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc libsecosal libsecbasecomponent libsecmfcencapi
-LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc libsecosal libsecbasecomponent \
+ libsecmfcencapi libseccsc
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui libhardware
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 \
+ $(SEC_OMX_COMPONENT)/video/enc
LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include
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
index 239649e..f038e17 100644
--- 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
@@ -35,6 +35,7 @@
#include "library_register.h"
#include "SEC_OMX_H264enc.h"
#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
#undef SEC_LOG_TAG
#define SEC_LOG_TAG "SEC_H264_ENC"
@@ -230,6 +231,26 @@ void Set_H264ENC_Param(SSBSIP_MFC_ENC_H264_PARAM *pH264Arg, SEC_OMX_BASECOMPONEN
pH264Arg->StaticDisable = 1;
pH264Arg->ActivityDisable = 1;
+ switch ((SEC_OMX_COLOR_FORMATTYPE)pSECInputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ pH264Arg->FrameMap = NV12_LINEAR;
+ break;
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ default:
+ pH264Arg->FrameMap = NV12_TILE;
+ break;
+ }
+
+#ifdef USE_ANDROID_EXTENSION
+ if (pSECInputPort->bStoreMetaDataInBuffer != OMX_FALSE) {
+ SEC_OMX_DATA *pInputData = &pSECComponent->processData[INPUT_PORT_INDEX];
+ if(isMetadataBufferTypeGrallocSource(pInputData->dataBuffer) == OMX_TRUE)
+ pH264Arg->FrameMap = NV12_LINEAR;
+ else
+ pH264Arg->FrameMap = NV12_TILE;
+ }
+#endif
+
SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->eControlRate: 0x%x", pSECOutputPort->eControlRate);
switch (pSECOutputPort->eControlRate) {
case OMX_Video_ControlRateDisable:
@@ -307,7 +328,7 @@ OMX_ERRORTYPE SEC_MFC_H264Enc_GetParameter(
goto EXIT;
}
- SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_H264_ENC_ROLE);
+ SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPONENT_H264_ENC_ROLE);
}
break;
case OMX_IndexParamVideoProfileLevelQuerySupported:
@@ -466,7 +487,7 @@ OMX_ERRORTYPE SEC_MFC_H264Enc_SetParameter(
goto EXIT;
}
- if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_H264_ENC_ROLE)) {
+ if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPONENT_H264_ENC_ROLE)) {
pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
} else {
ret = OMX_ErrorBadParameter;
@@ -533,6 +554,54 @@ EXIT:
return ret;
}
+OMX_ERRORTYPE SEC_MFC_H264Enc_GetConfig(
+ 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) {
+ default:
+ ret = SEC_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE SEC_MFC_H264Enc_SetConfig(
OMX_HANDLETYPE hComponent,
OMX_INDEXTYPE nIndex,
@@ -576,6 +645,59 @@ EXIT:
return ret;
}
+OMX_ERRORTYPE SEC_MFC_H264Enc_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;
+ }
+
+#ifdef USE_ANDROID_EXTENSION
+ if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_STORE_METADATA_BUFFER) == 0) {
+ *pIndexType = OMX_IndexParamStoreMetaDataBuffer;
+ ret = OMX_ErrorNone;
+ } else {
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+#else
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+#endif
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE SEC_MFC_H264Enc_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
@@ -589,7 +711,7 @@ OMX_ERRORTYPE SEC_MFC_H264Enc_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U
goto EXIT;
}
if (nIndex == (MAX_COMPONENT_ROLE_NUM-1)) {
- SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_H264_ENC_ROLE);
+ SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPONENT_H264_ENC_ROLE);
ret = OMX_ErrorNone;
} else {
ret = OMX_ErrorNoMore;
@@ -606,6 +728,7 @@ OMX_ERRORTYPE SEC_MFC_H264Enc_Init(OMX_COMPONENTTYPE *pOMXComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
SEC_H264ENC_HANDLE *pH264Enc = NULL;
OMX_PTR hMFCHandle = NULL;
OMX_S32 returnCodec = 0;
@@ -625,13 +748,9 @@ OMX_ERRORTYPE SEC_MFC_H264Enc_Init(OMX_COMPONENTTYPE *pOMXComponent)
}
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;
- }
+ SsbSipMfcEncSetSize(hMFCHandle, H264_ENC,
+ pSECOutputPort->portDefinition.format.video.nFrameWidth,
+ pSECOutputPort->portDefinition.format.video.nFrameHeight);
/* Allocate encoder's input buffer */
returnCodec = SsbSipMfcEncGetInBuf(hMFCHandle, &(pH264Enc->hMFCH264Handle.inputInfo));
@@ -699,6 +818,13 @@ OMX_ERRORTYPE SEC_MFC_H264_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
FunctionIn();
if (pH264Enc->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) {
+ Set_H264ENC_Param(&(pH264Enc->hMFCH264Handle.mfcVideoAvc), pSECComponent);
+ returnCodec = SsbSipMfcEncInit(pH264Enc->hMFCH264Handle.hMFCHandle, &(pH264Enc->hMFCH264Handle.mfcVideoAvc));
+ if (returnCodec != MFC_RET_OK) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
returnCodec = SsbSipMfcEncGetOutBuf(pH264Enc->hMFCH264Handle.hMFCHandle, &outputInfo);
if (returnCodec != MFC_RET_OK)
{
@@ -725,13 +851,13 @@ OMX_ERRORTYPE SEC_MFC_H264_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
pOutputData->dataBuffer = outputInfo.StrmVirAddr;
pOutputData->allocSize = outputInfo.headerSize;
pOutputData->dataLen = outputInfo.headerSize;
- pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->timeStamp = 0;
pOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG;
pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
pH264Enc->hMFCH264Handle.bConfiguredMFC = OMX_TRUE;
- ret = OMX_ErrorNone;
+ ret = OMX_ErrorInputDataEncodeYet;
goto EXIT;
}
@@ -744,8 +870,7 @@ OMX_ERRORTYPE SEC_MFC_H264_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
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;
+ pH264Enc->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP;
if (oneFrameSize <= 0) {
pOutputData->timeStamp = pInputData->timeStamp;
@@ -756,28 +881,28 @@ OMX_ERRORTYPE SEC_MFC_H264_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
}
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
+ if (pSECPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
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;
+#ifdef USE_ANDROID_EXTENSION
+ } else if (pSECPort->bStoreMetaDataInBuffer != OMX_FALSE) {
+ ret = preprocessMetaDataInBuffers(pOMXComponent, pInputData->dataBuffer, pInputInfo);
+ if (ret != OMX_ErrorNone)
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
+ } else {
+ /* Real input data */
+ pInputInfo->YPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YPhyAddr;
+ pInputInfo->CPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CPhyAddr;
+ }
+
+ 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;
}
returnCodec = SsbSipMfcEncExe(pH264Enc->hMFCH264Handle.hMFCHandle);
@@ -786,7 +911,7 @@ OMX_ERRORTYPE SEC_MFC_H264_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
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)))){
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))){
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
} else {
@@ -847,9 +972,14 @@ OMX_ERRORTYPE SEC_MFC_H264Enc_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, SE
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);
+ 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;
@@ -882,7 +1012,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
goto EXIT;
}
- if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_H264_ENC, componentName) != 0) {
+ if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_H264_ENC, componentName) != 0) {
ret = OMX_ErrorBadParameter;
SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__);
goto EXIT;
@@ -916,7 +1046,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
SEC_OSAL_Memset(pH264Enc, 0, sizeof(SEC_H264ENC_HANDLE));
pSECComponent->hCodecHandle = (OMX_HANDLETYPE)pH264Enc;
- SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_H264_ENC);
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_H264_ENC);
/* Set componentVersion */
pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
pSECComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
@@ -947,7 +1077,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
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.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
pSECPort->portDefinition.bEnabled = OMX_TRUE;
/* Output port */
@@ -971,7 +1101,9 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
pOMXComponent->GetParameter = &SEC_MFC_H264Enc_GetParameter;
pOMXComponent->SetParameter = &SEC_MFC_H264Enc_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_H264Enc_GetConfig;
pOMXComponent->SetConfig = &SEC_MFC_H264Enc_SetConfig;
+ pOMXComponent->GetExtensionIndex = &SEC_MFC_H264Enc_GetExtensionIndex;
pOMXComponent->ComponentRoleEnum = &SEC_MFC_H264Enc_ComponentRoleEnum;
pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit;
@@ -995,7 +1127,7 @@ 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;
+ SEC_H264ENC_HANDLE *pH264Enc = NULL;
FunctionIn();
@@ -1009,10 +1141,10 @@ OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent)
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;
+ pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle;
+ if (pH264Enc != NULL) {
+ SEC_OSAL_Free(pH264Enc);
+ pH264Enc = pSECComponent->hCodecHandle = NULL;
}
ret = SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent);
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
index ee1ea0a..247b38b 100644
--- 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
@@ -37,19 +37,19 @@
OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents)
{
- FunctionIn();
+ FunctionIn();
- if (secComponents == NULL)
- goto EXIT;
+ 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;
+ /* component 1 - video decoder H.264 */
+ SEC_OSAL_Strcpy(secComponents[0]->componentName, SEC_OMX_COMPONENT_H264_ENC);
+ SEC_OSAL_Strcpy(secComponents[0]->roles[0], SEC_OMX_COMPONENT_H264_ENC_ROLE);
+ secComponents[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
EXIT:
- FunctionOut();
+ FunctionOut();
- return MAX_COMPONENT_NUM;
+ 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
index 71397ef..6a176ad 100644
--- 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
@@ -37,8 +37,8 @@
#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"
+#define SEC_OMX_COMPONENT_H264_ENC "OMX.SEC.AVC.Encoder"
+#define SEC_OMX_COMPONENT_H264_ENC_ROLE "video_encoder.avc"
#ifdef __cplusplus
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
index e4e4ee4..edefec6 100644
--- 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
@@ -7,15 +7,16 @@ LOCAL_SRC_FILES := \
SEC_OMX_Mpeg4enc.c \
library_register.c
-LOCAL_PRELINK_MODULE := false
+
LOCAL_MODULE := libOMX.SEC.M4V.Encoder
LOCAL_CFLAGS :=
LOCAL_ARM_MODE := arm
-LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc libsecosal libsecbasecomponent libsecmfcencapi
-LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc libsecosal libsecbasecomponent \
+ libsecmfcencapi libseccsc
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui libhardware
LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
$(SEC_OMX_INC)/sec \
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
index 0596c25..8c29d47 100644
--- 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
@@ -36,6 +36,7 @@
#include "library_register.h"
#include "SEC_OMX_Mpeg4enc.h"
#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
#undef SEC_LOG_TAG
#define SEC_LOG_TAG "SEC_MPEG4_ENC"
@@ -214,6 +215,26 @@ void Set_Mpeg4Enc_Param(SSBSIP_MFC_ENC_MPEG4_PARAM *pMpeg4Param, SEC_OMX_BASECOM
pMpeg4Param->NumberBFrames = 0; /* 0(not used) ~ 2 */
pMpeg4Param->DisableQpelME = 1;
+ switch ((SEC_OMX_COLOR_FORMATTYPE)pSECInputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ pMpeg4Param->FrameMap = NV12_LINEAR;
+ break;
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ default:
+ pMpeg4Param->FrameMap = NV12_TILE;
+ break;
+ }
+
+#ifdef USE_ANDROID_EXTENSION
+ if (pSECInputPort->bStoreMetaDataInBuffer != OMX_FALSE) {
+ SEC_OMX_DATA *pInputData = &pSECComponent->processData[INPUT_PORT_INDEX];
+ if(isMetadataBufferTypeGrallocSource(pInputData->dataBuffer) == OMX_TRUE)
+ pMpeg4Param->FrameMap = NV12_LINEAR;
+ else
+ pMpeg4Param->FrameMap = NV12_TILE;
+ }
+#endif
+
SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->eControlRate: 0x%x", pSECOutputPort->eControlRate);
switch (pSECOutputPort->eControlRate) {
case OMX_Video_ControlRateDisable:
@@ -259,6 +280,26 @@ void Set_H263Enc_Param(SSBSIP_MFC_ENC_H263_PARAM *pH263Param, SEC_OMX_BASECOMPON
pH263Param->FrameRate = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16;
+ switch ((SEC_OMX_COLOR_FORMATTYPE)pSECInputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ pH263Param->FrameMap = NV12_LINEAR;
+ break;
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ default:
+ pH263Param->FrameMap = NV12_TILE;
+ break;
+ }
+
+#ifdef USE_ANDROID_EXTENSION
+ if (pSECInputPort->bStoreMetaDataInBuffer != OMX_FALSE) {
+ SEC_OMX_DATA *pInputData = &pSECComponent->processData[INPUT_PORT_INDEX];
+ if(isMetadataBufferTypeGrallocSource(pInputData->dataBuffer) == OMX_TRUE)
+ pH263Param->FrameMap = NV12_LINEAR;
+ else
+ pH263Param->FrameMap = NV12_TILE;
+ }
+#endif
+
SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->eControlRate: 0x%x", pSECOutputPort->eControlRate);
switch (pSECOutputPort->eControlRate) {
case OMX_Video_ControlRateDisable:
@@ -362,9 +403,9 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_GetParameter(
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);
+ SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPONENT_MPEG4_ENC_ROLE);
else
- SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPOMENT_H263_ENC_ROLE);
+ SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPONENT_H263_ENC_ROLE);
}
break;
case OMX_IndexParamVideoProfileLevelQuerySupported:
@@ -560,10 +601,10 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_SetParameter(
goto EXIT;
}
- if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPOMENT_MPEG4_ENC_ROLE)) {
+ if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPONENT_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)) {
+ } else if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPONENT_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 {
@@ -647,6 +688,54 @@ EXIT:
return ret;
}
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_GetConfig(
+ 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) {
+ default:
+ ret = SEC_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_SetConfig(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
@@ -690,6 +779,59 @@ EXIT:
return ret;
}
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_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;
+ }
+
+#ifdef USE_ANDROID_EXTENSION
+ if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_STORE_METADATA_BUFFER) == 0) {
+ *pIndexType = OMX_IndexParamStoreMetaDataBuffer;
+ ret = OMX_ErrorNone;
+ } else {
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+#else
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+#endif
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_ComponentRoleEnum(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_OUT OMX_U8 *cRole,
@@ -728,9 +870,9 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_ComponentRoleEnum(
codecType = ((SEC_MPEG4ENC_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType;
if (codecType == CODEC_TYPE_MPEG4)
- SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_MPEG4_ENC_ROLE);
+ SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPONENT_MPEG4_ENC_ROLE);
else
- SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPOMENT_H263_ENC_ROLE);
+ SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPONENT_H263_ENC_ROLE);
EXIT:
FunctionOut();
@@ -743,7 +885,7 @@ 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_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
OMX_HANDLETYPE hMFCHandle = NULL;
OMX_S32 returnCodec = 0;
@@ -765,15 +907,13 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_Init(OMX_COMPONENTTYPE *pOMXComponent)
/* 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));
+ SsbSipMfcEncSetSize(hMFCHandle, MPEG4_ENC,
+ pSECOutputPort->portDefinition.format.video.nFrameWidth,
+ pSECOutputPort->portDefinition.format.video.nFrameHeight);
} else {
- Set_H263Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam), pSECComponent);
- returnCodec = SsbSipMfcEncInit(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam));
- }
- if (returnCodec != MFC_RET_OK) {
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
+ SsbSipMfcEncSetSize(hMFCHandle, H263_ENC,
+ pSECOutputPort->portDefinition.format.video.nFrameWidth,
+ pSECOutputPort->portDefinition.format.video.nFrameHeight);
}
/* allocate encoder's input buffer */
@@ -840,6 +980,19 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
FunctionIn();
if (pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC == OMX_FALSE) {
+ /* 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;
+ }
+
returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo);
if (returnCodec != MFC_RET_OK)
{
@@ -851,19 +1004,14 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
pOutputData->dataBuffer = outputInfo.StrmVirAddr;
pOutputData->allocSize = outputInfo.headerSize;
pOutputData->dataLen = outputInfo.headerSize;
- pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->timeStamp = 0;
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;
- }
+ ret = OMX_ErrorInputDataEncodeYet;
+ goto EXIT;
}
if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
@@ -875,8 +1023,7 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
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;
+ pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp %= MAX_TIMESTAMP;
if (oneFrameSize <= 0) {
pOutputData->timeStamp = pInputData->timeStamp;
@@ -887,29 +1034,28 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
}
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
+ if (pSECPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
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;
+#ifdef USE_ANDROID_EXTENSION
+ } else if (pSECPort->bStoreMetaDataInBuffer != OMX_FALSE) {
+ ret = preprocessMetaDataInBuffers(pOMXComponent, pInputData->dataBuffer, pInputInfo);
+ if (ret != OMX_ErrorNone)
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
+ } else {
+ /* Real input data */
+ pInputInfo->YPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YPhyAddr;
+ pInputInfo->CPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CPhyAddr;
+ }
+
+ 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;
}
returnCodec = SsbSipMfcEncExe(hMFCHandle);
@@ -919,7 +1065,7 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo);
if ((SsbSipMfcEncGetConfig(hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
- (((indexTimestamp < 0) || (indexTimestamp > MAX_TIMESTAMP)))) {
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
} else {
@@ -976,9 +1122,9 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, S
pOutputData->usedDataLen = 0;
pOutputData->remainDataLen = pOutputData->dataLen;
} else {
- pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
- pSECComponent->callbackData,
- OMX_EventError, ret, 0, NULL);
+ pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventError, ret, 0, NULL);
}
} else {
pInputData->usedDataLen += pInputData->dataLen;
@@ -1013,9 +1159,9 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
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) {
+ if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_MPEG4_ENC, componentName) == 0) {
codecType = CODEC_TYPE_MPEG4;
- } else if (SEC_OSAL_Strcmp(SEC_OMX_COMPOMENT_H263_ENC, componentName) == 0) {
+ } else if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_H263_ENC, componentName) == 0) {
codecType = CODEC_TYPE_H263;
} else {
ret = OMX_ErrorBadParameter;
@@ -1053,9 +1199,9 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
pMpeg4Enc->hMFCMpeg4Handle.codecType = codecType;
if (codecType == CODEC_TYPE_MPEG4)
- SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_MPEG4_ENC);
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_MPEG4_ENC);
else
- SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPOMENT_H263_ENC);
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_H263_ENC);
/* Set componentVersion */
pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
@@ -1089,7 +1235,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
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.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE;
pSECPort->portDefinition.bEnabled = OMX_TRUE;
@@ -1147,7 +1293,9 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
pOMXComponent->GetParameter = &SEC_MFC_Mpeg4Enc_GetParameter;
pOMXComponent->SetParameter = &SEC_MFC_Mpeg4Enc_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_Mpeg4Enc_GetConfig;
pOMXComponent->SetConfig = &SEC_MFC_Mpeg4Enc_SetConfig;
+ pOMXComponent->GetExtensionIndex = &SEC_MFC_Mpeg4Enc_GetExtensionIndex;
pOMXComponent->ComponentRoleEnum = &SEC_MFC_Mpeg4Enc_ComponentRoleEnum;
pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit;
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
index 20e4eb8..467eba2 100644
--- 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
@@ -42,23 +42,23 @@
OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent)
{
- FunctionIn();
+ FunctionIn();
- if (ppSECComponent == NULL)
- goto EXIT;
+ 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 1 - video encoder MPEG4 */
+ SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPONENT_MPEG4_ENC);
+ SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPONENT_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;
+ /* component 2 - video encoder H.263 */
+ SEC_OSAL_Strcpy(ppSECComponent[1]->componentName, SEC_OMX_COMPONENT_H263_ENC);
+ SEC_OSAL_Strcpy(ppSECComponent[1]->roles[0], SEC_OMX_COMPONENT_H263_ENC_ROLE);
+ ppSECComponent[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
EXIT:
- FunctionOut();
- return MAX_COMPONENT_NUM;
+ 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
index 3b23011..e172d51 100644
--- 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
@@ -37,12 +37,12 @@
#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"
+#define SEC_OMX_COMPONENT_MPEG4_ENC "OMX.SEC.MPEG4.Encoder"
+#define SEC_OMX_COMPONENT_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"
+#define SEC_OMX_COMPONENT_H263_ENC "OMX.SEC.H263.Encoder"
+#define SEC_OMX_COMPONENT_H263_ENC_ROLE "video_encoder.h263"
#ifdef __cplusplus
diff --git a/sec_mm/sec_omx/sec_omx_core/Android.mk b/sec_mm/sec_omx/sec_omx_core/Android.mk
index dc2e3ee..3fc0811 100644
--- a/sec_mm/sec_omx/sec_omx_core/Android.mk
+++ b/sec_mm/sec_omx/sec_omx_core/Android.mk
@@ -6,7 +6,7 @@ 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
LOCAL_CFLAGS :=
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
index 10dd94d..10b6144 100644
--- 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
@@ -16,10 +16,10 @@
*/
/*
- * @file SEC_OMX_Def.h
- * @brief SEC_OMX specific define
- * @author SeungBeom Kim (sbcrux.kim@samsung.com)
- * @version 1.0
+ * @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
*/
@@ -43,83 +43,99 @@
#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
+#define MAX_TIMESTAMP 17
+#define MAX_FLAGS 17
+
+#define USE_ANDROID_EXTENSION
typedef enum _SEC_CODEC_TYPE
{
- SW_CODEC,
- HW_VIDEO_CODEC,
- HW_AUDIO_CODEC
+ 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;
+ 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*/
+#define SEC_INDEX_PARAM_ENABLE_THUMBNAIL "OMX.SEC.index.ThumbnailMode"
+ OMX_IndexVendorThumbnailMode = 0x7F000001,
+
+ /* for Android Native Window */
+#define SEC_INDEX_PARAM_ENABLE_ANB "OMX.google.android.index.enableAndroidNativeBuffers"
+ OMX_IndexParamEnableAndroidBuffers = 0x7F000011,
+#define SEC_INDEX_PARAM_GET_ANB "OMX.google.android.index.getAndroidNativeBufferUsage"
+ OMX_IndexParamGetAndroidNativeBuffer = 0x7F000012,
+#define SEC_INDEX_PARAM_USE_ANB "OMX.google.android.index.useAndroidNativeBuffer"
+ OMX_IndexParamUseAndroidNativeBuffer = 0x7F000013,
+ /* for Android Store Metadata Inbuffer */
+#define SEC_INDEX_PARAM_STORE_METADATA_BUFFER "OMX.google.android.index.storeMetaDataInBuffers"
+ OMX_IndexParamStoreMetaDataBuffer = 0x7F000014,
+
+ /* for Android PV OpenCore*/
+ OMX_COMPONENT_CAPABILITY_TYPE_INDEX = 0xFF7A347
} SEC_OMX_INDEXTYPE;
typedef enum _SEC_OMX_ERRORTYPE
{
- OMX_ErrorNoEOF = 0x90000001,
- OMX_ErrorInputDataDecodeYet,
- OMX_ErrorInputDataEncodeYet,
- OMX_ErrorMFCInit
+ 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_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_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
+ OMX_SEC_COLOR_FormatNV12TPhysicalAddress = 0x7F000001, /**< Reserved region for introducing Vendor Extensions */
+ /* for Android Native Window */
+ OMX_SEC_COLOR_FormatANBYUV420SemiPlanar = 0x100,
+ /* for Android surface texture encode */
+ OMX_COLOR_FormatAndroidOpaque = 0x7F000789
}SEC_OMX_COLOR_FORMATTYPE;
typedef enum _SEC_OMX_SUPPORTFORMAT_TYPE
{
- supportFormat_1 = 0x00,
- supportFormat_2,
- supportFormat_3,
- supportFormat_4
+ supportFormat_0 = 0x00,
+ supportFormat_1,
+ supportFormat_2,
+ supportFormat_3
} 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;
+ /* 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
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
index b3bfda6..1debc62 100644
--- 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
@@ -16,10 +16,10 @@
*/
/*
- * @file SEC_OMX_Macros.h
- * @brief Macros
- * @author SeungBeom Kim (sbcrux.kim@samsung.com)
- * @version 1.0
+ * @file SEC_OMX_Macros.h
+ * @brief Macros
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.0
* @history
* 2010.7.15 : Create
*/
@@ -38,15 +38,15 @@
#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)
+#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
diff --git a/sec_mm/sec_omx/sec_osal/Android.mk b/sec_mm/sec_omx/sec_osal/Android.mk
index 9bd2a5d..a98e884 100644
--- a/sec_mm/sec_omx/sec_osal/Android.mk
+++ b/sec_mm/sec_omx/sec_osal/Android.mk
@@ -12,18 +12,28 @@ LOCAL_SRC_FILES := \
SEC_OSAL_Memory.c \
SEC_OSAL_Semaphore.c \
SEC_OSAL_Library.c \
- SEC_OSAL_Log.c
+ SEC_OSAL_Log.c \
+ SEC_OSAL_Buffer.cpp
+
-LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := libsecosal
LOCAL_CFLAGS :=
LOCAL_STATIC_LIBRARIES :=
-LOCAL_SHARED_LIBRARIES := libcutils libutils
+
+LOCAL_SHARED_LIBRARIES := libcutils libutils \
+ libui \
+ libhardware \
+ libandroid_runtime \
+ libsurfaceflinger_client \
+ libbinder \
+ libmedia
LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
$(SEC_OMX_INC)/sec \
- $(SEC_OMX_TOP)/sec_osal
+ $(SEC_OMX_TOP)/sec_osal \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_TOP)/../../include
include $(BUILD_STATIC_LIBRARY)
diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp
new file mode 100644
index 0000000..949fc19
--- /dev/null
+++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp
@@ -0,0 +1,450 @@
+/*
+ *
+ * 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_Buffer.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * Jinsung Yang (jsgood.yang@samsung.com)
+ * @version 1.0.2
+ * @history
+ * 2011.5.15 : Create
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SEC_OMX_Def.h"
+#include "SEC_OMX_Macros.h"
+#include "SEC_OSAL_Memory.h"
+#include "SEC_OSAL_Semaphore.h"
+#include "SEC_OSAL_Buffer.h"
+#include "SEC_OMX_Basecomponent.h"
+
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <ui/android_native_buffer.h>
+#include <ui/GraphicBuffer.h>
+#include <ui/GraphicBufferMapper.h>
+#include <ui/Rect.h>
+#include <media/stagefright/HardwareAPI.h>
+#include <hardware/hardware.h>
+#include <media/stagefright/MetadataBufferType.h>
+#include "hal_public.h"
+
+#define HAL_PIXEL_FORMAT_C110_NV12 0x100
+
+using namespace android;
+
+
+struct AndroidNativeBuffersParams {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_U32 nPortIndex;
+};
+
+#ifdef USE_ANDROID_EXTENSION
+OMX_ERRORTYPE checkVersionANB(OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_VERSIONTYPE* version = NULL;
+
+
+ AndroidNativeBuffersParams *pANBP;
+ pANBP = (AndroidNativeBuffersParams *)ComponentParameterStructure;
+
+ version = (OMX_VERSIONTYPE*)((char*)pANBP + sizeof(OMX_U32));
+ if (*((OMX_U32*)pANBP) <= sizeof(AndroidNativeBuffersParams)) {
+ 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_U32 checkPortIndexANB(OMX_PTR ComponentParameterStructure)
+{
+ AndroidNativeBuffersParams *pANBP;
+ pANBP = (AndroidNativeBuffersParams *)ComponentParameterStructure;
+
+ return pANBP->nPortIndex;
+}
+
+OMX_U32 getMetadataBufferType(const uint8_t *ptr)
+{
+ OMX_U32 type = *(OMX_U32 *) ptr;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "getMetadataBufferType: %ld", type);
+ return type;
+}
+
+OMX_U32 getVADDRfromANB(OMX_PTR pUnreadableBuffer, OMX_U32 Width, OMX_U32 Height, void *pVirAddrs[])
+{
+ OMX_U32 ret = 0;
+ android_native_buffer_t *buf;
+ void *readableBuffer;
+ GraphicBufferMapper &mapper = GraphicBufferMapper::get();
+ Rect bounds(Width, Height);
+
+ FunctionIn();
+
+ buf = (android_native_buffer_t *)pUnreadableBuffer;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pUnreadableBuffer:0x%x, buf:0x%x, buf->handle:0x%x",
+ pUnreadableBuffer, buf, buf->handle);
+
+ ret = mapper.lock(buf->handle, GRALLOC_USAGE_SW_WRITE_OFTEN, bounds, pVirAddrs);
+ if (ret != 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "mapper.lock Error, Error code:%d", ret);
+ }
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_U32 putVADDRtoANB(OMX_PTR pUnreadableBuffer)
+{
+ android_native_buffer_t *buf;
+ void *readableBuffer;
+ int ret = 0;
+ GraphicBufferMapper &mapper = GraphicBufferMapper::get();
+
+ FunctionIn();
+
+ buf = (android_native_buffer_t *)pUnreadableBuffer;
+
+ FunctionOut();
+
+ return mapper.unlock(buf->handle);
+}
+
+OMX_ERRORTYPE enableAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ EnableAndroidNativeBuffersParams *peanbp;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ peanbp = (EnableAndroidNativeBuffersParams *)ComponentParameterStructure;
+ pSECPort = &pSECComponent->pSECPort[peanbp->nPortIndex];
+
+ if (peanbp->enable == OMX_FALSE) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "disable AndroidNativeBuffer");
+ pSECPort->bUseAndroidNativeBuffer = OMX_FALSE;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "enable AndroidNativeBuffer");
+ pSECPort->bUseAndroidNativeBuffer = OMX_TRUE;
+ pSECPort->portDefinition.format.video.eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_SEC_COLOR_FormatANBYUV420SemiPlanar;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE getAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ GetAndroidNativeBufferUsageParams *pganbp;
+
+ FunctionIn();
+
+ pganbp = (GetAndroidNativeBufferUsageParams *)ComponentParameterStructure;
+
+ pganbp->nUsage = GRALLOC_USAGE_SW_WRITE_OFTEN;
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE UseBufferANB(
+ 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;
+ 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;
+ }
+ }
+
+ SEC_OSAL_Free(temp_bufferHeader);
+ ret = OMX_ErrorInsufficientResources;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE useAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_U32 frameSize = 0;
+ OMX_U32 bufWidth, bufHeight;
+ UseAndroidNativeBufferParams *puanbp;
+
+ FunctionIn();
+
+ puanbp = (UseAndroidNativeBufferParams *)ComponentParameterStructure;
+
+ OMX_PTR buffer = (void *)puanbp->nativeBuffer.get();
+ android_native_buffer_t *buf = (android_native_buffer_t *)buffer;
+ bufWidth = ((buf->width + 15) / 16) * 16;
+ bufHeight = ((buf->height + 15) / 16) * 16;
+ frameSize = (bufWidth * bufHeight * 3) / 2;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "buffer:0x%x, buf:0x%x, buf->handle:0x%x", buffer, buf, buf->handle);
+
+ ret = UseBufferANB(hComponent, puanbp->bufferHeader, puanbp->nPortIndex,
+ puanbp->pAppPrivate, frameSize, (OMX_U8 *)buffer);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE enableStoreMetaDataInBuffers(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ StoreMetaDataInBuffersParams *pStoreMetaData;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pStoreMetaData = (StoreMetaDataInBuffersParams*)ComponentParameterStructure;
+ pSECPort = &pSECComponent->pSECPort[pStoreMetaData->nPortIndex];
+
+ if (pStoreMetaData->bStoreMetaData == OMX_FALSE) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "disable StoreMetaDataInBuffers");
+ pSECPort->bStoreMetaDataInBuffer = OMX_FALSE;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "enable StoreMetaDataInBuffers");
+ pSECPort->bStoreMetaDataInBuffer = OMX_TRUE;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_BOOL isMetadataBufferTypeGrallocSource(OMX_BYTE pInputDataBuffer)
+{
+ OMX_U32 type = getMetadataBufferType(pInputDataBuffer);
+
+ if (type == kMetadataBufferTypeGrallocSource)
+ return OMX_TRUE;
+ else
+ return OMX_FALSE;
+}
+
+OMX_ERRORTYPE preprocessMetaDataInBuffers(OMX_HANDLETYPE hComponent, OMX_BYTE pInputDataBuffer, BUFFER_ADDRESS_INFO *pInputInfo)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_U32 type = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+
+ type = getMetadataBufferType(pInputDataBuffer);
+ if (type == kMetadataBufferTypeCameraSource) {
+ SEC_OSAL_Memcpy(&pInputInfo->YPhyAddr, pInputDataBuffer + 4, sizeof(void *));
+ SEC_OSAL_Memcpy(&pInputInfo->CPhyAddr, pInputDataBuffer + 4 + sizeof(void *), sizeof(void *));
+ } else if (type == kMetadataBufferTypeGrallocSource){
+ IMG_gralloc_module_public_t *module = (IMG_gralloc_module_public_t *)pSECPort->pIMGGrallocModule;
+ OMX_PTR pUnreadableBuffer = NULL;
+ OMX_PTR pReadableBuffer = NULL;
+ OMX_PTR pVirAddrs[3];
+ int err = 0;
+
+ pVirAddrs[0] = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YVirAddr;
+ pVirAddrs[1] = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CVirAddr;
+ pVirAddrs[2] = NULL;
+
+ if (module == NULL) {
+ err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&module);
+ if(err) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "hw_get_module failed (err=%d)\n", err);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+ pSECPort->pIMGGrallocModule = (OMX_PTR)module;
+ }
+
+ /**************************************/
+ /* IMG CSC RGB to NV12 */
+ /**************************************/
+ buffer_handle_t buf = *((buffer_handle_t *) (pInputDataBuffer + 4));
+ SEC_OSAL_Log(SEC_LOG_TRACE, "buffer handle %p)\n", buf);
+ err = module->Blit(module, buf, pVirAddrs, HAL_PIXEL_FORMAT_C110_NV12);
+ if(err) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "module->Blit() failed (err=%d)\n", err);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ pInputInfo->YPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YPhyAddr;
+ pInputInfo->CPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CPhyAddr;
+ } else {
+ ret = OMX_ErrorNotImplemented;
+ goto EXIT;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+#endif
diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.h
new file mode 100644
index 0000000..da7e8f3
--- /dev/null
+++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.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_OSAL_Buffer.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * Jinsung Yang (jsgood.yang@samsung.com)
+ * @version 1.0.2
+ * @history
+ * 2011.5.15 : Create
+ */
+
+#ifndef SEC_OSAL_BUFFER
+#define SEC_OSAL_BUFFER
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "OMX_Types.h"
+
+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
+} BUFFER_ADDRESS_INFO;
+
+
+OMX_ERRORTYPE checkVersionANB(OMX_PTR ComponentParameterStructure);
+OMX_U32 checkPortIndexANB(OMX_PTR ComponentParameterStructure);
+OMX_U32 getMetadataBufferType(const uint8_t *ptr);
+OMX_ERRORTYPE enableAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure);
+OMX_ERRORTYPE getAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure);
+OMX_ERRORTYPE useAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure);
+OMX_U32 getVADDRfromANB(OMX_PTR pUnreadableBuffer, OMX_U32 Width, OMX_U32 Height, void *vaddress[]);
+OMX_U32 putVADDRtoANB(OMX_PTR pUnreadableBuffer);
+OMX_ERRORTYPE enableStoreMetaDataInBuffers(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure);
+OMX_BOOL isMetadataBufferTypeGrallocSource(OMX_BYTE pInputDataBuffer);
+OMX_ERRORTYPE preprocessMetaDataInBuffers(OMX_HANDLETYPE hComponent, OMX_BYTE pInputDataBuffer, BUFFER_ADDRESS_INFO *pInputInfo);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h
index 68910cc..3f0938f 100644
--- a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h
+++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h
@@ -33,11 +33,10 @@
#define MAX_QUEUE_ELEMENTS 10
-struct SEC_QElem;
typedef struct _SEC_QElem
{
- void *data;
- struct SEC_QElem *qNext;
+ void *data;
+ struct _SEC_QElem *qNext;
} SEC_QElem;
typedef struct _SEC_QUEUE
diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c
index 17a29a0..94bc9c8 100644
--- a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c
+++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Semaphore.c
@@ -43,7 +43,7 @@ OMX_ERRORTYPE SEC_OSAL_SemaphoreCreate(OMX_HANDLETYPE *semaphoreHandle)
{
sem_t *sema;
- sema = (sem_t *)SEC_OSAL_Malloc(sizeof(sema));
+ sema = (sem_t *)SEC_OSAL_Malloc(sizeof(sem_t));
if (!sema)
return OMX_ErrorInsufficientResources;
diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c
index d488885..3b69d30 100644
--- a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c
+++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.c
@@ -125,7 +125,7 @@ EXIT:
}
-OMX_ERRORTYPE SEC_OSAL_ThreadCancle(OMX_HANDLETYPE threadHandle)
+OMX_ERRORTYPE SEC_OSAL_ThreadCancel(OMX_HANDLETYPE threadHandle)
{
SEC_THREAD_HANDLE_TYPE *thread = (SEC_THREAD_HANDLE_TYPE *)threadHandle;
@@ -140,7 +140,7 @@ OMX_ERRORTYPE SEC_OSAL_ThreadCancle(OMX_HANDLETYPE threadHandle)
return OMX_ErrorNone;
}
-void SEC_OSAL_TheadExit(void *value_ptr)
+void SEC_OSAL_ThreadExit(void *value_ptr)
{
pthread_exit(value_ptr);
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
index b932aef..ccd2609 100644
--- a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h
+++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Thread.h
@@ -37,8 +37,8 @@ extern "C" {
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);
+OMX_ERRORTYPE SEC_OSAL_ThreadCancel(OMX_HANDLETYPE threadHandle);
+void SEC_OSAL_ThreadExit(void *value_ptr);
void SEC_OSAL_SleepMillisec(OMX_U32 ms);
#ifdef __cplusplus
diff --git a/self-extractors/Android.mk b/self-extractors/Android.mk
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/self-extractors/Android.mk
diff --git a/self-extractors/PART1 b/self-extractors/PART1
new file mode 100644
index 0000000..935267e
--- /dev/null
+++ b/self-extractors/PART1
@@ -0,0 +1,12 @@
+#
+# Usage is subject to the enclosed license agreement
+
+echo
+echo The license for this software will now be displayed.
+echo You must agree to this license before using this software.
+echo
+echo -n Press Enter to view the license
+read dummy
+echo
+
+more << __EOF__
diff --git a/self-extractors/PART2 b/self-extractors/PART2
new file mode 100644
index 0000000..30e8d43
--- /dev/null
+++ b/self-extractors/PART2
@@ -0,0 +1,22 @@
+__EOF__
+
+if test $? != 0
+then
+ echo ERROR: Couldn\'t display license file 1>&2
+ exit 1
+fi
+
+echo
+
+echo -n Type \"I ACCEPT\" if you agree to the terms of the license:\
+read typed
+
+if test "$typed" != I\ ACCEPT
+then
+ echo
+ echo You didn\'t accept the license. Extraction aborted.
+ exit 2
+fi
+
+echo
+
diff --git a/self-extractors/PART3 b/self-extractors/PART3
new file mode 100644
index 0000000..6847be5
--- /dev/null
+++ b/self-extractors/PART3
@@ -0,0 +1,12 @@
+
+if test $? != 0
+then
+ echo
+ echo ERROR: Couldn\'t extract files. 1>&2
+ exit 3
+else
+ echo
+ echo Files extracted successfully.
+fi
+exit 0
+
diff --git a/self-extractors/PROLOGUE b/self-extractors/PROLOGUE
new file mode 100644
index 0000000..c856ef1
--- /dev/null
+++ b/self-extractors/PROLOGUE
@@ -0,0 +1,2 @@
+#!/bin/bash
+#
diff --git a/self-extractors/akm/COPYRIGHT b/self-extractors/akm/COPYRIGHT
new file mode 100644
index 0000000..9fdaac3
--- /dev/null
+++ b/self-extractors/akm/COPYRIGHT
@@ -0,0 +1 @@
+# (C) Asahi Kasei Microdevices Corporation
diff --git a/self-extractors/akm/LICENSE b/self-extractors/akm/LICENSE
new file mode 100644
index 0000000..238f2d7
--- /dev/null
+++ b/self-extractors/akm/LICENSE
@@ -0,0 +1,218 @@
+THIS DEVELOPER SOFTWARE LICENSE AGREEMENT (THE "AGREEMENT") IS A LEGALLY
+BINDING AGREEMENT BETWEEN ASAHI KASEI MICRODEVICES CORP. ("LICENSOR") AND
+YOU OR THE LEGAL ENTITY YOU REPRESENT ("You" or its possessive, "Your"). BY
+TYPING "I ACCEPT" WHERE INDICATED YOU ACKNOWLEDGE THAT YOU HAVE READ THIS
+AGREEMENT, UNDERSTAND IT AND AGREE TO BE BOUND BY ITS TERMS AND CONDITIONS. IF
+YOU DO NOT AGREE TO THESE TERMS YOU MUST DISCONTINUE THE INSTALLATION PROCESS
+AND YOU SHALL NOT USE THE SOFTWARE OR RETAIN ANY COPIES OF THE SOFTWARE OR
+DOCUMENTATION. ANY USE OR POSSESSION OF THE SOFTWARE BY YOU IS SUBJECT TO THE
+TERMS AND CONDITIONS SET FORTH IN THIS AGREEMENT. IF THE SOFTWARE IS INSTALLED
+ON A COMPUTER OWNED BY A CORPORATION OR OTHER LEGAL ENTITY, THEN YOU REPRESENT
+AND WARRANT THAT YOU HAVE THE AUTHORITY TO BIND SUCH ENTITY TO THE TERMS AND
+CONDITIONS OF THIS AGREEMENT.
+
+ 1. Special Definitions
+
+ a. The term "Android" means the open source mobile platform, software
+ stack, operating system, middleware, application programming
+ interfaces and mobile applications under the trade-name "Android"
+ distributed at Android.com.
+
+ b. The term "Android Applications" means a software application or
+ open-source contribution developed by You, designed to operate with
+ Android that does not contain or incorporate any of the Software.
+
+ c. The term "Authorized Android Enabled Device" means the device
+ known as Nexus S.
+ The term "Software" means the Licensor's proprietary software and
+ libraries in object code form, designed for use on the Authorized
+ Android Enabled Device.
+
+ d. The term "Authorized Android Enabled Device Software" means a
+ packaged build for Authorized Android Enabled Devices, consisting of
+ files suitable for installation on an Authorized Android Enabled
+ Device using a mechanism such as fastboot mode or recovery mode.
+
+ 2. License Grant
+
+ a. Subject to the terms of this Agreement, Licensor hereby grants to
+ You, free of charge, a non-exclusive, non-sublicensable,
+ non-transferable, limited license, during the term of this Agreement,
+ to download, install and use the Software internally in
+ machine-readable (i.e., object code) form and the Documentation for
+ non-commercial use on an Authorized Android Enabled Device and
+ non-commercial redistribution of the Authorized Android Enabled
+ Device Software (the “Limited Purpose”). You may grant your end users
+ the right to use the Software for the Limited Purpose. The license to
+ the Software granted to You hereunder is solely for the Limited
+ Purpose set forth in this section, and the Software shall not be used
+ for any other purpose.
+
+ 3. Restrictions
+
+ a. Retention of Rights. The entire right, title and interest in the
+ Software shall remain with Licensor and, unless specified in writing
+ hereunder, no rights are granted to any of the Software. Except for
+ the right to use the Software for the Limited Purpose, the delivery
+ of the Software to You does not convey to You any intellectual
+ property rights in the Software, including, but not limited to any
+ rights under any patent, trademark, copyright, or trade secret.
+ Neither the delivery of the Software to You nor any terms set forth
+ herein shall be construed to grant to You, either expressly, by
+ implication or by way of estoppel, any license under any patents or
+ other intellectual property rights covering or relating to any other
+ product or invention or any combination of the Software with any
+ other product. Any rights not expressly granted to You herein are
+ reserved by Licensor.
+
+ b. No Commercialization or Distribution of the Software and
+ Documentation. Except as expressly provided in Section 2 of this
+ Agreement, You shall have no right to (i) copy, disclose, distribute,
+ publically perform, publically display, transfer, alter, modify,
+ translate, disassemble, decompile, reverse engineer, or adapt the
+ Software and Documentation, or any portion thereof, or create any
+ derivative works based thereon; (ii) rent, lease, assign, sublicense,
+ resell, disclose or otherwise transfer the Software and Documentation
+ in whole or in part to any third party (iii) use the Software and
+ Documentation except for the Limited Purpose, (iv) remove or alter
+ any of the copyright or proprietary notices contained in any of the
+ Software and Documentation. For the purposes of clarity, nothing in
+ this Agreement prohibits You from making and distributing Android
+ Applications under commercial or non-commercial terms, provided that
+ You shall not contain, incorporate, and/or compile the Software or
+ any of its derivative works, in whole or in part, into Your Android
+ Applications and/or any software/devices created by You or by third
+ parties acting on Your behalf. You and any such third party shall
+ comply with all of the terms and conditions of this Agreement.
+
+ c. No Reverse Engineering. Except for any portions of the Software
+ provided to You in source code format and except for any third party
+ code distributed with the Software that is licensed under contrary
+ terms, You will not reverse engineer, disassemble,
+ decompile, or translate the Software, or otherwise attempt to derive
+ the source code version of the Software, except if and to the extent
+ expressly permitted under any applicable law.
+
+ d. Third Party Software. You agree that Android may contain third party
+ software. You agree that you may not distribute such third party
+ software for any purpose without appropriate licenses from the
+ applicable third party or parties.
+
+ e. No Transfer or Assignment. You shall not assign any of its rights or
+ obligations under this Agreement. Any attempted assignment in
+ contravention of this Section shall be void.
+
+ 4. Indemnity
+
+ a. You agree to indemnify and hold harmless Licensor and its officers,
+ directors, customers, employees and successors and assigns (each an
+ "Indemnified Party") against any and all claims, demands, causes of
+ action, losses, liabilities, damages, costs and expenses, incurred by
+ the Indemnified Party (including but not limited to costs of defense,
+ investigation and reasonable attorney's fees) arising out of,
+ resulting from or related to (i) any software, products,
+ documentation, content, materials or derivative works created or
+ developed by You using the Software which causes an infringement of
+ any patent, copyright, trademark, trade secret, or other property,
+ publicity or privacy rights of any third parties arising in any
+ jurisdiction anywhere in the world, (ii) the download, distribution,
+ installation, storage, execution, use or transfer of such software,
+ products, documentation, content, materials or derivative works by
+ any person or entity, and/or (iii) any breach of this Agreement by
+ You. If requested by an Indemnified Party, You agree to defend such
+ Indemnified Party in connection with any third party claims, demands,
+ or causes of action resulting from, arising out of or in connection
+ with any of the foregoing.
+
+ 5. Limitation of Liability
+
+ a. TO THE MAXIMUM EXTENT PERMITTED UNDER APPLICABLE LAWS, UNDER NO
+ CIRCUMSTANCES, INCLUDING WITHOUT LIMITATION NEGLIGENCE, SHALL
+ LICENSOR, ITS AFFILIATES AND/OR ITS DIRECTORS, OFFICERS, EMPLOYEES OR
+ AGENTS BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE OR
+ CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO DAMAGES FOR LOSS
+ OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
+ INFORMATION AND THE LIKE) ARISING OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR ANY DOWNLOAD, INSTALLATION OR USE OF, OR INABILITY TO
+ USE, THE SOFTWARE, EVEN IF LICENSOR HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW THE
+ LIMITATION OR EXCLUSION OF LIABILITY FOR INCIDENTAL OR CONSEQUENTIAL
+ DAMAGES SO THE ABOVE LIMITATION OR EXCLUSION MAY NOT APPLY OR MAY BE
+ LIMITED. IN NO EVENT SHALL LICENSOR'S TOTAL AGGREGATE LIABILITY TO
+ YOU FOR ANY AND ALL DAMAGES, LOSSES, CLAIMS AND CAUSES OF ACTIONS
+ (WHETHER IN CONTRACT, TORT, INCLUDING NEGLIGENCE, INDEMNIFICATION OR
+ OTHERWISE) EXCEED ONE HUNDRED U.S. DOLLARS (US$100). THE LIMITATIONS
+ SET FORTH IN THIS PARAGRAPH SHALL BE DEEMED TO APPLY TO THE MAXIMUM
+ EXTENT PERMITTED BY APPLICABLE LAW. THE PARTIES HAVE FULLY CONSIDERED
+ THE FOREGOING ALLOCATION OF RISK AND FIND IT REASONABLE, AND THAT THE
+ FOREGOING LIMITATIONS IN THIS PARAGRAPH ARE AN ESSENTIAL BASIS OF
+ THE BARGAIN BETWEEN THE PARTIES.
+
+ 6. No Warranty
+
+ a. LICENSOR MAKES NO WARRANTIES, EXPRESS OR IMPLIED, WITH RESPECT TO THE
+ SOFTWARE AND DOCUMENTATION PROVIDED UNDER THIS AGREEMENT, INCLUDING
+ BUT NOT LIMITED TO ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR PURPOSE OR AGAINST INFRINGEMENT, OR ANY EXPRESS OR IMPLIED
+ WARRANTY ARISING OUT OF TRADE USAGE OR OUT OF A COURSE OF DEALING OR
+ COURSE OF PERFORMANCE. NOTHING CONTAINED IN THIS AGREEMENT SHALL BE
+ CONSTRUED AS A WARRANTY OR REPRESENTATION BY LICENSOR (I) AS TO THE
+ VALIDITY OR SCOPE OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL
+ PROPERTY RIGHT AND (II) THAT ANY MANUFACTURE OR USE WILL BE FREE FROM
+ INFRINGEMENT OF PATENTS, COPYRIGHTS OR OTHER INTELLECTUAL PROPERTY
+ RIGHTS OF OTHERS, AND IT SHALL BE THE SOLE RESPONSIBILITY OF YOU TO
+ MAKE SUCH DETERMINATION AS IS NECESSARY WITH RESPECT TO THE
+ ACQUISITION OF LICENSES UNDER PATENTS AND OTHER INTELLECTUAL PROPERTY
+ OF THIRD PARTIES. LICENSOR SHALL NOT HAVE ANY OBLIGATION TO PROVIDE
+ ANY TECHNICAL SUPPORT OF THE SOFTWARE UNDER THIS AGREEMENT.
+
+ 7. Term and Termination
+
+ a. This Agreement shall be effective on the date You accept this
+ Agreement and shall remain in effect until terminated as provided
+ herein. You may terminate the Agreement at any time by deleting and
+ destroying all copies of the Software and all related information in
+ Your possession or control. This Agreement terminates immediately and
+ automatically, with or without notice, if You fail to comply with any
+ provision hereof. Additionally, Licensor may at any time terminate
+ this Agreement, without cause, upon notice to You. Upon termination
+ You must delete or destroy all copies of the Software in Your
+ possession, and the license granted to You in this Agreement shall
+ terminate. Sections 3, 4, 5, 6 and 8 shall survive the termination of
+ this Agreement.
+
+ 8. Miscellaneous
+
+ a. Governing Law. This Agreement is governed and interpreted in
+ accordance with the laws of the State of California without giving
+ effect to its conflict of laws provisions. The United Nations
+ Convention on Contracts for the International Sale of Goods is
+ expressly disclaimed and shall not apply. Any claim arising out of or
+ related to this Agreement must be brought exclusively in a federal or
+ state court located in Santa Clara County, California and You consent
+ to the jurisdiction and venue of such courts.
+
+ b. Waiver and Severability. The failure of either party to require
+ performance by the other party of any provision of this Agreement
+ shall not affect the full right to require such performance at any
+ time thereafter; nor shall the waiver by either party of a breach of
+ any provision of this Agreement be taken or held to be a waiver of
+ the provision itself. Severability. If any provision of this
+ Agreement is unenforceable or invalid under any applicable law or is
+ so held by applicable court decision, such unenforceability or
+ invalidity shall not render this Agreement unenforceable or invalid
+ as a whole, and such provision shall be changed and interpreted so as
+ to best accomplish the objectives of such unenforceable or invalid
+ provision within the limits of applicable law or applicable court
+ decisions.
+
+ c. Amendment and Modification. This Agreement and any of its terms and
+ provisions may only be amended, modified, supplemented or waived in a
+ writing signed by both parties hereto.
+
+ d. Compliance with Laws. You shall comply with all applicable laws,
+ rules, and regulations in connection with its activities under this
+ Agreement.
+
+ e. Entire Agreement. This Agreement completely and exclusively states
+ the agreement between You and Licensor regarding this subject matter.
diff --git a/self-extractors/akm/staging/BoardConfigCrespo.mk b/self-extractors/akm/staging/BoardConfigCrespo.mk
new file mode 100644
index 0000000..01a0ff3
--- /dev/null
+++ b/self-extractors/akm/staging/BoardConfigCrespo.mk
@@ -0,0 +1,13 @@
+# 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.
diff --git a/self-extractors/akm/staging/device-crespo.mk b/self-extractors/akm/staging/device-crespo.mk
new file mode 100644
index 0000000..21bcbfa
--- /dev/null
+++ b/self-extractors/akm/staging/device-crespo.mk
@@ -0,0 +1,19 @@
+# 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.
+
+LOCAL_PATH := vendor/akm/crespo
+
+# AKM blob necessary for Nexus S hardware
+PRODUCT_COPY_FILES := \
+ $(LOCAL_PATH)/proprietary/libakm.so:system/vendor/lib/libakm.so
diff --git a/self-extractors/broadcom/COPYRIGHT b/self-extractors/broadcom/COPYRIGHT
new file mode 100644
index 0000000..bf44774
--- /dev/null
+++ b/self-extractors/broadcom/COPYRIGHT
@@ -0,0 +1 @@
+# (C) Broadcom Corporation
diff --git a/self-extractors/broadcom/LICENSE b/self-extractors/broadcom/LICENSE
new file mode 100644
index 0000000..321757f
--- /dev/null
+++ b/self-extractors/broadcom/LICENSE
@@ -0,0 +1,218 @@
+THIS DEVELOPER SOFTWARE LICENSE AGREEMENT (THE "AGREEMENT") IS A LEGALLY
+BINDING AGREEMENT BETWEEN BROADCOM CORPORATION ("LICENSOR") AND
+YOU OR THE LEGAL ENTITY YOU REPRESENT ("You" or its possessive, "Your"). BY
+TYPING "I ACCEPT" WHERE INDICATED YOU ACKNOWLEDGE THAT YOU HAVE READ THIS
+AGREEMENT, UNDERSTAND IT AND AGREE TO BE BOUND BY ITS TERMS AND CONDITIONS. IF
+YOU DO NOT AGREE TO THESE TERMS YOU MUST DISCONTINUE THE INSTALLATION PROCESS
+AND YOU SHALL NOT USE THE SOFTWARE OR RETAIN ANY COPIES OF THE SOFTWARE OR
+DOCUMENTATION. ANY USE OR POSSESSION OF THE SOFTWARE BY YOU IS SUBJECT TO THE
+TERMS AND CONDITIONS SET FORTH IN THIS AGREEMENT. IF THE SOFTWARE IS INSTALLED
+ON A COMPUTER OWNED BY A CORPORATION OR OTHER LEGAL ENTITY, THEN YOU REPRESENT
+AND WARRANT THAT YOU HAVE THE AUTHORITY TO BIND SUCH ENTITY TO THE TERMS AND
+CONDITIONS OF THIS AGREEMENT.
+
+ 1. Special Definitions
+
+ a. The term "Android" means the open source mobile platform, software
+ stack, operating system, middleware, application programming
+ interfaces and mobile applications under the trade-name "Android"
+ distributed at Android.com.
+
+ b. The term "Android Applications" means a software application or
+ open-source contribution developed by You, designed to operate with
+ Android that does not contain or incorporate any of the Software.
+
+ c. The term "Authorized Android Enabled Device" means the device
+ identified on the site from which You downloaded the Software.
+ The term "Software" means the Licensor's proprietary software and
+ libraries in object code form, designed for use on the Authorized
+ Android Enabled Device.
+
+ d. The term "Authorized Android Enabled Device Software" means a
+ packaged build for Authorized Android Enabled Devices, consisting of
+ files suitable for installation on an Authorized Android Enabled
+ Device using a mechanism such as fastboot mode or recovery mode.
+
+ 2. License Grant
+
+ a. Subject to the terms of this Agreement, Licensor hereby grants to
+ You, free of charge, a non-exclusive, non-sublicensable,
+ non-transferable, limited license, during the term of this Agreement,
+ to download, install and use the Software internally in
+ machine-readable (i.e., object code) form and the Documentation for
+ non-commercial use on an Authorized Android Enabled Device and
+ non-commercial redistribution of the Authorized Android Enabled
+ Device Software (the “Limited Purpose”). You may grant your end users
+ the right to use the Software for the Limited Purpose. The license to
+ the Software granted to You hereunder is solely for the Limited
+ Purpose set forth in this section, and the Software shall not be used
+ for any other purpose.
+
+ 3. Restrictions
+
+ a. Retention of Rights. The entire right, title and interest in the
+ Software shall remain with Licensor and, unless specified in writing
+ hereunder, no rights are granted to any of the Software. Except for
+ the right to use the Software for the Limited Purpose, the delivery
+ of the Software to You does not convey to You any intellectual
+ property rights in the Software, including, but not limited to any
+ rights under any patent, trademark, copyright, or trade secret.
+ Neither the delivery of the Software to You nor any terms set forth
+ herein shall be construed to grant to You, either expressly, by
+ implication or by way of estoppel, any license under any patents or
+ other intellectual property rights covering or relating to any other
+ product or invention or any combination of the Software with any
+ other product. Any rights not expressly granted to You herein are
+ reserved by Licensor.
+
+ b. No Commercialization or Distribution of the Software and
+ Documentation. Except as expressly provided in Section 2 of this
+ Agreement, You shall have no right to (i) copy, disclose, distribute,
+ publically perform, publically display, transfer, alter, modify,
+ translate, disassemble, decompile, reverse engineer, or adapt the
+ Software and Documentation, or any portion thereof, or create any
+ derivative works based thereon; (ii) rent, lease, assign, sublicense,
+ resell, disclose or otherwise transfer the Software and Documentation
+ in whole or in part to any third party (iii) use the Software and
+ Documentation except for the Limited Purpose, (iv) remove or alter
+ any of the copyright or proprietary notices contained in any of the
+ Software and Documentation. For the purposes of clarity, nothing in
+ this Agreement prohibits You from making and distributing Android
+ Applications under commercial or non-commercial terms, provided that
+ You shall not contain, incorporate, and/or compile the Software or
+ any of its derivative works, in whole or in part, into Your Android
+ Applications and/or any software/devices created by You or by third
+ parties acting on Your behalf. You and any such third party shall
+ comply with all of the terms and conditions of this Agreement.
+
+ c. No Reverse Engineering. Except for any portions of the Software
+ provided to You in source code format and except for any third party
+ code distributed with the Software that is licensed under contrary
+ terms, You will not reverse engineer, disassemble,
+ decompile, or translate the Software, or otherwise attempt to derive
+ the source code version of the Software, except if and to the extent
+ expressly permitted under any applicable law.
+
+ d. Third Party Software. You agree that Android may contain third party
+ software. You agree that you may not distribute such third party
+ software for any purpose without appropriate licenses from the
+ applicable third party or parties.
+
+ e. No Transfer or Assignment. You shall not assign any of its rights or
+ obligations under this Agreement. Any attempted assignment in
+ contravention of this Section shall be void.
+
+ 4. Indemnity
+
+ a. You agree to indemnify and hold harmless Licensor and its officers,
+ directors, customers, employees and successors and assigns (each an
+ "Indemnified Party") against any and all claims, demands, causes of
+ action, losses, liabilities, damages, costs and expenses, incurred by
+ the Indemnified Party (including but not limited to costs of defense,
+ investigation and reasonable attorney's fees) arising out of,
+ resulting from or related to (i) any software, products,
+ documentation, content, materials or derivative works created or
+ developed by You using the Software which causes an infringement of
+ any patent, copyright, trademark, trade secret, or other property,
+ publicity or privacy rights of any third parties arising in any
+ jurisdiction anywhere in the world, (ii) the download, distribution,
+ installation, storage, execution, use or transfer of such software,
+ products, documentation, content, materials or derivative works by
+ any person or entity, and/or (iii) any breach of this Agreement by
+ You. If requested by an Indemnified Party, You agree to defend such
+ Indemnified Party in connection with any third party claims, demands,
+ or causes of action resulting from, arising out of or in connection
+ with any of the foregoing.
+
+ 5. Limitation of Liability
+
+ a. TO THE MAXIMUM EXTENT PERMITTED UNDER APPLICABLE LAWS, UNDER NO
+ CIRCUMSTANCES, INCLUDING WITHOUT LIMITATION NEGLIGENCE, SHALL
+ LICENSOR, ITS AFFILIATES AND/OR ITS DIRECTORS, OFFICERS, EMPLOYEES OR
+ AGENTS BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE OR
+ CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO DAMAGES FOR LOSS
+ OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
+ INFORMATION AND THE LIKE) ARISING OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR ANY DOWNLOAD, INSTALLATION OR USE OF, OR INABILITY TO
+ USE, THE SOFTWARE, EVEN IF LICENSOR HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW THE
+ LIMITATION OR EXCLUSION OF LIABILITY FOR INCIDENTAL OR CONSEQUENTIAL
+ DAMAGES SO THE ABOVE LIMITATION OR EXCLUSION MAY NOT APPLY OR MAY BE
+ LIMITED. IN NO EVENT SHALL LICENSOR'S TOTAL AGGREGATE LIABILITY TO
+ YOU FOR ANY AND ALL DAMAGES, LOSSES, CLAIMS AND CAUSES OF ACTIONS
+ (WHETHER IN CONTRACT, TORT, INCLUDING NEGLIGENCE, INDEMNIFICATION OR
+ OTHERWISE) EXCEED ONE HUNDRED U.S. DOLLARS (US$100). THE LIMITATIONS
+ SET FORTH IN THIS PARAGRAPH SHALL BE DEEMED TO APPLY TO THE MAXIMUM
+ EXTENT PERMITTED BY APPLICABLE LAW. THE PARTIES HAVE FULLY CONSIDERED
+ THE FOREGOING ALLOCATION OF RISK AND FIND IT REASONABLE, AND THAT THE
+ FOREGOING LIMITATIONS IN THIS PARAGRAPH ARE AN ESSENTIAL BASIS OF
+ THE BARGAIN BETWEEN THE PARTIES.
+
+ 6. No Warranty
+
+ a. LICENSOR MAKES NO WARRANTIES, EXPRESS OR IMPLIED, WITH RESPECT TO THE
+ SOFTWARE AND DOCUMENTATION PROVIDED UNDER THIS AGREEMENT, INCLUDING
+ BUT NOT LIMITED TO ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR PURPOSE OR AGAINST INFRINGEMENT, OR ANY EXPRESS OR IMPLIED
+ WARRANTY ARISING OUT OF TRADE USAGE OR OUT OF A COURSE OF DEALING OR
+ COURSE OF PERFORMANCE. NOTHING CONTAINED IN THIS AGREEMENT SHALL BE
+ CONSTRUED AS A WARRANTY OR REPRESENTATION BY LICENSOR (I) AS TO THE
+ VALIDITY OR SCOPE OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL
+ PROPERTY RIGHT AND (II) THAT ANY MANUFACTURE OR USE WILL BE FREE FROM
+ INFRINGEMENT OF PATENTS, COPYRIGHTS OR OTHER INTELLECTUAL PROPERTY
+ RIGHTS OF OTHERS, AND IT SHALL BE THE SOLE RESPONSIBILITY OF YOU TO
+ MAKE SUCH DETERMINATION AS IS NECESSARY WITH RESPECT TO THE
+ ACQUISITION OF LICENSES UNDER PATENTS AND OTHER INTELLECTUAL PROPERTY
+ OF THIRD PARTIES. LICENSOR SHALL NOT HAVE ANY OBLIGATION TO PROVIDE
+ ANY TECHNICAL SUPPORT OF THE SOFTWARE UNDER THIS AGREEMENT.
+
+ 7. Term and Termination
+
+ a. This Agreement shall be effective on the date You accept this
+ Agreement and shall remain in effect until terminated as provided
+ herein. You may terminate the Agreement at any time by deleting and
+ destroying all copies of the Software and all related information in
+ Your possession or control. This Agreement terminates immediately and
+ automatically, with or without notice, if You fail to comply with any
+ provision hereof. Additionally, Licensor may at any time terminate
+ this Agreement, without cause, upon notice to You. Upon termination
+ You must delete or destroy all copies of the Software in Your
+ possession, and the license granted to You in this Agreement shall
+ terminate. Sections 3, 4, 5, 6 and 8 shall survive the termination of
+ this Agreement.
+
+ 8. Miscellaneous
+
+ a. Governing Law. This Agreement is governed and interpreted in
+ accordance with the laws of the State of California without giving
+ effect to its conflict of laws provisions. The United Nations
+ Convention on Contracts for the International Sale of Goods is
+ expressly disclaimed and shall not apply. Any claim arising out of or
+ related to this Agreement must be brought exclusively in a federal or
+ state court located in Santa Clara County, California and You consent
+ to the jurisdiction and venue of such courts.
+
+ b. Waiver and Severability. The failure of either party to require
+ performance by the other party of any provision of this Agreement
+ shall not affect the full right to require such performance at any
+ time thereafter; nor shall the waiver by either party of a breach of
+ any provision of this Agreement be taken or held to be a waiver of
+ the provision itself. Severability. If any provision of this
+ Agreement is unenforceable or invalid under any applicable law or is
+ so held by applicable court decision, such unenforceability or
+ invalidity shall not render this Agreement unenforceable or invalid
+ as a whole, and such provision shall be changed and interpreted so as
+ to best accomplish the objectives of such unenforceable or invalid
+ provision within the limits of applicable law or applicable court
+ decisions.
+
+ c. Amendment and Modification. This Agreement and any of its terms and
+ provisions may only be amended, modified, supplemented or waived in a
+ writing signed by both parties hereto.
+
+ d. Compliance with Laws. You shall comply with all applicable laws,
+ rules, and regulations in connection with its activities under this
+ Agreement.
+
+ e. Entire Agreement. This Agreement completely and exclusively states
+ the agreement between You and Licensor regarding this subject matter.
diff --git a/self-extractors/broadcom/staging/BoardConfigCrespo.mk b/self-extractors/broadcom/staging/BoardConfigCrespo.mk
new file mode 100644
index 0000000..01a0ff3
--- /dev/null
+++ b/self-extractors/broadcom/staging/BoardConfigCrespo.mk
@@ -0,0 +1,13 @@
+# 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.
diff --git a/self-extractors/broadcom/staging/device-crespo.mk b/self-extractors/broadcom/staging/device-crespo.mk
new file mode 100644
index 0000000..a31bedb
--- /dev/null
+++ b/self-extractors/broadcom/staging/device-crespo.mk
@@ -0,0 +1,21 @@
+# 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.
+
+LOCAL_PATH := vendor/broadcom/crespo
+
+# Broadcom blobs necessary for Nexus S hardware
+PRODUCT_COPY_FILES := \
+ $(LOCAL_PATH)/proprietary/gpsd:system/vendor/bin/gpsd \
+ $(LOCAL_PATH)/proprietary/bcm4329.hcd:system/vendor/firmware/bcm4329.hcd \
+ $(LOCAL_PATH)/proprietary/gps.s5pc110.so:system/vendor/lib/hw/gps.s5pc110.so
diff --git a/self-extractors/cypress/COPYRIGHT b/self-extractors/cypress/COPYRIGHT
new file mode 100644
index 0000000..b3aa5ec
--- /dev/null
+++ b/self-extractors/cypress/COPYRIGHT
@@ -0,0 +1 @@
+# (C) Cypress Semiconductor Corporation. All Rights Reserved.
diff --git a/self-extractors/cypress/LICENSE b/self-extractors/cypress/LICENSE
new file mode 100644
index 0000000..44a23b9
--- /dev/null
+++ b/self-extractors/cypress/LICENSE
@@ -0,0 +1 @@
+CYPRESS LICENSE SHOULD GO HERE
diff --git a/self-extractors/cypress/staging/BoardConfigCrespo.mk b/self-extractors/cypress/staging/BoardConfigCrespo.mk
new file mode 100644
index 0000000..01a0ff3
--- /dev/null
+++ b/self-extractors/cypress/staging/BoardConfigCrespo.mk
@@ -0,0 +1,13 @@
+# 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.
diff --git a/self-extractors/cypress/staging/device-crespo.mk b/self-extractors/cypress/staging/device-crespo.mk
new file mode 100644
index 0000000..9d51f96
--- /dev/null
+++ b/self-extractors/cypress/staging/device-crespo.mk
@@ -0,0 +1,19 @@
+# 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.
+
+LOCAL_PATH := vendor/cypress/crespo
+
+# cypress blob necessary for Nexus S hardware
+PRODUCT_COPY_FILES := \
+ $(LOCAL_PATH)/proprietary/cypress-touchkey.bin:system/vendor/firmware/cypress-touchkey.bin
diff --git a/self-extractors/generate-packages.sh b/self-extractors/generate-packages.sh
new file mode 100755
index 0000000..1a63d1c
--- /dev/null
+++ b/self-extractors/generate-packages.sh
@@ -0,0 +1,138 @@
+#!/bin/sh
+
+# 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.
+
+# 83327 = GRH70B
+# 85442 = GRH78
+# 91927 = GRI16B
+# 101070 = GRI34
+# 102588 = GRI40
+# 117340 = GRJ01
+# 118407 = GRJ06D
+# 120505 = GRJ18
+# 121341 = GRJ22
+# 128018 = IRJ54
+# 128447 = IRJ55
+# 138179 = IRJ89
+# 146649 = IRK18
+# 185907 = IRK76
+ZIP=soju-ota-185907.zip
+BUILD=irk76
+ROOTDEVICE=crespo
+DEVICE=crespo
+MANUFACTURER=samsung
+
+for COMPANY in akm broadcom cypress imgtec nxp samsung widevine
+do
+ echo Processing files from $COMPANY
+ rm -rf tmp
+ FILEDIR=tmp/vendor/$COMPANY/$DEVICE/proprietary
+ mkdir -p $FILEDIR
+ mkdir -p tmp/vendor/$MANUFACTURER/$ROOTDEVICE
+ case $COMPANY in
+ akm)
+ TO_EXTRACT="\
+ system/vendor/lib/libakm.so \
+ "
+ ;;
+ broadcom)
+ TO_EXTRACT="\
+ system/vendor/bin/gpsd \
+ system/vendor/firmware/bcm4329.hcd \
+ system/vendor/lib/hw/gps.s5pc110.so \
+ "
+ ;;
+ cypress)
+ TO_EXTRACT="\
+ system/vendor/firmware/cypress-touchkey.bin \
+ "
+ ;;
+ imgtec)
+ TO_EXTRACT="\
+ system/vendor/bin/pvrsrvinit \
+ system/vendor/lib/egl/libEGL_POWERVR_SGX540_120.so \
+ system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so \
+ system/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so \
+ system/vendor/lib/hw/gralloc.s5pc110.so \
+ system/vendor/lib/libglslcompiler.so \
+ system/vendor/lib/libIMGegl.so \
+ system/vendor/lib/libpvr2d.so \
+ system/vendor/lib/libpvrANDROID_WSEGL.so \
+ system/vendor/lib/libPVRScopeServices.so \
+ system/vendor/lib/libsrv_init.so \
+ system/vendor/lib/libsrv_um.so \
+ system/vendor/lib/libusc.so \
+ "
+ ;;
+ nxp)
+ TO_EXTRACT="\
+ system/vendor/firmware/libpn544_fw.so \
+ "
+ ;;
+ samsung)
+ TO_EXTRACT="\
+ system/lib/libsecril-client.so \
+ system/vendor/lib/libsec-ril.so \
+ "
+ ;;
+ widevine)
+ TO_EXTRACT="\
+ system/etc/permissions/com.google.widevine.software.drm.xml \
+ system/lib/drm/libdrmwvmplugin.so \
+ system/lib/libwvdrm_L3.so \
+ system/lib/libwvm.so \
+ system/lib/libWVStreamControlAPI_L3.so \
+ "
+ ;;
+ esac
+ echo \ \ Extracting files from OTA package
+ for ONE_FILE in $TO_EXTRACT
+ do
+ echo \ \ \ \ Extracting $ONE_FILE
+ unzip -j -o $ZIP $ONE_FILE -d $FILEDIR > /dev/null || echo \ \ \ \ Error extracting $ONE_FILE
+ if test $ONE_FILE = system/vendor/bin/gpsd -o $ONE_FILE = system/vendor/bin/pvrsrvinit
+ then
+ chmod a+x $FILEDIR/$(basename $ONE_FILE) || echo \ \ \ \ Error chmoding $ONE_FILE
+ fi
+ if test $(echo $ONE_FILE | grep \\.apk\$ | wc -l) = 1
+ then
+ echo \ \ \ \ Splitting $ONE_FILE
+ mkdir -p $FILEDIR/$(basename $ONE_FILE).parts || echo \ \ \ \ Error making parts dir for $ONE_FILE
+ unzip $FILEDIR/$(basename $ONE_FILE) -d $FILEDIR/$(basename $ONE_FILE).parts > /dev/null || echo \ \ \ \ Error unzipping $ONE_FILE
+ rm $FILEDIR/$(basename $ONE_FILE) || echo \ \ \ \ Error removing original $ONE_FILE
+ rm -rf $FILEDIR/$(basename $ONE_FILE).parts/META-INF || echo \ \ \ \ Error removing META-INF for $ONE_FILE
+ fi
+ done
+ echo \ \ Setting up $COMPANY-specific makefiles
+ cp -R $COMPANY/staging/* tmp/vendor/$COMPANY/$DEVICE || echo \ \ \ \ Error copying makefiles
+ echo \ \ Setting up shared makefiles
+ cp -R root/* tmp/vendor/$MANUFACTURER/$ROOTDEVICE || echo \ \ \ \ Error copying makefiles
+ echo \ \ Generating self-extracting script
+ SCRIPT=extract-$COMPANY-$DEVICE.sh
+ cat PROLOGUE > tmp/$SCRIPT || echo \ \ \ \ Error generating script
+ cat $COMPANY/COPYRIGHT >> tmp/$SCRIPT || echo \ \ \ \ Error generating script
+ cat PART1 >> tmp/$SCRIPT || echo \ \ \ \ Error generating script
+ cat $COMPANY/LICENSE >> tmp/$SCRIPT || echo \ \ \ \ Error generating script
+ cat PART2 >> tmp/$SCRIPT || echo \ \ \ \ Error generating script
+ echo tail -n +$(expr 2 + $(cat PROLOGUE $COMPANY/COPYRIGHT PART1 $COMPANY/LICENSE PART2 PART3 | wc -l)) \$0 \| tar zxv >> tmp/$SCRIPT || echo \ \ \ \ Error generating script
+ cat PART3 >> tmp/$SCRIPT || echo \ \ \ \ Error generating script
+ (cd tmp ; tar zc --owner=root --group=root vendor/ >> $SCRIPT || echo \ \ \ \ Error generating embedded tgz)
+ chmod a+x tmp/$SCRIPT || echo \ \ \ \ Error generating script
+ ARCHIVE=$COMPANY-$DEVICE-$BUILD-$(md5sum < tmp/$SCRIPT | cut -b -8 | tr -d \\n).tgz
+ rm -f $ARCHIVE
+ echo \ \ Generating final archive
+ (cd tmp ; tar --owner=root --group=root -z -c -f ../$ARCHIVE $SCRIPT || echo \ \ \ \ Error archiving script)
+ rm -rf tmp
+done
diff --git a/self-extractors/imgtec/COPYRIGHT b/self-extractors/imgtec/COPYRIGHT
new file mode 100644
index 0000000..373e4f9
--- /dev/null
+++ b/self-extractors/imgtec/COPYRIGHT
@@ -0,0 +1 @@
+# (C) Imagination Technologies Ltd.
diff --git a/self-extractors/imgtec/LICENSE b/self-extractors/imgtec/LICENSE
new file mode 100644
index 0000000..08ac7aa
--- /dev/null
+++ b/self-extractors/imgtec/LICENSE
@@ -0,0 +1,218 @@
+THIS DEVELOPER SOFTWARE LICENSE AGREEMENT (THE "AGREEMENT") IS A LEGALLY
+BINDING AGREEMENT BETWEEN IMAGINATION TECHNOLOGIES LTD. ("LICENSOR") AND
+YOU OR THE LEGAL ENTITY YOU REPRESENT ("You" or its possessive, "Your"). BY
+TYPING "I ACCEPT" WHERE INDICATED YOU ACKNOWLEDGE THAT YOU HAVE READ THIS
+AGREEMENT, UNDERSTAND IT AND AGREE TO BE BOUND BY ITS TERMS AND CONDITIONS. IF
+YOU DO NOT AGREE TO THESE TERMS YOU MUST DISCONTINUE THE INSTALLATION PROCESS
+AND YOU SHALL NOT USE THE SOFTWARE OR RETAIN ANY COPIES OF THE SOFTWARE OR
+DOCUMENTATION. ANY USE OR POSSESSION OF THE SOFTWARE BY YOU IS SUBJECT TO THE
+TERMS AND CONDITIONS SET FORTH IN THIS AGREEMENT. IF THE SOFTWARE IS INSTALLED
+ON A COMPUTER OWNED BY A CORPORATION OR OTHER LEGAL ENTITY, THEN YOU REPRESENT
+AND WARRANT THAT YOU HAVE THE AUTHORITY TO BIND SUCH ENTITY TO THE TERMS AND
+CONDITIONS OF THIS AGREEMENT.
+
+ 1. Special Definitions
+
+ a. The term "Android" means the open source mobile platform, software
+ stack, operating system, middleware, application programming
+ interfaces and mobile applications under the trade-name "Android"
+ distributed at Android.com.
+
+ b. The term "Android Applications" means a software application or
+ open-source contribution developed by You, designed to operate with
+ Android that does not contain or incorporate any of the Software.
+
+ c. The term "Authorized Android Enabled Device" means the device
+ known as the Nexus S only.
+ The term "Software" means the Licensor's proprietary software and
+ libraries in object code form, designed for use on the Authorized
+ Android Enabled Device.
+
+ d. The term "Authorized Android Enabled Device Software" means a
+ packaged build for Authorized Android Enabled Devices, consisting of
+ files suitable for installation on an Authorized Android Enabled
+ Device using a mechanism such as fastboot mode or recovery mode.
+
+ 2. License Grant
+
+ a. Subject to the terms of this Agreement, Licensor hereby grants to
+ You, free of charge, a non-exclusive, non-sublicensable,
+ non-transferable, limited license, during the term of this Agreement,
+ to download, install and use the Software internally in
+ machine-readable (i.e., object code) form and the Documentation for
+ non-commercial use on an Authorized Android Enabled Device and
+ non-commercial redistribution of the Authorized Android Enabled
+ Device Software (the “Limited Purpose”). You may grant your end users
+ the right to use the Software for the Limited Purpose. The license to
+ the Software granted to You hereunder is solely for the Limited
+ Purpose set forth in this section, and the Software shall not be used
+ for any other purpose.
+
+ 3. Restrictions
+
+ a. Retention of Rights. The entire right, title and interest in the
+ Software shall remain with Licensor and, unless specified in writing
+ hereunder, no rights are granted to any of the Software. Except for
+ the right to use the Software for the Limited Purpose, the delivery
+ of the Software to You does not convey to You any intellectual
+ property rights in the Software, including, but not limited to any
+ rights under any patent, trademark, copyright, or trade secret.
+ Neither the delivery of the Software to You nor any terms set forth
+ herein shall be construed to grant to You, either expressly, by
+ implication or by way of estoppel, any license under any patents or
+ other intellectual property rights covering or relating to any other
+ product or invention or any combination of the Software with any
+ other product. Any rights not expressly granted to You herein are
+ reserved by Licensor.
+
+ b. No Commercialization or Distribution of the Software and
+ Documentation. Except as expressly provided in Section 2 of this
+ Agreement, You shall have no right to (i) copy, disclose, distribute,
+ publically perform, publically display, transfer, alter, modify,
+ translate, disassemble, decompile, reverse engineer, or adapt the
+ Software and Documentation, or any portion thereof, or create any
+ derivative works based thereon; (ii) rent, lease, assign, sublicense,
+ resell, disclose or otherwise transfer the Software and Documentation
+ in whole or in part to any third party (iii) use the Software and
+ Documentation except for the Limited Purpose, (iv) remove or alter
+ any of the copyright or proprietary notices contained in any of the
+ Software and Documentation. For the purposes of clarity, nothing in
+ this Agreement prohibits You from making and distributing Android
+ Applications under commercial or non-commercial terms, provided that
+ You shall not contain, incorporate, and/or compile the Software or
+ any of its derivative works, in whole or in part, into Your Android
+ Applications and/or any software/devices created by You or by third
+ parties acting on Your behalf. You and any such third party shall
+ comply with all of the terms and conditions of this Agreement.
+
+ c. No Reverse Engineering. Except for any portions of the Software
+ provided to You in source code format and except for any third party
+ code distributed with the Software that is licensed under contrary
+ terms, You will not reverse engineer, disassemble,
+ decompile, or translate the Software, or otherwise attempt to derive
+ the source code version of the Software, except if and to the extent
+ expressly permitted under any applicable law.
+
+ d. Third Party Software. You agree that Android may contain third party
+ software. You agree that you may not distribute such third party
+ software for any purpose without appropriate licenses from the
+ applicable third party or parties.
+
+ e. No Transfer or Assignment. You shall not assign any of its rights or
+ obligations under this Agreement. Any attempted assignment in
+ contravention of this Section shall be void.
+
+ 4. Indemnity
+
+ a. You agree to indemnify and hold harmless Licensor and its officers,
+ directors, customers, employees and successors and assigns (each an
+ "Indemnified Party") against any and all claims, demands, causes of
+ action, losses, liabilities, damages, costs and expenses, incurred by
+ the Indemnified Party (including but not limited to costs of defense,
+ investigation and reasonable attorney's fees) arising out of,
+ resulting from or related to (i) any software, products,
+ documentation, content, materials or derivative works created or
+ developed by You using the Software which causes an infringement of
+ any patent, copyright, trademark, trade secret, or other property,
+ publicity or privacy rights of any third parties arising in any
+ jurisdiction anywhere in the world, (ii) the download, distribution,
+ installation, storage, execution, use or transfer of such software,
+ products, documentation, content, materials or derivative works by
+ any person or entity, and/or (iii) any breach of this Agreement by
+ You. If requested by an Indemnified Party, You agree to defend such
+ Indemnified Party in connection with any third party claims, demands,
+ or causes of action resulting from, arising out of or in connection
+ with any of the foregoing.
+
+ 5. Limitation of Liability
+
+ a. TO THE MAXIMUM EXTENT PERMITTED UNDER APPLICABLE LAWS, UNDER NO
+ CIRCUMSTANCES, INCLUDING WITHOUT LIMITATION NEGLIGENCE, SHALL
+ LICENSOR, ITS AFFILIATES AND/OR ITS DIRECTORS, OFFICERS, EMPLOYEES OR
+ AGENTS BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE OR
+ CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO DAMAGES FOR LOSS
+ OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
+ INFORMATION AND THE LIKE) ARISING OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR ANY DOWNLOAD, INSTALLATION OR USE OF, OR INABILITY TO
+ USE, THE SOFTWARE, EVEN IF LICENSOR HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW THE
+ LIMITATION OR EXCLUSION OF LIABILITY FOR INCIDENTAL OR CONSEQUENTIAL
+ DAMAGES SO THE ABOVE LIMITATION OR EXCLUSION MAY NOT APPLY OR MAY BE
+ LIMITED. IN NO EVENT SHALL LICENSOR'S TOTAL AGGREGATE LIABILITY TO
+ YOU FOR ANY AND ALL DAMAGES, LOSSES, CLAIMS AND CAUSES OF ACTIONS
+ (WHETHER IN CONTRACT, TORT, INCLUDING NEGLIGENCE, INDEMNIFICATION OR
+ OTHERWISE) EXCEED ONE HUNDRED U.S. DOLLARS (US$100). THE LIMITATIONS
+ SET FORTH IN THIS PARAGRAPH SHALL BE DEEMED TO APPLY TO THE MAXIMUM
+ EXTENT PERMITTED BY APPLICABLE LAW. THE PARTIES HAVE FULLY CONSIDERED
+ THE FOREGOING ALLOCATION OF RISK AND FIND IT REASONABLE, AND THAT THE
+ FOREGOING LIMITATIONS IN THIS PARAGRAPH ARE AN ESSENTIAL BASIS OF
+ THE BARGAIN BETWEEN THE PARTIES.
+
+ 6. No Warranty
+
+ a. LICENSOR MAKES NO WARRANTIES, EXPRESS OR IMPLIED, WITH RESPECT TO THE
+ SOFTWARE AND DOCUMENTATION PROVIDED UNDER THIS AGREEMENT, INCLUDING
+ BUT NOT LIMITED TO ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR PURPOSE OR AGAINST INFRINGEMENT, OR ANY EXPRESS OR IMPLIED
+ WARRANTY ARISING OUT OF TRADE USAGE OR OUT OF A COURSE OF DEALING OR
+ COURSE OF PERFORMANCE. NOTHING CONTAINED IN THIS AGREEMENT SHALL BE
+ CONSTRUED AS A WARRANTY OR REPRESENTATION BY LICENSOR (I) AS TO THE
+ VALIDITY OR SCOPE OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL
+ PROPERTY RIGHT AND (II) THAT ANY MANUFACTURE OR USE WILL BE FREE FROM
+ INFRINGEMENT OF PATENTS, COPYRIGHTS OR OTHER INTELLECTUAL PROPERTY
+ RIGHTS OF OTHERS, AND IT SHALL BE THE SOLE RESPONSIBILITY OF YOU TO
+ MAKE SUCH DETERMINATION AS IS NECESSARY WITH RESPECT TO THE
+ ACQUISITION OF LICENSES UNDER PATENTS AND OTHER INTELLECTUAL PROPERTY
+ OF THIRD PARTIES. LICENSOR SHALL NOT HAVE ANY OBLIGATION TO PROVIDE
+ ANY TECHNICAL SUPPORT OF THE SOFTWARE UNDER THIS AGREEMENT.
+
+ 7. Term and Termination
+
+ a. This Agreement shall be effective on the date You accept this
+ Agreement and shall remain in effect until terminated as provided
+ herein. You may terminate the Agreement at any time by deleting and
+ destroying all copies of the Software and all related information in
+ Your possession or control. This Agreement terminates immediately and
+ automatically, with or without notice, if You fail to comply with any
+ provision hereof. Additionally, Licensor may at any time terminate
+ this Agreement, without cause, upon notice to You. Upon termination
+ You must delete or destroy all copies of the Software in Your
+ possession, and the license granted to You in this Agreement shall
+ terminate. Sections 3, 4, 5, 6 and 8 shall survive the termination of
+ this Agreement.
+
+ 8. Miscellaneous
+
+ a. Governing Law. This Agreement is governed and interpreted in
+ accordance with the laws of the State of California without giving
+ effect to its conflict of laws provisions. The United Nations
+ Convention on Contracts for the International Sale of Goods is
+ expressly disclaimed and shall not apply. Any claim arising out of or
+ related to this Agreement must be brought exclusively in a federal or
+ state court located in Santa Clara County, California and You consent
+ to the jurisdiction and venue of such courts.
+
+ b. Waiver and Severability. The failure of either party to require
+ performance by the other party of any provision of this Agreement
+ shall not affect the full right to require such performance at any
+ time thereafter; nor shall the waiver by either party of a breach of
+ any provision of this Agreement be taken or held to be a waiver of
+ the provision itself. Severability. If any provision of this
+ Agreement is unenforceable or invalid under any applicable law or is
+ so held by applicable court decision, such unenforceability or
+ invalidity shall not render this Agreement unenforceable or invalid
+ as a whole, and such provision shall be changed and interpreted so as
+ to best accomplish the objectives of such unenforceable or invalid
+ provision within the limits of applicable law or applicable court
+ decisions.
+
+ c. Amendment and Modification. This Agreement and any of its terms and
+ provisions may only be amended, modified, supplemented or waived in a
+ writing signed by both parties hereto.
+
+ d. Compliance with Laws. You shall comply with all applicable laws,
+ rules, and regulations in connection with its activities under this
+ Agreement.
+
+ e. Entire Agreement. This Agreement completely and exclusively states
+ the agreement between You and Licensor regarding this subject matter.
diff --git a/self-extractors/imgtec/staging/BoardConfigCrespo.mk b/self-extractors/imgtec/staging/BoardConfigCrespo.mk
new file mode 100644
index 0000000..01a0ff3
--- /dev/null
+++ b/self-extractors/imgtec/staging/BoardConfigCrespo.mk
@@ -0,0 +1,13 @@
+# 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.
diff --git a/self-extractors/imgtec/staging/device-crespo.mk b/self-extractors/imgtec/staging/device-crespo.mk
new file mode 100644
index 0000000..a79deaf
--- /dev/null
+++ b/self-extractors/imgtec/staging/device-crespo.mk
@@ -0,0 +1,31 @@
+# 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.
+
+LOCAL_PATH := vendor/imgtec/crespo
+
+# Imgtec blobs necessary for Nexus S hardware
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/proprietary/pvrsrvinit:system/vendor/bin/pvrsrvinit \
+ $(LOCAL_PATH)/proprietary/libEGL_POWERVR_SGX540_120.so:system/vendor/lib/egl/libEGL_POWERVR_SGX540_120.so \
+ $(LOCAL_PATH)/proprietary/libGLESv1_CM_POWERVR_SGX540_120.so:system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so \
+ $(LOCAL_PATH)/proprietary/libGLESv2_POWERVR_SGX540_120.so:system/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so \
+ $(LOCAL_PATH)/proprietary/gralloc.s5pc110.so:system/vendor/lib/hw/gralloc.s5pc110.so \
+ $(LOCAL_PATH)/proprietary/libglslcompiler.so:system/vendor/lib/libglslcompiler.so \
+ $(LOCAL_PATH)/proprietary/libIMGegl.so:system/vendor/lib/libIMGegl.so \
+ $(LOCAL_PATH)/proprietary/libpvr2d.so:system/vendor/lib/libpvr2d.so \
+ $(LOCAL_PATH)/proprietary/libpvrANDROID_WSEGL.so:system/vendor/lib/libpvrANDROID_WSEGL.so \
+ $(LOCAL_PATH)/proprietary/libPVRScopeServices.so:system/vendor/lib/libPVRScopeServices.so \
+ $(LOCAL_PATH)/proprietary/libsrv_init.so:system/vendor/lib/libsrv_init.so \
+ $(LOCAL_PATH)/proprietary/libsrv_um.so:system/vendor/lib/libsrv_um.so \
+ $(LOCAL_PATH)/proprietary/libusc.so:system/vendor/lib/libusc.so
diff --git a/self-extractors/nxp/COPYRIGHT b/self-extractors/nxp/COPYRIGHT
new file mode 100644
index 0000000..446c4f7
--- /dev/null
+++ b/self-extractors/nxp/COPYRIGHT
@@ -0,0 +1 @@
+# (C) NXP Semiconductors Netherlands B.V.
diff --git a/self-extractors/nxp/LICENSE b/self-extractors/nxp/LICENSE
new file mode 100644
index 0000000..849e839
--- /dev/null
+++ b/self-extractors/nxp/LICENSE
@@ -0,0 +1,218 @@
+THIS DEVELOPER SOFTWARE LICENSE AGREEMENT (THE "AGREEMENT") IS A LEGALLY
+BINDING AGREEMENT BETWEEN NXP Semiconductors Netherlands B.V ("LICENSOR") AND
+YOU OR THE LEGAL ENTITY YOU REPRESENT ("You" or its possessive, "Your"). BY
+TYPING "I ACCEPT" WHERE INDICATED YOU ACKNOWLEDGE THAT YOU HAVE READ THIS
+AGREEMENT, UNDERSTAND IT AND AGREE TO BE BOUND BY ITS TERMS AND CONDITIONS. IF
+YOU DO NOT AGREE TO THESE TERMS YOU MUST DISCONTINUE THE INSTALLATION PROCESS
+AND YOU SHALL NOT USE THE SOFTWARE OR RETAIN ANY COPIES OF THE SOFTWARE OR
+DOCUMENTATION. ANY USE OR POSSESSION OF THE SOFTWARE BY YOU IS SUBJECT TO THE
+TERMS AND CONDITIONS SET FORTH IN THIS AGREEMENT. IF THE SOFTWARE IS INSTALLED
+ON A COMPUTER OWNED BY A CORPORATION OR OTHER LEGAL ENTITY, THEN YOU REPRESENT
+AND WARRANT THAT YOU HAVE THE AUTHORITY TO BIND SUCH ENTITY TO THE TERMS AND
+CONDITIONS OF THIS AGREEMENT.
+
+ 1. Special Definitions
+
+ a. The term "Android" means the open source mobile platform, software
+ stack, operating system, middleware, application programming
+ interfaces and mobile applications under the trade-name "Android"
+ distributed at Android.com.
+
+ b. The term "Android Applications" means a software application or
+ open-source contribution developed by You, designed to operate with
+ Android that does not contain or incorporate any of the Software.
+
+ c. The term "Authorized Android Enabled Device" means the device
+ known as the Nexus S only.
+ The term "Software" means the Licensor's proprietary software and
+ libraries in object code form, designed for use on the Authorized
+ Android Enabled Device.
+
+ d. The term "Authorized Android Enabled Device Software" means a
+ packaged build for Authorized Android Enabled Devices, consisting of
+ files suitable for installation on an Authorized Android Enabled
+ Device using a mechanism such as fastboot mode or recovery mode.
+
+ 2. License Grant
+
+ a. Subject to the terms of this Agreement, Licensor hereby grants to
+ You, free of charge, a non-exclusive, non-sublicensable,
+ non-transferable, limited license, during the term of this Agreement,
+ to download, install and use the Software internally in
+ machine-readable (i.e., object code) form and the Documentation for
+ non-commercial use on an Authorized Android Enabled Device and
+ non-commercial redistribution of the Authorized Android Enabled
+ Device Software (the “Limited Purpose”). You may grant your end users
+ the right to use the Software for the Limited Purpose. The license to
+ the Software granted to You hereunder is solely for the Limited
+ Purpose set forth in this section, and the Software shall not be used
+ for any other purpose.
+
+ 3. Restrictions
+
+ a. Retention of Rights. The entire right, title and interest in the
+ Software shall remain with Licensor and, unless specified in writing
+ hereunder, no rights are granted to any of the Software. Except for
+ the right to use the Software for the Limited Purpose, the delivery
+ of the Software to You does not convey to You any intellectual
+ property rights in the Software, including, but not limited to any
+ rights under any patent, trademark, copyright, or trade secret.
+ Neither the delivery of the Software to You nor any terms set forth
+ herein shall be construed to grant to You, either expressly, by
+ implication or by way of estoppel, any license under any patents or
+ other intellectual property rights covering or relating to any other
+ product or invention or any combination of the Software with any
+ other product. Any rights not expressly granted to You herein are
+ reserved by Licensor.
+
+ b. No Commercialization or Distribution of the Software and
+ Documentation. Except as expressly provided in Section 2 of this
+ Agreement, You shall have no right to (i) copy, disclose, distribute,
+ publically perform, publically display, transfer, alter, modify,
+ translate, disassemble, decompile, reverse engineer, or adapt the
+ Software and Documentation, or any portion thereof, or create any
+ derivative works based thereon; (ii) rent, lease, assign, sublicense,
+ resell, disclose or otherwise transfer the Software and Documentation
+ in whole or in part to any third party (iii) use the Software and
+ Documentation except for the Limited Purpose, (iv) remove or alter
+ any of the copyright or proprietary notices contained in any of the
+ Software and Documentation. For the purposes of clarity, nothing in
+ this Agreement prohibits You from making and distributing Android
+ Applications under commercial or non-commercial terms, provided that
+ You shall not contain, incorporate, and/or compile the Software or
+ any of its derivative works, in whole or in part, into Your Android
+ Applications and/or any software/devices created by You or by third
+ parties acting on Your behalf. You and any such third party shall
+ comply with all of the terms and conditions of this Agreement.
+
+ c. No Reverse Engineering. Except for any portions of the Software
+ provided to You in source code format and except for any third party
+ code distributed with the Software that is licensed under contrary
+ terms, You will not reverse engineer, disassemble,
+ decompile, or translate the Software, or otherwise attempt to derive
+ the source code version of the Software, except if and to the extent
+ expressly permitted under any applicable law.
+
+ d. Third Party Software. You agree that Android may contain third party
+ software. You agree that you may not distribute such third party
+ software for any purpose without appropriate licenses from the
+ applicable third party or parties.
+
+ e. No Transfer or Assignment. You shall not assign any of its rights or
+ obligations under this Agreement. Any attempted assignment in
+ contravention of this Section shall be void.
+
+ 4. Indemnity
+
+ a. You agree to indemnify and hold harmless Licensor and its officers,
+ directors, customers, employees and successors and assigns (each an
+ "Indemnified Party") against any and all claims, demands, causes of
+ action, losses, liabilities, damages, costs and expenses, incurred by
+ the Indemnified Party (including but not limited to costs of defense,
+ investigation and reasonable attorney's fees) arising out of,
+ resulting from or related to (i) any software, products,
+ documentation, content, materials or derivative works created or
+ developed by You using the Software which causes an infringement of
+ any patent, copyright, trademark, trade secret, or other property,
+ publicity or privacy rights of any third parties arising in any
+ jurisdiction anywhere in the world, (ii) the download, distribution,
+ installation, storage, execution, use or transfer of such software,
+ products, documentation, content, materials or derivative works by
+ any person or entity, and/or (iii) any breach of this Agreement by
+ You. If requested by an Indemnified Party, You agree to defend such
+ Indemnified Party in connection with any third party claims, demands,
+ or causes of action resulting from, arising out of or in connection
+ with any of the foregoing.
+
+ 5. Limitation of Liability
+
+ a. TO THE MAXIMUM EXTENT PERMITTED UNDER APPLICABLE LAWS, UNDER NO
+ CIRCUMSTANCES, INCLUDING WITHOUT LIMITATION NEGLIGENCE, SHALL
+ LICENSOR, ITS AFFILIATES AND/OR ITS DIRECTORS, OFFICERS, EMPLOYEES OR
+ AGENTS BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE OR
+ CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO DAMAGES FOR LOSS
+ OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
+ INFORMATION AND THE LIKE) ARISING OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR ANY DOWNLOAD, INSTALLATION OR USE OF, OR INABILITY TO
+ USE, THE SOFTWARE, EVEN IF LICENSOR HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW THE
+ LIMITATION OR EXCLUSION OF LIABILITY FOR INCIDENTAL OR CONSEQUENTIAL
+ DAMAGES SO THE ABOVE LIMITATION OR EXCLUSION MAY NOT APPLY OR MAY BE
+ LIMITED. IN NO EVENT SHALL LICENSOR'S TOTAL AGGREGATE LIABILITY TO
+ YOU FOR ANY AND ALL DAMAGES, LOSSES, CLAIMS AND CAUSES OF ACTIONS
+ (WHETHER IN CONTRACT, TORT, INCLUDING NEGLIGENCE, INDEMNIFICATION OR
+ OTHERWISE) EXCEED ONE HUNDRED U.S. DOLLARS (US$100). THE LIMITATIONS
+ SET FORTH IN THIS PARAGRAPH SHALL BE DEEMED TO APPLY TO THE MAXIMUM
+ EXTENT PERMITTED BY APPLICABLE LAW. THE PARTIES HAVE FULLY CONSIDERED
+ THE FOREGOING ALLOCATION OF RISK AND FIND IT REASONABLE, AND THAT THE
+ FOREGOING LIMITATIONS IN THIS PARAGRAPH ARE AN ESSENTIAL BASIS OF
+ THE BARGAIN BETWEEN THE PARTIES.
+
+ 6. No Warranty
+
+ a. LICENSOR MAKES NO WARRANTIES, EXPRESS OR IMPLIED, WITH RESPECT TO THE
+ SOFTWARE AND DOCUMENTATION PROVIDED UNDER THIS AGREEMENT, INCLUDING
+ BUT NOT LIMITED TO ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR PURPOSE OR AGAINST INFRINGEMENT, OR ANY EXPRESS OR IMPLIED
+ WARRANTY ARISING OUT OF TRADE USAGE OR OUT OF A COURSE OF DEALING OR
+ COURSE OF PERFORMANCE. NOTHING CONTAINED IN THIS AGREEMENT SHALL BE
+ CONSTRUED AS A WARRANTY OR REPRESENTATION BY LICENSOR (I) AS TO THE
+ VALIDITY OR SCOPE OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL
+ PROPERTY RIGHT AND (II) THAT ANY MANUFACTURE OR USE WILL BE FREE FROM
+ INFRINGEMENT OF PATENTS, COPYRIGHTS OR OTHER INTELLECTUAL PROPERTY
+ RIGHTS OF OTHERS, AND IT SHALL BE THE SOLE RESPONSIBILITY OF YOU TO
+ MAKE SUCH DETERMINATION AS IS NECESSARY WITH RESPECT TO THE
+ ACQUISITION OF LICENSES UNDER PATENTS AND OTHER INTELLECTUAL PROPERTY
+ OF THIRD PARTIES. LICENSOR SHALL NOT HAVE ANY OBLIGATION TO PROVIDE
+ ANY TECHNICAL SUPPORT OF THE SOFTWARE UNDER THIS AGREEMENT.
+
+ 7. Term and Termination
+
+ a. This Agreement shall be effective on the date You accept this
+ Agreement and shall remain in effect until terminated as provided
+ herein. You may terminate the Agreement at any time by deleting and
+ destroying all copies of the Software and all related information in
+ Your possession or control. This Agreement terminates immediately and
+ automatically, with or without notice, if You fail to comply with any
+ provision hereof. Additionally, Licensor may at any time terminate
+ this Agreement, without cause, upon notice to You. Upon termination
+ You must delete or destroy all copies of the Software in Your
+ possession, and the license granted to You in this Agreement shall
+ terminate. Sections 3, 4, 5, 6 and 8 shall survive the termination of
+ this Agreement.
+
+ 8. Miscellaneous
+
+ a. Governing Law. This Agreement is governed and interpreted in
+ accordance with the laws of the State of California without giving
+ effect to its conflict of laws provisions. The United Nations
+ Convention on Contracts for the International Sale of Goods is
+ expressly disclaimed and shall not apply. Any claim arising out of or
+ related to this Agreement must be brought exclusively in a federal or
+ state court located in Santa Clara County, California and You consent
+ to the jurisdiction and venue of such courts.
+
+ b. Waiver and Severability. The failure of either party to require
+ performance by the other party of any provision of this Agreement
+ shall not affect the full right to require such performance at any
+ time thereafter; nor shall the waiver by either party of a breach of
+ any provision of this Agreement be taken or held to be a waiver of
+ the provision itself. Severability. If any provision of this
+ Agreement is unenforceable or invalid under any applicable law or is
+ so held by applicable court decision, such unenforceability or
+ invalidity shall not render this Agreement unenforceable or invalid
+ as a whole, and such provision shall be changed and interpreted so as
+ to best accomplish the objectives of such unenforceable or invalid
+ provision within the limits of applicable law or applicable court
+ decisions.
+
+ c. Amendment and Modification. This Agreement and any of its terms and
+ provisions may only be amended, modified, supplemented or waived in a
+ writing signed by both parties hereto.
+
+ d. Compliance with Laws. You shall comply with all applicable laws,
+ rules, and regulations in connection with its activities under this
+ Agreement.
+
+ e. Entire Agreement. This Agreement completely and exclusively states
+ the agreement between You and Licensor regarding this subject matter.
diff --git a/self-extractors/nxp/staging/BoardConfigCrespo.mk b/self-extractors/nxp/staging/BoardConfigCrespo.mk
new file mode 100644
index 0000000..01a0ff3
--- /dev/null
+++ b/self-extractors/nxp/staging/BoardConfigCrespo.mk
@@ -0,0 +1,13 @@
+# 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.
diff --git a/self-extractors/nxp/staging/device-crespo.mk b/self-extractors/nxp/staging/device-crespo.mk
new file mode 100644
index 0000000..f9cc5b0
--- /dev/null
+++ b/self-extractors/nxp/staging/device-crespo.mk
@@ -0,0 +1,19 @@
+# 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.
+
+LOCAL_PATH := vendor/nxp/crespo
+
+# NXP blob necessary for Nexus S hardware
+PRODUCT_COPY_FILES := \
+ $(LOCAL_PATH)/proprietary/libpn544_fw.so:system/vendor/firmware/libpn544_fw.so
diff --git a/self-extractors/root/BoardConfigVendor.mk b/self-extractors/root/BoardConfigVendor.mk
new file mode 100644
index 0000000..365996f
--- /dev/null
+++ b/self-extractors/root/BoardConfigVendor.mk
@@ -0,0 +1,23 @@
+# 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.
+
+LOCAL_STEM := crespo/BoardConfigCrespo.mk
+
+-include vendor/akm/$(LOCAL_STEM)
+-include vendor/broadcom/$(LOCAL_STEM)
+-include vendor/cypress/$(LOCAL_STEM)
+-include vendor/imgtec/$(LOCAL_STEM)
+-include vendor/nxp/$(LOCAL_STEM)
+-include vendor/samsung/$(LOCAL_STEM)
+-include vendor/widevine/$(LOCAL_STEM)
diff --git a/self-extractors/root/device-vendor.mk b/self-extractors/root/device-vendor.mk
new file mode 100644
index 0000000..dcf6247
--- /dev/null
+++ b/self-extractors/root/device-vendor.mk
@@ -0,0 +1,23 @@
+# 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.
+
+LOCAL_STEM := crespo/device-crespo.mk
+
+$(call inherit-product-if-exists, vendor/akm/$(LOCAL_STEM))
+$(call inherit-product-if-exists, vendor/broadcom/$(LOCAL_STEM))
+$(call inherit-product-if-exists, vendor/cypress/$(LOCAL_STEM))
+$(call inherit-product-if-exists, vendor/imgtec/$(LOCAL_STEM))
+$(call inherit-product-if-exists, vendor/nxp/$(LOCAL_STEM))
+$(call inherit-product-if-exists, vendor/samsung/$(LOCAL_STEM))
+$(call inherit-product-if-exists, vendor/widevine/$(LOCAL_STEM))
diff --git a/self-extractors/samsung/COPYRIGHT b/self-extractors/samsung/COPYRIGHT
new file mode 100644
index 0000000..e5dc6cc
--- /dev/null
+++ b/self-extractors/samsung/COPYRIGHT
@@ -0,0 +1 @@
+# (C) Samsung Electronics, Inc.
diff --git a/self-extractors/samsung/LICENSE b/self-extractors/samsung/LICENSE
new file mode 100644
index 0000000..2e20c75
--- /dev/null
+++ b/self-extractors/samsung/LICENSE
@@ -0,0 +1,225 @@
+THIS DEVELOPER SOFTWARE LICENSE AGREEMENT (THE "AGREEMENT") IS A LEGALLY
+BINDING AGREEMENT BETWEEN Samsung Electronics ("LICENSOR") AND
+YOU OR THE LEGAL ENTITY YOU REPRESENT ("You" or its possessive, "Your"). BY
+TYPING "I ACCEPT" WHERE INDICATED YOU ACKNOWLEDGE THAT YOU HAVE READ THIS
+AGREEMENT, UNDERSTAND IT AND AGREE TO BE BOUND BY ITS TERMS AND CONDITIONS. IF
+YOU DO NOT AGREE TO THESE TERMS YOU MUST DISCONTINUE THE INSTALLATION PROCESS
+AND YOU SHALL NOT USE THE SOFTWARE OR RETAIN ANY COPIES OF THE SOFTWARE OR
+DOCUMENTATION. ANY USE OR POSSESSION OF THE SOFTWARE BY YOU IS SUBJECT TO THE
+TERMS AND CONDITIONS SET FORTH IN THIS AGREEMENT. IF THE SOFTWARE IS INSTALLED
+ON A COMPUTER OWNED BY A CORPORATION OR OTHER LEGAL ENTITY, THEN YOU REPRESENT
+AND WARRANT THAT YOU HAVE THE AUTHORITY TO BIND SUCH ENTITY TO THE TERMS AND
+CONDITIONS OF THIS AGREEMENT.
+
+ 1. Special Definitions
+
+ a. The term "Android" means the open source mobile platform, software
+ stack, operating system, middleware, application programming
+ interfaces and mobile applications under the trade-name "Android"
+ distributed at Android.com.
+
+ b. The term "Android Applications" means a software application or
+ open-source contribution developed by You, designed to operate with
+ Android that does not contain or incorporate any of the Software.
+
+ c. The term "Authorized Android Enabled Device" means the device
+ known as the Nexus S only.
+ The term "Software" means the Licensor's proprietary software and
+ libraries in object code form, designed for use on the Authorized
+ Android Enabled Device.
+
+ d. The term "Authorized Android Enabled Device Software" means a
+ packaged build for Authorized Android Enabled Devices, consisting of
+ files suitable for installation on an Authorized Android Enabled
+ Device using a mechanism such as fastboot mode or recovery mode.
+
+ 2. License Grant
+
+ a. Subject to the terms of this Agreement, Licensor hereby grants to
+ You, free of charge, a non-exclusive, non-sublicensable,
+ non-transferable, limited license, during the term of this Agreement,
+ to download, install and use the Software internally in
+ machine-readable (i.e., object code) form and the Documentation for
+ non-commercial use on an Authorized Android Enabled Device and
+ non-commercial redistribution of the Authorized Android Enabled
+ Device Software (the “Limited Purpose”). You may grant your end users
+ the right to use the Software for the Limited Purpose. The license to
+ the Software granted to You hereunder is solely for the Limited
+ Purpose set forth in this section, and the Software shall not be used
+ for any other purpose.
+
+ 3. Restrictions
+
+ a. Retention of Rights. The entire right, title and interest in the
+ Software shall remain with Licensor and, unless specified in writing
+ hereunder, no rights are granted to any of the Software. Except for
+ the right to use the Software for the Limited Purpose, the delivery
+ of the Software to You does not convey to You any intellectual
+ property rights in the Software, including, but not limited to any
+ rights under any patent, trademark, copyright, or trade secret.
+ Neither the delivery of the Software to You nor any terms set forth
+ herein shall be construed to grant to You, either expressly, by
+ implication or by way of estoppel, any license under any patents or
+ other intellectual property rights covering or relating to any other
+ product or invention or any combination of the Software with any
+ other product. Any rights not expressly granted to You herein are
+ reserved by Licensor.
+
+ b. No Commercialization or Distribution of the Software and
+ Documentation. Except as expressly provided in Section 2 of this
+ Agreement, You shall have no right to (i) copy, disclose, distribute,
+ publically perform, publically display, transfer, alter, modify,
+ translate, disassemble, decompile, reverse engineer, or adapt the
+ Software and Documentation, or any portion thereof, or create any
+ derivative works based thereon; (ii) rent, lease, assign, sublicense,
+ resell, disclose or otherwise transfer the Software and Documentation
+ in whole or in part to any third party (iii) use the Software and
+ Documentation except for the Limited Purpose, (iv) remove or alter
+ any of the copyright or proprietary notices contained in any of the
+ Software and Documentation. For the purposes of clarity, nothing in
+ this Agreement prohibits You from making and distributing Android
+ Applications under commercial or non-commercial terms, provided that
+ You shall not contain, incorporate, and/or compile the Software or
+ any of its derivative works, in whole or in part, into Your Android
+ Applications and/or any software/devices created by You or by third
+ parties acting on Your behalf. You and any such third party shall
+ comply with all of the terms and conditions of this Agreement.
+
+ c. No Reverse Engineering. You will not reverse engineer, disassemble,
+ decompile, or translate the Software, or otherwise attempt to derive
+ the source code version of the Software, except if and to the extent
+ expressly permitted under any applicable law.
+
+ d. Third Party Software. You agree that Android may contain third party
+ software. You agree that you may not distribute such third party
+ software for any purpose without appropriate licenses from the
+ applicable third party or parties.
+
+ e. No Transfer or Assignment. You shall not assign any of its rights or
+ obligations under this Agreement. Any attempted assignment in
+ contravention of this Section shall be void.
+
+ 4. Onwership of Intellectual Property
+
+ a. You acknowledge that all intellectual property rights in or relating
+ to the Software and all parts of the Software are and shall remain
+ the exclusive property of Licensor and its licensors. You agree that
+ you will not remove or alter any copyright notices or similar
+ proprietary devices, including without limitation any electronic
+ watermarks or other identifiers, that may be incorporated in the
+ Software.
+
+ 5. Indemnity
+
+ a. You agree to indemnify and hold harmless Licensor and its officers,
+ directors, customers, employees and successors and assigns (each an
+ "Indemnified Party") against any and all claims, demands, causes of
+ action, losses, liabilities, damages, costs and expenses, incurred by
+ the Indemnified Party (including but not limited to costs of defense,
+ investigation and reasonable attorney's fees) arising out of,
+ resulting from or related to (i) any software, products,
+ documentation, content, materials or derivative works created or
+ developed by You using the Software which causes an infringement of
+ any patent, copyright, trademark, trade secret, or other property,
+ publicity or privacy rights of any third parties arising in any
+ jurisdiction anywhere in the world, (ii) the download, distribution,
+ installation, storage, execution, use or transfer of such software,
+ products, documentation, content, materials or derivative works by
+ any person or entity, and/or (iii) any breach of this Agreement by
+ You. If requested by an Indemnified Party, You agree to defend such
+ Indemnified Party in connection with any third party claims, demands,
+ or causes of action resulting from, arising out of or in connection
+ with any of the foregoing.
+
+ 6. Limitation of Liability
+
+ a. TO THE MAXIMUM EXTENT PERMITTED UNDER APPLICABLE LAWS, UNDER NO
+ CIRCUMSTANCES, INCLUDING WITHOUT LIMITATION NEGLIGENCE, SHALL
+ LICENSOR, ITS AFFILIATES AND/OR ITS DIRECTORS, OFFICERS, EMPLOYEES OR
+ AGENTS BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE OR
+ CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO DAMAGES FOR LOSS
+ OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
+ INFORMATION AND THE LIKE) ARISING OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR ANY DOWNLOAD, INSTALLATION OR USE OF, OR INABILITY TO
+ USE, THE SOFTWARE, EVEN IF LICENSOR HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW THE
+ LIMITATION OR EXCLUSION OF LIABILITY FOR INCIDENTAL OR CONSEQUENTIAL
+ DAMAGES SO THE ABOVE LIMITATION OR EXCLUSION MAY NOT APPLY OR MAY BE
+ LIMITED. IN NO EVENT SHALL LICENSOR'S TOTAL AGGREGATE LIABILITY TO
+ YOU FOR ANY AND ALL DAMAGES, LOSSES, CLAIMS AND CAUSES OF ACTIONS
+ (WHETHER IN CONTRACT, TORT, INCLUDING NEGLIGENCE, INDEMNIFICATION OR
+ OTHERWISE) EXCEED ONE HUNDRED U.S. DOLLARS (US$100). THE LIMITATIONS
+ SET FORTH IN THIS PARAGRAPH SHALL BE DEEMED TO APPLY TO THE MAXIMUM
+ EXTENT PERMITTED BY APPLICABLE LAW. THE PARTIES HAVE FULLY CONSIDERED
+ THE FOREGOING ALLOCATION OF RISK AND FIND IT REASONABLE, AND THAT THE
+ FOREGOING LIMITATIONS IN THIS PARAGRAPH ARE AN ESSENTIAL BASIS OF
+ THE BARGAIN BETWEEN THE PARTIES.
+
+ 7. No Warranty
+
+ a. LICENSOR MAKES NO WARRANTIES, EXPRESS OR IMPLIED, WITH RESPECT TO THE
+ SOFTWARE AND DOCUMENTATION PROVIDED UNDER THIS AGREEMENT, INCLUDING
+ BUT NOT LIMITED TO ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
+ PARTICULAR PURPOSE OR AGAINST INFRINGEMENT, OR ANY EXPRESS OR IMPLIED
+ WARRANTY ARISING OUT OF TRADE USAGE OR OUT OF A COURSE OF DEALING OR
+ COURSE OF PERFORMANCE. NOTHING CONTAINED IN THIS AGREEMENT SHALL BE
+ CONSTRUED AS A WARRANTY OR REPRESENTATION BY LICENSOR (I) AS TO THE
+ VALIDITY OR SCOPE OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL
+ PROPERTY RIGHT AND (II) THAT ANY MANUFACTURE OR USE WILL BE FREE FROM
+ INFRINGEMENT OF PATENTS, COPYRIGHTS OR OTHER INTELLECTUAL PROPERTY
+ RIGHTS OF OTHERS, AND IT SHALL BE THE SOLE RESPONSIBILITY OF YOU TO
+ MAKE SUCH DETERMINATION AS IS NECESSARY WITH RESPECT TO THE
+ ACQUISITION OF LICENSES UNDER PATENTS AND OTHER INTELLECTUAL PROPERTY
+ OF THIRD PARTIES. LICENSOR SHALL NOT HAVE ANY OBLIGATION TO PROVIDE
+ ANY TECHNICAL SUPPORT OF THE SOFTWARE UNDER THIS AGREEMENT.
+
+ 8. Term and Termination
+
+ a. This Agreement shall be effective on the date You accept this
+ Agreement and shall remain in effect until terminated as provided
+ herein. You may terminate the Agreement at any time by deleting and
+ destroying all copies of the Software and all related information in
+ Your possession or control. This Agreement terminates immediately and
+ automatically, with or without notice, if You fail to comply with any
+ provision hereof. Additionally, Licensor may at any time terminate
+ this Agreement, without cause, upon notice to You. Upon termination
+ You must delete or destroy all copies of the Software in Your
+ possession, and the license granted to You in this Agreement shall
+ terminate. Sections 3, 4, 5, 6 and 8 shall survive the termination of
+ this Agreement.
+
+ 9. Miscellaneous
+
+ a. Governing Law. This Agreement is governed and interpreted in
+ accordance with the laws of the State of California without giving
+ effect to its conflict of laws provisions. The United Nations
+ Convention on Contracts for the International Sale of Goods is
+ expressly disclaimed and shall not apply. Any claim arising out of or
+ related to this Agreement must be brought exclusively in a federal or
+ state court located in Santa Clara County, California and You consent
+ to the jurisdiction and venue of such courts.
+
+ b. Waiver and Severability. The failure of either party to require
+ performance by the other party of any provision of this Agreement
+ shall not affect the full right to require such performance at any
+ time thereafter; nor shall the waiver by either party of a breach of
+ any provision of this Agreement be taken or held to be a waiver of
+ the provision itself. Severability. If any provision of this
+ Agreement is unenforceable or invalid under any applicable law or is
+ so held by applicable court decision, such unenforceability or
+ invalidity shall not render this Agreement unenforceable or invalid
+ as a whole, and such provision shall be changed and interpreted so as
+ to best accomplish the objectives of such unenforceable or invalid
+ provision within the limits of applicable law or applicable court
+ decisions.
+
+ c. Amendment and Modification. This Agreement and any of its terms and
+ provisions may only be amended, modified, supplemented or waived in a
+ writing signed by both parties hereto.
+
+ d. Compliance with Laws. You shall comply with all applicable laws,
+ rules, and regulations in connection with its activities under this
+ Agreement.
+
+ e. Entire Agreement. This Agreement completely and exclusively states
+ the agreement between You and Licensor regarding this subject matter.
diff --git a/self-extractors/samsung/staging/BoardConfigCrespo.mk b/self-extractors/samsung/staging/BoardConfigCrespo.mk
new file mode 100644
index 0000000..01a0ff3
--- /dev/null
+++ b/self-extractors/samsung/staging/BoardConfigCrespo.mk
@@ -0,0 +1,13 @@
+# 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.
diff --git a/self-extractors/samsung/staging/device-crespo.mk b/self-extractors/samsung/staging/device-crespo.mk
new file mode 100644
index 0000000..0488760
--- /dev/null
+++ b/self-extractors/samsung/staging/device-crespo.mk
@@ -0,0 +1,24 @@
+# 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.
+
+LOCAL_PATH := vendor/samsung/crespo
+
+# Prebuilt libraries that are needed to build open-source libraries
+PRODUCT_COPY_FILES := \
+ $(LOCAL_PATH)/proprietary/libsecril-client.so:obj/lib/libsecril-client.so
+
+# Samsung blobs necessary for Nexus S hardware
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/proprietary/libsecril-client.so:system/lib/libsecril-client.so \
+ $(LOCAL_PATH)/proprietary/libsec-ril.so:system/vendor/lib/libsec-ril.so
diff --git a/self-extractors/widevine/COPYRIGHT b/self-extractors/widevine/COPYRIGHT
new file mode 100644
index 0000000..91f97c9
--- /dev/null
+++ b/self-extractors/widevine/COPYRIGHT
@@ -0,0 +1 @@
+# (C) Widevine. All Rights Reserved.
diff --git a/self-extractors/widevine/LICENSE b/self-extractors/widevine/LICENSE
new file mode 100644
index 0000000..f1d5315
--- /dev/null
+++ b/self-extractors/widevine/LICENSE
@@ -0,0 +1 @@
+WIDEVINE LICENSE GOES HERE
diff --git a/self-extractors/widevine/staging/BoardConfigCrespo.mk b/self-extractors/widevine/staging/BoardConfigCrespo.mk
new file mode 100644
index 0000000..01a0ff3
--- /dev/null
+++ b/self-extractors/widevine/staging/BoardConfigCrespo.mk
@@ -0,0 +1,13 @@
+# 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.
diff --git a/self-extractors/widevine/staging/device-crespo.mk b/self-extractors/widevine/staging/device-crespo.mk
new file mode 100644
index 0000000..2d32797
--- /dev/null
+++ b/self-extractors/widevine/staging/device-crespo.mk
@@ -0,0 +1,24 @@
+# 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.
+
+LOCAL_PATH := vendor/widevine/crespo
+
+# Widevine blobs necessary for Nexus S hardware
+PRODUCT_COPY_FILES := \
+ $(LOCAL_PATH)/proprietary/com.google.widevine.software.drm.xml:system/etc/permissions/com.google.widevine.software.drm.xml \
+ $(LOCAL_PATH)/proprietary/libdrmwvmplugin.so:system/lib/drm/libdrmwvmplugin.so \
+ $(LOCAL_PATH)/proprietary/libwvdrm_L3.so:system/lib/libwvdrm_L3.so \
+ $(LOCAL_PATH)/proprietary/libwvm.so:system/lib/libwvm.so \
+ $(LOCAL_PATH)/proprietary/libWVStreamControlAPI_L3.so:system/lib/libWVStreamControlAPI_L3.so \
+
diff --git a/setup-makefiles.sh b/setup-makefiles.sh
index 916c1ea..cf06f2d 100755
--- a/setup-makefiles.sh
+++ b/setup-makefiles.sh
@@ -36,21 +36,6 @@ mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE
# This file is generated by device/__MANUFACTURER__/__DEVICE__/setup-makefiles.sh
-# Live wallpaper packages
-PRODUCT_PACKAGES := \\
- LiveWallpapers \\
- LiveWallpapersPicker \\
- MagicSmokeWallpapers \\
- VisualizationWallpapers \\
- librs_jni
-
-# Publish that we support the live wallpaper feature.
-PRODUCT_COPY_FILES := \\
- packages/wallpapers/LivePicker/android.software.live_wallpaper.xml:/system/etc/permissions/android.software.live_wallpaper.xml
-
-# Pick up overlay for features that depend on non-open-source files
-DEVICE_PACKAGE_OVERLAYS := vendor/__MANUFACTURER__/__DEVICE__/overlay
-
\$(call inherit-product, vendor/__MANUFACTURER__/__DEVICE__/device-vendor-blobs.mk)
EOF
@@ -70,41 +55,4 @@ EOF
# limitations under the License.
# This file is generated by device/__MANUFACTURER__/__DEVICE__/setup-makefiles.sh
-
-BOARD_GPS_LIBRARIES := libgps
-
-USE_CAMERA_STUB := false
-
-BOARD_USES_GENERIC_AUDIO := false
-
-BOARD_USES_LIBSECRIL_STUB := false
-
-BOARD_NO_PAGE_FLIPPING := false
-BOARD_NO_32BPP := false
-EOF
-
-mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE/overlay/packages/apps/Launcher2/res/layout
-(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/overlay/packages/apps/Launcher2/res/layout/all_apps.xml
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<!-- This file is generated by device/__MANUFACTURER__/__DEVICE__/setup-makefiles.sh -->
-
-<!-- switch to all_apps_3d on devices that support RenderScript -->
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
- <include layout="@layout/all_apps_3d" />
-</merge>
EOF
diff --git a/setup_fs.c b/setup_fs.c
deleted file mode 100644
index 0acf026..0000000
--- a/setup_fs.c
+++ /dev/null
@@ -1,75 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/reboot.h>
-#include <sys/wait.h>
-
-const char *mkfs = "/system/bin/make_ext4fs";
-
-int setup_fs(const char *blockdev)
-{
- char buf[256], path[128];
- pid_t child;
- int status, n;
-
- /* we might be looking at an indirect reference */
- n = readlink(blockdev, path, sizeof(path) - 1);
- if (n > 0) {
- path[n] = 0;
- if (!memcmp(path, "/dev/block/", 11))
- blockdev = path + 11;
- }
-
- if (strchr(blockdev,'/')) {
- fprintf(stderr,"not a block device name: %s\n", blockdev);
- return 0;
- }
-
- sprintf(buf,"/sys/fs/ext4/%s", blockdev);
- if (access(buf, F_OK) == 0) {
- fprintf(stderr,"device %s already has a filesystem\n", blockdev);
- return 0;
- }
- sprintf(buf,"/dev/block/%s", blockdev);
-
- fprintf(stderr,"+++\n");
-
- child = fork();
- if (child < 0) {
- fprintf(stderr,"error: fork failed\n");
- return 0;
- }
- if (child == 0) {
- execl(mkfs, mkfs, buf, NULL);
- exit(-1);
- }
-
- while (waitpid(-1, &status, 0) != child) ;
-
- fprintf(stderr,"---\n");
- return 1;
-}
-
-
-int main(int argc, char **argv)
-{
- int need_reboot = 0;
-
- while (argc > 1) {
- if (strlen(argv[1]) < 128)
- need_reboot |= setup_fs(argv[1]);
- argv++;
- argc--;
- }
-
- if (need_reboot) {
- sync();
- sync();
- sync();
- fprintf(stderr,"REBOOT!\n");
- reboot(RB_AUTOBOOT);
- exit(-1);
- }
- return 0;
-}
diff --git a/ueventd.herring.rc b/ueventd.herring.rc
index 9d1fc97..d6b5ea8 100644
--- a/ueventd.herring.rc
+++ b/ueventd.herring.rc
@@ -7,7 +7,7 @@
/dev/video2 0660 system camera
/dev/s3c-jpg 0660 system camera
/dev/s3c-mem 0660 system system
-/dev/s3c-mfc 0660 system graphics
+/dev/s3c-mfc 0660 media media
/dev/modem_ctl 0660 radio radio
/dev/modem_fmt 0660 radio radio
diff --git a/unzip-files.sh b/unzip-files.sh
index 9b41940..930e28e 100755
--- a/unzip-files.sh
+++ b/unzip-files.sh
@@ -20,18 +20,19 @@ DEVICE=crespo
MANUFACTURER=samsung
mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
-unzip -j -o ../../../${DEVICE}_update.zip system/etc/gps.conf -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
-unzip -j -o ../../../${DEVICE}_update.zip system/lib/libpn544_fw.so -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
+unzip -j -o ../../../${DEVICE}_update.zip system/etc/permissions/com.google.widevine.software.drm.xml -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
+unzip -j -o ../../../${DEVICE}_update.zip system/lib/drm/libdrmwvmplugin.so -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
unzip -j -o ../../../${DEVICE}_update.zip system/lib/libsecril-client.so -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
+unzip -j -o ../../../${DEVICE}_update.zip system/lib/libwvdrm_L3.so -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
+unzip -j -o ../../../${DEVICE}_update.zip system/lib/libwvm.so -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
+unzip -j -o ../../../${DEVICE}_update.zip system/lib/libWVStreamControlAPI_L3.so -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
unzip -j -o ../../../${DEVICE}_update.zip system/vendor/bin/gpsd -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
chmod 755 ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/gpsd
unzip -j -o ../../../${DEVICE}_update.zip system/vendor/bin/pvrsrvinit -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
chmod 755 ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/pvrsrvinit
-unzip -j -o ../../../${DEVICE}_update.zip system/vendor/etc/gps.xml -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
unzip -j -o ../../../${DEVICE}_update.zip system/vendor/firmware/bcm4329.hcd -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
unzip -j -o ../../../${DEVICE}_update.zip system/vendor/firmware/cypress-touchkey.bin -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
-unzip -j -o ../../../${DEVICE}_update.zip system/vendor/firmware/nvram_net.txt -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
-unzip -j -o ../../../${DEVICE}_update.zip system/vendor/firmware/samsung_mfc_fw.bin -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
+unzip -j -o ../../../${DEVICE}_update.zip system/vendor/firmware/libpn544_fw.so -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
unzip -j -o ../../../${DEVICE}_update.zip system/vendor/lib/egl/libEGL_POWERVR_SGX540_120.so -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
unzip -j -o ../../../${DEVICE}_update.zip system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
unzip -j -o ../../../${DEVICE}_update.zip system/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so -d ../../../vendor/$MANUFACTURER/$DEVICE/proprietary
@@ -71,16 +72,17 @@ PRODUCT_COPY_FILES := \\
# All the blobs necessary for crespo
PRODUCT_COPY_FILES += \\
- vendor/__MANUFACTURER__/__DEVICE__/proprietary/gps.conf:system/etc/gps.conf \\
- vendor/__MANUFACTURER__/__DEVICE__/proprietary/libpn544_fw.so:system/lib/libpn544_fw.so \\
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/com.google.widevine.software.drm.xml:system/etc/permissions/com.google.widevine.software.drm.xml \\
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/libdrmwvmplugin.so:system/lib/drm/libdrmwvmplugin.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libsecril-client.so:system/lib/libsecril-client.so \\
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/libwvdrm_L3.so:system/lib/libwvdrm_L3.so \\
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/libwvm.so:system/lib/libwvm.so \\
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/libWVStreamControlAPI_L3.so:system/lib/libWVStreamControlAPI_L3.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/gpsd:system/vendor/bin/gpsd \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/pvrsrvinit:system/vendor/bin/pvrsrvinit \\
- vendor/__MANUFACTURER__/__DEVICE__/proprietary/gps.xml:system/vendor/etc/gps.xml \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/bcm4329.hcd:system/vendor/firmware/bcm4329.hcd \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/cypress-touchkey.bin:system/vendor/firmware/cypress-touchkey.bin \\
- vendor/__MANUFACTURER__/__DEVICE__/proprietary/nvram_net.txt:system/vendor/firmware/nvram_net.txt \\
- vendor/__MANUFACTURER__/__DEVICE__/proprietary/samsung_mfc_fw.bin:system/vendor/firmware/samsung_mfc_fw.bin \\
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/libpn544_fw.so:system/vendor/firmware/libpn544_fw.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libEGL_POWERVR_SGX540_120.so:system/vendor/lib/egl/libEGL_POWERVR_SGX540_120.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libGLESv1_CM_POWERVR_SGX540_120.so:system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libGLESv2_POWERVR_SGX540_120.so:system/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so \\
@@ -96,6 +98,32 @@ PRODUCT_COPY_FILES += \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libsrv_init.so:system/vendor/lib/libsrv_init.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libsrv_um.so:system/vendor/lib/libsrv_um.so \\
vendor/__MANUFACTURER__/__DEVICE__/proprietary/libusc.so:system/vendor/lib/libusc.so
+
+
+EOF
+
+(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/Android.mk
+# Copyright (C) 2011 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.
+
+# This file is generated by device/__MANUFACTURER__/__DEVICE__/unzip-files.sh - DO NOT EDIT
+
+ifeq (\$(TARGET_DEVICE),crespo)
+LOCAL_PATH:=\$(call my-dir)
+
+endif
+
EOF
./setup-makefiles.sh
diff --git a/vold.fstab b/vold.fstab
index f841d3e..974dd6a 100644
--- a/vold.fstab
+++ b/vold.fstab
@@ -9,7 +9,8 @@
## label - Label for the volume
## mount_point - Where the volume will be mounted
## part - Partition # (1 based), or 'auto' for first usable partition.
-## <sysfs_path> - List of sysfs paths to source devices
+## <sysfs_path> - List of sysfs paths to source devices, must start with '/' character
+## flags - (optional) Comma separated list of flags, must not contain '/' character
######################
-dev_mount sdcard /mnt/sdcard 3 /devices/platform/s3c-sdhci.0/mmc_host/mmc0/mmc0:0001/block/mmcblk0
+dev_mount sdcard /mnt/sdcard 3 /devices/platform/s3c-sdhci.0/mmc_host/mmc0/mmc0:0001/block/mmcblk0 nonremovable,encryptable