summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvishal <vishal.bhoj@linaro.org>2018-08-07 18:18:04 +0530
committerVictor Chong <victor.chong@linaro.org>2018-10-26 18:50:30 +0100
commitf297ea2982f0727eccf7eef1c1583ec478d84450 (patch)
tree5cf6606cca776e36c76998c5fcc37f30d032e6d1
parenta5ec180c8cee90099b6e35080e156a810b9e6f3c (diff)
parent531fb4c307e7b5f5791ee4a60487c20c18cebcfc (diff)
downloadhikey-linaro-android-pie-treble.tar.gz
Merge remote-tracking branch 'aosp/master' into HEADlinaro-android-pie-treble
The FULL_TREBLE support was merged in June. The current pie-dev branch were create in May from Master. This update will make sure the next minor Android update will include hikey with full treble support. This also gives developers using stable Android codebase on HiKey/HiKey960 will be able to make use of latest changes. Change-Id: I90595c3229281938bc6b69b2160556bbf0366aca
-rw-r--r--AndroidProducts.mk13
-rw-r--r--BoardConfigCommon.mk12
-rw-r--r--audio/Android.mk14
-rw-r--r--audio/audio_hw.c200
-rw-r--r--bootloader/EFI/BOOT/fastboot.efibin62528 -> 0 bytes
-rw-r--r--bootloader/EFI/BOOT/grub.cfg41
-rw-r--r--bootloader/EFI/BOOT/grubaa64.efibin497152 -> 0 bytes
-rw-r--r--bt-wifi-firmware-util/Android.mk52
-rw-r--r--build/tasks/boot_fat.mk16
-rw-r--r--device-common.mk100
-rw-r--r--etc/media_codecs.xml63
-rwxr-xr-xfactory-images/generate-factory-images-hikey960.sh20
-rw-r--r--gralloc/Android.mk27
-rw-r--r--gralloc/alloc_device.cpp157
-rw-r--r--gralloc/alloc_device.h12
-rw-r--r--gralloc/framebuffer_device.cpp48
-rw-r--r--gralloc/gralloc_module.cpp185
-rw-r--r--gralloc/gralloc_priv.h43
-rw-r--r--gralloc960/Android.hikey960.mk8
-rw-r--r--gralloc960/Android.juno.mk1
-rw-r--r--gralloc960/Android.mk38
-rw-r--r--gralloc960/Android.vexpress.mk1
-rw-r--r--gralloc960/alloc_device.h37
-rw-r--r--gralloc960/alloc_device_allocator_specific.h25
-rw-r--r--gralloc960/alloc_ion.cpp444
-rw-r--r--gralloc960/framebuffer_device.cpp409
-rw-r--r--gralloc960/framebuffer_device.h8
-rw-r--r--gralloc960/gralloc_buffer_priv.cpp60
-rw-r--r--gralloc960/gralloc_buffer_priv.h150
-rw-r--r--gralloc960/gralloc_helper.h26
-rw-r--r--gralloc960/gralloc_module.cpp329
-rw-r--r--gralloc960/gralloc_module_ion.cpp132
-rw-r--r--gralloc960/gralloc_priv.h270
-rw-r--r--gralloc960/gralloc_vsync.h6
-rw-r--r--gralloc960/gralloc_vsync_default.cpp32
-rw-r--r--gralloc960/gralloc_vsync_report.h10
-rw-r--r--gralloc960/gralloc_vsync_s3cfb.cpp32
-rw-r--r--gralloc960/legacy/alloc_device.cpp184
-rw-r--r--gralloc960/legacy/alloc_device.h (renamed from gralloc960/gralloc_module_allocator_specific.h)11
-rw-r--r--gralloc960/mali_gralloc_buffer.h267
-rw-r--r--gralloc960/mali_gralloc_bufferaccess.cpp414
-rw-r--r--gralloc960/mali_gralloc_bufferaccess.h40
-rw-r--r--gralloc960/mali_gralloc_bufferallocation.cpp (renamed from gralloc960/alloc_device.cpp)727
-rw-r--r--gralloc960/mali_gralloc_bufferallocation.h31
-rw-r--r--gralloc960/mali_gralloc_bufferdescriptor.cpp201
-rw-r--r--gralloc960/mali_gralloc_bufferdescriptor.h68
-rw-r--r--gralloc960/mali_gralloc_debug.cpp143
-rw-r--r--gralloc960/mali_gralloc_debug.h39
-rw-r--r--gralloc960/mali_gralloc_formats.cpp1060
-rw-r--r--gralloc960/mali_gralloc_formats.h304
-rw-r--r--gralloc960/mali_gralloc_ion.cpp770
-rw-r--r--gralloc960/mali_gralloc_ion.h33
-rw-r--r--gralloc960/mali_gralloc_module.cpp193
-rw-r--r--gralloc960/mali_gralloc_module.h102
-rw-r--r--gralloc960/mali_gralloc_private_interface.cpp281
-rw-r--r--gralloc960/mali_gralloc_private_interface.h73
-rw-r--r--gralloc960/mali_gralloc_private_interface_types.h86
-rw-r--r--gralloc960/mali_gralloc_public_interface.cpp451
-rw-r--r--gralloc960/mali_gralloc_public_interface.h25
-rw-r--r--gralloc960/mali_gralloc_reference.cpp158
-rw-r--r--gralloc960/mali_gralloc_reference.h27
-rw-r--r--gralloc960/mali_gralloc_usages.h92
-rw-r--r--hifi/firmware/hifi-hikey960.imgbin12520 -> 110844 bytes
-rw-r--r--hifi/xaf/Android.mk (renamed from self-extractors_hikey960/arm/staging/BoardConfigPartial.mk)6
-rwxr-xr-xhifi/xaf/README39
-rwxr-xr-xhifi/xaf/config/hifi3_hikey960_linux.tgzbin0 -> 23977955 bytes
-rwxr-xr-xhifi/xaf/config/hifi3_hikey960_win32.tgzbin0 -> 21077520 bytes
-rwxr-xr-xhifi/xaf/docs/HiFi-AF-Hosted-ProgrammersGuide.pdfbin0 -> 1447614 bytes
-rwxr-xr-xhifi/xaf/docs/HiFi-Audio-Codec-API-Definition.pdfbin0 -> 765944 bytes
-rwxr-xr-xhifi/xaf/docs/HiFi-Speech-Codec-API-Definition.pdfbin0 -> 620160 bytes
-rwxr-xr-xhifi/xaf/docs/HiKey960-HiFi3-Android-SDK-Guide.pdfbin0 -> 369215 bytes
-rwxr-xr-xhifi/xaf/docs/Hosted_XAF_Arch_v0.7.pdfbin0 -> 339183 bytes
-rw-r--r--hifi/xaf/hifi-dpf/app/xa-factory.c163
-rw-r--r--hifi/xaf/hifi-dpf/audio/xa-class-audio-codec.c785
-rw-r--r--hifi/xaf/hifi-dpf/audio/xa-class-base.c537
-rw-r--r--hifi/xaf/hifi-dpf/audio/xa-class-base.h263
-rw-r--r--hifi/xaf/hifi-dpf/audio/xa-class-mixer.c870
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/Makefile135
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/common.mk156
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.x827
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xbn827
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xn827
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xr42
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xu42
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/memmap.xmm49
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/min-rt.parm15
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/specs22
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/tag3
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/user.parm (renamed from self-extractors/Android.mk)0
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/map_hikey.txt2167
-rwxr-xr-xhifi/xaf/hifi-dpf/build_hikey/tools/elftobin.sh94
-rw-r--r--hifi/xaf/hifi-dpf/build_hikey/xa_hikey.imgbin0 -> 110396 bytes
-rw-r--r--hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub-entry.S198
-rw-r--r--hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub.c756
-rw-r--r--hifi/xaf/hifi-dpf/core/util/gdbstub/xtensa-defs.h37
-rw-r--r--hifi/xaf/hifi-dpf/core/util/mutex.c156
-rw-r--r--hifi/xaf/hifi-dpf/core/util/rbtree.c842
-rw-r--r--hifi/xaf/hifi-dpf/core/util/tinyvprintf.c198
-rw-r--r--hifi/xaf/hifi-dpf/core/xf-core.c709
-rw-r--r--hifi/xaf/hifi-dpf/core/xf-io.c644
-rw-r--r--hifi/xaf/hifi-dpf/core/xf-isr.c68
-rw-r--r--hifi/xaf/hifi-dpf/core/xf-mem.c361
-rw-r--r--hifi/xaf/hifi-dpf/core/xf-msg.c107
-rw-r--r--hifi/xaf/hifi-dpf/core/xf-sched.c153
-rw-r--r--hifi/xaf/hifi-dpf/core/xf-shmem.c350
-rw-r--r--hifi/xaf/hifi-dpf/include/audio/xa-audio-decoder-api.h66
-rw-r--r--hifi/xaf/hifi-dpf/include/audio/xa-mixer-api.h157
-rw-r--r--hifi/xaf/hifi-dpf/include/audio/xa_apicmd_standards.h107
-rw-r--r--hifi/xaf/hifi-dpf/include/audio/xa_error_standards.h79
-rw-r--r--hifi/xaf/hifi-dpf/include/audio/xa_memory_standards.h104
-rw-r--r--hifi/xaf/hifi-dpf/include/audio/xa_type_def.h98
-rw-r--r--hifi/xaf/hifi-dpf/include/lib/mutex.h59
-rw-r--r--hifi/xaf/hifi-dpf/include/lib/rbtree.h157
-rw-r--r--hifi/xaf/hifi-dpf/include/lib/tinyput.h31
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/arch_hifi330.h134
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/cpu_c.h109
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_comm.h45
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_debug.h71
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_ipc.h61
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_mailbox.h171
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_memory_config.h96
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_pcm_gain.h37
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/reset.h62
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/xf-board.h180
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-config.h63
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-hal.h151
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-ipc.h345
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-mem.h180
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-runtime.h81
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-shmem.h173
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-sys.h75
-rw-r--r--hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-types.h55
-rw-r--r--hifi/xaf/hifi-dpf/include/xa_profiler.h156
-rw-r--r--hifi/xaf/hifi-dpf/include/xa_timer.h111
-rw-r--r--hifi/xaf/hifi-dpf/include/xf-component.h91
-rw-r--r--hifi/xaf/hifi-dpf/include/xf-core.h150
-rw-r--r--hifi/xaf/hifi-dpf/include/xf-debug.h216
-rw-r--r--hifi/xaf/hifi-dpf/include/xf-io.h298
-rw-r--r--hifi/xaf/hifi-dpf/include/xf-mm.h142
-rw-r--r--hifi/xaf/hifi-dpf/include/xf-msg.h252
-rw-r--r--hifi/xaf/hifi-dpf/include/xf-opcode.h290
-rw-r--r--hifi/xaf/hifi-dpf/include/xf-plugin.h48
-rw-r--r--hifi/xaf/hifi-dpf/include/xf-proxy.h102
-rw-r--r--hifi/xaf/hifi-dpf/include/xf-sched.h98
-rw-r--r--hifi/xaf/hifi-dpf/include/xf-timebase.h132
-rw-r--r--hifi/xaf/hifi-dpf/include/xf-trace.h82
-rw-r--r--hifi/xaf/hifi-dpf/include/xf.h112
-rw-r--r--hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/arch_hifi330.S468
-rw-r--r--hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/cpu_c.c152
-rw-r--r--hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_comm.c75
-rw-r--r--hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_debug.c468
-rw-r--r--hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/int_vector.S830
-rw-r--r--hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/reset.S460
-rw-r--r--hifi/xaf/hifi-dpf/ipc/xt-shmem/xf-main.c189
-rw-r--r--hifi/xaf/hifi-dpf/plugins/cadence/mixer/xa-mixer.c669
-rw-r--r--hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm-api.h145
-rw-r--r--hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm.c841
-rw-r--r--hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.abin0 -> 124410 bytes
-rw-r--r--hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa-vorbis-decoder.c84
-rw-r--r--hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa_vorbis_dec_api.h121
-rw-r--r--hifi/xaf/host-apf/Android.mk66
-rw-r--r--hifi/xaf/host-apf/include/audio/xa-audio-decoder-api.h46
-rw-r--r--hifi/xaf/host-apf/include/audio/xa-mixer-api.h154
-rw-r--r--hifi/xaf/host-apf/include/audio/xa-pcm-api.h138
-rw-r--r--hifi/xaf/host-apf/include/audio/xa_apicmd_standards.h107
-rw-r--r--hifi/xaf/host-apf/include/audio/xa_error_standards.h79
-rw-r--r--hifi/xaf/host-apf/include/audio/xa_memory_standards.h104
-rw-r--r--hifi/xaf/host-apf/include/audio/xa_type_def.h98
-rw-r--r--hifi/xaf/host-apf/include/audio/xa_vorbis_dec_api.h121
-rw-r--r--hifi/xaf/host-apf/include/os/android/xf-osal.h215
-rw-r--r--hifi/xaf/host-apf/include/os/xos/xf-osal.h206
-rw-r--r--hifi/xaf/host-apf/include/sys/fio/xf-config.h36
-rw-r--r--hifi/xaf/host-apf/include/sys/fio/xf-hal.h34
-rw-r--r--hifi/xaf/host-apf/include/sys/fio/xf-ipc.h127
-rw-r--r--hifi/xaf/host-apf/include/sys/fio/xf-runtime.h35
-rw-r--r--hifi/xaf/host-apf/include/sys/fio/xf-types.h88
-rw-r--r--hifi/xaf/host-apf/include/xaf-api.h139
-rw-r--r--hifi/xaf/host-apf/include/xaf-structs.h82
-rw-r--r--hifi/xaf/host-apf/include/xf-debug.h194
-rw-r--r--hifi/xaf/host-apf/include/xf-opcode.h297
-rw-r--r--hifi/xaf/host-apf/include/xf-proto.h82
-rw-r--r--hifi/xaf/host-apf/include/xf-proxy.h297
-rw-r--r--hifi/xaf/host-apf/include/xf.h53
-rw-r--r--hifi/xaf/host-apf/playback/tinyalsa/asoundlib.h314
-rw-r--r--hifi/xaf/host-apf/playback/tinyalsa/pcm.c1311
-rw-r--r--hifi/xaf/host-apf/playback/xa_playback.c366
-rw-r--r--hifi/xaf/host-apf/playback/xa_playback.h42
-rw-r--r--hifi/xaf/host-apf/proxy/xaf-api.c597
-rw-r--r--hifi/xaf/host-apf/proxy/xf-fio.c193
-rw-r--r--hifi/xaf/host-apf/proxy/xf-proxy.c686
-rw-r--r--hifi/xaf/host-apf/proxy/xf-trace.c90
-rwxr-xr-xhifi/xaf/host-apf/tools/dhifimesgbin0 -> 6264 bytes
-rw-r--r--hifi/xaf/host-apf/utest/include/xaf-mem.h49
-rw-r--r--hifi/xaf/host-apf/utest/include/xaf-utils-test.h37
-rw-r--r--hifi/xaf/host-apf/utest/xaf-dec-mix-test.c421
-rw-r--r--hifi/xaf/host-apf/utest/xaf-dec-test.c344
-rw-r--r--hifi/xaf/host-apf/utest/xaf-mem-test.c150
-rw-r--r--hifi/xaf/host-apf/utest/xaf-utils-test.c69
-rwxr-xr-xhifi/xaf/release.txt24
-rw-r--r--hikey-common.mk4
-rw-r--r--hikey.mk7
-rw-r--r--hikey/BoardConfig.mk14
-rw-r--r--hikey/README14
-rw-r--r--hikey/device-hikey.mk25
-rw-r--r--hikey/fstab.hikey6
-rw-r--r--hikey/fstab.hikey-3.189
-rw-r--r--hikey960.mk2
-rw-r--r--hikey960/BoardConfig.mk13
-rw-r--r--hikey960/README1
-rw-r--r--hikey960/device-hikey960.mk33
-rw-r--r--hikey960/fstab.hikey9606
-rw-r--r--init.common.rc8
-rw-r--r--init.hikey960.power.rc2
-rwxr-xr-xinstaller/hikey/flash-all.sh2
-rw-r--r--installer/hikey/ptable-aosp-4g.imgbin17408 -> 17408 bytes
-rw-r--r--installer/hikey/ptable-aosp-8g.imgbin17408 -> 17408 bytes
-rw-r--r--installer/hikey960/README12
-rw-r--r--installer/hikey960/fip.binbin0 -> 1513984 bytes
-rwxr-xr-xinstaller/hikey960/flash-all.sh7
-rw-r--r--installer/hikey960/hisi-bl31.bin (renamed from installer/hikey960/bl31.bin)bin148968 -> 148968 bytes
-rw-r--r--installer/hikey960/hisi-lpm3.img (renamed from installer/hikey960/lpm3.img)bin217344 -> 217344 bytes
-rw-r--r--installer/hikey960/hisi-nvme.img (renamed from installer/hikey960/nvme.img)bin131072 -> 131072 bytes
-rw-r--r--installer/hikey960/hisi-sec_xloader.imgbin154752 -> 154752 bytes
-rw-r--r--installer/hikey960/l-loader.binbin0 -> 25712 bytes
-rw-r--r--installer/hikey960/prm_ptable.imgbin0 -> 24576 bytes
-rwxr-xr-xinstaller/hikey960/uefi-flash-all.sh76
-rwxr-xr-xl-loader/generate_ptable.sh4
-rw-r--r--libmemtrack/Android.mk2
-rw-r--r--mali/Android.mk31
-rw-r--r--mali/bifrost/Android.mk37
-rw-r--r--mali/bifrost/END_USER_LICENCE_AGREEMENT.txt194
-rwxr-xr-xmali/bifrost/lib/egl/libGLES_mali.sobin0 -> 38643628 bytes
-rwxr-xr-xmali/bifrost/lib/hw/android.hardware.renderscript@1.0-impl.sobin0 -> 54184 bytes
-rwxr-xr-xmali/bifrost/lib/hw/gralloc.hikey960.sobin0 -> 41728 bytes
l---------mali/bifrost/lib/hw/vulkan.hikey960.so1
-rwxr-xr-xmali/bifrost/lib/libRSDriverArm.sobin0 -> 224248 bytes
-rw-r--r--mali/bifrost/lib/libmalicore.bcbin0 -> 123056 bytes
-rwxr-xr-xmali/bifrost/lib64/egl/libGLES_mali.sobin0 -> 39559944 bytes
-rwxr-xr-xmali/bifrost/lib64/hw/android.hardware.renderscript@1.0-impl.sobin0 -> 60576 bytes
-rwxr-xr-xmali/bifrost/lib64/hw/gralloc.hikey960.sobin0 -> 40232 bytes
l---------mali/bifrost/lib64/hw/vulkan.hikey960.so1
-rwxr-xr-xmali/bifrost/lib64/libRSDriverArm.sobin0 -> 281848 bytes
-rwxr-xr-xmali/bifrost/lib64/libbccArm.sobin0 -> 301352 bytes
-rw-r--r--mali/bifrost/lib64/libmalicore.bcbin0 -> 137384 bytes
-rw-r--r--mali/utgard/Android.mk26
-rw-r--r--mali/utgard/END_USER_LICENCE_AGREEMENT.txt194
-rwxr-xr-xmali/utgard/lib/egl/libGLES_mali.sobin0 -> 1339400 bytes
-rwxr-xr-xmali/utgard/lib64/egl/libGLES_mali.sobin0 -> 1391320 bytes
-rw-r--r--manifest.xml105
-rw-r--r--power/Android.mk6
-rw-r--r--power/power_hikey.c2
-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/extract-lists.txt6
-rw-r--r--self-extractors/linaro/COPYRIGHT1
-rw-r--r--self-extractors/linaro/LICENSE177
-rw-r--r--self-extractors/linaro/staging/device-partial.mk19
-rw-r--r--self-extractors/root/BoardConfigVendor.mk17
-rw-r--r--self-extractors/root/device-vendor.mk19
-rw-r--r--self-extractors_hikey960/arm/COPYRIGHT1
-rw-r--r--self-extractors_hikey960/arm/LICENSE177
-rw-r--r--self-extractors_hikey960/arm/staging/device-partial.mk20
-rw-r--r--self-extractors_hikey960/extract-lists.txt18
-rw-r--r--self-extractors_hikey960/hisilicon/COPYRIGHT1
-rw-r--r--self-extractors_hikey960/hisilicon/LICENSE126
-rw-r--r--self-extractors_hikey960/hisilicon/staging/BoardConfigPartial.mk (renamed from self-extractors/linaro/staging/BoardConfigPartial.mk)0
-rw-r--r--self-extractors_hikey960/hisilicon/staging/device-partial.mk32
-rw-r--r--self-extractors_hikey960/root/device-vendor.mk2
-rw-r--r--sepolicy/file_contexts13
-rw-r--r--sepolicy/hal_graphics_allocator_default.te2
-rw-r--r--sepolicy/hal_graphics_composer_default.te2
-rw-r--r--sepolicy/healthd.te1
-rw-r--r--sepolicy/init.te3
-rw-r--r--sepolicy/netd.te1
-rw-r--r--sepolicy/surfaceflinger.te1
-rw-r--r--sepolicy/system_server.te5
-rw-r--r--ueventd.common.rc7
-rwxr-xr-xvendorsetup.sh25
-rw-r--r--vndk/Android.mk28
281 files changed, 36655 insertions, 3410 deletions
diff --git a/AndroidProducts.mk b/AndroidProducts.mk
index 1b16eec2..1fc71292 100644
--- a/AndroidProducts.mk
+++ b/AndroidProducts.mk
@@ -10,7 +10,12 @@
#
PRODUCT_MAKEFILES := \
-$(LOCAL_DIR)/hikey.mk \
-$(LOCAL_DIR)/hikey32.mk \
-$(LOCAL_DIR)/hikey64_only.mk \
-$(LOCAL_DIR)/hikey960.mk
+ $(LOCAL_DIR)/hikey.mk \
+ $(LOCAL_DIR)/hikey32.mk \
+ $(LOCAL_DIR)/hikey64_only.mk \
+ $(LOCAL_DIR)/hikey960.mk
+
+COMMON_LUNCH_CHOICES := \
+ hikey-userdebug \
+ hikey64_only-userdebug \
+ hikey960-userdebug
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
index eb64ac65..c6fac23e 100644
--- a/BoardConfigCommon.mk
+++ b/BoardConfigCommon.mk
@@ -11,12 +11,21 @@ TARGET_2ND_CPU_ABI2 := armeabi
TARGET_USES_64_BIT_BINDER := true
-WITH_DEXPREOPT ?= true
USE_OPENGL_RENDERER := true
# BT configs
BOARD_HAVE_BLUETOOTH := true
+# HACK! hikey64_only doesn't build w/ VNDK_VERSION=current
+# This is due to software codecs being required but only
+# building for 32bit. Remove the conditional once 64bit
+# soft-codecs work
+ifeq ($(filter hikey64, $(TARGET_DEVICE)),)
+# enable Treble
+PRODUCT_FULL_TREBLE_OVERRIDE := true
+BOARD_VNDK_VERSION := current
+endif
+
# generic wifi
WPA_SUPPLICANT_VERSION := VER_0_8_X
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
@@ -33,7 +42,6 @@ BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
TARGET_USE_PAN_DISPLAY := true
TARGET_USES_HWC2 := true
-SF_START_GRAPHICS_ALLOCATOR_SERVICE := true
TARGET_AUX_OS_VARIANT_LIST := neonkey argonkey
diff --git a/audio/Android.mk b/audio/Android.mk
index fe091a84..0a02789e 100644
--- a/audio/Android.mk
+++ b/audio/Android.mk
@@ -22,8 +22,11 @@ LOCAL_PATH := $(call my-dir)
# required type is 'primary'. Other possibilites are 'a2dp', 'usb', etc.
include $(CLEAR_VARS)
+LOCAL_HEADER_LIBRARIES += libhardware_headers
LOCAL_MODULE := audio.primary.$(TARGET_BOARD_PLATFORM)
LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_VENDOR_MODULE := true
+
LOCAL_SRC_FILES := audio_hw.c
LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa
LOCAL_CFLAGS := -Wno-unused-parameter
@@ -33,5 +36,16 @@ LOCAL_C_INCLUDES += \
system/media/audio_utils/include \
system/media/audio_effects/include
+ifeq ($(TARGET_ENABLE_DSP_DEVICE), true)
+LOCAL_CFLAGS += -DENABLE_XAF_DSP_DEVICE
+LOCAL_C_INCLUDES += \
+ $(LOCAL_PATH)/../hifi/xaf/host-apf/include \
+ $(LOCAL_PATH)/../hifi/xaf/host-apf/include/os/android \
+ $(LOCAL_PATH)/../hifi/xaf/host-apf/include/sys/fio\
+ $(LOCAL_PATH)/../hifi/xaf/host-apf/include/audio \
+ $(LOCAL_PATH)/../hifi/xaf/host-apf/utest/include
+
+LOCAL_STATIC_LIBRARIES := libxtensa_proxy
+endif
include $(BUILD_SHARED_LIBRARY)
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index a62c3446..56b3e141 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -23,8 +23,9 @@
#include <stdint.h>
#include <sys/time.h>
#include <stdlib.h>
+#include <unistd.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/str_parms.h>
#include <cutils/properties.h>
@@ -59,6 +60,33 @@
#define CHANNEL_STEREO 2
#define MIN_WRITE_SLEEP_US 5000
+#ifdef ENABLE_XAF_DSP_DEVICE
+#include "xaf-utils-test.h"
+#include "audio/xa_vorbis_dec_api.h"
+#include "audio/xa-audio-decoder-api.h"
+#define NUM_COMP_IN_GRAPH 1
+
+struct alsa_audio_device;
+
+struct xaf_dsp_device {
+ void *p_adev;
+ void *p_decoder;
+ xaf_info_t comp_info;
+ /* ...playback format */
+ xaf_format_t pb_format;
+ xaf_comp_status dec_status;
+ int dec_info[4];
+ void *dec_inbuf[2];
+ int read_length;
+ xf_id_t dec_id;
+ int xaf_started;
+ mem_obj_t* mem_handle;
+ int num_comp;
+ int (*dec_setup)(void *p_comp, struct alsa_audio_device *audio_device);
+ int xafinitdone;
+};
+#endif
+
struct stub_stream_in {
struct audio_stream_in stream;
};
@@ -71,7 +99,10 @@ struct alsa_audio_device {
struct alsa_stream_in *active_input;
struct alsa_stream_out *active_output;
bool mic_mute;
+#ifdef ENABLE_XAF_DSP_DEVICE
+ struct xaf_dsp_device dsp_device;
int hifi_dsp_fd;
+#endif
};
struct alsa_stream_out {
@@ -87,6 +118,134 @@ struct alsa_stream_out {
unsigned int written;
};
+#ifdef ENABLE_XAF_DSP_DEVICE
+static int pcm_setup(void *p_pcm, struct alsa_audio_device *audio_device)
+{
+ int param[6];
+
+ param[0] = XA_CODEC_CONFIG_PARAM_SAMPLE_RATE;
+ param[1] = audio_device->dsp_device.pb_format.sample_rate;
+ param[2] = XA_CODEC_CONFIG_PARAM_CHANNELS;
+ param[3] = audio_device->dsp_device.pb_format.channels;
+ param[4] = XA_CODEC_CONFIG_PARAM_PCM_WIDTH;
+ param[5] = audio_device->dsp_device.pb_format.pcm_width;
+
+ XF_CHK_API(xaf_comp_set_config(p_pcm, 3, &param[0]));
+
+ return 0;
+}
+
+void xa_thread_exit_handler(int sig)
+{
+ /* ...unused arg */
+ (void) sig;
+
+ pthread_exit(0);
+}
+
+/*xtensa audio device init*/
+static int xa_device_init(struct alsa_audio_device *audio_device)
+{
+ /* ...initialize playback format */
+ audio_device->dsp_device.p_adev = NULL;
+ audio_device->dsp_device.pb_format.sample_rate = 48000;
+ audio_device->dsp_device.pb_format.channels = 2;
+ audio_device->dsp_device.pb_format.pcm_width = 16;
+ audio_device->dsp_device.xafinitdone = 0;
+ audio_frmwk_buf_size = 0; //unused
+ audio_comp_buf_size = 0; //unused
+ audio_device->dsp_device.num_comp = NUM_COMP_IN_GRAPH;
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = xa_thread_exit_handler;
+ sigaction(SIGUSR1,&actions,NULL);
+ /* ...initialize tracing facility */
+ audio_device->dsp_device.xaf_started =1;
+ audio_device->dsp_device.dec_id = "audio-decoder/pcm";
+ audio_device->dsp_device.dec_setup = pcm_setup;
+ audio_device->dsp_device.mem_handle = mem_init(); //initialize memory handler
+ XF_CHK_API(xaf_adev_open(&audio_device->dsp_device.p_adev, audio_frmwk_buf_size, audio_comp_buf_size, mem_malloc, mem_free));
+ /* ...create decoder component */
+ XF_CHK_API(xaf_comp_create(audio_device->dsp_device.p_adev, &audio_device->dsp_device.p_decoder, audio_device->dsp_device.dec_id, 1, 1, &audio_device->dsp_device.dec_inbuf[0], XAF_DECODER));
+ XF_CHK_API(audio_device->dsp_device.dec_setup(audio_device->dsp_device.p_decoder,audio_device));
+
+ /* ...start decoder component */
+ XF_CHK_API(xaf_comp_process(audio_device->dsp_device.p_adev, audio_device->dsp_device.p_decoder, NULL, 0, XAF_START_FLAG));
+ return 0;
+}
+
+static int xa_device_run(struct audio_stream_out *stream, const void *buffer, size_t frame_size, size_t out_frames, size_t bytes)
+{
+ struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
+ struct alsa_audio_device *adev = out->dev;
+ int ret=0;
+ void *p_comp=adev->dsp_device.p_decoder;
+ xaf_comp_status comp_status;
+ memcpy(adev->dsp_device.dec_inbuf[0],buffer,bytes);
+ adev->dsp_device.read_length=bytes;
+
+ if (adev->dsp_device.xafinitdone == 0) {
+ XF_CHK_API(xaf_comp_process(adev->dsp_device.p_adev, adev->dsp_device.p_decoder, adev->dsp_device.dec_inbuf[0], adev->dsp_device.read_length, XAF_INPUT_READY_FLAG));
+ XF_CHK_API(xaf_comp_get_status(adev->dsp_device.p_adev, adev->dsp_device.p_decoder, &adev->dsp_device.dec_status, &adev->dsp_device.comp_info));
+ ALOGE("PROXY:%s xaf_comp_get_status %d\n",__func__,adev->dsp_device.dec_status);
+ if (adev->dsp_device.dec_status == XAF_INIT_DONE) {
+ adev->dsp_device.xafinitdone = 1;
+ out->written += out_frames;
+ XF_CHK_API(xaf_comp_process(NULL, p_comp, NULL, 0, XAF_EXEC_FLAG));
+ }
+ } else {
+ XF_CHK_API(xaf_comp_process(NULL, adev->dsp_device.p_decoder, adev->dsp_device.dec_inbuf[0], adev->dsp_device.read_length, XAF_INPUT_READY_FLAG));
+ while (1) {
+ XF_CHK_API(xaf_comp_get_status(NULL, p_comp, &comp_status, &adev->dsp_device.comp_info));
+ if (comp_status == XAF_EXEC_DONE) break;
+ if (comp_status == XAF_NEED_INPUT) {
+ ALOGV("PROXY:%s loop:XAF_NEED_INPUT\n",__func__);
+ break;
+ }
+ if (comp_status == XAF_OUTPUT_READY) {
+ void *p_buf = (void *)adev->dsp_device.comp_info.buf;
+ int size = adev->dsp_device.comp_info.length;
+ ret = pcm_mmap_write(out->pcm, p_buf, size);
+ if (ret == 0) {
+ out->written += out_frames;
+ }
+ XF_CHK_API(xaf_comp_process(NULL, adev->dsp_device.p_decoder, (void *)adev->dsp_device.comp_info.buf, adev->dsp_device.comp_info.length, XAF_NEED_OUTPUT_FLAG));
+ }
+ }
+ }
+ return ret;
+}
+
+static int xa_device_close(struct alsa_audio_device *audio_device)
+{
+ if (audio_device->dsp_device.xaf_started) {
+ xaf_comp_status comp_status;
+ audio_device->dsp_device.xaf_started=0;
+ while (1) {
+ XF_CHK_API(xaf_comp_get_status(NULL, audio_device->dsp_device.p_decoder, &comp_status, &audio_device->dsp_device.comp_info));
+ ALOGV("PROXY:comp_status:%d,audio_device->dsp_device.comp_info.length:%d\n",(int)comp_status,audio_device->dsp_device.comp_info.length);
+ if (comp_status == XAF_EXEC_DONE)
+ break;
+ if (comp_status == XAF_NEED_INPUT) {
+ XF_CHK_API(xaf_comp_process(NULL, audio_device->dsp_device.p_decoder, NULL, 0, XAF_INPUT_OVER_FLAG));
+ }
+
+ if (comp_status == XAF_OUTPUT_READY) {
+ XF_CHK_API(xaf_comp_process(NULL, audio_device->dsp_device.p_decoder, (void *)audio_device->dsp_device.comp_info.buf, audio_device->dsp_device.comp_info.length, XAF_NEED_OUTPUT_FLAG));
+ }
+ }
+
+ /* ...exec done, clean-up */
+ XF_CHK_API(xaf_comp_delete(audio_device->dsp_device.p_decoder));
+ XF_CHK_API(xaf_adev_close(audio_device->dsp_device.p_adev, 0 /*unused*/));
+ mem_exit();
+ XF_CHK_API(print_mem_mcps_info(audio_device->dsp_device.mem_handle, audio_device->dsp_device.num_comp));
+ }
+ return 0;
+}
+#endif
/* must be called with hw device and output stream mutexes locked */
static int start_output_stream(struct alsa_stream_out *out)
@@ -181,6 +340,9 @@ static int out_standby(struct audio_stream *stream)
pthread_mutex_lock(&out->dev->lock);
pthread_mutex_lock(&out->lock);
+#ifdef ENABLE_XAF_DSP_DEVICE
+ xa_device_close(out->dev);
+#endif
status = do_output_standby(out);
pthread_mutex_unlock(&out->lock);
pthread_mutex_unlock(&out->dev->lock);
@@ -249,7 +411,6 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
struct alsa_audio_device *adev = out->dev;
size_t frame_size = audio_stream_out_frame_size(stream);
size_t out_frames = bytes / frame_size;
- struct misc_io_pcm_buf_param pcmbuf;
/* acquiring hw device mutex systematically is useful if a low priority thread is waiting
* on the output stream mutex - e.g. executing select_mode() while holding the hw device
@@ -258,6 +419,11 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
pthread_mutex_lock(&adev->lock);
pthread_mutex_lock(&out->lock);
if (out->standby) {
+#ifdef ENABLE_XAF_DSP_DEVICE
+ if (adev->hifi_dsp_fd >= 0) {
+ xa_device_init(adev);
+ }
+#endif
ret = start_output_stream(out);
if (ret != 0) {
pthread_mutex_unlock(&adev->lock);
@@ -268,19 +434,19 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
pthread_mutex_unlock(&adev->lock);
- if (adev->hifi_dsp_fd >= 0) {
- pcmbuf.buf = (uint64_t)buffer;
- pcmbuf.buf_size = bytes;
- ret = ioctl(adev->hifi_dsp_fd, HIFI_MISC_IOCTL_PCM_GAIN, &pcmbuf);
- if (ret) {
- ALOGV("hifi_dsp: Error buffer processing: %d", errno);
+#ifdef ENABLE_XAF_DSP_DEVICE
+ /*fallback to original audio processing*/
+ if (adev->dsp_device.p_adev != NULL) {
+ ret = xa_device_run(stream, buffer,frame_size, out_frames, bytes);
+ } else {
+#endif
+ ret = pcm_mmap_write(out->pcm, buffer, out_frames * frame_size);
+ if (ret == 0) {
+ out->written += out_frames;
}
+#ifdef ENABLE_XAF_DSP_DEVICE
}
-
- ret = pcm_mmap_write(out->pcm, buffer, out_frames * frame_size);
- if (ret == 0) {
- out->written += out_frames;
- }
+#endif
exit:
pthread_mutex_unlock(&out->lock);
@@ -638,11 +804,14 @@ static int adev_dump(const audio_hw_device_t *device, int fd)
static int adev_close(hw_device_t *device)
{
+#ifdef ENABLE_XAF_DSP_DEVICE
struct alsa_audio_device *adev = (struct alsa_audio_device *)device;
-
+#endif
ALOGV("adev_close");
+#ifdef ENABLE_XAF_DSP_DEVICE
if (adev->hifi_dsp_fd >= 0)
close(adev->hifi_dsp_fd);
+#endif
free(device);
return 0;
}
@@ -686,13 +855,14 @@ static int adev_open(const hw_module_t* module, const char* name,
adev->devices = AUDIO_DEVICE_NONE;
*device = &adev->hw_device.common;
-
+#ifdef ENABLE_XAF_DSP_DEVICE
adev->hifi_dsp_fd = open(HIFI_DSP_MISC_DRIVER, O_WRONLY, 0);
if (adev->hifi_dsp_fd < 0) {
ALOGW("hifi_dsp: Error opening device %d", errno);
} else {
ALOGI("hifi_dsp: Open device");
}
+#endif
return 0;
}
diff --git a/bootloader/EFI/BOOT/fastboot.efi b/bootloader/EFI/BOOT/fastboot.efi
deleted file mode 100644
index 8758eb5c..00000000
--- a/bootloader/EFI/BOOT/fastboot.efi
+++ /dev/null
Binary files differ
diff --git a/bootloader/EFI/BOOT/grub.cfg b/bootloader/EFI/BOOT/grub.cfg
deleted file mode 100644
index f8a13a74..00000000
--- a/bootloader/EFI/BOOT/grub.cfg
+++ /dev/null
@@ -1,41 +0,0 @@
-set default="0"
-set timeout=1
-menuentry 'AOSP' {
- search.fs_label boot root
- set root=($root)
- linux /kernel console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime printk.devkmsg=on androidboot.serialno=0123456789
- initrd /ramdisk.img
- devicetree /hi6220-hikey.dtb
-}
-menuentry 'AOSP-DEBUG' {
- search.fs_label boot root
- set root=($root)
- linux /kernel earlycon=pl011,0xf7113000 no_console_suspend=1 console=ttyFIQ0 androidboot.console=ttyFIQ0 sysrq_always_enabled androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime printk.devkmsg=on androidboot.serialno=0123456789
- initrd /ramdisk.img
- devicetree /hi6220-hikey.dtb
-}
-menuentry 'AOSP-CONSOLE' {
- search.fs_label boot root
- set root=($root)
- linux /kernel console=ttyAMA3,115200 androidboot.console=ttyAMA3 fiq_debugger.disable=Y androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime printk.devkmsg=on androidboot.serialno=0123456789
- initrd /ramdisk.img
- devicetree /hi6220-hikey.dtb
-}
-menuentry 'AOSP@720P' {
- search.fs_label boot root
- set root=($root)
- linux /kernel console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime video=HDMI-A-1:1280x720@60 printk.devkmsg=on androidboot.serialno=0123456789
- initrd /ramdisk.img
- devicetree /hi6220-hikey.dtb
-}
-menuentry 'AOSP@SVGA' {
- search.fs_label boot root
- set root=($root)
- linux /kernel console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime video=HDMI-A-1:800x600@60 printk.devkmsg=on androidboot.serialno=0123456789
- initrd /ramdisk.img
- devicetree /hi6220-hikey.dtb
-}
-menuentry 'Fastboot' {
- search.fs_label boot root
- chainloader ($root)/EFI/BOOT/fastboot.efi
-}
diff --git a/bootloader/EFI/BOOT/grubaa64.efi b/bootloader/EFI/BOOT/grubaa64.efi
deleted file mode 100644
index d7561229..00000000
--- a/bootloader/EFI/BOOT/grubaa64.efi
+++ /dev/null
Binary files differ
diff --git a/bt-wifi-firmware-util/Android.mk b/bt-wifi-firmware-util/Android.mk
deleted file mode 100644
index 7e41a35e..00000000
--- a/bt-wifi-firmware-util/Android.mk
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-TI_WILINK_FW_PATH := $(TARGET_OUT_ETC)/firmware/ti-connectivity
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := TIInit_11.8.32.bts
-ifneq ($(filter hikey960, $(TARGET_DEVICE)),)
-LOCAL_SRC_FILES := TIInit_11.8.32-pcm-960.bts
-else
-LOCAL_SRC_FILES := TIInit_11.8.32.bts
-endif
-LOCAL_MODULE_CLASS := FIRMWARE
-LOCAL_MODULE_PATH := $(TI_WILINK_FW_PATH)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_OWNER := ti
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := wl18xx-fw-4.bin
-LOCAL_SRC_FILES := wl18xx-fw-4.bin
-LOCAL_MODULE_CLASS := FIRMWARE
-LOCAL_MODULE_PATH := $(TI_WILINK_FW_PATH)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_OWNER := ti
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := wl18xx-conf.bin
-ifneq ($(filter hikey960, $(TARGET_DEVICE)),)
-LOCAL_SRC_FILES := wl18xx-conf-wl1837mod.bin
-else
-LOCAL_SRC_FILES := wl18xx-conf.bin
-endif
-LOCAL_MODULE_CLASS := FIRMWARE
-LOCAL_MODULE_PATH := $(TI_WILINK_FW_PATH)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_OWNER := ti
-include $(BUILD_PREBUILT)
diff --git a/build/tasks/boot_fat.mk b/build/tasks/boot_fat.mk
deleted file mode 100644
index b65b2188..00000000
--- a/build/tasks/boot_fat.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-ifneq ($(filter hikey%, $(TARGET_DEVICE)),)
-
-ifeq ($(TARGET_BOOTIMAGE_USE_FAT), true)
-$(PRODUCT_OUT)/boot_fat.uefi.img: $(INSTALLED_KERNEL_TARGET) $(INSTALLED_RAMDISK_TARGET) $(PRODUCT_OUT)/hi6220-hikey.dtb
-# $@ is referring to $(PRODUCT_OUT)/boot_fat.uefi.img
- dd if=/dev/zero of=$@ bs=512 count=98304
- mkfs.fat -n "boot" $@
- $(FAT16COPY) $@ $(PRODUCT_OUT)/kernel
- $(FAT16COPY) $@ $(PRODUCT_OUT)/hi6220-hikey.dtb
- $(FAT16COPY) $@ device/linaro/hikey/bootloader/*
- $(FAT16COPY) $@ $(PRODUCT_OUT)/ramdisk.img
-
-droidcore: $(PRODUCT_OUT)/boot_fat.uefi.img
-endif
-
-endif
diff --git a/device-common.mk b/device-common.mk
index a6c4c3a7..e0927644 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -41,11 +41,14 @@ PRODUCT_PACKAGES += audio.a2dp.default \
tinyplay
PRODUCT_PACKAGES += \
+ android.hardware.audio@2.0-service \
android.hardware.audio@2.0-impl \
android.hardware.audio.effect@2.0-impl \
android.hardware.broadcastradio@1.0-impl \
android.hardware.soundtrigger@2.0-impl
+PRODUCT_PACKAGES += vndk_package
+
PRODUCT_PACKAGES += \
android.hardware.drm@1.0-impl \
@@ -54,7 +57,9 @@ PRODUCT_PACKAGES += libGLES_android
# Graphics HAL
PRODUCT_PACKAGES += \
android.hardware.graphics.allocator@2.0-impl \
+ android.hardware.graphics.allocator@2.0-service \
android.hardware.graphics.composer@2.1-impl \
+ android.hardware.graphics.composer@2.1-service \
android.hardware.graphics.mapper@2.0-impl
# Memtrack
@@ -62,11 +67,6 @@ PRODUCT_PACKAGES += memtrack.default \
android.hardware.memtrack@1.0-service \
android.hardware.memtrack@1.0-impl
-PRODUCT_PACKAGES += TIInit_11.8.32.bts \
- wl18xx-fw-4.bin \
- wl18xx-conf.bin
-
-
ifeq ($(HIKEY_USE_LEGACY_TI_BLUETOOTH), true)
PRODUCT_PACKAGES += android.hardware.bluetooth@1.0-service.hikey uim
else
@@ -82,7 +82,9 @@ PRODUCT_PACKAGES += \
# Keymaster HAL
PRODUCT_PACKAGES += \
- android.hardware.keymaster@3.0-impl
+ android.hardware.keymaster@3.0-impl \
+ android.hardware.keymaster@3.0-service
+
# Sensor HAL
ifneq ($(TARGET_SENSOR_MEZZANINE),)
@@ -107,21 +109,21 @@ PRODUCT_COPY_FILES += \
# Copy sensors config file(s)
PRODUCT_COPY_FILES += \
- frameworks/native/data/etc/android.hardware.sensor.accelerometer.xml:system/etc/permissions/android.hardware.sensor.accelerometer.xml \
- frameworks/native/data/etc/android.hardware.sensor.ambient_temperature.xml:system/etc/permissions/android.hardware.sensor.ambient_temperature.xml \
- frameworks/native/data/etc/android.hardware.sensor.barometer.xml:system/etc/permissions/android.hardware.sensor.barometer.xml \
- frameworks/native/data/etc/android.hardware.sensor.compass.xml:system/etc/permissions/android.hardware.sensor.compass.xml \
- frameworks/native/data/etc/android.hardware.sensor.gyroscope.xml:system/etc/permissions/android.hardware.sensor.gyroscope.xml \
- frameworks/native/data/etc/android.hardware.sensor.hifi_sensors.xml:system/etc/permissions/android.hardware.sensor.hifi_sensors.xml \
- frameworks/native/data/etc/android.hardware.sensor.light.xml:system/etc/permissions/android.hardware.sensor.light.xml \
- frameworks/native/data/etc/android.hardware.sensor.relative_humidity.xml:system/etc/permissions/android.hardware.sensor.relative_humidity.xml \
- frameworks/native/data/etc/android.hardware.sensor.stepcounter.xml:system/etc/permissions/android.hardware.sensor.stepcounter.xml \
- frameworks/native/data/etc/android.hardware.sensor.stepdetector.xml:system/etc/permissions/android.hardware.sensor.stepdetector.xml
+ frameworks/native/data/etc/android.hardware.sensor.accelerometer.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.accelerometer.xml \
+ frameworks/native/data/etc/android.hardware.sensor.ambient_temperature.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.ambient_temperature.xml \
+ frameworks/native/data/etc/android.hardware.sensor.barometer.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.barometer.xml \
+ frameworks/native/data/etc/android.hardware.sensor.compass.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.compass.xml \
+ frameworks/native/data/etc/android.hardware.sensor.gyroscope.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.gyroscope.xml \
+ frameworks/native/data/etc/android.hardware.sensor.hifi_sensors.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.hifi_sensors.xml \
+ frameworks/native/data/etc/android.hardware.sensor.light.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.light.xml \
+ frameworks/native/data/etc/android.hardware.sensor.relative_humidity.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.relative_humidity.xml \
+ frameworks/native/data/etc/android.hardware.sensor.stepcounter.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.stepcounter.xml \
+ frameworks/native/data/etc/android.hardware.sensor.stepdetector.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.stepdetector.xml
# Argonkey VL53L0X proximity driver is not available yet. So we are going to copy conf file for neonkey only
ifeq ($(TARGET_SENSOR_MEZZANINE),neonkey)
PRODUCT_COPY_FILES += \
- frameworks/native/data/etc/android.hardware.sensor.proximity.xml:system/etc/permissions/android.hardware.sensor.proximity.xml
+ frameworks/native/data/etc/android.hardware.sensor.proximity.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.sensor.proximity.xml
endif
# VR HAL
@@ -142,25 +144,25 @@ PRODUCT_PACKAGES += Launcher3QuickStep
# Copy hardware config file(s)
PRODUCT_COPY_FILES += \
- device/linaro/hikey/etc/permissions/android.hardware.screen.xml:system/etc/permissions/android.hardware.screen.xml \
- frameworks/native/data/etc/android.software.cts.xml:system/etc/permissions/android.software.cts.xml \
- frameworks/native/data/etc/android.software.app_widgets.xml:system/etc/permissions/android.software.app_widgets.xml \
- frameworks/native/data/etc/android.software.backup.xml:system/etc/permissions/android.software.backup.xml \
- frameworks/native/data/etc/android.software.voice_recognizers.xml:system/etc/permissions/android.software.voice_recognizers.xml \
- frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml \
- frameworks/native/data/etc/android.hardware.usb.accessory.xml:system/etc/permissions/android.hardware.usb.accessory.xml \
- frameworks/native/data/etc/android.hardware.usb.host.xml:system/etc/permissions/android.hardware.usb.host.xml \
- frameworks/native/data/etc/android.software.device_admin.xml:system/etc/permissions/android.software.device_admin.xml
+ device/linaro/hikey/etc/permissions/android.hardware.screen.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.screen.xml \
+ frameworks/native/data/etc/android.software.cts.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.cts.xml \
+ frameworks/native/data/etc/android.software.app_widgets.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.app_widgets.xml \
+ frameworks/native/data/etc/android.software.backup.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.backup.xml \
+ frameworks/native/data/etc/android.software.voice_recognizers.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.voice_recognizers.xml \
+ frameworks/native/data/etc/android.hardware.ethernet.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.ethernet.xml \
+ frameworks/native/data/etc/android.hardware.usb.accessory.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.accessory.xml \
+ frameworks/native/data/etc/android.hardware.usb.host.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.host.xml \
+ frameworks/native/data/etc/android.software.device_admin.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.device_admin.xml
# Include BT modules
$(call inherit-product-if-exists, device/linaro/hikey/wpan/ti-wpan-products.mk)
PRODUCT_COPY_FILES += \
- frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \
- frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.direct.xml \
- frameworks/native/data/etc/android.hardware.bluetooth.xml:system/etc/permissions/android.hardware.bluetooth.xml \
- frameworks/native/data/etc/android.hardware.bluetooth_le.xml:system/etc/permissions/android.hardware.bluetooth_le.xml \
- device/linaro/hikey/wpa_supplicant.conf:system/etc/wifi/wpa_supplicant.conf \
+ frameworks/native/data/etc/android.hardware.wifi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.xml \
+ frameworks/native/data/etc/android.hardware.wifi.direct.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.direct.xml \
+ frameworks/native/data/etc/android.hardware.bluetooth.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth.xml \
+ frameworks/native/data/etc/android.hardware.bluetooth_le.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth_le.xml \
+ device/linaro/hikey/wpa_supplicant.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/wpa_supplicant.conf \
$(LOCAL_PATH)/wpa_supplicant_overlay.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/wpa_supplicant_overlay.conf \
$(LOCAL_PATH)/p2p_supplicant_overlay.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/p2p_supplicant_overlay.conf
@@ -176,5 +178,37 @@ PRODUCT_COPY_FILES += \
# Copy media codecs config file
PRODUCT_COPY_FILES += \
- device/linaro/hikey/etc/media_codecs.xml:system/etc/media_codecs.xml \
- frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml
+ device/linaro/hikey/etc/media_codecs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_audio.xml
+
+PRODUCT_PACKAGES += \
+ android.hardware.renderscript@1.0.vndk-sp\
+ android.hardware.graphics.composer@2.1.vndk-sp\
+ android.hardware.graphics.allocator@2.0.vndk-sp\
+ android.hardware.graphics.mapper@2.0.vndk-sp\
+ android.hardware.graphics.common@1.0.vndk-sp\
+ libvndksupport.vndk-sp\
+ libbinder.vndk-sp\
+ libhwbinder.vndk-sp\
+ libbase.vndk-sp\
+ libfmq.vndk-sp\
+ libcutils.vndk-sp\
+ libhardware.vndk-sp\
+ libhidlbase.vndk-sp\
+ libhidltransport.vndk-sp\
+ libui.vndk-sp\
+ libutils.vndk-sp\
+ libc++.vndk-sp\
+ libRS_internal.vndk-sp\
+ libRSDriver.vndk-sp\
+ libRSCpuRef.vndk-sp\
+ libbcinfo.vndk-sp\
+ libblas.vndk-sp\
+ libft2.vndk-sp\
+ libpng.vndk-sp\
+ libcompiler_rt.vndk-sp\
+ libbacktrace.vndk-sp\
+ libunwind.vndk-sp\
+ libunwindstack.vndk-sp\
+ liblzma.vndk-sp\
+ libion.vndk-sp\
diff --git a/etc/media_codecs.xml b/etc/media_codecs.xml
index 424914d8..43bb0d8f 100644
--- a/etc/media_codecs.xml
+++ b/etc/media_codecs.xml
@@ -78,6 +78,69 @@ Only the three quirks included above are recognized at this point:
<MediaCodecs>
<Include href="media_codecs_google_audio.xml" />
<Decoders>
+ <MediaCodec name="OMX.hisi.video.decoder.avc" type="video/avc" >
+ <Quirk name="needs-flush-on-all-ports" />
+ <Limit name="size" min="128x128" max="4096x2304" />
+ <Limit name="alignment" value="2x2" />
+ <Limit name="block-size" value="16x16" />
+ <Limit name="blocks-per-second" min="1" max="972000" />
+ <Limit name="bitrate" range="1-100000000" />
+ <Feature name="adaptive-playback" />
+ <Quirk name="requires-allocate-on-input-ports" />
+ <Quirk name="requires-allocate-on-output-ports" />
+ <Limit name="concurrent-instances" max="16" />
+ </MediaCodec>
+ <MediaCodec name="OMX.hisi.video.decoder.hevc" type="video/hevc" >
+ <Quirk name="needs-flush-on-all-ports" />
+ <Limit name="size" min="128x128" max="4096x2304" />
+ <Limit name="alignment" value="2x2" />
+ <Limit name="block-size" value="16x16" />
+ <Limit name="block-count" range="64-36896" />
+ <Limit name="blocks-per-second" range="99-1106880" />
+ <Limit name="bitrate" range="1-52428800" />
+ <Feature name="adaptive-playback" />
+ <Quirk name="requires-allocate-on-input-ports" />
+ <Quirk name="requires-allocate-on-output-ports" />
+ <Limit name="concurrent-instances" max="16" />
+ </MediaCodec>
+ <MediaCodec name="OMX.hisi.video.decoder.mpeg4" type="video/mp4v-es" >
+ <Quirk name="needs-flush-on-all-ports" />
+ <Limit name="size" min="128x128" max="1920x1088" />
+ <Limit name="alignment" value="2x2" />
+ <Limit name="block-size" value="16x16" />
+ <Limit name="blocks-per-second" range="99-244800" />
+ <Limit name="bitrate" range="1-60000000" />
+ <Feature name="adaptive-playback" />
+ <Quirk name="requires-allocate-on-input-ports" />
+ <Quirk name="requires-allocate-on-output-ports" />
+ <Limit name="concurrent-instances" max="16" />
+ </MediaCodec>
+ <MediaCodec name="OMX.hisi.video.decoder.mpeg2" >
+ <Quirk name="needs-flush-on-all-ports" />
+ <Limit name="size" min="128x128" max="1920x1088" />
+ <Limit name="alignment" value="2x2" />
+ <Limit name="block-size" value="16x16" />
+ <Limit name="blocks-per-second" range="99-244800" />
+ <Limit name="bitrate" range="1-60000000" />
+ <Feature name="adaptive-playback" />
+ <Quirk name="requires-allocate-on-input-ports" />
+ <Quirk name="requires-allocate-on-output-ports" />
+ <Limit name="concurrent-instances" max="16" />
+ <Type name="video/mpeg2">
+ <Limit name="concurrent-instances" max="16" />
+ </Type>
+ <Type name="video/mpeg">
+ <Limit name="concurrent-instances" max="16" />
+ </Type>
+ </MediaCodec>
+ <MediaCodec name="OMX.hisi.video.decoder.vp8" type="video/x-vnd.on2.vp8" >
+ <Limit name="size" min="128x128" max="1920x1088" />
+ <Quirk name="needs-flush-on-all-ports" />
+ <Quirk name="requires-allocate-on-input-ports" />
+ <Quirk name="requires-allocate-on-output-ports" />
+ <Feature name="adaptive-playback" />
+ <Limit name="concurrent-instances" max="16" />
+ </MediaCodec>
<MediaCodec name="OMX.google.mpeg4.decoder" type="video/mp4v-es" />
<MediaCodec name="OMX.google.h263.decoder" type="video/3gpp" />
<MediaCodec name="OMX.google.h264.decoder" type="video/avc" />
diff --git a/factory-images/generate-factory-images-hikey960.sh b/factory-images/generate-factory-images-hikey960.sh
index ce270275..30cd7b8b 100755
--- a/factory-images/generate-factory-images-hikey960.sh
+++ b/factory-images/generate-factory-images-hikey960.sh
@@ -32,13 +32,13 @@ rm -rf tmp
mkdir -p tmp/$PRODUCT-$VERSION
# copy over bootloader binaries
-cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/bl31.bin tmp/$PRODUCT-$VERSION/
+cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/hisi-bl31.bin tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/hisi-fastboot.img tmp/$PRODUCT-$VERSION/
-cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/lpm3.img tmp/$PRODUCT-$VERSION/
-cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/nvme.img tmp/$PRODUCT-$VERSION/
+cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/hisi-lpm3.img tmp/$PRODUCT-$VERSION/
+cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/hisi-nvme.img tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/hisi-ptable.img tmp/$PRODUCT-$VERSION/
-cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/README tmp/$PRODUCT-$VERSION/
cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/hisi-sec_xloader.img tmp/$PRODUCT-$VERSION/
+cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/README tmp/$PRODUCT-$VERSION/
# copy over dts.img
cp $ANDROID_BUILD_TOP/out/target/product/hikey960/dt.img tmp/$PRODUCT-$VERSION/
@@ -72,13 +72,13 @@ cat > tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
-fastboot flash xloader sec_xloader.img
-fastboot flash ptable ptable.img
-fastboot flash fastboot fastboot.img
+fastboot flash xloader hisi-sec_xloader.img
+fastboot flash ptable hisi-ptable.img
+fastboot flash fastboot hisi-fastboot.img
fastboot reboot-bootloader
-fastboot flash nvme nvme.img
-fastboot flash fw_lpm3 lpm3.img
-fastboot flash trustfirmware bl31.bin
+fastboot flash nvme hisi-nvme.img
+fastboot flash fw_lpm3 hisi-lpm3.img
+fastboot flash trustfirmware hisi-bl31.bin
fastboot flash dts dt.img
# XXX fastboot update doesn't format cache and userdata
diff --git a/gralloc/Android.mk b/gralloc/Android.mk
index fc62685a..8c418425 100644
--- a/gralloc/Android.mk
+++ b/gralloc/Android.mk
@@ -1,4 +1,6 @@
+#
# Copyright (C) 2010 ARM Limited. All rights reserved.
+#
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,15 +15,32 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+
LOCAL_PATH := $(call my-dir)
# HAL module implemenation, not prelinked and stored in
# hw/<OVERLAY_HARDWARE_MODULE_ID>.<ro.product.board>.so
include $(CLEAR_VARS)
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_VENDOR_MODULE := true
+
+MALI_DDK_TEST_PATH := hardware/arm/
+
+LOCAL_MODULE := gralloc.hikey
+#LOCAL_MODULE_TAGS := optional
+# Mali-200/300/400MP DDK
+MALI_DDK_PATH := hardware/arm/mali
+#SHARED_MEM_LIBS := libUMP
SHARED_MEM_LIBS := libion libhardware
-LOCAL_SHARED_LIBRARIES := liblog libcutils libGLESv1_CM $(SHARED_MEM_LIBS)
-LOCAL_C_INCLUDES := system/core/include/
+LOCAL_SHARED_LIBRARIES := liblog libsync libGLESv1_CM $(SHARED_MEM_LIBS)
+
+LOCAL_C_INCLUDES := system/core/include/ $(MALI_DDK_PATH)/include
+# Include the UMP header files
+LOCAL_C_INCLUDES += $(MALI_DDK_PATH)/src/ump/include
+
LOCAL_CFLAGS := -DLOG_TAG=\"gralloc\" -DGRALLOC_32_BITS -DSTANDARD_LINUX_SCREEN -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
LOCAL_SRC_FILES := \
@@ -29,7 +48,5 @@ LOCAL_SRC_FILES := \
alloc_device.cpp \
framebuffer_device.cpp
-LOCAL_MODULE := gralloc.hikey
-LOCAL_MODULE_RELATIVE_PATH := hw
-
+#LOCAL_CFLAGS+= -DMALI_VSYNC_EVENT_REPORT_ENABLE
include $(BUILD_SHARED_LIBRARY)
diff --git a/gralloc/alloc_device.cpp b/gralloc/alloc_device.cpp
index 488e47c2..076cb5ce 100644
--- a/gralloc/alloc_device.cpp
+++ b/gralloc/alloc_device.cpp
@@ -44,8 +44,6 @@
#include "ion_4.12.h"
#endif
-#define GRALLOC_ALIGN( value, base ) (((value) + ((base) - 1)) & ~((base) - 1))
-
#if GRALLOC_SIMULATE_FAILURES
#include <cutils/properties.h>
@@ -96,6 +94,27 @@ static int __ump_alloc_should_fail()
}
#endif
+#ifdef FBIOGET_DMABUF
+static int fb_get_framebuffer_dmabuf(private_module_t *m, private_handle_t *hnd)
+{
+ struct fb_dmabuf_export fb_dma_buf;
+ int res;
+ res = ioctl(m->framebuffer->fd, FBIOGET_DMABUF, &fb_dma_buf);
+
+ if (res == 0)
+ {
+ hnd->share_fd = fb_dma_buf.fd;
+ return 0;
+ }
+ else
+ {
+ AINF("FBIOGET_DMABUF ioctl failed(%d). See gralloc_priv.h and the integration manual for vendor framebuffer "
+ "integration",
+ res);
+ return -1;
+ }
+}
+#endif
static int gralloc_alloc_buffer(alloc_device_t *dev, size_t size, int usage, buffer_handle_t *pHandle)
{
@@ -103,9 +122,26 @@ static int gralloc_alloc_buffer(alloc_device_t *dev, size_t size, int usage, buf
{
private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module);
ion_user_handle_t ion_hnd;
- unsigned char *cpu_ptr;
+ void *cpu_ptr = MAP_FAILED;
int shared_fd;
int ret;
+ unsigned int heap_mask;
+ int lock_state = 0;
+ int map_mask = 0;
+
+ if (usage & GRALLOC_USAGE_PROTECTED)
+ {
+#if defined(ION_HEAP_SECURE_MASK)
+ heap_mask = ION_HEAP_SECURE_MASK;
+#else
+ AERR("The platform does NOT support protected ION memory.");
+ return -1;
+#endif
+ }
+ else
+ {
+ heap_mask = ION_HEAP_SYSTEM_MASK;
+ }
if (m->gralloc_legacy_ion)
{
@@ -149,7 +185,16 @@ static int gralloc_alloc_buffer(alloc_device_t *dev, size_t size, int usage, buf
}
}
- cpu_ptr = (unsigned char *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, shared_fd, 0);
+ if (!(usage & GRALLOC_USAGE_PROTECTED))
+ {
+ map_mask = PROT_READ | PROT_WRITE;
+ }
+ else
+ {
+ map_mask = PROT_WRITE;
+ }
+
+ cpu_ptr = mmap(NULL, size, map_mask, MAP_SHARED, shared_fd, 0);
if (MAP_FAILED == cpu_ptr)
{
@@ -159,7 +204,9 @@ static int gralloc_alloc_buffer(alloc_device_t *dev, size_t size, int usage, buf
return -1;
}
- private_handle_t *hnd = new private_handle_t(private_handle_t::PRIV_FLAGS_USES_ION, usage, size, cpu_ptr, private_handle_t::LOCK_STATE_MAPPED);
+ lock_state = private_handle_t::LOCK_STATE_MAPPED;
+
+ private_handle_t *hnd = new private_handle_t(private_handle_t::PRIV_FLAGS_USES_ION, usage, size, cpu_ptr, lock_state);
if (NULL != hnd)
{
@@ -173,6 +220,7 @@ static int gralloc_alloc_buffer(alloc_device_t *dev, size_t size, int usage, buf
}
close(shared_fd);
+
ret = munmap(cpu_ptr, size);
if (0 != ret)
@@ -213,48 +261,55 @@ static int gralloc_alloc_buffer(alloc_device_t *dev, size_t size, int usage, buf
else
#endif
{
- ump_mem_handle = ump_ref_drv_allocate(size, constraints);
-
- if (UMP_INVALID_MEMORY_HANDLE != ump_mem_handle)
+ if (usage & GRALLOC_USAGE_PROTECTED)
{
- cpu_ptr = ump_mapped_pointer_get(ump_mem_handle);
+ AERR("gralloc_alloc_buffer() does not support to allocate protected UMP memory.");
+ }
+ else
+ {
+ ump_mem_handle = ump_ref_drv_allocate(size, constraints);
- if (NULL != cpu_ptr)
+ if (UMP_INVALID_MEMORY_HANDLE != ump_mem_handle)
{
- ump_id = ump_secure_id_get(ump_mem_handle);
+ cpu_ptr = ump_mapped_pointer_get(ump_mem_handle);
- if (UMP_INVALID_SECURE_ID != ump_id)
+ if (NULL != cpu_ptr)
{
- private_handle_t *hnd = new private_handle_t(private_handle_t::PRIV_FLAGS_USES_UMP, usage, size, cpu_ptr,
- private_handle_t::LOCK_STATE_MAPPED, ump_id, ump_mem_handle);
+ ump_id = ump_secure_id_get(ump_mem_handle);
- if (NULL != hnd)
+ if (UMP_INVALID_SECURE_ID != ump_id)
{
- *pHandle = hnd;
- return 0;
+ private_handle_t *hnd = new private_handle_t(private_handle_t::PRIV_FLAGS_USES_UMP, usage, size, cpu_ptr,
+ private_handle_t::LOCK_STATE_MAPPED, ump_id, ump_mem_handle);
+
+ if (NULL != hnd)
+ {
+ *pHandle = hnd;
+ return 0;
+ }
+ else
+ {
+ AERR("gralloc_alloc_buffer() failed to allocate handle. ump_handle = %p, ump_id = %d", ump_mem_handle, ump_id);
+ }
}
else
{
- AERR("gralloc_alloc_buffer() failed to allocate handle. ump_handle = %p, ump_id = %d", ump_mem_handle, ump_id);
+ AERR("gralloc_alloc_buffer() failed to retrieve valid secure id. ump_handle = %p", ump_mem_handle);
}
+
+ ump_mapped_pointer_release(ump_mem_handle);
}
else
{
- AERR("gralloc_alloc_buffer() failed to retrieve valid secure id. ump_handle = %p", ump_mem_handle);
+ AERR("gralloc_alloc_buffer() failed to map UMP memory. ump_handle = %p", ump_mem_handle);
}
- ump_mapped_pointer_release(ump_mem_handle);
+ ump_reference_release(ump_mem_handle);
}
else
{
- AERR("gralloc_alloc_buffer() failed to map UMP memory. ump_handle = %p", ump_mem_handle);
+ AERR("gralloc_alloc_buffer() failed to allocate UMP memory. size:%d constraints: %d", size, constraints);
}
-
- ump_reference_release(ump_mem_handle);
- }
- else
- {
- AERR("gralloc_alloc_buffer() failed to allocate UMP memory. size:%d constraints: %d", size, constraints);
}
}
@@ -280,7 +335,7 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t *dev, size_t size, in
}
}
- const uint32_t bufferMask = m->bufferMask;
+ uint32_t bufferMask = m->bufferMask;
const uint32_t numBuffers = m->numBuffers;
const size_t bufferSize = m->finfo.line_length * m->info.yres;
@@ -296,8 +351,9 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t *dev, size_t size, in
if (bufferMask >= ((1LU << numBuffers) - 1))
{
- // We ran out of buffers.
- return -ENOMEM;
+ // We ran out of buffers, reset bufferMask.
+ bufferMask = 0;
+ m->bufferMask = 0;
}
void *vaddr = m->framebuffer->base;
@@ -314,10 +370,10 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t *dev, size_t size, in
vaddr = (void *)((uintptr_t)vaddr + bufferSize);
}
- int fbdev_fd = m->framebuffer->shallow_fbdev_fd;
// The entire framebuffer memory is already mapped, now create a buffer object for parts of this memory
private_handle_t *hnd = new private_handle_t(private_handle_t::PRIV_FLAGS_FRAMEBUFFER, usage, size, vaddr,
- 0, fbdev_fd, (uintptr_t)vaddr - (uintptr_t) m->framebuffer->base);
+ 0, m->framebuffer->fd, (uintptr_t)vaddr - (uintptr_t) m->framebuffer->base, m->framebuffer->fb_paddr);
+
#if GRALLOC_ARM_UMP_MODULE
hnd->ump_id = m->framebuffer->ump_id;
@@ -337,19 +393,23 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t *dev, size_t size, in
#if GRALLOC_ARM_DMA_BUF_MODULE
{
#ifdef FBIOGET_DMABUF
- struct fb_dmabuf_export fb_dma_buf;
-
- if (ioctl(fbdev_fd, FBIOGET_DMABUF, &fb_dma_buf) == 0)
+ /*
+ * Perform allocator specific actions. If these fail we fall back to a regular buffer
+ * which will be memcpy'ed to the main screen when fb_post is called.
+ */
+ if (fb_get_framebuffer_dmabuf(m, hnd) == -1)
{
- AINF("framebuffer accessed with dma buf (fd 0x%x)\n", (int)fb_dma_buf.fd);
- hnd->share_fd = fb_dma_buf.fd;
- }
+ int newUsage = (usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D;
+ AINF("Fallback to single buffering. Unable to map framebuffer memory to handle:%p", hnd);
+ return gralloc_alloc_buffer(dev, bufferSize, newUsage, pHandle);
+ }
#endif
}
// correct numFds/numInts when there is no dmabuf fd
- if (hnd->share_fd < 0) {
+ if (hnd->share_fd < 0)
+ {
hnd->numFds--;
hnd->numInts++;
}
@@ -400,7 +460,12 @@ static int alloc_device_alloc(alloc_device_t *dev, int w, int h, int format, int
#ifdef SUPPORT_LEGACY_FORMAT
case HAL_PIXEL_FORMAT_YCbCr_420_P:
#endif
- stride = GRALLOC_ALIGN(w, 16);
+ /*
+ * Since Utgard has limitation that "64-byte alignment is enforced on texture and mipmap addresses", here to make sure
+ * the v, u plane start addresses are 64-byte aligned.
+ */
+ stride = GRALLOC_ALIGN(w, (h % 8 == 0) ? GRALLOC_ALIGN_BASE_16 :
+ ((h % 4 == 0) ? GRALLOC_ALIGN_BASE_64 : GRALLOC_ALIGN_BASE_128));
size = GRALLOC_ALIGN(h, 2) * (stride + GRALLOC_ALIGN(stride / 2, 16));
break;
@@ -530,7 +595,7 @@ static int alloc_device_alloc(alloc_device_t *dev, int w, int h, int format, int
return 0;
}
-static int alloc_device_free(alloc_device_t *dev, buffer_handle_t handle)
+static int alloc_device_free(alloc_device_t __unused *dev, buffer_handle_t handle)
{
if (private_handle_t::validate(handle) < 0)
{
@@ -541,12 +606,6 @@ static int alloc_device_free(alloc_device_t *dev, buffer_handle_t handle)
if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
{
- // free this buffer
- private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module);
- const size_t bufferSize = m->finfo.line_length * m->info.yres;
- int index = ((uintptr_t)hnd->base - (uintptr_t)m->framebuffer->base) / bufferSize;
- m->bufferMask &= ~(1 << index);
-
#if GRALLOC_ARM_UMP_MODULE
if ((int)UMP_INVALID_MEMORY_HANDLE != hnd->ump_mem_handle)
@@ -568,7 +627,7 @@ static int alloc_device_free(alloc_device_t *dev, buffer_handle_t handle)
}
#else
- AERR("Can't free ump memory for handle:0x%p. Not supported.", hnd);
+ AERR("Can't free ump memory for handle:%p. Not supported.", hnd);
#endif
}
else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
@@ -579,7 +638,7 @@ static int alloc_device_free(alloc_device_t *dev, buffer_handle_t handle)
{
if (0 != munmap((void *)hnd->base, hnd->size))
{
- AERR("Failed to munmap handle 0x%p", hnd);
+ AERR("Failed to munmap handle %p", hnd);
}
}
diff --git a/gralloc/alloc_device.h b/gralloc/alloc_device.h
index 534a0d68..563c27c7 100644
--- a/gralloc/alloc_device.h
+++ b/gralloc/alloc_device.h
@@ -19,17 +19,23 @@
#include <hardware/hardware.h>
#ifndef AWAR
-#define AWAR(fmt, args...) __android_log_print(ANDROID_LOG_WARN, "[Gralloc-Warning]", "%s:%d " fmt,__func__,__LINE__,args)
+#define AWAR(fmt, args...) __android_log_print(ANDROID_LOG_WARN, "[Gralloc-Warning]", "%s:%d " fmt,__func__,__LINE__,##args)
#endif
#ifndef AINF
-#define AINF(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "[Gralloc]", fmt,args)
+#define AINF(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "[Gralloc]", fmt,##args)
#endif
#ifndef AERR
-#define AERR(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "[Gralloc-ERROR]", "%s:%d " fmt,__func__,__LINE__,args)
+#define AERR(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "[Gralloc-ERROR]", "%s:%d " fmt,__func__,__LINE__,##args)
#endif
#ifndef AERR_IF
#define AERR_IF( eq, fmt, args...) if ( (eq) ) AERR( fmt, args )
#endif
+#define GRALLOC_ALIGN( value, base ) (((value) + ((base) - 1)) & ~((base) - 1))
+
+#define GRALLOC_ALIGN_BASE_16 16
+#define GRALLOC_ALIGN_BASE_64 64
+#define GRALLOC_ALIGN_BASE_128 128
+
// Create an alloc device
int alloc_device_open(hw_module_t const *module, const char *name, hw_device_t **device);
diff --git a/gralloc/framebuffer_device.cpp b/gralloc/framebuffer_device.cpp
index bacefeed..6ab88a58 100644
--- a/gralloc/framebuffer_device.cpp
+++ b/gralloc/framebuffer_device.cpp
@@ -22,6 +22,7 @@
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <stdlib.h>
+
#include <cutils/log.h>
#include <cutils/atomic.h>
#include <hardware/hardware.h>
@@ -85,20 +86,17 @@ static int fb_post(struct framebuffer_device_t *dev, buffer_handle_t buffer)
m->base.lock(&m->base, buffer, private_module_t::PRIV_USAGE_LOCKED_FOR_POST,
0, 0, m->info.xres, m->info.yres, NULL);
- const size_t offset = (uintptr_t)hnd->base - (uintptr_t)m->framebuffer->base;
int interrupt;
m->info.activate = FB_ACTIVATE_VBL;
- m->info.yoffset = offset / m->finfo.line_length;
+ m->info.yoffset = hnd->offset / m->finfo.line_length;
#ifdef STANDARD_LINUX_SCREEN
#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
#define S3CFB_SET_VSYNC_INT _IOW('F', 206, unsigned int)
- int fbdev_fd = m->framebuffer->shallow_fbdev_fd;
-
- if (ioctl(fbdev_fd, FBIOPAN_DISPLAY, &m->info) == -1)
+ if (ioctl(m->framebuffer->fd, FBIOPAN_DISPLAY, &m->info) == -1)
{
- AERR("FBIOPAN_DISPLAY failed for fd: %d", fbdev_fd);
+ AERR("FBIOPAN_DISPLAY failed for fd: %d", m->framebuffer->fd);
m->base.unlock(&m->base, buffer);
return 0;
}
@@ -108,9 +106,9 @@ static int fb_post(struct framebuffer_device_t *dev, buffer_handle_t buffer)
// enable VSYNC
interrupt = 1;
- if (ioctl(fbdev_fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0)
+ if (ioctl(m->framebuffer->fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0)
{
- // AERR("S3CFB_SET_VSYNC_INT enable failed for fd: %d", fbdev_fd);
+ // AERR("S3CFB_SET_VSYNC_INT enable failed for fd: %d", m->framebuffer->fd);
return 0;
}
@@ -120,9 +118,9 @@ static int fb_post(struct framebuffer_device_t *dev, buffer_handle_t buffer)
#endif
int crtc = 0;
- if (ioctl(fbdev_fd, FBIO_WAITFORVSYNC, &crtc) < 0)
+ if (ioctl(m->framebuffer->fd, FBIO_WAITFORVSYNC, &crtc) < 0)
{
- AERR("FBIO_WAITFORVSYNC failed for fd: %d", fbdev_fd);
+ AERR("FBIO_WAITFORVSYNC failed for fd: %d", m->framebuffer->fd);
#ifdef MALI_VSYNC_EVENT_REPORT_ENABLE
gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT);
#endif
@@ -135,9 +133,9 @@ static int fb_post(struct framebuffer_device_t *dev, buffer_handle_t buffer)
// disable VSYNC
interrupt = 0;
- if (ioctl(fbdev_fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0)
+ if (ioctl(m->framebuffer->fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0)
{
- AERR("S3CFB_SET_VSYNC_INT disable failed for fd: %d", fbdev_fd);
+ AERR("S3CFB_SET_VSYNC_INT disable failed for fd: %d", m->framebuffer->fd);
return 0;
}
}
@@ -148,9 +146,9 @@ static int fb_post(struct framebuffer_device_t *dev, buffer_handle_t buffer)
gralloc_mali_vsync_report(MALI_VSYNC_EVENT_BEGIN_WAIT);
#endif
- if (ioctl(fbdev_fd, FBIOPUT_VSCREENINFO, &m->info) == -1)
+ if (ioctl(m->framebuffer->fd, FBIOPUT_VSCREENINFO, &m->info) == -1)
{
- AERR("FBIOPUT_VSCREENINFO failed for fd: %d", fbdev_fd);
+ AERR("FBIOPUT_VSCREENINFO failed for fd: %d", m->framebuffer->fd);
#ifdef MALI_VSYNC_EVENT_REPORT_ENABLE
gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT);
#endif
@@ -254,14 +252,14 @@ int init_frame_buffer_locked(struct private_module_t *module)
* Explicitly request 8/8/8
*/
info.bits_per_pixel = 32;
- info.red.offset = 0;
+ info.red.offset = 16;
info.red.length = 8;
info.green.offset = 8;
info.green.length = 8;
- info.blue.offset = 16;
+ info.blue.offset = 0;
info.blue.length = 8;
- info.transp.offset = 24;
- info.transp.length = 8;
+ info.transp.offset = 0;
+ info.transp.length = 0;
#endif
/*
@@ -385,7 +383,11 @@ int init_frame_buffer_locked(struct private_module_t *module)
// Create a "fake" buffer object for the entire frame buffer memory, and store it in the module
module->framebuffer = new private_handle_t(private_handle_t::PRIV_FLAGS_FRAMEBUFFER, 0, fbSize, vaddr,
- 0, fd, 0);
+ 0, fd, 0, (void *)finfo.smem_start);
+
+ /* There is no share_fd in framebuffer handle, correct numFds/numInts */
+ module->framebuffer->numFds--;
+ module->framebuffer->numInts++;
module->numBuffers = info.yres_virtual / info.yres;
module->bufferMask = 0;
@@ -471,12 +473,6 @@ int framebuffer_device_open(hw_module_t const *module, const char *name, hw_devi
/* initialize our state here */
framebuffer_device_t *dev = (framebuffer_device_t *)malloc(sizeof(framebuffer_device_t));
- if (dev == NULL)
- {
- AERR("Error to malloc the framebuffer (%s)", strerror(errno));
- gralloc_close(gralloc_device);
- return -ENOMEM;
- }
memset(dev, 0, sizeof(*dev));
/* initialize the procs */
@@ -497,7 +493,7 @@ int framebuffer_device_open(hw_module_t const *module, const char *name, hw_devi
#ifdef GRALLOC_16_BITS
const_cast<int &>(dev->format) = HAL_PIXEL_FORMAT_RGB_565;
#else
- const_cast<int &>(dev->format) = HAL_PIXEL_FORMAT_RGBA_8888;
+ const_cast<int &>(dev->format) = HAL_PIXEL_FORMAT_BGRA_8888;
#endif
const_cast<float &>(dev->xdpi) = m->xdpi;
const_cast<float &>(dev->ydpi) = m->ydpi;
diff --git a/gralloc/gralloc_module.cpp b/gralloc/gralloc_module.cpp
index 38ed3dad..84054736 100644
--- a/gralloc/gralloc_module.cpp
+++ b/gralloc/gralloc_module.cpp
@@ -19,6 +19,8 @@
#include <errno.h>
#include <pthread.h>
#include <string.h>
+//#include <sync/sync.h>
+#include <android/sync.h>
#include <cutils/log.h>
#include <cutils/atomic.h>
@@ -64,7 +66,7 @@ static int gralloc_register_buffer(gralloc_module_t const *module, buffer_handle
if (private_handle_t::validate(handle) < 0)
{
- AERR("Registering invalid buffer 0x%p, returning error", handle);
+ AERR("Registering invalid buffer %p, returning error", handle);
return -EINVAL;
}
@@ -97,9 +99,8 @@ static int gralloc_register_buffer(gralloc_module_t const *module, buffer_handle
if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
{
- AINF("Register framebuffer 0x%p is no-op", handle);
+ AINF("Register buffer %p although it will be treated as a nop", handle);
retval = 0;
-
}
else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP)
{
@@ -114,6 +115,7 @@ static int gralloc_register_buffer(gralloc_module_t const *module, buffer_handle
{
hnd->writeOwner = 0;
hnd->lockState &= ~(private_handle_t::LOCK_STATE_UNREGISTERED);
+
pthread_mutex_unlock(&s_map_lock);
return 0;
}
@@ -130,7 +132,7 @@ static int gralloc_register_buffer(gralloc_module_t const *module, buffer_handle
}
#else
- AERR("Gralloc does not support UMP. Unable to register UMP memory for handle 0x%p", hnd);
+ AERR("Gralloc does not support UMP. Unable to register UMP memory for handle %p", hnd);
#endif
}
else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
@@ -147,7 +149,7 @@ static int gralloc_register_buffer(gralloc_module_t const *module, buffer_handle
}
else
{
- AERR("Could not get gralloc module for handle: 0x%p", hnd);
+ AERR("Could not get gralloc module for handle: %p", hnd);
retval = -errno;
goto cleanup;
}
@@ -163,7 +165,7 @@ static int gralloc_register_buffer(gralloc_module_t const *module, buffer_handle
if (m->ion_client < 0)
{
- AERR("Could not open ion device for handle: 0x%p", hnd);
+ AERR("Could not open ion device for handle: %p", hnd);
retval = -errno;
goto cleanup;
}
@@ -180,6 +182,7 @@ static int gralloc_register_buffer(gralloc_module_t const *module, buffer_handle
hnd->base = mappedAddress + hnd->offset;
hnd->lockState &= ~(private_handle_t::LOCK_STATE_UNREGISTERED);
+
pthread_mutex_unlock(&s_map_lock);
return 0;
#endif
@@ -189,7 +192,9 @@ static int gralloc_register_buffer(gralloc_module_t const *module, buffer_handle
AERR("registering non-UMP buffer not supported. flags = %d", hnd->flags);
}
+#if GRALLOC_ARM_DMA_BUF_MODULE
cleanup:
+#endif
pthread_mutex_unlock(&s_map_lock);
return retval;
}
@@ -203,7 +208,7 @@ static void unmap_buffer(private_handle_t *hnd)
ump_reference_release((ump_handle)hnd->ump_mem_handle);
hnd->ump_mem_handle = (int)UMP_INVALID_MEMORY_HANDLE;
#else
- AERR("Can't unregister UMP buffer for handle 0x%p. Not supported", hnd);
+ AERR("Can't unregister UMP buffer for handle %p. Not supported", hnd);
#endif
}
else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
@@ -214,7 +219,7 @@ static void unmap_buffer(private_handle_t *hnd)
if (munmap(base, size) < 0)
{
- AERR("Could not munmap base:0x%p size:%lu '%s'", base, (unsigned long)size, strerror(errno));
+ AERR("Could not munmap base:%p size:%lu '%s'", base, (unsigned long)size, strerror(errno));
}
#else
@@ -238,7 +243,7 @@ static int gralloc_unregister_buffer(gralloc_module_t const *module, buffer_hand
if (private_handle_t::validate(handle) < 0)
{
- AERR("unregistering invalid buffer 0x%p, returning error", handle);
+ AERR("unregistering invalid buffer %p, returning error", handle);
return -EINVAL;
}
@@ -248,7 +253,7 @@ static int gralloc_unregister_buffer(gralloc_module_t const *module, buffer_hand
if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
{
- AERR("Can't unregister buffer 0x%p as it is a framebuffer", handle);
+ AERR("Can't unregister buffer %p as it is a framebuffer", handle);
}
else if (hnd->pid == getpid()) // never unmap buffers that were not registered in this process
{
@@ -268,7 +273,7 @@ static int gralloc_unregister_buffer(gralloc_module_t const *module, buffer_hand
}
else
{
- AERR("Trying to unregister buffer 0x%p from process %d that was not created in current process: %d", hnd, hnd->pid, getpid());
+ AERR("Trying to unregister buffer %p from process %d that was not created in current process: %d", hnd, hnd->pid, getpid());
}
return 0;
@@ -276,19 +281,27 @@ static int gralloc_unregister_buffer(gralloc_module_t const *module, buffer_hand
static int gralloc_lock(gralloc_module_t const *module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void **vaddr)
{
+
+
if (private_handle_t::validate(handle) < 0)
{
- AERR("Locking invalid buffer 0x%p, returning error", handle);
+ AERR("Locking invalid buffer %p, returning error", handle);
return -EINVAL;
}
private_handle_t *hnd = (private_handle_t *)handle;
+ if (hnd->format == HAL_PIXEL_FORMAT_YCbCr_420_888)
+ {
+ AERR("Buffer with format HAL_PIXEL_FORMAT_YCbCr_*_888 must be locked by lock_ycbcr()");
+ return -EINVAL;
+ }
+
pthread_mutex_lock(&s_map_lock);
if (hnd->lockState & private_handle_t::LOCK_STATE_UNREGISTERED)
{
- AERR("Locking on an unregistered buffer 0x%p, returning error", hnd);
+ AERR("Locking on an unregistered buffer %p, returning error", hnd);
pthread_mutex_unlock(&s_map_lock);
return -EINVAL;
}
@@ -315,13 +328,93 @@ static int gralloc_lock(gralloc_module_t const *module, buffer_handle_t handle,
return 0;
}
+static int gralloc_lock_ycbcr(gralloc_module_t const *module, buffer_handle_t handle, int usage, int l, int t, int w, int h, struct android_ycbcr *ycbcr)
+{
+ int retval = 0;
+ int ystride, cstride;
+
+ if (private_handle_t::validate(handle) < 0)
+ {
+ AERR("Locking invalid buffer %p, returning error", handle);
+ return -EINVAL;
+ }
+
+ private_handle_t *hnd = (private_handle_t *)handle;
+
+ pthread_mutex_lock(&s_map_lock);
+
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP || hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
+ {
+ hnd->writeOwner = usage & GRALLOC_USAGE_SW_WRITE_MASK;
+ }
+
+ hnd->lockState |= private_handle_t::LOCK_STATE_WRITE;
+
+ pthread_mutex_unlock(&s_map_lock);
+
+
+ if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
+ {
+ switch (hnd->format)
+ {
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ ystride = cstride = GRALLOC_ALIGN(hnd->width, 16);
+ ycbcr->y = (void *)hnd->base;
+ ycbcr->cr = (void *)((unsigned char *)hnd->base + ystride * hnd->height);
+ ycbcr->cb = (void *)((unsigned char *)hnd->base + ystride * hnd->height + 1);
+ ycbcr->ystride = ystride;
+ ycbcr->cstride = cstride;
+ ycbcr->chroma_step = 2;
+ break;
+
+ case HAL_PIXEL_FORMAT_YV12:
+ /* Here to keep consistency with YV12 alignment, define the ystride according to image height. */
+ ystride = GRALLOC_ALIGN(hnd->width, (hnd->height % 8 == 0) ? GRALLOC_ALIGN_BASE_16 :
+ ((hnd->height % 4 == 0) ? GRALLOC_ALIGN_BASE_64 : GRALLOC_ALIGN_BASE_128));
+ cstride = GRALLOC_ALIGN(ystride / 2, 16);
+ ycbcr->y = (void *)hnd->base;
+ /* the ystride calc is assuming the height can at least be divided by 2 */
+ ycbcr->cr = (void *)((unsigned char *)hnd->base + ystride * GRALLOC_ALIGN(hnd->height, 2));
+ ycbcr->cb = (void *)((unsigned char *)hnd->base + ystride * GRALLOC_ALIGN(hnd->height, 2) + cstride * hnd->height / 2);
+ ycbcr->ystride = ystride;
+ ycbcr->cstride = cstride;
+ ycbcr->chroma_step = 1;
+ break;
+
+#ifdef SUPPORT_LEGACY_FORMAT
+
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ ystride = cstride = GRALLOC_ALIGN(hnd->width, 16);
+ ycbcr->y = (void *)hnd->base;
+ ycbcr->cb = (void *)((unsigned char *)hnd->base + ystride * hnd->height);
+ ycbcr->cr = (void *)((unsigned char *)hnd->base + ystride * hnd->height + 1);
+ ycbcr->ystride = ystride;
+ ycbcr->cstride = cstride;
+ ycbcr->chroma_step = 2;
+ break;
+#endif
+
+ default:
+ AERR("Can not lock buffer, invalid format: 0x%x", hnd->format);
+ retval = -EINVAL;
+ }
+ }
+
+ MALI_IGNORE(module);
+ MALI_IGNORE(l);
+ MALI_IGNORE(t);
+ MALI_IGNORE(w);
+ MALI_IGNORE(h);
+ return retval;
+}
+
static int gralloc_unlock(gralloc_module_t const *module, buffer_handle_t handle)
{
MALI_IGNORE(module);
if (private_handle_t::validate(handle) < 0)
{
- AERR("Unlocking invalid buffer 0x%p, returning error", handle);
+ AERR("Unlocking invalid buffer %p, returning error", handle);
return -EINVAL;
}
@@ -332,18 +425,25 @@ static int gralloc_unlock(gralloc_module_t const *module, buffer_handle_t handle
#if GRALLOC_ARM_UMP_MODULE
ump_cpu_msync_now((ump_handle)hnd->ump_mem_handle, UMP_MSYNC_CLEAN_AND_INVALIDATE, (void *)hnd->base, hnd->size);
#else
- AERR("Buffer 0x%p is UMP type but it is not supported", hnd);
+ AERR("Buffer %p is UMP type but it is not supported", hnd);
#endif
}
else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION && hnd->writeOwner)
{
#if GRALLOC_ARM_DMA_BUF_MODULE
hw_module_t *pmodule = NULL;
+ private_module_t *m = NULL;
- if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&pmodule) != 0)
+ if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&pmodule) == 0)
+ {
+ m = reinterpret_cast<private_module_t *>(pmodule);
+ //ion_sync_fd(m->ion_client, hnd->share_fd);
+ }
+ else
{
- AERR("Couldnot get gralloc module for handle 0x%p\n", handle);
+ AERR("Couldnot get gralloc module for handle %p\n", handle);
}
+
#endif
}
@@ -362,11 +462,48 @@ static int gralloc_unlock(gralloc_module_t const *module, buffer_handle_t handle
return 0;
}
+#if defined(GRALLOC_MODULE_API_VERSION_0_3)
+static int gralloc_lock_async (gralloc_module_t const *module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void **vaddr, int fenceFD)
+{
+ if (fenceFD >= 0)
+ {
+ sync_wait(fenceFD, -1);
+ close(fenceFD);
+ }
+
+ return gralloc_lock(module, handle, usage, l, t, w, h, vaddr);
+}
+
+static int gralloc_unlock_async(gralloc_module_t const *module, buffer_handle_t handle, int *fenceFD)
+{
+ *fenceFD = -1;
+
+ if (gralloc_unlock(module, handle) < 0)
+ {
+ return -EINVAL;
+ }
+
+ return 0;
+
+}
+
+static int gralloc_lock_async_ycbcr(gralloc_module_t const *module, buffer_handle_t handle, int usage, int l, int t, int w, int h, struct android_ycbcr *ycbcr, int fenceFD)
+{
+ if (fenceFD >= 0)
+ {
+ sync_wait(fenceFD, -1);
+ close(fenceFD);
+ }
+
+ return gralloc_lock_ycbcr(module, handle, usage, l, t, w, h, ycbcr);
+}
+#endif
+
// There is one global instance of the module
static struct hw_module_methods_t gralloc_module_methods =
{
- .open = gralloc_device_open,
+ .open = gralloc_device_open
};
private_module_t::private_module_t()
@@ -374,7 +511,11 @@ private_module_t::private_module_t()
#define INIT_ZERO(obj) (memset(&(obj),0,sizeof((obj))))
base.common.tag = HARDWARE_MODULE_TAG;
- base.common.version_major = 1;
+#if defined(GRALLOC_MODULE_API_VERSION_0_3)
+ base.common.version_major = GRALLOC_MODULE_API_VERSION_0_3;
+#else
+ base.common.version_major = GRALLOC_MODULE_API_VERSION_0_2;
+#endif
base.common.version_minor = 0;
base.common.id = GRALLOC_HARDWARE_MODULE_ID;
base.common.name = "Graphics Memory Allocator Module";
@@ -388,6 +529,12 @@ private_module_t::private_module_t()
base.lock = gralloc_lock;
base.unlock = gralloc_unlock;
base.perform = NULL;
+ base.lock_ycbcr = gralloc_lock_ycbcr;
+#if defined(GRALLOC_MODULE_API_VERSION_0_3)
+ base.lockAsync = gralloc_lock_async;
+ base.unlockAsync = gralloc_unlock_async;
+ base.lockAsync_ycbcr = gralloc_lock_async_ycbcr;
+#endif
INIT_ZERO(base.reserved_proc);
framebuffer = NULL;
diff --git a/gralloc/gralloc_priv.h b/gralloc/gralloc_priv.h
index 582c4875..71920e0b 100644
--- a/gralloc/gralloc_priv.h
+++ b/gralloc/gralloc_priv.h
@@ -60,6 +60,8 @@ struct fb_dmabuf_export
__u32 fd;
__u32 flags;
};
+
+/* Un-comment this line to use dma_buf framebuffer */
/*#define FBIOGET_DMABUF _IOR('F', 0x21, struct fb_dmabuf_export)*/
#if PLATFORM_SDK_VERSION >= 21
@@ -150,7 +152,7 @@ struct private_handle_t
LOCK_STATE_WRITE = 1 << 31,
LOCK_STATE_MAPPED = 1 << 30,
LOCK_STATE_UNREGISTERED = 1 << 29,
- LOCK_STATE_READ_MASK = 0x1FFFFFFF
+ LOCK_STATE_READ_MASK = 0x3FFFFFFF
};
// ints
@@ -184,11 +186,15 @@ struct private_handle_t
#endif
// Following members is for framebuffer only
- int shallow_fbdev_fd; // shallow copy, not dup'ed
+ int fd; //Shallow copy, DO NOT duplicate
int offset;
-
+ union
+ {
+ void *fb_paddr;
+ uint64_t fb_paddr_padding;
+ };
#if GRALLOC_ARM_DMA_BUF_MODULE
- ion_user_handle_t ion_hnd_UNUSED;
+ ion_user_handle_t ion_hnd;
#endif
#if GRALLOC_ARM_DMA_BUF_MODULE
@@ -221,11 +227,12 @@ struct private_handle_t
yuv_info(MALI_YUV_NO_INFO),
ump_id((int)secure_id),
ump_mem_handle((int)handle),
- shallow_fbdev_fd(0),
- offset(0)
+ fd(0),
+ offset(0),
+ fb_paddr(NULL)
#if GRALLOC_ARM_DMA_BUF_MODULE
,
- ion_hnd_UNUSED(ION_INVALID_HANDLE)
+ ion_hnd(ION_INVALID_HANDLE)
#endif
{
@@ -255,9 +262,10 @@ struct private_handle_t
ump_id((int)UMP_INVALID_SECURE_ID),
ump_mem_handle((int)UMP_INVALID_MEMORY_HANDLE),
#endif
- shallow_fbdev_fd(0),
+ fd(0),
offset(0),
- ion_hnd_UNUSED(ION_INVALID_HANDLE)
+ fb_paddr(NULL),
+ ion_hnd(ION_INVALID_HANDLE)
{
version = sizeof(native_handle);
@@ -267,7 +275,7 @@ struct private_handle_t
#endif
- private_handle_t(int flags, int usage, int size, void *base, int lock_state, int fb_file, int fb_offset):
+ private_handle_t(int flags, int usage, int size, void *base, int lock_state, int fb_file, int fb_offset, void *fb_paddr):
#if GRALLOC_ARM_DMA_BUF_MODULE
share_fd(-1),
#endif
@@ -288,11 +296,12 @@ struct private_handle_t
ump_id((int)UMP_INVALID_SECURE_ID),
ump_mem_handle((int)UMP_INVALID_MEMORY_HANDLE),
#endif
- shallow_fbdev_fd(fb_file),
- offset(fb_offset)
+ fd(fb_file),
+ offset(fb_offset),
+ fb_paddr(fb_paddr)
#if GRALLOC_ARM_DMA_BUF_MODULE
,
- ion_hnd_UNUSED(ION_INVALID_HANDLE)
+ ion_hnd(ION_INVALID_HANDLE)
#endif
{
@@ -315,21 +324,23 @@ struct private_handle_t
{
const private_handle_t *hnd = (const private_handle_t *)h;
- if (!h || h->version != sizeof(native_handle) || hnd->magic != sMagic)
+ if (!hnd || hnd->version != sizeof(native_handle) || hnd->magic != sMagic)
{
return -EINVAL;
}
int numFds = sNumFds;
int numInts = (sizeof(private_handle_t) - sizeof(native_handle)) / sizeof(int) - sNumFds;
+
#if GRALLOC_ARM_DMA_BUF_MODULE
- if (hnd->share_fd < 0) {
+ if (hnd->share_fd < 0)
+ {
numFds--;
numInts++;
}
#endif
- if (h->numFds != numFds || h->numInts != numInts)
+ if (hnd->numFds != numFds || hnd->numInts != numInts)
{
return -EINVAL;
}
diff --git a/gralloc960/Android.hikey960.mk b/gralloc960/Android.hikey960.mk
index a7bb4721..5a1a9581 100644
--- a/gralloc960/Android.hikey960.mk
+++ b/gralloc960/Android.hikey960.mk
@@ -15,10 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-$(info gralloc for hikey960)
-GRALLOC_FB_SWAP_RED_BLUE := 0
-GRALLOC_DEPTH := GRALLOC_32_BITS
-
# GPU support for AFBC 1.0
MALI_GPU_SUPPORT_AFBC_BASIC=1
# GPU support for AFBC 1.1 block split
@@ -34,12 +30,16 @@ MALI_GPU_USE_YUV_AFBC_WIDEBLK=0
# Software behaviour defines
#
+# Gralloc1 support
+GRALLOC_USE_GRALLOC1_API=0
# Use ION DMA heap for all allocations. Default is system heap.
GRALLOC_USE_ION_DMA_HEAP=0
# Use ION Compound heap for all allocations. Default is system heap.
GRALLOC_USE_ION_COMPOUND_PAGE_HEAP=0
# Properly initializes an empty AFBC buffer
GRALLOC_INIT_AFBC=0
+# fbdev bitdepth to use
+GRALLOC_DEPTH=GRALLOC_32_BITS
# When enabled, forces display framebuffer format to BGRA_8888
GRALLOC_FB_SWAP_RED_BLUE=0
# Disables the framebuffer HAL device. When a hwc impl is available.
diff --git a/gralloc960/Android.juno.mk b/gralloc960/Android.juno.mk
index e2ecd4ab..8423d2bd 100644
--- a/gralloc960/Android.juno.mk
+++ b/gralloc960/Android.juno.mk
@@ -15,6 +15,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-$(info gralloc for juno)
GRALLOC_FB_SWAP_RED_BLUE := 1
GRALLOC_DEPTH := GRALLOC_32_BITS
diff --git a/gralloc960/Android.mk b/gralloc960/Android.mk
index 04357799..35bdb8f9 100644
--- a/gralloc960/Android.mk
+++ b/gralloc960/Android.mk
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2016 ARM Limited. All rights reserved.
+# Copyright (C) 2016-2017 ARM Limited. All rights reserved.
#
# Copyright (C) 2008 The Android Open Source Project
#
@@ -46,6 +46,8 @@ MALI_DISPLAY_VERSION?=0
# Software behaviour defines
#
+# Gralloc1 support
+GRALLOC_USE_GRALLOC1_API?=0
# Use ION DMA heap for all allocations. Default is system heap.
GRALLOC_USE_ION_DMA_HEAP?=0
# Use ION Compound heap for all allocations. Default is system heap.
@@ -108,6 +110,14 @@ $(error GRALLOC_USE_ION_DMA_HEAP and GRALLOC_USE_ION_COMPOUND_PAGE_HEAP can't be
endif
endif
+PLATFORM_SDK_GREATER_THAN_24 := $(shell expr $(PLATFORM_SDK_VERSION) \> 24)
+
+ifeq ($(PLATFORM_SDK_GREATER_THAN_24), 1)
+ifeq ($(GRALLOC_EXPERIMENTAL), 1)
+ GRALLOC_USE_GRALLOC1_API := 1
+endif
+endif
+
LOCAL_C_INCLUDES := $(MALI_LOCAL_PATH) $(MALI_DDK_INCLUDES)
# General compilation flags
@@ -124,6 +134,7 @@ LOCAL_CFLAGS += -DMALI_DISPLAY_VERSION=$(MALI_DISPLAY_VERSION)
LOCAL_CFLAGS += -DMALI_VIDEO_VERSION=$(MALI_VIDEO_VERSION)
# Software behaviour flags
+LOCAL_CFLAGS += -DGRALLOC_USE_GRALLOC1_API=$(GRALLOC_USE_GRALLOC1_API)
LOCAL_CFLAGS += -DGRALLOC_DISP_W=$(GRALLOC_DISP_W)
LOCAL_CFLAGS += -DGRALLOC_DISP_H=$(GRALLOC_DISP_H)
LOCAL_CFLAGS += -DDISABLE_FRAMEBUFFER_HAL=$(GRALLOC_DISABLE_FRAMEBUFFER_HAL)
@@ -133,28 +144,39 @@ LOCAL_CFLAGS += -DGRALLOC_INIT_AFBC=$(GRALLOC_INIT_AFBC)
LOCAL_CFLAGS += -D$(GRALLOC_DEPTH)
LOCAL_CFLAGS += -DGRALLOC_FB_SWAP_RED_BLUE=$(GRALLOC_FB_SWAP_RED_BLUE)
LOCAL_CFLAGS += -DGRALLOC_ARM_NO_EXTERNAL_AFBC=$(GRALLOC_ARM_NO_EXTERNAL_AFBC)
+LOCAL_CFLAGS += -DGRALLOC_LIBRARY_BUILD=1
-LOCAL_SHARED_LIBRARIES := libhardware liblog libcutils libGLESv1_CM libion
+LOCAL_SHARED_LIBRARIES := libhardware liblog libcutils libGLESv1_CM libion libsync libutils
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
-
LOCAL_MODULE := gralloc.hikey960
LOCAL_MODULE_TAGS := optional
LOCAL_MULTILIB := both
LOCAL_SRC_FILES := \
- gralloc_module.cpp \
- alloc_device.cpp \
- alloc_ion.cpp \
- gralloc_module_ion.cpp \
+ mali_gralloc_module.cpp \
framebuffer_device.cpp \
gralloc_buffer_priv.cpp \
gralloc_vsync_${GRALLOC_VSYNC_BACKEND}.cpp \
- mali_gralloc_formats.cpp
+ mali_gralloc_bufferaccess.cpp \
+ mali_gralloc_bufferallocation.cpp \
+ mali_gralloc_bufferdescriptor.cpp \
+ mali_gralloc_ion.cpp \
+ mali_gralloc_formats.cpp \
+ mali_gralloc_reference.cpp \
+ mali_gralloc_debug.cpp
+
+ifeq ($(GRALLOC_USE_GRALLOC1_API), 1)
+LOCAL_SRC_FILES += \
+ mali_gralloc_public_interface.cpp \
+ mali_gralloc_private_interface.cpp
+else
+LOCAL_SRC_FILES += legacy/alloc_device.cpp
+endif
LOCAL_MODULE_OWNER := arm
diff --git a/gralloc960/Android.vexpress.mk b/gralloc960/Android.vexpress.mk
index 73ac1197..69324e52 100644
--- a/gralloc960/Android.vexpress.mk
+++ b/gralloc960/Android.vexpress.mk
@@ -15,6 +15,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-$(info gralloc for vexpress)
GRALLOC_FB_SWAP_RED_BLUE := 0
GRALLOC_DEPTH := GRALLOC_16_BITS
diff --git a/gralloc960/alloc_device.h b/gralloc960/alloc_device.h
deleted file mode 100644
index bcbc1dc1..00000000
--- a/gralloc960/alloc_device.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2010 ARM Limited. All rights reserved.
- *
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <hardware/hardware.h>
-
-#ifndef AWAR
-#define AWAR(fmt, args...) __android_log_print(ANDROID_LOG_WARN, "[Gralloc-Warning]", "%s:%d " fmt,__func__,__LINE__,##args)
-#endif
-#ifndef AINF
-#define AINF(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "[Gralloc]", fmt,##args)
-#endif
-#ifndef AERR
-#define AERR(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "[Gralloc-ERROR]", "%s:%d " fmt,__func__,__LINE__,##args)
-#endif
-#ifndef AERR_IF
-#define AERR_IF( eq, fmt, args...) if ( (eq) ) AERR( fmt, args )
-#endif
-
-#define GRALLOC_ALIGN( value, base ) (((value) + ((base) - 1)) & ~((base) - 1))
-
-// Create an alloc device
-int alloc_device_open(hw_module_t const* module, const char* name, hw_device_t** device);
diff --git a/gralloc960/alloc_device_allocator_specific.h b/gralloc960/alloc_device_allocator_specific.h
deleted file mode 100644
index 2de38b5d..00000000
--- a/gralloc960/alloc_device_allocator_specific.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2013 ARM Limited. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle, uint64_t fmt, int w, int h);
-
-int alloc_backend_alloc_framebuffer(struct private_module_t* m, struct private_handle_t* hnd);
-
-void alloc_backend_alloc_free(struct private_handle_t const* hnd, struct private_module_t* m);
-
-int alloc_backend_open(alloc_device_t *dev);
-
-int alloc_backend_close(struct hw_device_t *device);
diff --git a/gralloc960/alloc_ion.cpp b/gralloc960/alloc_ion.cpp
deleted file mode 100644
index 0a84aaa3..00000000
--- a/gralloc960/alloc_ion.cpp
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * Copyright (C) 2013 ARM Limited. All rights reserved.
- *
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <cstdlib>
-#include <string.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <pthread.h>
-
-#include <cutils/log.h>
-#include <cutils/atomic.h>
-#include <hardware/hardware.h>
-#include <hardware/gralloc.h>
-
-#include <sys/ioctl.h>
-
-#include "alloc_device.h"
-#include "gralloc_priv.h"
-#include "gralloc_helper.h"
-#include "framebuffer_device.h"
-#include "ion_4.12.h"
-
-#include "mali_gralloc_formats.h"
-
-#include <linux/ion.h>
-#include <ion/ion.h>
-
-static void init_afbc(uint8_t *buf, uint64_t internal_format, int w, int h)
-{
- uint32_t n_headers = (w * h) / 64;
- uint32_t body_offset = n_headers * 16;
- uint32_t headers[][4] = { {body_offset, 0x1, 0x0, 0x0}, /* Layouts 0, 3, 4 */
- {(body_offset + (1 << 28)), 0x200040, 0x4000, 0x80} /* Layouts 1, 5 */
- };
- uint32_t i, layout;
-
- /* map format if necessary (also removes internal extension bits) */
- uint64_t base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
-
- switch (base_format)
- {
- case MALI_GRALLOC_FORMAT_INTERNAL_RGBA_8888:
- case MALI_GRALLOC_FORMAT_INTERNAL_RGBX_8888:
- case MALI_GRALLOC_FORMAT_INTERNAL_RGB_888:
- case MALI_GRALLOC_FORMAT_INTERNAL_RGB_565:
- case MALI_GRALLOC_FORMAT_INTERNAL_BGRA_8888:
- layout = 0;
- break;
-
- case MALI_GRALLOC_FORMAT_INTERNAL_YV12:
- case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
- case MALI_GRALLOC_FORMAT_INTERNAL_NV21:
- layout = 1;
- break;
- default:
- layout = 0;
- }
-
- ALOGV("Writing AFBC header layout %d for format %" PRIu64, layout, base_format);
-
- for (i = 0; i < n_headers; i++)
- {
- memcpy(buf, headers[layout], sizeof(headers[layout]));
- buf += sizeof(headers[layout]);
- }
-
-}
-
-static ion_user_handle_t alloc_from_ion_heap(int ion_fd, size_t size, unsigned int heap_mask,
- unsigned int flags, int *min_pgsz)
-{
- ion_user_handle_t ion_hnd = -1;
- int ret;
-
- if ((ion_fd < 0) || (size <= 0) || (heap_mask == 0) || (min_pgsz == NULL))
- return -1;
-
- ret = ion_alloc(ion_fd, size, 0, heap_mask, flags, &ion_hnd);
- if (ret < 0)
- {
-#if defined(ION_HEAP_SECURE_MASK)
- if (heap_mask == ION_HEAP_SECURE_MASK)
- {
- return -1;
- }
- else
-#endif
- {
- /* If everything else failed try system heap */
- flags = 0; /* Fallback option flags are not longer valid */
- heap_mask = ION_HEAP_SYSTEM_MASK;
- ret = ion_alloc(ion_fd, size, 0, heap_mask, flags, &ion_hnd);
- }
- }
-
- if (ret >= 0)
- {
- switch (heap_mask)
- {
- case ION_HEAP_SYSTEM_MASK:
- *min_pgsz = SZ_4K;
- break;
- case ION_HEAP_SYSTEM_CONTIG_MASK:
- case ION_HEAP_CARVEOUT_MASK:
-#ifdef ION_HEAP_TYPE_DMA_MASK
- case ION_HEAP_TYPE_DMA_MASK:
-#endif
- *min_pgsz = size;
- break;
-#ifdef ION_HEAP_CHUNK_MASK
- /* NOTE: if have this heap make sure your ION chunk size is 2M*/
- case ION_HEAP_CHUNK_MASK:
- *min_pgsz = SZ_2M;
- break;
-#endif
-#ifdef ION_HEAP_COMPOUND_PAGE_MASK
- case ION_HEAP_COMPOUND_PAGE_MASK:
- *min_pgsz = SZ_2M;
- break;
-#endif
- /* If have customized heap please set the suitable pg type according to
- * the customized ION implementation
- */
-#ifdef ION_HEAP_CUSTOM_MASK
- case ION_HEAP_CUSTOM_MASK:
- *min_pgsz = SZ_4K;
- break;
-#endif
- default:
- *min_pgsz = SZ_4K;
- break;
- }
- }
-
- return ion_hnd;
-}
-
-static int find_system_heap_id(int ion_client)
-{
- int i, ret, cnt, system_heap_id = -1;
- struct ion_heap_data *data;
-
- ret = ion_query_heap_cnt(ion_client, &cnt);
-
- if (ret)
- {
- AERR("ion count query failed with %s", strerror(errno));
- return -1;
- }
-
- data = (struct ion_heap_data *)malloc(cnt * sizeof(*data));
- if (!data)
- {
- AERR("Error allocating data %s\n", strerror(errno));
- return -1;
- }
-
- ret = ion_query_get_heaps(ion_client, cnt, data);
- if (ret)
- {
- AERR("Error querying heaps from ion %s", strerror(errno));
- }
- else
- {
- for (i = 0; i < cnt; i++) {
- if (strcmp(data[i].name, "ion_system_heap") == 0) {
- system_heap_id = data[i].heap_id;
- break;
- }
- }
-
- if (i == cnt)
- {
- AERR("No System Heap Found amongst %d heaps\n", cnt);
- system_heap_id = -1;
- }
- }
-
- free(data);
- return system_heap_id;
-}
-
-unsigned int pick_ion_heap(int usage)
-{
- unsigned int heap_mask;
-
- if(usage & GRALLOC_USAGE_PROTECTED)
- {
-#if defined(ION_HEAP_SECURE_MASK)
- heap_mask = ION_HEAP_SECURE_MASK;
-#else
- AERR("Protected ION memory is not supported on this platform.");
- return 0;
-#endif
- }
-#if defined(ION_HEAP_TYPE_COMPOUND_PAGE_MASK) && GRALLOC_USE_ION_COMPOUND_PAGE_HEAP
- else if(!(usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) && (usage & (GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_COMPOSER)))
- {
- heap_mask = ION_HEAP_TYPE_COMPOUND_PAGE_MASK;
- }
-#elif defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
- else if(!(usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) && (usage & (GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_COMPOSER)))
- {
- heap_mask = ION_HEAP_TYPE_DMA_MASK;
- }
-#endif
- else
- {
- heap_mask = ION_HEAP_SYSTEM_MASK;
- }
-
- return heap_mask;
-}
-
-void set_ion_flags(unsigned int heap_mask, int usage, unsigned int *priv_heap_flag, int *ion_flags)
-{
-#if !GRALLOC_USE_ION_DMA_HEAP
- GRALLOC_UNUSED(heap_mask);
-#endif
-
- if (priv_heap_flag)
- {
-#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
- if (heap_mask == ION_HEAP_TYPE_DMA_MASK)
- {
- *priv_heap_flag = private_handle_t::PRIV_FLAGS_USES_ION_DMA_HEAP;
- }
-#endif
- }
-
- if (ion_flags)
- {
-#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
- if(heap_mask != ION_HEAP_TYPE_DMA_MASK)
- {
-#endif
- if ( (usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN )
- {
- *ion_flags = ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC;
- }
-#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
- }
-#endif
- }
-}
-
-int alloc_backend_alloc(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle, uint64_t fmt, int w, int h)
-{
- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
- unsigned char *cpu_ptr = NULL;
- int shared_fd;
- int ret;
- unsigned int heap_mask, priv_heap_flag = 0;
- int ion_flags = 0;
- static int support_protected = 1; /* initially, assume we support protected memory */
- int lock_state = 0;
- int min_pgsz = 0;
-
- if (m->gralloc_legacy_ion)
- {
- ion_user_handle_t ion_hnd;
-
- heap_mask = pick_ion_heap(usage);
- if(heap_mask == 0)
- {
- AERR("Failed to find an appropriate ion heap");
- return -1;
- }
- set_ion_flags(heap_mask, usage, &priv_heap_flag, &ion_flags);
-
- ion_hnd = alloc_from_ion_heap(m->ion_client, size, heap_mask, ion_flags, &min_pgsz);
- if (ion_hnd < 0)
- {
- AERR("Failed to ion_alloc from ion_client:%d", m->ion_client);
- return -1;
- }
-
- ret = ion_share( m->ion_client, ion_hnd, &shared_fd );
- if ( ret != 0 )
- {
- AERR( "ion_share( %d ) failed", m->ion_client );
- if ( 0 != ion_free( m->ion_client, ion_hnd ) ) AERR( "ion_free( %d ) failed", m->ion_client );
- return -1;
- }
-
- // we do not need ion_hnd once we have shared_fd
- if (0 != ion_free(m->ion_client, ion_hnd))
- {
- AWAR("ion_free( %d ) failed", m->ion_client);
- }
- ion_hnd = -1;
- }
- else
- {
- /* Support only System heap to begin with */
- ret = ion_alloc_fd(m->ion_client, size, 0, 1 << m->system_heap_id, 0, &(shared_fd));
- if (ret != 0)
- {
- AERR("Failed to ion_alloc_fd from ion_client:%d", m->ion_client);
- return -1;
- }
- min_pgsz = SZ_4K;
- }
-
- if (!(usage & GRALLOC_USAGE_PROTECTED))
- {
- cpu_ptr = (unsigned char*)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, shared_fd, 0 );
-
- if ( MAP_FAILED == cpu_ptr )
- {
- AERR( "ion_map( %d ) failed", m->ion_client );
- close( shared_fd );
- return -1;
- }
- lock_state = private_handle_t::LOCK_STATE_MAPPED;
-
-#if GRALLOC_INIT_AFBC == 1
- if (fmt & MALI_GRALLOC_INTFMT_AFBCENABLE_MASK)
- {
- init_afbc(cpu_ptr, fmt, w, h);
- }
-#else
- GRALLOC_UNUSED(fmt);
- GRALLOC_UNUSED(w);
- GRALLOC_UNUSED(h);
-
-#endif /* GRALLOC_INIT_AFBC == 1 */
- }
-
- private_handle_t *hnd = new private_handle_t( private_handle_t::PRIV_FLAGS_USES_ION | priv_heap_flag, usage, size, cpu_ptr,
- lock_state, -1, 0);
-
- if ( NULL != hnd )
- {
- hnd->share_fd = shared_fd;
- hnd->min_pgsz = min_pgsz;
- *pHandle = hnd;
- return 0;
- }
- else
- {
- AERR( "Gralloc out of mem for ion_client:%d", m->ion_client );
- }
-
- close( shared_fd );
-
- if(!(usage & GRALLOC_USAGE_PROTECTED))
- {
- ret = munmap( cpu_ptr, size );
- if ( 0 != ret ) AERR( "munmap failed for base:%p size: %zd", cpu_ptr, size );
- }
-
- return -1;
-}
-
-int alloc_backend_alloc_framebuffer(private_module_t* m, private_handle_t* hnd)
-{
- struct fb_dmabuf_export fb_dma_buf;
- int res;
- res = ioctl( m->framebuffer->shallow_fbdev_fd, FBIOGET_DMABUF, &fb_dma_buf );
- if(res == 0)
- {
- hnd->share_fd = fb_dma_buf.fd;
- return 0;
- }
- else
- {
- AINF("FBIOGET_DMABUF ioctl failed(%d). See gralloc_priv.h and the integration manual for vendor framebuffer integration", res);
- return -1;
- }
-}
-
-void alloc_backend_alloc_free(private_handle_t const* hnd, private_module_t* m)
-{
- (void) m;
- if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
- {
- return;
- }
- else if ( hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION )
- {
- /* Buffer might be unregistered already so we need to assure we have a valid handle*/
- if ( 0 != hnd->base )
- {
- if ( 0 != munmap( (void*)hnd->base, hnd->size ) ) AERR( "Failed to munmap handle %p", hnd );
- }
- close( hnd->share_fd );
- memset( (void*)hnd, 0, sizeof( *hnd ) );
- }
-}
-
-int alloc_backend_open(alloc_device_t *dev)
-{
- private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module);
- m->ion_client = ion_open();
- if ( m->ion_client < 0 )
- {
- AERR( "ion_open failed with %s", strerror(errno) );
- return -1;
- }
-
- m->gralloc_legacy_ion = ion_is_legacy(m->ion_client);
-
- if (!m->gralloc_legacy_ion)
- {
- m->system_heap_id = find_system_heap_id(m->ion_client);
- if (m->system_heap_id < 0)
- {
- ion_close(m->ion_client);
- m->ion_client = -1;
- AERR( "ion_open failed: no system heap found" );
- return -1;
- }
- }
-
- return 0;
-}
-
-int alloc_backend_close(struct hw_device_t *device)
-{
- alloc_device_t* dev = reinterpret_cast<alloc_device_t*>(device);
- if (dev)
- {
- private_module_t *m = reinterpret_cast<private_module_t*>(dev->common.module);
- if ( 0 != ion_close(m->ion_client) ) AERR( "Failed to close ion_client: %d err=%s", m->ion_client , strerror(errno));
- delete dev;
- }
- return 0;
-}
diff --git a/gralloc960/framebuffer_device.cpp b/gralloc960/framebuffer_device.cpp
index fa60eb5b..a45d0c37 100644
--- a/gralloc960/framebuffer_device.cpp
+++ b/gralloc960/framebuffer_device.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2017 ARM Limited. All rights reserved.
*
* Copyright (C) 2008 The Android Open Source Project
*
@@ -23,30 +23,38 @@
#include <sys/ioctl.h>
#include <linux/fb.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <cutils/atomic.h>
#include <hardware/hardware.h>
-#include <hardware/gralloc.h>
+#include <hardware/fb.h>
#include <GLES/gl.h>
-#include "alloc_device.h"
-#include "gralloc_priv.h"
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+
+#include "mali_gralloc_module.h"
+#include "mali_gralloc_private_interface_types.h"
+#include "mali_gralloc_buffer.h"
#include "gralloc_helper.h"
#include "gralloc_vsync.h"
+#include "mali_gralloc_bufferaccess.h"
+#include "mali_gralloc_ion.h"
#define STANDARD_LINUX_SCREEN
// numbers of buffers for page flipping
-#define NUM_BUFFERS NUM_FB_BUFFERS
+#define NUM_BUFFERS NUM_FB_BUFFERS
enum
{
PAGE_FLIP = 0x00000001,
};
-
-static int fb_set_swap_interval(struct framebuffer_device_t* dev, int interval)
+static int fb_set_swap_interval(struct framebuffer_device_t *dev, int interval)
{
if (interval < dev->minSwapInterval)
{
@@ -57,79 +65,86 @@ static int fb_set_swap_interval(struct framebuffer_device_t* dev, int interval)
interval = dev->maxSwapInterval;
}
- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
+ private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module);
m->swapInterval = interval;
- if (0 == interval) gralloc_vsync_disable(dev);
- else gralloc_vsync_enable(dev);
+ if (0 == interval)
+ {
+ gralloc_vsync_disable(dev);
+ }
+ else
+ {
+ gralloc_vsync_enable(dev);
+ }
return 0;
}
-static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer)
+static int fb_post(struct framebuffer_device_t *dev, buffer_handle_t buffer)
{
if (private_handle_t::validate(buffer) < 0)
{
return -EINVAL;
}
- private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(buffer);
- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
+ private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(buffer);
+ private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module);
if (m->currentBuffer)
{
- m->base.unlock(&m->base, m->currentBuffer);
+ mali_gralloc_unlock(m, m->currentBuffer);
m->currentBuffer = 0;
}
if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
{
- m->base.lock(&m->base, buffer, private_module_t::PRIV_USAGE_LOCKED_FOR_POST,
- 0, 0, m->info.xres, m->info.yres, NULL);
+ mali_gralloc_lock(m, buffer, private_module_t::PRIV_USAGE_LOCKED_FOR_POST, -1, -1, -1, -1, NULL);
- const size_t offset = (uintptr_t)hnd->base - (uintptr_t)m->framebuffer->base;
int interrupt;
m->info.activate = FB_ACTIVATE_VBL;
- m->info.yoffset = offset / m->finfo.line_length;
+ m->info.yoffset = hnd->offset / m->finfo.line_length;
- int fbdev_fd = m->framebuffer->shallow_fbdev_fd;
#ifdef STANDARD_LINUX_SCREEN
- if (ioctl(fbdev_fd, FBIOPAN_DISPLAY, &m->info) == -1)
+
+ if (ioctl(m->framebuffer->fd, FBIOPAN_DISPLAY, &m->info) == -1)
{
- AERR( "FBIOPAN_DISPLAY failed for fd: %d", fbdev_fd );
- m->base.unlock(&m->base, buffer);
+ AERR("FBIOPAN_DISPLAY failed for fd: %d", m->framebuffer->fd);
+ mali_gralloc_unlock(m, buffer);
return -errno;
}
+
#else /*Standard Android way*/
- if (ioctl(fbdev_fd, FBIOPUT_VSCREENINFO, &m->info) == -1)
+
+ if (ioctl(m->framebuffer->fd, FBIOPUT_VSCREENINFO, &m->info) == -1)
{
- AERR( "FBIOPUT_VSCREENINFO failed for fd: %d", fbdev_fd );
- m->base.unlock(&m->base, buffer);
+ AERR("FBIOPUT_VSCREENINFO failed for fd: %d", m->framebuffer->fd);
+ mali_gralloc_unlock(m, buffer);
return -errno;
}
+
#endif
- if ( 0 != gralloc_wait_for_vsync(dev) )
+
+ if (0 != gralloc_wait_for_vsync(dev))
{
- AERR( "Gralloc wait for vsync failed for fd: %d", fbdev_fd );
- m->base.unlock(&m->base, buffer);
+ AERR("Gralloc wait for vsync failed for fd: %d", m->framebuffer->fd);
+ mali_gralloc_unlock(m, buffer);
return -errno;
}
+
m->currentBuffer = buffer;
- }
+ }
else
{
- void* fb_vaddr;
- void* buffer_vaddr;
+ void *fb_vaddr;
+ void *buffer_vaddr;
- m->base.lock(&m->base, m->framebuffer, GRALLOC_USAGE_SW_WRITE_RARELY,
- 0, 0, m->info.xres, m->info.yres, &fb_vaddr);
+ mali_gralloc_lock(m, m->framebuffer, GRALLOC_USAGE_SW_WRITE_RARELY, -1, -1, -1, -1, &fb_vaddr);
- m->base.lock(&m->base, buffer, GRALLOC_USAGE_SW_READ_RARELY,
- 0, 0, m->info.xres, m->info.yres, &buffer_vaddr);
+ mali_gralloc_lock(m, buffer, GRALLOC_USAGE_SW_READ_RARELY, -1, -1, -1, -1, &buffer_vaddr);
// If buffer's alignment match framebuffer alignment we can do a direct copy.
// If not we must fallback to do an aligned copy of each line.
- if ( hnd->byte_stride == (int)m->finfo.line_length )
+ if (hnd->byte_stride == (int)m->finfo.line_length)
{
memcpy(fb_vaddr, buffer_vaddr, m->finfo.line_length * m->info.yres);
}
@@ -141,34 +156,29 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer)
for (i = 0; i < m->info.yres; i++)
{
- memcpy((void *)((uintptr_t)fb_vaddr + fb_offset),
- (void *)((uintptr_t)buffer_vaddr + buffer_offset),
- m->finfo.line_length);
+ memcpy((void *)((uintptr_t)fb_vaddr + fb_offset), (void *)((uintptr_t)buffer_vaddr + buffer_offset),
+ m->finfo.line_length);
fb_offset += m->finfo.line_length;
buffer_offset += hnd->byte_stride;
}
}
- m->base.unlock(&m->base, buffer);
- m->base.unlock(&m->base, m->framebuffer);
+
+ mali_gralloc_unlock(m, buffer);
+ mali_gralloc_unlock(m, m->framebuffer);
}
return 0;
}
-int init_frame_buffer_locked(struct private_module_t* module)
+static int init_frame_buffer_locked(struct private_module_t *module)
{
if (module->framebuffer)
{
return 0; // Nothing to do, already initialized
}
-
- char const * const device_template[] =
- {
- "/dev/graphics/fb%u",
- "/dev/fb%u",
- NULL
- };
+
+ char const *const device_template[] = { "/dev/graphics/fb%u", "/dev/fb%u", NULL };
int fd = -1;
int i = 0;
@@ -187,12 +197,14 @@ int init_frame_buffer_locked(struct private_module_t* module)
}
struct fb_fix_screeninfo finfo;
+
if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1)
{
return -errno;
}
struct fb_var_screeninfo info;
+
if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1)
{
return -errno;
@@ -210,27 +222,27 @@ int init_frame_buffer_locked(struct private_module_t* module)
* Explicitly request 5/6/5
*/
info.bits_per_pixel = 16;
- info.red.offset = 11;
- info.red.length = 5;
- info.green.offset = 5;
- info.green.length = 6;
- info.blue.offset = 0;
- info.blue.length = 5;
- info.transp.offset = 0;
- info.transp.length = 0;
+ info.red.offset = 11;
+ info.red.length = 5;
+ info.green.offset = 5;
+ info.green.length = 6;
+ info.blue.offset = 0;
+ info.blue.length = 5;
+ info.transp.offset = 0;
+ info.transp.length = 0;
#else
/*
* Explicitly request 8/8/8
*/
info.bits_per_pixel = 32;
- info.red.offset = 16;
- info.red.length = 8;
- info.green.offset = 8;
- info.green.length = 8;
- info.blue.offset = 0;
- info.blue.length = 8;
- info.transp.offset = 0;
- info.transp.length = 0;
+ info.red.offset = 16;
+ info.red.length = 8;
+ info.green.offset = 8;
+ info.green.length = 8;
+ info.blue.offset = 0;
+ info.blue.length = 8;
+ info.transp.offset = 0;
+ info.transp.length = 0;
#endif
/*
@@ -239,11 +251,12 @@ int init_frame_buffer_locked(struct private_module_t* module)
info.yres_virtual = info.yres * NUM_BUFFERS;
uint32_t flags = PAGE_FLIP;
+
if (ioctl(fd, FBIOPUT_VSCREENINFO, &info) == -1)
{
info.yres_virtual = info.yres;
flags &= ~PAGE_FLIP;
- AWAR( "FBIOPUT_VSCREENINFO failed, page flipping not supported fd: %d", fd );
+ AWAR("FBIOPUT_VSCREENINFO failed, page flipping not supported fd: %d", fd);
}
if (info.yres_virtual < info.yres * 2)
@@ -251,7 +264,7 @@ int init_frame_buffer_locked(struct private_module_t* module)
// we need at least 2 for page-flipping
info.yres_virtual = info.yres;
flags &= ~PAGE_FLIP;
- AWAR( "page flipping not supported (yres_virtual=%d, requested=%d)", info.yres_virtual, info.yres*2 );
+ AWAR("page flipping not supported (yres_virtual=%d, requested=%d)", info.yres_virtual, info.yres * 2);
}
if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1)
@@ -260,36 +273,34 @@ int init_frame_buffer_locked(struct private_module_t* module)
}
int refreshRate = 0;
- if ( info.pixclock > 0 )
+
+ if (info.pixclock > 0)
{
- refreshRate = 1000000000000000LLU /
- (
- uint64_t( info.upper_margin + info.lower_margin + info.yres + info.hsync_len )
- * ( info.left_margin + info.right_margin + info.xres + info.vsync_len )
- * info.pixclock
- );
+ refreshRate =
+ 1000000000000000LLU / (uint64_t(info.upper_margin + info.lower_margin + info.yres + info.hsync_len) *
+ (info.left_margin + info.right_margin + info.xres + info.vsync_len) * info.pixclock);
}
else
{
- AWAR( "fbdev pixclock is zero for fd: %d", fd );
+ AWAR("fbdev pixclock is zero for fd: %d", fd);
}
if (refreshRate == 0)
{
- refreshRate = 60*1000; // 60 Hz
+ refreshRate = 60 * 1000; // 60 Hz
}
if (int(info.width) <= 0 || int(info.height) <= 0)
{
// the driver doesn't return that information
// default to 160 dpi
- info.width = ((info.xres * 25.4f)/160.0f + 0.5f);
- info.height = ((info.yres * 25.4f)/160.0f + 0.5f);
+ info.width = ((info.xres * 25.4f) / 160.0f + 0.5f);
+ info.height = ((info.yres * 25.4f) / 160.0f + 0.5f);
}
float xdpi = (info.xres * 25.4f) / info.width;
float ydpi = (info.yres * 25.4f) / info.height;
- float fps = refreshRate / 1000.0f;
+ float fps = refreshRate / 1000.0f;
AINF("using (fd=%d)\n"
"id = %s\n"
@@ -301,23 +312,13 @@ int init_frame_buffer_locked(struct private_module_t* module)
"r = %2u:%u\n"
"g = %2u:%u\n"
"b = %2u:%u\n",
- fd,
- finfo.id,
- info.xres,
- info.yres,
- info.xres_virtual,
- info.yres_virtual,
- info.bits_per_pixel,
- info.red.offset, info.red.length,
- info.green.offset, info.green.length,
- info.blue.offset, info.blue.length);
+ fd, finfo.id, info.xres, info.yres, info.xres_virtual, info.yres_virtual, info.bits_per_pixel, info.red.offset,
+ info.red.length, info.green.offset, info.green.length, info.blue.offset, info.blue.length);
AINF("width = %d mm (%f dpi)\n"
"height = %d mm (%f dpi)\n"
"refresh rate = %.2f Hz\n",
- info.width, xdpi,
- info.height, ydpi,
- fps);
+ info.width, xdpi, info.height, ydpi, fps);
if (0 == strncmp(finfo.id, "CLCD FB", 7))
{
@@ -327,6 +328,10 @@ int init_frame_buffer_locked(struct private_module_t* module)
{
module->dpy_type = MALI_DPY_TYPE_HDLCD;
}
+ else if (0 == strncmp(finfo.id, "ARM HDLCD Control", 16))
+ {
+ module->dpy_type = MALI_DPY_TYPE_HDLCD;
+ }
else
{
module->dpy_type = MALI_DPY_TYPE_UNKNOWN;
@@ -354,19 +359,19 @@ int init_frame_buffer_locked(struct private_module_t* module)
* map the framebuffer
*/
size_t fbSize = round_up_to_page_size(finfo.line_length * info.yres_virtual);
- void* vaddr = mmap(0, fbSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
- if (vaddr == MAP_FAILED)
+ void *vaddr = mmap(0, fbSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+
+ if (vaddr == MAP_FAILED)
{
- AERR( "Error mapping the framebuffer (%s)", strerror(errno) );
+ AERR("Error mapping the framebuffer (%s)", strerror(errno));
return -errno;
}
memset(vaddr, 0, fbSize);
-
// Create a "fake" buffer object for the entire frame buffer memory, and store it in the module
- module->framebuffer = new private_handle_t(private_handle_t::PRIV_FLAGS_FRAMEBUFFER, GRALLOC_USAGE_HW_FB, fbSize, vaddr,
- 0, fd, 0);
+ module->framebuffer = new private_handle_t(private_handle_t::PRIV_FLAGS_FRAMEBUFFER, fbSize, vaddr,
+ GRALLOC_USAGE_HW_FB, GRALLOC_USAGE_HW_FB, dup(fd), 0);
module->numBuffers = info.yres_virtual / info.yres;
module->bufferMask = 0;
@@ -374,7 +379,7 @@ int init_frame_buffer_locked(struct private_module_t* module)
return 0;
}
-static int init_frame_buffer(struct private_module_t* module)
+static int init_frame_buffer(struct private_module_t *module)
{
pthread_mutex_lock(&module->lock);
int err = init_frame_buffer_locked(module);
@@ -384,15 +389,148 @@ static int init_frame_buffer(struct private_module_t* module)
static int fb_close(struct hw_device_t *device)
{
- framebuffer_device_t* dev = reinterpret_cast<framebuffer_device_t*>(device);
+ framebuffer_device_t *dev = reinterpret_cast<framebuffer_device_t *>(device);
+
if (dev)
{
free(dev);
}
+
return 0;
}
-int compositionComplete(struct framebuffer_device_t* dev)
+static int fb_alloc_framebuffer_dmabuf(private_module_t *m, private_handle_t *hnd)
+{
+ struct fb_dmabuf_export fb_dma_buf;
+ int res;
+ res = ioctl(m->framebuffer->fd, FBIOGET_DMABUF, &fb_dma_buf);
+
+ if (res == 0)
+ {
+ hnd->share_fd = fb_dma_buf.fd;
+ return 0;
+ }
+ else
+ {
+ AINF("FBIOGET_DMABUF ioctl failed(%d). See gralloc_priv.h and the integration manual for vendor framebuffer "
+ "integration",
+ res);
+ return -1;
+ }
+}
+
+static int fb_alloc_from_ion_module(mali_gralloc_module *m, size_t buffer_size, uint64_t consumer_usage,
+ uint64_t producer_usage, buffer_handle_t *pHandle)
+{
+ buffer_descriptor_t fb_buffer_descriptor;
+ gralloc_buffer_descriptor_t gralloc_buffer_descriptor[1];
+ bool shared = false;
+ int err = 0;
+
+ fb_buffer_descriptor.size = buffer_size;
+ fb_buffer_descriptor.consumer_usage = consumer_usage;
+ fb_buffer_descriptor.producer_usage = producer_usage;
+ gralloc_buffer_descriptor[0] = (gralloc_buffer_descriptor_t)(&fb_buffer_descriptor);
+
+ err = mali_gralloc_ion_allocate(m, gralloc_buffer_descriptor, 1, pHandle, &shared);
+
+ return err;
+}
+
+static int fb_alloc_framebuffer_locked(mali_gralloc_module *m, uint64_t consumer_usage, uint64_t producer_usage,
+ buffer_handle_t *pHandle, int *stride, int *byte_stride)
+{
+ // allocate the framebuffer
+ if (m->framebuffer == NULL)
+ {
+ // initialize the framebuffer, the framebuffer is mapped once and forever.
+ int err = init_frame_buffer_locked(m);
+
+ if (err < 0)
+ {
+ return err;
+ }
+ }
+
+ uint32_t bufferMask = m->bufferMask;
+ const uint32_t numBuffers = m->numBuffers;
+ /* framebufferSize is used for allocating the handle to the framebuffer and refers
+ * to the size of the actual framebuffer.
+ * alignedFramebufferSize is used for allocating a possible internal buffer and
+ * thus need to consider internal alignment requirements. */
+ const size_t framebufferSize = m->finfo.line_length * m->info.yres;
+ const size_t alignedFramebufferSize = GRALLOC_ALIGN(m->finfo.line_length, 64) * m->info.yres;
+
+ *stride = m->info.xres;
+
+ if (numBuffers == 1)
+ {
+ // If we have only one buffer, we never use page-flipping. Instead,
+ // we return a regular buffer which will be memcpy'ed to the main
+ // screen when post is called.
+ uint64_t newConsumerUsage = (consumer_usage & ~GRALLOC_USAGE_HW_FB);
+ uint64_t newProducerUsage = (producer_usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D;
+ AWAR("fallback to single buffering. Virtual Y-res too small %d", m->info.yres);
+ *byte_stride = GRALLOC_ALIGN(m->finfo.line_length, 64);
+ return fb_alloc_from_ion_module(m, alignedFramebufferSize, newConsumerUsage, newProducerUsage, pHandle);
+ }
+
+ if (bufferMask >= ((1LU << numBuffers) - 1))
+ {
+ // We ran out of buffers, reset bufferMask
+ bufferMask = 0;
+ m->bufferMask = 0;
+ }
+
+ uintptr_t framebufferVaddr = (uintptr_t)m->framebuffer->base;
+
+ // find a free slot
+ for (uint32_t i = 0; i < numBuffers; i++)
+ {
+ if ((bufferMask & (1LU << i)) == 0)
+ {
+ m->bufferMask |= (1LU << i);
+ break;
+ }
+
+ framebufferVaddr += framebufferSize;
+ }
+
+ // The entire framebuffer memory is already mapped, now create a buffer object for parts of this memory
+ private_handle_t *hnd = new private_handle_t(
+ private_handle_t::PRIV_FLAGS_FRAMEBUFFER, framebufferSize, (void *)framebufferVaddr, consumer_usage,
+ producer_usage, dup(m->framebuffer->fd), (framebufferVaddr - (uintptr_t)m->framebuffer->base));
+
+ /*
+ * Perform allocator specific actions. If these fail we fall back to a regular buffer
+ * which will be memcpy'ed to the main screen when fb_post is called.
+ */
+ if (fb_alloc_framebuffer_dmabuf(m, hnd) == -1)
+ {
+ delete hnd;
+ uint64_t newConsumerUsage = (consumer_usage & ~GRALLOC_USAGE_HW_FB);
+ uint64_t newProducerUsage = (producer_usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D;
+ AERR("Fallback to single buffering. Unable to map framebuffer memory to handle:%p", hnd);
+ *byte_stride = GRALLOC_ALIGN(m->finfo.line_length, 64);
+ return fb_alloc_from_ion_module(m, alignedFramebufferSize, newConsumerUsage, newProducerUsage, pHandle);
+ }
+
+ *pHandle = hnd;
+ *byte_stride = m->finfo.line_length;
+
+ return 0;
+}
+
+int fb_alloc_framebuffer(mali_gralloc_module *m, uint64_t consumer_usage, uint64_t producer_usage,
+ buffer_handle_t *pHandle, int *stride, int *byte_stride)
+{
+ pthread_mutex_lock(&m->lock);
+ int err = fb_alloc_framebuffer_locked(m, consumer_usage, producer_usage, pHandle, stride, byte_stride);
+ pthread_mutex_unlock(&m->lock);
+ return err;
+}
+
+int compositionComplete(struct framebuffer_device_t *dev)
{
GRALLOC_UNUSED(dev);
@@ -404,61 +542,76 @@ int compositionComplete(struct framebuffer_device_t* dev)
synchronously in the same thread, and not asynchronoulsy in a background thread later.
The SurfaceFlinger requires this behaviour since it releases the lock on all the
SourceBuffers (Layers) after the compositionComplete() function returns.
- However this "bad" behaviour by SurfaceFlinger should not affect performance,
- since the Applications that render the SourceBuffers (Layers) still get the
+ However this "bad" behaviour by SurfaceFlinger should not affect performance,
+ since the Applications that render the SourceBuffers (Layers) still get the
full renderpipeline using asynchronous rendering. So they perform at maximum speed,
and because of their complexity compared to the Surface flinger jobs, the Surface flinger
- is normally faster even if it does everyhing synchronous and serial.
+ is normally faster even if it does everyhing synchronous and serial.
*/
return 0;
}
-int framebuffer_device_open(hw_module_t const* module, const char* name, hw_device_t** device)
+int framebuffer_device_open(hw_module_t const *module, const char *name, hw_device_t **device)
{
int status = -EINVAL;
GRALLOC_UNUSED(name);
- alloc_device_t* gralloc_device;
+#if GRALLOC_USE_GRALLOC1_API == 1
+ gralloc1_device_t *gralloc_device;
+#else
+ alloc_device_t *gralloc_device;
+#endif
+
#if DISABLE_FRAMEBUFFER_HAL == 1
AERR("Framebuffer HAL not support/disabled %s",
#ifdef MALI_DISPLAY_VERSION
- "with MALI display enable");
+ "with MALI display enable");
#else
- "");
+ "");
#endif
return -ENODEV;
#endif
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+ status = gralloc1_open(module, &gralloc_device);
+#else
status = gralloc_open(module, &gralloc_device);
+#endif
+
if (status < 0)
{
return status;
}
- private_module_t* m = (private_module_t*)module;
+ private_module_t *m = (private_module_t *)module;
status = init_frame_buffer(m);
/* malloc is used instead of 'new' to instantiate the struct framebuffer_device_t
- * C++11 spec specifies that if a class/struct has a const member,default constructor
+ * C++11 spec specifies that if a class/struct has a const member,default constructor
* is deleted. So, if 'new' is used to instantiate the class/struct, it will throw
* error complaining about deleted constructor. Even if the struct is wrapped in a class
- * it will still try to use the base class constructor to initialize the members, resulting
+ * it will still try to use the base class constructor to initialize the members, resulting
* in error 'deleted constructor'.
- * This leaves two options
+ * This leaves two options
* Option 1: initialize the const members at the instantiation time. With {value1, value2 ..}
* Which relies on the order of the members, and if members are reordered or a new member is introduced
* it will end up assiging wrong value to members. Designated assignment as well has been removed in C++11
- * Option 2: use malloc instead of 'new' to allocate the class/struct and initialize the members in code.
+ * Option 2: use malloc instead of 'new' to allocate the class/struct and initialize the members in code.
* This is the only maintainable option available.
*/
- framebuffer_device_t *dev = reinterpret_cast<framebuffer_device_t*> (malloc(sizeof(framebuffer_device_t)));
+ framebuffer_device_t *dev = reinterpret_cast<framebuffer_device_t *>(malloc(sizeof(framebuffer_device_t)));
/* if either or both of init_frame_buffer() and malloc failed */
if ((status < 0) || (!dev))
{
+#if GRALLOC_USE_GRALLOC1_API == 1
+ gralloc1_close(gralloc_device);
+#else
gralloc_close(gralloc_device);
- (!dev)? (void)(status = -ENOMEM) : free(dev);
+#endif
+ (!dev) ? (void)(status = -ENOMEM) : free(dev);
return status;
}
@@ -467,7 +620,7 @@ int framebuffer_device_open(hw_module_t const* module, const char* name, hw_devi
/* initialize the procs */
dev->common.tag = HARDWARE_DEVICE_TAG;
dev->common.version = 0;
- dev->common.module = const_cast<hw_module_t*>(module);
+ dev->common.module = const_cast<hw_module_t *>(module);
dev->common.close = fb_close;
dev->setSwapInterval = fb_set_swap_interval;
dev->post = fb_post;
@@ -475,20 +628,20 @@ int framebuffer_device_open(hw_module_t const* module, const char* name, hw_devi
dev->compositionComplete = &compositionComplete;
int stride = m->finfo.line_length / (m->info.bits_per_pixel >> 3);
- const_cast<uint32_t&>(dev->flags) = 0;
- const_cast<uint32_t&>(dev->width) = m->info.xres;
- const_cast<uint32_t&>(dev->height) = m->info.yres;
- const_cast<int&>(dev->stride) = stride;
+ const_cast<uint32_t &>(dev->flags) = 0;
+ const_cast<uint32_t &>(dev->width) = m->info.xres;
+ const_cast<uint32_t &>(dev->height) = m->info.yres;
+ const_cast<int &>(dev->stride) = stride;
#ifdef GRALLOC_16_BITS
- const_cast<int&>(dev->format) = HAL_PIXEL_FORMAT_RGB_565;
+ const_cast<int &>(dev->format) = HAL_PIXEL_FORMAT_RGB_565;
#else
- const_cast<int&>(dev->format) = HAL_PIXEL_FORMAT_BGRA_8888;
+ const_cast<int &>(dev->format) = HAL_PIXEL_FORMAT_BGRA_8888;
#endif
- const_cast<float&>(dev->xdpi) = m->xdpi;
- const_cast<float&>(dev->ydpi) = m->ydpi;
- const_cast<float&>(dev->fps) = m->fps;
- const_cast<int&>(dev->minSwapInterval) = 0;
- const_cast<int&>(dev->maxSwapInterval) = 1;
+ const_cast<float &>(dev->xdpi) = m->xdpi;
+ const_cast<float &>(dev->ydpi) = m->ydpi;
+ const_cast<float &>(dev->fps) = m->fps;
+ const_cast<int &>(dev->minSwapInterval) = 0;
+ const_cast<int &>(dev->maxSwapInterval) = 1;
*device = &dev->common;
gralloc_vsync_enable(dev);
diff --git a/gralloc960/framebuffer_device.h b/gralloc960/framebuffer_device.h
index a653cefc..1bfb00bf 100644
--- a/gralloc960/framebuffer_device.h
+++ b/gralloc960/framebuffer_device.h
@@ -20,7 +20,11 @@
#include "gralloc_priv.h"
// Create a framebuffer device
-int framebuffer_device_open(hw_module_t const* module, const char* name, hw_device_t** device);
+int framebuffer_device_open(hw_module_t const *module, const char *name, hw_device_t **device);
// Initialize the framebuffer (must keep module lock before calling
-int init_frame_buffer_locked(struct private_module_t* module);
+int init_frame_buffer_locked(struct private_module_t *module);
+
+// Allocate framebuffer buffer
+int fb_alloc_framebuffer(mali_gralloc_module *m, uint64_t consumer_usage, uint64_t producer_usage,
+ buffer_handle_t *pHandle, int *stride, int *byte_stride);
diff --git a/gralloc960/gralloc_buffer_priv.cpp b/gralloc960/gralloc_buffer_priv.cpp
index a3570308..30b49ce3 100644
--- a/gralloc960/gralloc_buffer_priv.cpp
+++ b/gralloc960/gralloc_buffer_priv.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 ARM Limited. All rights reserved.
+ * Copyright (C) 2014-2017 ARM Limited. All rights reserved.
*
* Copyright (C) 2008 The Android Open Source Project
*
@@ -17,11 +17,19 @@
*/
#include <cutils/ashmem.h>
-#include <cutils/log.h>
+#include <log/log.h>
#include <sys/mman.h>
-#include "gralloc_priv.h"
-#include "gralloc_buffer_priv.h"
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+
+#include "mali_gralloc_module.h"
+#include "mali_gralloc_private_interface_types.h"
+#include "mali_gralloc_buffer.h"
+#include "gralloc_buffer_priv.h"
/*
* Allocate shared memory for attribute storage. Only to be
@@ -29,21 +37,24 @@
*
* Return 0 on success.
*/
-int gralloc_buffer_attr_allocate( private_handle_t *hnd )
+int gralloc_buffer_attr_allocate(private_handle_t *hnd)
{
int rval = -1;
- if( !hnd )
+ if (!hnd)
+ {
goto out;
+ }
- if( hnd->share_attr_fd >= 0 )
+ if (hnd->share_attr_fd >= 0)
{
ALOGW("Warning share attribute fd already exists during create. Closing.");
- close( hnd->share_attr_fd );
+ close(hnd->share_attr_fd);
}
- hnd->share_attr_fd = ashmem_create_region( "gralloc_shared_attr", PAGE_SIZE );
- if(hnd->share_attr_fd < 0)
+ hnd->share_attr_fd = ashmem_create_region("gralloc_shared_attr", PAGE_SIZE);
+
+ if (hnd->share_attr_fd < 0)
{
ALOGE("Failed to allocate page for shared attribute region");
goto err_ashmem;
@@ -62,17 +73,18 @@ int gralloc_buffer_attr_allocate( private_handle_t *hnd )
* Because of this we keep the PROT_EXEC flag.
*/
- hnd->attr_base = mmap( NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, hnd->share_attr_fd, 0 );
- if(hnd->attr_base != MAP_FAILED)
+ hnd->attr_base = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, hnd->share_attr_fd, 0);
+
+ if (hnd->attr_base != MAP_FAILED)
{
/* The attribute region contains signed integers only.
* The reason for this is because we can set a value less than 0 for
* not-initialized values.
*/
- attr_region *region = (attr_region *) hnd->attr_base;
+ attr_region *region = (attr_region *)hnd->attr_base;
memset(hnd->attr_base, 0xff, PAGE_SIZE);
- munmap( hnd->attr_base, PAGE_SIZE );
+ munmap(hnd->attr_base, PAGE_SIZE);
hnd->attr_base = MAP_FAILED;
}
else
@@ -85,9 +97,10 @@ int gralloc_buffer_attr_allocate( private_handle_t *hnd )
goto out;
err_ashmem:
- if( hnd->share_attr_fd >= 0 )
+
+ if (hnd->share_attr_fd >= 0)
{
- close( hnd->share_attr_fd );
+ close(hnd->share_attr_fd);
hnd->share_attr_fd = -1;
}
@@ -101,26 +114,29 @@ out:
* Return 0 on success.
*/
-int gralloc_buffer_attr_free( private_handle_t *hnd )
+int gralloc_buffer_attr_free(private_handle_t *hnd)
{
int rval = -1;
- if( !hnd )
+ if (!hnd)
+ {
goto out;
+ }
- if( hnd->share_attr_fd < 0 )
+ if (hnd->share_attr_fd < 0)
{
ALOGE("Shared attribute region not avail to free");
goto out;
}
- if( hnd->attr_base != MAP_FAILED )
+
+ if (hnd->attr_base != MAP_FAILED)
{
ALOGW("Warning shared attribute region mapped at free. Unmapping");
- munmap( hnd->attr_base, PAGE_SIZE );
+ munmap(hnd->attr_base, PAGE_SIZE);
hnd->attr_base = MAP_FAILED;
}
- close( hnd->share_attr_fd );
+ close(hnd->share_attr_fd);
hnd->share_attr_fd = -1;
rval = 0;
diff --git a/gralloc960/gralloc_buffer_priv.h b/gralloc960/gralloc_buffer_priv.h
index 516781cb..122ee2a6 100644
--- a/gralloc960/gralloc_buffer_priv.h
+++ b/gralloc960/gralloc_buffer_priv.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 ARM Limited. All rights reserved.
+ * Copyright (C) 2014-2017 ARM Limited. All rights reserved.
*
* Copyright (C) 2008 The Android Open Source Project
*
@@ -22,6 +22,7 @@
#include "gralloc_priv.h"
#include <errno.h>
#include <string.h>
+#include "mali_gralloc_private_interface_types.h"
// private gralloc buffer manipulation API
@@ -34,38 +35,18 @@ struct attr_region
int crop_width;
int use_yuv_transform;
int use_sparse_alloc;
-} __attribute__ ((packed));
+ mali_hdr_info hdr_info;
+} __attribute__((packed));
typedef struct attr_region attr_region;
-enum
-{
- /* CROP_RECT and YUV_TRANS are intended to be
- * written by producers and read by consumers.
- * A producer should write these parameters before
- * it queues a buffer to the consumer.
- */
-
- /* CROP RECT, defined as an int array of top, left, height, width. Origin in top-left corner */
- GRALLOC_ARM_BUFFER_ATTR_CROP_RECT = 1,
-
- /* Set if the AFBC format used a YUV transform before compressing */
- GRALLOC_ARM_BUFFER_ATTR_AFBC_YUV_TRANS = 2,
-
- /* Set if the AFBC format uses sparse allocation */
- GRALLOC_ARM_BUFFER_ATTR_AFBC_SPARSE_ALLOC = 3,
- GRALLOC_ARM_BUFFER_ATTR_LAST
-};
-
-typedef uint32_t buf_attr;
-
/*
* Allocate shared memory for attribute storage. Only to be
* used by gralloc internally.
*
* Return 0 on success.
*/
-int gralloc_buffer_attr_allocate( struct private_handle_t *hnd );
+int gralloc_buffer_attr_allocate(struct private_handle_t *hnd);
/*
* Frees the shared memory allocated for attribute storage.
@@ -73,7 +54,7 @@ int gralloc_buffer_attr_allocate( struct private_handle_t *hnd );
* Return 0 on success.
*/
-int gralloc_buffer_attr_free( struct private_handle_t *hnd );
+int gralloc_buffer_attr_free(struct private_handle_t *hnd);
/*
* Map the attribute storage area before attempting to
@@ -81,29 +62,32 @@ int gralloc_buffer_attr_free( struct private_handle_t *hnd );
*
* Return 0 on success.
*/
-static inline int gralloc_buffer_attr_map( struct private_handle_t *hnd, int readwrite)
+static inline int gralloc_buffer_attr_map(struct private_handle_t *hnd, int readwrite)
{
int rval = -1;
int prot_flags = PROT_READ;
- if( !hnd )
+ if (!hnd)
+ {
goto out;
+ }
- if( hnd->share_attr_fd < 0 )
+ if (hnd->share_attr_fd < 0)
{
ALOGE("Shared attribute region not available to be mapped");
goto out;
}
- if( readwrite )
+ if (readwrite)
{
- prot_flags |= PROT_WRITE;
+ prot_flags |= PROT_WRITE;
}
- hnd->attr_base = mmap( NULL, PAGE_SIZE, prot_flags, MAP_SHARED, hnd->share_attr_fd, 0 );
- if(hnd->attr_base == MAP_FAILED)
+ hnd->attr_base = mmap(NULL, PAGE_SIZE, prot_flags, MAP_SHARED, hnd->share_attr_fd, 0);
+
+ if (hnd->attr_base == MAP_FAILED)
{
- ALOGE("Failed to mmap shared attribute region err=%s",strerror(errno));
+ ALOGE("Failed to mmap shared attribute region err=%s", strerror(errno));
goto out;
}
@@ -118,16 +102,18 @@ out:
*
* Return 0 on success.
*/
-static inline int gralloc_buffer_attr_unmap( struct private_handle_t *hnd )
+static inline int gralloc_buffer_attr_unmap(struct private_handle_t *hnd)
{
int rval = -1;
- if( !hnd )
+ if (!hnd)
+ {
goto out;
+ }
- if( hnd->attr_base != MAP_FAILED )
+ if (hnd->attr_base != MAP_FAILED)
{
- if ( munmap( hnd->attr_base, PAGE_SIZE ) == 0 )
+ if (munmap(hnd->attr_base, PAGE_SIZE) == 0)
{
hnd->attr_base = MAP_FAILED;
rval = 0;
@@ -143,33 +129,40 @@ out:
*
* Return 0 on success.
*/
-static inline int gralloc_buffer_attr_write( struct private_handle_t *hnd, buf_attr attr, int *val )
+static inline int gralloc_buffer_attr_write(struct private_handle_t *hnd, buf_attr attr, int *val)
{
int rval = -1;
- if( !hnd || !val || attr >= GRALLOC_ARM_BUFFER_ATTR_LAST )
+ if (!hnd || !val || attr >= GRALLOC_ARM_BUFFER_ATTR_LAST)
+ {
goto out;
+ }
- if( hnd->attr_base != MAP_FAILED )
+ if (hnd->attr_base != MAP_FAILED)
{
- attr_region *region = (attr_region *) hnd->attr_base;
+ attr_region *region = (attr_region *)hnd->attr_base;
- switch( attr )
+ switch (attr)
{
- case GRALLOC_ARM_BUFFER_ATTR_CROP_RECT:
- memcpy( &region->crop_top, val, sizeof(int)*4 );
- rval = 0;
- break;
-
- case GRALLOC_ARM_BUFFER_ATTR_AFBC_YUV_TRANS:
- region->use_yuv_transform = *val;
- rval = 0;
- break;
-
- case GRALLOC_ARM_BUFFER_ATTR_AFBC_SPARSE_ALLOC:
- region->use_sparse_alloc = *val;
- rval = 0;
- break;
+ case GRALLOC_ARM_BUFFER_ATTR_CROP_RECT:
+ memcpy(&region->crop_top, val, sizeof(int) * 4);
+ rval = 0;
+ break;
+
+ case GRALLOC_ARM_BUFFER_ATTR_AFBC_YUV_TRANS:
+ region->use_yuv_transform = *val;
+ rval = 0;
+ break;
+
+ case GRALLOC_ARM_BUFFER_ATTR_AFBC_SPARSE_ALLOC:
+ region->use_sparse_alloc = *val;
+ rval = 0;
+ break;
+
+ case GRALLOC_ARM_BUFFER_ATTR_HDR_INFO:
+ memcpy(&region->hdr_info, val, sizeof(mali_hdr_info));
+ rval = 0;
+ break;
}
}
@@ -177,33 +170,40 @@ out:
return rval;
}
-static inline int gralloc_buffer_attr_read( struct private_handle_t *hnd, buf_attr attr, int *val )
+static inline int gralloc_buffer_attr_read(struct private_handle_t *hnd, buf_attr attr, int *val)
{
int rval = -1;
- if( !hnd || !val || attr >= GRALLOC_ARM_BUFFER_ATTR_LAST )
+ if (!hnd || !val || attr >= GRALLOC_ARM_BUFFER_ATTR_LAST)
+ {
goto out;
+ }
- if( hnd->attr_base != MAP_FAILED )
+ if (hnd->attr_base != MAP_FAILED)
{
- attr_region *region = (attr_region *) hnd->attr_base;
+ attr_region *region = (attr_region *)hnd->attr_base;
- switch( attr )
+ switch (attr)
{
- case GRALLOC_ARM_BUFFER_ATTR_CROP_RECT:
- memcpy( val, &region->crop_top, sizeof(int)*4 );
- rval = 0;
- break;
-
- case GRALLOC_ARM_BUFFER_ATTR_AFBC_YUV_TRANS:
- *val = region->use_yuv_transform;
- rval = 0;
- break;
-
- case GRALLOC_ARM_BUFFER_ATTR_AFBC_SPARSE_ALLOC:
- *val = region->use_sparse_alloc;
- rval = 0;
- break;
+ case GRALLOC_ARM_BUFFER_ATTR_CROP_RECT:
+ memcpy(val, &region->crop_top, sizeof(int) * 4);
+ rval = 0;
+ break;
+
+ case GRALLOC_ARM_BUFFER_ATTR_AFBC_YUV_TRANS:
+ *val = region->use_yuv_transform;
+ rval = 0;
+ break;
+
+ case GRALLOC_ARM_BUFFER_ATTR_AFBC_SPARSE_ALLOC:
+ *val = region->use_sparse_alloc;
+ rval = 0;
+ break;
+
+ case GRALLOC_ARM_BUFFER_ATTR_HDR_INFO:
+ memcpy(val, &region->hdr_info, sizeof(mali_hdr_info));
+ rval = 0;
+ break;
}
}
diff --git a/gralloc960/gralloc_helper.h b/gralloc960/gralloc_helper.h
index 12adb531..fea10e5e 100644
--- a/gralloc960/gralloc_helper.h
+++ b/gralloc960/gralloc_helper.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 ARM Limited. All rights reserved.
+ * Copyright (C) 2010-2017 ARM Limited. All rights reserved.
*
* Copyright (C) 2008 The Android Open Source Project
*
@@ -20,12 +20,32 @@
#define GRALLOC_HELPER_H_
#include <sys/mman.h>
+#include <android/log.h>
-#define GRALLOC_UNUSED(x) ((void) x)
+#ifndef AWAR
+#define AWAR(fmt, args...) \
+ __android_log_print(ANDROID_LOG_WARN, "[Gralloc-Warning]", "%s:%d " fmt, __func__, __LINE__, ##args)
+#endif
+#ifndef AINF
+#define AINF(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "[Gralloc]", fmt, ##args)
+#endif
+#ifndef AERR
+#define AERR(fmt, args...) \
+ __android_log_print(ANDROID_LOG_ERROR, "[Gralloc-ERROR]", "%s:%d " fmt, __func__, __LINE__, ##args)
+#endif
+#ifndef AERR_IF
+#define AERR_IF(eq, fmt, args...) \
+ if ((eq)) \
+ AERR(fmt, args)
+#endif
+
+#define GRALLOC_ALIGN(value, base) (((value) + ((base)-1)) & ~((base)-1))
+
+#define GRALLOC_UNUSED(x) ((void)x)
static inline size_t round_up_to_page_size(size_t x)
{
- return (x + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1);
+ return (x + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
}
#endif /* GRALLOC_HELPER_H_ */
diff --git a/gralloc960/gralloc_module.cpp b/gralloc960/gralloc_module.cpp
deleted file mode 100644
index df2d82e3..00000000
--- a/gralloc960/gralloc_module.cpp
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright (C) 2010 ARM Limited. All rights reserved.
- *
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <errno.h>
-#include <pthread.h>
-#include <inttypes.h>
-
-#include <cutils/log.h>
-#include <cutils/atomic.h>
-#include <hardware/hardware.h>
-#include <hardware/gralloc.h>
-
-#include "gralloc_priv.h"
-#include "gralloc_helper.h"
-#include "alloc_device.h"
-#include "framebuffer_device.h"
-
-#include "gralloc_module_allocator_specific.h"
-#include "gralloc_buffer_priv.h"
-
-#include "mali_gralloc_formats.h"
-
-static pthread_mutex_t s_map_lock = PTHREAD_MUTEX_INITIALIZER;
-
-static int gralloc_device_open(const hw_module_t* module, const char* name, hw_device_t** device)
-{
- int status = -EINVAL;
-
- if (!strncmp(name, GRALLOC_HARDWARE_GPU0, MALI_GRALLOC_HARDWARE_MAX_STR_LEN))
- {
- status = alloc_device_open(module, name, device);
- }
- else if (!strncmp(name, GRALLOC_HARDWARE_FB0, MALI_GRALLOC_HARDWARE_MAX_STR_LEN))
- {
- status = framebuffer_device_open(module, name, device);
- }
-
- return status;
-}
-
-static int gralloc_register_buffer(gralloc_module_t const* module, buffer_handle_t handle)
-{
- GRALLOC_UNUSED(module);
-
- if (private_handle_t::validate(handle) < 0)
- {
- AERR("Registering invalid buffer %p, returning error", handle);
- return -EINVAL;
- }
-
- // if this handle was created in this process, then we keep it as is.
- private_handle_t* hnd = (private_handle_t*)handle;
-
- int retval = -EINVAL;
-
- pthread_mutex_lock(&s_map_lock);
-
- if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
- {
- AINF("Register framebuffer 0x%p is no-op", handle);
- retval = 0;
- }
- else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
- {
- retval = gralloc_backend_register(hnd);
- }
- else
- {
- AERR("unknown buffer flags not supported. flags = %d", hnd->flags );
- }
-
- pthread_mutex_unlock(&s_map_lock);
- return retval;
-}
-
-static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_handle_t handle)
-{
- GRALLOC_UNUSED(module);
-
- if (private_handle_t::validate(handle) < 0)
- {
- AERR("unregistering invalid buffer %p, returning error", handle);
- return -EINVAL;
- }
-
- private_handle_t* hnd = (private_handle_t*)handle;
-
- AERR_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK, "[unregister] handle %p still locked (state=%08x)", hnd, hnd->lockState);
-
- if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
- {
- AERR( "Can't unregister buffer %p as it is a framebuffer", handle );
- }
- else
- {
- pthread_mutex_lock(&s_map_lock);
-
- if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
- {
- gralloc_backend_unregister(hnd);
- }
- else
- {
- AERR("Unregistering unknown buffer is not supported. Flags = %d", hnd->flags);
- }
-
- /*
- * Close shared attribute region file descriptor. It might seem strange to "free"
- * this here since this can happen in a client process, but free here is nothing
- * but unmapping and closing the duplicated file descriptor. The original ashmem
- * fd instance is still open until alloc_device_free() is called. Even sharing
- * of gralloc buffers within the same process should have fds dup:ed.
- */
- gralloc_buffer_attr_free( hnd );
-
- hnd->base = 0;
- hnd->lockState = 0;
- hnd->writeOwner = 0;
-
- pthread_mutex_unlock(&s_map_lock);
- }
-
- return 0;
-}
-
-static int gralloc_lock(gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr)
-{
- GRALLOC_UNUSED(module);
- GRALLOC_UNUSED(l);
- GRALLOC_UNUSED(t);
- GRALLOC_UNUSED(w);
- GRALLOC_UNUSED(h);
-
- if (private_handle_t::validate(handle) < 0)
- {
- AERR("Locking invalid buffer %p, returning error", handle );
- return -EINVAL;
- }
-
- private_handle_t* hnd = (private_handle_t*)handle;
-
- if (hnd->req_format == HAL_PIXEL_FORMAT_YCbCr_420_888)
- {
- AERR("Buffers with format YCbCr_420_888 must be locked using (*lock_ycbcr)" );
- return -EINVAL;
- }
-
- if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
- {
- hnd->writeOwner = usage & GRALLOC_USAGE_SW_WRITE_MASK;
- }
- if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
- {
- *vaddr = (void*)hnd->base;
- }
- return 0;
-}
-
-static int gralloc_lock_ycbcr(gralloc_module_t const* module, buffer_handle_t handle, int usage,
- int l, int t, int w, int h,
- android_ycbcr *ycbcr)
-{
- GRALLOC_UNUSED(module);
- GRALLOC_UNUSED(l);
- GRALLOC_UNUSED(t);
- GRALLOC_UNUSED(w);
- GRALLOC_UNUSED(h);
-
- if (private_handle_t::validate(handle) < 0)
- {
- AERR("Locking invalid buffer %p, returning error", handle );
- return -EINVAL;
- }
-
- private_handle_t* hnd = (private_handle_t*)handle;
-
- if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
- {
- hnd->writeOwner = usage & GRALLOC_USAGE_SW_WRITE_MASK;
- }
- if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK) &&
- !(hnd->internal_format & MALI_GRALLOC_INTFMT_EXT_MASK))
- {
- char* base = (char*)hnd->base;
- int y_stride = hnd->byte_stride;
- /* Ensure height is aligned for subsampled chroma before calculating buffer parameters */
- int adjusted_height = GRALLOC_ALIGN(hnd->height, 2);
- int y_size = y_stride * adjusted_height;
-
- int u_offset = 0;
- int v_offset = 0;
- int c_stride = 0;
- int step = 0;
-
- uint64_t base_format = hnd->internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
-
- switch (base_format)
- {
- case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
- c_stride = y_stride;
- /* Y plane, UV plane */
- u_offset = y_size;
- v_offset = y_size + 1;
- step = 2;
- break;
-
- case MALI_GRALLOC_FORMAT_INTERNAL_NV21:
- c_stride = y_stride;
- /* Y plane, UV plane */
- v_offset = y_size;
- u_offset = y_size + 1;
- step = 2;
- break;
-
- case MALI_GRALLOC_FORMAT_INTERNAL_YV12:
- {
- int c_size;
-
- /* Stride alignment set to 16 as the SW access flags were set */
- c_stride = GRALLOC_ALIGN(hnd->byte_stride / 2, 16);
- c_size = c_stride * (adjusted_height / 2);
- /* Y plane, V plane, U plane */
- v_offset = y_size;
- u_offset = y_size + c_size;
- step = 1;
- break;
- }
-
- default:
- AERR("Can't lock buffer %p: wrong format %" PRIx64, hnd, hnd->internal_format);
- return -EINVAL;
- }
-
- ycbcr->y = base;
- ycbcr->cb = base + u_offset;
- ycbcr->cr = base + v_offset;
- ycbcr->ystride = y_stride;
- ycbcr->cstride = c_stride;
- ycbcr->chroma_step = step;
- }
- return 0;
-}
-
-static int gralloc_unlock(gralloc_module_t const* module, buffer_handle_t handle)
-{
- GRALLOC_UNUSED(module);
-
- if (private_handle_t::validate(handle) < 0)
- {
- AERR( "Unlocking invalid buffer %p, returning error", handle );
- return -EINVAL;
- }
-
- private_handle_t* hnd = (private_handle_t*)handle;
-
- if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION && hnd->writeOwner)
- {
- gralloc_backend_sync(hnd);
- }
-
- return 0;
-}
-
-// There is one global instance of the module
-
-static struct hw_module_methods_t gralloc_module_methods =
-{
- gralloc_device_open
-};
-
-private_module_t::private_module_t()
-{
-#define INIT_ZERO(obj) (memset(&(obj),0,sizeof((obj))))
-
- base.common.tag = HARDWARE_MODULE_TAG;
- base.common.version_major = 1;
- base.common.version_minor = 0;
- base.common.id = GRALLOC_HARDWARE_MODULE_ID;
- base.common.name = "Graphics Memory Allocator Module";
- base.common.author = "ARM Ltd.";
- base.common.methods = &gralloc_module_methods;
- base.common.dso = NULL;
- INIT_ZERO(base.common.reserved);
-
- base.registerBuffer = gralloc_register_buffer;
- base.unregisterBuffer = gralloc_unregister_buffer;
- base.lock = gralloc_lock;
- base.lock_ycbcr = gralloc_lock_ycbcr;
- base.unlock = gralloc_unlock;
- base.perform = NULL;
- INIT_ZERO(base.reserved_proc);
-
- framebuffer = NULL;
- flags = 0;
- numBuffers = 0;
- bufferMask = 0;
- pthread_mutex_init(&(lock), NULL);
- currentBuffer = NULL;
- INIT_ZERO(info);
- INIT_ZERO(finfo);
- xdpi = 0.0f;
- ydpi = 0.0f;
- fps = 0.0f;
- swapInterval = 1;
-
-#undef INIT_ZERO
-};
-
-/*
- * HAL_MODULE_INFO_SYM will be initialized using the default constructor
- * implemented above
- */
-struct private_module_t HAL_MODULE_INFO_SYM;
-
diff --git a/gralloc960/gralloc_module_ion.cpp b/gralloc960/gralloc_module_ion.cpp
deleted file mode 100644
index 49a17a05..00000000
--- a/gralloc960/gralloc_module_ion.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2013 ARM Limited. All rights reserved.
- *
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <errno.h>
-#include <pthread.h>
-#include <string.h>
-
-#include <cutils/log.h>
-#include <cutils/atomic.h>
-#include <hardware/hardware.h>
-#include <hardware/gralloc.h>
-
-#include "gralloc_priv.h"
-#include "alloc_device.h"
-#include "framebuffer_device.h"
-#include "ion_4.12.h"
-
-#include <linux/ion.h>
-#include <ion/ion.h>
-#include <sys/mman.h>
-
-int gralloc_backend_register(private_handle_t* hnd)
-{
- int retval = -EINVAL;
-
- switch (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
- {
- case private_handle_t::PRIV_FLAGS_USES_ION:
- unsigned char *mappedAddress;
- size_t size = hnd->size;
- hw_module_t * pmodule = NULL;
- private_module_t *m=NULL;
- if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&pmodule) == 0)
- {
- m = reinterpret_cast<private_module_t *>(pmodule);
- }
- else
- {
- AERR("Could not get gralloc module for handle: %p", hnd);
- retval = -errno;
- break;
- }
- /* the test condition is set to m->ion_client <= 0 here, because:
- * 1) module structure are initialized to 0 if no initial value is applied
- * 2) a second user process should get a ion fd greater than 0.
- */
- if (m->ion_client <= 0)
- {
- /* a second user process must obtain a client handle first via ion_open before it can obtain the shared ion buffer*/
- m->ion_client = ion_open();
-
- if (m->ion_client < 0)
- {
- AERR( "Could not open ion device for handle: %p", hnd );
- retval = -errno;
- break;
- }
- }
-
- mappedAddress = (unsigned char*)mmap( NULL, size, PROT_READ | PROT_WRITE,
- MAP_SHARED, hnd->share_fd, 0 );
-
- if ( MAP_FAILED == mappedAddress )
- {
- AERR( "mmap( share_fd:%d ) failed with %s", hnd->share_fd, strerror( errno ) );
- retval = -errno;
- break;
- }
-
- hnd->base = (void*)(uintptr_t(mappedAddress) + hnd->offset);
- retval = 0;
- break;
- }
-
- return retval;
-}
-
-void gralloc_backend_unregister(private_handle_t* hnd)
-{
- switch (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
- {
- case private_handle_t::PRIV_FLAGS_USES_ION:
- void* base = (void*)hnd->base;
- size_t size = hnd->size;
-
- if ( munmap( base,size ) < 0 )
- {
- AERR("Could not munmap base:%p size:%zd '%s'", base, size, strerror(errno));
- }
- break;
- }
-}
-
-void gralloc_backend_sync(private_handle_t* hnd)
-{
- switch (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
- {
- case private_handle_t::PRIV_FLAGS_USES_ION:
- hw_module_t * pmodule = NULL;
- if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&pmodule) == 0)
- {
- private_module_t *m = reinterpret_cast<private_module_t *>(pmodule);
- if (m->gralloc_legacy_ion)
- {
- if(!(hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION_DMA_HEAP))
- {
- ion_sync_fd(m->ion_client, hnd->share_fd);
- }
- }
- }
- else
- {
- AERR("Could not get gralloc module for handle %p\n", hnd);
- }
- break;
- }
-}
diff --git a/gralloc960/gralloc_priv.h b/gralloc960/gralloc_priv.h
index 606b3654..82538bc0 100644
--- a/gralloc960/gralloc_priv.h
+++ b/gralloc960/gralloc_priv.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 ARM Limited. All rights reserved.
+ * Copyright (C) 2017 ARM Limited. All rights reserved.
*
* Copyright (C) 2008 The Android Open Source Project
*
@@ -27,262 +27,42 @@
#include <sys/types.h>
#include <unistd.h>
#include <sys/mman.h>
-#include <hardware/gralloc.h>
#include <cutils/native_handle.h>
-#include "alloc_device.h"
#include <utils/Log.h>
+#if GRALLOC_USE_GRALLOC1_API
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+/**
+ * mali_gralloc_formats.h needs the define for GRALLOC_MODULE_API_VERSION_0_3 and
+ * GRALLOC_MODULE_API_VERSION_1_0, so include <gralloc1.h> or <gralloc.h> before
+ * including mali_gralloc_formats.h
+ **/
#include "mali_gralloc_formats.h"
+#include "mali_gralloc_usages.h"
#include "gralloc_helper.h"
+#if defined(GRALLOC_MODULE_API_VERSION_0_3) || \
+ (defined(GRALLOC_MODULE_API_VERSION_1_0) && !defined(GRALLOC_DISABLE_PRIVATE_BUFFER_DEF))
-/* NOTE:
- * If your framebuffer device driver is integrated with dma_buf, you will have to
- * change this IOCTL definition to reflect your integration with the framebuffer
- * device.
- * Expected return value is a structure filled with a file descriptor
- * backing your framebuffer device memory.
- */
-struct fb_dmabuf_export
-{
- __u32 fd;
- __u32 flags;
-};
-#define FBIOGET_DMABUF _IOR('F', 0x21, struct fb_dmabuf_export)
-
-
-/* the max string size of GRALLOC_HARDWARE_GPU0 & GRALLOC_HARDWARE_FB0
- * 8 is big enough for "gpu0" & "fb0" currently
+/*
+ * This header file contains the private buffer definition. For gralloc 0.3 it will
+ * always be exposed, but for gralloc 1.0 it will be removed at some point in the future.
+ *
+ * GRALLOC_DISABLE_PRIVATE_BUFFER_DEF is intended for DDKs to test while implementing
+ * the new private API.
*/
-#define MALI_GRALLOC_HARDWARE_MAX_STR_LEN 8
-#define NUM_FB_BUFFERS 2
-
-/* Define number of shared file descriptors */
-#define GRALLOC_ARM_NUM_FDS 2
-
-#define NUM_INTS_IN_PRIVATE_HANDLE ((sizeof(struct private_handle_t) - sizeof(native_handle)) / sizeof(int) - sNumFds)
-
-#define SZ_4K 0x00001000
-#define SZ_2M 0x00200000
-
-typedef enum
-{
- MALI_YUV_NO_INFO,
- MALI_YUV_BT601_NARROW,
- MALI_YUV_BT601_WIDE,
- MALI_YUV_BT709_NARROW,
- MALI_YUV_BT709_WIDE
-} mali_gralloc_yuv_info;
-
-typedef enum
-{
- MALI_DPY_TYPE_UNKNOWN = 0,
- MALI_DPY_TYPE_CLCD,
- MALI_DPY_TYPE_HDLCD
-} mali_dpy_type;
-
-struct private_handle_t;
-
-struct private_module_t
-{
- gralloc_module_t base;
-
- struct private_handle_t* framebuffer;
- uint32_t flags;
- uint32_t numBuffers;
- uint32_t bufferMask;
- pthread_mutex_t lock;
- buffer_handle_t currentBuffer;
- int ion_client;
- int system_heap_id;
- bool gralloc_legacy_ion;
- mali_dpy_type dpy_type;
-
- struct fb_var_screeninfo info;
- struct fb_fix_screeninfo finfo;
- float xdpi;
- float ydpi;
- float fps;
- int swapInterval;
-
-#ifdef __cplusplus
- /* Never intended to be used from C code */
- enum
- {
- // flag to indicate we'll post this buffer
- PRIV_USAGE_LOCKED_FOR_POST = 0x80000000
- };
+#include "mali_gralloc_buffer.h"
#endif
-#ifdef __cplusplus
- /* default constructor */
- private_module_t();
-#endif
-};
+#if defined(GRALLOC_MODULE_API_VERSION_1_0)
-#ifndef __cplusplus
-/* C99 with pedantic don't allow anonymous unions which is used in below struct
- * Disable pedantic for C for this struct only.
+/* gralloc 1.0 supports the new private interface that abstracts
+ * the private buffer definition to a set of defined APIs.
*/
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-
-#ifdef __cplusplus
-struct private_handle_t : public native_handle
-{
-#else
-struct private_handle_t
-{
- struct native_handle nativeHandle;
-#endif
-
-#ifdef __cplusplus
- /* Never intended to be used from C code */
- enum
- {
- PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
- PRIV_FLAGS_USES_ION_COMPOUND_HEAP = 0x00000002,
- PRIV_FLAGS_USES_ION = 0x00000004,
- PRIV_FLAGS_USES_ION_DMA_HEAP = 0x00000008
- };
-
- enum
- {
- LOCK_STATE_WRITE = 1<<31,
- LOCK_STATE_MAPPED = 1<<30,
- LOCK_STATE_READ_MASK = 0x3FFFFFFF
- };
-#endif
-
- /*
- * Shared file descriptor for dma_buf sharing. This must be the first element in the
- * structure so that binder knows where it is and can properly share it between
- * processes.
- * DO NOT MOVE THIS ELEMENT!
- */
- int share_fd;
- int share_attr_fd;
-
- ion_user_handle_t ion_hnd_UNUSED;
-
- // ints
- int magic;
- int req_format;
- uint64_t internal_format;
- int byte_stride;
- int flags;
- int usage;
- int size;
- int width;
- int height;
- int internalWidth;
- int internalHeight;
- int stride;
- union {
- void* base;
- uint64_t padding;
- };
- int lockState;
- int writeOwner;
- int pid_UNUSED;
-
- // locally mapped shared attribute area
- union {
- void* attr_base;
- uint64_t padding3;
- };
-
- mali_gralloc_yuv_info yuv_info;
-
- // Following members is for framebuffer only
- int shallow_fbdev_fd; // shallow copy, not dup'ed
- union {
- off_t offset;
- uint64_t padding4;
- };
-
- /*
- * min_pgsz denotes minimum phys_page size used by this buffer.
- * if buffer memory is physical contiguous set min_pgsz to buff->size
- * if not sure buff's real phys_page size, you can use SZ_4K for safe.
- */
- int min_pgsz;
-#ifdef __cplusplus
- /*
- * We track the number of integers in the structure. There are 16 unconditional
- * integers (magic - pid, yuv_info, shallow_fbdev_fd and offset).
- * Note that the shallow_fbdev_fd element is
- * considered an int not an fd because it is not intended to be used outside the
- * surface flinger process. The GRALLOC_ARM_NUM_INTS variable is used to track the
- * number of integers that are conditionally included. Similar considerations apply
- * to the number of fds.
- */
- static const int sNumFds = GRALLOC_ARM_NUM_FDS;
- static const int sMagic = 0x3141592;
-
- private_handle_t(int _flags, int _usage, int _size, void *_base, int lock_state, int fb_file, off_t fb_offset):
- share_fd(-1),
- share_attr_fd(-1),
- ion_hnd_UNUSED(-1),
- magic(sMagic),
- flags(_flags),
- usage(_usage),
- size(_size),
- width(0),
- height(0),
- stride(0),
- base(_base),
- lockState(lock_state),
- writeOwner(0),
- pid_UNUSED(-1),
- attr_base(MAP_FAILED),
- yuv_info(MALI_YUV_NO_INFO),
- shallow_fbdev_fd(fb_file),
- offset(fb_offset)
- {
- version = sizeof(native_handle);
- numFds = sNumFds;
- numInts = NUM_INTS_IN_PRIVATE_HANDLE;
- }
-
- ~private_handle_t()
- {
- magic = 0;
- }
-
- bool usesPhysicallyContiguousMemory()
- {
- return (flags & PRIV_FLAGS_FRAMEBUFFER) ? true : false;
- }
-
- static int validate(const native_handle* h)
- {
- const private_handle_t* hnd = (const private_handle_t*)h;
- if (!h ||
- h->version != sizeof(native_handle) ||
- h->numInts != NUM_INTS_IN_PRIVATE_HANDLE ||
- h->numFds != sNumFds ||
- hnd->magic != sMagic)
- {
- return -EINVAL;
- }
- return 0;
- }
-
- static private_handle_t* dynamicCast(const native_handle* in)
- {
- if (validate(in) == 0)
- {
- return (private_handle_t*) in;
- }
- return NULL;
- }
-#endif
-};
-#ifndef __cplusplus
-/* Restore previous diagnostic for pedantic */
-#pragma GCC diagnostic pop
+#include "mali_gralloc_private_interface.h"
#endif
#endif /* GRALLOC_PRIV_H_ */
diff --git a/gralloc960/gralloc_vsync.h b/gralloc960/gralloc_vsync.h
index 6027edaa..af2bd2b6 100644
--- a/gralloc960/gralloc_vsync.h
+++ b/gralloc960/gralloc_vsync.h
@@ -22,10 +22,10 @@
struct framebuffer_device_t;
/* Enables vsync interrupt. */
-int gralloc_vsync_enable(struct framebuffer_device_t* dev);
+int gralloc_vsync_enable(struct framebuffer_device_t *dev);
/* Disables vsync interrupt. */
-int gralloc_vsync_disable(struct framebuffer_device_t* dev);
+int gralloc_vsync_disable(struct framebuffer_device_t *dev);
/* Waits for the vsync interrupt. */
-int gralloc_wait_for_vsync(struct framebuffer_device_t* dev);
+int gralloc_wait_for_vsync(struct framebuffer_device_t *dev);
#endif /* _GRALLOC_VSYNC_H_ */
diff --git a/gralloc960/gralloc_vsync_default.cpp b/gralloc960/gralloc_vsync_default.cpp
index 3ce7f0e8..2a38fd98 100644
--- a/gralloc960/gralloc_vsync_default.cpp
+++ b/gralloc960/gralloc_vsync_default.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 ARM Limited. All rights reserved.
+ * Copyright (C) 2014-2017 ARM Limited. All rights reserved.
*
* Copyright (C) 2008 The Android Open Source Project
*
@@ -16,13 +16,25 @@
* limitations under the License.
*/
-#include "gralloc_priv.h"
-#include "gralloc_vsync.h"
-#include "gralloc_vsync_report.h"
#include <sys/ioctl.h>
#include <errno.h>
-#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
+#include <hardware/hardware.h>
+#include <hardware/fb.h>
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+
+#include "mali_gralloc_module.h"
+#include "mali_gralloc_private_interface_types.h"
+#include "mali_gralloc_buffer.h"
+#include "gralloc_vsync.h"
+#include "gralloc_vsync_report.h"
+
+#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
int gralloc_vsync_enable(framebuffer_device_t *dev)
{
@@ -38,23 +50,27 @@ int gralloc_vsync_disable(framebuffer_device_t *dev)
int gralloc_wait_for_vsync(framebuffer_device_t *dev)
{
- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
+ private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module);
+
if (MALI_DPY_TYPE_CLCD == m->dpy_type || MALI_DPY_TYPE_HDLCD == m->dpy_type)
{
/* Silently ignore wait for vsync as neither PL111 nor HDLCD implement this IOCTL. */
return 0;
}
- if ( m->swapInterval )
+ if (m->swapInterval)
{
int crtc = 0;
gralloc_mali_vsync_report(MALI_VSYNC_EVENT_BEGIN_WAIT);
- if(ioctl(m->framebuffer->shallow_fbdev_fd, FBIO_WAITFORVSYNC, &crtc) < 0)
+
+ if (ioctl(m->framebuffer->fd, FBIO_WAITFORVSYNC, &crtc) < 0)
{
gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT);
return -errno;
}
+
gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT);
}
+
return 0;
}
diff --git a/gralloc960/gralloc_vsync_report.h b/gralloc960/gralloc_vsync_report.h
index ea45cc44..49baabf3 100644
--- a/gralloc960/gralloc_vsync_report.h
+++ b/gralloc960/gralloc_vsync_report.h
@@ -20,11 +20,9 @@
#include "gralloc_helper.h"
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
-
typedef enum mali_vsync_event
{
MALI_VSYNC_EVENT_BEGIN_WAIT = 0,
@@ -35,11 +33,11 @@ extern void _mali_base_arch_vsync_event_report(mali_vsync_event);
inline void gralloc_mali_vsync_report(mali_vsync_event event)
{
- #ifdef MALI_VSYNC_EVENT_REPORT_ENABLE
+#ifdef MALI_VSYNC_EVENT_REPORT_ENABLE
_mali_base_arch_vsync_event_report(event);
- #else
+#else
GRALLOC_UNUSED(event);
- #endif
+#endif
}
#ifdef __cplusplus
diff --git a/gralloc960/gralloc_vsync_s3cfb.cpp b/gralloc960/gralloc_vsync_s3cfb.cpp
index 5740ea93..434e685b 100644
--- a/gralloc960/gralloc_vsync_s3cfb.cpp
+++ b/gralloc960/gralloc_vsync_s3cfb.cpp
@@ -22,38 +22,52 @@
#include <sys/ioctl.h>
#include <errno.h>
-#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
-#define S3CFB_SET_VSYNC_INT _IOW('F', 206, unsigned int)
+#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
+#define S3CFB_SET_VSYNC_INT _IOW('F', 206, unsigned int)
int gralloc_vsync_enable(framebuffer_device_t *dev)
{
- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
+ private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module);
int interrupt = 1;
- if(ioctl(m->framebuffer->fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0) return -errno;
+
+ if (ioctl(m->framebuffer->fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0)
+ {
+ return -errno;
+ }
+
return 0;
}
int gralloc_vsync_disable(framebuffer_device_t *dev)
{
- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
+ private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module);
int interrupt = 0;
- if(ioctl(m->framebuffer->fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0) return -errno;
+
+ if (ioctl(m->framebuffer->fd, S3CFB_SET_VSYNC_INT, &interrupt) < 0)
+ {
+ return -errno;
+ }
+
return 0;
}
int gralloc_wait_for_vsync(framebuffer_device_t *dev)
{
- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
- if ( m->swapInterval )
+ private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module);
+
+ if (m->swapInterval)
{
int crtc = 0;
gralloc_mali_vsync_report(MALI_VSYNC_EVENT_BEGIN_WAIT);
- if(ioctl(m->framebuffer->fd, FBIO_WAITFORVSYNC, &crtc) < 0)
+
+ if (ioctl(m->framebuffer->fd, FBIO_WAITFORVSYNC, &crtc) < 0)
{
gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT);
return -errno;
}
+
gralloc_mali_vsync_report(MALI_VSYNC_EVENT_END_WAIT);
}
+
return 0;
}
diff --git a/gralloc960/legacy/alloc_device.cpp b/gralloc960/legacy/alloc_device.cpp
new file mode 100644
index 00000000..6b76948b
--- /dev/null
+++ b/gralloc960/legacy/alloc_device.cpp
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2010-2017 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+
+#include <log/log.h>
+#include <cutils/atomic.h>
+#include <hardware/hardware.h>
+#include <hardware/gralloc.h>
+
+#include <sys/ioctl.h>
+
+#include "mali_gralloc_module.h"
+#include "alloc_device.h"
+#include "gralloc_priv.h"
+#include "gralloc_helper.h"
+#include "framebuffer_device.h"
+#include "mali_gralloc_ion.h"
+#include "gralloc_buffer_priv.h"
+#include "mali_gralloc_bufferdescriptor.h"
+#include "mali_gralloc_bufferallocation.h"
+#include "mali_gralloc_formats.h"
+#include "mali_gralloc_usages.h"
+
+static int alloc_device_alloc(alloc_device_t *dev, int w, int h, int format, int usage, buffer_handle_t *pHandle,
+ int *pStride)
+{
+ mali_gralloc_module *m;
+ int err = -EINVAL;
+
+ if (!dev || !pHandle || !pStride)
+ {
+ return err;
+ }
+
+ m = reinterpret_cast<private_module_t *>(dev->common.module);
+
+#if GRALLOC_FB_SWAP_RED_BLUE == 1
+
+ /* match the framebuffer format */
+ if (usage & GRALLOC_USAGE_HW_FB)
+ {
+#ifdef GRALLOC_16_BITS
+ format = HAL_PIXEL_FORMAT_RGB_565;
+#else
+ format = HAL_PIXEL_FORMAT_BGRA_8888;
+#endif
+ }
+
+#endif
+
+#if DISABLE_FRAMEBUFFER_HAL != 1
+
+ if (usage & GRALLOC_USAGE_HW_FB)
+ {
+ int byte_stride;
+ int pixel_stride;
+
+ err = fb_alloc_framebuffer(m, usage, usage, pHandle, &pixel_stride, &byte_stride);
+
+ if (err >= 0)
+ {
+ private_handle_t *hnd = (private_handle_t *)*pHandle;
+
+ /* Allocate a meta-data buffer for framebuffer too. fbhal
+ * ones wont need it but it will lead to binder IPC fail
+ * without a valid share_attr_fd.
+ *
+ * Explicitly ignore allocation errors since it is not critical to have
+ */
+ (void)gralloc_buffer_attr_allocate(hnd);
+
+ hnd->req_format = format;
+ hnd->yuv_info = MALI_YUV_BT601_NARROW;
+ hnd->internal_format = format;
+ hnd->byte_stride = byte_stride;
+ hnd->width = w;
+ hnd->height = h;
+ hnd->stride = pixel_stride;
+ hnd->internalWidth = w;
+ hnd->internalHeight = h;
+ }
+ }
+ else
+#endif
+ {
+ /* share the same allocation interface with gralloc1.*/
+ buffer_descriptor_t buffer_descriptor;
+ gralloc_buffer_descriptor_t gralloc_buffer_descriptor[1];
+
+ buffer_descriptor.hal_format = format;
+ buffer_descriptor.consumer_usage = usage;
+ buffer_descriptor.producer_usage = usage;
+ buffer_descriptor.width = w;
+ buffer_descriptor.height = h;
+ buffer_descriptor.format_type = MALI_GRALLOC_FORMAT_TYPE_USAGE;
+ gralloc_buffer_descriptor[0] = (gralloc_buffer_descriptor_t)(&buffer_descriptor);
+
+ if (mali_gralloc_buffer_allocate(m, gralloc_buffer_descriptor, 1, pHandle, NULL) < 0)
+ {
+ ALOGE("Failed to allocate buffer.");
+ err = -ENOMEM;
+ }
+ else
+ {
+ mali_gralloc_query_getstride(*pHandle, pStride);
+ err = 0;
+ }
+ }
+
+ return err;
+}
+
+static int alloc_device_free(alloc_device_t *dev, buffer_handle_t handle)
+{
+ if (private_handle_t::validate(handle) < 0)
+ {
+ return -EINVAL;
+ }
+
+ private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(handle);
+ private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module);
+
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
+ {
+ // free this buffer
+ close(hnd->fd);
+ }
+ else
+ {
+ mali_gralloc_buffer_free(handle);
+ }
+
+ delete hnd;
+
+ return 0;
+}
+
+int alloc_device_open(hw_module_t const *module, const char *name, hw_device_t **device)
+{
+ alloc_device_t *dev;
+
+ GRALLOC_UNUSED(name);
+
+ dev = new alloc_device_t;
+
+ if (NULL == dev)
+ {
+ return -1;
+ }
+
+ /* initialize our state here */
+ memset(dev, 0, sizeof(*dev));
+
+ /* initialize the procs */
+ dev->common.tag = HARDWARE_DEVICE_TAG;
+ dev->common.version = 0;
+ dev->common.module = const_cast<hw_module_t *>(module);
+ dev->common.close = mali_gralloc_ion_device_close;
+ dev->alloc = alloc_device_alloc;
+ dev->free = alloc_device_free;
+
+ *device = &dev->common;
+
+ return 0;
+}
diff --git a/gralloc960/gralloc_module_allocator_specific.h b/gralloc960/legacy/alloc_device.h
index f719e73a..6fb186a0 100644
--- a/gralloc960/gralloc_module_allocator_specific.h
+++ b/gralloc960/legacy/alloc_device.h
@@ -1,5 +1,7 @@
/*
- * Copyright (C) 2013 ARM Limited. All rights reserved.
+ * Copyright (C) 2010 ARM Limited. All rights reserved.
+ *
+ * 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.
@@ -14,8 +16,7 @@
* limitations under the License.
*/
-int gralloc_backend_register(struct private_handle_t* hnd);
-
-void gralloc_backend_unregister(struct private_handle_t* hnd);
+#include <hardware/hardware.h>
-void gralloc_backend_sync(struct private_handle_t* hnd);
+// Create an alloc device
+int alloc_device_open(hw_module_t const *module, const char *name, hw_device_t **device);
diff --git a/gralloc960/mali_gralloc_buffer.h b/gralloc960/mali_gralloc_buffer.h
new file mode 100644
index 00000000..959653f0
--- /dev/null
+++ b/gralloc960/mali_gralloc_buffer.h
@@ -0,0 +1,267 @@
+/*
+ * Copyright (C) 2017 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef MALI_GRALLOC_BUFFER_H_
+#define MALI_GRALLOC_BUFFER_H_
+
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/ion.h>
+#include <sys/mman.h>
+
+#include "mali_gralloc_private_interface_types.h"
+
+/* NOTE:
+ * If your framebuffer device driver is integrated with dma_buf, you will have to
+ * change this IOCTL definition to reflect your integration with the framebuffer
+ * device.
+ * Expected return value is a structure filled with a file descriptor
+ * backing your framebuffer device memory.
+ */
+struct fb_dmabuf_export
+{
+ __u32 fd;
+ __u32 flags;
+};
+#define FBIOGET_DMABUF _IOR('F', 0x21, struct fb_dmabuf_export)
+
+/* the max string size of GRALLOC_HARDWARE_GPU0 & GRALLOC_HARDWARE_FB0
+ * 8 is big enough for "gpu0" & "fb0" currently
+ */
+#define MALI_GRALLOC_HARDWARE_MAX_STR_LEN 8
+#define NUM_FB_BUFFERS 2
+
+/* Define number of shared file descriptors */
+#define GRALLOC_ARM_NUM_FDS 2
+
+#define NUM_INTS_IN_PRIVATE_HANDLE ((sizeof(struct private_handle_t) - sizeof(native_handle)) / sizeof(int) - sNumFds)
+
+#define SZ_4K 0x00001000
+#define SZ_2M 0x00200000
+
+struct private_handle_t;
+
+#ifndef __cplusplus
+/* C99 with pedantic don't allow anonymous unions which is used in below struct
+ * Disable pedantic for C for this struct only.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+
+#ifdef __cplusplus
+struct private_handle_t : public native_handle
+{
+#else
+struct private_handle_t
+{
+ struct native_handle nativeHandle;
+#endif
+
+#ifdef __cplusplus
+ /* Never intended to be used from C code */
+ enum
+ {
+ PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
+ PRIV_FLAGS_USES_ION_COMPOUND_HEAP = 0x00000002,
+ PRIV_FLAGS_USES_ION = 0x00000004,
+ PRIV_FLAGS_USES_ION_DMA_HEAP = 0x00000008
+ };
+
+ enum
+ {
+ LOCK_STATE_WRITE = 1 << 31,
+ LOCK_STATE_MAPPED = 1 << 30,
+ LOCK_STATE_READ_MASK = 0x3FFFFFFF
+ };
+#endif
+
+ /*
+ * Shared file descriptor for dma_buf sharing. This must be the first element in the
+ * structure so that binder knows where it is and can properly share it between
+ * processes.
+ * DO NOT MOVE THIS ELEMENT!
+ */
+ int share_fd;
+ int share_attr_fd;
+
+ // ints
+ int magic;
+ int req_format;
+ uint64_t internal_format;
+ int byte_stride;
+ int flags;
+ int size;
+ int width;
+ int height;
+ int internalWidth;
+ int internalHeight;
+ int stride;
+ union
+ {
+ void *base;
+ uint64_t padding;
+ };
+ uint64_t consumer_usage;
+ uint64_t producer_usage;
+ uint64_t backing_store_id;
+ int backing_store_size;
+ int writeOwner;
+ int allocating_pid;
+ int remote_pid;
+ int ref_count;
+ // locally mapped shared attribute area
+ union
+ {
+ void *attr_base;
+ uint64_t padding3;
+ };
+
+ mali_gralloc_yuv_info yuv_info;
+
+ // Following members is for framebuffer only
+ int fd;
+ union
+ {
+ off_t offset;
+ uint64_t padding4;
+ };
+
+ /*
+ * min_pgsz denotes minimum phys_page size used by this buffer.
+ * if buffer memory is physical contiguous set min_pgsz to buff->size
+ * if not sure buff's real phys_page size, you can use SZ_4K for safe.
+ */
+ int min_pgsz;
+#ifdef __cplusplus
+ /*
+ * We track the number of integers in the structure. There are 16 unconditional
+ * integers (magic - pid, yuv_info, fd and offset). Note that the fd element is
+ * considered an int not an fd because it is not intended to be used outside the
+ * surface flinger process. The GRALLOC_ARM_NUM_INTS variable is used to track the
+ * number of integers that are conditionally included. Similar considerations apply
+ * to the number of fds.
+ */
+ static const int sNumFds = GRALLOC_ARM_NUM_FDS;
+ static const int sMagic = 0x3141592;
+
+ private_handle_t(int _flags, int _size, void *_base, uint64_t _consumer_usage, uint64_t _producer_usage,
+ int fb_file, off_t fb_offset)
+ : share_fd(-1)
+ , share_attr_fd(-1)
+ , magic(sMagic)
+ , flags(_flags)
+ , size(_size)
+ , width(0)
+ , height(0)
+ , stride(0)
+ , base(_base)
+ , consumer_usage(_consumer_usage)
+ , producer_usage(_producer_usage)
+ , backing_store_id(0x0)
+ , backing_store_size(0)
+ , writeOwner(0)
+ , allocating_pid(getpid())
+ , remote_pid(-1)
+ , ref_count(1)
+ , attr_base(MAP_FAILED)
+ , yuv_info(MALI_YUV_NO_INFO)
+ , fd(fb_file)
+ , offset(fb_offset)
+ {
+ version = sizeof(native_handle);
+ numFds = sNumFds;
+ numInts = NUM_INTS_IN_PRIVATE_HANDLE;
+ }
+
+ private_handle_t(int _flags, int _size, int _min_pgsz, uint64_t _consumer_usage, uint64_t _producer_usage,
+ int _shared_fd, int _req_format, uint64_t _internal_format, int _byte_stride, int _width,
+ int _height, int _stride, int _internalWidth, int _internalHeight, int _backing_store_size)
+ : share_fd(_shared_fd)
+ , share_attr_fd(-1)
+ , magic(sMagic)
+ , req_format(_req_format)
+ , internal_format(_internal_format)
+ , byte_stride(_byte_stride)
+ , flags(_flags)
+ , size(_size)
+ , width(_width)
+ , height(_height)
+ , internalWidth(_internalWidth)
+ , internalHeight(_internalHeight)
+ , stride(_stride)
+ , base(NULL)
+ , consumer_usage(_consumer_usage)
+ , producer_usage(_producer_usage)
+ , backing_store_id(0x0)
+ , backing_store_size(_backing_store_size)
+ , writeOwner(0)
+ , allocating_pid(getpid())
+ , remote_pid(-1)
+ , ref_count(1)
+ , attr_base(MAP_FAILED)
+ , yuv_info(MALI_YUV_NO_INFO)
+ , fd(-1)
+ , offset(0)
+ , min_pgsz(_min_pgsz)
+ {
+ version = sizeof(native_handle);
+ numFds = sNumFds;
+ numInts = NUM_INTS_IN_PRIVATE_HANDLE;
+ }
+
+ ~private_handle_t()
+ {
+ magic = 0;
+ }
+
+ bool usesPhysicallyContiguousMemory()
+ {
+ return (flags & PRIV_FLAGS_FRAMEBUFFER) ? true : false;
+ }
+
+ static int validate(const native_handle *h)
+ {
+ const private_handle_t *hnd = (const private_handle_t *)h;
+
+ if (!h || h->version != sizeof(native_handle) || h->numInts != NUM_INTS_IN_PRIVATE_HANDLE ||
+ h->numFds != sNumFds || hnd->magic != sMagic)
+ {
+ return -EINVAL;
+ }
+
+ return 0;
+ }
+
+ static private_handle_t *dynamicCast(const native_handle *in)
+ {
+ if (validate(in) == 0)
+ {
+ return (private_handle_t *)in;
+ }
+
+ return NULL;
+ }
+#endif
+};
+#ifndef __cplusplus
+/* Restore previous diagnostic for pedantic */
+#pragma GCC diagnostic pop
+#endif
+
+#endif /* MALI_GRALLOC_BUFFER_H_ */
diff --git a/gralloc960/mali_gralloc_bufferaccess.cpp b/gralloc960/mali_gralloc_bufferaccess.cpp
new file mode 100644
index 00000000..ea772836
--- /dev/null
+++ b/gralloc960/mali_gralloc_bufferaccess.cpp
@@ -0,0 +1,414 @@
+/*
+ * Copyright (C) 2016-2017 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <errno.h>
+#include <inttypes.h>
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+
+#include "mali_gralloc_module.h"
+#include "mali_gralloc_private_interface_types.h"
+#include "mali_gralloc_buffer.h"
+#include "mali_gralloc_formats.h"
+#include "mali_gralloc_usages.h"
+#include "mali_gralloc_ion.h"
+#include "gralloc_helper.h"
+#include <sync/sync.h>
+
+int mali_gralloc_lock(const mali_gralloc_module *m, buffer_handle_t buffer, uint64_t usage, int l, int t, int w, int h,
+ void **vaddr)
+{
+ GRALLOC_UNUSED(m);
+ GRALLOC_UNUSED(l);
+ GRALLOC_UNUSED(t);
+ GRALLOC_UNUSED(w);
+ GRALLOC_UNUSED(h);
+
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ AERR("Locking invalid buffer %p, returning error", buffer);
+ return -EINVAL;
+ }
+
+ private_handle_t *hnd = (private_handle_t *)buffer;
+
+ if (hnd->req_format == HAL_PIXEL_FORMAT_YCbCr_420_888)
+ {
+ AERR("Buffers with format YCbCr_420_888 must be locked using (*lock_ycbcr)");
+ return -EINVAL;
+ }
+
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
+ {
+ hnd->writeOwner = usage & GRALLOC_USAGE_SW_WRITE_MASK;
+ }
+
+ if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
+ {
+ *vaddr = (void *)hnd->base;
+ }
+
+ return 0;
+}
+
+int mali_gralloc_lock_ycbcr(const mali_gralloc_module *m, buffer_handle_t buffer, uint64_t usage, int l, int t, int w,
+ int h, android_ycbcr *ycbcr)
+{
+ GRALLOC_UNUSED(m);
+ GRALLOC_UNUSED(l);
+ GRALLOC_UNUSED(t);
+ GRALLOC_UNUSED(w);
+ GRALLOC_UNUSED(h);
+
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ AERR("Locking invalid buffer %p, returning error", buffer);
+ return -EINVAL;
+ }
+
+ if (NULL == ycbcr)
+ {
+ return -EINVAL;
+ }
+
+ private_handle_t *hnd = (private_handle_t *)buffer;
+
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
+ {
+ hnd->writeOwner = usage & GRALLOC_USAGE_SW_WRITE_MASK;
+ }
+
+ if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK) &&
+ !(hnd->internal_format & MALI_GRALLOC_INTFMT_EXT_MASK))
+ {
+ char *base = (char *)hnd->base;
+ int y_stride = hnd->byte_stride;
+ /* Ensure height is aligned for subsampled chroma before calculating buffer parameters */
+ int adjusted_height = GRALLOC_ALIGN(hnd->height, 2);
+ int y_size = y_stride * adjusted_height;
+
+ int u_offset = 0;
+ int v_offset = 0;
+ int c_stride = 0;
+ int step = 0;
+
+ uint64_t base_format = hnd->internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
+
+ switch (base_format)
+ {
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
+ c_stride = y_stride;
+ /* Y plane, UV plane */
+ u_offset = y_size;
+ v_offset = y_size + 1;
+ step = 2;
+ break;
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV21:
+ c_stride = y_stride;
+ /* Y plane, UV plane */
+ v_offset = y_size;
+ u_offset = y_size + 1;
+ step = 2;
+ break;
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_YV12:
+ {
+ int c_size;
+
+ /* Stride alignment set to 16 as the SW access flags were set */
+ c_stride = GRALLOC_ALIGN(hnd->byte_stride / 2, 16);
+ c_size = c_stride * (adjusted_height / 2);
+ /* Y plane, V plane, U plane */
+ v_offset = y_size;
+ u_offset = y_size + c_size;
+ step = 1;
+ break;
+ }
+
+ default:
+ AERR("Can't lock buffer %p: wrong format %" PRIx64, hnd, hnd->internal_format);
+ return -EINVAL;
+ }
+
+ ycbcr->y = base;
+ ycbcr->cb = base + u_offset;
+ ycbcr->cr = base + v_offset;
+ ycbcr->ystride = y_stride;
+ ycbcr->cstride = c_stride;
+ ycbcr->chroma_step = step;
+ }
+ else
+ {
+ AERR("Don't support to lock buffer %p: with format %" PRIx64, hnd, hnd->internal_format);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+int mali_gralloc_unlock(const mali_gralloc_module *m, buffer_handle_t buffer)
+{
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ AERR("Unlocking invalid buffer %p, returning error", buffer);
+ return -EINVAL;
+ }
+
+ private_handle_t *hnd = (private_handle_t *)buffer;
+
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION && hnd->writeOwner)
+ {
+ mali_gralloc_ion_sync(m, hnd);
+ }
+
+ return 0;
+}
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+int mali_gralloc_get_num_flex_planes(const mali_gralloc_module *m, buffer_handle_t buffer, uint32_t *num_planes)
+{
+ GRALLOC_UNUSED(m);
+
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ AERR("Invalid buffer %p, returning error", buffer);
+ return -EINVAL;
+ }
+
+ if (NULL == num_planes)
+ {
+ return -EINVAL;
+ }
+
+ private_handle_t *hnd = (private_handle_t *)buffer;
+ uint64_t base_format = hnd->internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
+
+ switch (base_format)
+ {
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV21:
+ case MALI_GRALLOC_FORMAT_INTERNAL_YV12:
+ *num_planes = 3;
+ break;
+
+ default:
+ AERR("Can't get planes number of buffer %p: with format %" PRIx64, hnd, hnd->internal_format);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+#endif
+
+int mali_gralloc_lock_async(const mali_gralloc_module *m, buffer_handle_t buffer, uint64_t usage, int l, int t, int w,
+ int h, void **vaddr, int32_t fence_fd)
+{
+ if (fence_fd >= 0)
+ {
+ sync_wait(fence_fd, -1);
+ close(fence_fd);
+ }
+
+ return mali_gralloc_lock(m, buffer, usage, l, t, w, h, vaddr);
+}
+
+int mali_gralloc_lock_ycbcr_async(const mali_gralloc_module *m, buffer_handle_t buffer, uint64_t usage, int l, int t,
+ int w, int h, android_ycbcr *ycbcr, int32_t fence_fd)
+{
+ if (fence_fd >= 0)
+ {
+ sync_wait(fence_fd, -1);
+ close(fence_fd);
+ }
+
+ return mali_gralloc_lock_ycbcr(m, buffer, usage, l, t, w, h, ycbcr);
+}
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+
+int mali_gralloc_lock_flex_async(const mali_gralloc_module *m, buffer_handle_t buffer, uint64_t usage, int l, int t,
+ int w, int h, struct android_flex_layout *flex_layout, int32_t fence_fd)
+{
+ GRALLOC_UNUSED(m);
+ GRALLOC_UNUSED(l);
+ GRALLOC_UNUSED(t);
+ GRALLOC_UNUSED(w);
+ GRALLOC_UNUSED(h);
+
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ AERR("Locking invalid buffer %p, returning error", buffer);
+ return -EINVAL;
+ }
+
+ if (NULL == flex_layout)
+ {
+ return -EINVAL;
+ }
+
+ if (fence_fd >= 0)
+ {
+ sync_wait(fence_fd, -1);
+ close(fence_fd);
+ }
+
+ private_handle_t *hnd = (private_handle_t *)buffer;
+
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
+ {
+ hnd->writeOwner = usage & GRALLOC_USAGE_SW_WRITE_MASK;
+ }
+
+ if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK) &&
+ !(hnd->internal_format & MALI_GRALLOC_INTFMT_EXT_MASK))
+ {
+ uint8_t *base = (uint8_t *)hnd->base;
+ int y_stride = hnd->byte_stride;
+ /* Ensure height is aligned for subsampled chroma before calculating buffer parameters */
+ int adjusted_height = GRALLOC_ALIGN(hnd->height, 2);
+ int y_size = y_stride * adjusted_height;
+
+ uint64_t base_format = hnd->internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
+
+ switch (base_format)
+ {
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
+ flex_layout->format = FLEX_FORMAT_YCbCr;
+ flex_layout->num_planes = 3;
+ flex_layout->planes[0].top_left = base;
+ flex_layout->planes[0].component = FLEX_COMPONENT_Y;
+ flex_layout->planes[0].bits_per_component = 8;
+ flex_layout->planes[0].bits_used = 8;
+ flex_layout->planes[0].h_increment = 1;
+ flex_layout->planes[0].v_increment = y_stride;
+ flex_layout->planes[0].h_subsampling = 1;
+ flex_layout->planes[0].v_subsampling = 1;
+ flex_layout->planes[1].top_left = base + y_size;
+ flex_layout->planes[1].component = FLEX_COMPONENT_Cb;
+ flex_layout->planes[1].bits_per_component = 8;
+ flex_layout->planes[1].bits_used = 8;
+ flex_layout->planes[1].h_increment = 2;
+ flex_layout->planes[1].v_increment = y_stride;
+ flex_layout->planes[1].h_subsampling = 2;
+ flex_layout->planes[1].v_subsampling = 2;
+ flex_layout->planes[2].top_left = flex_layout->planes[1].top_left + 1;
+ flex_layout->planes[2].component = FLEX_COMPONENT_Cr;
+ flex_layout->planes[2].bits_per_component = 8;
+ flex_layout->planes[2].bits_used = 8;
+ flex_layout->planes[2].h_increment = 2;
+ flex_layout->planes[2].v_increment = y_stride;
+ flex_layout->planes[2].h_subsampling = 2;
+ flex_layout->planes[2].v_subsampling = 2;
+ break;
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV21:
+ flex_layout->format = FLEX_FORMAT_YCbCr;
+ flex_layout->num_planes = 3;
+ flex_layout->planes[0].top_left = base;
+ flex_layout->planes[0].component = FLEX_COMPONENT_Y;
+ flex_layout->planes[0].bits_per_component = 8;
+ flex_layout->planes[0].bits_used = 8;
+ flex_layout->planes[0].h_increment = 1;
+ flex_layout->planes[0].v_increment = y_stride;
+ flex_layout->planes[0].h_subsampling = 1;
+ flex_layout->planes[0].v_subsampling = 1;
+ flex_layout->planes[1].top_left = base + y_size;
+ flex_layout->planes[1].component = FLEX_COMPONENT_Cr;
+ flex_layout->planes[1].bits_per_component = 8;
+ flex_layout->planes[1].bits_used = 8;
+ flex_layout->planes[1].h_increment = 2;
+ flex_layout->planes[1].v_increment = y_stride;
+ flex_layout->planes[1].h_subsampling = 2;
+ flex_layout->planes[1].v_subsampling = 2;
+ flex_layout->planes[2].top_left = flex_layout->planes[1].top_left + 1;
+ flex_layout->planes[2].component = FLEX_COMPONENT_Cb;
+ flex_layout->planes[2].bits_per_component = 8;
+ flex_layout->planes[2].bits_used = 8;
+ flex_layout->planes[2].h_increment = 2;
+ flex_layout->planes[2].v_increment = y_stride;
+ flex_layout->planes[2].h_subsampling = 2;
+ flex_layout->planes[2].v_subsampling = 2;
+ break;
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_YV12:
+ {
+ int c_size;
+ int c_stride;
+ /* Stride alignment set to 16 as the SW access flags were set */
+ c_stride = GRALLOC_ALIGN(hnd->byte_stride / 2, 16);
+ c_size = c_stride * (adjusted_height / 2);
+ /* Y plane, V plane, U plane */
+ flex_layout->format = FLEX_FORMAT_YCbCr;
+ flex_layout->num_planes = 3;
+ flex_layout->planes[0].top_left = base;
+ flex_layout->planes[0].component = FLEX_COMPONENT_Y;
+ flex_layout->planes[0].bits_per_component = 8;
+ flex_layout->planes[0].bits_used = 8;
+ flex_layout->planes[0].h_increment = 1;
+ flex_layout->planes[0].v_increment = y_stride;
+ flex_layout->planes[0].h_subsampling = 1;
+ flex_layout->planes[0].v_subsampling = 1;
+ flex_layout->planes[1].top_left = base + y_size;
+ flex_layout->planes[1].component = FLEX_COMPONENT_Cr;
+ flex_layout->planes[1].bits_per_component = 8;
+ flex_layout->planes[1].bits_used = 8;
+ flex_layout->planes[1].h_increment = 1;
+ flex_layout->planes[1].v_increment = c_stride;
+ flex_layout->planes[1].h_subsampling = 2;
+ flex_layout->planes[1].v_subsampling = 2;
+ flex_layout->planes[2].top_left = flex_layout->planes[1].top_left + c_size;
+ flex_layout->planes[2].component = FLEX_COMPONENT_Cb;
+ flex_layout->planes[2].bits_per_component = 8;
+ flex_layout->planes[2].bits_used = 8;
+ flex_layout->planes[2].h_increment = 1;
+ flex_layout->planes[2].v_increment = c_stride;
+ flex_layout->planes[2].h_subsampling = 2;
+ flex_layout->planes[2].v_subsampling = 2;
+ break;
+ }
+
+ default:
+ AERR("Can't lock buffer %p: wrong format %" PRIx64, hnd, hnd->internal_format);
+ return -EINVAL;
+ }
+ }
+ else
+ {
+ AERR("Don't support to lock buffer %p: with format %" PRIx64, hnd, hnd->internal_format);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+#endif
+
+int mali_gralloc_unlock_async(const mali_gralloc_module *m, buffer_handle_t buffer, int32_t *fence_fd)
+{
+ *fence_fd = -1;
+
+ if (mali_gralloc_unlock(m, buffer) < 0)
+ {
+ return -EINVAL;
+ }
+
+ return 0;
+}
diff --git a/gralloc960/mali_gralloc_bufferaccess.h b/gralloc960/mali_gralloc_bufferaccess.h
new file mode 100644
index 00000000..28e09596
--- /dev/null
+++ b/gralloc960/mali_gralloc_bufferaccess.h
@@ -0,0 +1,40 @@
+
+/*
+ * Copyright (C) 2016-2017 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef MALI_GRALLOC_BUFFERACCESS_H_
+#define MALI_GRALLOC_BUFFERACCESS_H_
+
+#include "gralloc_priv.h"
+#include "mali_gralloc_module.h"
+
+int mali_gralloc_lock(const mali_gralloc_module *m, buffer_handle_t buffer, uint64_t usage, int l, int t, int w, int h,
+ void **vaddr);
+int mali_gralloc_lock_ycbcr(const mali_gralloc_module *m, buffer_handle_t buffer, uint64_t usage, int l, int t, int w,
+ int h, android_ycbcr *ycbcr);
+int mali_gralloc_unlock(const mali_gralloc_module *m, buffer_handle_t buffer);
+
+int mali_gralloc_get_num_flex_planes(const mali_gralloc_module *m, buffer_handle_t buffer, uint32_t *num_planes);
+int mali_gralloc_lock_async(const mali_gralloc_module *m, buffer_handle_t buffer, uint64_t usage, int l, int t, int w,
+ int h, void **vaddr, int32_t fence_fd);
+int mali_gralloc_lock_ycbcr_async(const mali_gralloc_module *m, buffer_handle_t buffer, uint64_t usage, int l, int t,
+ int w, int h, android_ycbcr *ycbcr, int32_t fence_fd);
+int mali_gralloc_lock_flex_async(const mali_gralloc_module *m, buffer_handle_t buffer, uint64_t usage, int l, int t,
+ int w, int h, struct android_flex_layout *flex_layout, int32_t fence_fd);
+int mali_gralloc_unlock_async(const mali_gralloc_module *m, buffer_handle_t buffer, int32_t *fence_fd);
+
+#endif /* MALI_GRALLOC_BUFFERACCESS_H_ */
diff --git a/gralloc960/alloc_device.cpp b/gralloc960/mali_gralloc_bufferallocation.cpp
index 9a3ff8ca..0efc64ed 100644
--- a/gralloc960/alloc_device.cpp
+++ b/gralloc960/mali_gralloc_bufferallocation.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 ARM Limited. All rights reserved.
+ * Copyright (C) 2016-2017 ARM Limited. All rights reserved.
*
* Copyright (C) 2008 The Android Open Source Project
*
@@ -16,42 +16,40 @@
* limitations under the License.
*/
-#include <string.h>
-#include <errno.h>
-#include <pthread.h>
-
-#include <cutils/log.h>
-#include <cutils/atomic.h>
#include <hardware/hardware.h>
-#include <hardware/gralloc.h>
+#include <inttypes.h>
+#include <atomic>
-#include <sys/ioctl.h>
-
-#include "alloc_device.h"
-#include "gralloc_priv.h"
-#include "gralloc_helper.h"
-#include "framebuffer_device.h"
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
-#include "alloc_device_allocator_specific.h"
+#include "mali_gralloc_module.h"
+#include "mali_gralloc_bufferallocation.h"
+#include "mali_gralloc_ion.h"
+#include "mali_gralloc_private_interface_types.h"
+#include "mali_gralloc_buffer.h"
#include "gralloc_buffer_priv.h"
+#include "mali_gralloc_bufferdescriptor.h"
+#include "mali_gralloc_debug.h"
-#include "mali_gralloc_formats.h"
-
-#define AFBC_PIXELS_PER_BLOCK 16
-#define AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY 16
+#define AFBC_PIXELS_PER_BLOCK 16
+#define AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY 16
-#define AFBC_BODY_BUFFER_BYTE_ALIGNMENT 1024
-#define AFBC_NORMAL_WIDTH_ALIGN 16
-#define AFBC_NORMAL_HEIGHT_ALIGN 16
-#define AFBC_WIDEBLK_WIDTH_ALIGN 32
-#define AFBC_WIDEBLK_HEIGHT_ALIGN 16
+#define AFBC_BODY_BUFFER_BYTE_ALIGNMENT 1024
+#define AFBC_NORMAL_WIDTH_ALIGN 16
+#define AFBC_NORMAL_HEIGHT_ALIGN 16
+#define AFBC_WIDEBLK_WIDTH_ALIGN 32
+#define AFBC_WIDEBLK_HEIGHT_ALIGN 16
// Regarding Tiled Headers AFBC mode, both header and body buffer should aligned to 4KB
// and in non-wide mode (16x16), the width and height should be both rounded up to 128
// in wide mode (32x8) the width should be rounded up to 256, the height should be rounded up to 64
-#define AFBC_TILED_HEADERS_BASIC_WIDTH_ALIGN 128
-#define AFBC_TILED_HEADERS_BASIC_HEIGHT_ALIGN 128
-#define AFBC_TILED_HEADERS_WIDEBLK_WIDTH_ALIGN 256
-#define AFBC_TILED_HEADERS_WIDEBLK_HEIGHT_ALIGN 64
+#define AFBC_TILED_HEADERS_BASIC_WIDTH_ALIGN 128
+#define AFBC_TILED_HEADERS_BASIC_HEIGHT_ALIGN 128
+#define AFBC_TILED_HEADERS_WIDEBLK_WIDTH_ALIGN 256
+#define AFBC_TILED_HEADERS_WIDEBLK_HEIGHT_ALIGN 64
// This value is platform specific and should be set according to hardware YUV planes restrictions.
// Please note that EGL winsys platform config file needs to use the same value when importing buffers.
@@ -60,94 +58,6 @@
// Default YUV stride aligment in Android
#define YUV_ANDROID_PLANE_ALIGN 16
-static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle, int* stride, int* byte_stride)
-{
- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
-
- // allocate the framebuffer
- if (m->framebuffer == NULL)
- {
- // initialize the framebuffer, the framebuffer is mapped once and forever.
- int err = init_frame_buffer_locked(m);
- if (err < 0)
- {
- return err;
- }
- }
-
- const uint32_t bufferMask = m->bufferMask;
- const uint32_t numBuffers = m->numBuffers;
- /* framebufferSize is used for allocating the handle to the framebuffer and refers
- * to the size of the actual framebuffer.
- * alignedFramebufferSize is used for allocating a possible internal buffer and
- * thus need to consider internal alignment requirements. */
- const size_t framebufferSize = m->finfo.line_length * m->info.yres;
- const size_t alignedFramebufferSize = GRALLOC_ALIGN(m->finfo.line_length, 64) * m->info.yres;
-
- *stride = m->info.xres;
-
- if (numBuffers == 1)
- {
- // If we have only one buffer, we never use page-flipping. Instead,
- // we return a regular buffer which will be memcpy'ed to the main
- // screen when post is called.
- int newUsage = (usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D;
- AWAR( "fallback to single buffering. Virtual Y-res too small %d", m->info.yres );
- *byte_stride = GRALLOC_ALIGN(m->finfo.line_length, 64);
- return alloc_backend_alloc(dev, alignedFramebufferSize, newUsage, pHandle, 0, 0, 0);
- }
-
- if (bufferMask >= ((1LU<<numBuffers)-1))
- {
- // We ran out of buffers.
- return -ENOMEM;
- }
-
- uintptr_t framebufferVaddr = (uintptr_t)m->framebuffer->base;
- // find a free slot
- for (uint32_t i=0 ; i<numBuffers ; i++)
- {
- if ((bufferMask & (1LU<<i)) == 0)
- {
- m->bufferMask |= (1LU<<i);
- break;
- }
- framebufferVaddr += framebufferSize;
- }
-
- // The entire framebuffer memory is already mapped, now create a buffer object for parts of this memory
- private_handle_t* hnd = new private_handle_t(private_handle_t::PRIV_FLAGS_FRAMEBUFFER, usage, size,
- (void*)framebufferVaddr, 0, m->framebuffer->shallow_fbdev_fd,
- (framebufferVaddr - (uintptr_t)m->framebuffer->base));
-
- /*
- * Perform allocator specific actions. If these fail we fall back to a regular buffer
- * which will be memcpy'ed to the main screen when fb_post is called.
- */
- if (alloc_backend_alloc_framebuffer(m, hnd) == -1)
- {
- delete hnd;
- int newUsage = (usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D;
- AERR( "Fallback to single buffering. Unable to map framebuffer memory to handle:%p", hnd );
- *byte_stride = GRALLOC_ALIGN(m->finfo.line_length, 64);
- return alloc_backend_alloc(dev, alignedFramebufferSize, newUsage, pHandle, 0, 0, 0);
- }
-
- *pHandle = hnd;
- *byte_stride = m->finfo.line_length;
-
- return 0;
-}
-
-static int gralloc_alloc_framebuffer(alloc_device_t* dev, size_t size, int usage, buffer_handle_t* pHandle, int* stride, int* byte_stride)
-{
- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
- pthread_mutex_lock(&m->lock);
- int err = gralloc_alloc_framebuffer_locked(dev, size, usage, pHandle, stride, byte_stride);
- pthread_mutex_unlock(&m->lock);
- return err;
-}
-
/*
* Type of allocation
*/
@@ -166,6 +76,18 @@ enum AllocType
AFBC_TILED_HEADERS_WIDEBLK,
};
+static int mali_gralloc_buffer_free_internal(buffer_handle_t *pHandle, uint32_t num_hnds);
+
+/*
+ * Get a global unique ID
+ */
+static uint64_t getUniqueId()
+{
+ static std::atomic<uint32_t> counter(0);
+ uint64_t id = static_cast<uint64_t>(getpid()) << 32;
+ return id | counter++;
+}
+
/*
* Computes the strides and size for an RGB buffer
*
@@ -178,8 +100,8 @@ enum AllocType
* size (out) size of the buffer in bytes
* type (in) if buffer should be allocated for afbc
*/
-static void get_rgb_stride_and_size(int width, int height, int pixel_size,
- int* pixel_stride, int* byte_stride, size_t* size, AllocType type)
+static void get_rgb_stride_and_size(int width, int height, int pixel_size, int *pixel_stride, int *byte_stride,
+ size_t *size, AllocType type)
{
int stride;
@@ -191,7 +113,7 @@ static void get_rgb_stride_and_size(int width, int height, int pixel_size,
if (size != NULL)
{
- *size = stride * height;
+ *size = stride *height;
}
if (byte_stride != NULL)
@@ -207,42 +129,55 @@ static void get_rgb_stride_and_size(int width, int height, int pixel_size,
if (type != UNCOMPRESSED)
{
int w_aligned;
- int h_aligned = GRALLOC_ALIGN( height, AFBC_NORMAL_HEIGHT_ALIGN );
+ int h_aligned = GRALLOC_ALIGN(height, AFBC_NORMAL_HEIGHT_ALIGN);
int nblocks;
int buffer_byte_alignment = AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
if (type == AFBC_TILED_HEADERS_BASIC)
{
- w_aligned = GRALLOC_ALIGN( width, AFBC_TILED_HEADERS_BASIC_WIDTH_ALIGN );
- h_aligned = GRALLOC_ALIGN( height, AFBC_TILED_HEADERS_BASIC_HEIGHT_ALIGN );
+ w_aligned = GRALLOC_ALIGN(width, AFBC_TILED_HEADERS_BASIC_WIDTH_ALIGN);
+ h_aligned = GRALLOC_ALIGN(height, AFBC_TILED_HEADERS_BASIC_HEIGHT_ALIGN);
buffer_byte_alignment = 4 * AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
}
else if (type == AFBC_TILED_HEADERS_WIDEBLK)
{
- w_aligned = GRALLOC_ALIGN( width, AFBC_TILED_HEADERS_WIDEBLK_WIDTH_ALIGN );
- h_aligned = GRALLOC_ALIGN( height, AFBC_TILED_HEADERS_WIDEBLK_HEIGHT_ALIGN );
+ w_aligned = GRALLOC_ALIGN(width, AFBC_TILED_HEADERS_WIDEBLK_WIDTH_ALIGN);
+ h_aligned = GRALLOC_ALIGN(height, AFBC_TILED_HEADERS_WIDEBLK_HEIGHT_ALIGN);
buffer_byte_alignment = 4 * AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
}
else if (type == AFBC_PADDED)
{
- w_aligned = GRALLOC_ALIGN( width, 64 );
+ w_aligned = GRALLOC_ALIGN(width, 64);
}
else if (type == AFBC_WIDEBLK)
{
- w_aligned = GRALLOC_ALIGN( width, AFBC_WIDEBLK_WIDTH_ALIGN );
- h_aligned = GRALLOC_ALIGN( height, AFBC_WIDEBLK_HEIGHT_ALIGN );
+ w_aligned = GRALLOC_ALIGN(width, AFBC_WIDEBLK_WIDTH_ALIGN);
+ h_aligned = GRALLOC_ALIGN(height, AFBC_WIDEBLK_HEIGHT_ALIGN);
}
else
{
- w_aligned = GRALLOC_ALIGN( width, AFBC_NORMAL_WIDTH_ALIGN );
+ w_aligned = GRALLOC_ALIGN(width, AFBC_NORMAL_WIDTH_ALIGN);
+ }
+
+ stride = w_aligned * pixel_size;
+ stride = GRALLOC_ALIGN(stride, 64);
+
+ if (byte_stride != NULL)
+ {
+ *byte_stride = stride;
+ }
+
+ if (pixel_stride != NULL)
+ {
+ *pixel_stride = stride / pixel_size;
}
nblocks = w_aligned / AFBC_PIXELS_PER_BLOCK * h_aligned / AFBC_PIXELS_PER_BLOCK;
- if ( size != NULL )
+ if (size != NULL)
{
- *size = w_aligned * h_aligned * pixel_size +
- GRALLOC_ALIGN( nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, buffer_byte_alignment );
+ *size = stride *h_aligned +
+ GRALLOC_ALIGN(nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, buffer_byte_alignment);
}
}
}
@@ -259,8 +194,8 @@ static void get_rgb_stride_and_size(int width, int height, int pixel_size,
* type if buffer should be allocated for a certain afbc type
* internalHeight (out) The internal height, which may be greater than the public known height.
*/
-static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride,
- size_t* size, AllocType type, int *internalHeight)
+static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int *pixel_stride, int *byte_stride,
+ size_t *size, AllocType type, int *internalHeight)
{
int yuv420_afbc_luma_stride, yuv420_afbc_chroma_stride;
int buffer_byte_alignment = AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
@@ -288,14 +223,14 @@ static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pix
}
else if (type == AFBC_TILED_HEADERS_BASIC)
{
- width = GRALLOC_ALIGN( width, AFBC_TILED_HEADERS_BASIC_WIDTH_ALIGN );
- height = GRALLOC_ALIGN( *internalHeight, AFBC_TILED_HEADERS_BASIC_HEIGHT_ALIGN );
+ width = GRALLOC_ALIGN(width, AFBC_TILED_HEADERS_BASIC_WIDTH_ALIGN);
+ height = GRALLOC_ALIGN(*internalHeight, AFBC_TILED_HEADERS_BASIC_HEIGHT_ALIGN);
buffer_byte_alignment = 4 * AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
}
else if (type == AFBC_TILED_HEADERS_WIDEBLK)
{
- width = GRALLOC_ALIGN( width, AFBC_TILED_HEADERS_WIDEBLK_WIDTH_ALIGN );
- height = GRALLOC_ALIGN( *internalHeight, AFBC_TILED_HEADERS_WIDEBLK_HEIGHT_ALIGN );
+ width = GRALLOC_ALIGN(width, AFBC_TILED_HEADERS_WIDEBLK_WIDTH_ALIGN);
+ height = GRALLOC_ALIGN(*internalHeight, AFBC_TILED_HEADERS_WIDEBLK_HEIGHT_ALIGN);
buffer_byte_alignment = 4 * AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
}
else if (type == AFBC_PADDED)
@@ -306,12 +241,12 @@ static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pix
else if (type == AFBC_WIDEBLK)
{
width = GRALLOC_ALIGN(width, AFBC_WIDEBLK_WIDTH_ALIGN);
- height = GRALLOC_ALIGN( *internalHeight, AFBC_WIDEBLK_HEIGHT_ALIGN );
+ height = GRALLOC_ALIGN(*internalHeight, AFBC_WIDEBLK_HEIGHT_ALIGN);
}
else
{
width = GRALLOC_ALIGN(width, AFBC_NORMAL_WIDTH_ALIGN);
- height = GRALLOC_ALIGN( *internalHeight, AFBC_NORMAL_HEIGHT_ALIGN );
+ height = GRALLOC_ALIGN(*internalHeight, AFBC_NORMAL_HEIGHT_ALIGN);
}
yuv420_afbc_luma_stride = width;
@@ -321,9 +256,8 @@ static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pix
{
int nblocks = width / AFBC_PIXELS_PER_BLOCK * height / AFBC_PIXELS_PER_BLOCK;
/* Simplification of (height * luma-stride + 2 * (height /2 * chroma_stride) */
- *size =
- ( yuv420_afbc_luma_stride + yuv420_afbc_chroma_stride ) * height +
- GRALLOC_ALIGN( nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, buffer_byte_alignment );
+ *size = (yuv420_afbc_luma_stride + yuv420_afbc_chroma_stride) * height +
+ GRALLOC_ALIGN(nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, buffer_byte_alignment);
}
if (byte_stride != NULL)
@@ -352,14 +286,15 @@ static bool get_afbc_yuv420_8bit_stride_and_size(int width, int height, int* pix
* internalHeight (out) The internal height, which may be greater than the public known height.
* stride_alignment (in) stride aligment value in bytes.
*/
-static bool get_yv12_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size,
- AllocType type, int* internalHeight, int stride_alignment)
+static bool get_yv12_stride_and_size(int width, int height, int *pixel_stride, int *byte_stride, size_t *size,
+ AllocType type, int *internalHeight, int stride_alignment)
{
int luma_stride;
if (type != UNCOMPRESSED)
{
- return get_afbc_yuv420_8bit_stride_and_size(width, height, pixel_stride, byte_stride, size, type, internalHeight);
+ return get_afbc_yuv420_8bit_stride_and_size(width, height, pixel_stride, byte_stride, size, type,
+ internalHeight);
}
/* 4:2:0 formats must have buffers with even height and width as the clump size is 2x2 pixels.
@@ -372,7 +307,7 @@ static bool get_yv12_stride_and_size(int width, int height, int* pixel_stride, i
{
int chroma_stride = GRALLOC_ALIGN(luma_stride / 2, stride_alignment);
/* Simplification of ((height * luma_stride ) + 2 * ((height / 2) * chroma_stride)). */
- *size = height * (luma_stride + chroma_stride);
+ *size = height *(luma_stride + chroma_stride);
}
if (byte_stride != NULL)
@@ -387,6 +322,7 @@ static bool get_yv12_stride_and_size(int width, int height, int* pixel_stride, i
return true;
}
+
/*
* Computes the strides and size for an 8 bit YUYV 422 buffer
*
@@ -397,7 +333,7 @@ static bool get_yv12_stride_and_size(int width, int height, int* pixel_stride, i
* byte_stride (out) stride of the buffer in bytes
* size (out) size of the buffer in bytes
*/
-static bool get_yuv422_8bit_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size)
+static bool get_yuv422_8bit_stride_and_size(int width, int height, int *pixel_stride, int *byte_stride, size_t *size)
{
int local_byte_stride, local_pixel_stride;
@@ -405,11 +341,11 @@ static bool get_yuv422_8bit_stride_and_size(int width, int height, int* pixel_st
* This is taken care of by the even stride alignment. */
local_pixel_stride = GRALLOC_ALIGN(width, YUV_MALI_PLANE_ALIGN);
- local_byte_stride = GRALLOC_ALIGN(width * 2, YUV_MALI_PLANE_ALIGN); /* 4 bytes per 2 pixels */
+ local_byte_stride = GRALLOC_ALIGN(width * 2, YUV_MALI_PLANE_ALIGN); /* 4 bytes per 2 pixels */
if (size != NULL)
{
- *size = local_byte_stride * height;
+ *size = local_byte_stride *height;
}
if (byte_stride != NULL)
@@ -436,7 +372,8 @@ static bool get_yuv422_8bit_stride_and_size(int width, int height, int* pixel_st
* size (out) size of the buffer in bytes
* type if buffer should be allocated for a certain afbc type
*/
-static bool get_afbc_yuv422_8bit_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size, AllocType type)
+static bool get_afbc_yuv422_8bit_stride_and_size(int width, int height, int *pixel_stride, int *byte_stride,
+ size_t *size, AllocType type)
{
int yuv422_afbc_luma_stride;
int buffer_byte_alignment = AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
@@ -480,8 +417,8 @@ static bool get_afbc_yuv422_8bit_stride_and_size(int width, int height, int* pix
{
int nblocks = width / AFBC_PIXELS_PER_BLOCK * height / AFBC_PIXELS_PER_BLOCK;
/* YUV 4:2:2 luma size equals chroma size */
- *size = yuv422_afbc_luma_stride * height * 2
- + GRALLOC_ALIGN(nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, buffer_byte_alignment);
+ *size = yuv422_afbc_luma_stride *height * 2 +
+ GRALLOC_ALIGN(nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, buffer_byte_alignment);
}
if (byte_stride != NULL)
@@ -514,7 +451,8 @@ static bool get_afbc_yuv422_8bit_stride_and_size(int width, int height, int* pix
* @return true if the calculation was successful; false otherwise (invalid
* parameter)
*/
-static bool get_yuv_pX10_stride_and_size(int width, int height, int vss, int* pixel_stride, int* byte_stride, size_t* size)
+static bool get_yuv_pX10_stride_and_size(int width, int height, int vss, int *pixel_stride, int *byte_stride,
+ size_t *size)
{
int luma_pixel_stride, luma_byte_stride;
@@ -533,12 +471,12 @@ static bool get_yuv_pX10_stride_and_size(int width, int height, int vss, int* pi
}
luma_pixel_stride = GRALLOC_ALIGN(width, YUV_MALI_PLANE_ALIGN);
- luma_byte_stride = GRALLOC_ALIGN(width * 2, YUV_MALI_PLANE_ALIGN);
+ luma_byte_stride = GRALLOC_ALIGN(width * 2, YUV_MALI_PLANE_ALIGN);
if (size != NULL)
{
int chroma_size = GRALLOC_ALIGN(width * 2, YUV_MALI_PLANE_ALIGN) * (height / vss);
- *size = luma_byte_stride * height + chroma_size;
+ *size = luma_byte_stride *height + chroma_size;
}
if (byte_stride != NULL)
@@ -569,7 +507,7 @@ static bool get_yuv_pX10_stride_and_size(int width, int height, int vss, int* pi
* @return true if the calculation was successful; false otherwise (invalid
* parameter)
*/
-static bool get_yuv_y210_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size)
+static bool get_yuv_y210_stride_and_size(int width, int height, int *pixel_stride, int *byte_stride, size_t *size)
{
int y210_byte_stride, y210_pixel_stride;
@@ -578,11 +516,11 @@ static bool get_yuv_y210_stride_and_size(int width, int height, int* pixel_strid
y210_pixel_stride = GRALLOC_ALIGN(width, YUV_MALI_PLANE_ALIGN);
/* 4x16 bits per 2 pixels */
- y210_byte_stride = GRALLOC_ALIGN(width * 4, YUV_MALI_PLANE_ALIGN);
+ y210_byte_stride = GRALLOC_ALIGN(width * 4, YUV_MALI_PLANE_ALIGN);
if (size != NULL)
{
- *size = y210_byte_stride * height;
+ *size = y210_byte_stride *height;
}
if (byte_stride != NULL)
@@ -616,7 +554,7 @@ static bool get_yuv_y210_stride_and_size(int width, int height, int* pixel_strid
* @note Each YUYAAYVYAA clump encodes a 2x2 area of pixels. YU&V are 10 bits. A is 1 bit. total 8 bytes
*
*/
-static bool get_yuv_y0l2_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size)
+static bool get_yuv_y0l2_stride_and_size(int width, int height, int *pixel_stride, int *byte_stride, size_t *size)
{
int y0l2_byte_stride, y0l2_pixel_stride;
@@ -625,11 +563,11 @@ static bool get_yuv_y0l2_stride_and_size(int width, int height, int* pixel_strid
height = GRALLOC_ALIGN(height, 2);
y0l2_pixel_stride = GRALLOC_ALIGN(width, YUV_MALI_PLANE_ALIGN);
- y0l2_byte_stride = GRALLOC_ALIGN(width * 4, YUV_MALI_PLANE_ALIGN); /* 2 horiz pixels per 8 byte clump */
+ y0l2_byte_stride = GRALLOC_ALIGN(width * 4, YUV_MALI_PLANE_ALIGN); /* 2 horiz pixels per 8 byte clump */
if (size != NULL)
{
- *size = y0l2_byte_stride * height / 2; /* byte stride covers 2 vert pixels */
+ *size = y0l2_byte_stride *height / 2; /* byte stride covers 2 vert pixels */
}
if (byte_stride != NULL)
@@ -641,8 +579,10 @@ static bool get_yuv_y0l2_stride_and_size(int width, int height, int* pixel_strid
{
*pixel_stride = y0l2_pixel_stride;
}
+
return true;
}
+
/*
* Calculate strides and strides for Y410 (AVYU packed, 4:4:4) format buffer.
*
@@ -658,17 +598,17 @@ static bool get_yuv_y0l2_stride_and_size(int width, int height, int* pixel_strid
* @return true if the calculation was successful; false otherwise (invalid
* parameter)
*/
-static bool get_yuv_y410_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size)
+static bool get_yuv_y410_stride_and_size(int width, int height, int *pixel_stride, int *byte_stride, size_t *size)
{
int y410_byte_stride, y410_pixel_stride;
y410_pixel_stride = GRALLOC_ALIGN(width, YUV_MALI_PLANE_ALIGN);
- y410_byte_stride = GRALLOC_ALIGN(width * 4, YUV_MALI_PLANE_ALIGN);
+ y410_byte_stride = GRALLOC_ALIGN(width * 4, YUV_MALI_PLANE_ALIGN);
if (size != NULL)
{
/* 4x8bits per pixel */
- *size = y410_byte_stride * height;
+ *size = y410_byte_stride *height;
}
if (byte_stride != NULL)
@@ -680,6 +620,7 @@ static bool get_yuv_y410_stride_and_size(int width, int height, int* pixel_strid
{
*pixel_stride = y410_pixel_stride;
}
+
return true;
}
@@ -701,7 +642,8 @@ static bool get_yuv_y410_stride_and_size(int width, int height, int* pixel_strid
* @return true if the calculation was successful; false otherwise (invalid
* parameter)
*/
-static bool get_yuv420_10bit_afbc_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size, AllocType type, int* internalHeight)
+static bool get_yuv420_10bit_afbc_stride_and_size(int width, int height, int *pixel_stride, int *byte_stride,
+ size_t *size, AllocType type, int *internalHeight)
{
int yuv420_afbc_byte_stride, yuv420_afbc_pixel_stride;
int buffer_byte_alignment = AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
@@ -711,12 +653,13 @@ static bool get_yuv420_10bit_afbc_stride_and_size(int width, int height, int* pi
return false;
}
- *internalHeight = height;
+ *internalHeight = height;
#if MALI_VIDEO_VERSION
/* If we have a greater internal height than public we set the internalHeight. This
* implies that cropping will be applied of internal dimensions to fit the public one. */
- *internalHeight += AFBC_PIXELS_PER_BLOCK;
+ *internalHeight += AFBC_PIXELS_PER_BLOCK;
#endif
+
/* The actual height used in size calculation must include the possible extra row. But
* it must also be AFBC-aligned. Only the extra row-padding should be reported back in
* internalHeight. This as only this row needs to be considered when cropping. */
@@ -728,13 +671,13 @@ static bool get_yuv420_10bit_afbc_stride_and_size(int width, int height, int* pi
else if (type == AFBC_TILED_HEADERS_BASIC)
{
width = GRALLOC_ALIGN(width, AFBC_TILED_HEADERS_BASIC_WIDTH_ALIGN);
- height = GRALLOC_ALIGN(*internalHeight/2, AFBC_TILED_HEADERS_BASIC_HEIGHT_ALIGN);
+ height = GRALLOC_ALIGN(*internalHeight / 2, AFBC_TILED_HEADERS_BASIC_HEIGHT_ALIGN);
buffer_byte_alignment = 4 * AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
}
else if (type == AFBC_TILED_HEADERS_WIDEBLK)
{
width = GRALLOC_ALIGN(width, AFBC_TILED_HEADERS_WIDEBLK_WIDTH_ALIGN);
- height = GRALLOC_ALIGN(*internalHeight/2, AFBC_TILED_HEADERS_WIDEBLK_HEIGHT_ALIGN);
+ height = GRALLOC_ALIGN(*internalHeight / 2, AFBC_TILED_HEADERS_WIDEBLK_HEIGHT_ALIGN);
buffer_byte_alignment = 4 * AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
}
else if (type == AFBC_PADDED)
@@ -745,22 +688,22 @@ static bool get_yuv420_10bit_afbc_stride_and_size(int width, int height, int* pi
else if (type == AFBC_WIDEBLK)
{
width = GRALLOC_ALIGN(width, AFBC_WIDEBLK_WIDTH_ALIGN);
- height = GRALLOC_ALIGN(*internalHeight/2, AFBC_WIDEBLK_HEIGHT_ALIGN);
+ height = GRALLOC_ALIGN(*internalHeight / 2, AFBC_WIDEBLK_HEIGHT_ALIGN);
}
else
{
width = GRALLOC_ALIGN(width, AFBC_NORMAL_WIDTH_ALIGN);
- height = GRALLOC_ALIGN(*internalHeight/2, AFBC_NORMAL_HEIGHT_ALIGN);
+ height = GRALLOC_ALIGN(*internalHeight / 2, AFBC_NORMAL_HEIGHT_ALIGN);
}
yuv420_afbc_pixel_stride = GRALLOC_ALIGN(width, 16);
- yuv420_afbc_byte_stride = GRALLOC_ALIGN(width * 4, 16); /* 64-bit packed and horizontally downsampled */
+ yuv420_afbc_byte_stride = GRALLOC_ALIGN(width * 4, 16); /* 64-bit packed and horizontally downsampled */
if (size != NULL)
{
int nblocks = width / AFBC_PIXELS_PER_BLOCK * (*internalHeight) / AFBC_PIXELS_PER_BLOCK;
- *size = yuv420_afbc_byte_stride * height
- + GRALLOC_ALIGN(nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, buffer_byte_alignment);
+ *size = yuv420_afbc_byte_stride *height +
+ GRALLOC_ALIGN(nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, buffer_byte_alignment);
}
if (byte_stride != NULL)
@@ -792,7 +735,8 @@ static bool get_yuv420_10bit_afbc_stride_and_size(int width, int height, int* pi
* @return true if the calculation was successful; false otherwise (invalid
* parameter)
*/
-static bool get_yuv422_10bit_afbc_stride_and_size(int width, int height, int* pixel_stride, int* byte_stride, size_t* size, AllocType type)
+static bool get_yuv422_10bit_afbc_stride_and_size(int width, int height, int *pixel_stride, int *byte_stride,
+ size_t *size, AllocType type)
{
int yuv422_afbc_byte_stride, yuv422_afbc_pixel_stride;
int buffer_byte_alignment = AFBC_BODY_BUFFER_BYTE_ALIGNMENT;
@@ -836,14 +780,14 @@ static bool get_yuv422_10bit_afbc_stride_and_size(int width, int height, int* pi
}
yuv422_afbc_pixel_stride = GRALLOC_ALIGN(width, 16);
- yuv422_afbc_byte_stride = GRALLOC_ALIGN(width * 2, 16);
+ yuv422_afbc_byte_stride = GRALLOC_ALIGN(width * 2, 16);
if (size != NULL)
{
int nblocks = width / AFBC_PIXELS_PER_BLOCK * height / AFBC_PIXELS_PER_BLOCK;
/* YUV 4:2:2 chroma size equals to luma size */
- *size = yuv422_afbc_byte_stride * height * 2
- + GRALLOC_ALIGN(nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, buffer_byte_alignment);
+ *size = yuv422_afbc_byte_stride *height * 2 +
+ GRALLOC_ALIGN(nblocks * AFBC_HEADER_BUFFER_BYTES_PER_BLOCKENTRY, buffer_byte_alignment);
}
if (byte_stride != NULL)
@@ -880,45 +824,47 @@ static bool get_camera_formats_stride_and_size(int w, int h, uint64_t format, in
switch (format)
{
- case HAL_PIXEL_FORMAT_RAW16:
- stride = w; /* Format assumes stride in pixels */
- stride = GRALLOC_ALIGN(stride, 16); /* Alignment mandated by Android */
- size = stride * h * 2; /* 2 bytes per pixel */
- break;
+ case HAL_PIXEL_FORMAT_RAW16:
+ stride = w; /* Format assumes stride in pixels */
+ stride = GRALLOC_ALIGN(stride, 16); /* Alignment mandated by Android */
+ size = stride * h * 2; /* 2 bytes per pixel */
+ break;
- case HAL_PIXEL_FORMAT_RAW12:
- if (w % 4 != 0)
- {
- ALOGE("ERROR: Width for HAL_PIXEL_FORMAT_RAW12 buffers has to be multiple of 4.");
- return false;
- }
- stride = (w / 2) * 3; /* Stride in bytes; 2 pixels in 3 bytes */
- size = stride * h;
- break;
+ case HAL_PIXEL_FORMAT_RAW12:
+ if (w % 4 != 0)
+ {
+ ALOGE("ERROR: Width for HAL_PIXEL_FORMAT_RAW12 buffers has to be multiple of 4.");
+ return false;
+ }
- case HAL_PIXEL_FORMAT_RAW10:
- if (w % 4 != 0)
- {
- ALOGE("ERROR: Width for HAL_PIXEL_FORMAT_RAW10 buffers has to be multiple of 4.");
- return false;
- }
- stride = (w / 4) * 5; /* Stride in bytes; 4 pixels in 5 bytes */
- size = stride * h;
- break;
+ stride = (w / 2) * 3; /* Stride in bytes; 2 pixels in 3 bytes */
+ size = stride * h;
+ break;
- case HAL_PIXEL_FORMAT_BLOB:
- if (h != 1)
- {
- ALOGE("ERROR: Height for HAL_PIXEL_FORMAT_BLOB must be 1.");
- return false;
- }
- stride = 0; /* No 'rows', it's effectively a long one dimensional array */
- size = w;
- break;
+ case HAL_PIXEL_FORMAT_RAW10:
+ if (w % 4 != 0)
+ {
+ ALOGE("ERROR: Width for HAL_PIXEL_FORMAT_RAW10 buffers has to be multiple of 4.");
+ return false;
+ }
- default:
+ stride = (w / 4) * 5; /* Stride in bytes; 4 pixels in 5 bytes */
+ size = stride * h;
+ break;
+
+ case HAL_PIXEL_FORMAT_BLOB:
+ if (h != 1)
+ {
+ ALOGE("ERROR: Height for HAL_PIXEL_FORMAT_BLOB must be 1.");
return false;
+ }
+
+ stride = 0; /* No 'rows', it's effectively a long one dimensional array */
+ size = w;
+ break;
+ default:
+ return false;
}
if (out_size != NULL)
@@ -934,91 +880,89 @@ static bool get_camera_formats_stride_and_size(int w, int h, uint64_t format, in
return true;
}
-static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int usage, buffer_handle_t* pHandle, int* pStride)
+int mali_gralloc_buffer_allocate(mali_gralloc_module *m, const gralloc_buffer_descriptor_t *descriptors,
+ uint32_t numDescriptors, buffer_handle_t *pHandle, bool *shared_backend)
{
+ bool shared = false;
+ uint64_t backing_store_id = 0x0;
+ AllocType alloc_type = UNCOMPRESSED;
+ uint64_t usage;
+ uint32_t i = 0;
+ int err;
- if (!pHandle || !pStride)
+ for (i = 0; i < numDescriptors; i++)
{
- return -EINVAL;
- }
-
- size_t size; // Size to be allocated for the buffer
- int byte_stride; // Stride of the buffer in bytes
- int pixel_stride; // Stride of the buffer in pixels - as returned in pStride
- uint64_t internal_format;
- AllocType type = UNCOMPRESSED;
- int internalWidth,internalHeight;
+ buffer_descriptor_t *bufDescriptor = (buffer_descriptor_t *)(descriptors[i]);
-#if GRALLOC_FB_SWAP_RED_BLUE == 1
- /* match the framebuffer format */
- if (usage & GRALLOC_USAGE_HW_FB)
- {
-#ifdef GRALLOC_16_BITS
- format = HAL_PIXEL_FORMAT_RGB_565;
-#else
- format = HAL_PIXEL_FORMAT_BGRA_8888;
-#endif
- }
-#endif
+ /* Some formats require an internal width and height that may be used by
+ * consumers/producers.
+ */
+ bufDescriptor->internalWidth = bufDescriptor->width;
+ bufDescriptor->internalHeight = bufDescriptor->height;
+ usage = bufDescriptor->producer_usage | bufDescriptor->consumer_usage;
- /* Some formats require an internal width and height that may be used by
- * consumers/producers.
- */
- internalWidth = w;
- internalHeight = h;
+ bufDescriptor->internal_format = mali_gralloc_select_format(
+ bufDescriptor->hal_format, bufDescriptor->format_type, usage, bufDescriptor->width * bufDescriptor->height);
- internal_format = mali_gralloc_select_format(format, usage, w*h);
- if(internal_format == 0)
- {
- ALOGE("Unrecognized and/or unsupported format(0x%08X) and usage(0x%08X).",format,usage);
- return -EINVAL;
- }
+ if (bufDescriptor->internal_format == 0)
+ {
+ ALOGE("Unrecognized and/or unsupported format 0x%" PRIx64 " and usage 0x%" PRIx64,
+ bufDescriptor->hal_format, usage);
+ return -EINVAL;
+ }
- if (internal_format & MALI_GRALLOC_INTFMT_AFBCENABLE_MASK)
- {
- if (internal_format & MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS)
+ /* Determine AFBC type for this format */
+ if (bufDescriptor->internal_format & MALI_GRALLOC_INTFMT_AFBCENABLE_MASK)
{
- if (internal_format & MALI_GRALLOC_INTFMT_AFBC_WIDEBLK)
+ if (bufDescriptor->internal_format & MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS)
{
- type = AFBC_TILED_HEADERS_WIDEBLK;
+ if (bufDescriptor->internal_format & MALI_GRALLOC_INTFMT_AFBC_WIDEBLK)
+ {
+ alloc_type = AFBC_TILED_HEADERS_WIDEBLK;
+ }
+ else if (bufDescriptor->internal_format & MALI_GRALLOC_INTFMT_AFBC_BASIC)
+ {
+ alloc_type = AFBC_TILED_HEADERS_BASIC;
+ }
+ else if (bufDescriptor->internal_format & MALI_GRALLOC_INTFMT_AFBC_SPLITBLK)
+ {
+ ALOGE("Unsupported format. Splitblk in tiled header configuration.");
+ return -EINVAL;
+ }
}
- else if (internal_format & MALI_GRALLOC_INTFMT_AFBC_BASIC)
+ else if (usage & MALI_GRALLOC_USAGE_AFBC_PADDING)
{
- type = AFBC_TILED_HEADERS_BASIC;
+ alloc_type = AFBC_PADDED;
}
- else if (internal_format & MALI_GRALLOC_INTFMT_AFBC_SPLITBLK)
+ else if (bufDescriptor->internal_format & MALI_GRALLOC_INTFMT_AFBC_WIDEBLK)
{
- ALOGE("Unsupported format. Splitblk in tiled header configuration.");
- return -EINVAL;
+ alloc_type = AFBC_WIDEBLK;
+ }
+ else
+ {
+ alloc_type = AFBC;
}
}
- else if (usage & MALI_GRALLOC_USAGE_AFBC_PADDING)
- {
- type = AFBC_PADDED;
- }
- else if (internal_format & MALI_GRALLOC_INTFMT_AFBC_WIDEBLK)
- {
- type = AFBC_WIDEBLK;
- }
- else
- {
- type = AFBC;
- }
- }
- uint64_t base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
- switch (base_format)
- {
+ uint64_t base_format = bufDescriptor->internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
+
+ switch (base_format)
+ {
case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_RGBX_8888:
case HAL_PIXEL_FORMAT_BGRA_8888:
- get_rgb_stride_and_size(w, h, 4, &pixel_stride, &byte_stride, &size, type );
+ get_rgb_stride_and_size(bufDescriptor->width, bufDescriptor->height, 4, &bufDescriptor->pixel_stride,
+ &bufDescriptor->byte_stride, &bufDescriptor->size, alloc_type);
break;
+
case HAL_PIXEL_FORMAT_RGB_888:
- get_rgb_stride_and_size(w, h, 3, &pixel_stride, &byte_stride, &size, type );
+ get_rgb_stride_and_size(bufDescriptor->width, bufDescriptor->height, 3, &bufDescriptor->pixel_stride,
+ &bufDescriptor->byte_stride, &bufDescriptor->size, alloc_type);
break;
+
case HAL_PIXEL_FORMAT_RGB_565:
- get_rgb_stride_and_size(w, h, 2, &pixel_stride, &byte_stride, &size, type );
+ get_rgb_stride_and_size(bufDescriptor->width, bufDescriptor->height, 2, &bufDescriptor->pixel_stride,
+ &bufDescriptor->byte_stride, &bufDescriptor->size, alloc_type);
break;
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
@@ -1030,249 +974,266 @@ static int alloc_device_alloc(alloc_device_t* dev, int w, int h, int format, int
* default of 16. We only need to care about YV12 as it's the only, implicit, HAL YUV format in Android.
*/
int yv12_align = YUV_MALI_PLANE_ALIGN;
- if(usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
+
+ if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
{
yv12_align = YUV_ANDROID_PLANE_ALIGN;
}
- if (!get_yv12_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type,
- &internalHeight, yv12_align))
+ if (!get_yv12_stride_and_size(bufDescriptor->width, bufDescriptor->height, &bufDescriptor->pixel_stride,
+ &bufDescriptor->byte_stride, &bufDescriptor->size, alloc_type,
+ &bufDescriptor->internalHeight, yv12_align))
{
return -EINVAL;
}
+
break;
}
+
case HAL_PIXEL_FORMAT_YCbCr_422_I:
{
/* YUYV 4:2:2 */
- if (type != UNCOMPRESSED || !get_yuv422_8bit_stride_and_size(w, h, &pixel_stride, &byte_stride, &size))
+ if (alloc_type != UNCOMPRESSED ||
+ !get_yuv422_8bit_stride_and_size(bufDescriptor->width, bufDescriptor->height,
+ &bufDescriptor->pixel_stride, &bufDescriptor->byte_stride,
+ &bufDescriptor->size))
{
return -EINVAL;
}
+
break;
}
+
case HAL_PIXEL_FORMAT_RAW16:
case HAL_PIXEL_FORMAT_RAW12:
case HAL_PIXEL_FORMAT_RAW10:
case HAL_PIXEL_FORMAT_BLOB:
- if (type != UNCOMPRESSED)
+ if (alloc_type != UNCOMPRESSED)
{
return -EINVAL;
}
- get_camera_formats_stride_and_size(w, h, base_format, &pixel_stride, &size);
- byte_stride = pixel_stride; /* For Raw/Blob formats stride is defined to be either in bytes or pixels per format */
+
+ get_camera_formats_stride_and_size(bufDescriptor->width, bufDescriptor->height, base_format,
+ &bufDescriptor->pixel_stride, &bufDescriptor->size);
+ /* For Raw/Blob formats stride is defined to be either in bytes or pixels per format */
+ bufDescriptor->byte_stride = bufDescriptor->pixel_stride;
break;
case MALI_GRALLOC_FORMAT_INTERNAL_Y0L2:
+
/* YUYAAYUVAA 4:2:0 with and without AFBC */
- if (type != UNCOMPRESSED)
+ if (alloc_type != UNCOMPRESSED)
{
- if (!get_yuv420_10bit_afbc_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type, &internalHeight))
+ if (!get_yuv420_10bit_afbc_stride_and_size(
+ bufDescriptor->width, bufDescriptor->height, &bufDescriptor->pixel_stride,
+ &bufDescriptor->byte_stride, &bufDescriptor->size, alloc_type, &bufDescriptor->internalHeight))
{
return -EINVAL;
}
}
else
{
- if(!get_yuv_y0l2_stride_and_size(w, h, &pixel_stride, &byte_stride, &size))
+ if (!get_yuv_y0l2_stride_and_size(bufDescriptor->width, bufDescriptor->height,
+ &bufDescriptor->pixel_stride, &bufDescriptor->byte_stride,
+ &bufDescriptor->size))
{
return -EINVAL;
}
}
+
break;
case MALI_GRALLOC_FORMAT_INTERNAL_P010:
+
/* Y-UV 4:2:0 */
- if (type != UNCOMPRESSED || !get_yuv_pX10_stride_and_size(w, h, 2, &pixel_stride, &byte_stride, &size))
+ if (alloc_type != UNCOMPRESSED ||
+ !get_yuv_pX10_stride_and_size(bufDescriptor->width, bufDescriptor->height, 2,
+ &bufDescriptor->pixel_stride, &bufDescriptor->byte_stride,
+ &bufDescriptor->size))
{
return -EINVAL;
}
+
break;
case MALI_GRALLOC_FORMAT_INTERNAL_P210:
+
/* Y-UV 4:2:2 */
- if (type != UNCOMPRESSED || !get_yuv_pX10_stride_and_size(w, h, 1, &pixel_stride, &byte_stride, &size))
+ if (alloc_type != UNCOMPRESSED ||
+ !get_yuv_pX10_stride_and_size(bufDescriptor->width, bufDescriptor->height, 1,
+ &bufDescriptor->pixel_stride, &bufDescriptor->byte_stride,
+ &bufDescriptor->size))
{
return -EINVAL;
}
+
break;
case MALI_GRALLOC_FORMAT_INTERNAL_Y210:
+
/* YUYV 4:2:2 with and without AFBC */
- if (type != UNCOMPRESSED)
+ if (alloc_type != UNCOMPRESSED)
{
- if (!get_yuv422_10bit_afbc_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type))
+ if (!get_yuv422_10bit_afbc_stride_and_size(bufDescriptor->width, bufDescriptor->height,
+ &bufDescriptor->pixel_stride, &bufDescriptor->byte_stride,
+ &bufDescriptor->size, alloc_type))
{
return -EINVAL;
}
}
else
{
- if(!get_yuv_y210_stride_and_size(w, h, &pixel_stride, &byte_stride, &size))
+ if (!get_yuv_y210_stride_and_size(bufDescriptor->width, bufDescriptor->height,
+ &bufDescriptor->pixel_stride, &bufDescriptor->byte_stride,
+ &bufDescriptor->size))
{
return -EINVAL;
}
}
+
break;
case MALI_GRALLOC_FORMAT_INTERNAL_Y410:
+
/* AVYU 2-10-10-10 */
- if (type != UNCOMPRESSED || !get_yuv_y410_stride_and_size(w, h, &pixel_stride, &byte_stride, &size))
+ if (alloc_type != UNCOMPRESSED ||
+ !get_yuv_y410_stride_and_size(bufDescriptor->width, bufDescriptor->height, &bufDescriptor->pixel_stride,
+ &bufDescriptor->byte_stride, &bufDescriptor->size))
{
return -EINVAL;
}
+
break;
case MALI_GRALLOC_FORMAT_INTERNAL_YUV422_8BIT:
+
/* 8BIT AFBC YUV4:2:2 testing usage */
- /* We only support compressed for this format right now.
- * Below will fail in case format is uncompressed.
- */
- if (!get_afbc_yuv422_8bit_stride_and_size(w, h, &pixel_stride, &byte_stride, &size, type))
+ /* We only support compressed for this format right now.
+ * Below will fail in case format is uncompressed.
+ */
+ if (!get_afbc_yuv422_8bit_stride_and_size(bufDescriptor->width, bufDescriptor->height,
+ &bufDescriptor->pixel_stride, &bufDescriptor->byte_stride,
+ &bufDescriptor->size, alloc_type))
{
return -EINVAL;
}
+
break;
- /*
- * Additional custom formats can be added here
- * and must fill the variables pixel_stride, byte_stride and size.
- */
+
+ /*
+ * Additional custom formats can be added here
+ * and must fill the variables pixel_stride, byte_stride and size.
+ */
default:
return -EINVAL;
+ }
}
- int err;
-#if DISABLE_FRAMEBUFFER_HAL != 1
- if (usage & GRALLOC_USAGE_HW_FB)
{
- err = gralloc_alloc_framebuffer(dev, size, usage, pHandle, &pixel_stride, &byte_stride);
+ /* Allocate ION backing store memory */
+ err = mali_gralloc_ion_allocate(m, descriptors, numDescriptors, pHandle, &shared);
+
+ if (err < 0)
+ {
+ return err;
+ }
}
- else
-#endif
+
+ if (shared)
{
- err = alloc_backend_alloc(dev, size, usage, pHandle, internal_format, w, h);
+ backing_store_id = getUniqueId();
}
- if (err < 0)
+ for (i = 0; i < numDescriptors; i++)
{
- return err;
- }
+ buffer_descriptor_t *bufDescriptor = (buffer_descriptor_t *)descriptors[i];
+ private_handle_t *hnd = (private_handle_t *)pHandle[i];
- private_handle_t *hnd = (private_handle_t *)*pHandle;
+ usage = bufDescriptor->consumer_usage | bufDescriptor->producer_usage;
- err = gralloc_buffer_attr_allocate( hnd );
- if( err < 0 )
- {
- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
+ err = gralloc_buffer_attr_allocate(hnd);
- if ( (usage & GRALLOC_USAGE_HW_FB) )
- {
- /*
- * Having the attribute region is not critical for the framebuffer so let it pass.
- */
- err = 0;
- }
- else
+ if (err < 0)
{
- alloc_backend_alloc_free( hnd, m );
+ /* free all allocated ion buffer& attr buffer here.*/
+ mali_gralloc_buffer_free_internal(pHandle, numDescriptors);
return err;
}
- }
- hnd->req_format = format;
- hnd->byte_stride = byte_stride;
- hnd->internal_format = internal_format;
+ mali_gralloc_dump_buffer_add(hnd);
- int private_usage = usage & MALI_GRALLOC_USAGE_YUV_CONF_MASK;
-
- switch (private_usage)
- {
+ switch (usage & MALI_GRALLOC_USAGE_YUV_CONF_MASK)
+ {
case MALI_GRALLOC_USAGE_YUV_CONF_0:
hnd->yuv_info = MALI_YUV_BT601_NARROW;
break;
+
case MALI_GRALLOC_USAGE_YUV_CONF_1:
hnd->yuv_info = MALI_YUV_BT601_WIDE;
break;
+
case MALI_GRALLOC_USAGE_YUV_CONF_2:
hnd->yuv_info = MALI_YUV_BT709_NARROW;
break;
+
case MALI_GRALLOC_USAGE_YUV_CONF_3:
hnd->yuv_info = MALI_YUV_BT709_WIDE;
break;
+ }
+
+ /* Workaround 10bit YUV only support BT709_WIDE in GPU DDK */
+ if ((bufDescriptor->internal_format & MALI_GRALLOC_INTFMT_FMT_MASK) == MALI_GRALLOC_FORMAT_INTERNAL_Y0L2)
+ {
+ hnd->yuv_info = MALI_YUV_BT709_WIDE;
+ }
+
+ if (shared)
+ {
+ /*each buffer will share the same backing store id.*/
+ hnd->backing_store_id = backing_store_id;
+ }
+ else
+ {
+ /* each buffer will have an unique backing store id.*/
+ hnd->backing_store_id = getUniqueId();
+ }
}
- /* Workaround 10bit YUV only support BT709_WIDE in GPU DDK */
- if ((hnd->internal_format & MALI_GRALLOC_INTFMT_FMT_MASK) == MALI_GRALLOC_FORMAT_INTERNAL_Y0L2)
+ if (NULL != shared_backend)
{
- hnd->yuv_info = MALI_YUV_BT709_WIDE;
+ *shared_backend = shared;
}
- hnd->width = w;
- hnd->height = h;
- hnd->stride = pixel_stride;
- hnd->internalWidth = internalWidth;
- hnd->internalHeight = internalHeight;
- *pStride = pixel_stride;
return 0;
}
-static int alloc_device_free(alloc_device_t* dev, buffer_handle_t handle)
+int mali_gralloc_buffer_free(buffer_handle_t pHandle)
{
- if (private_handle_t::validate(handle) < 0)
- {
- return -EINVAL;
- }
-
- private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(handle);
- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
+ int rval = -1;
+ private_handle_t *hnd = (private_handle_t *)(pHandle);
- if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
+ if (hnd != NULL)
{
- // free this buffer
- private_module_t* m = reinterpret_cast<private_module_t*>(dev->common.module);
- const size_t bufferSize = m->finfo.line_length * m->info.yres;
- int index = ((uintptr_t)hnd->base - (uintptr_t)m->framebuffer->base) / bufferSize;
- m->bufferMask &= ~(1 << index);
+ rval = gralloc_buffer_attr_free(hnd);
+ mali_gralloc_ion_free(hnd);
}
- gralloc_buffer_attr_free( (private_handle_t *) hnd );
- alloc_backend_alloc_free(hnd, m);
-
- delete hnd;
-
- return 0;
+ return rval;
}
-int alloc_device_open(hw_module_t const* module, const char* name, hw_device_t** device)
+static int mali_gralloc_buffer_free_internal(buffer_handle_t *pHandle, uint32_t num_hnds)
{
- alloc_device_t *dev;
-
- GRALLOC_UNUSED(name);
+ int err = -1;
+ uint32_t i = 0;
- dev = new alloc_device_t;
- if (NULL == dev)
+ for (i = 0; i < num_hnds; i++)
{
- return -1;
- }
-
- /* initialize our state here */
- memset(dev, 0, sizeof(*dev));
-
- /* initialize the procs */
- dev->common.tag = HARDWARE_DEVICE_TAG;
- dev->common.version = 0;
- dev->common.module = const_cast<hw_module_t*>(module);
- dev->common.close = alloc_backend_close;
- dev->alloc = alloc_device_alloc;
- dev->free = alloc_device_free;
+ private_handle_t *hnd = (private_handle_t *)(pHandle[i]);
- if (0 != alloc_backend_open(dev)) {
- delete dev;
- return -1;
+ err = gralloc_buffer_attr_free(hnd);
+ mali_gralloc_ion_free(hnd);
}
- *device = &dev->common;
-
- return 0;
+ return err;
}
diff --git a/gralloc960/mali_gralloc_bufferallocation.h b/gralloc960/mali_gralloc_bufferallocation.h
new file mode 100644
index 00000000..5148252e
--- /dev/null
+++ b/gralloc960/mali_gralloc_bufferallocation.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2016-2017 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef MALI_GRALLOC_BUFFERALLOCATION_H_
+#define MALI_GRALLOC_BUFFERALLOCATION_H_
+
+#include <hardware/hardware.h>
+#include "mali_gralloc_module.h"
+#include "mali_gralloc_private_interface_types.h"
+#include "mali_gralloc_buffer.h"
+#include "mali_gralloc_bufferdescriptor.h"
+
+int mali_gralloc_buffer_allocate(mali_gralloc_module *m, const gralloc_buffer_descriptor_t *descriptors,
+ uint32_t numDescriptors, buffer_handle_t *pHandle, bool *shared_backend);
+int mali_gralloc_buffer_free(buffer_handle_t pHandle);
+
+#endif /* MALI_GRALLOC_BUFFERALLOCATION_H_ */
diff --git a/gralloc960/mali_gralloc_bufferdescriptor.cpp b/gralloc960/mali_gralloc_bufferdescriptor.cpp
new file mode 100644
index 00000000..11e3cb3a
--- /dev/null
+++ b/gralloc960/mali_gralloc_bufferdescriptor.cpp
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2016-2017 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <hardware/hardware.h>
+#include <stdlib.h>
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+
+#include "mali_gralloc_module.h"
+#include "mali_gralloc_bufferdescriptor.h"
+#include "mali_gralloc_private_interface_types.h"
+#include "mali_gralloc_buffer.h"
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+int mali_gralloc_create_descriptor_internal(gralloc1_buffer_descriptor_t *outDescriptor)
+{
+ buffer_descriptor_t *buffer_descriptor;
+
+ if (NULL == outDescriptor)
+ {
+ return GRALLOC1_ERROR_BAD_DESCRIPTOR;
+ }
+
+ buffer_descriptor = reinterpret_cast<buffer_descriptor_t *>(malloc(sizeof(buffer_descriptor_t)));
+
+ if (NULL == buffer_descriptor)
+ {
+ AERR("failed to create buffer descriptor");
+ return GRALLOC1_ERROR_BAD_DESCRIPTOR;
+ }
+
+ *outDescriptor = (gralloc1_buffer_descriptor_t)buffer_descriptor;
+ return GRALLOC1_ERROR_NONE;
+}
+
+int mali_gralloc_destroy_descriptor_internal(gralloc1_buffer_descriptor_t descriptor)
+{
+ if (!descriptor)
+ {
+ return GRALLOC1_ERROR_BAD_DESCRIPTOR;
+ }
+
+ buffer_descriptor_t *buffer_descriptor = (buffer_descriptor_t *)descriptor;
+ free(buffer_descriptor);
+ return GRALLOC1_ERROR_NONE;
+}
+
+int mali_gralloc_set_dimensions_internal(gralloc1_buffer_descriptor_t descriptor, uint32_t width, uint32_t height)
+{
+ if (!descriptor)
+ {
+ return GRALLOC1_ERROR_BAD_DESCRIPTOR;
+ }
+
+ buffer_descriptor_t *buffer_descriptor = (buffer_descriptor_t *)descriptor;
+ buffer_descriptor->width = width;
+ buffer_descriptor->height = height;
+ return GRALLOC1_ERROR_NONE;
+}
+
+int mali_gralloc_set_format_internal(gralloc1_buffer_descriptor_t descriptor, int32_t format)
+{
+ if (!descriptor)
+ {
+ return GRALLOC1_ERROR_BAD_DESCRIPTOR;
+ }
+
+ buffer_descriptor_t *buffer_descriptor = (buffer_descriptor_t *)descriptor;
+ buffer_descriptor->hal_format = format;
+ buffer_descriptor->format_type = MALI_GRALLOC_FORMAT_TYPE_USAGE;
+ return GRALLOC1_ERROR_NONE;
+}
+
+int mali_gralloc_set_producerusage_internal(gralloc1_buffer_descriptor_t descriptor, uint64_t usage)
+{
+ if (!descriptor)
+ {
+ return GRALLOC1_ERROR_BAD_DESCRIPTOR;
+ }
+
+ buffer_descriptor_t *buffer_descriptor = (buffer_descriptor_t *)descriptor;
+ buffer_descriptor->producer_usage = usage;
+ return GRALLOC1_ERROR_NONE;
+}
+
+int mali_gralloc_set_consumerusage_internal(gralloc1_buffer_descriptor_t descriptor, uint64_t usage)
+{
+ if (!descriptor)
+ {
+ return GRALLOC1_ERROR_BAD_DESCRIPTOR;
+ }
+
+ buffer_descriptor_t *buffer_descriptor = (buffer_descriptor_t *)descriptor;
+ buffer_descriptor->consumer_usage = usage;
+ return GRALLOC1_ERROR_NONE;
+}
+
+int mali_gralloc_get_backing_store_internal(buffer_handle_t buffer, gralloc1_backing_store_t *outStore)
+{
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ AERR("Invalid buffer %p, returning error", buffer);
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ private_handle_t *hnd = (private_handle_t *)buffer;
+
+ *outStore = (gralloc1_backing_store_t)hnd->backing_store_id;
+ return GRALLOC1_ERROR_NONE;
+}
+
+int mali_gralloc_get_consumer_usage_internal(buffer_handle_t buffer, uint64_t *outUsage)
+{
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ AERR("Invalid buffer %p, returning error", buffer);
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ private_handle_t *hnd = (private_handle_t *)buffer;
+ *outUsage = hnd->consumer_usage;
+ return GRALLOC1_ERROR_NONE;
+}
+
+int mali_gralloc_get_dimensions_internal(buffer_handle_t buffer, uint32_t *outWidth, uint32_t *outHeight)
+{
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ AERR("Invalid buffer %p, returning error", buffer);
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ private_handle_t *hnd = (private_handle_t *)buffer;
+ *outWidth = hnd->width;
+ *outHeight = hnd->height;
+ return GRALLOC1_ERROR_NONE;
+}
+
+int mali_gralloc_get_format_internal(buffer_handle_t buffer, int32_t *outFormat)
+{
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ AERR("Invalid buffer %p, returning error", buffer);
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ private_handle_t *hnd = (private_handle_t *)buffer;
+ *outFormat = hnd->req_format;
+ return GRALLOC1_ERROR_NONE;
+}
+
+int mali_gralloc_get_producer_usage_internal(buffer_handle_t buffer, uint64_t *outUsage)
+{
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ AERR("Invalid buffer %p, returning error", buffer);
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ private_handle_t *hnd = (private_handle_t *)buffer;
+ *outUsage = hnd->producer_usage;
+ return GRALLOC1_ERROR_NONE;
+}
+
+#endif
+int mali_gralloc_query_getstride(buffer_handle_t buffer, int *pixelStride)
+{
+ int rval = -1;
+
+ if (buffer != NULL && pixelStride != NULL)
+ {
+ private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(buffer);
+
+ if (hnd)
+ {
+ *pixelStride = hnd->stride;
+ rval = 0;
+ }
+ }
+
+ return rval;
+}
diff --git a/gralloc960/mali_gralloc_bufferdescriptor.h b/gralloc960/mali_gralloc_bufferdescriptor.h
new file mode 100644
index 00000000..6783be07
--- /dev/null
+++ b/gralloc960/mali_gralloc_bufferdescriptor.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2016-2017 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MALI_GRALLOC_BUFFERDESCRIPTOR_H_
+#define MALI_GRALLOC_BUFFERDESCRIPTOR_H_
+
+#include <hardware/hardware.h>
+#include "gralloc_priv.h"
+#include "mali_gralloc_module.h"
+#include "mali_gralloc_formats.h"
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+
+typedef uint64_t gralloc_buffer_descriptor_t;
+
+typedef struct buffer_descriptor
+{
+ uint32_t width;
+ uint32_t height;
+ uint64_t producer_usage;
+ uint64_t consumer_usage;
+ uint64_t hal_format;
+
+ mali_gralloc_format_type format_type;
+ size_t size;
+ int byte_stride;
+ int pixel_stride;
+ int internalWidth;
+ int internalHeight;
+ uint64_t internal_format;
+} buffer_descriptor_t;
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+int mali_gralloc_create_descriptor_internal(gralloc1_buffer_descriptor_t *outDescriptor);
+int mali_gralloc_destroy_descriptor_internal(gralloc1_buffer_descriptor_t descriptor);
+int mali_gralloc_set_dimensions_internal(gralloc1_buffer_descriptor_t descriptor, uint32_t width, uint32_t height);
+int mali_gralloc_set_format_internal(gralloc1_buffer_descriptor_t descriptor, int32_t format);
+int mali_gralloc_set_producerusage_internal(gralloc1_buffer_descriptor_t descriptor, uint64_t usage);
+int mali_gralloc_set_consumerusage_internal(gralloc1_buffer_descriptor_t descriptor, uint64_t usage);
+
+int mali_gralloc_get_backing_store_internal(buffer_handle_t buffer, gralloc1_backing_store_t *outStore);
+int mali_gralloc_get_consumer_usage_internal(buffer_handle_t buffer, uint64_t *outUsage);
+int mali_gralloc_get_dimensions_internal(buffer_handle_t buffer, uint32_t *outWidth, uint32_t *outHeight);
+int mali_gralloc_get_format_internal(buffer_handle_t buffer, int32_t *outFormat);
+int mali_gralloc_get_producer_usage_internal(buffer_handle_t buffer, uint64_t *outUsage);
+#endif
+int mali_gralloc_query_getstride(buffer_handle_t handle, int *pixelStride);
+
+#endif /* MALI_GRALLOC_BUFFERDESCRIPTOR_H_ */
diff --git a/gralloc960/mali_gralloc_debug.cpp b/gralloc960/mali_gralloc_debug.cpp
new file mode 100644
index 00000000..d4473ed2
--- /dev/null
+++ b/gralloc960/mali_gralloc_debug.cpp
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2016 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include <vector>
+#include <algorithm>
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+#include <hardware/hardware.h>
+
+#include "mali_gralloc_module.h"
+#include "gralloc_priv.h"
+#include "mali_gralloc_debug.h"
+
+static pthread_mutex_t dump_lock = PTHREAD_MUTEX_INITIALIZER;
+static std::vector<private_handle_t *> dump_buffers;
+static android::String8 dumpStrings;
+
+void mali_gralloc_dump_buffer_add(private_handle_t *handle)
+{
+ if (NULL == handle)
+ {
+ ALOGE("Invalid handle %p and return", handle);
+ return;
+ }
+
+ pthread_mutex_lock(&dump_lock);
+ dump_buffers.push_back(handle);
+ pthread_mutex_unlock(&dump_lock);
+}
+
+void mali_gralloc_dump_buffer_erase(private_handle_t *handle)
+{
+ if (NULL == handle)
+ {
+ ALOGE("Invalid handle %p and return", handle);
+ return;
+ }
+
+ pthread_mutex_lock(&dump_lock);
+ dump_buffers.erase(std::remove(dump_buffers.begin(), dump_buffers.end(), handle));
+ pthread_mutex_unlock(&dump_lock);
+}
+
+void mali_gralloc_dump_string(android::String8 &buf, const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ buf.appendFormatV(fmt, args);
+ va_end(args);
+}
+
+void mali_gralloc_dump_buffers(android::String8 &dumpStrings, uint32_t *outSize)
+{
+ if (NULL == outSize)
+ {
+ ALOGE("Invalid pointer to dump buffer size and return");
+ return;
+ }
+
+ dumpStrings.clear();
+ mali_gralloc_dump_string(dumpStrings,
+ "-------------------------Start to dump Gralloc buffers info------------------------\n");
+ private_handle_t *hnd;
+ size_t num;
+
+ mali_gralloc_dump_string(dumpStrings, " handle | width | height | stride | req format |internal "
+ "format|consumer usage|producer usage| shared fd | AFBC "
+ "|\n");
+ mali_gralloc_dump_string(dumpStrings, "------------+-------+--------+--------+----------------+---------------+----"
+ "----------+--------------+-----------+------+\n");
+ pthread_mutex_lock(&dump_lock);
+
+ for (num = 0; num < dump_buffers.size(); num++)
+ {
+ hnd = dump_buffers[num];
+ mali_gralloc_dump_string(dumpStrings, " %08" PRIxPTR " | %5d | %5d | %5d | %08x | %09" PRIx64
+ " | %09" PRIx64 " | %09" PRIx64 " | %08x | %4d |\n",
+ hnd, hnd->width, hnd->height, hnd->stride, hnd->req_format, hnd->internal_format,
+ hnd->consumer_usage, hnd->producer_usage, hnd->share_fd,
+ (hnd->internal_format & MALI_GRALLOC_INTFMT_AFBCENABLE_MASK) ? true : false);
+ }
+
+ pthread_mutex_unlock(&dump_lock);
+ mali_gralloc_dump_string(
+ dumpStrings, "---------------------End dump Gralloc buffers info with num %zu----------------------\n", num);
+
+ *outSize = dumpStrings.size();
+}
+
+void mali_gralloc_dump_internal(uint32_t *outSize, char *outBuffer)
+{
+ uint32_t dumpSize;
+
+ if (NULL == outSize)
+ {
+ ALOGE("Invalid pointer to dump buffer size and return");
+ return;
+ }
+
+ if (NULL == outBuffer)
+ {
+ if (!dumpStrings.isEmpty())
+ {
+ dumpStrings.clear();
+ }
+
+ mali_gralloc_dump_buffers(dumpStrings, outSize);
+ }
+ else
+ {
+ if (dumpStrings.isEmpty())
+ {
+ *outSize = 0;
+ }
+ else
+ {
+ dumpSize = dumpStrings.size();
+ *outSize = (dumpSize < *outSize) ? dumpSize : *outSize;
+ memcpy(outBuffer, dumpStrings.string(), *outSize);
+ }
+ }
+}
diff --git a/gralloc960/mali_gralloc_debug.h b/gralloc960/mali_gralloc_debug.h
new file mode 100644
index 00000000..26e23814
--- /dev/null
+++ b/gralloc960/mali_gralloc_debug.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2016 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MALI_GRALLOC_DEBUG_H_
+#define MALI_GRALLOC_DEBUG_H_
+
+#include <utils/String8.h>
+#include <hardware/hardware.h>
+#include "gralloc_priv.h"
+#include "mali_gralloc_module.h"
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+
+void mali_gralloc_dump_buffer_add(private_handle_t *handle);
+void mali_gralloc_dump_buffer_erase(private_handle_t *handle);
+
+void mali_gralloc_dump_string(android::String8 &buf, const char *fmt, ...);
+void mali_gralloc_dump_buffers(android::String8 &dumpBuffer, uint32_t *outSize);
+void mali_gralloc_dump_internal(uint32_t *outSize, char *outBuffer);
+#endif
diff --git a/gralloc960/mali_gralloc_formats.cpp b/gralloc960/mali_gralloc_formats.cpp
index 67127fd0..32272d73 100644
--- a/gralloc960/mali_gralloc_formats.cpp
+++ b/gralloc960/mali_gralloc_formats.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 ARM Limited. All rights reserved.
+ * Copyright (C) 2016-2017 ARM Limited. All rights reserved.
*
* Copyright (C) 2008 The Android Open Source Project
*
@@ -18,11 +18,16 @@
#include <string.h>
#include <dlfcn.h>
-#include <hardware/gralloc.h>
#include <inttypes.h>
-#include <cutils/log.h>
+#include <log/log.h>
-#include "mali_gralloc_formats.h"
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+
+#include "mali_gralloc_module.h"
#include "gralloc_priv.h"
static mali_gralloc_format_caps dpu_runtime_caps;
@@ -41,51 +46,53 @@ static bool runtime_caps_read = false;
#define MALI_GRALLOC_GPU_LIBRARY_PATH2 "/system/lib/egl/"
#endif
+#define GRALLOC_AFBC_MIN_SIZE 75
+
static bool get_block_capabilities(bool hal_module, const char *name, mali_gralloc_format_caps *block_caps)
{
- void *dso_handle = NULL;
- bool rval = false;
-
- /* Look for MALI_GRALLOC_FORMATCAPS_SYM_NAME_STR symbol in user-space drivers
- * to determine hw format capabilities.
- */
- if(!hal_module)
- {
- dso_handle = dlopen(name, RTLD_LAZY);
- }
- else
- {
- /* libhardware does some heuristics to find hal modules
- * and then stores the dso handle internally. Use this.
- */
- const struct hw_module_t *module = {NULL};
-
- if(hw_get_module(name, &module) >= 0)
- {
- dso_handle = module->dso;
- }
- }
-
- if(dso_handle)
- {
- void *sym = dlsym(dso_handle, MALI_GRALLOC_FORMATCAPS_SYM_NAME_STR);
-
- if(sym)
- {
- memcpy((void*) block_caps, sym, sizeof(mali_gralloc_format_caps));
- rval = true;
- }
-
- if(!hal_module)
- {
- dlclose(dso_handle);
- }
- }
-
- return rval;
+ void *dso_handle = NULL;
+ bool rval = false;
+
+ /* Look for MALI_GRALLOC_FORMATCAPS_SYM_NAME_STR symbol in user-space drivers
+ * to determine hw format capabilities.
+ */
+ if (!hal_module)
+ {
+ dso_handle = dlopen(name, RTLD_LAZY);
+ }
+ else
+ {
+ /* libhardware does some heuristics to find hal modules
+ * and then stores the dso handle internally. Use this.
+ */
+ const struct hw_module_t *module = { NULL };
+
+ if (hw_get_module(name, &module) >= 0)
+ {
+ dso_handle = module->dso;
+ }
+ }
+
+ if (dso_handle)
+ {
+ void *sym = dlsym(dso_handle, MALI_GRALLOC_FORMATCAPS_SYM_NAME_STR);
+
+ if (sym)
+ {
+ memcpy((void *)block_caps, sym, sizeof(mali_gralloc_format_caps));
+ rval = true;
+ }
+
+ if (!hal_module)
+ {
+ dlclose(dso_handle);
+ }
+ }
+
+ return rval;
}
-static int map_flex_formats(int req_format, uint64_t *producer_runtime_mask)
+static int map_flex_formats(uint64_t req_format)
{
/* Map Android flexible formats to internal base formats */
if(req_format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED ||
@@ -93,361 +100,393 @@ static int map_flex_formats(int req_format, uint64_t *producer_runtime_mask)
{
req_format = MALI_GRALLOC_FORMAT_INTERNAL_NV12;
- /*
- * We disable AFBC for NV12 since neither VPU or DPU DDKs support
- * them currently.
- */
- *producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
}
return req_format;
}
static bool is_afbc_supported(int req_format_mapped)
{
- bool rval = true;
-
- /* These base formats we currently don't support with compression */
- switch(req_format_mapped)
- {
- case MALI_GRALLOC_FORMAT_INTERNAL_RAW16:
- case MALI_GRALLOC_FORMAT_INTERNAL_RAW12:
- case MALI_GRALLOC_FORMAT_INTERNAL_RAW10:
- case MALI_GRALLOC_FORMAT_INTERNAL_BLOB:
- case MALI_GRALLOC_FORMAT_INTERNAL_P010:
- case MALI_GRALLOC_FORMAT_INTERNAL_P210:
- case MALI_GRALLOC_FORMAT_INTERNAL_Y410:
- case HAL_PIXEL_FORMAT_YCbCr_422_I:
- rval = false;
- break;
- }
- return rval;
+ bool rval = true;
+
+ /* These base formats we currently don't support with compression */
+ switch (req_format_mapped)
+ {
+ case MALI_GRALLOC_FORMAT_INTERNAL_RAW16:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RAW12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RAW10:
+ case MALI_GRALLOC_FORMAT_INTERNAL_BLOB:
+ case MALI_GRALLOC_FORMAT_INTERNAL_P010:
+ case MALI_GRALLOC_FORMAT_INTERNAL_P210:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y410:
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ rval = false;
+ break;
+ }
+
+ return rval;
}
static bool is_android_yuv_format(int req_format)
{
- bool rval = false;
-
- switch(req_format)
- {
- case HAL_PIXEL_FORMAT_YV12:
- case HAL_PIXEL_FORMAT_Y8:
- case HAL_PIXEL_FORMAT_Y16:
- case HAL_PIXEL_FORMAT_YCbCr_420_888:
- case HAL_PIXEL_FORMAT_YCbCr_422_888:
- case HAL_PIXEL_FORMAT_YCbCr_444_888:
- rval = true;
- break;
- }
- return rval;
+ bool rval = false;
+
+ switch (req_format)
+ {
+ case HAL_PIXEL_FORMAT_YV12:
+ case HAL_PIXEL_FORMAT_Y8:
+ case HAL_PIXEL_FORMAT_Y16:
+ case HAL_PIXEL_FORMAT_YCbCr_420_888:
+ case HAL_PIXEL_FORMAT_YCbCr_422_888:
+ case HAL_PIXEL_FORMAT_YCbCr_444_888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
+ case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
+ rval = true;
+ break;
+ }
+
+ return rval;
}
static bool is_afbc_allowed(int buffer_size)
{
- bool afbc_allowed = false;
+ bool afbc_allowed = false;
- (void) buffer_size;
+ (void)buffer_size;
+#if MALI_DISPLAY_VERSION == 550 || MALI_DISPLAY_VERSION == 650
#if GRALLOC_DISP_W != 0 && GRALLOC_DISP_H != 0
- afbc_allowed = ((buffer_size*100) / (GRALLOC_DISP_W*GRALLOC_DISP_H)) >= GRALLOC_AFBC_MIN_SIZE;
+ afbc_allowed = ((buffer_size * 100) / (GRALLOC_DISP_W * GRALLOC_DISP_H)) >= GRALLOC_AFBC_MIN_SIZE;
#else
- /* If display size is not valid then always allow AFBC */
- afbc_allowed = true;
+ /* If display size is not valid then always allow AFBC */
+ afbc_allowed = true;
#endif
-
- return afbc_allowed;
+#else
+ /* For cetus, always allow AFBC */
+ afbc_allowed = true;
+#endif
+ return afbc_allowed;
}
static bool is_afbc_format(uint64_t internal_format)
{
- return (internal_format & MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK) != 0;
+ return (internal_format & MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK) != 0;
}
-static uint64_t determine_best_format(int req_format, mali_gralloc_producer_type producer, mali_gralloc_consumer_type consumer,
- uint64_t producer_runtime_mask, uint64_t consumer_runtime_mask)
+static uint64_t determine_best_format(int req_format, mali_gralloc_producer_type producer,
+ mali_gralloc_consumer_type consumer, uint64_t producer_runtime_mask,
+ uint64_t consumer_runtime_mask)
{
- /* Default is to return the requested format */
- uint64_t internal_format = req_format;
- uint64_t dpu_mask = dpu_runtime_caps.caps_mask;
- uint64_t gpu_mask = gpu_runtime_caps.caps_mask;
- uint64_t vpu_mask = vpu_runtime_caps.caps_mask;
- uint64_t cam_mask = cam_runtime_caps.caps_mask;
-
- if(producer == MALI_GRALLOC_PRODUCER_GPU && gpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT)
- {
- gpu_mask &= producer_runtime_mask;
-
- if(consumer == MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY)
- {
- gpu_mask &= consumer_runtime_mask;
- dpu_mask &= consumer_runtime_mask;
-
- if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK &&
- dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK)
- {
- internal_format |= MALI_GRALLOC_INTFMT_AFBC_SPLITBLK;
- }
- else if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
- dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
- {
- internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
-
- if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS &&
- dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS)
- {
- internal_format |= MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS;
- }
- }
- }
- else if(consumer == MALI_GRALLOC_CONSUMER_GPU_EXCL)
- {
- gpu_mask &= consumer_runtime_mask;
-
- /* When GPU acts as both producer and consumer it prefers 16x16 superblocks */
- if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
- {
- internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
- }
-
- if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS)
- {
- internal_format |= MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS;
- }
- }
- else if(consumer == MALI_GRALLOC_CONSUMER_VIDEO_ENCODER)
- {
- vpu_mask &= consumer_runtime_mask;
-
- if(req_format == HAL_PIXEL_FORMAT_YV12)
- {
- if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
- vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
- {
- internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
- }
-
- if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS &&
- vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS)
- {
- internal_format |= MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS;
- }
- }
- }
- }
- else if(producer == MALI_GRALLOC_PRODUCER_VIDEO_DECODER && vpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT)
- {
- vpu_mask &= producer_runtime_mask;
-
- if(consumer == MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY)
- {
- gpu_mask &= consumer_runtime_mask;
- dpu_mask &= consumer_runtime_mask;
-
- if(internal_format == HAL_PIXEL_FORMAT_YV12)
- {
- if(vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
- gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
- dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
- {
- internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
- }
-
- if(vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS &&
- gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS &&
- dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS)
- {
- internal_format |= MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS;
- }
- }
- }
- else if(consumer == MALI_GRALLOC_CONSUMER_GPU_EXCL)
- {
- gpu_mask &= consumer_runtime_mask;
-
- if(internal_format == HAL_PIXEL_FORMAT_YV12)
- {
- if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
- vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
- {
- internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
- }
-
- if(gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS &&
- vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS)
- {
- internal_format |= MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS;
- }
- }
- }
- else if(consumer == MALI_GRALLOC_CONSUMER_VIDEO_ENCODER)
- {
- /* Fall-through. To be decided.*/
- }
- }
- else if(producer == MALI_GRALLOC_PRODUCER_CAMERA && cam_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT)
- {
- if(consumer == MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY)
- {
- /* Fall-through. To be decided.*/
- }
- else if(consumer == MALI_GRALLOC_CONSUMER_GPU_EXCL)
- {
- /* Fall-through. To be decided.*/
- }
- else if(consumer == MALI_GRALLOC_CONSUMER_VIDEO_ENCODER)
- {
- /* Fall-through. To be decided.*/
- }
- }
- return internal_format;
+ /* Default is to return the requested format */
+ uint64_t internal_format = req_format;
+ uint64_t dpu_mask = dpu_runtime_caps.caps_mask;
+ uint64_t gpu_mask = gpu_runtime_caps.caps_mask;
+ uint64_t vpu_mask = vpu_runtime_caps.caps_mask;
+ uint64_t cam_mask = cam_runtime_caps.caps_mask;
+
+ if (producer == MALI_GRALLOC_PRODUCER_GPU &&
+ gpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT)
+ {
+ gpu_mask &= producer_runtime_mask;
+
+ if (consumer == MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY)
+ {
+ gpu_mask &= consumer_runtime_mask;
+ dpu_mask &= consumer_runtime_mask;
+
+ if (gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK &&
+ dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_SPLITBLK;
+ }
+ else if (gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
+ dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
+
+ if (gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS &&
+ dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS;
+ }
+ }
+ }
+ else if (consumer == MALI_GRALLOC_CONSUMER_GPU_EXCL)
+ {
+ gpu_mask &= consumer_runtime_mask;
+
+ /* When GPU acts as both producer and consumer it prefers 16x16 superblocks */
+ if (gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
+ }
+
+ if (gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS;
+ }
+ }
+ else if (consumer == MALI_GRALLOC_CONSUMER_VIDEO_ENCODER)
+ {
+ vpu_mask &= consumer_runtime_mask;
+
+ if (internal_format == HAL_PIXEL_FORMAT_YV12 || internal_format == MALI_GRALLOC_FORMAT_INTERNAL_NV12)
+ {
+ if (gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
+ vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
+ }
+
+ if (gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS &&
+ vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS;
+ }
+ }
+ }
+ }
+ else if (producer == MALI_GRALLOC_PRODUCER_VIDEO_DECODER &&
+ vpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT)
+ {
+ vpu_mask &= producer_runtime_mask;
+
+ if (consumer == MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY)
+ {
+ gpu_mask &= consumer_runtime_mask;
+ dpu_mask &= consumer_runtime_mask;
+
+ if (internal_format == HAL_PIXEL_FORMAT_YV12)
+ {
+ if (vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
+ gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
+ dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
+ }
+
+ if (vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS &&
+ gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS &&
+ dpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS;
+ }
+ }
+ }
+ else if (consumer == MALI_GRALLOC_CONSUMER_GPU_EXCL)
+ {
+ gpu_mask &= consumer_runtime_mask;
+
+ if (internal_format == HAL_PIXEL_FORMAT_YV12)
+ {
+ if (gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC &&
+ vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_BASIC;
+ }
+
+ if (gpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS &&
+ vpu_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS)
+ {
+ internal_format |= MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS;
+ }
+ }
+ }
+ else if (consumer == MALI_GRALLOC_CONSUMER_VIDEO_ENCODER)
+ {
+ /* Fall-through. To be decided.*/
+ }
+ }
+ else if (producer == MALI_GRALLOC_PRODUCER_CAMERA &&
+ cam_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT)
+ {
+ if (consumer == MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY)
+ {
+ /* Fall-through. To be decided.*/
+ }
+ else if (consumer == MALI_GRALLOC_CONSUMER_GPU_EXCL)
+ {
+ /* Fall-through. To be decided.*/
+ }
+ else if (consumer == MALI_GRALLOC_CONSUMER_VIDEO_ENCODER)
+ {
+ /* Fall-through. To be decided.*/
+ }
+ }
+
+ return internal_format;
}
-static uint64_t decode_internal_format(int req_format)
+static uint64_t decode_internal_format(uint64_t req_format, mali_gralloc_format_type type)
{
- uint64_t internal_format, me_mask, base_format, mapped_base_format;
- uint64_t ignore_mask;
-
- internal_format = GRALLOC_PRIVATE_FORMAT_UNWRAP(req_format);
-
- me_mask = internal_format & MALI_GRALLOC_INTFMT_ME_EXT_MASK;
- if(me_mask > 0 && ((me_mask - 1) & me_mask) != 0)
- {
- ALOGE("Internal format contains multiple mutually exclusive modifier bits: %" PRIx64, internal_format);
- internal_format = 0;
- goto out;
- }
+ uint64_t internal_format, me_mask, base_format, mapped_base_format;
+
+ if (type == MALI_GRALLOC_FORMAT_TYPE_USAGE)
+ {
+ internal_format = GRALLOC_PRIVATE_FORMAT_UNWRAP((int)req_format);
+ }
+ else if (type == MALI_GRALLOC_FORMAT_TYPE_INTERNAL)
+ {
+ internal_format = req_format;
+ }
+ else
+ {
+ internal_format = 0;
+ goto out;
+ }
+
+ me_mask = internal_format & MALI_GRALLOC_INTFMT_ME_EXT_MASK;
+
+ if (me_mask > 0 && ((me_mask - 1) & me_mask) != 0)
+ {
+ ALOGE("Internal format contains multiple mutually exclusive modifier bits: %" PRIx64, internal_format);
+ internal_format = 0;
+ goto out;
+ }
+
+ base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
+
+ /* Even though private format allocations are intended to be for specific
+ * formats, certain test cases uses the flexible formats that needs to be mapped
+ * to internal ones.
+ */
+ mapped_base_format = map_flex_formats((uint32_t)base_format);
+
+ /* Validate the internal base format passed in */
+ switch (mapped_base_format)
+ {
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGBA_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGBX_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGB_888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGB_565:
+ case MALI_GRALLOC_FORMAT_INTERNAL_BGRA_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_YV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y8:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y16:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RAW16:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RAW12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RAW10:
+ case MALI_GRALLOC_FORMAT_INTERNAL_BLOB:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV21:
+ case MALI_GRALLOC_FORMAT_INTERNAL_YUV422_8BIT:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y0L2:
+ case MALI_GRALLOC_FORMAT_INTERNAL_P010:
+ case MALI_GRALLOC_FORMAT_INTERNAL_P210:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y210:
+ case MALI_GRALLOC_FORMAT_INTERNAL_Y410:
+ if (mapped_base_format != base_format)
+ {
+ internal_format = (internal_format & MALI_GRALLOC_INTFMT_EXT_MASK) | mapped_base_format;
+ }
+
+ break;
+
+ default:
+ ALOGE("Internal base format requested is unrecognized: %" PRIx64, internal_format);
+ internal_format = 0;
+ break;
+ }
- base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
-
- /* Even though private format allocations are intended to be for specific
- * formats, certain test cases uses the flexible formats that needs to be mapped
- * to internal ones.
- */
- mapped_base_format = map_flex_formats((uint32_t ) base_format, &ignore_mask);
-
- /* Validate the internal base format passed in */
- switch(mapped_base_format)
- {
- case MALI_GRALLOC_FORMAT_INTERNAL_RGBA_8888:
- case MALI_GRALLOC_FORMAT_INTERNAL_RGBX_8888:
- case MALI_GRALLOC_FORMAT_INTERNAL_RGB_888:
- case MALI_GRALLOC_FORMAT_INTERNAL_RGB_565:
- case MALI_GRALLOC_FORMAT_INTERNAL_BGRA_8888:
- case MALI_GRALLOC_FORMAT_INTERNAL_YV12:
- case MALI_GRALLOC_FORMAT_INTERNAL_Y8:
- case MALI_GRALLOC_FORMAT_INTERNAL_Y16:
- case MALI_GRALLOC_FORMAT_INTERNAL_RAW16:
- case MALI_GRALLOC_FORMAT_INTERNAL_RAW12:
- case MALI_GRALLOC_FORMAT_INTERNAL_RAW10:
- case MALI_GRALLOC_FORMAT_INTERNAL_BLOB:
- case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
- case MALI_GRALLOC_FORMAT_INTERNAL_NV21:
- case MALI_GRALLOC_FORMAT_INTERNAL_YUV422_8BIT:
- case MALI_GRALLOC_FORMAT_INTERNAL_Y0L2:
- case MALI_GRALLOC_FORMAT_INTERNAL_P010:
- case MALI_GRALLOC_FORMAT_INTERNAL_P210:
- case MALI_GRALLOC_FORMAT_INTERNAL_Y210:
- case MALI_GRALLOC_FORMAT_INTERNAL_Y410:
- if(mapped_base_format != base_format)
- {
- internal_format = (internal_format & MALI_GRALLOC_INTFMT_EXT_MASK) | mapped_base_format;
- }
- break;
-
- default:
- ALOGE("Internal base format requested is unrecognized: %" PRIx64 ,internal_format);
- internal_format = 0;
- break;
- }
out:
- return internal_format;
+ return internal_format;
}
-static bool determine_producer(mali_gralloc_producer_type *producer, uint64_t *producer_runtime_mask, int req_format, int usage)
+static bool determine_producer(mali_gralloc_producer_type *producer, uint64_t *producer_runtime_mask, int req_format,
+ int usage)
{
- bool rval = true;
-
- /* Default to GPU */
- *producer = MALI_GRALLOC_PRODUCER_GPU;
-
- if(usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
- {
- rval = false;
- }
- else if(usage & GRALLOC_USAGE_HW_RENDER)
- {
- if(is_android_yuv_format(req_format))
- {
- if(gpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOWRITE)
- {
- *producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
- }
- else
- {
- /* All GPUs that can write YUV AFBC can only do it in 16x16, optionally with tiled */
- *producer_runtime_mask &= ~(MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK | MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK);
- }
- }
- *producer = MALI_GRALLOC_PRODUCER_GPU;
- }
- else if(usage & GRALLOC_USAGE_HW_CAMERA_MASK)
- {
- *producer = MALI_GRALLOC_PRODUCER_CAMERA;
- }
- /* HW_TEXTURE+HW_COMPOSER+EXTERNAL_DISP is a definition set by
- * stagefright for "video decoder". We check for it here.
- */
- else if((usage & (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_EXTERNAL_DISP)) ==
- (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_EXTERNAL_DISP))
- {
- *producer = MALI_GRALLOC_PRODUCER_VIDEO_DECODER;
- }
-
- return rval;
+ bool rval = true;
+
+ /* Default to GPU */
+ *producer = MALI_GRALLOC_PRODUCER_GPU;
+
+ if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
+ {
+ rval = false;
+ }
+ else if (usage & GRALLOC_USAGE_HW_RENDER)
+ {
+ if (is_android_yuv_format(req_format))
+ {
+ if (gpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOWRITE)
+ {
+ *producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+ else
+ {
+ /* All GPUs that can write YUV AFBC can only do it in 16x16, optionally with tiled */
+ *producer_runtime_mask &=
+ ~(MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK | MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK);
+ }
+ }
+
+ *producer = MALI_GRALLOC_PRODUCER_GPU;
+ }
+ else if (usage & GRALLOC_USAGE_HW_CAMERA_MASK)
+ {
+ *producer = MALI_GRALLOC_PRODUCER_CAMERA;
+ }
+ /* HW_TEXTURE+HW_COMPOSER+EXTERNAL_DISP is a definition set by
+ * stagefright for "video decoder". We check for it here.
+ */
+ else if ((usage & (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_EXTERNAL_DISP)) ==
+ (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_EXTERNAL_DISP))
+ {
+ *producer = MALI_GRALLOC_PRODUCER_VIDEO_DECODER;
+ }
+
+ return rval;
}
-static bool determine_consumer(mali_gralloc_consumer_type *consumer, uint64_t *consumer_runtime_mask, int req_format, int usage)
+static bool determine_consumer(mali_gralloc_consumer_type *consumer, uint64_t *consumer_runtime_mask, int req_format,
+ int usage)
{
- bool rval = true;
-
- /* Default to GPU */
- *consumer = MALI_GRALLOC_CONSUMER_GPU_EXCL;
-
- if(usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
- {
- rval = false;
- }
- /* When usage explicitly targets a consumer, as it does with GRALLOC_USAGE_HW_FB,
- * we pick DPU even if there are no runtime capabilities present.
- */
- else if( usage & GRALLOC_USAGE_HW_FB )
- {
- *consumer = MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY;
- }
- else if(usage & GRALLOC_USAGE_HW_VIDEO_ENCODER)
- {
- if((vpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOREAD) &&
- is_android_yuv_format(req_format))
- {
- *consumer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
- }
- *consumer = MALI_GRALLOC_CONSUMER_VIDEO_ENCODER;
- }
- /* GRALLOC_USAGE_HW_COMPOSER is by default applied by SurfaceFlinger so we can't exclusively rely on it
- * to determine consumer. When a buffer is targeted for either we reject the DPU when it lacks
- * runtime capabilities, in favor of the more capable GPU.
- */
- else if((usage & (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER )) == (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER ) &&
- dpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT)
- {
- *consumer = MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY;
- }
- else if(usage & GRALLOC_USAGE_HW_TEXTURE)
- {
- *consumer = MALI_GRALLOC_CONSUMER_GPU_EXCL;
- }
- return rval;
+ bool rval = true;
+
+ /* Default to GPU */
+ *consumer = MALI_GRALLOC_CONSUMER_GPU_EXCL;
+
+ if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK))
+ {
+ rval = false;
+ }
+ /* When usage explicitly targets a consumer, as it does with GRALLOC_USAGE_HW_FB,
+ * we pick DPU even if there are no runtime capabilities present.
+ */
+ else if (usage & GRALLOC_USAGE_HW_FB)
+ {
+ *consumer = MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY;
+ }
+ else if (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER)
+ {
+ if (is_android_yuv_format(req_format))
+ {
+ if (vpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOREAD)
+ *consumer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+ else
+ {
+ *consumer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+ *consumer = MALI_GRALLOC_CONSUMER_VIDEO_ENCODER;
+ }
+ /* GRALLOC_USAGE_HW_COMPOSER is by default applied by SurfaceFlinger so we can't exclusively rely on it
+ * to determine consumer. When a buffer is targeted for either we reject the DPU when it lacks
+ * runtime capabilities, in favor of the more capable GPU.
+ */
+ else if ((usage & (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER)) ==
+ (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER) &&
+ dpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT)
+ {
+ *consumer = MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY;
+ }
+ else if (usage & GRALLOC_USAGE_HW_TEXTURE)
+ {
+ *consumer = MALI_GRALLOC_CONSUMER_GPU_EXCL;
+ }
+
+ return rval;
}
/*
@@ -457,196 +496,201 @@ static bool determine_consumer(mali_gralloc_consumer_type *consumer, uint64_t *c
*/
static void determine_format_capabilities()
{
- /* Loading libraries can take some time and
- * we may see many allocations at boot.
- */
- pthread_mutex_lock(&caps_init_mutex);
-
- if(runtime_caps_read)
- {
- goto already_init;
- }
-
- memset((void*) &dpu_runtime_caps,0,sizeof(dpu_runtime_caps));
- memset((void*) &vpu_runtime_caps,0,sizeof(vpu_runtime_caps));
- memset((void*) &gpu_runtime_caps,0,sizeof(gpu_runtime_caps));
- memset((void*) &cam_runtime_caps,0,sizeof(cam_runtime_caps));
-
- /* Determine DPU format capabilities */
- if(!get_block_capabilities(true, "hwcomposer", &dpu_runtime_caps))
- {
+ /* Loading libraries can take some time and
+ * we may see many allocations at boot.
+ */
+ pthread_mutex_lock(&caps_init_mutex);
+
+ if (runtime_caps_read)
+ {
+ goto already_init;
+ }
+
+ memset((void *)&dpu_runtime_caps, 0, sizeof(dpu_runtime_caps));
+ memset((void *)&vpu_runtime_caps, 0, sizeof(vpu_runtime_caps));
+ memset((void *)&gpu_runtime_caps, 0, sizeof(gpu_runtime_caps));
+ memset((void *)&cam_runtime_caps, 0, sizeof(cam_runtime_caps));
+
+ /* Determine DPU format capabilities */
+ if (!get_block_capabilities(true, "hwcomposer", &dpu_runtime_caps))
+ {
#if MALI_DISPLAY_VERSION >= 500
- dpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT;
- dpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC;
+ dpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT;
+ dpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC;
#if MALI_DISPLAY_VERSION >= 550
- dpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK;
+ dpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK;
#endif
#endif
- }
-
- /* Determine GPU format capabilities */
- if(access(MALI_GRALLOC_GPU_LIBRARY_PATH1 MALI_GRALLOC_GPU_LIB_NAME,R_OK) == 0)
- {
- get_block_capabilities(false, MALI_GRALLOC_GPU_LIBRARY_PATH1 MALI_GRALLOC_GPU_LIB_NAME, &gpu_runtime_caps);
- }
- else if(access(MALI_GRALLOC_GPU_LIBRARY_PATH2 MALI_GRALLOC_GPU_LIB_NAME,R_OK) == 0)
- {
- get_block_capabilities(false, MALI_GRALLOC_GPU_LIBRARY_PATH2 MALI_GRALLOC_GPU_LIB_NAME, &gpu_runtime_caps);
- }
-
- if((gpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT) == 0)
- {
- ALOGW("Failed to find GPU block configuration in %s. Using static build configuration.", MALI_GRALLOC_GPU_LIB_NAME);
+ }
+
+ /* Determine GPU format capabilities */
+ if (access(MALI_GRALLOC_GPU_LIBRARY_PATH1 MALI_GRALLOC_GPU_LIB_NAME, R_OK) == 0)
+ {
+ get_block_capabilities(false, MALI_GRALLOC_GPU_LIBRARY_PATH1 MALI_GRALLOC_GPU_LIB_NAME, &gpu_runtime_caps);
+ }
+ else if (access(MALI_GRALLOC_GPU_LIBRARY_PATH2 MALI_GRALLOC_GPU_LIB_NAME, R_OK) == 0)
+ {
+ get_block_capabilities(false, MALI_GRALLOC_GPU_LIBRARY_PATH2 MALI_GRALLOC_GPU_LIB_NAME, &gpu_runtime_caps);
+ }
+
+ if ((gpu_runtime_caps.caps_mask & MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT) == 0)
+ {
+ ALOGW("Failed to find GPU block configuration in %s. Using static build configuration.",
+ MALI_GRALLOC_GPU_LIB_NAME);
#if MALI_GPU_SUPPORT_AFBC_BASIC == 1
- gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT;
- gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC;
- /* Need to verify when to remove this */
- gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOWRITE;
+ /* Need to verify when to remove this */
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOWRITE;
#if MALI_SUPPORT_AFBC_SPLITBLK == 1
- gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK;
#endif
#if MALI_SUPPORT_AFBC_WIDEBLK == 1
- gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK;
- gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK;
#endif
#if MALI_USE_YUV_AFBC_WIDEBLK != 1
- gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK_YUV_DISABLE;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK_YUV_DISABLE;
#endif
#if MALI_SUPPORT_AFBC_TILED_HEADERS == 1
- gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK;
- gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK;
- gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK;
+ gpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS;
#endif
#endif /* MALI_GPU_SUPPORT_AFBC_BASIC == 1 */
- }
+ }
- /* Determine VPU format capabilities */
+/* Determine VPU format capabilities */
#if MALI_VIDEO_VERSION == 500 || MALI_VIDEO_VERSION == 550
- vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT;
- vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC;
- vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOREAD;
+ vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT;
+ vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC;
+ vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOREAD;
#endif
#if MALI_VIDEO_VERSION == 61
- vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT;
- vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC;
- vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS;
+ vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT;
+ vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC;
+ vpu_runtime_caps.caps_mask |= MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS;
#endif
-
- /* Build specific capability changes */
+/* Build specific capability changes */
#if GRALLOC_ARM_NO_EXTERNAL_AFBC == 1
- {
- dpu_runtime_caps.caps_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
- gpu_runtime_caps.caps_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
- vpu_runtime_caps.caps_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
- cam_runtime_caps.caps_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
- }
+ {
+ dpu_runtime_caps.caps_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ gpu_runtime_caps.caps_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ vpu_runtime_caps.caps_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ cam_runtime_caps.caps_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
#endif
- runtime_caps_read = true;
+ runtime_caps_read = true;
already_init:
- pthread_mutex_unlock(&caps_init_mutex);
+ pthread_mutex_unlock(&caps_init_mutex);
- ALOGV("GPU format capabilities 0x%" PRIx64 , gpu_runtime_caps.caps_mask);
- ALOGV("DPU format capabilities 0x%" PRIx64 , dpu_runtime_caps.caps_mask);
- ALOGV("VPU format capabilities 0x%" PRIx64 , vpu_runtime_caps.caps_mask);
- ALOGV("CAM format capabilities 0x%" PRIx64 , cam_runtime_caps.caps_mask);
+ ALOGV("GPU format capabilities 0x%" PRIx64, gpu_runtime_caps.caps_mask);
+ ALOGV("DPU format capabilities 0x%" PRIx64, dpu_runtime_caps.caps_mask);
+ ALOGV("VPU format capabilities 0x%" PRIx64, vpu_runtime_caps.caps_mask);
+ ALOGV("CAM format capabilities 0x%" PRIx64, cam_runtime_caps.caps_mask);
}
-uint64_t mali_gralloc_select_format(int req_format, int usage, int buffer_size)
+uint64_t mali_gralloc_select_format(uint64_t req_format, mali_gralloc_format_type type, uint64_t usage, int buffer_size)
{
- uint64_t internal_format = 0;
- mali_gralloc_consumer_type consumer;
- mali_gralloc_producer_type producer;
- uint64_t producer_runtime_mask = ~(0ULL);
- uint64_t consumer_runtime_mask = ~(0ULL);
- int req_format_mapped=0;
-
- if(!runtime_caps_read)
- {
- /*
- * It is better to initialize these when needed because
- * not all processes allocates memory.
- */
- determine_format_capabilities();
- }
-
- /* A unique usage specifies that an internal format is in req_format */
- if(usage & MALI_GRALLOC_USAGE_PRIVATE_FORMAT)
- {
- internal_format = decode_internal_format(req_format);
- goto out;
- }
-
- /* Re-map special Android formats */
- req_format_mapped = map_flex_formats(req_format, &producer_runtime_mask);
-
- /* Determine producer/consumer */
- if(!determine_producer(&producer, &producer_runtime_mask, req_format, usage) ||
- !determine_consumer(&consumer, &consumer_runtime_mask, req_format, usage))
- {
- /* Failing to determine producer/consumer usually means
- * client has requested sw rendering.
- */
- internal_format = req_format_mapped;
- goto out;
- }
-
- /*
- * Determine runtime capability limitations
- */
-
- /* Disable AFBC based on unique usage */
- if ((usage & MALI_GRALLOC_USAGE_NO_AFBC) == MALI_GRALLOC_USAGE_NO_AFBC)
- {
- if(is_android_yuv_format(req_format_mapped))
- {
- ALOGE("It is invalid to specify NO_AFBC usage flags when allocating YUV formats.\
- Requested fmt: 0x%08X Re-Mapped fmt: 0x%08X",req_format,req_format_mapped);
- internal_format = 0;
- goto out;
- }
- producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
- }
- /* Disable AFBC based on buffer dimensions */
- else if(!is_afbc_allowed(buffer_size))
- {
- producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
- }
- else if(!is_afbc_supported(req_format_mapped))
- {
- producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
- }
-
- /* Automatically select format in case producer/consumer identified */
- internal_format = determine_best_format(req_format_mapped, producer, consumer, producer_runtime_mask, consumer_runtime_mask);
+ uint64_t internal_format = 0;
+ mali_gralloc_consumer_type consumer;
+ mali_gralloc_producer_type producer;
+ uint64_t producer_runtime_mask = ~(0ULL);
+ uint64_t consumer_runtime_mask = ~(0ULL);
+ uint64_t req_format_mapped = 0;
+
+ if (!runtime_caps_read)
+ {
+ /*
+ * It is better to initialize these when needed because
+ * not all processes allocates memory.
+ */
+ determine_format_capabilities();
+ }
+
+ /* A unique usage specifies that an internal format is in req_format */
+ if (usage & MALI_GRALLOC_USAGE_PRIVATE_FORMAT || type == MALI_GRALLOC_FORMAT_TYPE_INTERNAL)
+ {
+ internal_format = decode_internal_format(req_format, type);
+ goto out;
+ }
+
+ /* Re-map special Android formats */
+ req_format_mapped = map_flex_formats(req_format);
+
+ /* Determine producer/consumer */
+ if (!determine_producer(&producer, &producer_runtime_mask, req_format, usage) ||
+ !determine_consumer(&consumer, &consumer_runtime_mask, req_format, usage))
+ {
+ /* Failing to determine producer/consumer usually means
+ * client has requested sw rendering.
+ */
+ internal_format = req_format_mapped;
+ goto out;
+ }
+
+ /*
+ * Determine runtime capability limitations
+ */
+
+ /* Disable AFBC based on unique usage */
+ if ((usage & MALI_GRALLOC_USAGE_NO_AFBC) == MALI_GRALLOC_USAGE_NO_AFBC)
+ {
+ if (is_android_yuv_format(req_format_mapped))
+ {
+ ALOGE("It is invalid to specify NO_AFBC usage flags when allocating YUV formats.\
+ Requested fmt: 0x%" PRIx64 " Re-Mapped fmt: 0x%" PRIx64,
+ req_format, req_format_mapped);
+ internal_format = 0;
+ goto out;
+ }
+
+ producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+ /* Disable AFBC based on buffer dimensions */
+ else if (!is_afbc_allowed(buffer_size))
+ {
+ producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+ else if (!is_afbc_supported(req_format_mapped))
+ {
+ producer_runtime_mask &= ~MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK;
+ }
+
+ /* Automatically select format in case producer/consumer identified */
+ internal_format =
+ determine_best_format(req_format_mapped, producer, consumer, producer_runtime_mask, consumer_runtime_mask);
out:
- ALOGV("mali_gralloc_select_format: req_format=0x%08X req_fmt_mapped=0x%08X internal_format=0x%" PRIx64 " usage=0x%08X",req_format, req_format_mapped, internal_format, usage);
+ ALOGV("mali_gralloc_select_format: req_format=0x%08" PRIx64 " req_fmt_mapped=0x%" PRIx64
+ " internal_format=0x%" PRIx64 " usage=0x%" PRIx64,
+ req_format, req_format_mapped, internal_format, usage);
- return internal_format;
+ return internal_format;
}
-extern "C"
-{
+extern "C" {
void mali_gralloc_get_gpu_caps(struct mali_gralloc_format_caps *gpu_caps)
{
- if(gpu_caps != NULL)
- {
- if(!runtime_caps_read)
- {
- determine_format_capabilities();
- }
- memcpy(gpu_caps,(void*) &gpu_runtime_caps,sizeof(struct mali_gralloc_format_caps));
- }
+ if (gpu_caps != NULL)
+ {
+ if (!runtime_caps_read)
+ {
+ determine_format_capabilities();
+ }
+
+ memcpy(gpu_caps, (void *)&gpu_runtime_caps, sizeof(struct mali_gralloc_format_caps));
+ }
}
}
diff --git a/gralloc960/mali_gralloc_formats.h b/gralloc960/mali_gralloc_formats.h
index 5b893b43..928dc2ab 100644
--- a/gralloc960/mali_gralloc_formats.h
+++ b/gralloc960/mali_gralloc_formats.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 ARM Limited. All rights reserved.
+ * Copyright (C) 2016-2017 ARM Limited. All rights reserved.
*
* Copyright (C) 2008 The Android Open Source Project
*
@@ -30,10 +30,10 @@
typedef uint64_t mali_gralloc_internal_format;
/* Internal format masks */
-#define MALI_GRALLOC_INTFMT_FMT_MASK 0x00000000ffffffffULL
-#define MALI_GRALLOC_INTFMT_EXT_MASK 0xffffffff00000000ULL
-#define MALI_GRALLOC_INTFMT_ME_EXT_MASK 0x0000ffff00000000ULL
-#define MALI_GRALLOC_INTFMT_REG_EXT_MASK 0xffff000000000000ULL
+#define MALI_GRALLOC_INTFMT_FMT_MASK 0x00000000ffffffffULL
+#define MALI_GRALLOC_INTFMT_EXT_MASK 0xffffffff00000000ULL
+#define MALI_GRALLOC_INTFMT_ME_EXT_MASK 0x0000ffff00000000ULL
+#define MALI_GRALLOC_INTFMT_REG_EXT_MASK 0xffff000000000000ULL
/* Internal base formats */
@@ -44,85 +44,84 @@ typedef uint64_t mali_gralloc_internal_format;
typedef enum
{
- /* Internal definitions for HAL formats. */
- MALI_GRALLOC_FORMAT_INTERNAL_RGBA_8888 = HAL_PIXEL_FORMAT_RGBA_8888,
- MALI_GRALLOC_FORMAT_INTERNAL_RGBX_8888 = HAL_PIXEL_FORMAT_RGBX_8888,
- MALI_GRALLOC_FORMAT_INTERNAL_RGB_888 = HAL_PIXEL_FORMAT_RGB_888,
- MALI_GRALLOC_FORMAT_INTERNAL_RGB_565 = HAL_PIXEL_FORMAT_RGB_565 ,
- MALI_GRALLOC_FORMAT_INTERNAL_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888,
- MALI_GRALLOC_FORMAT_INTERNAL_YV12 = HAL_PIXEL_FORMAT_YV12 ,
- MALI_GRALLOC_FORMAT_INTERNAL_Y8 = HAL_PIXEL_FORMAT_Y8,
- MALI_GRALLOC_FORMAT_INTERNAL_Y16 = HAL_PIXEL_FORMAT_Y16,
- MALI_GRALLOC_FORMAT_INTERNAL_YUV420_888 = HAL_PIXEL_FORMAT_YCbCr_420_888,
-
- /* Camera specific HAL formats */
- MALI_GRALLOC_FORMAT_INTERNAL_RAW16 = HAL_PIXEL_FORMAT_RAW16,
- MALI_GRALLOC_FORMAT_INTERNAL_RAW12 = HAL_PIXEL_FORMAT_RAW12,
- MALI_GRALLOC_FORMAT_INTERNAL_RAW10 = HAL_PIXEL_FORMAT_RAW10,
- MALI_GRALLOC_FORMAT_INTERNAL_BLOB = HAL_PIXEL_FORMAT_BLOB,
-
- /* Flexible YUV formats would be parsed but not have any representation as
+ MALI_GRALLOC_FORMAT_TYPE_USAGE,
+ MALI_GRALLOC_FORMAT_TYPE_INTERNAL,
+} mali_gralloc_format_type;
+
+typedef enum
+{
+ /* Internal definitions for HAL formats. */
+ MALI_GRALLOC_FORMAT_INTERNAL_RGBA_8888 = HAL_PIXEL_FORMAT_RGBA_8888,
+ MALI_GRALLOC_FORMAT_INTERNAL_RGBX_8888 = HAL_PIXEL_FORMAT_RGBX_8888,
+ MALI_GRALLOC_FORMAT_INTERNAL_RGB_888 = HAL_PIXEL_FORMAT_RGB_888,
+ MALI_GRALLOC_FORMAT_INTERNAL_RGB_565 = HAL_PIXEL_FORMAT_RGB_565,
+ MALI_GRALLOC_FORMAT_INTERNAL_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888,
+ MALI_GRALLOC_FORMAT_INTERNAL_YV12 = HAL_PIXEL_FORMAT_YV12,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y8 = HAL_PIXEL_FORMAT_Y8,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y16 = HAL_PIXEL_FORMAT_Y16,
+ MALI_GRALLOC_FORMAT_INTERNAL_YUV420_888 = HAL_PIXEL_FORMAT_YCbCr_420_888,
+
+ /* Camera specific HAL formats */
+ MALI_GRALLOC_FORMAT_INTERNAL_RAW16 = HAL_PIXEL_FORMAT_RAW16,
+ MALI_GRALLOC_FORMAT_INTERNAL_RAW12 = HAL_PIXEL_FORMAT_RAW12,
+ MALI_GRALLOC_FORMAT_INTERNAL_RAW10 = HAL_PIXEL_FORMAT_RAW10,
+ MALI_GRALLOC_FORMAT_INTERNAL_BLOB = HAL_PIXEL_FORMAT_BLOB,
+
+ /* Flexible YUV formats would be parsed but not have any representation as
* internal format itself but one of the ones below
*/
- /* The internal private formats that have no HAL equivivalent are defined
+ /* The internal private formats that have no HAL equivivalent are defined
* afterwards starting at a specific base range */
- MALI_GRALLOC_FORMAT_INTERNAL_NV12 = MALI_GRALLOC_FORMAT_INTERNAL_RANGE_BASE,
- MALI_GRALLOC_FORMAT_INTERNAL_NV21,
- MALI_GRALLOC_FORMAT_INTERNAL_YUV422_8BIT,
+ MALI_GRALLOC_FORMAT_INTERNAL_NV12 = MALI_GRALLOC_FORMAT_INTERNAL_RANGE_BASE,
+ MALI_GRALLOC_FORMAT_INTERNAL_NV21,
+ MALI_GRALLOC_FORMAT_INTERNAL_YUV422_8BIT,
- /* Extended YUV formats
+ /* Extended YUV formats
*
* NOTE: P010, P210, and Y410 are only supported uncompressed.
*/
- MALI_GRALLOC_FORMAT_INTERNAL_Y0L2,
- MALI_GRALLOC_FORMAT_INTERNAL_P010,
- MALI_GRALLOC_FORMAT_INTERNAL_P210,
- MALI_GRALLOC_FORMAT_INTERNAL_Y210,
- MALI_GRALLOC_FORMAT_INTERNAL_Y410,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y0L2,
+ MALI_GRALLOC_FORMAT_INTERNAL_P010,
+ MALI_GRALLOC_FORMAT_INTERNAL_P210,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y210,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y410,
- /* Add more internal formats here. Make sure decode_internal_format() is updated. */
+ /* Add more internal formats here. Make sure decode_internal_format() is updated. */
- /* These are legacy 0.3 gralloc formats used only by the wrap/unwrap macros. */
- MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP,
- MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP,
- MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP,
+ /* These are legacy 0.3 gralloc formats used only by the wrap/unwrap macros. */
+ MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP,
+ MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP,
MALI_GRALLOC_FORMAT_INTERNAL_RANGE_LAST,
} mali_gralloc_pixel_format;
-
/* Format Modifier Bits Locations */
-#define MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START 32
-#define MALI_GRALLOC_INTFMT_EXTENSION_BIT_START (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START+16)
+#define MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START 32
+#define MALI_GRALLOC_INTFMT_EXTENSION_BIT_START (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START + 16)
/* Mutually Exclusive Modifier Bits */
/* This format will use AFBC */
-#define MALI_GRALLOC_INTFMT_AFBC_BASIC (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START+0))
+#define MALI_GRALLOC_INTFMT_AFBC_BASIC (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START + 0))
/* This format uses AFBC split block mode */
-#define MALI_GRALLOC_INTFMT_AFBC_SPLITBLK (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START+1))
+#define MALI_GRALLOC_INTFMT_AFBC_SPLITBLK (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START + 1))
-#define MALI_GRALLOC_INTFMT_UNUSED (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START+2))
+#define MALI_GRALLOC_INTFMT_UNUSED (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START + 2))
/* This format uses AFBC wide block mode */
-#define MALI_GRALLOC_INTFMT_AFBC_WIDEBLK (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START+3))
-
+#define MALI_GRALLOC_INTFMT_AFBC_WIDEBLK (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START + 3))
/* Regular Modifier Bits */
-#define MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS (1ULL << (MALI_GRALLOC_INTFMT_EXTENSION_BIT_START+0))
-
+#define MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS (1ULL << (MALI_GRALLOC_INTFMT_EXTENSION_BIT_START + 0))
/* This mask should be used to check or clear support for AFBC for an internal format
* These bits are mutually exclusive so this mask should not be used to enable support
*/
-#define MALI_GRALLOC_INTFMT_AFBCENABLE_MASK ((uint64_t) (MALI_GRALLOC_INTFMT_AFBC_BASIC | \
- MALI_GRALLOC_INTFMT_AFBC_SPLITBLK | \
- MALI_GRALLOC_INTFMT_AFBC_WIDEBLK))
-
-/* Prototypes */
-uint64_t mali_gralloc_select_format(int req_format,int usage, int buffer_size);
+#define MALI_GRALLOC_INTFMT_AFBCENABLE_MASK \
+ ((uint64_t)(MALI_GRALLOC_INTFMT_AFBC_BASIC | MALI_GRALLOC_INTFMT_AFBC_SPLITBLK | MALI_GRALLOC_INTFMT_AFBC_WIDEBLK))
/* These are legacy Gralloc 0.3 support macros for passing private formats through the 0.3 alloc interface.
* It packs modifier bits together with base format into a 32 bit format identifier.
@@ -136,78 +135,83 @@ uint64_t mali_gralloc_select_format(int req_format,int usage, int buffer_size);
*/
static inline int mali_gralloc_format_wrapper(int format, int modifiers)
{
- /* Internal formats that are identical to HAL formats
- * have the same definition. This is convenient for
- * client parsing code to not have to parse them separately.
- *
- * For 3 of the HAL YUV formats that have very large definitions
- * this causes problems for packing in modifier bits.
- * Because of this reason we redefine these three formats
- * while packing/unpacking them.
- */
- if(format == MALI_GRALLOC_FORMAT_INTERNAL_YV12)
- {
- format = MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP;
- }
- else if(format == MALI_GRALLOC_FORMAT_INTERNAL_Y8)
- {
- format = MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP;
- }
- else if(format == MALI_GRALLOC_FORMAT_INTERNAL_Y16)
- {
- format = MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP;
- }
- return (modifiers | format);
+ /* Internal formats that are identical to HAL formats
+ * have the same definition. This is convenient for
+ * client parsing code to not have to parse them separately.
+ *
+ * For 3 of the HAL YUV formats that have very large definitions
+ * this causes problems for packing in modifier bits.
+ * Because of this reason we redefine these three formats
+ * while packing/unpacking them.
+ */
+ if (format == MALI_GRALLOC_FORMAT_INTERNAL_YV12)
+ {
+ format = MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP;
+ }
+ else if (format == MALI_GRALLOC_FORMAT_INTERNAL_Y8)
+ {
+ format = MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP;
+ }
+ else if (format == MALI_GRALLOC_FORMAT_INTERNAL_Y16)
+ {
+ format = MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP;
+ }
+
+ return (modifiers | format);
}
static inline uint64_t mali_gralloc_format_unwrap(int x)
{
- uint64_t internal_format = (uint64_t) ( ((((uint64_t)(x)) & 0xff000000) << 24) | // Regular modifier bits
- ((((uint64_t)(x)) & 0x00ff0000) << 16) | // Mutually exclusive modifier bits
- (((uint64_t)(x)) & 0x0000ffff) ); // Private format
-
- uint64_t base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
- uint64_t modifiers = internal_format & MALI_GRALLOC_INTFMT_EXT_MASK;
-
- if(base_format == MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP)
- {
- base_format = MALI_GRALLOC_FORMAT_INTERNAL_YV12;
- }
- else if(base_format == MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP)
- {
- base_format = MALI_GRALLOC_FORMAT_INTERNAL_Y8;
- }
- else if(base_format == MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP)
- {
- base_format = MALI_GRALLOC_FORMAT_INTERNAL_Y16;
- }
- return (modifiers | base_format);
+ uint64_t internal_format = (uint64_t)(((((uint64_t)(x)) & 0xff000000) << 24) | // Regular modifier bits
+ ((((uint64_t)(x)) & 0x00ff0000) << 16) | // Mutually exclusive modifier bits
+ (((uint64_t)(x)) & 0x0000ffff)); // Private format
+
+ uint64_t base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
+ uint64_t modifiers = internal_format & MALI_GRALLOC_INTFMT_EXT_MASK;
+
+ if (base_format == MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP)
+ {
+ base_format = MALI_GRALLOC_FORMAT_INTERNAL_YV12;
+ }
+ else if (base_format == MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP)
+ {
+ base_format = MALI_GRALLOC_FORMAT_INTERNAL_Y8;
+ }
+ else if (base_format == MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP)
+ {
+ base_format = MALI_GRALLOC_FORMAT_INTERNAL_Y16;
+ }
+
+ return (modifiers | base_format);
}
-#define GRALLOC_PRIVATE_FORMAT_WRAPPER(x) ( mali_gralloc_format_wrapper(x, 0) )
-#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC(x) ( mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_BASIC >> 16)) )
-#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_SPLITBLK(x) ( mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_SPLITBLK >> 16)) )
-#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_WIDEBLK(x) ( mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> 16)) )
-#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_HEADERS_BASIC(x) ( mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> 24) | \
- (MALI_GRALLOC_INTFMT_AFBC_BASIC >> 16)))
-#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_HEADERS_WIDE(x) ( mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> 24) | \
- (MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> 16)))
-#define GRALLOC_PRIVATE_FORMAT_UNWRAP(x) mali_gralloc_format_unwrap(x)
+#define GRALLOC_PRIVATE_FORMAT_WRAPPER(x) (mali_gralloc_format_wrapper(x, 0))
+#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC(x) (mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_BASIC >> 16)))
+#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_SPLITBLK(x) \
+ (mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_SPLITBLK >> 16)))
+#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_WIDEBLK(x) \
+ (mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> 16)))
+#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_HEADERS_BASIC(x) \
+ (mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> 24) | \
+ (MALI_GRALLOC_INTFMT_AFBC_BASIC >> 16)))
+#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_HEADERS_WIDE(x) \
+ (mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> 24) | \
+ (MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> 16)))
+#define GRALLOC_PRIVATE_FORMAT_UNWRAP(x) mali_gralloc_format_unwrap(x)
/* IP block capability masks */
-#define MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT ((uint64_t) (1 << 0))
-#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC ((uint64_t) (1 << 1))
-#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK ((uint64_t) (1 << 2))
-#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK ((uint64_t) (1 << 3))
-#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK_YUV_DISABLE ((uint64_t) (1 << 4))
-#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOREAD ((uint64_t) (1 << 5))
-#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOWRITE ((uint64_t) (1 << 6))
-#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS ((uint64_t) (1 << 7))
-
-#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK ((uint64_t) (MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC | \
- MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK | \
- MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK | \
- MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT ((uint64_t)(1 << 0))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC ((uint64_t)(1 << 1))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK ((uint64_t)(1 << 2))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK ((uint64_t)(1 << 3))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK_YUV_DISABLE ((uint64_t)(1 << 4))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOREAD ((uint64_t)(1 << 5))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOWRITE ((uint64_t)(1 << 6))
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS ((uint64_t)(1 << 7))
+
+#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK \
+ ((uint64_t)(MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC | MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK | \
+ MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK | MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS))
struct mali_gralloc_format_caps
{
@@ -215,8 +219,8 @@ struct mali_gralloc_format_caps
};
typedef struct mali_gralloc_format_caps mali_gralloc_format_caps;
-#define MALI_GRALLOC_FORMATCAPS_SYM_NAME mali_gralloc_format_capabilities
-#define MALI_GRALLOC_FORMATCAPS_SYM_NAME_STR "mali_gralloc_format_capabilities"
+#define MALI_GRALLOC_FORMATCAPS_SYM_NAME mali_gralloc_format_capabilities
+#define MALI_GRALLOC_FORMATCAPS_SYM_NAME_STR "mali_gralloc_format_capabilities"
/* Producer and Consumer definitions */
typedef enum
@@ -229,68 +233,30 @@ typedef enum
typedef enum
{
- /* For surface composition in SurfaceFlinger a producer
+ /* For surface composition in SurfaceFlinger a producer
* will not know what consumer will process a buffer.
*
* MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY means the GPU
* MUST support the given format but it should be allocated
* with preference to the DPU.
*/
- MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY,
- MALI_GRALLOC_CONSUMER_VIDEO_ENCODER,
-
+ MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY,
+ MALI_GRALLOC_CONSUMER_VIDEO_ENCODER,
- /* This is used when no known "premium" dpu is configured.
+ /* This is used when no known "premium" dpu is configured.
* For example, HDLCD/CLCD would be such a dpu.
*/
- MALI_GRALLOC_CONSUMER_GPU_EXCL,
+ MALI_GRALLOC_CONSUMER_GPU_EXCL,
} mali_gralloc_consumer_type;
-
-/*
- * Below usage types overlap, this is intentional.
- * The reason is that for Gralloc 0.3 there are very
- * few usage flags we have at our disposal.
- *
- * The overlapping is handled by processing the definitions
- * in a specific order.
- *
- * MALI_GRALLOC_USAGE_PRIVATE_FORMAT and MALI_GRALLOC_USAGE_NO_AFBC
- * don't overlap and are processed first.
- *
- * MALI_GRALLOC_USAGE_YUV_CONF are only for YUV formats and clients
- * using MALI_GRALLOC_USAGE_NO_AFBC must never allocate YUV formats.
- * The latter is strictly enforced and allocations will fail.
- *
- * MALI_GRALLOC_USAGE_AFBC_PADDING is only valid if MALI_GRALLOC_USAGE_NO_AFBC
- * is not present.
- */
-typedef enum
-{
- /* The client has specified a private format in the format parameter */
- MALI_GRALLOC_USAGE_PRIVATE_FORMAT = (int) GRALLOC_USAGE_PRIVATE_3,
-
- /* Buffer won't be allocated as AFBC */
- MALI_GRALLOC_USAGE_NO_AFBC = (int) (GRALLOC_USAGE_PRIVATE_1 | GRALLOC_USAGE_PRIVATE_2),
-
- /* Valid only for YUV allocations */
- MALI_GRALLOC_USAGE_YUV_CONF_0 = 0,
- MALI_GRALLOC_USAGE_YUV_CONF_1 = (int) GRALLOC_USAGE_PRIVATE_1,
- MALI_GRALLOC_USAGE_YUV_CONF_2 = (int) GRALLOC_USAGE_PRIVATE_0,
- MALI_GRALLOC_USAGE_YUV_CONF_3 = (int) (GRALLOC_USAGE_PRIVATE_0 | GRALLOC_USAGE_PRIVATE_1),
- MALI_GRALLOC_USAGE_YUV_CONF_MASK = MALI_GRALLOC_USAGE_YUV_CONF_3,
-
- /* A very specific alignment is requested on some buffers */
- MALI_GRALLOC_USAGE_AFBC_PADDING = GRALLOC_USAGE_PRIVATE_2,
-
-} mali_gralloc_usage_type;
-
-/* Prototypes */
-uint64_t mali_gralloc_select_format(int req_format,int usage, int buffer_size);
+/* Internal prototypes */
+#if defined(GRALLOC_LIBRARY_BUILD)
+uint64_t mali_gralloc_select_format(uint64_t req_format, mali_gralloc_format_type type, uint64_t usage,
+ int buffer_size);
+#endif
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
void mali_gralloc_get_gpu_caps(struct mali_gralloc_format_caps *gpu_caps);
diff --git a/gralloc960/mali_gralloc_ion.cpp b/gralloc960/mali_gralloc_ion.cpp
new file mode 100644
index 00000000..63d9e18f
--- /dev/null
+++ b/gralloc960/mali_gralloc_ion.cpp
@@ -0,0 +1,770 @@
+/*
+ * Copyright (C) 2016-2017 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <cstdlib>
+#include <string.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <pthread.h>
+
+#include <log/log.h>
+#include <cutils/atomic.h>
+
+#include <linux/ion.h>
+#include <ion/ion.h>
+#include <sys/ioctl.h>
+
+#include <hardware/hardware.h>
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+
+#include "mali_gralloc_module.h"
+#include "mali_gralloc_private_interface_types.h"
+#include "mali_gralloc_buffer.h"
+#include "gralloc_helper.h"
+#include "framebuffer_device.h"
+#include "mali_gralloc_formats.h"
+#include "mali_gralloc_usages.h"
+#include "mali_gralloc_bufferdescriptor.h"
+#include "ion_4.12.h"
+
+
+
+#define ION_SYSTEM (char*)"ion_system_heap"
+#define ION_CMA (char*)"linux,cma"
+static bool gralloc_legacy_ion;
+static int system_heap_id;
+static int cma_heap_id;
+
+static void mali_gralloc_ion_free_internal(buffer_handle_t *pHandle, uint32_t num_hnds);
+
+static void init_afbc(uint8_t *buf, uint64_t internal_format, int w, int h)
+{
+ uint32_t n_headers = (w * h) / 256;
+ uint32_t body_offset = n_headers * 16;
+ uint32_t headers[][4] = {
+ { body_offset, 0x1, 0x10000, 0x0 }, /* Layouts 0, 3, 4 */
+ { (body_offset + (1 << 28)), 0x80200040, 0x1004000, 0x20080 } /* Layouts 1, 5 */
+ };
+ uint32_t i, layout;
+
+ /* For AFBC 1.2, header buffer can be initilized to 0 for Layouts 0, 3, 4 */
+ if (internal_format & MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS)
+ {
+ memset(headers[0], 0, sizeof(uint32_t) * 4);
+ }
+ /* map format if necessary (also removes internal extension bits) */
+ uint64_t base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
+
+ switch (base_format)
+ {
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGBA_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGBX_8888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGB_888:
+ case MALI_GRALLOC_FORMAT_INTERNAL_RGB_565:
+ case MALI_GRALLOC_FORMAT_INTERNAL_BGRA_8888:
+ layout = 0;
+ break;
+
+ case MALI_GRALLOC_FORMAT_INTERNAL_YV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV12:
+ case MALI_GRALLOC_FORMAT_INTERNAL_NV21:
+ layout = 1;
+ break;
+
+ default:
+ layout = 0;
+ }
+
+ ALOGV("Writing AFBC header layout %d for format %" PRIu64, layout, base_format);
+
+ for (i = 0; i < n_headers; i++)
+ {
+ memcpy(buf, headers[layout], sizeof(headers[layout]));
+ buf += sizeof(headers[layout]);
+ }
+}
+
+
+
+static int find_heap_id(int ion_client, char *name)
+{
+ int i, ret, cnt, heap_id = -1;
+ struct ion_heap_data *data;
+
+ ret = ion_query_heap_cnt(ion_client, &cnt);
+
+ if (ret)
+ {
+ AERR("ion count query failed with %s", strerror(errno));
+ return -1;
+ }
+
+ data = (struct ion_heap_data *)malloc(cnt * sizeof(*data));
+ if (!data)
+ {
+ AERR("Error allocating data %s\n", strerror(errno));
+ return -1;
+ }
+
+ ret = ion_query_get_heaps(ion_client, cnt, data);
+ if (ret)
+ {
+ AERR("Error querying heaps from ion %s", strerror(errno));
+ }
+ else
+ {
+ for (i = 0; i < cnt; i++) {
+ if (strcmp(data[i].name, name) == 0) {
+ heap_id = data[i].heap_id;
+ break;
+ }
+ }
+
+ if (i == cnt)
+ {
+ AERR("No %s Heap Found amongst %d heaps\n", name, cnt);
+ heap_id = -1;
+ }
+ }
+
+ free(data);
+ return heap_id;
+}
+
+
+static int alloc_from_ion_heap(int ion_fd, size_t size, unsigned int heap_mask, unsigned int flags, int *min_pgsz)
+{
+ ion_user_handle_t ion_hnd = -1;
+ int shared_fd, ret;
+
+ if ((ion_fd < 0) || (size <= 0) || (heap_mask == 0) || (min_pgsz == NULL))
+ {
+ return -1;
+ }
+
+ /**
+ * step 1: ion_alloc new ion_hnd
+ * step 2: ion_share from ion_hnd and get shared_fd
+ * step 3: ion free the given ion_hnd
+ * step 4: when we need to free this ion buffer, just close the shared_fd,
+ * kernel will count the reference of file struct, so it's safe to
+ * be transfered between processes.
+ */
+ ret = ion_alloc(ion_fd, size, 0, heap_mask, flags, &ion_hnd);
+
+ if (ret < 0)
+ {
+#if defined(ION_HEAP_SECURE_MASK)
+
+ if (heap_mask == ION_HEAP_SECURE_MASK)
+ {
+ return -1;
+ }
+ else
+#endif
+ {
+ /* If everything else failed try system heap */
+ flags = 0; /* Fallback option flags are not longer valid */
+ heap_mask = ION_HEAP_SYSTEM_MASK;
+ ret = ion_alloc(ion_fd, size, 0, heap_mask, flags, &ion_hnd);
+ }
+ }
+
+ ret = ion_share(ion_fd, ion_hnd, &shared_fd);
+
+ if (ret != 0)
+ {
+ AERR("ion_share( %d ) failed", ion_fd);
+ shared_fd = -1;
+ }
+
+ ret = ion_free(ion_fd, ion_hnd);
+
+ if (0 != ret)
+ {
+ AERR("ion_free( %d ) failed", ion_fd);
+ close(shared_fd);
+ shared_fd = -1;
+ }
+
+ if (ret >= 0)
+ {
+ switch (heap_mask)
+ {
+ case ION_HEAP_SYSTEM_MASK:
+ *min_pgsz = SZ_4K;
+ break;
+
+ case ION_HEAP_SYSTEM_CONTIG_MASK:
+ case ION_HEAP_CARVEOUT_MASK:
+#ifdef ION_HEAP_TYPE_DMA_MASK
+ case ION_HEAP_TYPE_DMA_MASK:
+#endif
+ *min_pgsz = size;
+ break;
+#ifdef ION_HEAP_CHUNK_MASK
+
+ /* NOTE: if have this heap make sure your ION chunk size is 2M*/
+ case ION_HEAP_CHUNK_MASK:
+ *min_pgsz = SZ_2M;
+ break;
+#endif
+#ifdef ION_HEAP_COMPOUND_PAGE_MASK
+
+ case ION_HEAP_COMPOUND_PAGE_MASK:
+ *min_pgsz = SZ_2M;
+ break;
+#endif
+/* If have customized heap please set the suitable pg type according to
+ * the customized ION implementation
+ */
+#ifdef ION_HEAP_CUSTOM_MASK
+
+ case ION_HEAP_CUSTOM_MASK:
+ *min_pgsz = SZ_4K;
+ break;
+#endif
+
+ default:
+ *min_pgsz = SZ_4K;
+ break;
+ }
+ }
+
+ return shared_fd;
+}
+
+unsigned int pick_ion_heap(uint64_t usage)
+{
+ unsigned int heap_mask;
+
+ if (usage & GRALLOC_USAGE_PROTECTED)
+ {
+#if defined(ION_HEAP_SECURE_MASK)
+ heap_mask = ION_HEAP_SECURE_MASK;
+#else
+ AERR("Protected ION memory is not supported on this platform.");
+ return 0;
+#endif
+ }
+
+#if defined(ION_HEAP_TYPE_COMPOUND_PAGE_MASK) && GRALLOC_USE_ION_COMPOUND_PAGE_HEAP
+ else if (!(usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) && (usage & (GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_COMPOSER)))
+ {
+ heap_mask = ION_HEAP_TYPE_COMPOUND_PAGE_MASK;
+ }
+
+#elif defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
+ else if (!(usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) && (usage & (GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_COMPOSER)))
+ {
+ heap_mask = ION_HEAP_TYPE_DMA_MASK;
+ }
+
+#endif
+ else
+ {
+ heap_mask = ION_HEAP_SYSTEM_MASK;
+ }
+
+ return heap_mask;
+}
+
+void set_ion_flags(unsigned int heap_mask, uint64_t usage, unsigned int *priv_heap_flag, int *ion_flags)
+{
+#if !GRALLOC_USE_ION_DMA_HEAP
+ GRALLOC_UNUSED(heap_mask);
+#endif
+
+ if (priv_heap_flag)
+ {
+#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
+
+ if (heap_mask == ION_HEAP_TYPE_DMA_MASK)
+ {
+ *priv_heap_flag = private_handle_t::PRIV_FLAGS_USES_ION_DMA_HEAP;
+ }
+
+#endif
+ }
+
+ if (ion_flags)
+ {
+#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
+
+ if (heap_mask != ION_HEAP_TYPE_DMA_MASK)
+ {
+#endif
+
+ if ((usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN)
+ {
+ *ion_flags = ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC;
+ }
+
+#if defined(ION_HEAP_TYPE_DMA_MASK) && GRALLOC_USE_ION_DMA_HEAP
+ }
+
+#endif
+ }
+}
+
+static bool check_buffers_sharable(const gralloc_buffer_descriptor_t *descriptors, uint32_t numDescriptors)
+{
+ unsigned int shared_backend_heap_mask = 0;
+ int shared_ion_flags = 0;
+ uint64_t usage;
+ uint32_t i;
+
+ if (numDescriptors <= 1)
+ {
+ return false;
+ }
+
+ for (i = 0; i < numDescriptors; i++)
+ {
+ unsigned int heap_mask;
+ int ion_flags;
+ buffer_descriptor_t *bufDescriptor = (buffer_descriptor_t *)descriptors[i];
+
+ usage = bufDescriptor->consumer_usage | bufDescriptor->producer_usage;
+ heap_mask = pick_ion_heap(usage);
+
+ if (0 == heap_mask)
+ {
+ return false;
+ }
+
+ set_ion_flags(heap_mask, usage, NULL, &ion_flags);
+
+ if (0 != shared_backend_heap_mask)
+ {
+ if (shared_backend_heap_mask != heap_mask || shared_ion_flags != ion_flags)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ shared_backend_heap_mask = heap_mask;
+ shared_ion_flags = ion_flags;
+ }
+ }
+
+ return true;
+}
+
+static int get_max_buffer_descriptor_index(const gralloc_buffer_descriptor_t *descriptors, uint32_t numDescriptors)
+{
+ uint32_t i, max_buffer_index = 0;
+ size_t max_buffer_size = 0;
+
+ for (i = 0; i < numDescriptors; i++)
+ {
+ buffer_descriptor_t *bufDescriptor = (buffer_descriptor_t *)descriptors[i];
+
+ if (max_buffer_size < bufDescriptor->size)
+ {
+ max_buffer_index = i;
+ max_buffer_size = bufDescriptor->size;
+ }
+ }
+
+ return max_buffer_index;
+}
+
+int mali_gralloc_ion_allocate(mali_gralloc_module *m, const gralloc_buffer_descriptor_t *descriptors,
+ uint32_t numDescriptors, buffer_handle_t *pHandle, bool *shared_backend)
+{
+ static int support_protected = 1; /* initially, assume we support protected memory */
+ unsigned int heap_mask, priv_heap_flag = 0;
+ unsigned char *cpu_ptr = NULL;
+ uint64_t usage;
+ uint32_t i, max_buffer_index = 0;
+ int shared_fd, ret, ion_flags = 0;
+ int min_pgsz = 0;
+
+ if (m->ion_client < 0)
+ {
+ m->ion_client = ion_open();
+
+ if (m->ion_client < 0)
+ {
+ AERR("ion_open failed with %s", strerror(errno));
+ return -1;
+ }
+
+ gralloc_legacy_ion = ion_is_legacy(m->ion_client);
+ if (!gralloc_legacy_ion)
+ {
+ system_heap_id = find_heap_id(m->ion_client, ION_SYSTEM);
+ cma_heap_id = find_heap_id(m->ion_client, ION_CMA);
+ if (system_heap_id < 0)
+ {
+ ion_close(m->ion_client);
+ m->ion_client = -1;
+ AERR( "ion_open failed: no system heap found" );
+ return -1;
+ }
+ if (cma_heap_id < 0) {
+ AERR("No cma heap found, falling back to system");
+ cma_heap_id = system_heap_id;
+ }
+ }
+ }
+
+ *shared_backend = check_buffers_sharable(descriptors, numDescriptors);
+
+ if (*shared_backend)
+ {
+ buffer_descriptor_t *max_bufDescriptor;
+
+ max_buffer_index = get_max_buffer_descriptor_index(descriptors, numDescriptors);
+ max_bufDescriptor = (buffer_descriptor_t *)(descriptors[max_buffer_index]);
+ usage = max_bufDescriptor->consumer_usage | max_bufDescriptor->producer_usage;
+
+ heap_mask = pick_ion_heap(usage);
+
+ if (heap_mask == 0)
+ {
+ AERR("Failed to find an appropriate ion heap");
+ return -1;
+ }
+
+ set_ion_flags(heap_mask, usage, &priv_heap_flag, &ion_flags);
+ if (gralloc_legacy_ion)
+ {
+ shared_fd = alloc_from_ion_heap(m->ion_client, max_bufDescriptor->size, heap_mask, ion_flags, &min_pgsz);
+ }
+ else
+ {
+ int heap = 1 << system_heap_id;
+ if (heap_mask == ION_HEAP_TYPE_DMA_MASK)
+ heap = 1 << cma_heap_id;
+
+ ret = ion_alloc_fd(m->ion_client, max_bufDescriptor->size, 0, heap, 0, &(shared_fd));
+ if (ret != 0)
+ {
+ AERR("Failed to ion_alloc_fd from ion_client:%d", m->ion_client);
+ return -1;
+ }
+ min_pgsz = SZ_4K;
+ }
+
+ if (shared_fd < 0)
+ {
+ AERR("ion_alloc failed form client: ( %d )", m->ion_client);
+ return -1;
+ }
+
+ for (i = 0; i < numDescriptors; i++)
+ {
+ buffer_descriptor_t *bufDescriptor = (buffer_descriptor_t *)(descriptors[i]);
+ int tmp_fd;
+
+ if (i != max_buffer_index)
+ {
+ tmp_fd = dup(shared_fd);
+
+ if (tmp_fd < 0)
+ {
+ /* need to free already allocated memory. */
+ mali_gralloc_ion_free_internal(pHandle, numDescriptors);
+ return -1;
+ }
+ }
+ else
+ {
+ tmp_fd = shared_fd;
+ }
+
+ private_handle_t *hnd = new private_handle_t(
+ private_handle_t::PRIV_FLAGS_USES_ION | priv_heap_flag, bufDescriptor->size, min_pgsz,
+ bufDescriptor->consumer_usage, bufDescriptor->producer_usage, tmp_fd, bufDescriptor->hal_format,
+ bufDescriptor->internal_format, bufDescriptor->byte_stride, bufDescriptor->width, bufDescriptor->height,
+ bufDescriptor->pixel_stride, bufDescriptor->internalWidth, bufDescriptor->internalHeight,
+ max_bufDescriptor->size);
+
+ if (NULL == hnd)
+ {
+ mali_gralloc_ion_free_internal(pHandle, numDescriptors);
+ return -1;
+ }
+
+ pHandle[i] = hnd;
+ }
+ }
+ else
+ {
+ for (i = 0; i < numDescriptors; i++)
+ {
+ buffer_descriptor_t *bufDescriptor = (buffer_descriptor_t *)(descriptors[i]);
+ usage = bufDescriptor->consumer_usage | bufDescriptor->producer_usage;
+
+ heap_mask = pick_ion_heap(usage);
+
+ if (heap_mask == 0)
+ {
+ AERR("Failed to find an appropriate ion heap");
+ mali_gralloc_ion_free_internal(pHandle, numDescriptors);
+ return -1;
+ }
+
+ set_ion_flags(heap_mask, usage, &priv_heap_flag, &ion_flags);
+ if (gralloc_legacy_ion)
+ {
+ shared_fd = alloc_from_ion_heap(m->ion_client, bufDescriptor->size, heap_mask, ion_flags, &min_pgsz);
+ }
+ else
+ {
+ int heap = 1 << system_heap_id;
+ if (heap_mask == ION_HEAP_TYPE_DMA_MASK)
+ heap = 1 << cma_heap_id;
+
+ ret = ion_alloc_fd(m->ion_client, bufDescriptor->size, 0, heap, 0, &(shared_fd));
+ if (ret != 0)
+ {
+ AERR("Failed to ion_alloc_fd from ion_client:%d", m->ion_client);
+ mali_gralloc_ion_free_internal(pHandle, numDescriptors);
+ return -1;
+ }
+ min_pgsz = SZ_4K;
+ }
+
+ if (shared_fd < 0)
+ {
+ AERR("ion_alloc failed from client ( %d )", m->ion_client);
+
+ /* need to free already allocated memory. not just this one */
+ mali_gralloc_ion_free_internal(pHandle, numDescriptors);
+
+ return -1;
+ }
+
+ private_handle_t *hnd = new private_handle_t(
+ private_handle_t::PRIV_FLAGS_USES_ION | priv_heap_flag, bufDescriptor->size, min_pgsz,
+ bufDescriptor->consumer_usage, bufDescriptor->producer_usage, shared_fd, bufDescriptor->hal_format,
+ bufDescriptor->internal_format, bufDescriptor->byte_stride, bufDescriptor->width, bufDescriptor->height,
+ bufDescriptor->pixel_stride, bufDescriptor->internalWidth, bufDescriptor->internalHeight,
+ bufDescriptor->size);
+
+ if (NULL == hnd)
+ {
+ mali_gralloc_ion_free_internal(pHandle, numDescriptors);
+ return -1;
+ }
+
+ pHandle[i] = hnd;
+ }
+ }
+
+ for (i = 0; i < numDescriptors; i++)
+ {
+ buffer_descriptor_t *bufDescriptor = (buffer_descriptor_t *)(descriptors[i]);
+ private_handle_t *hnd = (private_handle_t *)(pHandle[i]);
+
+ usage = bufDescriptor->consumer_usage | bufDescriptor->producer_usage;
+
+ if (!(usage & GRALLOC_USAGE_PROTECTED))
+ {
+ cpu_ptr =
+ (unsigned char *)mmap(NULL, bufDescriptor->size, PROT_READ | PROT_WRITE, MAP_SHARED, hnd->share_fd, 0);
+
+ if (MAP_FAILED == cpu_ptr)
+ {
+ AERR("mmap failed from client ( %d ), fd ( %d )", m->ion_client, hnd->share_fd);
+ mali_gralloc_ion_free_internal(pHandle, numDescriptors);
+ return -1;
+ }
+
+#if GRALLOC_INIT_AFBC == 1
+
+ if ((bufDescriptor->internal_format & MALI_GRALLOC_INTFMT_AFBCENABLE_MASK) && (!(*shared_backend)))
+ {
+ init_afbc(cpu_ptr, bufDescriptor->internal_format, bufDescriptor->width, bufDescriptor->height);
+ }
+
+#endif
+ hnd->base = cpu_ptr;
+ }
+ }
+
+ return 0;
+}
+
+void mali_gralloc_ion_free(private_handle_t const *hnd)
+{
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
+ {
+ return;
+ }
+ else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
+ {
+ /* Buffer might be unregistered already so we need to assure we have a valid handle*/
+ if (0 != hnd->base)
+ {
+ if (0 != munmap((void *)hnd->base, hnd->size))
+ {
+ AERR("Failed to munmap handle %p", hnd);
+ }
+ }
+
+ close(hnd->share_fd);
+ memset((void *)hnd, 0, sizeof(*hnd));
+ }
+}
+
+static void mali_gralloc_ion_free_internal(buffer_handle_t *pHandle, uint32_t num_hnds)
+{
+ uint32_t i = 0;
+
+ for (i = 0; i < num_hnds; i++)
+ {
+ if (NULL != pHandle[i])
+ {
+ mali_gralloc_ion_free((private_handle_t *)(pHandle[i]));
+ }
+ }
+
+ return;
+}
+
+void mali_gralloc_ion_sync(const mali_gralloc_module *m, private_handle_t *hnd)
+{
+ if (!gralloc_legacy_ion)
+ return;
+
+ if (m != NULL && hnd != NULL)
+ {
+ switch (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
+ {
+ case private_handle_t::PRIV_FLAGS_USES_ION:
+ if (!(hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION_DMA_HEAP))
+ {
+ ion_sync_fd(m->ion_client, hnd->share_fd);
+ }
+
+ break;
+ }
+ }
+}
+
+int mali_gralloc_ion_map(private_handle_t *hnd)
+{
+ int retval = -EINVAL;
+
+ switch (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
+ {
+ case private_handle_t::PRIV_FLAGS_USES_ION:
+ unsigned char *mappedAddress;
+ size_t size = hnd->size;
+ hw_module_t *pmodule = NULL;
+ private_module_t *m = NULL;
+
+ if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **)&pmodule) == 0)
+ {
+ m = reinterpret_cast<private_module_t *>(pmodule);
+ }
+ else
+ {
+ AERR("Could not get gralloc module for handle: %p", hnd);
+ retval = -errno;
+ break;
+ }
+
+ /* the test condition is set to m->ion_client <= 0 here, because:
+ * 1) module structure are initialized to 0 if no initial value is applied
+ * 2) a second user process should get a ion fd greater than 0.
+ */
+ if (m->ion_client <= 0)
+ {
+ /* a second user process must obtain a client handle first via ion_open before it can obtain the shared ion buffer*/
+ m->ion_client = ion_open();
+
+ if (m->ion_client < 0)
+ {
+ AERR("Could not open ion device for handle: %p", hnd);
+ retval = -errno;
+ break;
+ }
+ }
+
+ mappedAddress = (unsigned char *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, hnd->share_fd, 0);
+
+ if (MAP_FAILED == mappedAddress)
+ {
+ AERR("mmap( share_fd:%d ) failed with %s", hnd->share_fd, strerror(errno));
+ retval = -errno;
+ break;
+ }
+
+ hnd->base = (void *)(uintptr_t(mappedAddress) + hnd->offset);
+ retval = 0;
+ break;
+ }
+
+ return retval;
+}
+
+void mali_gralloc_ion_unmap(private_handle_t *hnd)
+{
+ switch (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION)
+ {
+ case private_handle_t::PRIV_FLAGS_USES_ION:
+ void *base = (void *)hnd->base;
+ size_t size = hnd->size;
+
+ if (munmap(base, size) < 0)
+ {
+ AERR("Could not munmap base:%p size:%zd '%s'", base, size, strerror(errno));
+ }
+
+ break;
+ }
+}
+
+int mali_gralloc_ion_device_close(struct hw_device_t *device)
+{
+#if GRALLOC_USE_GRALLOC1_API == 1
+ gralloc1_device_t *dev = reinterpret_cast<gralloc1_device_t *>(device);
+#else
+ alloc_device_t *dev = reinterpret_cast<alloc_device_t *>(device);
+#endif
+
+ if (dev)
+ {
+ private_module_t *m = reinterpret_cast<private_module_t *>(dev->common.module);
+
+ if (m->ion_client != -1)
+ {
+ if (0 != ion_close(m->ion_client))
+ {
+ AERR("Failed to close ion_client: %d err=%s", m->ion_client, strerror(errno));
+ }
+
+ m->ion_client = -1;
+ }
+
+ delete dev;
+ }
+
+ return 0;
+}
diff --git a/gralloc960/mali_gralloc_ion.h b/gralloc960/mali_gralloc_ion.h
new file mode 100644
index 00000000..015e8a3e
--- /dev/null
+++ b/gralloc960/mali_gralloc_ion.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MALI_GRALLOC_ION_H_
+#define MALI_GRALLOC_ION_H_
+
+#include "mali_gralloc_module.h"
+#include "mali_gralloc_bufferdescriptor.h"
+
+int mali_gralloc_ion_allocate(mali_gralloc_module *m, const gralloc_buffer_descriptor_t *descriptors,
+ uint32_t numDescriptors, buffer_handle_t *pHandle, bool *alloc_from_backing_store);
+void mali_gralloc_ion_free(private_handle_t const *hnd);
+void mali_gralloc_ion_sync(const mali_gralloc_module *m, private_handle_t *hnd);
+int mali_gralloc_ion_map(private_handle_t *hnd);
+void mali_gralloc_ion_unmap(private_handle_t *hnd);
+int mali_gralloc_ion_device_close(struct hw_device_t *device);
+
+#endif /* MALI_GRALLOC_ION_H_ */
diff --git a/gralloc960/mali_gralloc_module.cpp b/gralloc960/mali_gralloc_module.cpp
new file mode 100644
index 00000000..39563518
--- /dev/null
+++ b/gralloc960/mali_gralloc_module.cpp
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2016-2017 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <errno.h>
+#include <pthread.h>
+#include <inttypes.h>
+
+#include <log/log.h>
+#include <cutils/atomic.h>
+#include <hardware/hardware.h>
+#include <hardware/fb.h>
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+
+#include "mali_gralloc_module.h"
+#include "mali_gralloc_private_interface_types.h"
+#include "mali_gralloc_buffer.h"
+#include "gralloc_helper.h"
+#include "framebuffer_device.h"
+#include "gralloc_buffer_priv.h"
+#include "mali_gralloc_formats.h"
+#include "mali_gralloc_usages.h"
+#include "mali_gralloc_bufferaccess.h"
+#include "mali_gralloc_reference.h"
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include "mali_gralloc_public_interface.h"
+#else
+#include "legacy/alloc_device.h"
+#endif
+
+static int mali_gralloc_module_device_open(const hw_module_t *module, const char *name, hw_device_t **device)
+{
+ int status = -EINVAL;
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+
+ if (!strncmp(name, GRALLOC_HARDWARE_MODULE_ID, MALI_GRALLOC_HARDWARE_MAX_STR_LEN))
+ {
+ status = mali_gralloc_device_open(module, name, device);
+ }
+
+#else
+
+ if (!strncmp(name, GRALLOC_HARDWARE_GPU0, MALI_GRALLOC_HARDWARE_MAX_STR_LEN))
+ {
+ status = alloc_device_open(module, name, device);
+ }
+
+#endif
+ else if (!strncmp(name, GRALLOC_HARDWARE_FB0, MALI_GRALLOC_HARDWARE_MAX_STR_LEN))
+ {
+ status = framebuffer_device_open(module, name, device);
+ }
+
+ return status;
+}
+
+static int gralloc_register_buffer(gralloc_module_t const *module, buffer_handle_t handle)
+{
+ const mali_gralloc_module *m = reinterpret_cast<const mali_gralloc_module *>(module);
+
+ return mali_gralloc_reference_retain(m, handle);
+}
+
+static int gralloc_unregister_buffer(gralloc_module_t const *module, buffer_handle_t handle)
+{
+ const mali_gralloc_module *m = reinterpret_cast<const mali_gralloc_module *>(module);
+
+ return mali_gralloc_reference_release(m, handle, false);
+}
+
+static int gralloc_lock(gralloc_module_t const *module, buffer_handle_t handle, int usage, int l, int t, int w, int h,
+ void **vaddr)
+{
+ const mali_gralloc_module *m = reinterpret_cast<const mali_gralloc_module *>(module);
+
+ return mali_gralloc_lock(m, handle, usage, l, t, w, h, vaddr);
+}
+
+static int gralloc_lock_ycbcr(gralloc_module_t const *module, buffer_handle_t handle, int usage, int l, int t, int w,
+ int h, android_ycbcr *ycbcr)
+{
+ const mali_gralloc_module *m = reinterpret_cast<const mali_gralloc_module *>(module);
+
+ return mali_gralloc_lock_ycbcr(m, handle, usage, l, t, w, h, ycbcr);
+}
+
+static int gralloc_unlock(gralloc_module_t const *module, buffer_handle_t handle)
+{
+ const mali_gralloc_module *m = reinterpret_cast<const mali_gralloc_module *>(module);
+
+ return mali_gralloc_unlock(m, handle);
+}
+
+static int gralloc_lock_async(gralloc_module_t const *module, buffer_handle_t handle, int usage, int l, int t, int w,
+ int h, void **vaddr, int32_t fence_fd)
+{
+ const mali_gralloc_module *m = reinterpret_cast<const mali_gralloc_module *>(module);
+
+ return mali_gralloc_lock_async(m, handle, usage, l, t, w, h, vaddr, fence_fd);
+}
+
+static int gralloc_lock_ycbcr_async(gralloc_module_t const *module, buffer_handle_t handle, int usage, int l, int t,
+ int w, int h, android_ycbcr *ycbcr, int32_t fence_fd)
+{
+ const mali_gralloc_module *m = reinterpret_cast<const mali_gralloc_module *>(module);
+
+ return mali_gralloc_lock_ycbcr_async(m, handle, usage, l, t, w, h, ycbcr, fence_fd);
+}
+
+static int gralloc_unlock_async(gralloc_module_t const *module, buffer_handle_t handle, int32_t *fence_fd)
+{
+ const mali_gralloc_module *m = reinterpret_cast<const mali_gralloc_module *>(module);
+
+ return mali_gralloc_unlock_async(m, handle, fence_fd);
+}
+
+// There is one global instance of the module
+
+static struct hw_module_methods_t mali_gralloc_module_methods = { mali_gralloc_module_device_open };
+
+private_module_t::private_module_t()
+{
+#define INIT_ZERO(obj) (memset(&(obj), 0, sizeof((obj))))
+ base.common.tag = HARDWARE_MODULE_TAG;
+#if GRALLOC_USE_GRALLOC1_API == 1
+ base.common.version_major = GRALLOC_MODULE_API_VERSION_1_0;
+#else
+ base.common.version_major = GRALLOC_MODULE_API_VERSION_0_3;
+#endif
+ base.common.version_minor = 0;
+ base.common.id = GRALLOC_HARDWARE_MODULE_ID;
+ base.common.name = "Graphics Memory Allocator Module";
+ base.common.author = "ARM Ltd.";
+ base.common.methods = &mali_gralloc_module_methods;
+ base.common.dso = NULL;
+ INIT_ZERO(base.common.reserved);
+
+#if GRALLOC_USE_GRALLOC1_API == 0
+ base.registerBuffer = gralloc_register_buffer;
+ base.unregisterBuffer = gralloc_unregister_buffer;
+ base.lock = gralloc_lock;
+ base.lock_ycbcr = gralloc_lock_ycbcr;
+ base.unlock = gralloc_unlock;
+ base.lockAsync = gralloc_lock_async;
+ base.lockAsync_ycbcr = gralloc_lock_ycbcr_async;
+ base.unlockAsync = gralloc_unlock_async;
+ base.perform = NULL;
+ INIT_ZERO(base.reserved_proc);
+#endif
+
+ framebuffer = NULL;
+ flags = 0;
+ numBuffers = 0;
+ bufferMask = 0;
+ pthread_mutex_init(&(lock), NULL);
+ currentBuffer = NULL;
+ INIT_ZERO(info);
+ INIT_ZERO(finfo);
+ xdpi = 0.0f;
+ ydpi = 0.0f;
+ fps = 0.0f;
+ swapInterval = 1;
+ ion_client = -1;
+
+#undef INIT_ZERO
+};
+
+/*
+ * HAL_MODULE_INFO_SYM will be initialized using the default constructor
+ * implemented above
+ */
+struct private_module_t HAL_MODULE_INFO_SYM;
diff --git a/gralloc960/mali_gralloc_module.h b/gralloc960/mali_gralloc_module.h
new file mode 100644
index 00000000..53e08e5a
--- /dev/null
+++ b/gralloc960/mali_gralloc_module.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2016 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef MALI_GRALLOC_MODULE_H_
+#define MALI_GRALLOC_MODULE_H_
+
+#include <linux/fb.h>
+#include <pthread.h>
+
+typedef enum
+{
+ MALI_DPY_TYPE_UNKNOWN = 0,
+ MALI_DPY_TYPE_CLCD,
+ MALI_DPY_TYPE_HDLCD
+} mali_dpy_type;
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+typedef struct
+{
+ struct hw_module_t common;
+} gralloc_module_t;
+
+/*
+ * Most gralloc code is fairly version agnostic, but certain
+ * places still use old usage defines. Make sure it works
+ * ok for usages that are backwards compatible.
+ */
+#define GRALLOC_USAGE_PRIVATE_0 GRALLOC1_CONSUMER_USAGE_PRIVATE_0
+#define GRALLOC_USAGE_PRIVATE_1 GRALLOC1_CONSUMER_USAGE_PRIVATE_1
+#define GRALLOC_USAGE_PRIVATE_2 GRALLOC1_CONSUMER_USAGE_PRIVATE_2
+#define GRALLOC_USAGE_PRIVATE_3 GRALLOC1_CONSUMER_USAGE_PRIVATE_3
+
+#define GRALLOC_USAGE_SW_WRITE_RARELY GRALLOC1_PRODUCER_USAGE_CPU_WRITE
+#define GRALLOC_USAGE_SW_WRITE_OFTEN GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN
+#define GRALLOC_USAGE_SW_READ_RARELY GRALLOC1_CONSUMER_USAGE_CPU_READ
+#define GRALLOC_USAGE_SW_READ_OFTEN GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN
+#define GRALLOC_USAGE_HW_FB GRALLOC1_CONSUMER_USAGE_CLIENT_TARGET
+#define GRALLOC_USAGE_HW_2D 0x00000400
+
+#define GRALLOC_USAGE_SW_WRITE_MASK 0x000000F0
+#define GRALLOC_USAGE_SW_READ_MASK 0x0000000F
+#define GRALLOC_USAGE_PROTECTED GRALLOC1_PRODUCER_USAGE_PROTECTED
+#define GRALLOC_USAGE_HW_RENDER GRALLOC1_PRODUCER_USAGE_GPU_RENDER_TARGET
+#define GRALLOC_USAGE_HW_CAMERA_MASK (GRALLOC1_CONSUMER_USAGE_CAMERA | GRALLOC1_PRODUCER_USAGE_CAMERA)
+#define GRALLOC_USAGE_HW_TEXTURE GRALLOC1_CONSUMER_USAGE_GPU_TEXTURE
+#define GRALLOC_USAGE_HW_VIDEO_ENCODER GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER
+#define GRALLOC_USAGE_HW_COMPOSER GRALLOC1_CONSUMER_USAGE_HWCOMPOSER
+#define GRALLOC_USAGE_EXTERNAL_DISP 0x00002000
+
+#endif
+
+struct private_module_t
+{
+ gralloc_module_t base;
+
+ struct private_handle_t *framebuffer;
+ uint32_t flags;
+ uint32_t numBuffers;
+ uint32_t bufferMask;
+ pthread_mutex_t lock;
+ buffer_handle_t currentBuffer;
+ int ion_client;
+ mali_dpy_type dpy_type;
+
+ struct fb_var_screeninfo info;
+ struct fb_fix_screeninfo finfo;
+ float xdpi;
+ float ydpi;
+ float fps;
+ int swapInterval;
+
+#ifdef __cplusplus
+ /* Never intended to be used from C code */
+ enum
+ {
+ // flag to indicate we'll post this buffer
+ PRIV_USAGE_LOCKED_FOR_POST = 0x80000000
+ };
+#endif
+
+#ifdef __cplusplus
+ /* default constructor */
+ private_module_t();
+#endif
+};
+typedef struct private_module_t mali_gralloc_module;
+
+#endif /* MALI_GRALLOC_MODULE_H_ */
diff --git a/gralloc960/mali_gralloc_private_interface.cpp b/gralloc960/mali_gralloc_private_interface.cpp
new file mode 100644
index 00000000..2f84e37f
--- /dev/null
+++ b/gralloc960/mali_gralloc_private_interface.cpp
@@ -0,0 +1,281 @@
+/*
+ * Copyright (C) 2017 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <hardware/hardware.h>
+#include <hardware/gralloc1.h>
+
+#include "mali_gralloc_private_interface.h"
+#include "mali_gralloc_buffer.h"
+#include "gralloc_helper.h"
+#include "gralloc_buffer_priv.h"
+#include "mali_gralloc_bufferdescriptor.h"
+
+#define CHECK_FUNCTION(A, B, C) \
+ do \
+ { \
+ if (A == B) \
+ return (gralloc1_function_pointer_t)C; \
+ } while (0)
+
+static int32_t mali_gralloc_private_get_buff_int_fmt(gralloc1_device_t *device, buffer_handle_t handle,
+ uint64_t *internal_format)
+{
+ GRALLOC_UNUSED(device);
+
+ if (private_handle_t::validate(handle) < 0 || internal_format == NULL)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ const private_handle_t *hnd = static_cast<const private_handle_t *>(handle);
+ *internal_format = hnd->internal_format;
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_private_get_buff_fd(gralloc1_device_t *device, buffer_handle_t handle, int *fd)
+{
+ GRALLOC_UNUSED(device);
+
+ if (private_handle_t::validate(handle) < 0 || fd == NULL)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ const private_handle_t *hnd = static_cast<const private_handle_t *>(handle);
+ *fd = hnd->share_fd;
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_private_get_buff_int_dims(gralloc1_device_t *device, buffer_handle_t handle,
+ int *internalWidth, int *internalHeight)
+{
+ GRALLOC_UNUSED(device);
+
+ if (private_handle_t::validate(handle) < 0 || internalWidth == NULL || internalHeight == NULL)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ const private_handle_t *hnd = static_cast<const private_handle_t *>(handle);
+ *internalWidth = hnd->internalWidth;
+ *internalHeight = hnd->internalHeight;
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_private_get_buff_offset(gralloc1_device_t *device, buffer_handle_t handle, int64_t *offset)
+{
+ GRALLOC_UNUSED(device);
+
+ if (private_handle_t::validate(handle) < 0 || offset == NULL)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ const private_handle_t *hnd = static_cast<const private_handle_t *>(handle);
+ *offset = hnd->offset;
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_private_get_buff_bytestride(gralloc1_device_t *device, buffer_handle_t handle,
+ int *bytestride)
+{
+ GRALLOC_UNUSED(device);
+
+ if (private_handle_t::validate(handle) < 0 || bytestride == NULL)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ const private_handle_t *hnd = static_cast<const private_handle_t *>(handle);
+ *bytestride = hnd->byte_stride;
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_private_get_buff_yuvinfo(gralloc1_device_t *device, buffer_handle_t handle,
+ mali_gralloc_yuv_info *yuvinfo)
+{
+ GRALLOC_UNUSED(device);
+
+ if (private_handle_t::validate(handle) < 0 || yuvinfo == NULL)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ const private_handle_t *hnd = static_cast<const private_handle_t *>(handle);
+ *yuvinfo = hnd->yuv_info;
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_private_get_buff_size(gralloc1_device_t *device, buffer_handle_t handle, int *size)
+{
+ GRALLOC_UNUSED(device);
+
+ if (private_handle_t::validate(handle) < 0 || size == NULL)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ const private_handle_t *hnd = static_cast<const private_handle_t *>(handle);
+ *size = hnd->size;
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_private_get_buff_flags(gralloc1_device_t *device, buffer_handle_t handle, int *flags)
+{
+ GRALLOC_UNUSED(device);
+
+ if (private_handle_t::validate(handle) < 0 || flags == NULL)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ const private_handle_t *hnd = static_cast<const private_handle_t *>(handle);
+ *flags = hnd->flags;
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_private_get_buff_min_page_size(gralloc1_device_t *device, buffer_handle_t handle,
+ int *min_pgsz)
+{
+ GRALLOC_UNUSED(device);
+
+ if (private_handle_t::validate(handle) < 0 || min_pgsz == NULL)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ const private_handle_t *hnd = static_cast<const private_handle_t *>(handle);
+ *min_pgsz = hnd->min_pgsz;
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_private_get_attr_param(gralloc1_device_t *device, buffer_handle_t handle, buf_attr attr,
+ int32_t *val, int32_t last_call)
+{
+ GRALLOC_UNUSED(device);
+
+ if (private_handle_t::validate(handle) < 0 || val == NULL)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ const private_handle_t *const_hnd = static_cast<const private_handle_t *>(handle);
+ private_handle_t *hnd = const_cast<private_handle_t *>(const_hnd);
+
+ if (hnd->attr_base == MAP_FAILED)
+ {
+ if (gralloc_buffer_attr_map(hnd, 1) < 0)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+ }
+
+ if (gralloc_buffer_attr_read(hnd, attr, val) < 0)
+ {
+ gralloc_buffer_attr_unmap(hnd);
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ if (last_call)
+ {
+ gralloc_buffer_attr_unmap(hnd);
+ }
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_private_set_attr_param(gralloc1_device_t *device, buffer_handle_t handle, buf_attr attr,
+ int32_t *val, int32_t last_call)
+{
+ GRALLOC_UNUSED(device);
+
+ if (private_handle_t::validate(handle) < 0 || val == NULL)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ const private_handle_t *const_hnd = static_cast<const private_handle_t *>(handle);
+ private_handle_t *hnd = const_cast<private_handle_t *>(const_hnd);
+
+ if (hnd->attr_base == MAP_FAILED)
+ {
+ if (gralloc_buffer_attr_map(hnd, 1) < 0)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+ }
+
+ if (gralloc_buffer_attr_write(hnd, attr, val) < 0)
+ {
+ gralloc_buffer_attr_unmap(hnd);
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ if (last_call)
+ {
+ gralloc_buffer_attr_unmap(hnd);
+ }
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_private_set_priv_fmt(gralloc1_device_t *device, gralloc1_buffer_descriptor_t desc,
+ uint64_t internal_format)
+{
+ GRALLOC_UNUSED(device);
+
+ buffer_descriptor_t *priv_desc = reinterpret_cast<buffer_descriptor_t *>(desc);
+
+ if (priv_desc == NULL)
+ {
+ return GRALLOC1_ERROR_BAD_DESCRIPTOR;
+ }
+
+ priv_desc->hal_format = internal_format;
+ priv_desc->format_type = MALI_GRALLOC_FORMAT_TYPE_INTERNAL;
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+gralloc1_function_pointer_t mali_gralloc_private_interface_getFunction(int32_t descriptor)
+{
+ CHECK_FUNCTION(descriptor, MALI_GRALLOC1_FUNCTION_GET_BUFF_INT_FMT, mali_gralloc_private_get_buff_int_fmt);
+ CHECK_FUNCTION(descriptor, MALI_GRALLOC1_FUNCTION_GET_BUFF_FD, mali_gralloc_private_get_buff_fd);
+ CHECK_FUNCTION(descriptor, MALI_GRALLOC1_FUNCTION_GET_BUFF_INTERNAL_DIMS, mali_gralloc_private_get_buff_int_dims);
+ CHECK_FUNCTION(descriptor, MALI_GRALLOC1_FUNCTION_GET_BUFF_OFFSET, mali_gralloc_private_get_buff_offset);
+ CHECK_FUNCTION(descriptor, MALI_GRALLOC1_FUNCTION_GET_BUFF_BYTESTRIDE, mali_gralloc_private_get_buff_bytestride);
+ CHECK_FUNCTION(descriptor, MALI_GRALLOC1_FUNCTION_GET_BUFF_YUVINFO, mali_gralloc_private_get_buff_yuvinfo);
+ CHECK_FUNCTION(descriptor, MALI_GRALLOC1_FUNCTION_GET_BUFF_SIZE, mali_gralloc_private_get_buff_size);
+ CHECK_FUNCTION(descriptor, MALI_GRALLOC1_FUNCTION_GET_BUFF_FLAGS, mali_gralloc_private_get_buff_flags);
+ CHECK_FUNCTION(descriptor, MALI_GRALLOC1_FUNCTION_GET_BUFF_MIN_PAGESIZE,
+ mali_gralloc_private_get_buff_min_page_size);
+ CHECK_FUNCTION(descriptor, MALI_GRALLOC1_FUNCTION_GET_ATTR_PARAM, mali_gralloc_private_get_attr_param);
+ CHECK_FUNCTION(descriptor, MALI_GRALLOC1_FUNCTION_SET_ATTR_PARAM, mali_gralloc_private_set_attr_param);
+ CHECK_FUNCTION(descriptor, MALI_GRALLOC1_FUNCTION_SET_PRIV_FMT, mali_gralloc_private_set_priv_fmt);
+
+ return NULL;
+}
diff --git a/gralloc960/mali_gralloc_private_interface.h b/gralloc960/mali_gralloc_private_interface.h
new file mode 100644
index 00000000..5f9428ac
--- /dev/null
+++ b/gralloc960/mali_gralloc_private_interface.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2017 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MALI_GRALLOC_PRIVATE_INTERFACE_H_
+#define MALI_GRALLOC_PRIVATE_INTERFACE_H_
+
+#include "mali_gralloc_private_interface_types.h"
+
+typedef enum
+{
+
+ MALI_GRALLOC1_LAST_PUBLIC_FUNCTION = GRALLOC1_LAST_FUNCTION,
+
+ MALI_GRALLOC1_FUNCTION_GET_BUFF_INT_FMT = MALI_GRALLOC1_LAST_PUBLIC_FUNCTION + 100,
+ MALI_GRALLOC1_FUNCTION_GET_BUFF_FD,
+ MALI_GRALLOC1_FUNCTION_GET_BUFF_INTERNAL_DIMS,
+ MALI_GRALLOC1_FUNCTION_GET_BUFF_OFFSET,
+ MALI_GRALLOC1_FUNCTION_GET_BUFF_BYTESTRIDE,
+ MALI_GRALLOC1_FUNCTION_GET_BUFF_YUVINFO,
+ MALI_GRALLOC1_FUNCTION_GET_BUFF_SIZE,
+ MALI_GRALLOC1_FUNCTION_GET_BUFF_FLAGS,
+ MALI_GRALLOC1_FUNCTION_GET_BUFF_MIN_PAGESIZE,
+ MALI_GRALLOC1_FUNCTION_SET_PRIV_FMT,
+
+ /* API related to the shared attribute region */
+ MALI_GRALLOC1_FUNCTION_GET_ATTR_PARAM,
+ MALI_GRALLOC1_FUNCTION_SET_ATTR_PARAM,
+
+ MALI_GRALLOC1_LAST_PRIVATE_FUNCTION
+} mali_gralloc1_function_descriptor_t;
+
+typedef int32_t (*GRALLOC1_PFN_PRIVATE_GET_BUFF_INT_FMT)(gralloc1_device_t *device, buffer_handle_t handle,
+ uint64_t *internal_format);
+typedef int32_t (*GRALLOC1_PFN_PRIVATE_GET_BUFF_FD)(gralloc1_device_t *device, buffer_handle_t handle, int *fd);
+typedef int32_t (*GRALLOC1_PFN_PRIVATE_GET_BUFF_INTERNAL_DIMS)(gralloc1_device_t *device, buffer_handle_t handle,
+ int *internalWidth, int *internalHeight);
+typedef int32_t (*GRALLOC1_PFN_PRIVATE_GET_BUFF_OFFSET)(gralloc1_device_t *device, buffer_handle_t handle,
+ int64_t *offset);
+typedef int32_t (*GRALLOC1_PFN_PRIVATE_GET_BUFF_BYTESTRIDE)(gralloc1_device_t *device, buffer_handle_t handle,
+ int *bytestride);
+typedef int32_t (*GRALLOC1_PFN_PRIVATE_GET_BUFF_YUVINFO)(gralloc1_device_t *device, buffer_handle_t handle,
+ mali_gralloc_yuv_info *yuvinfo);
+typedef int32_t (*GRALLOC1_PFN_PRIVATE_GET_BUFF_SIZE)(gralloc1_device_t *device, buffer_handle_t handle, int *size);
+typedef int32_t (*GRALLOC1_PFN_PRIVATE_GET_BUFF_FLAGS)(gralloc1_device_t *device, buffer_handle_t handle, int *flags);
+typedef int32_t (*GRALLOC1_PFN_PRIVATE_GET_BUFF_MIN_PAGESIZE)(gralloc1_device_t *device, buffer_handle_t handle,
+ int *min_pgsz);
+typedef int32_t (*GRALLOC1_PFN_PRIVATE_GET_ATTR_PARAM)(gralloc1_device_t *device, buffer_handle_t handle, buf_attr attr,
+ int32_t *val, int32_t last_call);
+typedef int32_t (*GRALLOC1_PFN_PRIVATE_SET_ATTR_PARAM)(gralloc1_device_t *device, buffer_handle_t handle, buf_attr attr,
+ int32_t *val, int32_t last_call);
+typedef int32_t (*GRALLOC1_PFN_PRIVATE_SET_PRIV_FMT)(gralloc1_device_t *device, gralloc1_buffer_descriptor_t desc,
+ uint64_t internal_format);
+
+#if defined(GRALLOC_LIBRARY_BUILD)
+gralloc1_function_pointer_t mali_gralloc_private_interface_getFunction(int32_t descriptor);
+#endif
+
+#endif /* MALI_GRALLOC_PRIVATE_INTERFACE_H_ */
diff --git a/gralloc960/mali_gralloc_private_interface_types.h b/gralloc960/mali_gralloc_private_interface_types.h
new file mode 100644
index 00000000..eb644a6a
--- /dev/null
+++ b/gralloc960/mali_gralloc_private_interface_types.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2017 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MALI_GRALLOC_PRIVATE_INTERFACE_TYPES_H_
+#define MALI_GRALLOC_PRIVATE_INTERFACE_TYPES_H_
+
+#define GRALLOC_ARM_BUFFER_ATTR_HDR_INFO_SUPPORT
+
+typedef enum
+{
+ MALI_HDR_NO_INFO,
+ MALI_HDR_ST2084,
+ MALI_HDR_HLG,
+ MALI_HDR_LAST
+} mali_transfer_function;
+
+typedef struct
+{
+ //values are in units of 0.00002
+ uint16_t x;
+ uint16_t y;
+} primaries;
+
+typedef struct
+{
+ primaries r;
+ primaries g;
+ primaries b;
+ primaries w;
+ uint16_t minDisplayLuminance; // in cd/m^2
+ uint16_t maxDisplayLuminance; // in 0.0001 cd/m^2
+ uint16_t maxContentLightLevel; // in cd/m^2
+ uint16_t maxFrameAverageLightLevel; // in cd/m^2
+ mali_transfer_function eotf;
+} mali_hdr_info;
+
+enum
+{
+ /* CROP_RECT and YUV_TRANS are intended to be
+ * written by producers and read by consumers.
+ * A producer should write these parameters before
+ * it queues a buffer to the consumer.
+ */
+
+ /* CROP RECT, defined as an int array of top, left, height, width. Origin in top-left corner */
+ GRALLOC_ARM_BUFFER_ATTR_CROP_RECT = 1,
+
+ /* Set if the AFBC format used a YUV transform before compressing */
+ GRALLOC_ARM_BUFFER_ATTR_AFBC_YUV_TRANS = 2,
+
+ /* Set if the AFBC format uses sparse allocation */
+ GRALLOC_ARM_BUFFER_ATTR_AFBC_SPARSE_ALLOC = 3,
+
+ /* HDR Informations*/
+ GRALLOC_ARM_BUFFER_ATTR_HDR_INFO = 4,
+
+ GRALLOC_ARM_BUFFER_ATTR_LAST
+};
+
+typedef uint32_t buf_attr;
+
+typedef enum
+{
+ MALI_YUV_NO_INFO,
+ MALI_YUV_BT601_NARROW,
+ MALI_YUV_BT601_WIDE,
+ MALI_YUV_BT709_NARROW,
+ MALI_YUV_BT709_WIDE
+} mali_gralloc_yuv_info;
+
+#endif /* MALI_GRALLOC_PRIVATE_INTERFACE_TYPES_H_ */
diff --git a/gralloc960/mali_gralloc_public_interface.cpp b/gralloc960/mali_gralloc_public_interface.cpp
new file mode 100644
index 00000000..9475d827
--- /dev/null
+++ b/gralloc960/mali_gralloc_public_interface.cpp
@@ -0,0 +1,451 @@
+/*
+ * Copyright (C) 2016 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <hardware/hardware.h>
+#include <hardware/gralloc1.h>
+
+#include "mali_gralloc_module.h"
+
+#include "mali_gralloc_private_interface.h"
+#include "mali_gralloc_buffer.h"
+#include "mali_gralloc_ion.h"
+#include "mali_gralloc_bufferdescriptor.h"
+#include "mali_gralloc_bufferallocation.h"
+#include "mali_gralloc_reference.h"
+#include "mali_gralloc_bufferaccess.h"
+#include "framebuffer_device.h"
+#include "gralloc_buffer_priv.h"
+#include "mali_gralloc_debug.h"
+
+typedef struct mali_gralloc_func
+{
+ gralloc1_function_descriptor_t desc;
+ gralloc1_function_pointer_t func;
+} mali_gralloc_func;
+
+static void mali_gralloc_dump(gralloc1_device_t *device, uint32_t *outSize, char *outBuffer)
+{
+ if (NULL == outSize)
+ {
+ ALOGE("Invalid pointer to outSize and return");
+ return;
+ }
+
+ mali_gralloc_dump_internal(outSize, outBuffer);
+ GRALLOC_UNUSED(device);
+}
+
+static int32_t mali_gralloc_create_descriptor(gralloc1_device_t *device, gralloc1_buffer_descriptor_t *outDescriptor)
+{
+ int ret = 0;
+ ret = mali_gralloc_create_descriptor_internal(outDescriptor);
+ GRALLOC_UNUSED(device);
+ return ret;
+}
+
+static int32_t mali_gralloc_destroy_descriptor(gralloc1_device_t *device, gralloc1_buffer_descriptor_t descriptor)
+{
+ int ret = 0;
+ ret = mali_gralloc_destroy_descriptor_internal(descriptor);
+ GRALLOC_UNUSED(device);
+ return ret;
+}
+
+static int32_t mali_gralloc_set_consumer_usage(gralloc1_device_t *device, gralloc1_buffer_descriptor_t descriptor,
+ /*uint64_t */ gralloc1_consumer_usage_t usage)
+{
+ int ret = 0;
+ ret = mali_gralloc_set_consumerusage_internal(descriptor, usage);
+ GRALLOC_UNUSED(device);
+ return ret;
+}
+
+static int32_t mali_gralloc_set_dimensions(gralloc1_device_t *device, gralloc1_buffer_descriptor_t descriptor,
+ uint32_t width, uint32_t height)
+{
+ int ret = 0;
+ ret = mali_gralloc_set_dimensions_internal(descriptor, width, height);
+ GRALLOC_UNUSED(device);
+ return ret;
+}
+
+static int32_t mali_gralloc_set_format(gralloc1_device_t *device, gralloc1_buffer_descriptor_t descriptor,
+ /*int32_t*/ android_pixel_format_t format)
+{
+ int ret = 0;
+ ret = mali_gralloc_set_format_internal(descriptor, format);
+ GRALLOC_UNUSED(device);
+ return ret;
+}
+
+static int32_t mali_gralloc_set_producer_usage(gralloc1_device_t *device, gralloc1_buffer_descriptor_t descriptor,
+ /*uint64_t */ gralloc1_producer_usage_t usage)
+{
+ int ret = 0;
+ ret = mali_gralloc_set_producerusage_internal(descriptor, usage);
+ GRALLOC_UNUSED(device);
+ return ret;
+}
+
+static int32_t mali_gralloc_get_backing_store(gralloc1_device_t *device, buffer_handle_t buffer,
+ gralloc1_backing_store_t *outStore)
+{
+ int ret = 0;
+ ret = mali_gralloc_get_backing_store_internal(buffer, outStore);
+ GRALLOC_UNUSED(device);
+ return ret;
+}
+
+static int32_t mali_gralloc_get_consumer_usage(gralloc1_device_t *device, buffer_handle_t buffer,
+ uint64_t * /*gralloc1_consumer_usage_t*/ outUsage)
+{
+ int ret = 0;
+ ret = mali_gralloc_get_consumer_usage_internal(buffer, outUsage);
+ GRALLOC_UNUSED(device);
+ return ret;
+}
+
+static int32_t mali_gralloc_get_dimensions(gralloc1_device_t *device, buffer_handle_t buffer, uint32_t *outWidth,
+ uint32_t *outHeight)
+{
+ int ret = 0;
+ ret = mali_gralloc_get_dimensions_internal(buffer, outWidth, outHeight);
+ GRALLOC_UNUSED(device);
+ return ret;
+}
+
+static int32_t mali_gralloc_get_format(gralloc1_device_t *device, buffer_handle_t buffer, int32_t *outFormat)
+{
+ int ret = 0;
+ ret = mali_gralloc_get_format_internal(buffer, outFormat);
+ GRALLOC_UNUSED(device);
+ return ret;
+}
+
+static int32_t mali_gralloc_get_producer_usage(gralloc1_device_t *device, buffer_handle_t buffer,
+ uint64_t * /*gralloc1_producer_usage_t*/ outUsage)
+{
+ int ret = 0;
+ ret = mali_gralloc_get_producer_usage_internal(buffer, outUsage);
+ GRALLOC_UNUSED(device);
+ return ret;
+}
+
+static int32_t mali_gralloc_get_stride(gralloc1_device_t *device, buffer_handle_t buffer, uint32_t *outStride)
+{
+ GRALLOC_UNUSED(device);
+
+ int stride;
+
+ if (mali_gralloc_query_getstride(buffer, &stride) < 0)
+ {
+ return GRALLOC1_ERROR_UNSUPPORTED;
+ }
+
+ *outStride = (uint32_t)stride;
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_allocate(gralloc1_device_t *device, uint32_t numDescriptors,
+ const gralloc1_buffer_descriptor_t *descriptors, buffer_handle_t *outBuffers)
+{
+ mali_gralloc_module *m;
+ m = reinterpret_cast<private_module_t *>(device->common.module);
+ buffer_descriptor_t *bufDescriptor = (buffer_descriptor_t *)(*descriptors);
+ uint64_t usage;
+ bool shared = false;
+
+ usage = bufDescriptor->producer_usage | bufDescriptor->consumer_usage;
+
+#if DISABLE_FRAMEBUFFER_HAL != 1
+
+ if (usage & GRALLOC_USAGE_HW_FB)
+ {
+ int byte_stride;
+ int pixel_stride;
+ int width, height;
+ uint64_t format;
+
+ format = bufDescriptor->hal_format;
+ width = bufDescriptor->width;
+ height = bufDescriptor->height;
+
+#if GRALLOC_FB_SWAP_RED_BLUE == 1
+#ifdef GRALLOC_16_BITS
+ format = HAL_PIXEL_FORMAT_RGB_565;
+#else
+ format = HAL_PIXEL_FORMAT_BGRA_8888;
+#endif
+#endif
+
+ if (fb_alloc_framebuffer(m, bufDescriptor->consumer_usage, bufDescriptor->producer_usage, outBuffers,
+ &pixel_stride, &byte_stride) < 0)
+ {
+ return GRALLOC1_ERROR_NO_RESOURCES;
+ }
+ else
+ {
+ private_handle_t *hnd = (private_handle_t *)*outBuffers;
+
+ /* Allocate a meta-data buffer for framebuffer too. fbhal
+ * ones wont need it but for hwc they will.
+ *
+ * Explicitly ignore allocation errors since it is not critical to have
+ */
+ (void)gralloc_buffer_attr_allocate(hnd);
+
+ hnd->req_format = format;
+ hnd->yuv_info = MALI_YUV_BT601_NARROW;
+ hnd->internal_format = format;
+ hnd->byte_stride = byte_stride;
+ hnd->width = width;
+ hnd->height = height;
+ hnd->stride = pixel_stride;
+ hnd->internalWidth = width;
+ hnd->internalHeight = height;
+ }
+ }
+ else
+#endif
+ {
+ if (mali_gralloc_buffer_allocate(m, (gralloc_buffer_descriptor_t *)descriptors, numDescriptors, outBuffers,
+ &shared) < 0)
+ {
+ ALOGE("Failed to allocate buffer.");
+ return GRALLOC1_ERROR_NO_RESOURCES;
+ }
+
+ if (!shared && 1 != numDescriptors)
+ {
+ return GRALLOC1_ERROR_NOT_SHARED;
+ }
+ }
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_retain(gralloc1_device_t *device, buffer_handle_t buffer)
+{
+ mali_gralloc_module *m;
+ m = reinterpret_cast<private_module_t *>(device->common.module);
+
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ if (mali_gralloc_reference_retain(m, buffer) < 0)
+ {
+ return GRALLOC1_ERROR_NO_RESOURCES;
+ }
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc_release(gralloc1_device_t *device, buffer_handle_t buffer)
+{
+ mali_gralloc_module *m;
+ m = reinterpret_cast<private_module_t *>(device->common.module);
+
+ if (mali_gralloc_reference_release(m, buffer, true) < 0)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc1_get_num_flex_planes(gralloc1_device_t *device, buffer_handle_t buffer,
+ uint32_t *outNumPlanes)
+{
+ mali_gralloc_module *m;
+ m = reinterpret_cast<private_module_t *>(device->common.module);
+
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ if (mali_gralloc_get_num_flex_planes(m, buffer, outNumPlanes) < 0)
+ {
+ return GRALLOC1_ERROR_UNSUPPORTED;
+ }
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc1_lock_async(gralloc1_device_t *device, buffer_handle_t buffer,
+ uint64_t /*gralloc1_producer_usage_t*/ producerUsage,
+ uint64_t /*gralloc1_consumer_usage_t*/ consumerUsage,
+ const gralloc1_rect_t *accessRegion, void **outData, int32_t acquireFence)
+{
+ mali_gralloc_module *m;
+ m = reinterpret_cast<private_module_t *>(device->common.module);
+
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ if (!((producerUsage | consumerUsage) & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)))
+ {
+ return GRALLOC1_ERROR_BAD_VALUE;
+ }
+
+ if (mali_gralloc_lock_async(m, buffer, producerUsage | consumerUsage, accessRegion->left, accessRegion->top,
+ accessRegion->width, accessRegion->height, outData, acquireFence) < 0)
+ {
+ return GRALLOC1_ERROR_UNSUPPORTED;
+ }
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc1_lock_flex_async(gralloc1_device_t *device, buffer_handle_t buffer,
+ uint64_t /*gralloc1_producer_usage_t*/ producerUsage,
+ uint64_t /*gralloc1_consumer_usage_t*/ consumerUsage,
+ const gralloc1_rect_t *accessRegion,
+ struct android_flex_layout *outFlexLayout, int32_t acquireFence)
+{
+ mali_gralloc_module *m;
+ m = reinterpret_cast<private_module_t *>(device->common.module);
+
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ if (!((producerUsage | consumerUsage) & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)))
+ {
+ return GRALLOC1_ERROR_BAD_VALUE;
+ }
+
+ if (mali_gralloc_lock_flex_async(m, buffer, producerUsage | consumerUsage, accessRegion->left, accessRegion->top,
+ accessRegion->width, accessRegion->height, outFlexLayout, acquireFence) < 0)
+ {
+ return GRALLOC1_ERROR_UNSUPPORTED;
+ }
+
+ return GRALLOC1_ERROR_NONE;
+}
+
+static int32_t mali_gralloc1_unlock_async(gralloc1_device_t *device, buffer_handle_t buffer, int32_t *outReleaseFence)
+{
+ mali_gralloc_module *m;
+ m = reinterpret_cast<private_module_t *>(device->common.module);
+
+ if (private_handle_t::validate(buffer) < 0)
+ {
+ return GRALLOC1_ERROR_BAD_HANDLE;
+ }
+
+ mali_gralloc_unlock_async(m, buffer, outReleaseFence);
+ return GRALLOC1_ERROR_NONE;
+}
+
+static const mali_gralloc_func mali_gralloc_func_list[] = {
+ { GRALLOC1_FUNCTION_DUMP, (gralloc1_function_pointer_t)mali_gralloc_dump },
+ { GRALLOC1_FUNCTION_CREATE_DESCRIPTOR, (gralloc1_function_pointer_t)mali_gralloc_create_descriptor },
+ { GRALLOC1_FUNCTION_DESTROY_DESCRIPTOR, (gralloc1_function_pointer_t)mali_gralloc_destroy_descriptor },
+ { GRALLOC1_FUNCTION_SET_CONSUMER_USAGE, (gralloc1_function_pointer_t)mali_gralloc_set_consumer_usage },
+ { GRALLOC1_FUNCTION_SET_DIMENSIONS, (gralloc1_function_pointer_t)mali_gralloc_set_dimensions },
+ { GRALLOC1_FUNCTION_SET_FORMAT, (gralloc1_function_pointer_t)mali_gralloc_set_format },
+ { GRALLOC1_FUNCTION_SET_PRODUCER_USAGE, (gralloc1_function_pointer_t)mali_gralloc_set_producer_usage },
+ { GRALLOC1_FUNCTION_GET_BACKING_STORE, (gralloc1_function_pointer_t)mali_gralloc_get_backing_store },
+ { GRALLOC1_FUNCTION_GET_CONSUMER_USAGE, (gralloc1_function_pointer_t)mali_gralloc_get_consumer_usage },
+ { GRALLOC1_FUNCTION_GET_DIMENSIONS, (gralloc1_function_pointer_t)mali_gralloc_get_dimensions },
+ { GRALLOC1_FUNCTION_GET_FORMAT, (gralloc1_function_pointer_t)mali_gralloc_get_format },
+ { GRALLOC1_FUNCTION_GET_PRODUCER_USAGE, (gralloc1_function_pointer_t)mali_gralloc_get_producer_usage },
+ { GRALLOC1_FUNCTION_GET_STRIDE, (gralloc1_function_pointer_t)mali_gralloc_get_stride },
+ { GRALLOC1_FUNCTION_ALLOCATE, (gralloc1_function_pointer_t)mali_gralloc_allocate },
+ { GRALLOC1_FUNCTION_RETAIN, (gralloc1_function_pointer_t)mali_gralloc_retain },
+ { GRALLOC1_FUNCTION_RELEASE, (gralloc1_function_pointer_t)mali_gralloc_release },
+ { GRALLOC1_FUNCTION_GET_NUM_FLEX_PLANES, (gralloc1_function_pointer_t)mali_gralloc1_get_num_flex_planes },
+ { GRALLOC1_FUNCTION_LOCK, (gralloc1_function_pointer_t)mali_gralloc1_lock_async },
+ { GRALLOC1_FUNCTION_LOCK_FLEX, (gralloc1_function_pointer_t)mali_gralloc1_lock_flex_async },
+ { GRALLOC1_FUNCTION_UNLOCK, (gralloc1_function_pointer_t)mali_gralloc1_unlock_async },
+
+ /* GRALLOC1_FUNCTION_INVALID has to be the last descriptor on the list. */
+ { GRALLOC1_FUNCTION_INVALID, NULL }
+};
+
+static void mali_gralloc_getCapabilities(gralloc1_device_t *dev, uint32_t *outCount, int32_t *outCapabilities)
+{
+ GRALLOC_UNUSED(dev);
+ GRALLOC_UNUSED(outCapabilities);
+
+ if (outCount != NULL)
+ {
+ *outCount = 0;
+ }
+}
+
+static gralloc1_function_pointer_t mali_gralloc_getFunction(gralloc1_device_t *dev, int32_t descriptor)
+{
+ GRALLOC_UNUSED(dev);
+ gralloc1_function_pointer_t rval = NULL;
+ uint32_t pos = 0;
+
+ while (mali_gralloc_func_list[pos].desc != GRALLOC1_FUNCTION_INVALID)
+ {
+ if (mali_gralloc_func_list[pos].desc == descriptor)
+ {
+ rval = mali_gralloc_func_list[pos].func;
+ break;
+ }
+
+ pos++;
+ }
+
+ if (rval == NULL)
+ {
+ rval = mali_gralloc_private_interface_getFunction(descriptor);
+ }
+
+ return rval;
+}
+
+int mali_gralloc_device_open(hw_module_t const *module, const char *name, hw_device_t **device)
+{
+ gralloc1_device_t *dev;
+
+ GRALLOC_UNUSED(name);
+
+ dev = new gralloc1_device_t;
+
+ if (NULL == dev)
+ {
+ return -1;
+ }
+
+ /* initialize our state here */
+ memset(dev, 0, sizeof(*dev));
+
+ /* initialize the procs */
+ dev->common.tag = HARDWARE_DEVICE_TAG;
+ dev->common.version = 0;
+ dev->common.module = const_cast<hw_module_t *>(module);
+ dev->common.close = mali_gralloc_ion_device_close;
+
+ dev->getCapabilities = mali_gralloc_getCapabilities;
+ dev->getFunction = mali_gralloc_getFunction;
+
+ *device = &dev->common;
+
+ return 0;
+}
diff --git a/gralloc960/mali_gralloc_public_interface.h b/gralloc960/mali_gralloc_public_interface.h
new file mode 100644
index 00000000..b35d11cf
--- /dev/null
+++ b/gralloc960/mali_gralloc_public_interface.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2016 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef MALI_GRALLOC_PUBLIC_INTERFACE_H_
+#define MALI_GRALLOC_PUBLIC_INTERFACE_H_
+
+#include <hardware/hardware.h>
+
+int mali_gralloc_device_open(hw_module_t const *module, const char *name, hw_device_t **device);
+
+#endif /* MALI_GRALLOC_PUBLIC_INTERFACE_H_ */
diff --git a/gralloc960/mali_gralloc_reference.cpp b/gralloc960/mali_gralloc_reference.cpp
new file mode 100644
index 00000000..826a3911
--- /dev/null
+++ b/gralloc960/mali_gralloc_reference.cpp
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2016 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <hardware/hardware.h>
+
+#if GRALLOC_USE_GRALLOC1_API == 1
+#include <hardware/gralloc1.h>
+#else
+#include <hardware/gralloc.h>
+#endif
+
+#include "mali_gralloc_module.h"
+#include "mali_gralloc_private_interface_types.h"
+#include "mali_gralloc_buffer.h"
+#include "mali_gralloc_ion.h"
+#include "gralloc_buffer_priv.h"
+#include "mali_gralloc_bufferallocation.h"
+#include "mali_gralloc_debug.h"
+
+static pthread_mutex_t s_map_lock = PTHREAD_MUTEX_INITIALIZER;
+
+int mali_gralloc_reference_retain(mali_gralloc_module const *module, buffer_handle_t handle)
+{
+ GRALLOC_UNUSED(module);
+
+ if (private_handle_t::validate(handle) < 0)
+ {
+ AERR("Registering/Retaining invalid buffer %p, returning error", handle);
+ return -EINVAL;
+ }
+
+ private_handle_t *hnd = (private_handle_t *)handle;
+ pthread_mutex_lock(&s_map_lock);
+
+ if (hnd->allocating_pid == getpid() || hnd->remote_pid == getpid())
+ {
+ hnd->ref_count++;
+ pthread_mutex_unlock(&s_map_lock);
+ return 0;
+ }
+ else
+ {
+ hnd->remote_pid = getpid();
+ hnd->ref_count = 1;
+ }
+
+ int retval = -EINVAL;
+
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
+ {
+ retval = 0;
+ }
+ else if (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_ION))
+ {
+ retval = mali_gralloc_ion_map(hnd);
+ }
+ else
+ {
+ AERR("unkown buffer flags not supported. flags = %d", hnd->flags);
+ }
+
+ pthread_mutex_unlock(&s_map_lock);
+ return retval;
+}
+
+int mali_gralloc_reference_release(mali_gralloc_module const *module, buffer_handle_t handle, bool canFree)
+{
+ GRALLOC_UNUSED(module);
+
+ if (private_handle_t::validate(handle) < 0)
+ {
+ AERR("unregistering/releasing invalid buffer %p, returning error", handle);
+ return -EINVAL;
+ }
+
+ private_handle_t *hnd = (private_handle_t *)handle;
+ pthread_mutex_lock(&s_map_lock);
+
+ if (hnd->ref_count == 0)
+ {
+ AERR("Buffer %p should have already been released", handle);
+ pthread_mutex_unlock(&s_map_lock);
+ return -EINVAL;
+ }
+
+ if (hnd->allocating_pid == getpid())
+ {
+ hnd->ref_count--;
+
+ if (hnd->ref_count == 0 && canFree)
+ {
+
+ if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
+ {
+ close(hnd->fd);
+ }
+ else
+ {
+ mali_gralloc_dump_buffer_erase(hnd);
+ }
+ mali_gralloc_buffer_free(handle);
+ delete handle;
+
+ }
+ }
+ else if (hnd->remote_pid == getpid()) // never unmap buffers that were not imported into this process
+ {
+ hnd->ref_count--;
+
+ if (hnd->ref_count == 0)
+ {
+
+ if (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_ION))
+ {
+ mali_gralloc_ion_unmap(hnd);
+ }
+ else
+ {
+ AERR("Unregistering/Releasing unknown buffer is not supported. Flags = %d", hnd->flags);
+ }
+
+ /*
+ * Close shared attribute region file descriptor. It might seem strange to "free"
+ * this here since this can happen in a client process, but free here is nothing
+ * but unmapping and closing the duplicated file descriptor. The original ashmem
+ * fd instance is still open until alloc_device_free() is called. Even sharing
+ * of gralloc buffers within the same process should have fds dup:ed.
+ */
+ gralloc_buffer_attr_free(hnd);
+
+ hnd->base = 0;
+ hnd->writeOwner = 0;
+ }
+ }
+ else
+ {
+ AERR("Trying to unregister buffer %p from process %d that was not imported into current process: %d", hnd,
+ hnd->remote_pid, getpid());
+ }
+
+ pthread_mutex_unlock(&s_map_lock);
+ return 0;
+}
diff --git a/gralloc960/mali_gralloc_reference.h b/gralloc960/mali_gralloc_reference.h
new file mode 100644
index 00000000..5fa6809e
--- /dev/null
+++ b/gralloc960/mali_gralloc_reference.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2016 ARM Limited. All rights reserved.
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MALI_GRALLOC_REFERENCE_H_
+#define MALI_GRALLOC_REFERENCE_H_
+
+#include "gralloc_priv.h"
+
+int mali_gralloc_reference_retain(mali_gralloc_module const *module, buffer_handle_t handle);
+int mali_gralloc_reference_release(mali_gralloc_module const *module, buffer_handle_t handle, bool canFree);
+
+#endif /* MALI_GRALLOC_REFERENCE_H_ */
diff --git a/gralloc960/mali_gralloc_usages.h b/gralloc960/mali_gralloc_usages.h
new file mode 100644
index 00000000..4f034ebe
--- /dev/null
+++ b/gralloc960/mali_gralloc_usages.h
@@ -0,0 +1,92 @@
+/*
+ * (C) COPYRIGHT 2017 ARM Limited. All rights reserved.
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MALI_GRALLOC_USAGES_H_
+#define MALI_GRALLOC_USAGES_H_
+
+/*
+ * Below usage types overlap, this is intentional.
+ * The reason is that for Gralloc 0.3 there are very
+ * few usage flags we have at our disposal.
+ *
+ * The overlapping is handled by processing the definitions
+ * in a specific order.
+ *
+ * MALI_GRALLOC_USAGE_PRIVATE_FORMAT and MALI_GRALLOC_USAGE_NO_AFBC
+ * don't overlap and are processed first.
+ *
+ * MALI_GRALLOC_USAGE_YUV_CONF are only for YUV formats and clients
+ * using MALI_GRALLOC_USAGE_NO_AFBC must never allocate YUV formats.
+ * The latter is strictly enforced and allocations will fail.
+ *
+ * MALI_GRALLOC_USAGE_AFBC_PADDING is only valid if MALI_GRALLOC_USAGE_NO_AFBC
+ * is not present.
+ */
+
+/*
+ * Gralloc private usage 0-3 are the same in 0.3 and 1.0.
+ * We defined based our usages based on what is available.
+ */
+#if defined(GRALLOC_MODULE_API_VERSION_1_0)
+typedef enum
+{
+ /* The client has specified a private format in the format parameter */
+ MALI_GRALLOC_USAGE_PRIVATE_FORMAT = (int)GRALLOC1_PRODUCER_USAGE_PRIVATE_3,
+
+ /* Buffer won't be allocated as AFBC */
+ MALI_GRALLOC_USAGE_NO_AFBC = (int)(GRALLOC1_PRODUCER_USAGE_PRIVATE_1 | GRALLOC1_PRODUCER_USAGE_PRIVATE_2),
+
+ /* Valid only for YUV allocations */
+ MALI_GRALLOC_USAGE_YUV_CONF_0 = 0,
+ MALI_GRALLOC_USAGE_YUV_CONF_1 = (int)GRALLOC1_PRODUCER_USAGE_PRIVATE_1,
+ MALI_GRALLOC_USAGE_YUV_CONF_2 = (int)GRALLOC1_PRODUCER_USAGE_PRIVATE_0,
+ MALI_GRALLOC_USAGE_YUV_CONF_3 = (int)(GRALLOC1_PRODUCER_USAGE_PRIVATE_0 | GRALLOC1_PRODUCER_USAGE_PRIVATE_1),
+ MALI_GRALLOC_USAGE_YUV_CONF_MASK = MALI_GRALLOC_USAGE_YUV_CONF_3,
+
+ /* A very specific alignment is requested on some buffers */
+ MALI_GRALLOC_USAGE_AFBC_PADDING = (int)GRALLOC1_PRODUCER_USAGE_PRIVATE_2,
+
+} mali_gralloc_usage_type;
+#elif defined(GRALLOC_MODULE_API_VERSION_0_3)
+typedef enum
+{
+ /* The client has specified a private format in the format parameter */
+ MALI_GRALLOC_USAGE_PRIVATE_FORMAT = (int)GRALLOC_USAGE_PRIVATE_3,
+
+ /* Buffer won't be allocated as AFBC */
+ MALI_GRALLOC_USAGE_NO_AFBC = (int)(GRALLOC_USAGE_PRIVATE_1 | GRALLOC_USAGE_PRIVATE_2),
+
+ /* Valid only for YUV allocations */
+ MALI_GRALLOC_USAGE_YUV_CONF_0 = 0,
+ MALI_GRALLOC_USAGE_YUV_CONF_1 = (int)GRALLOC_USAGE_PRIVATE_1,
+ MALI_GRALLOC_USAGE_YUV_CONF_2 = (int)GRALLOC_USAGE_PRIVATE_0,
+ MALI_GRALLOC_USAGE_YUV_CONF_3 = (int)(GRALLOC_USAGE_PRIVATE_0 | GRALLOC_USAGE_PRIVATE_1),
+ MALI_GRALLOC_USAGE_YUV_CONF_MASK = MALI_GRALLOC_USAGE_YUV_CONF_3,
+
+ /* A very specific alignment is requested on some buffers */
+ MALI_GRALLOC_USAGE_AFBC_PADDING = GRALLOC_USAGE_PRIVATE_2,
+
+} mali_gralloc_usage_type;
+#else
+#if defined(GRALLOC_LIBRARY_BUILD)
+#error "Please include mali_gralloc_module.h before including other gralloc headers when building gralloc itself"
+#else
+#error "Please include either gralloc.h or gralloc1.h header before including gralloc_priv.h"
+#endif
+#endif
+
+#endif /*MALI_GRALLOC_USAGES_H_*/
diff --git a/hifi/firmware/hifi-hikey960.img b/hifi/firmware/hifi-hikey960.img
index 7656fac8..b8c25169 100644
--- a/hifi/firmware/hifi-hikey960.img
+++ b/hifi/firmware/hifi-hikey960.img
Binary files differ
diff --git a/self-extractors_hikey960/arm/staging/BoardConfigPartial.mk b/hifi/xaf/Android.mk
index c0aab8ba..f3377fec 100644
--- a/self-extractors_hikey960/arm/staging/BoardConfigPartial.mk
+++ b/hifi/xaf/Android.mk
@@ -1,4 +1,5 @@
-# Copyright 2016 The Android Open Source Project
+#
+# Copyright 2017 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.
@@ -11,3 +12,6 @@
# WITHOUT 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 $(all-subdir-makefiles)
diff --git a/hifi/xaf/README b/hifi/xaf/README
new file mode 100755
index 00000000..9c835768
--- /dev/null
+++ b/hifi/xaf/README
@@ -0,0 +1,39 @@
+
+.
+|--- README
+|   - This file
+|  
+|--- release.txt
+|   - Release notes
+|  
+|--- config
+| |  
+|   |--- hifi3_hikey960_linux.tgz
+| |   - HiKey960 HiFi3 LX6 config with SW upgraded to RG.5 tools for Linux
+| |  
+|   |-- hifi3_hikey960_win32.tgz
+|   - HiKey960 HiFi3 LX6 config with SW upgraded to RG.5 tools for Windows
+|  
+|--- docs
+| |  
+|   |--- HiFi-AF-Hosted-ProgrammersGuide.pdf
+| |   - Xtensa Audio Framework (Hosted) Programmers Guide, v0.6
+| |  
+|   |--- HiFi-Audio-Codec-API-Definition.pdf
+| |   - HiFi Audio Codec API Definition, v1.0
+| |  
+|   |--- HiFi-Speech-Codec-API-Definition.pdf
+| |   - HiFi Speech Codec API Definition, v1.0
+| |  
+|   |-- HiKey960-HiFi3-Android-SDK-Guide.pdf
+|   - HiKey960-HiFi3-Android-SDK Guide, v0.7
+|  
+|--- xaf-dsp-v0.7_Alpha.tgz
+|   - XAF DSP Firmware Source Code(hifi-dpf)
+|  
+|-- xaf-host-v0.7_Alpha.tgz
+| - XAF Host application Source Code(host-apf)
+|
+|-- Get xtensa tools and guide to install xtensa tools,HiKey960 HiFi3 LX6 config
+| -https://www.tensilicatools.com/platform/huawei-kirin-960/
+|
diff --git a/hifi/xaf/config/hifi3_hikey960_linux.tgz b/hifi/xaf/config/hifi3_hikey960_linux.tgz
new file mode 100755
index 00000000..81152190
--- /dev/null
+++ b/hifi/xaf/config/hifi3_hikey960_linux.tgz
Binary files differ
diff --git a/hifi/xaf/config/hifi3_hikey960_win32.tgz b/hifi/xaf/config/hifi3_hikey960_win32.tgz
new file mode 100755
index 00000000..32871752
--- /dev/null
+++ b/hifi/xaf/config/hifi3_hikey960_win32.tgz
Binary files differ
diff --git a/hifi/xaf/docs/HiFi-AF-Hosted-ProgrammersGuide.pdf b/hifi/xaf/docs/HiFi-AF-Hosted-ProgrammersGuide.pdf
new file mode 100755
index 00000000..3499a875
--- /dev/null
+++ b/hifi/xaf/docs/HiFi-AF-Hosted-ProgrammersGuide.pdf
Binary files differ
diff --git a/hifi/xaf/docs/HiFi-Audio-Codec-API-Definition.pdf b/hifi/xaf/docs/HiFi-Audio-Codec-API-Definition.pdf
new file mode 100755
index 00000000..179d13b3
--- /dev/null
+++ b/hifi/xaf/docs/HiFi-Audio-Codec-API-Definition.pdf
Binary files differ
diff --git a/hifi/xaf/docs/HiFi-Speech-Codec-API-Definition.pdf b/hifi/xaf/docs/HiFi-Speech-Codec-API-Definition.pdf
new file mode 100755
index 00000000..2b6a68ac
--- /dev/null
+++ b/hifi/xaf/docs/HiFi-Speech-Codec-API-Definition.pdf
Binary files differ
diff --git a/hifi/xaf/docs/HiKey960-HiFi3-Android-SDK-Guide.pdf b/hifi/xaf/docs/HiKey960-HiFi3-Android-SDK-Guide.pdf
new file mode 100755
index 00000000..ea3c07a4
--- /dev/null
+++ b/hifi/xaf/docs/HiKey960-HiFi3-Android-SDK-Guide.pdf
Binary files differ
diff --git a/hifi/xaf/docs/Hosted_XAF_Arch_v0.7.pdf b/hifi/xaf/docs/Hosted_XAF_Arch_v0.7.pdf
new file mode 100755
index 00000000..f5b372f4
--- /dev/null
+++ b/hifi/xaf/docs/Hosted_XAF_Arch_v0.7.pdf
Binary files differ
diff --git a/hifi/xaf/hifi-dpf/app/xa-factory.c b/hifi/xaf/hifi-dpf/app/xa-factory.c
new file mode 100644
index 00000000..b9e7d193
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/app/xa-factory.c
@@ -0,0 +1,163 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-factory.c
+ *
+ * DSP processing framework core - component factory
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG FACTORY
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+#include "audio/xa_type_def.h"
+
+/*******************************************************************************
+ * Tracing tags
+ ******************************************************************************/
+
+/* ...general initialization sequence */
+TRACE_TAG(INIT, 1);
+
+/*******************************************************************************
+ * Local types definitions
+ ******************************************************************************/
+
+/* ...component descriptor */
+typedef struct xf_component_id
+{
+ /* ...class id (string identifier) */
+ const char *id;
+
+ /* ...class constructor */
+ xf_component_t * (*factory)(u32 core, xa_codec_func_t process);
+
+ /* ...component API function */
+ xa_codec_func_t *process;
+
+} xf_component_id_t;
+
+/*******************************************************************************
+ * External functions
+ ******************************************************************************/
+
+/* ...components API functions */
+extern XA_ERRORCODE xa_pcm_codec(xa_codec_handle_t, WORD32, WORD32, pVOID);
+extern XA_ERRORCODE xa_mp3_decoder(xa_codec_handle_t, WORD32, WORD32, pVOID);
+extern XA_ERRORCODE xa_aac_decoder(xa_codec_handle_t, WORD32, WORD32, pVOID);
+extern XA_ERRORCODE xa_aac_encoder(xa_codec_handle_t, WORD32, WORD32, pVOID);
+extern XA_ERRORCODE xa_vorbis_decoder(xa_codec_handle_t, WORD32, WORD32, pVOID);
+extern XA_ERRORCODE xa_ac3_decoder(xa_codec_handle_t, WORD32, WORD32, pVOID);
+extern XA_ERRORCODE xa_ddplus71_decoder(xa_codec_handle_t, WORD32, WORD32, pVOID);
+extern XA_ERRORCODE xa_mixer(xa_codec_handle_t, WORD32, WORD32, pVOID);
+extern XA_ERRORCODE xa_renderer(xa_codec_handle_t, WORD32, WORD32, pVOID);
+extern XA_ERRORCODE xa_capturer(xa_codec_handle_t, WORD32, WORD32, pVOID);
+extern XA_ERRORCODE xa_src_pp_fx(xa_codec_handle_t, WORD32, WORD32, pVOID);
+extern XA_ERRORCODE xa_dts_hd_decoder(xa_codec_handle_t, WORD32, WORD32, pVOID);
+extern XA_ERRORCODE xa_dap_fx(xa_codec_handle_t, WORD32, WORD32, pVOID);
+
+/* ...component class factories */
+extern xf_component_t * xa_audio_codec_factory(u32 core, xa_codec_func_t process);
+extern xf_component_t * xa_audio_fx_factory(u32 core, xa_codec_func_t process);
+extern xf_component_t * xa_mixer_factory(u32 core, xa_codec_func_t process);
+extern xf_component_t * xa_renderer_factory(u32 core,xa_codec_func_t process);
+
+/*******************************************************************************
+ * Local constants definitions
+ ******************************************************************************/
+
+/* ...component class id */
+static const xf_component_id_t xf_component_id[] =
+{
+#if XA_PCM
+ { "audio-decoder/pcm", xa_audio_codec_factory, xa_pcm_codec },
+#endif
+#if XA_MP3_DECODER
+ { "audio-decoder/mp3", xa_audio_codec_factory, xa_mp3_decoder },
+#endif
+#if XA_AAC_DECODER
+ { "audio-decoder/aac", xa_audio_codec_factory, xa_aac_decoder },
+#endif
+#if XA_AC3_DECODER
+ { "audio-decoder/ac3", xa_audio_codec_factory, xa_ac3_decoder },
+#endif
+#if XA_DDP71_DECODER
+ { "audio-decoder/ddplus71", xa_audio_codec_factory, xa_ddplus71_decoder },
+#endif
+#if XA_DTS_HD_DECODER
+ { "audio-decoder/dts-hd", xa_audio_codec_factory, xa_dts_hd_decoder },
+#endif
+#if XA_VORBIS_DECODER
+ { "audio-decoder/vorbis", xa_audio_codec_factory, xa_vorbis_decoder },
+#endif
+#if XA_AAC_ENCODER
+ { "audio-encoder/aac", xa_audio_codec_factory, xa_aac_encoder },
+#endif
+#if XA_SRC_PP_FX
+ { "audio-fx/src-pp", xa_audio_codec_factory, xa_src_pp_fx },
+#endif
+#if XA_DAP_FX
+ { "audio-fx/dap", xa_audio_codec_factory, xa_dap_fx },
+#endif
+#if XA_MIXER
+ { "mixer", xa_mixer_factory, xa_mixer },
+#endif
+#if XA_RENDERER
+ { "renderer", xa_renderer_factory, xa_renderer },
+#endif
+#if XA_CAPTURER
+ { "capturer", xa_capturer_factory, xa_capturer },
+#endif
+};
+
+/* ...number of items in the map */
+#define XF_COMPONENT_ID_MAX (sizeof(xf_component_id) / sizeof(xf_component_id[0]))
+
+/*******************************************************************************
+ * Enry points
+ ******************************************************************************/
+
+xf_component_t * xf_component_factory(u32 core, xf_id_t id, u32 length)
+{
+ u32 i;
+
+ /* ...find component-id in static map */
+ for (i = 0; i < XF_COMPONENT_ID_MAX; i++)
+ {
+ /* ...symbolic search - not too good; would prefer GUIDs in some form */
+ if (!strncmp(id, xf_component_id[i].id, length))
+ {
+ /* ...pass control to specific class factory */
+ return xf_component_id[i].factory(core, xf_component_id[i].process);
+ }
+ }
+
+ /* ...component string id is not recognized */
+ TRACE(ERROR, _b("Unknown component type: %s"), id);
+
+ return NULL;
+}
diff --git a/hifi/xaf/hifi-dpf/audio/xa-class-audio-codec.c b/hifi/xaf/hifi-dpf/audio/xa-class-audio-codec.c
new file mode 100644
index 00000000..3806548f
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/audio/xa-class-audio-codec.c
@@ -0,0 +1,785 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-class-audio-codec.c
+ *
+ * Generic audio codec task implementation
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG CODEC
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+#include "xa-class-base.h"
+#include "audio/xa-audio-decoder-api.h"
+
+/*******************************************************************************
+ * Tracing configuration
+ ******************************************************************************/
+
+TRACE_TAG(INIT, 1);
+TRACE_TAG(WARNING, 1);
+TRACE_TAG(INFO, 1);
+TRACE_TAG(INPUT, 1);
+TRACE_TAG(OUTPUT, 1);
+TRACE_TAG(DECODE, 1);
+
+/*******************************************************************************
+ * Internal functions definitions
+ ******************************************************************************/
+
+typedef struct XAAudioCodec
+{
+ /***************************************************************************
+ * Control data
+ **************************************************************************/
+
+ /* ...generic audio codec data */
+ XACodecBase base;
+
+ /* ...input port data */
+ xf_input_port_t input;
+
+ /* ...output port data */
+ xf_output_port_t output;
+
+ /* ...input port index */
+ WORD32 in_idx;
+
+ /* ...output port index */
+ WORD32 out_idx;
+
+ /***************************************************************************
+ * Run-time configuration parameters
+ **************************************************************************/
+
+ /* ...sample size in bytes */
+ u32 sample_size;
+
+ /* ...audio sample duration */
+ u32 factor;
+
+ /* ...total number of produced audio frames since last reset */
+ u32 produced;
+
+} XAAudioCodec;
+
+/*******************************************************************************
+ * Auxiliary codec execution flags
+ ******************************************************************************/
+
+/* ...input port setup condition */
+#define XA_CODEC_FLAG_INPUT_SETUP __XA_BASE_FLAG(1 << 0)
+
+/* ...output port setup condition */
+#define XA_CODEC_FLAG_OUTPUT_SETUP __XA_BASE_FLAG(1 << 1)
+
+/*******************************************************************************
+ * Data processing scheduling
+ ******************************************************************************/
+
+/* ...prepare codec for steady operation (tbd - don't absolutely like it) */
+static inline XA_ERRORCODE xa_codec_prepare_runtime(XAAudioCodec *codec)
+{
+ XACodecBase *base = (XACodecBase *)codec;
+ xf_message_t *m = xf_msg_queue_head(&codec->output.queue);
+ xf_start_msg_t *msg = m->buffer;
+ u32 frame_size;
+ u32 factor;
+
+ /* ...fill-in buffer parameters */
+ XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_CODEC_CONFIG_PARAM_SAMPLE_RATE, &msg->sample_rate);
+ XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_CODEC_CONFIG_PARAM_CHANNELS, &msg->channels);
+ XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_CODEC_CONFIG_PARAM_PCM_WIDTH, &msg->pcm_width);
+ XA_API(base, XA_API_CMD_GET_MEM_INFO_SIZE, codec->in_idx, &msg->input_length);
+ XA_API(base, XA_API_CMD_GET_MEM_INFO_SIZE, codec->out_idx, &msg->output_length);
+
+ TRACE(INIT, _b("codec[%p]::runtime init: f=%u, c=%u, w=%u, i=%u, o=%u"), codec, msg->sample_rate, msg->channels, msg->pcm_width, msg->input_length, msg->output_length);
+
+ /* ...reallocate input port buffer as needed - tbd */
+ BUG(msg->input_length > codec->input.length, _x("Input buffer reallocation required: %u to %u"), codec->input.length, msg->input_length);
+
+ /* ...save sample size in bytes */
+ codec->sample_size = msg->channels * (msg->pcm_width == 16 ? 2 : 4);
+
+ /* ...calculate frame duration; get number of samples in the frame (don't like division here - tbd) */
+ frame_size = msg->output_length / codec->sample_size;
+
+ /* ...it must be a multiple */
+ XF_CHK_ERR(frame_size * codec->sample_size == msg->output_length, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...retrieve upsampling factor for given sample rate */
+ XF_CHK_ERR(factor = xf_timebase_factor(msg->sample_rate), XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...set frame duration factor (converts number of bytes into timebase units) */
+ codec->factor = factor / codec->sample_size;
+
+ TRACE(INIT, _b("ts-factor: %u (%u)"), codec->factor, factor);
+
+ BUG(codec->factor * codec->sample_size != factor, _x("Freq mismatch: %u vs %u"), codec->factor * codec->sample_size, factor);
+
+ /* ...pass response to caller (push out of output port) */
+ xf_output_port_produce(&codec->output, sizeof(*msg));
+
+ /* ...codec runtime initialization is completed */
+ TRACE(INIT, _b("codec[%p] runtime initialized: i=%u, o=%u"), codec, msg->input_length, msg->output_length);
+
+ return XA_NO_ERROR;
+}
+
+/*******************************************************************************
+ * Commands processing
+ ******************************************************************************/
+
+/* ...EMPTY-THIS-BUFFER command processing */
+static XA_ERRORCODE xa_codec_empty_this_buffer(XACodecBase *base, xf_message_t *m)
+{
+ XAAudioCodec *codec = (XAAudioCodec *) base;
+
+ /* ...make sure the port is sane */
+ XF_CHK_ERR(XF_MSG_DST_PORT(m->id) == 0, XA_API_FATAL_INVALID_CMD);
+
+ /* ...command is allowed only in post-init state */
+ XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD);
+
+ /* ...put message into input queue */
+ if (xf_input_port_put(&codec->input, m))
+ {
+ /* ...restart stream if it is in completed state */
+ if (base->state & XA_BASE_FLAG_COMPLETED)
+ {
+ /* ...reset execution stage */
+ base->state = XA_BASE_FLAG_POSTINIT | XA_BASE_FLAG_EXECUTION;
+
+ /* ...reset execution runtime */
+ XA_API(base, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DO_RUNTIME_INIT, NULL);
+
+ /* ...reset produced samples counter */
+ codec->produced = 0;
+ }
+
+ /* ...codec must be in one of these states */
+ XF_CHK_ERR(base->state & (XA_BASE_FLAG_RUNTIME_INIT | XA_BASE_FLAG_EXECUTION), XA_API_FATAL_INVALID_CMD);
+
+ /* ...schedule data processing if output is ready */
+ if (xf_output_port_ready(&codec->output))
+ {
+ xa_base_schedule(base, 0);
+ }
+ }
+
+ TRACE(INPUT, _b("Received buffer [%p]:%u"), m->buffer, m->length);
+
+ return XA_NO_ERROR;
+}
+
+/* ...FILL-THIS-BUFFER command processing */
+static XA_ERRORCODE xa_codec_fill_this_buffer(XACodecBase *base, xf_message_t *m)
+{
+ XAAudioCodec *codec = (XAAudioCodec *) base;
+
+ /* ...make sure the port is sane */
+ XF_CHK_ERR(XF_MSG_DST_PORT(m->id) == 1, XA_API_FATAL_INVALID_CMD);
+
+ /* ...command is allowed only in postinit state */
+ XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD);
+
+ /* ...special handling of zero-length buffer */
+ if (base->state & XA_BASE_FLAG_RUNTIME_INIT)
+ {
+ /* ...message must be zero-length */
+ BUG(m->length != 0, _x("Invalid message length: %u"), m->length);
+ }
+ else if (m == xf_output_port_control_msg(&codec->output))
+ {
+ /* ...end-of-stream processing indication received; check the state */
+ BUG((base->state & XA_BASE_FLAG_COMPLETED) == 0, _x("invalid state: %x"), base->state);
+
+ /* ... mark flushing sequence is done */
+ xf_output_port_flush_done(&codec->output);
+
+ /* ...complete pending zero-length input buffer */
+ xf_input_port_purge(&codec->input);
+
+ TRACE(INFO, _b("codec[%p] playback completed"), codec);
+
+ /* ...playback is over */
+ return XA_NO_ERROR;
+ }
+ else if ((base->state & XA_BASE_FLAG_COMPLETED) && !xf_output_port_routed(&codec->output))
+ {
+ /* ...return message arrived from application immediately */
+ xf_response_ok(m);
+
+ return XA_NO_ERROR;
+ }
+ else
+ {
+ TRACE(OUTPUT, _b("Received output buffer [%p]:%u"), m->buffer, m->length);
+
+ /* ...adjust message length (may be shorter than original) */
+ m->length = codec->output.length;
+ }
+
+ /* ...place message into output port */
+ if (xf_output_port_put(&codec->output, m) && xf_input_port_ready(&codec->input))
+ {
+ /* ...schedule data processing instantly */
+ if (base->state & (XA_BASE_FLAG_RUNTIME_INIT | XA_BASE_FLAG_EXECUTION))
+ {
+ xa_base_schedule(base, 0);
+ }
+ }
+
+ return XA_NO_ERROR;
+}
+
+/* ...output port routing */
+static XA_ERRORCODE xa_codec_port_route(XACodecBase *base, xf_message_t *m)
+{
+ XAAudioCodec *codec = (XAAudioCodec *) base;
+ xf_route_port_msg_t *cmd = m->buffer;
+ xf_output_port_t *port = &codec->output;
+ u32 src = XF_MSG_DST(m->id);
+ u32 dst = cmd->dst;
+
+ /* ...command is allowed only in "postinit" state */
+ XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD);
+
+ /* ...make sure output port is addressed */
+ XF_CHK_ERR(XF_MSG_DST_PORT(m->id) == 1, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...make sure port is not routed yet */
+ XF_CHK_ERR(!xf_output_port_routed(port), XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...route output port - allocate queue */
+ XF_CHK_ERR(xf_output_port_route(port, __XF_MSG_ID(dst, src), cmd->alloc_number, cmd->alloc_size, cmd->alloc_align) == 0, XA_API_FATAL_MEM_ALLOC);
+
+ /* ...schedule processing instantly */
+ xa_base_schedule(base, 0);
+
+ /* ...pass success result to caller */
+ xf_response_ok(m);
+
+ return XA_NO_ERROR;
+}
+
+/* ...port unroute command */
+static XA_ERRORCODE xa_codec_port_unroute(XACodecBase *base, xf_message_t *m)
+{
+ XAAudioCodec *codec = (XAAudioCodec *) base;
+
+ /* ...command is allowed only in "postinit" state */
+ XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD);
+
+ /* ...make sure output port is addressed */
+ XF_CHK_ERR(XF_MSG_DST_PORT(m->id) == 1, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...cancel any pending processing */
+ xa_base_cancel(base);
+
+ /* ...clear output-port-setup condition */
+ base->state &= ~XA_CODEC_FLAG_OUTPUT_SETUP;
+
+ /* ...pass flush command down the graph */
+ if (xf_output_port_flush(&codec->output, XF_FLUSH))
+ {
+ TRACE(INFO, _b("port is idle; instantly unroute"));
+
+ /* ...flushing sequence is not needed; command may be satisfied instantly */
+ xf_output_port_unroute(&codec->output);
+
+ /* ...pass response to the proxy */
+ xf_response_ok(m);
+ }
+ else
+ {
+ TRACE(INFO, _b("port is busy; propagate unroute command"));
+
+ /* ...flushing sequence is started; save flow-control message */
+ xf_output_port_unroute_start(&codec->output, m);
+ }
+
+ return XA_NO_ERROR;
+}
+
+/* ...FLUSH command processing */
+static XA_ERRORCODE xa_codec_flush(XACodecBase *base, xf_message_t *m)
+{
+ XAAudioCodec *codec = (XAAudioCodec *) base;
+
+ /* ...command is allowed only in "postinit" state */
+ XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD);
+
+ /* ...ensure input parameter length is zero */
+ XF_CHK_ERR(m->length == 0, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ TRACE(1, _b("flush command received"));
+
+ /* ...flush command must be addressed to input port */
+ if (XF_MSG_DST_PORT(m->id) == 0)
+ {
+ /* ...cancel data processing message if needed */
+ xa_base_cancel(base);
+
+ /* ...input port flushing; purge content of input buffer */
+ xf_input_port_purge(&codec->input);
+
+ /* ...clear input-ready condition */
+ base->state &= ~XA_CODEC_FLAG_INPUT_SETUP;
+
+ /* ...reset execution runtime */
+ XA_API(base, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DO_RUNTIME_INIT, NULL);
+
+ /* ...reset produced samples counter */
+ codec->produced = 0;
+
+ /* ...propagate flushing command to output port */
+ if (xf_output_port_flush(&codec->output, XF_FLUSH))
+ {
+ /* ...flushing sequence is not needed; satisfy command instantly */
+ xf_response(m);
+ }
+ else
+ {
+ /* ...flushing sequence is started; save flow-control message at input port */
+ xf_input_port_control_save(&codec->input, m);
+ }
+ }
+ else if (xf_output_port_unrouting(&codec->output))
+ {
+ /* ...flushing during port unrouting; complete unroute sequence */
+ xf_output_port_unroute_done(&codec->output);
+
+ TRACE(INFO, _b("port is unrouted"));
+ }
+ else
+ {
+ /* ...output port flush command/response; check if the port is routed */
+ if (!xf_output_port_routed(&codec->output))
+ {
+ /* ...complete all queued messages */
+ xf_output_port_flush(&codec->output, XF_FLUSH);
+
+ /* ...and pass response to flushing command */
+ xf_response(m);
+ }
+ else
+ {
+ /* ...response to flushing command received */
+ BUG(m != xf_output_port_control_msg(&codec->output), _x("invalid message: %p"), m);
+
+ /* ...mark flushing sequence is completed */
+ xf_output_port_flush_done(&codec->output);
+
+ /* ...complete original flow-control command */
+ xf_input_port_purge_done(&codec->input);
+ }
+
+ /* ...clear output-setup condition */
+ base->state &= ~XA_CODEC_FLAG_OUTPUT_SETUP;
+ }
+
+ return XA_NO_ERROR;
+}
+
+/*******************************************************************************
+ * Generic codec API
+ ******************************************************************************/
+
+/* ...memory buffer handling */
+static XA_ERRORCODE xa_codec_memtab(XACodecBase *base, WORD32 idx, WORD32 type, WORD32 size, WORD32 align, u32 core)
+{
+ XAAudioCodec *codec = (XAAudioCodec *) base;
+
+ if (type == XA_MEMTYPE_INPUT)
+ {
+ /* ...input port specification; allocate internal buffer */
+ XF_CHK_ERR(xf_input_port_init(&codec->input, size, align, core) == 0, XA_API_FATAL_MEM_ALLOC);
+
+ /* ...save input port index */
+ codec->in_idx = idx;
+
+ /* ...set input buffer pointer as needed */
+ (size ? XA_API(base, XA_API_CMD_SET_MEM_PTR, idx, codec->input.buffer) : 0);
+
+ (size ? TRACE(1, _x("set input ptr: %p"), codec->input.buffer) : 0);
+ }
+ else
+ {
+ /* ...output buffer specification */
+ XF_CHK_ERR(type == XA_MEMTYPE_OUTPUT, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...initialize output port queue (no allocation here yet) */
+ XF_CHK_ERR(xf_output_port_init(&codec->output, size) == 0, XA_API_FATAL_MEM_ALLOC);
+
+ /* ...save output port index */
+ codec->out_idx = idx;
+ }
+
+ return XA_NO_ERROR;
+}
+
+/* ...prepare input/output buffers */
+static XA_ERRORCODE xa_codec_preprocess(XACodecBase *base)
+{
+ XAAudioCodec *codec = (XAAudioCodec *) base;
+
+ /* ...prepare output buffer if needed */
+ if (!(base->state & XA_CODEC_FLAG_OUTPUT_SETUP))
+ {
+ void *output;
+
+ /* ...get output buffer from port, if possible */
+ if (base->state & XA_BASE_FLAG_RUNTIME_INIT)
+ {
+ /* ...run-time is not initialized yet; use scratch buffer */
+ output = base->scratch;
+ }
+ else if ((output = xf_output_port_data(&codec->output)) == NULL)
+ {
+ /* ...no output buffer available */
+ return XA_CODEC_EXEC_NO_DATA;
+ }
+
+ /* ...set the output buffer pointer */
+ XA_API(base, XA_API_CMD_SET_MEM_PTR, codec->out_idx, output);
+
+ TRACE(1, _x("set output ptr: %p"), output);
+
+ /* ...mark output port is setup */
+ base->state ^= XA_CODEC_FLAG_OUTPUT_SETUP;
+ }
+
+ /* ...prepare input data if needed */
+ if (!(base->state & XA_CODEC_FLAG_INPUT_SETUP))
+ {
+ void *input;
+ u32 filled;
+
+ /* ...fill input buffer */
+ if (xf_input_port_bypass(&codec->input))
+ {
+ /* ...use input buffer directly; check if there is data available */
+ if ((input = xf_input_port_data(&codec->input)) != NULL)
+ {
+ /* ...set input data buffer pointer */
+ XA_API(base, XA_API_CMD_SET_MEM_PTR, codec->in_idx, input);
+
+ /* ...retrieve number of input bytes */
+ filled = xf_input_port_length(&codec->input);
+ }
+ else if (!xf_input_port_done(&codec->input))
+ {
+ /* ...return non-fatal indication to prevent further processing */
+ return XA_CODEC_EXEC_NO_DATA;
+ }
+ else
+ {
+ /* ...mark we have no data in current buffer */
+ filled = 0;
+ }
+ }
+ else
+ {
+ /* ...port is in non-bypass mode; try to fill internal buffer */
+ if (xf_input_port_done(&codec->input) || xf_input_port_fill(&codec->input))
+ {
+ /* ...retrieve number of bytes in input buffer (not really - tbd) */
+ filled = xf_input_port_level(&codec->input);
+ }
+ else
+ {
+ /* ...return non-fatal indication to prevent further processing */
+ return XA_CODEC_EXEC_NO_DATA;
+ }
+ }
+
+ /* ...check if input stream is over */
+ if (xf_input_port_done(&codec->input))
+ {
+ /* ...pass input-over command to the codec to indicate the final buffer */
+ XA_API(base, XA_API_CMD_INPUT_OVER, codec->in_idx, NULL);
+
+ TRACE(INFO, _b("codec[%p]: signal input-over (filled: %u)"), codec, filled);
+ }
+
+ TRACE(INPUT, _b("input-buffer fill-level: %u bytes"), filled);
+
+ /* ...specify number of bytes available in the input buffer */
+ XA_API(base, XA_API_CMD_SET_INPUT_BYTES, codec->in_idx, &filled);
+
+ /* ...mark input port is setup */
+ base->state ^= XA_CODEC_FLAG_INPUT_SETUP;
+ }
+
+ return XA_NO_ERROR;
+}
+
+/* ...post-processing operation; input/output ports maintenance */
+static XA_ERRORCODE xa_codec_postprocess(XACodecBase *base, int done)
+{
+ XAAudioCodec *codec = (XAAudioCodec *) base;
+ WORD32 consumed = 0;
+ WORD32 produced = 0;
+
+ /* ...get number of consumed / produced bytes */
+ XA_API(base, XA_API_CMD_GET_CURIDX_INPUT_BUF, codec->in_idx, &consumed);
+
+ /* ...get number of produced bytes only if runtime is initialized (sample size is known) */
+ (codec->sample_size ? XA_API(base, XA_API_CMD_GET_OUTPUT_BYTES, codec->out_idx, &produced) : 0);
+
+ TRACE(DECODE, _b("codec[%p]::postprocess(c=%u, p=%u, d=%u)"), codec, consumed, produced, done);
+
+ /* ...input buffer maintenance; check if we consumed anything */
+ if (consumed)
+ {
+ /* ...consume specified number of bytes from input port */
+ xf_input_port_consume(&codec->input, consumed);
+
+ /* ...clear input-setup flag */
+ base->state ^= XA_CODEC_FLAG_INPUT_SETUP;
+ }
+
+ /* ...output buffer maintenance; check if we have produced anything */
+ if (produced)
+ {
+ /* ...increment total number of produced samples (really don't like division here - tbd) */
+ codec->produced += produced / codec->sample_size;
+
+ /* ...immediately complete output buffer (don't wait until it gets filled) */
+ xf_output_port_produce(&codec->output, produced);
+
+ /* ...clear output port setup flag */
+ base->state ^= XA_CODEC_FLAG_OUTPUT_SETUP;
+ }
+
+ /* ...process execution stage transition */
+ if (done)
+ {
+ if (base->state & XA_BASE_FLAG_RUNTIME_INIT)
+ {
+ /* ...stream is completed while codec is in runtime initialization stage */
+ BUG(1, _x("breakpoint"));
+ }
+ else if (base->state & XA_BASE_FLAG_EXECUTION)
+ {
+ /* ...runtime initialization done */
+ XA_CHK(xa_codec_prepare_runtime(codec));
+
+ /* ...clear output port setup flag as we were using scratch buffer;
+ * technically, no need to repeat setup of input buffer, but some codecs require
+ * it as well
+ */
+ base->state &= ~(XA_CODEC_FLAG_INPUT_SETUP | XA_CODEC_FLAG_OUTPUT_SETUP);
+ }
+ else
+ {
+ /* ...output stream is over; propagate condition to sink port */
+ if (xf_output_port_flush(&codec->output, XF_FILL_THIS_BUFFER))
+ {
+ /* ...flushing sequence is not needed; complete pending zero-length input */
+ xf_input_port_purge(&codec->input);
+
+ /* ...no propagation to output port */
+ TRACE(INFO, _b("codec[%p] playback completed"), codec);
+ }
+ else
+ {
+ /* ...flushing sequence is started; wait until flow-control message returns */
+ TRACE(INFO, _b("propagate end-of-stream condition"));
+ }
+ }
+
+ /* ...return early to prevent task rescheduling */
+ return XA_NO_ERROR;
+ }
+
+ /* ...reschedule processing if needed */
+ if (xf_input_port_ready(&codec->input) && xf_output_port_ready(&codec->output))
+ {
+ /* ...schedule data processing with respect to its urgency */
+ xa_base_schedule(base, produced * codec->factor);
+ }
+
+ return XA_NO_ERROR;
+}
+
+/* ...configuration parameter retrieval */
+static XA_ERRORCODE xa_codec_getparam(XACodecBase *base, WORD32 id, pVOID value)
+{
+ XAAudioCodec *codec = (XAAudioCodec *) base;
+
+ if (id == XA_CODEC_CONFIG_PARAM_PRODUCED)
+ {
+ /* ...retrieve number of produced samples since last reset */
+ *(u32 *)value = codec->produced;
+
+ return XA_NO_ERROR;
+ }
+ else
+ {
+ /* ...pass command to underlying codec plugin */
+ return XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, id, value);
+ }
+}
+
+/*******************************************************************************
+ * Component entry point
+ ******************************************************************************/
+
+/* ...command hooks */
+static XA_ERRORCODE (* const xa_codec_cmd[])(XACodecBase *, xf_message_t *) =
+{
+ [XF_OPCODE_TYPE(XF_SET_PARAM)] = xa_base_set_param,
+ [XF_OPCODE_TYPE(XF_GET_PARAM)] = xa_base_get_param,
+ [XF_OPCODE_TYPE(XF_ROUTE)] = xa_codec_port_route,
+ [XF_OPCODE_TYPE(XF_UNROUTE)] = xa_codec_port_unroute,
+ [XF_OPCODE_TYPE(XF_EMPTY_THIS_BUFFER)] = xa_codec_empty_this_buffer,
+ [XF_OPCODE_TYPE(XF_FILL_THIS_BUFFER)] = xa_codec_fill_this_buffer,
+ [XF_OPCODE_TYPE(XF_FLUSH)] = xa_codec_flush,
+ [XF_OPCODE_TYPE(XF_SET_PARAM_EXT)] = xa_base_set_param_ext,
+ [XF_OPCODE_TYPE(XF_GET_PARAM_EXT)] = xa_base_get_param_ext,
+};
+
+/* ...total number of commands supported */
+#define XA_CODEC_CMD_NUM (sizeof(xa_codec_cmd) / sizeof(xa_codec_cmd[0]))
+
+/* ...command processor for termination state (only for routed port case) */
+static int xa_audio_codec_terminate(xf_component_t *component, xf_message_t *m)
+{
+ XAAudioCodec *codec = (XAAudioCodec *) component;
+ u32 opcode = m->opcode;
+
+ /* ...check if we received output port control message */
+ if (m == xf_output_port_control_msg(&codec->output))
+ {
+ /* ...output port flushing complete; mark port is idle and terminate */
+ xf_output_port_flush_done(&codec->output);
+ return -1;
+ }
+ else if (opcode == XF_FILL_THIS_BUFFER)
+ {
+ /* ...output buffer returned by the sink component; ignore and keep waiting */
+ TRACE(OUTPUT, _b("collect output buffer"));
+ return 0;
+ }
+ else if (opcode == XF_UNREGISTER)
+ {
+ /* ...ignore subsequent unregister command/response - tbd */
+ return 0;
+ }
+ else
+ {
+ /* ...everything else is responded with generic failure */
+ xf_response_err(m);
+ return 0;
+ }
+}
+
+/* ...audio codec destructor */
+static int xa_audio_codec_destroy(xf_component_t *component, xf_message_t *m)
+{
+ XAAudioCodec *codec = (XAAudioCodec *) component;
+ u32 core = xf_component_core(component);
+
+ /* ...destroy input port */
+ xf_input_port_destroy(&codec->input, core);
+
+ /* ...destroy output port */
+ xf_output_port_destroy(&codec->output, core);
+
+ /* ...deallocate all resources */
+ xa_base_destroy(&codec->base, XF_MM(sizeof(*codec)), core);
+
+ TRACE(INIT, _b("audio-codec[%p@%u] destroyed"), codec, core);
+
+ /* ...indicate the client has been destroyed */
+ return 0;
+}
+
+/* ...audio codec destructor - first stage (ports unrouting) */
+static int xa_audio_codec_cleanup(xf_component_t *component, xf_message_t *m)
+{
+ XAAudioCodec *codec = (XAAudioCodec *) component;
+
+ /* ...complete message with error response */
+ xf_response_err(m);
+
+ /* ...cancel internal scheduling message if needed */
+ xa_base_cancel(&codec->base);
+
+ /* ...purge input port (returns OK? pretty strange at this point - tbd) */
+ xf_input_port_purge(&codec->input);
+
+ /* ...propagate unregister command to connected component */
+ if (xf_output_port_flush(&codec->output, XF_FLUSH))
+ {
+ /* ...flushing sequence is not needed; destroy audio codec */
+ return xa_audio_codec_destroy(component, NULL);
+ }
+ else
+ {
+ /* ...wait until output port is cleaned; adjust component hooks */
+ component->entry = xa_audio_codec_terminate;
+ component->exit = xa_audio_codec_destroy;
+
+ TRACE(INIT, _b("codec[%p] cleanup sequence started"), codec);
+
+ /* ...indicate that second stage is required */
+ return 1;
+ }
+}
+
+/*******************************************************************************
+ * Audio codec component factory
+ ******************************************************************************/
+
+xf_component_t * xa_audio_codec_factory(u32 core, xa_codec_func_t process)
+{
+ XAAudioCodec *codec;
+
+ /* ...allocate local memory for codec structure */
+ XF_CHK_ERR(codec = (XAAudioCodec *) xa_base_factory(core, XF_MM(sizeof(*codec)), process), NULL);
+
+ /* ...set base codec API methods */
+ codec->base.memtab = xa_codec_memtab;
+ codec->base.preprocess = xa_codec_preprocess;
+ codec->base.postprocess = xa_codec_postprocess;
+ codec->base.getparam = xa_codec_getparam;
+
+ /* ...set message commands processing table */
+ codec->base.command = xa_codec_cmd;
+ codec->base.command_num = XA_CODEC_CMD_NUM;
+
+ /* ...set component destructor hook */
+ codec->base.component.exit = xa_audio_codec_cleanup;
+
+ TRACE(INIT, _b("Codec[%p] initialized"), codec);
+
+ return (xf_component_t *) codec;
+}
diff --git a/hifi/xaf/hifi-dpf/audio/xa-class-base.c b/hifi/xaf/hifi-dpf/audio/xa-class-base.c
new file mode 100644
index 00000000..0b672553
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/audio/xa-class-base.c
@@ -0,0 +1,537 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-class-base.c
+ *
+ * Generic audio codec task implementation
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG BASE
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+#include "xa-class-base.h"
+
+/*******************************************************************************
+ * Tracing configuration
+ ******************************************************************************/
+
+TRACE_TAG(INIT, 1);
+TRACE_TAG(WARNING, 1);
+TRACE_TAG(SETUP, 1);
+TRACE_TAG(EXEC, 1);
+
+/*******************************************************************************
+ * Internal functions definitions
+ ******************************************************************************/
+
+/* ...codec pre-initialization */
+static XA_ERRORCODE xa_base_preinit(XACodecBase *base, u32 core)
+{
+ WORD32 n;
+
+ /* ...codec must be empty */
+ XF_CHK_ERR(base->state == 0, XA_API_FATAL_INVALID_CMD);
+
+ /* ...get API structure size */
+ XA_API(base, XA_API_CMD_GET_API_SIZE, 0, &n);
+
+ /* ...allocate memory for codec API structure (4-bytes aligned) */
+ XMALLOC(&base->api, n, 4, core);
+
+ /* ...set default config parameters */
+ XA_API(base, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS, NULL);
+
+ /* ...get memory info tables size */
+ if (XA_API(base, XA_API_CMD_GET_MEMTABS_SIZE, 0, &n), n != 0)
+ {
+ /* ...allocate memory for tables (4-bytes aligned) */
+ XMALLOC(&base->mem_tabs, n, 4, core);
+
+ /* ...set pointer for process memory tables */
+ XA_API(base, XA_API_CMD_SET_MEMTABS_PTR, 0, base->mem_tabs.addr);
+ }
+
+ TRACE(INIT, _b("Codec[%p] pre-initialization completed"), base);
+
+ return XA_NO_ERROR;
+}
+
+/* ...post-initialization setup */
+static XA_ERRORCODE xa_base_postinit(XACodecBase *base, u32 core)
+{
+ WORD32 n, i;
+
+ /* ...issue post-config command and determine the buffer requirements */
+ XA_API(base, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS, NULL);
+
+ /* ...get number of memory tables required */
+ XA_API(base, XA_API_CMD_GET_N_MEMTABS, 0, &n);
+
+ /* ...set scratch buffer in advance (as codec not necessarily exposes it) */
+ base->scratch = XF_CORE_DATA(core)->scratch;
+
+ /* ...allocate memory buffers */
+ for (i = 0; i < n; i++)
+ {
+ WORD32 size, align, type;
+
+ TRACE(1, _b("i = %u (of %u)"), (u32)i, (u32)n);
+
+ /* ...get memory type */
+ XA_API(base, XA_API_CMD_GET_MEM_INFO_TYPE, i, &type);
+
+ /* ...get memory size of i-th buffer */
+ XA_API(base, XA_API_CMD_GET_MEM_INFO_SIZE, i, &size);
+
+ /* ...get alignment */
+ XA_API(base, XA_API_CMD_GET_MEM_INFO_ALIGNMENT, i, &align);
+
+ /* ...process individual buffer */
+ switch (type)
+ {
+ case XA_MEMTYPE_SCRATCH:
+ /* ...scratch memory is shared among all codecs; check its validity */
+ XF_CHK_ERR(size <= XF_CFG_CODEC_SCRATCHMEM_SIZE, XA_API_FATAL_MEM_ALLOC);
+
+ /* ...make sure alignment is sane */
+ XF_CHK_ERR((XF_CFG_CODEC_SCRATCHMEM_ALIGN & (align - 1)) == 0, XA_API_FATAL_MEM_ALIGN);
+
+ /* ...set the scratch memory pointer */
+ XA_API(base, XA_API_CMD_SET_MEM_PTR, i, base->scratch);
+
+ TRACE(INIT, _b("Mem tab %d: sz=%d al=%d ty=%d Scratch memory (%p)"), i, size, align, type, base->scratch);
+
+ break;
+
+ case XA_MEMTYPE_PERSIST:
+ /* ...allocate persistent memory */
+ XMALLOC(&base->persist, size, align, core);
+
+ /* ...and set the pointer instantly */
+ XA_API(base, XA_API_CMD_SET_MEM_PTR, i, base->persist.addr);
+
+ TRACE(INIT, _b("Mem tab %d: sz=%d al=%d ty=%d Persistent memory (%p)"), i, size, align, type, base->persist.addr);
+
+ break;
+
+ case XA_MEMTYPE_INPUT:
+ case XA_MEMTYPE_OUTPUT:
+ /* ...input/output buffer specification; pass to codec function */
+ CODEC_API(base, memtab, i, type, size, align, core);
+
+ break;
+
+ default:
+ /* ...unrecognized memory type */
+ TRACE(ERROR, _x("Invalid memory type: [%d]=(%u, %u, %u)"), i, type, size, align);
+ return XA_API_FATAL_INVALID_CMD_TYPE;
+ }
+ }
+
+ TRACE(INIT, _b("Codec[%p] post-initialization completed (api:%p[%u])"), base, base->api.addr, base->api.size);
+
+ return XA_NO_ERROR;
+}
+
+/*******************************************************************************
+ * Commands processing
+ ******************************************************************************/
+
+/* ...SET-PARAM processing (enabled in all states) */
+XA_ERRORCODE xa_base_set_param(XACodecBase *base, xf_message_t *m)
+{
+ xf_set_param_msg_t *cmd = m->buffer;
+ xf_set_param_item_t *param = &cmd->item[0];
+ WORD32 n, i;
+
+ /* ...calculate total amount of parameters */
+ n = m->length / sizeof(*param);
+
+ /* ...check the message length is sane */
+ XF_CHK_ERR(m->length == XF_SET_PARAM_CMD_LEN(n), XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...apply all parameters; pass to codec-specific function */
+ for (i = 0; i < n; i++)
+ {
+ TRACE(SETUP, _b("set-param[%p]: [%u]=%u"), base, param[i].id, param[i].value);
+
+ if (base->setparam)
+ {
+ CODEC_API(base, setparam, param[i].id, &param[i].value);
+ }
+ else
+ {
+ XA_API(base, XA_API_CMD_SET_CONFIG_PARAM, param[i].id, &param[i].value);
+ }
+ }
+
+ /* ...check if we need to do post-initialization */
+ if ((base->state & XA_BASE_FLAG_POSTINIT) == 0)
+ {
+ /* ...do post-initialization step */
+ XA_CHK(xa_base_postinit(base, XF_MSG_DST_CORE(m->id)));
+
+ /* ...mark the codec static configuration is set */
+ base->state ^= XA_BASE_FLAG_POSTINIT | XA_BASE_FLAG_RUNTIME_INIT;
+ }
+
+ /* ...complete message processing; output buffer is empty */
+ xf_response_ok(m);
+
+ return XA_NO_ERROR;
+}
+
+/* ...GET-PARAM message processing (enabled in all states) */
+XA_ERRORCODE xa_base_get_param(XACodecBase *base, xf_message_t *m)
+{
+ xf_get_param_msg_t *cmd = m->buffer;
+ u32 *id = &cmd->c.id[0];
+ u32 *value = &cmd->r.value[0];
+ u32 n, i;
+
+ /* ...calculate amount of parameters */
+ n = m->length / sizeof(*id);
+
+ /* ...check input parameter length */
+ XF_CHK_ERR(XF_GET_PARAM_CMD_LEN(n) == m->length, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...retrieve the collection of codec parameters */
+ for (i = 0; i < n; i++)
+ {
+ /* ...place the result into same location */
+ if (base->getparam)
+ {
+ CODEC_API(base, getparam, id[i], &value[i]);
+ }
+ else
+ {
+ XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, id[i], &value[i]);
+ }
+ }
+
+ /* ...complete message specifying output buffer size */
+ xf_response_data(m, XF_GET_PARAM_RSP_LEN(n));
+
+ return XA_NO_ERROR;
+}
+
+/* ...SET-PARAM-EXT processing (enabled in all states) */
+XA_ERRORCODE xa_base_set_param_ext(XACodecBase *base, xf_message_t *m)
+{
+ xf_ext_param_msg_t *cmd = m->buffer;
+ u16 length = m->length;
+ u16 remaining = (length + 3) & ~3;
+ u16 i;
+
+ for (i = 0; TRACE_CFG(SETUP) && i < remaining; i += 16)
+ {
+ TRACE(SETUP, _b("[%03x]: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X"),
+ i,
+ ((u8 *)m->buffer)[i + 0], ((u8 *)m->buffer)[i + 1],
+ ((u8 *)m->buffer)[i + 2], ((u8 *)m->buffer)[i + 3],
+ ((u8 *)m->buffer)[i + 4], ((u8 *)m->buffer)[i + 5],
+ ((u8 *)m->buffer)[i + 6], ((u8 *)m->buffer)[i + 7],
+ ((u8 *)m->buffer)[i + 8], ((u8 *)m->buffer)[i + 9],
+ ((u8 *)m->buffer)[i + 10], ((u8 *)m->buffer)[i + 11],
+ ((u8 *)m->buffer)[i + 12], ((u8 *)m->buffer)[i + 13],
+ ((u8 *)m->buffer)[i + 14], ((u8 *)m->buffer)[i + 15]);
+ }
+
+ /* ...process all parameters encapsulated in buffer */
+ while (remaining >= sizeof(*cmd))
+ {
+ u16 id = cmd->desc.id;
+ u16 dlen = cmd->desc.length;
+ u16 dsize = (dlen + 3) & ~3;
+ u16 pad = dlen & 3;
+
+ /* ...cut-off descriptor header */
+ remaining -= sizeof(*cmd);
+
+ TRACE(SETUP, _b("remaining:%u, desc_size:%u"), (u32)remaining, (u32)dsize);
+
+ /* ...make sure length is sufficient */
+ XF_CHK_ERR(remaining >= dsize, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...pad remaining bytes with zeroes */
+ (pad ? memset(cmd->data + dlen, 0, 4 - pad) : 0);
+
+ TRACE(SETUP, _b("set-ext-param[%p]: [%u]:%u - [%02X:%02X:%02X:%02X:...]"), base, id, dsize, cmd->data[0], cmd->data[1], cmd->data[2], cmd->data[3]);
+
+ /* ...apply parameter */
+ XA_API(base, XA_API_CMD_SET_CONFIG_PARAM, id, cmd->data);
+
+ /* ...move to next item (keep 4-bytes alignment for descriptor) */
+ cmd = (xf_ext_param_msg_t *)(&cmd->data[0] + dsize), remaining -= dsize;
+ }
+
+ /* ...check the message is fully processed */
+ XF_CHK_ERR(remaining == 0, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...complete message processing; output buffer is empty */
+ //xf_response_ok(m);
+
+ /* ...unfortunately, it looks like a bug of the library that updates the memory
+ * and leaves it in a dirty state causing subsequent cache inconsistency - tbd
+ */
+ xf_response_data(m, length);
+
+ return XA_NO_ERROR;
+}
+
+/* ...GET-PARAM-EXT message processing (enabled in all states) */
+XA_ERRORCODE xa_base_get_param_ext(XACodecBase *base, xf_message_t *m)
+{
+ xf_ext_param_msg_t *cmd = m->buffer;
+ u32 length = m->length;
+ u32 remaining = (length + 3) & ~3;
+ int i;
+
+ for (i = 0; TRACE_CFG(SETUP) && i < remaining; i += 16)
+ {
+ TRACE(SETUP, _b("[%03x]: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X"),
+ i,
+ ((u8 *)m->buffer)[i + 0], ((u8 *)m->buffer)[i + 1],
+ ((u8 *)m->buffer)[i + 2], ((u8 *)m->buffer)[i + 3],
+ ((u8 *)m->buffer)[i + 4], ((u8 *)m->buffer)[i + 5],
+ ((u8 *)m->buffer)[i + 6], ((u8 *)m->buffer)[i + 7],
+ ((u8 *)m->buffer)[i + 8], ((u8 *)m->buffer)[i + 9],
+ ((u8 *)m->buffer)[i + 10], ((u8 *)m->buffer)[i + 11],
+ ((u8 *)m->buffer)[i + 12], ((u8 *)m->buffer)[i + 13],
+ ((u8 *)m->buffer)[i + 14], ((u8 *)m->buffer)[i + 15]);
+ }
+
+ /* ...process all parameters encapsulated in buffer */
+ while (remaining >= sizeof(*cmd))
+ {
+ u16 id = cmd->desc.id;
+ u16 len = cmd->desc.length;
+ u16 size = (len + 3) & ~3;
+ u8 pad = len & 3;
+
+ /* ...cut-off command header */
+ remaining -= sizeof(*cmd);
+
+ /* ...make sure data buffer has sufficient length */
+ XF_CHK_ERR(remaining >= size, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...retrieve parameter from buffer (care about alignment? - tbd) */
+ XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, id, cmd->data);
+
+ /* ...pad remaininig bytes with zeroes */
+ (pad ? memset(cmd->data + len, 0, 4 - pad) : 0);
+
+ TRACE(SETUP, _b("get-ext-param[%p]: [%u]:%u - [%02X:%02X:%02X:%02X:...]"), base, id, size, cmd->data[0], cmd->data[1], cmd->data[2], cmd->data[3]);
+
+ /* ...move to next item (alignment issues? - tbd) */
+ cmd = (xf_ext_param_msg_t *)(&cmd->data[0] + size), remaining -= size;
+ }
+
+ /* ...check the message is fully processed */
+ XF_CHK_ERR(remaining == 0, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...complete message processing; output buffer has the same length */
+ xf_response_data(m, length);
+
+ return XA_NO_ERROR;
+}
+
+/*******************************************************************************
+ * Command/data processing functions
+ ******************************************************************************/
+
+/* ...generic codec data processing */
+static XA_ERRORCODE xa_base_process(XACodecBase *base)
+{
+ XA_ERRORCODE error;
+ WORD32 done;
+
+ /* ...clear internal scheduling flag */
+ base->state &= ~XA_BASE_FLAG_SCHEDULE;
+
+ /* ...codec-specific preprocessing (buffer maintenance) */
+ if ((error = CODEC_API(base, preprocess)) != XA_NO_ERROR)
+ {
+ /* ...return non-fatal codec error */
+ return error;
+ }
+
+ /* ...execution step */
+ if (base->state & XA_BASE_FLAG_RUNTIME_INIT)
+ {
+ /* ...kick initialization process */
+ XA_API(base, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_PROCESS, NULL);
+
+ /* ...check if initialization is completed */
+ XA_API(base, XA_API_CMD_INIT, XA_CMD_TYPE_INIT_DONE_QUERY, &done);
+
+ TRACE(EXEC, _b("Initialization result: %d"), done);
+
+ /* ...switch to execution state if required */
+ (done ? base->state ^= XA_BASE_FLAG_RUNTIME_INIT | XA_BASE_FLAG_EXECUTION : 0);
+ }
+ else if (base->state & XA_BASE_FLAG_EXECUTION)
+ {
+ TRACE(1, _b("do exec"));
+
+ /* ...execute decoding process */
+ XA_API(base, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DO_EXECUTE, NULL);
+
+ /* ...check for end-of-stream condition */
+ XA_API(base, XA_API_CMD_EXECUTE, XA_CMD_TYPE_DONE_QUERY, &done);
+
+ TRACE(EXEC, _b("Execution result: %d"), done);
+
+ /* ...mark the output path is done to release all queued buffers */
+ (done ? base->state ^= XA_BASE_FLAG_EXECUTION | XA_BASE_FLAG_COMPLETED : 0);
+ }
+
+ /* ...codec-specific buffer post-processing */
+ return CODEC_API(base, postprocess, done);
+}
+
+/* ...message-processing function (component entry point) */
+static int xa_base_command(xf_component_t *component, xf_message_t *m)
+{
+ XACodecBase *base = (XACodecBase *) component;
+ u32 cmd;
+
+ /* ...invoke data-processing function if message is null */
+ if (m == NULL)
+ {
+ XF_CHK_ERR(!XA_ERROR_SEVERITY(xa_base_process(base)), -EPIPE);
+ return 0;
+ }
+
+ /* ...process the command */
+ TRACE(EXEC, _b("[%p]:state[%X]:(%X, %d, %p)"), base, base->state, m->opcode, m->length, m->buffer);
+
+ /* ...bail out if this is forced termination command (I do have a map; maybe I'd better have a hook? - tbd) */
+ if ((cmd = XF_OPCODE_TYPE(m->opcode)) == XF_OPCODE_TYPE(XF_UNREGISTER))
+ {
+ TRACE(INIT, _b("force component[%p] termination"), base);
+ return -1;
+ }
+
+ /* ...check opcode is valid */
+ XF_CHK_ERR(cmd < base->command_num, -EINVAL);
+
+ /* ...and has a hook */
+ XF_CHK_ERR(base->command[cmd] != NULL, -EINVAL);
+
+ /* ...pass control to specific command */
+ XF_CHK_ERR(!XA_ERROR_SEVERITY(base->command[cmd](base, m)), -EPIPE);
+
+ /* ...execution completed successfully */
+ return 0;
+}
+
+/*******************************************************************************
+ * Base codec API
+ ******************************************************************************/
+
+/* ...data processing scheduling */
+void xa_base_schedule(XACodecBase *base, u32 dts)
+{
+ if ((base->state & XA_BASE_FLAG_SCHEDULE) == 0)
+ {
+ /* ...schedule component task execution */
+ xf_component_schedule(&base->component, dts);
+
+ /* ...and put scheduling flag */
+ base->state ^= XA_BASE_FLAG_SCHEDULE;
+ }
+ else
+ {
+ TRACE(EXEC, _b("codec[%p] processing pending"), base);
+ }
+}
+
+/* ...cancel data processing */
+void xa_base_cancel(XACodecBase *base)
+{
+ if (base->state & XA_BASE_FLAG_SCHEDULE)
+ {
+ /* ...cancel scheduled codec task */
+ xf_component_cancel(&base->component);
+
+ /* ...and clear scheduling flag */
+ base->state ^= XA_BASE_FLAG_SCHEDULE;
+
+ TRACE(EXEC, _b("codec[%p] processing cancelled"), base);
+ }
+}
+
+/* ...base codec destructor */
+void xa_base_destroy(XACodecBase *base, u32 size, u32 core)
+{
+ /* ...deallocate all resources */
+ xf_mm_free_buffer(&base->persist, core);
+ xf_mm_free_buffer(&base->mem_tabs, core);
+ xf_mm_free_buffer(&base->api, core);
+
+ /* ...destroy codec structure (and task) itself */
+ xf_mem_free(base, size, core, 0);
+
+ TRACE(INIT, _b("codec[%p]:%u destroyed"), base, core);
+}
+
+/* ...generic codec initialization routine */
+XACodecBase * xa_base_factory(u32 core, u32 size, xa_codec_func_t process)
+{
+ XACodecBase *base;
+
+ /* ...make sure the size is sane */
+ XF_CHK_ERR(size >= sizeof(XACodecBase), NULL);
+
+ /* ...allocate local memory for codec structure */
+ XF_CHK_ERR(base = xf_mem_alloc(size, 0, core, 0), NULL);
+
+ /* ...reset codec memory */
+ memset(base, 0, size);
+
+ /* ...set low-level codec API function */
+ base->process = process;
+
+ /* ...set message processing function */
+ base->component.entry = xa_base_command;
+
+ /* ...do basic initialization */
+ if (xa_base_preinit(base, core) != XA_NO_ERROR)
+ {
+ /* ...initialization failed for some reason; do cleanup */
+ xa_base_destroy(base, size, core);
+
+ return NULL;
+ }
+
+ /* ...initialization completed successfully */
+ TRACE(INIT, _b("Codec[%p]:%u initialized"), base, core);
+
+ return base;
+}
diff --git a/hifi/xaf/hifi-dpf/audio/xa-class-base.h b/hifi/xaf/hifi-dpf/audio/xa-class-base.h
new file mode 100644
index 00000000..252044d4
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/audio/xa-class-base.h
@@ -0,0 +1,263 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-class-base.h
+ *
+ * Generic Xtensa Audio codecs interfaces
+ *
+ ******************************************************************************/
+
+#ifndef __XA_CLASS_BASE_H
+#define __XA_CLASS_BASE_H
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/* ...audio-specific API */
+#include "audio/xa_type_def.h"
+#include "audio/xa_error_standards.h"
+#include "audio/xa_apicmd_standards.h"
+#include "audio/xa_memory_standards.h"
+
+/*******************************************************************************
+ * Generic codec structure
+ ******************************************************************************/
+
+typedef struct XACodecBase XACodecBase;
+
+/* ...memory buffer initialization */
+typedef XA_ERRORCODE (*xa_codec_memtab_f)(XACodecBase *codec, WORD32 i, WORD32 type, WORD32 size, WORD32 align, u32 core);
+
+/* ...preprocessing operation */
+typedef XA_ERRORCODE (*xa_codec_preprocess_f)(XACodecBase *);
+
+/* ...postprocessing operation */
+typedef XA_ERRORCODE (*xa_codec_postprocess_f)(XACodecBase *, int);
+
+/* ...parameter setting function */
+typedef XA_ERRORCODE (*xa_codec_setparam_f)(XACodecBase *, WORD32, pVOID p);
+
+/* ...parameter retrival function */
+typedef XA_ERRORCODE (*xa_codec_getparam_f)(XACodecBase *, WORD32, pVOID p);
+
+/*******************************************************************************
+ * Codec instance structure
+ ******************************************************************************/
+
+struct XACodecBase
+{
+ /***************************************************************************
+ * Control data
+ **************************************************************************/
+
+ /* ...generic component handle */
+ xf_component_t component;
+
+ /* ...codec API entry point (function) */
+ xa_codec_func_t *process;
+
+ /* ...codec API handle, passed to *process */
+ xf_mm_buffer_t api;
+
+ /* ...memory table buffer */
+ xf_mm_buffer_t mem_tabs;
+
+ /* ...persistent memory buffer */
+ xf_mm_buffer_t persist;
+
+ /* ...scratch memory pointer */
+ void *scratch;
+
+ /* ...codec control state */
+ u32 state;
+
+ /***************************************************************************
+ * Codec-specific methods
+ **************************************************************************/
+
+ /* ...memory buffer initialization */
+ xa_codec_memtab_f memtab;
+
+ /* ...preprocessing function */
+ xa_codec_preprocess_f preprocess;
+
+ /* ...postprocessing function */
+ xa_codec_postprocess_f postprocess;
+
+ /* ...configuration parameter setting function */
+ xa_codec_setparam_f setparam;
+
+ /* ...configuration parameter retrieval function */
+ xa_codec_getparam_f getparam;
+
+ /* ...command-processing table */
+ XA_ERRORCODE (* const * command)(XACodecBase *, xf_message_t *);
+
+ /* ...command-processing table size */
+ u32 command_num;
+};
+
+/*******************************************************************************
+ * Base codec execution flags
+ ******************************************************************************/
+
+/* ...codec static initialization completed */
+#define XA_BASE_FLAG_POSTINIT (1 << 0)
+
+/* ...codec runtime initialization sequence */
+#define XA_BASE_FLAG_RUNTIME_INIT (1 << 1)
+
+/* ...codec steady execution state */
+#define XA_BASE_FLAG_EXECUTION (1 << 2)
+
+/* ...execution stage completed */
+#define XA_BASE_FLAG_COMPLETED (1 << 3)
+
+/* ...data processing scheduling flag */
+#define XA_BASE_FLAG_SCHEDULE (1 << 4)
+
+/* ...base codec flags accessor */
+#define __XA_BASE_FLAGS(flags) ((flags) & ((1 << 5) - 1))
+
+/* ...custom execution flag */
+#define __XA_BASE_FLAG(f) ((f) << 5)
+
+/*******************************************************************************
+ * Local macros definitions
+ ******************************************************************************/
+
+/* ...audio-framework API function execution */
+#define XA_CHK(cond) \
+({ \
+ XA_ERRORCODE __e = (cond); \
+ if (__e != XA_NO_ERROR) \
+ { \
+ if (XA_ERROR_SEVERITY(__e)) \
+ { \
+ TRACE(ERROR, _x("error: %X"), __e); \
+ return __e; \
+ } \
+ TRACE(WARNING, _x("warning: %X"), __e); \
+ } \
+ __e; \
+})
+
+/* ...low-level codec API function execution */
+#define XA_API(codec, cmd, idx, pv) \
+({ \
+ XA_ERRORCODE __e; \
+ __e = (codec)->process((xa_codec_handle_t)(codec)->api.addr, (cmd), (idx), (pv)); \
+ if (__e != XA_NO_ERROR) \
+ { \
+ if (XA_ERROR_SEVERITY(__e)) \
+ { \
+ TRACE(ERROR, _x("[%p]:(%d, %d, %p): %X"), (codec), (cmd), (idx), (pv), __e); \
+ return __e; \
+ } \
+ TRACE(WARNING, _x("%X"), __e); \
+ } \
+ __e; \
+})
+
+#define XA_API_NORET(codec, cmd, idx, pv) \
+({ \
+ XA_ERRORCODE __e; \
+ __e = (codec)->process((xa_codec_handle_t)(codec)->api.addr, (cmd), (idx), (pv)); \
+ if (__e != XA_NO_ERROR) \
+ { \
+ if (XA_ERROR_SEVERITY(__e)) \
+ { \
+ TRACE(ERROR, _x("[%p]:(%d, %d, %p): %X"), (codec), (cmd), (idx), (pv), __e); \
+ } \
+ TRACE(WARNING, _x("%X"), __e); \
+ } \
+ __e; \
+})
+
+/* ...codec hook invocation */
+#define CODEC_API(codec, func, ...) \
+({ \
+ XA_ERRORCODE __e = (codec)->func((codec), ##__VA_ARGS__); \
+ \
+ if (__e != XA_NO_ERROR) \
+ { \
+ if (XA_ERROR_SEVERITY(__e)) \
+ { \
+ /* ...actual error is reported by the codec */ \
+ TRACE(ERROR, _x("[%p]: " #func ": %X"), (codec), __e); \
+ return __e; \
+ } \
+ \
+ TRACE(WARNING, _x("warning: %X"), __e); \
+ } \
+ __e; \
+})
+
+/* ...allocate local memory on specific core */
+#define XMALLOC(p, size, align, core) \
+do \
+{ \
+ if (xf_mm_alloc_buffer((size), (align), (core), (p)) != 0) \
+ { \
+ TRACE(ERROR, _x("Failed to allocate %d bytes of memory"), (size)); \
+ return XA_API_FATAL_MEM_ALLOC; \
+ } \
+ \
+ if (((u32)((p)->addr) & ((align) - 1)) != 0) \
+ { \
+ TRACE(ERROR, _x("Invalid %d-algnment: %p"), (align), (p)->addr); \
+ return XA_API_FATAL_MEM_ALIGN; \
+ } \
+} \
+while (0)
+
+/*******************************************************************************
+ * Public API
+ ******************************************************************************/
+
+/* ...SET-PARAM processing */
+extern XA_ERRORCODE xa_base_set_param(XACodecBase *base, xf_message_t *m);
+
+/* ...GET-PARAM-EXT message processing */
+extern XA_ERRORCODE xa_base_set_param_ext(XACodecBase *base, xf_message_t *m);
+
+/* ...GET-PARAM message processing */
+extern XA_ERRORCODE xa_base_get_param(XACodecBase *base, xf_message_t *m);
+
+/* ...GET-PARAM-EXT message processing */
+extern XA_ERRORCODE xa_base_get_param_ext(XACodecBase *base, xf_message_t *m);
+
+/* ...data processing scheduling */
+extern void xa_base_schedule(XACodecBase *base, u32 dts);
+
+/* ...cancel internal scheduling message */
+extern void xa_base_cancel(XACodecBase *base);
+
+/* ...base codec factory */
+extern XACodecBase * xa_base_factory(u32 core, u32 size, xa_codec_func_t process);
+
+/* ...base codec destructor */
+extern void xa_base_destroy(XACodecBase *base, u32 size, u32 core);
+
+#endif /* __XA_CLASS_BASE_H */
diff --git a/hifi/xaf/hifi-dpf/audio/xa-class-mixer.c b/hifi/xaf/hifi-dpf/audio/xa-class-mixer.c
new file mode 100644
index 00000000..ac2ff9ad
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/audio/xa-class-mixer.c
@@ -0,0 +1,870 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-class-mixer.c
+ *
+ * Generic mixer component class
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG MIXER
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+#include "xa-class-base.h"
+#include "audio/xa-mixer-api.h"
+
+/*******************************************************************************
+ * Tracing tags
+ ******************************************************************************/
+
+TRACE_TAG(INIT, 1);
+TRACE_TAG(WARNING, 1);
+TRACE_TAG(INFO, 1);
+TRACE_TAG(INPUT, 1);
+TRACE_TAG(OUTPUT, 1);
+
+/*******************************************************************************
+ * Data structures
+ ******************************************************************************/
+
+/* ...mixed source - input data */
+typedef struct XATrack
+{
+ /* ...input port data */
+ xf_input_port_t input;
+
+ /* ...current presentation timestamp (in samples; local to a mixer state) */
+ u32 pts;
+
+ /* ...total amount of decoded frames since last synchronization point */
+ u32 decoded;
+
+ /* ...total amount of rendered frames (consumed) since last synchronization point */
+ u32 rendered;
+
+} XATrack;
+
+/*******************************************************************************
+ * Helpers
+ ******************************************************************************/
+
+static inline u32 xa_track_test_flags(XATrack *track, u32 flags)
+{
+ return (track->input.flags & flags);
+}
+
+static inline u32 xa_track_set_flags(XATrack *track, u32 flags)
+{
+ return (track->input.flags |= flags);
+}
+
+static inline u32 xa_track_clear_flags(XATrack *track, u32 flags)
+{
+ return (track->input.flags &= ~flags);
+}
+
+static inline u32 xa_track_toggle_flags(XATrack *track, u32 flags)
+{
+ return (track->input.flags ^= flags);
+}
+
+/*******************************************************************************
+ * Mixer data definitions
+ ******************************************************************************/
+
+/* ...mixer data */
+typedef struct XAMixer
+{
+ /***************************************************************************
+ * Control data
+ **************************************************************************/
+
+ /* ...generic audio codec data */
+ XACodecBase base;
+
+ /* ...input tracks */
+ XATrack track[XA_MIXER_MAX_TRACK_NUMBER];
+
+ /* ...output port */
+ xf_output_port_t output;
+
+ /***************************************************************************
+ * Run-time configuration parameters
+ **************************************************************************/
+
+ /* ...audio frame size in samples */
+ u32 frame_size;
+
+ /* ...audio frame duration */
+ u32 frame_duration;
+
+ /* ...presentation timestamp (in samples; local mixer scope) */
+ u32 pts;
+
+} XAMixer;
+
+/*******************************************************************************
+ * Mixer flags
+ ******************************************************************************/
+
+/* ...output port setup completed */
+#define XA_MIXER_FLAG_OUTPUT_SETUP __XA_BASE_FLAG(1 << 0)
+
+/*******************************************************************************
+ * Track state flags
+ ******************************************************************************/
+
+/* ...track is idle (will autostart as soon as input data received) */
+#define XA_TRACK_FLAG_IDLE __XF_INPUT_FLAG(1 << 0)
+
+/* ...track is rendered */
+#define XA_TRACK_FLAG_ACTIVE __XF_INPUT_FLAG(1 << 1)
+
+/* ...track is paused */
+#define XA_TRACK_FLAG_PAUSED __XF_INPUT_FLAG(1 << 2)
+
+/* ...track input port is setup */
+#define XA_TRACK_FLAG_INPUT_SETUP __XF_INPUT_FLAG(1 << 3)
+
+/* ...track has received data */
+#define XA_TRACK_FLAG_RECVD_DATA __XF_INPUT_FLAG(1 << 4)
+
+/*******************************************************************************
+ * Helper functions
+ ******************************************************************************/
+/* ...Count the tracks that have received data or are active*/
+static inline UWORD32 xa_mixer_check_active(XAMixer *mixer)
+{
+ XATrack *track;
+ UWORD32 i;
+ UWORD32 cnt = 0;
+
+ for (track = &mixer->track[i = 0]; i < XA_MIXER_MAX_TRACK_NUMBER; i++, track++)
+ {
+ if (xa_track_test_flags(track, XA_TRACK_FLAG_RECVD_DATA | XA_TRACK_FLAG_ACTIVE))
+ cnt++;
+ }
+ return cnt;
+}
+
+/* ...prepare mixer for steady operation */
+static inline XA_ERRORCODE xa_mixer_prepare_runtime(XAMixer *mixer)
+{
+ XACodecBase *base = (XACodecBase *) mixer;
+ xf_message_t *m = xf_msg_dequeue(&mixer->output.queue);
+ xf_start_msg_t *msg = m->buffer;
+ u32 frame_size;
+ u32 factor;
+
+ /* ...query mixer parameters */
+ XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_MIXER_CONFIG_PARAM_SAMPLE_RATE, &msg->sample_rate);
+ XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_MIXER_CONFIG_PARAM_CHANNELS, &msg->channels);
+ XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_MIXER_CONFIG_PARAM_PCM_WIDTH, &msg->pcm_width);
+ XA_API(base, XA_API_CMD_GET_MEM_INFO_SIZE, 0, &msg->input_length);
+ XA_API(base, XA_API_CMD_GET_MEM_INFO_SIZE, XA_MIXER_MAX_TRACK_NUMBER, &msg->output_length);
+ XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_MIXER_CONFIG_PARAM_FRAME_SIZE, &frame_size);
+
+ /* ...calculate mixer frame duration; get upsample factor */
+ XF_CHK_ERR(factor = xf_timebase_factor(msg->sample_rate), XA_MIXER_CONFIG_FATAL_RANGE);
+
+ /* ...set mixer frame duration */
+ mixer->frame_duration = frame_size * factor;
+
+ /* ...pass response to caller */
+ xf_response_data(m, sizeof(*msg));
+
+ return XA_NO_ERROR;
+}
+
+/*******************************************************************************
+ * Commands handlers
+ ******************************************************************************/
+
+/* ...EMPTY-THIS-BUFFER command processing */
+static XA_ERRORCODE xa_mixer_empty_this_buffer(XACodecBase *base, xf_message_t *m)
+{
+ XAMixer *mixer = (XAMixer *) base;
+ u32 i = XF_MSG_DST_PORT(m->id);
+ XATrack *track = &mixer->track[i];
+
+ /* ...make sure the port is valid */
+ XF_CHK_ERR(i < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...command is allowed only in "postinit" state */
+ XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD);
+
+ TRACE(INPUT, _b("track-%u: received buffer [%p]:%u"), i, m->buffer, m->length);
+
+ /* ...update received data for the track */
+ if (m->length)
+ xa_track_set_flags(track, XA_TRACK_FLAG_RECVD_DATA);
+ else
+ xa_track_clear_flags(track, XA_TRACK_FLAG_RECVD_DATA);
+
+ /* ...place received message into track input port */
+ if (xf_input_port_put(&track->input, m))
+ {
+ /* ...process track autostart if needed */
+ if (xa_track_test_flags(track, XA_TRACK_FLAG_IDLE))
+ {
+ /* ...put track into active state */
+ xa_track_toggle_flags(track, XA_TRACK_FLAG_IDLE | XA_TRACK_FLAG_ACTIVE);
+
+ /* ...save track presentation timestamp */
+ track->pts = mixer->pts;
+
+ TRACE(INFO, _b("track-%u started (pts=%x)"), i, track->pts);
+ }
+
+ /* ...schedule data processing if there is output port available */
+ if (xf_output_port_ready(&mixer->output))
+ {
+ /* ...force data processing */
+ xa_base_schedule(base, 0);
+ }
+ }
+
+ return XA_NO_ERROR;
+}
+
+/* ...FILL-THIS-BUFFER command processing */
+static XA_ERRORCODE xa_mixer_fill_this_buffer(XACodecBase *base, xf_message_t *m)
+{
+ XAMixer *mixer = (XAMixer *) base;
+ u32 i = XF_MSG_DST_PORT(m->id);
+
+ /* ...make sure the port is valid */
+ XF_CHK_ERR(i == XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...command is allowed only in "postinit" state */
+ XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD);
+
+ /* ...process runtime initialization explicitly */
+ if (base->state & XA_BASE_FLAG_RUNTIME_INIT)
+ {
+ /* ...message must be zero-length */
+ XF_CHK_ERR(m->length == 0, XA_MIXER_EXEC_FATAL_STATE);
+ }
+ else if (m->length != 0) /* ...EOS response */
+ {
+ /* ...message must have exactly expected size (there is no ordered abortion) */
+ XF_CHK_ERR(m->length == mixer->output.length, XA_MIXER_EXEC_FATAL_STATE);
+ }
+
+ TRACE(OUTPUT, _b("received output buffer [%p]:%u"), m->buffer, m->length);
+
+ /* ...put message into output port */
+ if (xf_output_port_put(&mixer->output, m))
+ {
+ /* ...force data processing */
+ xa_base_schedule(base, 0);
+ }
+
+ return XA_NO_ERROR;
+}
+
+/* ...output port routing */
+static XA_ERRORCODE xa_mixer_port_route(XACodecBase *base, xf_message_t *m)
+{
+ XAMixer *mixer = (XAMixer *) base;
+ xf_route_port_msg_t *cmd = m->buffer;
+ xf_output_port_t *port = &mixer->output;
+ u32 src = XF_MSG_DST(m->id);
+ u32 dst = cmd->dst;
+
+ /* ...command is allowed only in "postinit" state */
+ XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD);
+
+ /* ...make sure output port is addressed */
+ XF_CHK_ERR(XF_MSG_DST_PORT(m->id) == XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...make sure port is not routed yet */
+ XF_CHK_ERR(!xf_output_port_routed(port), XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...route output port - allocate queue */
+ XF_CHK_ERR(xf_output_port_route(port, __XF_MSG_ID(dst, src), cmd->alloc_number, cmd->alloc_size, cmd->alloc_align) == 0, XA_API_FATAL_MEM_ALLOC);
+
+ /* ...schedule processing instantly - tbd - check if we have anything pending on input */
+ xa_base_schedule(base, 0);
+
+ /* ...pass success result to caller */
+ xf_response_ok(m);
+
+ return XA_NO_ERROR;
+}
+
+/* ...port unroute command */
+static XA_ERRORCODE xa_mixer_port_unroute(XACodecBase *base, xf_message_t *m)
+{
+ XAMixer *mixer = (XAMixer *) base;
+ xf_output_port_t *port = &mixer->output;
+
+ /* ...command is allowed only in "postinit" state */
+ XF_CHK_ERR(base->state & XA_BASE_FLAG_POSTINIT, XA_API_FATAL_INVALID_CMD);
+
+ /* ...make sure output port is addressed */
+ XF_CHK_ERR(XF_MSG_DST_PORT(m->id) == XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...cancel any pending processing */
+ xa_base_cancel(base);
+
+ /* ...clear output-port-setup condition */
+ base->state &= ~XA_MIXER_FLAG_OUTPUT_SETUP;
+
+ /* ...pass flush command down the graph */
+ if (xf_output_port_flush(port, XF_FLUSH))
+ {
+ TRACE(INFO, _b("port is idle; instantly unroute"));
+
+ /* ...flushing sequence is not needed; command may be satisfied instantly */
+ xf_output_port_unroute(port);
+
+ /* ...pass response to the proxy */
+ xf_response_ok(m);
+ }
+ else
+ {
+ TRACE(INFO, _b("port is busy; propagate unroute command"));
+
+ /* ...flushing sequence is started; save flow-control message */
+ xf_output_port_unroute_start(port, m);
+ }
+
+ return XA_NO_ERROR;
+}
+
+/* ...PAUSE message processing */
+static XA_ERRORCODE xa_mixer_pause(XACodecBase *base, xf_message_t *m)
+{
+ XAMixer *mixer = (XAMixer *) base;
+ u32 i = XF_MSG_DST_PORT(m->id);
+ XATrack *track = &mixer->track[i];
+
+ /* ...make sure the buffer is empty */
+ XF_CHK_ERR(m->length == 0, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...check destination port is valid */
+ XF_CHK_ERR(i < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...check for actual track flags */
+ if (xa_track_test_flags(track, XA_TRACK_FLAG_ACTIVE))
+ {
+ /* ...switch to paused state */
+ xa_track_toggle_flags(track, XA_TRACK_FLAG_ACTIVE | XA_TRACK_FLAG_PAUSED);
+
+ /* ...other tracks may be waiting for this one, so force data processing */
+ if (xf_output_port_ready(&mixer->output))
+ {
+ xa_base_schedule(base, 0);
+ }
+
+ TRACE(INFO, _b("mixer[%p]::track[%u] paused"), mixer, i);
+ }
+ else
+ {
+ /* ...track is in idle state and pausing here means suspending */
+ TRACE(INFO, _b("mixer[%p]::track[%u] is not active"), mixer, i);
+ }
+
+ /* ...complete message immediately */
+ xf_response(m);
+
+ return XA_NO_ERROR;
+}
+
+/* ...RESUME command processing */
+static XA_ERRORCODE xa_mixer_resume(XACodecBase *base, xf_message_t *m)
+{
+ XAMixer *mixer = (XAMixer *) base;
+ u32 i = XF_MSG_DST_PORT(m->id);
+ XATrack *track = &mixer->track[i];
+
+ /* ...make sure the buffer is empty */
+ XF_CHK_ERR(m->length == 0, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...check destination port is valid */
+ XF_CHK_ERR(i < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...check for actual track state */
+ if (xa_track_test_flags(track, XA_TRACK_FLAG_PAUSED))
+ {
+ /* ...switch track to active state */
+ xa_track_toggle_flags(track, XA_TRACK_FLAG_ACTIVE | XA_TRACK_FLAG_PAUSED);
+
+ /* ...reset track presentation timestamp - tbd */
+ track->pts = mixer->pts;
+
+ /* ...force data processing if there is an output buffer */
+ if (xf_output_port_ready(&mixer->output))
+ {
+ xa_base_schedule(base, 0);
+ }
+
+ TRACE(INFO, _b("mixer[%p]::track[%u] resumed"), mixer, i);
+ }
+ else
+ {
+ /* ...track is in idle state; do nothing */
+ TRACE(INFO, _b("mixer[%p]::track[%u] is not paused"), mixer, i);
+ }
+
+ /* ...complete message */
+ xf_response(m);
+
+ return XA_NO_ERROR;
+}
+
+/* ...FLUSH command processing */
+static XA_ERRORCODE xa_mixer_flush(XACodecBase *base, xf_message_t *m)
+{
+ XAMixer *mixer = (XAMixer *) base;
+ u32 i = XF_MSG_DST_PORT(m->id);
+ XATrack *track = &mixer->track[i];
+
+ /* ...make sure the buffer is empty */
+ XF_CHK_ERR(m->length == 0, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...check destination port index */
+ if (i == XA_MIXER_MAX_TRACK_NUMBER)
+ {
+ /* ...flushing response received; that is a port unrouting sequence */
+ XF_CHK_ERR(xf_output_port_unrouting(&mixer->output), XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...complete unroute sequence */
+ xf_output_port_unroute_done(&mixer->output);
+
+ TRACE(INFO, _b("port is unrouted"));
+
+ return XA_NO_ERROR;
+ }
+
+ /* ...check destination port index is valid */
+ XF_CHK_ERR(i < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...input port flushing; check the track state is valid */
+ if (xa_track_test_flags(track, XA_TRACK_FLAG_ACTIVE | XA_TRACK_FLAG_PAUSED))
+ {
+ /* ...purge input port */
+ xf_input_port_purge(&track->input);
+
+ /* ...force clearing of ACTIVE and INPUT_SETUP condition */
+ xa_track_clear_flags(track, XA_TRACK_FLAG_ACTIVE | XA_TRACK_FLAG_PAUSED | XA_TRACK_FLAG_INPUT_SETUP);
+
+ /* ...and enter into idle state */
+ xa_track_set_flags(track, XA_TRACK_FLAG_IDLE);
+
+ /* ...other tracks may be waiting for this track, so force data processing */
+ if (xf_output_port_ready(&mixer->output))
+ {
+ xa_base_schedule(base, 0);
+ }
+
+ TRACE(INFO, _b("mixer[%p]::track[%u] flushed"), mixer, i);
+ }
+
+ /* ...complete message instantly (no propagation to output port) */
+ xf_response(m);
+
+ return XA_NO_ERROR;
+}
+
+/*******************************************************************************
+ * Codec API implementation
+ ******************************************************************************/
+
+/* ...buffers handling */
+static XA_ERRORCODE xa_mixer_memtab(XACodecBase *base, WORD32 idx, WORD32 type, WORD32 size, WORD32 align, u32 core)
+{
+ XAMixer *mixer = (XAMixer *)base;
+
+ if (type == XA_MEMTYPE_INPUT)
+ {
+ XATrack *track = &mixer->track[idx];
+
+ /* ...input buffer allocation; check track number is sane */
+ XF_CHK_ERR(idx < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...create input port for a track */
+ XF_CHK_ERR(xf_input_port_init(&track->input, size, align, core) == 0, XA_API_FATAL_MEM_ALLOC);
+
+ /* ...set input port buffer */
+ XA_API(base, XA_API_CMD_SET_MEM_PTR, idx, track->input.buffer);
+
+ /* ...put track into idle state (will start as soon as we receive data) */
+ xa_track_set_flags(track, XA_TRACK_FLAG_IDLE);
+
+ TRACE(INIT, _b("mixer[%p]::track[%u] input port created - size=%u"), mixer, idx, size);
+ }
+ else
+ {
+ /* ...output buffer allocation */
+ XF_CHK_ERR(type == XA_MEMTYPE_OUTPUT, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...check port number is what we expect */
+ XF_CHK_ERR(idx == XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...set mixer frame-size (in samples - for timestamp tracking) */
+ XA_API(base, XA_API_CMD_GET_CONFIG_PARAM, XA_MIXER_CONFIG_PARAM_FRAME_SIZE, &mixer->frame_size);
+
+ /* ...create output port for a track */
+ XF_CHK_ERR(xf_output_port_init(&mixer->output, size) == 0, XA_API_FATAL_MEM_ALLOC);
+
+ TRACE(INIT, _b("mixer[%p] output port created; size=%u"), mixer, size);
+ }
+
+ return XA_NO_ERROR;
+}
+
+/* ...preprocessing function */
+static XA_ERRORCODE xa_mixer_preprocess(XACodecBase *base)
+{
+ XAMixer *mixer = (XAMixer *) base;
+ XATrack *track;
+ u8 i;
+ XA_ERRORCODE e = XA_MIXER_EXEC_NONFATAL_NO_DATA;
+
+ /* ...prepare output buffer */
+ if (!(base->state & XA_MIXER_FLAG_OUTPUT_SETUP))
+ {
+ void *output;
+
+ /* ...set output buffer pointer */
+ if (base->state & XA_BASE_FLAG_RUNTIME_INIT)
+ {
+ /* ...no actual data processing during initialization */
+ return XA_NO_ERROR;
+ }
+ else if ((output = xf_output_port_data(&mixer->output)) == NULL)
+ {
+ /* ...no output buffer available */
+ return e;
+ }
+
+ /* ...set output buffer pointer */
+ XA_API(base, XA_API_CMD_SET_MEM_PTR, XA_MIXER_MAX_TRACK_NUMBER, output);
+
+ /* ...mark output port is setup */
+ base->state ^= XA_MIXER_FLAG_OUTPUT_SETUP;
+ }
+
+ /* ...check EOS */
+ if (!xa_mixer_check_active(mixer))
+ {
+ /* ...push EOS to output port */
+ xf_output_port_produce(&mixer->output, 0);
+ TRACE(INFO, _b("mixer[%p]::EOS generated"), mixer);
+ }
+
+ /* ...setup input buffer pointers and length */
+ for (track = &mixer->track[i = 0]; i < XA_MIXER_MAX_TRACK_NUMBER; i++, track++)
+ {
+ /* ...skip tracks that are not played */
+ if (!xa_track_test_flags(track, XA_TRACK_FLAG_ACTIVE)) continue;
+
+ /* ...set temporary mixing request */
+ e = XA_NO_ERROR;
+
+ /* ...skip the tracks that has been setup already */
+ if (xa_track_test_flags(track, XA_TRACK_FLAG_INPUT_SETUP)) continue;
+
+ /* ...found active track that hasn't been setup yet */
+ TRACE(INPUT, _b("track-%u: ts=%x vs mts=%x"), i, track->pts, mixer->pts);
+
+ /* ...if track presentation timestamp is in the future, do nothing yet really */
+ if (!xf_time_after(track->pts, mixer->pts))
+ {
+ u32 filled;
+
+ /* ...take actual data from input port (mixer is always using internal buffer) */
+ if (!xf_input_port_fill(&track->input))
+ {
+ /* ...failed to prefill input buffer - no sufficient data yet */
+ return XA_MIXER_EXEC_NONFATAL_NO_DATA;
+ }
+ else
+ {
+ /* ...retrieve number of bytes available */
+ filled = xf_input_port_level(&track->input);
+ }
+
+ /* ...set total number of bytes we have in buffer */
+ XA_API(base, XA_API_CMD_SET_INPUT_BYTES, i, &filled);
+
+ /* ...actual data is to be played */
+ TRACE(INPUT, _b("track-%u: filled %u bytes"), i, filled);
+ }
+
+ /* ...mark the track input is setup (emit silence or actual data) */
+ xa_track_set_flags(track, XA_TRACK_FLAG_INPUT_SETUP);
+ }
+
+ /* ...do mixing operation only when all active tracks are setup */
+ return e;
+}
+
+/* ...postprocessing function */
+static XA_ERRORCODE xa_mixer_postprocess(XACodecBase *base, int done)
+{
+ XAMixer *mixer = (XAMixer *) base;
+ XATrack *track;
+ u32 produced;
+ u32 consumed;
+ u8 i;
+
+ /* ...process execution stage transitions */
+ if (done)
+ {
+ if (base->state & XA_BASE_FLAG_RUNTIME_INIT)
+ {
+ /* ...failed to initialize runtime (can't be? - tbd)*/
+ BUG(1, _x("breakpoint"));
+ }
+ else if (base->state & XA_BASE_FLAG_EXECUTION)
+ {
+ /* ...enter into execution state; initialize runtime */
+ return XA_CHK(xa_mixer_prepare_runtime(mixer));
+ }
+ else
+ {
+ /* ...mixer operation is over (can't be? - tbd) */
+ BUG(1, _x("breakpoint"));
+ }
+ }
+
+ /* ...input ports maintenance; process all tracks */
+ for (track = &mixer->track[i = 0]; i < XA_MIXER_MAX_TRACK_NUMBER; i++, track++)
+ {
+ /* ...skip the tracks that are not runing */
+ if (!xa_track_test_flags(track, XA_TRACK_FLAG_ACTIVE)) continue;
+
+ /* ...clear input setup flag */
+ xa_track_clear_flags(track, XA_TRACK_FLAG_INPUT_SETUP);
+
+ /* ...advance track presentation timestamp */
+ track->pts += mixer->frame_size;
+
+ /* ...get total amount of consumed bytes */
+ XA_API(base, XA_API_CMD_GET_CURIDX_INPUT_BUF, i, &consumed);
+
+ TRACE(INPUT, _b("track-%u::postprocess(c=%u, ts=%x)"), i, consumed, track->pts);
+
+ /* ...consume that amount from input port (may be zero) */
+ xf_input_port_consume(&track->input, consumed);
+
+ /* ...check if input port is done */
+ if (xf_input_port_done(&track->input))
+ {
+ /* ...input stream is over; return zero-length input back to caller */
+ xf_input_port_purge(&track->input);
+
+ /* ...switch to idle state */
+ xa_track_toggle_flags(track, XA_TRACK_FLAG_ACTIVE | XA_TRACK_FLAG_IDLE);
+
+ TRACE(INFO, _b("mixer[%p]::track[%u] completed"), mixer, i);
+ }
+ }
+
+ /* ...check if we have produced anything */
+ XA_API(base, XA_API_CMD_GET_OUTPUT_BYTES, XA_MIXER_MAX_TRACK_NUMBER, &produced);
+
+ TRACE(OUTPUT, _b("mixer[%p]::postprocess(p=%u, ts=%x, done=%u)"), mixer, produced, mixer->pts, done);
+
+ /* ...output port maintenance */
+ if (produced)
+ {
+ /* ...make sure we have produced exactly single frame */
+ BUG(produced != mixer->output.length, _x("Invalid length: %u != %u"), produced, mixer->output.length);
+
+ /* ...steady mixing process; advance mixer presentation timestamp */
+ mixer->pts += mixer->frame_size;
+
+ /* ...push data from output port */
+ xf_output_port_produce(&mixer->output, produced);
+
+ /* ...clear output-setup condition */
+ base->state &= ~XA_MIXER_FLAG_OUTPUT_SETUP;
+ }
+
+ /* ...reschedule data processing if there is a pending output message */
+ if (xf_output_port_ready(&mixer->output))
+ {
+ /* ...schedule execution with respect to urgency */
+ xa_base_schedule(base, (produced ? mixer->frame_duration : 0));
+ }
+
+ return XA_NO_ERROR;
+}
+
+/*******************************************************************************
+ * Command-processing function
+ ******************************************************************************/
+
+/* ...command hooks */
+static XA_ERRORCODE (* const xa_mixer_cmd[])(XACodecBase *, xf_message_t *) =
+{
+ /* ...set-parameter - actually, same as in generic case */
+ [XF_OPCODE_TYPE(XF_SET_PARAM)] = xa_base_set_param,
+ [XF_OPCODE_TYPE(XF_GET_PARAM)] = xa_base_get_param,
+
+ /* ...output port routing/unrouting */
+ [XF_OPCODE_TYPE(XF_ROUTE)] = xa_mixer_port_route,
+ [XF_OPCODE_TYPE(XF_UNROUTE)] = xa_mixer_port_unroute,
+
+ /* ...input/output buffers processing */
+ [XF_OPCODE_TYPE(XF_EMPTY_THIS_BUFFER)] = xa_mixer_empty_this_buffer,
+ [XF_OPCODE_TYPE(XF_FILL_THIS_BUFFER)] = xa_mixer_fill_this_buffer,
+ [XF_OPCODE_TYPE(XF_FLUSH)] = xa_mixer_flush,
+
+ /* ...track control */
+ [XF_OPCODE_TYPE(XF_PAUSE)] = xa_mixer_pause,
+ [XF_OPCODE_TYPE(XF_RESUME)] = xa_mixer_resume,
+};
+
+/* ...total number of commands supported */
+#define XA_MIXER_CMD_NUM (sizeof(xa_mixer_cmd) / sizeof(xa_mixer_cmd[0]))
+
+/*******************************************************************************
+ * Entry points
+ ******************************************************************************/
+
+/* ...mixer termination-state command processor */
+static int xa_mixer_terminate(xf_component_t *component, xf_message_t *m)
+{
+ XAMixer *mixer = (XAMixer *) component;
+ u32 opcode = m->opcode;
+
+ if (m == xf_output_port_control_msg(&mixer->output))
+ {
+ /* ...output port flushing complete; mark port is idle and terminate */
+ xf_output_port_flush_done(&mixer->output);
+ return -1;
+ }
+ else if (opcode == XF_FILL_THIS_BUFFER && xf_output_port_routed(&mixer->output))
+ {
+ /* ...output buffer returned by the sink component; ignore and keep waiting */
+ TRACE(OUTPUT, _b("collect output buffer"));
+ return 0;
+ }
+ else if (opcode == XF_UNREGISTER)
+ {
+ /* ...ignore subsequent unregister command/response */
+ return 0;
+ }
+ else
+ {
+ /* ...everything else is responded with generic failure */
+ xf_response_err(m);
+ return 0;
+ }
+}
+
+/* ...mixer class destructor */
+static int xa_mixer_destroy(xf_component_t *component, xf_message_t *m)
+{
+ XAMixer *mixer = (XAMixer *) component;
+ u32 core = xf_component_core(component);
+ u32 i;
+
+ /* ...destroy all inputs */
+ for (i = 0; i < XA_MIXER_MAX_TRACK_NUMBER; i++)
+ {
+ xf_input_port_destroy(&mixer->track[i].input, core);
+ }
+
+ /* ...destroy output port */
+ xf_output_port_destroy(&mixer->output, core);
+
+ /* ...destroy base object */
+ xa_base_destroy(&mixer->base, XF_MM(sizeof(*mixer)), core);
+
+ TRACE(INIT, _b("mixer[%p] destroyed"), mixer);
+
+ return 0;
+}
+
+/* ...mixer class first-stage destructor */
+static int xa_mixer_cleanup(xf_component_t *component, xf_message_t *m)
+{
+ XAMixer *mixer = (XAMixer *) component;
+ u32 i;
+
+ /* ...complete message with error result code */
+ xf_response_err(m);
+
+ /* ...cancel internal scheduling message if needed */
+ xa_base_cancel(&mixer->base);
+
+ /* ...purge all input ports (specify "unregister"? - don't know yet - tbd) */
+ for (i = 0; i < XA_MIXER_MAX_TRACK_NUMBER; i++)
+ {
+ xf_input_port_purge(&mixer->track[i].input);
+ }
+
+ /* ...flush output port */
+ if (xf_output_port_flush(&mixer->output, XF_FLUSH))
+ {
+ /* ...flushing sequence is not needed; destroy mixer */
+ return xa_mixer_destroy(component, NULL);
+ }
+ else
+ {
+ /* ...wait until output port is cleaned; adjust component hooks */
+ component->entry = xa_mixer_terminate;
+ component->exit = xa_mixer_destroy;
+
+ TRACE(INIT, _b("mixer[%p] cleanup sequence started"), mixer);
+
+ /* ...indicate that second stage is required */
+ return 1;
+ }
+}
+
+/* ...mixer class factory */
+xf_component_t * xa_mixer_factory(u32 core, xa_codec_func_t process)
+{
+ XAMixer *mixer;
+
+ /* ...construct generic audio component */
+ XF_CHK_ERR(mixer = (XAMixer *)xa_base_factory(core, XF_MM(sizeof(*mixer)), process), NULL);
+
+ /* ...set generic codec API */
+ mixer->base.memtab = xa_mixer_memtab;
+ mixer->base.preprocess = xa_mixer_preprocess;
+ mixer->base.postprocess = xa_mixer_postprocess;
+
+ /* ...set message-processing table */
+ mixer->base.command = xa_mixer_cmd;
+ mixer->base.command_num = XA_MIXER_CMD_NUM;
+
+ /* ...set component destructor hook */
+ mixer->base.component.exit = xa_mixer_cleanup;
+
+ TRACE(INIT, _b("Mixer[%p] created"), mixer);
+
+ /* ...return handle to component */
+ return (xf_component_t *) mixer;
+}
diff --git a/hifi/xaf/hifi-dpf/build_hikey/Makefile b/hifi/xaf/hifi-dpf/build_hikey/Makefile
new file mode 100644
index 00000000..e1980a0d
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/Makefile
@@ -0,0 +1,135 @@
+#
+# Copyright (C) 2018 Cadence Design Systems, Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to use this Software with Cadence processor cores only and
+# not with any other processors and platforms, 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.
+#
+
+
+.PHONY: all install clean HIKEY960
+
+NOSTRIP = 1
+XF_TRACE = 1
+
+ROOTDIR = ..
+CODEC_NAME = hikey
+
+PLUGINO2OBJS =
+PLUGINLIBS =
+PLUGININCLUDES =
+
+XA_MP3_DECODER ?= 0
+XA_VORBIS_DECODER ?= 1
+XA_MIXER ?= 1
+XA_PCM ?= 1
+
+
+vpath %.c $(ROOTDIR)/ipc/xt-shmem/hikey
+vpath %.c $(ROOTDIR)/ipc/xt-shmem
+vpath %.c $(ROOTDIR)/core/util
+vpath %.c $(ROOTDIR)/core/util/gdbstub
+vpath %.c $(ROOTDIR)/core
+vpath %.c $(ROOTDIR)/app
+vpath %.c $(ROOTDIR)/audio
+
+vpath %.S $(ROOTDIR)/ipc/xt-shmem/hikey
+vpath %.S $(ROOTDIR)/core/util/gdbstub
+
+vpath %.c $(ROOTDIR)/plugins/cadence/mixer
+
+LIBXAFASMOBJS = \
+ reset.o \
+ int_vector.o \
+ arch_hifi330.o \
+ gdbstub-entry.o
+
+LIBXAFO2OBJS = \
+ cpu_c.o \
+ dsp_debug.o \
+ dsp_comm.o \
+ mutex.o \
+ rbtree.o \
+ xf-core.o \
+ xf-io.o \
+ xf-mem.o \
+ xf-msg.o \
+ xf-sched.o \
+ xa-factory.o \
+ xf-shmem.o \
+ tinyvprintf.o \
+ xf-isr.o \
+ gdbstub.o \
+ xa-class-base.o \
+ xa-class-audio-codec.o \
+ xa-class-mixer.o \
+ xf-main.o
+
+ifeq ($(XF_TRACE),1)
+ CFLAGS += -DXF_TRACE=1
+ CFLAGS += -DXAF_PROFILE_DSP=1
+endif
+
+ifeq ($(XA_MP3_DECODER),1)
+ vpath %.c $(ROOTDIR)/plugins/cadence/mp3_dec
+ CFLAGS += -DXA_MP3_DECODER=1
+ PLUGINO2OBJS += xa-mp3-decoder.o
+ PLUGINLIBS += $(ROOTDIR)/plugins/cadence/mp3_dec/lib/hifi2/xa_mp3_dec.a
+ PLUGININCLUDES += -I$(ROOTDIR)/plugins/cadence/mp3_dec
+endif
+
+ifeq ($(XA_PCM),1)
+ vpath %.c $(ROOTDIR)/plugins/cadence/pcm_proc
+ CFLAGS += -DXA_PCM=1
+ PLUGINO2OBJS += xa-pcm.o
+ PLUGINLIBS +=
+ PLUGININCLUDES += -I$(ROOTDIR)/plugins/cadence/pcm_proc
+endif
+
+ifeq ($(XA_VORBIS_DECODER),1)
+ vpath %.c $(ROOTDIR)/plugins/cadence/vorbis_dec
+ CFLAGS += -DXA_VORBIS_DECODER=1
+ PLUGINO2OBJS += xa-vorbis-decoder.o
+ PLUGINLIBS += $(ROOTDIR)/plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a
+ PLUGININCLUDES += -I$(ROOTDIR)/plugins/cadence/vorbis_dec
+endif
+
+ifeq ($(XA_MIXER),1)
+ vpath %.c $(ROOTDIR)/plugins/cadence/mixer
+ CFLAGS += -DXA_MIXER=1
+ PLUGINO2OBJS += xa-mixer.o
+ PLUGINLIBS +=
+ PLUGININCLUDES += -I$(ROOTDIR)/plugins/cadence/mixer
+endif
+
+LIBO2OBJS = $(LIBXAFO2OBJS) $(LIBMP3DECO2OBJS) $(LIBMIXERO2OBJS) $(PLUGINO2OBJS)
+LIBASMOBJS = $(LIBXAFASMOBJS)
+
+INCLUDES += \
+ -I$(ROOTDIR)/include \
+ -I$(ROOTDIR)/include/audio \
+ -I$(ROOTDIR)/include/sys/xt-shmem \
+ -I$(ROOTDIR)/include/sys/xt-shmem/board-hikey \
+ -I$(ROOTDIR)/plugins/cadence/mp3_dec
+
+INCLUDES += $(PLUGININCLUDES)
+
+LDFLAGS += -nostdlib -lhal -lhandlers-board -lc -lgcc
+LDFLAGS += -mlsp="./hifi_hikey_lsp"
+
+HIKEY960: $(CODEC_NAME)
+
+include $(ROOTDIR)/build_hikey/common.mk
diff --git a/hifi/xaf/hifi-dpf/build_hikey/common.mk b/hifi/xaf/hifi-dpf/build_hikey/common.mk
new file mode 100644
index 00000000..ef4429ea
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/common.mk
@@ -0,0 +1,156 @@
+#
+# Copyright (C) 2018 Cadence Design Systems, Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to use this Software with Cadence processor cores only and
+# not with any other processors and platforms, 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.
+#
+
+QUIET =
+MAPFILE = map_$(CODEC_NAME).txt
+LDSCRIPT = ldscript_$(CODEC_NAME).txt
+SYMFILE = symbols_$(CODEC_NAME).txt
+ELFTOBIN = $(ROOTDIR)/build_hikey/tools/elftobin.sh
+
+ifeq ($(CPU), gcc)
+ S = /
+ AR = ar
+ OBJCOPY = objcopy
+ CC = gcc
+ CXX = g++
+ CFLAGS += -fno-exceptions -DCSTUB=1
+ CFLAGS += -ffloat-store
+ CFLAGS += -DHIFI3_CSTUB
+ RM = rm -f
+ RM_R = rm -rf
+ MKPATH = mkdir -p
+ CP = cp -f
+ INCLUDES += \
+ -I$(ROOTDIR)/test/include
+else
+ AR = xt-ar $(XTCORE)
+ OBJCOPY = xt-objcopy $(XTCORE)
+ CC = xt-xcc $(XTCORE)
+ CXX = xt-xc++ $(XTCORE)
+ ISS = xt-run $(XTCORE)
+ CONFIGDIR := $(shell $(ISS) --show-config=config)
+ include $(CONFIGDIR)/misc/hostenv.mk
+ #CFLAGS += -Wall
+ #CFLAGS += -Werror
+ #CFLAGS += -mno-mul16 -mno-mul32 -mno-div32 -fsigned-char -fno-exceptions -mlongcalls -INLINE:requested -mcoproc -fno-zero-initialized-in-bss
+ CFLAGS += -mlongcalls -mtext-section-literals
+ ASMFLAGS += -mlongcalls
+endif
+
+OBJDIR = objs$(S)$(CODEC_NAME)
+LIBDIR = $(ROOTDIR)$(S)lib
+
+OBJ_LIBO2OBJS = $(addprefix $(OBJDIR)/,$(LIBO2OBJS))
+OBJ_LIBOSOBJS = $(addprefix $(OBJDIR)/,$(LIBOSOBJS))
+OBJ_LIBO2CPPOBJS = $(addprefix $(OBJDIR)/,$(LIBO2CPPOBJS))
+OBJ_LIBOSCPPOBJS = $(addprefix $(OBJDIR)/,$(LIBOSCPPOBJS))
+OBJ_LIBASMOBJS = $(addprefix $(OBJDIR)/,$(LIBASMOBJS))
+
+TEMPOBJ = temp.o
+
+ifeq ($(CPU), gcc)
+ LIBOBJ = $(OBJDIR)/xgcc_$(CODEC_NAME).o
+ LIB = xgcc_$(CODEC_NAME).img
+else
+ LIBOBJ = $(OBJDIR)/xa_$(CODEC_NAME).o
+ LIB = xa_$(CODEC_NAME).img
+endif
+
+CFLAGS += \
+ $(EXTRA_CFLAGS) $(EXTRA_CFLAGS2)
+
+
+ifeq ($(DEBUG),1)
+ NOSTRIP = 1
+ OPT_O2 = -O0 -g
+ OPT_OS = -O0 -g
+ CFLAGS += -DDEBUG
+else
+ifeq ($(CPU), gcc)
+ OPT_O2 = -O2 -g
+ OPT_OS = -O2 -g
+else
+ #OPT_O2 = -O3 -LNO:simd
+ OPT_O2 = -g -O2
+ OPT_OS = -Os
+endif
+endif
+
+OPT_ASM = -g -Wa,--gdwarf-2
+
+
+all: $(OBJDIR) $(LIB)
+$(CODEC_NAME): $(OBJDIR) $(LIB)
+
+install: $(LIB)
+ @echo "Installing $(LIB)"
+ $(QUIET) -$(MKPATH) "$(LIBDIR)"
+ $(QUIET) $(CP) $(LIB) "$(LIBDIR)"
+
+$(OBJDIR):
+ $(QUIET) -$(MKPATH) $@
+
+ifeq ($(NOSTRIP), 1)
+$(LIBOBJ): $(OBJ_LIBO2OBJS) $(OBJ_LIBOSOBJS) $(OBJ_LIBO2CPPOBJS) $(OBJ_LIBOSCPPOBJS) $(OBJ_LIBASMOBJS) $(PLUGINLIBS)
+ @echo "Linking Objects"
+ $(QUIET) $(CXX) -c $(OPT_O2) $(CFLAGS) -o $@ $^ \
+ -Wl,-Map,$(MAPFILE) --no-standard-libraries \
+ $(LDFLAGS) $(EXTRA_LDFLAGS)
+else
+$(LIBOBJ): $(OBJ_LIBO2OBJS) $(OBJ_LIBOSOBJS) $(OBJ_LIBO2CPPOBJS) $(OBJ_LIBOSCPPOBJS) $(OBJ_LIBASMOBJS) $(PLUGINLIBS)
+ @echo "Linking Objects"
+ $(QUIET) $(CXX) -c $(OPT_O2) $(CFLAGS) -o $@ $^ \
+ -Wl,-Map,$(MAPFILE) --no-standard-libraries \
+ -Wl,--retain-symbols-file,$(SYMFILE) \
+ $(IPA_FLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS)
+ $(QUIET) $(OBJCOPY) --keep-global-symbols=$(SYMFILE) $@ $(TEMPOBJ)
+ $(QUIET) $(OBJCOPY) --strip-unneeded $(TEMPOBJ) $@
+ $(QUIET) -$(RM) $(TEMPOBJ)
+endif
+
+
+$(OBJ_LIBO2OBJS): $(OBJDIR)/%.o: %.c
+ @echo "Compiling $<"
+ $(QUIET) $(CC) -o $@ $(OPT_O2) $(CFLAGS) $(INCLUDES) -c $<
+
+$(OBJ_LIBOSOBJS): $(OBJDIR)/%.o: %.c
+ @echo "Compiling $<"
+ $(QUIET) $(CC) -o $@ $(OPT_OS) $(CFLAGS) $(INCLUDES) -c $<
+
+$(OBJ_LIBO2CPPOBJS): $(OBJDIR)/%.o: %.cpp
+ @echo "Compiling $<"
+ $(QUIET) $(CXX) -o $@ $(OPT_O2) $(CFLAGS) $(INCLUDES) -c $<
+
+$(OBJ_LIBOSCPPOBJS): $(OBJDIR)/%.o: %.cpp
+ @echo "Compiling $<"
+ $(QUIET) $(CXX) -o $@ $(OPT_OS) $(CFLAGS) $(INCLUDES) -c $<
+
+$(OBJ_LIBASMOBJS): $(OBJDIR)/%.o: %.S
+ @echo "Compiling $<"
+ $(QUIET) $(CC) -o $@ $(OPT_ASM) $(ASMFLAGS) $(INCLUDES) -c $<
+
+$(LIB): %.img: $(OBJDIR)/%.o
+ @echo "Creating Library $@"
+ $(ELFTOBIN) $< $@
+
+clean:
+ -$(RM) $(LIB) $(MAPFILE)
+ -$(RM_R) $(OBJDIR) $(LIBDIR)
diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.x b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.x
new file mode 100644
index 00000000..67507ed3
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.x
@@ -0,0 +1,827 @@
+/* This linker script generated from xt-genldscripts.tpp for LSP hifi_hikey_lsp */
+/* Linker Script for default link */
+MEMORY
+{
+ sram0_seg : org = 0xC0000000, len = 0x408000
+ old_vlpd_seg : org = 0xC0408000, len = 0x10000
+ efr_fr_hr_vlpd_seg : org = 0xC0418000, len = 0x10000
+ amr_vlpd_seg : org = 0xC0428000, len = 0x10000
+ amrwb_vlpd_seg : org = 0xC0438000, len = 0x10000
+ evrc_evrcb_vlpt_seg : org = 0xC0448000, len = 0x48000
+ efr_fr_hr_vlpt_seg : org = 0xC0490000, len = 0x30000
+ amr_vlpt_seg : org = 0xC04C0000, len = 0x20000
+ amrwb_vlpt_seg : org = 0xC04E0000, len = 0x30000
+ vlpt_seg : org = 0xC0510000, len = 0x48000
+ vlpd_seg : org = 0xC0558000, len = 0x20000
+ ulpp_seg : org = 0xC0578000, len = 0x40000
+ dtsv3_seg : org = 0xC05B8000, len = 0x20000
+ dtsv4_seg : org = 0xC05D8000, len = 0x28000
+ dram0_0_seg : org = 0xE8058000, len = 0x28000
+ iram0_0_seg : org = 0xE8080000, len = 0x300
+ iram0_1_seg : org = 0xE8080300, len = 0x100
+ iram0_2_seg : org = 0xE8080400, len = 0x178
+ iram0_3_seg : org = 0xE8080578, len = 0x8
+ iram0_4_seg : org = 0xE8080580, len = 0x38
+ iram0_5_seg : org = 0xE80805B8, len = 0x8
+ iram0_6_seg : org = 0xE80805C0, len = 0x38
+ iram0_7_seg : org = 0xE80805F8, len = 0x8
+ iram0_8_seg : org = 0xE8080600, len = 0x38
+ iram0_9_seg : org = 0xE8080638, len = 0x8
+ iram0_10_seg : org = 0xE8080640, len = 0x38
+ iram0_11_seg : org = 0xE8080678, len = 0x48
+ iram0_12_seg : org = 0xE80806C0, len = 0x38
+ iram0_13_seg : org = 0xE80806F8, len = 0x8
+ iram0_14_seg : org = 0xE8080700, len = 0x38
+ iram0_15_seg : org = 0xE8080738, len = 0x8
+ iram0_16_seg : org = 0xE8080740, len = 0x38
+ iram0_17_seg : org = 0xE8080778, len = 0x48
+ iram0_18_seg : org = 0xE80807C0, len = 0x40
+ iram0_19_seg : org = 0xE8080800, len = 0xB800
+}
+
+PHDRS
+{
+ sram0_phdr PT_LOAD;
+ sram0_bss_phdr PT_LOAD;
+ old_vlpd_phdr PT_LOAD;
+ old_vlpd_bss_phdr PT_LOAD;
+ efr_fr_hr_vlpd_phdr PT_LOAD;
+ efr_fr_hr_vlpd_bss_phdr PT_LOAD;
+ amr_vlpd_phdr PT_LOAD;
+ amr_vlpd_bss_phdr PT_LOAD;
+ amrwb_vlpd_phdr PT_LOAD;
+ amrwb_vlpd_bss_phdr PT_LOAD;
+ evrc_evrcb_vlpt_phdr PT_LOAD;
+ efr_fr_hr_vlpt_phdr PT_LOAD;
+ amr_vlpt_phdr PT_LOAD;
+ amrwb_vlpt_phdr PT_LOAD;
+ vlpt_phdr PT_LOAD;
+ vlpd_phdr PT_LOAD;
+ ulpp_phdr PT_LOAD;
+ ulpp_bss_phdr PT_LOAD;
+ dtsv3_phdr PT_LOAD;
+ dtsv3_bss_phdr PT_LOAD;
+ dtsv4_phdr PT_LOAD;
+ dtsv4_bss_phdr PT_LOAD;
+ dram0_0_phdr PT_LOAD;
+ dram0_0_bss_phdr PT_LOAD;
+ iram0_0_phdr PT_LOAD;
+ iram0_1_phdr PT_LOAD;
+ iram0_2_phdr PT_LOAD;
+ iram0_3_phdr PT_LOAD;
+ iram0_4_phdr PT_LOAD;
+ iram0_5_phdr PT_LOAD;
+ iram0_6_phdr PT_LOAD;
+ iram0_7_phdr PT_LOAD;
+ iram0_8_phdr PT_LOAD;
+ iram0_9_phdr PT_LOAD;
+ iram0_10_phdr PT_LOAD;
+ iram0_11_phdr PT_LOAD;
+ iram0_12_phdr PT_LOAD;
+ iram0_13_phdr PT_LOAD;
+ iram0_14_phdr PT_LOAD;
+ iram0_15_phdr PT_LOAD;
+ iram0_16_phdr PT_LOAD;
+ iram0_17_phdr PT_LOAD;
+ iram0_18_phdr PT_LOAD;
+ iram0_19_phdr PT_LOAD;
+}
+
+
+/* Default entry point: */
+ENTRY(_ResetVector)
+
+/* Memory boundary addresses: */
+_memmap_mem_iram0_start = 0xe8080000;
+_memmap_mem_iram0_end = 0xe808c000;
+_memmap_mem_dram0_start = 0xe8058000;
+_memmap_mem_dram0_end = 0xe8080000;
+_memmap_mem_sram_start = 0xc0000000;
+_memmap_mem_sram_end = 0xc0600000;
+
+/* Memory segment boundary addresses: */
+_memmap_seg_sram0_start = 0xc0000000;
+_memmap_seg_sram0_max = 0xc0408000;
+_memmap_seg_old_vlpd_start = 0xc0408000;
+_memmap_seg_old_vlpd_max = 0xc0418000;
+_memmap_seg_efr_fr_hr_vlpd_start = 0xc0418000;
+_memmap_seg_efr_fr_hr_vlpd_max = 0xc0428000;
+_memmap_seg_amr_vlpd_start = 0xc0428000;
+_memmap_seg_amr_vlpd_max = 0xc0438000;
+_memmap_seg_amrwb_vlpd_start = 0xc0438000;
+_memmap_seg_amrwb_vlpd_max = 0xc0448000;
+_memmap_seg_evrc_evrcb_vlpt_start = 0xc0448000;
+_memmap_seg_evrc_evrcb_vlpt_max = 0xc0490000;
+_memmap_seg_efr_fr_hr_vlpt_start = 0xc0490000;
+_memmap_seg_efr_fr_hr_vlpt_max = 0xc04c0000;
+_memmap_seg_amr_vlpt_start = 0xc04c0000;
+_memmap_seg_amr_vlpt_max = 0xc04e0000;
+_memmap_seg_amrwb_vlpt_start = 0xc04e0000;
+_memmap_seg_amrwb_vlpt_max = 0xc0510000;
+_memmap_seg_vlpt_start = 0xc0510000;
+_memmap_seg_vlpt_max = 0xc0558000;
+_memmap_seg_vlpd_start = 0xc0558000;
+_memmap_seg_vlpd_max = 0xc0578000;
+_memmap_seg_ulpp_start = 0xc0578000;
+_memmap_seg_ulpp_max = 0xc05b8000;
+_memmap_seg_dtsv3_start = 0xc05b8000;
+_memmap_seg_dtsv3_max = 0xc05d8000;
+_memmap_seg_dtsv4_start = 0xc05d8000;
+_memmap_seg_dtsv4_max = 0xc0600000;
+_memmap_seg_dram0_0_start = 0xe8058000;
+_memmap_seg_dram0_0_max = 0xe8080000;
+_memmap_seg_iram0_0_start = 0xe8080000;
+_memmap_seg_iram0_0_max = 0xe8080300;
+_memmap_seg_iram0_1_start = 0xe8080300;
+_memmap_seg_iram0_1_max = 0xe8080400;
+_memmap_seg_iram0_2_start = 0xe8080400;
+_memmap_seg_iram0_2_max = 0xe8080578;
+_memmap_seg_iram0_3_start = 0xe8080578;
+_memmap_seg_iram0_3_max = 0xe8080580;
+_memmap_seg_iram0_4_start = 0xe8080580;
+_memmap_seg_iram0_4_max = 0xe80805b8;
+_memmap_seg_iram0_5_start = 0xe80805b8;
+_memmap_seg_iram0_5_max = 0xe80805c0;
+_memmap_seg_iram0_6_start = 0xe80805c0;
+_memmap_seg_iram0_6_max = 0xe80805f8;
+_memmap_seg_iram0_7_start = 0xe80805f8;
+_memmap_seg_iram0_7_max = 0xe8080600;
+_memmap_seg_iram0_8_start = 0xe8080600;
+_memmap_seg_iram0_8_max = 0xe8080638;
+_memmap_seg_iram0_9_start = 0xe8080638;
+_memmap_seg_iram0_9_max = 0xe8080640;
+_memmap_seg_iram0_10_start = 0xe8080640;
+_memmap_seg_iram0_10_max = 0xe8080678;
+_memmap_seg_iram0_11_start = 0xe8080678;
+_memmap_seg_iram0_11_max = 0xe80806c0;
+_memmap_seg_iram0_12_start = 0xe80806c0;
+_memmap_seg_iram0_12_max = 0xe80806f8;
+_memmap_seg_iram0_13_start = 0xe80806f8;
+_memmap_seg_iram0_13_max = 0xe8080700;
+_memmap_seg_iram0_14_start = 0xe8080700;
+_memmap_seg_iram0_14_max = 0xe8080738;
+_memmap_seg_iram0_15_start = 0xe8080738;
+_memmap_seg_iram0_15_max = 0xe8080740;
+_memmap_seg_iram0_16_start = 0xe8080740;
+_memmap_seg_iram0_16_max = 0xe8080778;
+_memmap_seg_iram0_17_start = 0xe8080778;
+_memmap_seg_iram0_17_max = 0xe80807c0;
+_memmap_seg_iram0_18_start = 0xe80807c0;
+_memmap_seg_iram0_18_max = 0xe8080800;
+_memmap_seg_iram0_19_start = 0xe8080800;
+_memmap_seg_iram0_19_max = 0xe808c000;
+
+_rom_store_table = 0;
+PROVIDE(_memmap_vecbase_reset = 0xe8080400);
+PROVIDE(_memmap_reset_vector = 0xe8080000);
+/* Various memory-map dependent cache attribute settings: */
+_memmap_cacheattr_wb_base = 0x44000000;
+_memmap_cacheattr_wt_base = 0x11000000;
+_memmap_cacheattr_bp_base = 0x22000000;
+_memmap_cacheattr_unused_mask = 0x00FFFFFF;
+_memmap_cacheattr_wb_trapnull = 0x4422222F;
+_memmap_cacheattr_wba_trapnull = 0x4422222F;
+_memmap_cacheattr_wbna_trapnull = 0x5522222F;
+_memmap_cacheattr_wt_trapnull = 0x1122222F;
+_memmap_cacheattr_bp_trapnull = 0x2222222F;
+_memmap_cacheattr_wb_strict = 0x44FFFFFF;
+_memmap_cacheattr_wt_strict = 0x11FFFFFF;
+_memmap_cacheattr_bp_strict = 0x22FFFFFF;
+_memmap_cacheattr_wb_allvalid = 0x44222222;
+_memmap_cacheattr_wt_allvalid = 0x11222222;
+_memmap_cacheattr_bp_allvalid = 0x22222222;
+PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull);
+
+SECTIONS
+{
+
+ .vlpd.rodata : ALIGN(4)
+ {
+ _vlpd_rodata_start = ABSOLUTE(.);
+ *(.vlpd.rodata)
+ _vlpd_rodata_end = ABSOLUTE(.);
+ } >old_vlpd_seg :old_vlpd_phdr
+
+ .vlpd.data : ALIGN(4)
+ {
+ _vlpd_data_start = ABSOLUTE(.);
+ *(.vlpd.data)
+ _vlpd_data_end = ABSOLUTE(.);
+ } >old_vlpd_seg :old_vlpd_phdr
+
+ .vlpd.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _vlpd_bss_start = ABSOLUTE(.);
+ *(.vlpd.bss)
+ . = ALIGN (8);
+ _vlpd_bss_end = ABSOLUTE(.);
+ _memmap_seg_old_vlpd_end = ALIGN(0x8);
+ } >old_vlpd_seg :old_vlpd_bss_phdr
+
+ .efr_fr_hr_vlpd.rodata : ALIGN(4)
+ {
+ _efr_fr_hr_vlpd_rodata_start = ABSOLUTE(.);
+ *(.efr_fr_hr_vlpd.rodata)
+ _efr_fr_hr_vlpd_rodata_end = ABSOLUTE(.);
+ } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_phdr
+
+ .efr_fr_hr_vlpd.data : ALIGN(4)
+ {
+ _efr_fr_hr_vlpd_data_start = ABSOLUTE(.);
+ *(.efr_fr_hr_vlpd.data)
+ _efr_fr_hr_vlpd_data_end = ABSOLUTE(.);
+ } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_phdr
+
+ .efr_fr_hr_vlpd.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _efr_fr_hr_vlpd_bss_start = ABSOLUTE(.);
+ *(.efr_fr_hr_vlpd.bss)
+ . = ALIGN (8);
+ _efr_fr_hr_vlpd_bss_end = ABSOLUTE(.);
+ _memmap_seg_efr_fr_hr_vlpd_end = ALIGN(0x8);
+ } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_bss_phdr
+
+ .amr_vlpd.rodata : ALIGN(4)
+ {
+ _amr_vlpd_rodata_start = ABSOLUTE(.);
+ *(.amr_vlpd.rodata)
+ _amr_vlpd_rodata_end = ABSOLUTE(.);
+ } >amr_vlpd_seg :amr_vlpd_phdr
+
+ .amr_vlpd.data : ALIGN(4)
+ {
+ _amr_vlpd_data_start = ABSOLUTE(.);
+ *(.amr_vlpd.data)
+ _amr_vlpd_data_end = ABSOLUTE(.);
+ } >amr_vlpd_seg :amr_vlpd_phdr
+
+ .amr_vlpd.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _amr_vlpd_bss_start = ABSOLUTE(.);
+ *(.amr_vlpd.bss)
+ . = ALIGN (8);
+ _amr_vlpd_bss_end = ABSOLUTE(.);
+ _memmap_seg_amr_vlpd_end = ALIGN(0x8);
+ } >amr_vlpd_seg :amr_vlpd_bss_phdr
+
+ .amrwb_vlpd.rodata : ALIGN(4)
+ {
+ _amrwb_vlpd_rodata_start = ABSOLUTE(.);
+ *(.amrwb_vlpd.rodata)
+ _amrwb_vlpd_rodata_end = ABSOLUTE(.);
+ } >amrwb_vlpd_seg :amrwb_vlpd_phdr
+
+ .amrwb_vlpd.data : ALIGN(4)
+ {
+ _amrwb_vlpd_data_start = ABSOLUTE(.);
+ *(.amrwb_vlpd.data)
+ _amrwb_vlpd_data_end = ABSOLUTE(.);
+ } >amrwb_vlpd_seg :amrwb_vlpd_phdr
+
+ .amrwb_vlpd.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _amrwb_vlpd_bss_start = ABSOLUTE(.);
+ *(.amrwb_vlpd.bss)
+ . = ALIGN (8);
+ _amrwb_vlpd_bss_end = ABSOLUTE(.);
+ _memmap_seg_amrwb_vlpd_end = ALIGN(0x8);
+ } >amrwb_vlpd_seg :amrwb_vlpd_bss_phdr
+
+ .evrc_evrcb_vlpt.text : ALIGN(4)
+ {
+ _evrc_evrcb_vlpt_text_start = ABSOLUTE(.);
+ *(.evrc_evrcb_vlpt.literal .evrc_evrcb_vlpt.text)
+ _evrc_evrcb_vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_evrc_evrcb_vlpt_end = ALIGN(0x8);
+ } >evrc_evrcb_vlpt_seg :evrc_evrcb_vlpt_phdr
+
+ .efr_fr_hr_vlpt.text : ALIGN(4)
+ {
+ _efr_fr_hr_vlpt_text_start = ABSOLUTE(.);
+ *(.efr_fr_hr_vlpt.literal .efr_fr_hr_vlpt.text)
+ _efr_fr_hr_vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_efr_fr_hr_vlpt_end = ALIGN(0x8);
+ } >efr_fr_hr_vlpt_seg :efr_fr_hr_vlpt_phdr
+
+ .amr_vlpt.text : ALIGN(4)
+ {
+ _amr_vlpt_text_start = ABSOLUTE(.);
+ *(.amr_vlpt.literal .amr_vlpt.text)
+ _amr_vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_amr_vlpt_end = ALIGN(0x8);
+ } >amr_vlpt_seg :amr_vlpt_phdr
+
+ .amrwb_vlpt.text : ALIGN(4)
+ {
+ _amrwb_vlpt_text_start = ABSOLUTE(.);
+ *(.amrwb_vlpt.literal .amrwb_vlpt.text)
+ _amrwb_vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_amrwb_vlpt_end = ALIGN(0x8);
+ } >amrwb_vlpt_seg :amrwb_vlpt_phdr
+
+ .vlpt.text : ALIGN(4)
+ {
+ _vlpt_text_start = ABSOLUTE(.);
+ *(.vlpt.literal .vlpt.text)
+ _vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_vlpt_end = ALIGN(0x8);
+ } >vlpt_seg :vlpt_phdr
+
+ .low_power_dyn_alloc : ALIGN(4)
+ {
+ _low_power_dyn_alloc_start = ABSOLUTE(.);
+ *(.low_power_dyn_alloc)
+ _low_power_dyn_alloc_end = ABSOLUTE(.);
+ _memmap_seg_vlpd_end = ALIGN(0x8);
+ } >vlpd_seg :vlpd_phdr
+
+ .ulpp.rodata : ALIGN(4)
+ {
+ _ulpp_rodata_start = ABSOLUTE(.);
+ *(.ulpp.rodata)
+ _ulpp_rodata_end = ABSOLUTE(.);
+ } >ulpp_seg :ulpp_phdr
+
+ .ulpp.data : ALIGN(4)
+ {
+ _ulpp_data_start = ABSOLUTE(.);
+ *(.ulpp.data)
+ _ulpp_data_end = ABSOLUTE(.);
+ } >ulpp_seg :ulpp_phdr
+
+ .ulpp.text : ALIGN(4)
+ {
+ _ulpp_text_start = ABSOLUTE(.);
+ *(.ulpp.literal .ulpp.text)
+ _ulpp_text_end = ABSOLUTE(.);
+ } >ulpp_seg :ulpp_phdr
+
+ .ulpp.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _ulpp_bss_start = ABSOLUTE(.);
+ *(.ulpp.bss)
+ . = ALIGN (8);
+ _ulpp_bss_end = ABSOLUTE(.);
+ _memmap_seg_ulpp_end = ALIGN(0x8);
+ } >ulpp_seg :ulpp_bss_phdr
+
+ .dtsv3.rodata : ALIGN(4)
+ {
+ _dtsv3_rodata_start = ABSOLUTE(.);
+ *(.dtsv3.rodata)
+ _dtsv3_rodata_end = ABSOLUTE(.);
+ } >dtsv3_seg :dtsv3_phdr
+
+ .dtsv3.data : ALIGN(4)
+ {
+ _dtsv3_data_start = ABSOLUTE(.);
+ *(.dtsv3.data)
+ _dtsv3_data_end = ABSOLUTE(.);
+ } >dtsv3_seg :dtsv3_phdr
+
+ .dtsv3.text : ALIGN(4)
+ {
+ _dtsv3_text_start = ABSOLUTE(.);
+ *(.dtsv3.literal .dtsv3.text)
+ _dtsv3_text_end = ABSOLUTE(.);
+ } >dtsv3_seg :dtsv3_phdr
+
+ .dtsv3.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _dtsv3_bss_start = ABSOLUTE(.);
+ *(.dtsv3.bss)
+ . = ALIGN (8);
+ _dtsv3_bss_end = ABSOLUTE(.);
+ _memmap_seg_dtsv3_end = ALIGN(0x8);
+ } >dtsv3_seg :dtsv3_bss_phdr
+
+ .dtsv4.rodata : ALIGN(4)
+ {
+ _dtsv4_rodata_start = ABSOLUTE(.);
+ *(.dtsv4.rodata)
+ _dtsv4_rodata_end = ABSOLUTE(.);
+ } >dtsv4_seg :dtsv4_phdr
+
+ .dtsv4.data : ALIGN(4)
+ {
+ _dtsv4_data_start = ABSOLUTE(.);
+ *(.dtsv4.data)
+ _dtsv4_data_end = ABSOLUTE(.);
+ } >dtsv4_seg :dtsv4_phdr
+
+ .dtsv4.text : ALIGN(4)
+ {
+ _dtsv4_text_start = ABSOLUTE(.);
+ *(.dtsv4.literal .dtsv4.text)
+ _dtsv4_text_end = ABSOLUTE(.);
+ } >dtsv4_seg :dtsv4_phdr
+
+ .dtsv4.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _dtsv4_bss_start = ABSOLUTE(.);
+ *(.dtsv4.bss)
+ . = ALIGN (8);
+ _dtsv4_bss_end = ABSOLUTE(.);
+ _memmap_seg_dtsv4_end = ALIGN(0x8);
+ } >dtsv4_seg :dtsv4_bss_phdr
+
+ .dram0.rodata : ALIGN(4)
+ {
+ _dram0_rodata_start = ABSOLUTE(.);
+ *(.dram0.rodata)
+ *(.dram.rodata)
+ _dram0_rodata_end = ABSOLUTE(.);
+ } >dram0_0_seg :dram0_0_phdr
+
+ .dram0.literal : ALIGN(4)
+ {
+ _dram0_literal_start = ABSOLUTE(.);
+ *(.dram0.literal)
+ *(.dram.literal)
+ _dram0_literal_end = ABSOLUTE(.);
+ } >dram0_0_seg :dram0_0_phdr
+
+ .dram0.data : ALIGN(4)
+ {
+ _dram0_data_start = ABSOLUTE(.);
+ *(.dram0.data)
+ *(.dram.data)
+ _dram0_data_end = ABSOLUTE(.);
+ } >dram0_0_seg :dram0_0_phdr
+
+ .dram0.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _dram0_bss_start = ABSOLUTE(.);
+ *(.dram0.bss)
+ *(.om.debug.bss)
+ *(.os.stack.bss)
+ . = ALIGN (8);
+ _dram0_bss_end = ABSOLUTE(.);
+ _end = ALIGN(0x8);
+ PROVIDE(end = ALIGN(0x8));
+ _stack_sentry = ALIGN(0x8);
+ _memmap_seg_dram0_0_end = ALIGN(0x8);
+ } >dram0_0_seg :dram0_0_bss_phdr
+ __stack = 0xe8080000;
+ _heap_sentry = 0xe8080000;
+
+ .ResetVector.text : ALIGN(4)
+ {
+ _ResetVector_text_start = ABSOLUTE(.);
+ KEEP (*(.ResetVector.text))
+ _ResetVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_0_end = ALIGN(0x8);
+ } >iram0_0_seg :iram0_0_phdr
+
+ .Reset.literal : ALIGN(4)
+ {
+ _Reset_literal_start = ABSOLUTE(.);
+ *(.Reset.literal)
+ _Reset_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_1_end = ALIGN(0x8);
+ } >iram0_1_seg :iram0_1_phdr
+
+ .WindowVectors.text : ALIGN(4)
+ {
+ _WindowVectors_text_start = ABSOLUTE(.);
+ KEEP (*(.WindowVectors.text))
+ _WindowVectors_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_2_end = ALIGN(0x8);
+ } >iram0_2_seg :iram0_2_phdr
+
+ .Level2InterruptVector.literal : ALIGN(4)
+ {
+ _Level2InterruptVector_literal_start = ABSOLUTE(.);
+ *(.Level2InterruptVector.literal)
+ _Level2InterruptVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_3_end = ALIGN(0x8);
+ } >iram0_3_seg :iram0_3_phdr
+
+ .Level2InterruptVector.text : ALIGN(4)
+ {
+ _Level2InterruptVector_text_start = ABSOLUTE(.);
+ KEEP (*(.Level2InterruptVector.text))
+ _Level2InterruptVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_4_end = ALIGN(0x8);
+ } >iram0_4_seg :iram0_4_phdr
+
+ .Level3InterruptVector.literal : ALIGN(4)
+ {
+ _Level3InterruptVector_literal_start = ABSOLUTE(.);
+ *(.Level3InterruptVector.literal)
+ _Level3InterruptVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_5_end = ALIGN(0x8);
+ } >iram0_5_seg :iram0_5_phdr
+
+ .Level3InterruptVector.text : ALIGN(4)
+ {
+ _Level3InterruptVector_text_start = ABSOLUTE(.);
+ KEEP (*(.Level3InterruptVector.text))
+ _Level3InterruptVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_6_end = ALIGN(0x8);
+ } >iram0_6_seg :iram0_6_phdr
+
+ .Level4InterruptVector.literal : ALIGN(4)
+ {
+ _Level4InterruptVector_literal_start = ABSOLUTE(.);
+ *(.Level4InterruptVector.literal)
+ _Level4InterruptVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_7_end = ALIGN(0x8);
+ } >iram0_7_seg :iram0_7_phdr
+
+ .Level4InterruptVector.text : ALIGN(4)
+ {
+ _Level4InterruptVector_text_start = ABSOLUTE(.);
+ KEEP (*(.Level4InterruptVector.text))
+ _Level4InterruptVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_8_end = ALIGN(0x8);
+ } >iram0_8_seg :iram0_8_phdr
+
+ .DebugExceptionVector.literal : ALIGN(4)
+ {
+ _DebugExceptionVector_literal_start = ABSOLUTE(.);
+ *(.DebugExceptionVector.literal)
+ _DebugExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_9_end = ALIGN(0x8);
+ } >iram0_9_seg :iram0_9_phdr
+
+ .DebugExceptionVector.text : ALIGN(4)
+ {
+ _DebugExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.DebugExceptionVector.text))
+ _DebugExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_10_end = ALIGN(0x8);
+ } >iram0_10_seg :iram0_10_phdr
+
+ .NMIExceptionVector.literal : ALIGN(4)
+ {
+ _NMIExceptionVector_literal_start = ABSOLUTE(.);
+ *(.NMIExceptionVector.literal)
+ _NMIExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_11_end = ALIGN(0x8);
+ } >iram0_11_seg :iram0_11_phdr
+
+ .NMIExceptionVector.text : ALIGN(4)
+ {
+ _NMIExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.NMIExceptionVector.text))
+ _NMIExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_12_end = ALIGN(0x8);
+ } >iram0_12_seg :iram0_12_phdr
+
+ .KernelExceptionVector.literal : ALIGN(4)
+ {
+ _KernelExceptionVector_literal_start = ABSOLUTE(.);
+ *(.KernelExceptionVector.literal)
+ _KernelExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_13_end = ALIGN(0x8);
+ } >iram0_13_seg :iram0_13_phdr
+
+ .KernelExceptionVector.text : ALIGN(4)
+ {
+ _KernelExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.KernelExceptionVector.text))
+ _KernelExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_14_end = ALIGN(0x8);
+ } >iram0_14_seg :iram0_14_phdr
+
+ .UserExceptionVector.literal : ALIGN(4)
+ {
+ _UserExceptionVector_literal_start = ABSOLUTE(.);
+ *(.UserExceptionVector.literal)
+ _UserExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_15_end = ALIGN(0x8);
+ } >iram0_15_seg :iram0_15_phdr
+
+ .UserExceptionVector.text : ALIGN(4)
+ {
+ _UserExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.UserExceptionVector.text))
+ _UserExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_16_end = ALIGN(0x8);
+ } >iram0_16_seg :iram0_16_phdr
+
+ .DoubleExceptionVector.literal : ALIGN(4)
+ {
+ _DoubleExceptionVector_literal_start = ABSOLUTE(.);
+ *(.DoubleExceptionVector.literal)
+ _DoubleExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_17_end = ALIGN(0x8);
+ } >iram0_17_seg :iram0_17_phdr
+
+ .DoubleExceptionVector.text : ALIGN(4)
+ {
+ _DoubleExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.DoubleExceptionVector.text))
+ _DoubleExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_18_end = ALIGN(0x8);
+ } >iram0_18_seg :iram0_18_phdr
+
+ .Reset.text : ALIGN(4)
+ {
+ _Reset_text_start = ABSOLUTE(.);
+ *(.Reset.text)
+ _Reset_text_end = ABSOLUTE(.);
+ } >iram0_19_seg :iram0_19_phdr
+
+ .iram0.text : ALIGN(4)
+ {
+ _iram0_text_start = ABSOLUTE(.);
+ *(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text)
+ _iram0_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_19_end = ALIGN(0x8);
+ } >iram0_19_seg :iram0_19_phdr
+
+ .sram.shareaddr : ALIGN(4)
+ {
+ _sram_shareaddr_start = ABSOLUTE(.);
+ *(.sram.shareaddr)
+ _sram_shareaddr_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .sram.rodata : ALIGN(4)
+ {
+ _sram_rodata_start = ABSOLUTE(.);
+ *(.sram.rodata)
+ _sram_rodata_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .rodata : ALIGN(4)
+ {
+ _rodata_start = ABSOLUTE(.);
+ *(.rodata)
+ *(.rodata.*)
+ *(.gnu.linkonce.r.*)
+ *(.rodata1)
+ __XT_EXCEPTION_TABLE__ = ABSOLUTE(.);
+ KEEP (*(.xt_except_table))
+ KEEP (*(.gcc_except_table))
+ *(.gnu.linkonce.e.*)
+ *(.gnu.version_r)
+ KEEP (*(.eh_frame))
+ /* C++ constructor and destructor tables, properly ordered: */
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ /* C++ exception handlers table: */
+ __XT_EXCEPTION_DESCS__ = ABSOLUTE(.);
+ *(.xt_except_desc)
+ *(.gnu.linkonce.h.*)
+ __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
+ *(.xt_except_desc_end)
+ *(.dynamic)
+ *(.gnu.version_d)
+ . = ALIGN(4); /* this table MUST be 4-byte aligned */
+ _bss_table_start = ABSOLUTE(.);
+ LONG(_vlpd_bss_start)
+ LONG(_vlpd_bss_end)
+ LONG(_efr_fr_hr_vlpd_bss_start)
+ LONG(_efr_fr_hr_vlpd_bss_end)
+ LONG(_amr_vlpd_bss_start)
+ LONG(_amr_vlpd_bss_end)
+ LONG(_amrwb_vlpd_bss_start)
+ LONG(_amrwb_vlpd_bss_end)
+ LONG(_ulpp_bss_start)
+ LONG(_ulpp_bss_end)
+ LONG(_dtsv3_bss_start)
+ LONG(_dtsv3_bss_end)
+ LONG(_dtsv4_bss_start)
+ LONG(_dtsv4_bss_end)
+ LONG(_dram0_bss_start)
+ LONG(_dram0_bss_end)
+ LONG(_bss_start)
+ LONG(_bss_end)
+ _bss_table_end = ABSOLUTE(.);
+ _rodata_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .sram.text : ALIGN(4)
+ {
+ _sram_text_start = ABSOLUTE(.);
+ *(.sram.literal .sram.text)
+ _sram_text_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .text : ALIGN(4)
+ {
+ _stext = .;
+ _text_start = ABSOLUTE(.);
+ *(.entry.text)
+ *(.init.literal)
+ KEEP(*(.init))
+ *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
+ *(.fini.literal)
+ KEEP(*(.fini))
+ *(.gnu.version)
+ _text_end = ABSOLUTE(.);
+ _etext = .;
+ } >sram0_seg :sram0_phdr
+
+ .sram.data : ALIGN(4)
+ {
+ _sram_data_start = ABSOLUTE(.);
+ *(.sram.data)
+ _sram_data_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .data : ALIGN(4)
+ {
+ _data_start = ABSOLUTE(.);
+ *(.data)
+ *(.data.*)
+ *(.gnu.linkonce.d.*)
+ KEEP(*(.gnu.linkonce.d.*personality*))
+ *(.data1)
+ *(.sdata)
+ *(.sdata.*)
+ *(.gnu.linkonce.s.*)
+ *(.sdata2)
+ *(.sdata2.*)
+ *(.gnu.linkonce.s2.*)
+ KEEP(*(.jcr))
+ _data_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .sram.uninit : ALIGN(4)
+ {
+ _sram_uninit_start = ABSOLUTE(.);
+ *(.sram.uninit)
+ _sram_uninit_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _bss_start = ABSOLUTE(.);
+ *(.dynsbss)
+ *(.sbss)
+ *(.sbss.*)
+ *(.gnu.linkonce.sb.*)
+ *(.scommon)
+ *(.sbss2)
+ *(.sbss2.*)
+ *(.gnu.linkonce.sb2.*)
+ *(.dynbss)
+ *(.bss)
+ *(.bss.*)
+ *(.gnu.linkonce.b.*)
+ *(COMMON)
+ *(.sram.pool.bss)
+ *(.sram.bss)
+ . = ALIGN (8);
+ _bss_end = ABSOLUTE(.);
+ _memmap_seg_sram0_end = ALIGN(0x8);
+ } >sram0_seg :sram0_bss_phdr
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ .debug_info 0 : { *(.debug_info) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+ .xt.insn 0 :
+ {
+ KEEP (*(.xt.insn))
+ KEEP (*(.gnu.linkonce.x.*))
+ }
+ .xt.prop 0 :
+ {
+ KEEP (*(.xt.prop))
+ KEEP (*(.xt.prop.*))
+ KEEP (*(.gnu.linkonce.prop.*))
+ }
+ .xt.lit 0 :
+ {
+ KEEP (*(.xt.lit))
+ KEEP (*(.xt.lit.*))
+ KEEP (*(.gnu.linkonce.p.*))
+ }
+ .debug.xt.callgraph 0 :
+ {
+ KEEP (*(.debug.xt.callgraph .debug.xt.callgraph.* .gnu.linkonce.xt.callgraph.*))
+ }
+}
+
diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xbn b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xbn
new file mode 100644
index 00000000..e226d641
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xbn
@@ -0,0 +1,827 @@
+/* This linker script generated from xt-genldscripts.tpp for LSP hifi_hikey_lsp */
+/* Linker Script for ld -N */
+MEMORY
+{
+ sram0_seg : org = 0xC0000000, len = 0x408000
+ old_vlpd_seg : org = 0xC0408000, len = 0x10000
+ efr_fr_hr_vlpd_seg : org = 0xC0418000, len = 0x10000
+ amr_vlpd_seg : org = 0xC0428000, len = 0x10000
+ amrwb_vlpd_seg : org = 0xC0438000, len = 0x10000
+ evrc_evrcb_vlpt_seg : org = 0xC0448000, len = 0x48000
+ efr_fr_hr_vlpt_seg : org = 0xC0490000, len = 0x30000
+ amr_vlpt_seg : org = 0xC04C0000, len = 0x20000
+ amrwb_vlpt_seg : org = 0xC04E0000, len = 0x30000
+ vlpt_seg : org = 0xC0510000, len = 0x48000
+ vlpd_seg : org = 0xC0558000, len = 0x20000
+ ulpp_seg : org = 0xC0578000, len = 0x40000
+ dtsv3_seg : org = 0xC05B8000, len = 0x20000
+ dtsv4_seg : org = 0xC05D8000, len = 0x28000
+ dram0_0_seg : org = 0xE8058000, len = 0x28000
+ iram0_0_seg : org = 0xE8080000, len = 0x300
+ iram0_1_seg : org = 0xE8080300, len = 0x100
+ iram0_2_seg : org = 0xE8080400, len = 0x178
+ iram0_3_seg : org = 0xE8080578, len = 0x8
+ iram0_4_seg : org = 0xE8080580, len = 0x38
+ iram0_5_seg : org = 0xE80805B8, len = 0x8
+ iram0_6_seg : org = 0xE80805C0, len = 0x38
+ iram0_7_seg : org = 0xE80805F8, len = 0x8
+ iram0_8_seg : org = 0xE8080600, len = 0x38
+ iram0_9_seg : org = 0xE8080638, len = 0x8
+ iram0_10_seg : org = 0xE8080640, len = 0x38
+ iram0_11_seg : org = 0xE8080678, len = 0x48
+ iram0_12_seg : org = 0xE80806C0, len = 0x38
+ iram0_13_seg : org = 0xE80806F8, len = 0x8
+ iram0_14_seg : org = 0xE8080700, len = 0x38
+ iram0_15_seg : org = 0xE8080738, len = 0x8
+ iram0_16_seg : org = 0xE8080740, len = 0x38
+ iram0_17_seg : org = 0xE8080778, len = 0x48
+ iram0_18_seg : org = 0xE80807C0, len = 0x40
+ iram0_19_seg : org = 0xE8080800, len = 0xB800
+}
+
+PHDRS
+{
+ sram0_phdr PT_LOAD;
+ sram0_bss_phdr PT_LOAD;
+ old_vlpd_phdr PT_LOAD;
+ old_vlpd_bss_phdr PT_LOAD;
+ efr_fr_hr_vlpd_phdr PT_LOAD;
+ efr_fr_hr_vlpd_bss_phdr PT_LOAD;
+ amr_vlpd_phdr PT_LOAD;
+ amr_vlpd_bss_phdr PT_LOAD;
+ amrwb_vlpd_phdr PT_LOAD;
+ amrwb_vlpd_bss_phdr PT_LOAD;
+ evrc_evrcb_vlpt_phdr PT_LOAD;
+ efr_fr_hr_vlpt_phdr PT_LOAD;
+ amr_vlpt_phdr PT_LOAD;
+ amrwb_vlpt_phdr PT_LOAD;
+ vlpt_phdr PT_LOAD;
+ vlpd_phdr PT_LOAD;
+ ulpp_phdr PT_LOAD;
+ ulpp_bss_phdr PT_LOAD;
+ dtsv3_phdr PT_LOAD;
+ dtsv3_bss_phdr PT_LOAD;
+ dtsv4_phdr PT_LOAD;
+ dtsv4_bss_phdr PT_LOAD;
+ dram0_0_phdr PT_LOAD;
+ dram0_0_bss_phdr PT_LOAD;
+ iram0_0_phdr PT_LOAD;
+ iram0_1_phdr PT_LOAD;
+ iram0_2_phdr PT_LOAD;
+ iram0_3_phdr PT_LOAD;
+ iram0_4_phdr PT_LOAD;
+ iram0_5_phdr PT_LOAD;
+ iram0_6_phdr PT_LOAD;
+ iram0_7_phdr PT_LOAD;
+ iram0_8_phdr PT_LOAD;
+ iram0_9_phdr PT_LOAD;
+ iram0_10_phdr PT_LOAD;
+ iram0_11_phdr PT_LOAD;
+ iram0_12_phdr PT_LOAD;
+ iram0_13_phdr PT_LOAD;
+ iram0_14_phdr PT_LOAD;
+ iram0_15_phdr PT_LOAD;
+ iram0_16_phdr PT_LOAD;
+ iram0_17_phdr PT_LOAD;
+ iram0_18_phdr PT_LOAD;
+ iram0_19_phdr PT_LOAD;
+}
+
+
+/* Default entry point: */
+ENTRY(_ResetVector)
+
+/* Memory boundary addresses: */
+_memmap_mem_iram0_start = 0xe8080000;
+_memmap_mem_iram0_end = 0xe808c000;
+_memmap_mem_dram0_start = 0xe8058000;
+_memmap_mem_dram0_end = 0xe8080000;
+_memmap_mem_sram_start = 0xc0000000;
+_memmap_mem_sram_end = 0xc0600000;
+
+/* Memory segment boundary addresses: */
+_memmap_seg_sram0_start = 0xc0000000;
+_memmap_seg_sram0_max = 0xc0408000;
+_memmap_seg_old_vlpd_start = 0xc0408000;
+_memmap_seg_old_vlpd_max = 0xc0418000;
+_memmap_seg_efr_fr_hr_vlpd_start = 0xc0418000;
+_memmap_seg_efr_fr_hr_vlpd_max = 0xc0428000;
+_memmap_seg_amr_vlpd_start = 0xc0428000;
+_memmap_seg_amr_vlpd_max = 0xc0438000;
+_memmap_seg_amrwb_vlpd_start = 0xc0438000;
+_memmap_seg_amrwb_vlpd_max = 0xc0448000;
+_memmap_seg_evrc_evrcb_vlpt_start = 0xc0448000;
+_memmap_seg_evrc_evrcb_vlpt_max = 0xc0490000;
+_memmap_seg_efr_fr_hr_vlpt_start = 0xc0490000;
+_memmap_seg_efr_fr_hr_vlpt_max = 0xc04c0000;
+_memmap_seg_amr_vlpt_start = 0xc04c0000;
+_memmap_seg_amr_vlpt_max = 0xc04e0000;
+_memmap_seg_amrwb_vlpt_start = 0xc04e0000;
+_memmap_seg_amrwb_vlpt_max = 0xc0510000;
+_memmap_seg_vlpt_start = 0xc0510000;
+_memmap_seg_vlpt_max = 0xc0558000;
+_memmap_seg_vlpd_start = 0xc0558000;
+_memmap_seg_vlpd_max = 0xc0578000;
+_memmap_seg_ulpp_start = 0xc0578000;
+_memmap_seg_ulpp_max = 0xc05b8000;
+_memmap_seg_dtsv3_start = 0xc05b8000;
+_memmap_seg_dtsv3_max = 0xc05d8000;
+_memmap_seg_dtsv4_start = 0xc05d8000;
+_memmap_seg_dtsv4_max = 0xc0600000;
+_memmap_seg_dram0_0_start = 0xe8058000;
+_memmap_seg_dram0_0_max = 0xe8080000;
+_memmap_seg_iram0_0_start = 0xe8080000;
+_memmap_seg_iram0_0_max = 0xe8080300;
+_memmap_seg_iram0_1_start = 0xe8080300;
+_memmap_seg_iram0_1_max = 0xe8080400;
+_memmap_seg_iram0_2_start = 0xe8080400;
+_memmap_seg_iram0_2_max = 0xe8080578;
+_memmap_seg_iram0_3_start = 0xe8080578;
+_memmap_seg_iram0_3_max = 0xe8080580;
+_memmap_seg_iram0_4_start = 0xe8080580;
+_memmap_seg_iram0_4_max = 0xe80805b8;
+_memmap_seg_iram0_5_start = 0xe80805b8;
+_memmap_seg_iram0_5_max = 0xe80805c0;
+_memmap_seg_iram0_6_start = 0xe80805c0;
+_memmap_seg_iram0_6_max = 0xe80805f8;
+_memmap_seg_iram0_7_start = 0xe80805f8;
+_memmap_seg_iram0_7_max = 0xe8080600;
+_memmap_seg_iram0_8_start = 0xe8080600;
+_memmap_seg_iram0_8_max = 0xe8080638;
+_memmap_seg_iram0_9_start = 0xe8080638;
+_memmap_seg_iram0_9_max = 0xe8080640;
+_memmap_seg_iram0_10_start = 0xe8080640;
+_memmap_seg_iram0_10_max = 0xe8080678;
+_memmap_seg_iram0_11_start = 0xe8080678;
+_memmap_seg_iram0_11_max = 0xe80806c0;
+_memmap_seg_iram0_12_start = 0xe80806c0;
+_memmap_seg_iram0_12_max = 0xe80806f8;
+_memmap_seg_iram0_13_start = 0xe80806f8;
+_memmap_seg_iram0_13_max = 0xe8080700;
+_memmap_seg_iram0_14_start = 0xe8080700;
+_memmap_seg_iram0_14_max = 0xe8080738;
+_memmap_seg_iram0_15_start = 0xe8080738;
+_memmap_seg_iram0_15_max = 0xe8080740;
+_memmap_seg_iram0_16_start = 0xe8080740;
+_memmap_seg_iram0_16_max = 0xe8080778;
+_memmap_seg_iram0_17_start = 0xe8080778;
+_memmap_seg_iram0_17_max = 0xe80807c0;
+_memmap_seg_iram0_18_start = 0xe80807c0;
+_memmap_seg_iram0_18_max = 0xe8080800;
+_memmap_seg_iram0_19_start = 0xe8080800;
+_memmap_seg_iram0_19_max = 0xe808c000;
+
+_rom_store_table = 0;
+PROVIDE(_memmap_vecbase_reset = 0xe8080400);
+PROVIDE(_memmap_reset_vector = 0xe8080000);
+/* Various memory-map dependent cache attribute settings: */
+_memmap_cacheattr_wb_base = 0x44000000;
+_memmap_cacheattr_wt_base = 0x11000000;
+_memmap_cacheattr_bp_base = 0x22000000;
+_memmap_cacheattr_unused_mask = 0x00FFFFFF;
+_memmap_cacheattr_wb_trapnull = 0x4422222F;
+_memmap_cacheattr_wba_trapnull = 0x4422222F;
+_memmap_cacheattr_wbna_trapnull = 0x5522222F;
+_memmap_cacheattr_wt_trapnull = 0x1122222F;
+_memmap_cacheattr_bp_trapnull = 0x2222222F;
+_memmap_cacheattr_wb_strict = 0x44FFFFFF;
+_memmap_cacheattr_wt_strict = 0x11FFFFFF;
+_memmap_cacheattr_bp_strict = 0x22FFFFFF;
+_memmap_cacheattr_wb_allvalid = 0x44222222;
+_memmap_cacheattr_wt_allvalid = 0x11222222;
+_memmap_cacheattr_bp_allvalid = 0x22222222;
+PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull);
+
+SECTIONS
+{
+
+ .vlpd.rodata : ALIGN(4)
+ {
+ _vlpd_rodata_start = ABSOLUTE(.);
+ *(.vlpd.rodata)
+ _vlpd_rodata_end = ABSOLUTE(.);
+ } >old_vlpd_seg :old_vlpd_phdr
+
+ .vlpd.data : ALIGN(4)
+ {
+ _vlpd_data_start = ABSOLUTE(.);
+ *(.vlpd.data)
+ _vlpd_data_end = ABSOLUTE(.);
+ } >old_vlpd_seg :old_vlpd_phdr
+
+ .vlpd.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _vlpd_bss_start = ABSOLUTE(.);
+ *(.vlpd.bss)
+ . = ALIGN (8);
+ _vlpd_bss_end = ABSOLUTE(.);
+ _memmap_seg_old_vlpd_end = ALIGN(0x8);
+ } >old_vlpd_seg :old_vlpd_bss_phdr
+
+ .efr_fr_hr_vlpd.rodata : ALIGN(4)
+ {
+ _efr_fr_hr_vlpd_rodata_start = ABSOLUTE(.);
+ *(.efr_fr_hr_vlpd.rodata)
+ _efr_fr_hr_vlpd_rodata_end = ABSOLUTE(.);
+ } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_phdr
+
+ .efr_fr_hr_vlpd.data : ALIGN(4)
+ {
+ _efr_fr_hr_vlpd_data_start = ABSOLUTE(.);
+ *(.efr_fr_hr_vlpd.data)
+ _efr_fr_hr_vlpd_data_end = ABSOLUTE(.);
+ } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_phdr
+
+ .efr_fr_hr_vlpd.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _efr_fr_hr_vlpd_bss_start = ABSOLUTE(.);
+ *(.efr_fr_hr_vlpd.bss)
+ . = ALIGN (8);
+ _efr_fr_hr_vlpd_bss_end = ABSOLUTE(.);
+ _memmap_seg_efr_fr_hr_vlpd_end = ALIGN(0x8);
+ } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_bss_phdr
+
+ .amr_vlpd.rodata : ALIGN(4)
+ {
+ _amr_vlpd_rodata_start = ABSOLUTE(.);
+ *(.amr_vlpd.rodata)
+ _amr_vlpd_rodata_end = ABSOLUTE(.);
+ } >amr_vlpd_seg :amr_vlpd_phdr
+
+ .amr_vlpd.data : ALIGN(4)
+ {
+ _amr_vlpd_data_start = ABSOLUTE(.);
+ *(.amr_vlpd.data)
+ _amr_vlpd_data_end = ABSOLUTE(.);
+ } >amr_vlpd_seg :amr_vlpd_phdr
+
+ .amr_vlpd.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _amr_vlpd_bss_start = ABSOLUTE(.);
+ *(.amr_vlpd.bss)
+ . = ALIGN (8);
+ _amr_vlpd_bss_end = ABSOLUTE(.);
+ _memmap_seg_amr_vlpd_end = ALIGN(0x8);
+ } >amr_vlpd_seg :amr_vlpd_bss_phdr
+
+ .amrwb_vlpd.rodata : ALIGN(4)
+ {
+ _amrwb_vlpd_rodata_start = ABSOLUTE(.);
+ *(.amrwb_vlpd.rodata)
+ _amrwb_vlpd_rodata_end = ABSOLUTE(.);
+ } >amrwb_vlpd_seg :amrwb_vlpd_phdr
+
+ .amrwb_vlpd.data : ALIGN(4)
+ {
+ _amrwb_vlpd_data_start = ABSOLUTE(.);
+ *(.amrwb_vlpd.data)
+ _amrwb_vlpd_data_end = ABSOLUTE(.);
+ } >amrwb_vlpd_seg :amrwb_vlpd_phdr
+
+ .amrwb_vlpd.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _amrwb_vlpd_bss_start = ABSOLUTE(.);
+ *(.amrwb_vlpd.bss)
+ . = ALIGN (8);
+ _amrwb_vlpd_bss_end = ABSOLUTE(.);
+ _memmap_seg_amrwb_vlpd_end = ALIGN(0x8);
+ } >amrwb_vlpd_seg :amrwb_vlpd_bss_phdr
+
+ .evrc_evrcb_vlpt.text : ALIGN(4)
+ {
+ _evrc_evrcb_vlpt_text_start = ABSOLUTE(.);
+ *(.evrc_evrcb_vlpt.literal .evrc_evrcb_vlpt.text)
+ _evrc_evrcb_vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_evrc_evrcb_vlpt_end = ALIGN(0x8);
+ } >evrc_evrcb_vlpt_seg :evrc_evrcb_vlpt_phdr
+
+ .efr_fr_hr_vlpt.text : ALIGN(4)
+ {
+ _efr_fr_hr_vlpt_text_start = ABSOLUTE(.);
+ *(.efr_fr_hr_vlpt.literal .efr_fr_hr_vlpt.text)
+ _efr_fr_hr_vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_efr_fr_hr_vlpt_end = ALIGN(0x8);
+ } >efr_fr_hr_vlpt_seg :efr_fr_hr_vlpt_phdr
+
+ .amr_vlpt.text : ALIGN(4)
+ {
+ _amr_vlpt_text_start = ABSOLUTE(.);
+ *(.amr_vlpt.literal .amr_vlpt.text)
+ _amr_vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_amr_vlpt_end = ALIGN(0x8);
+ } >amr_vlpt_seg :amr_vlpt_phdr
+
+ .amrwb_vlpt.text : ALIGN(4)
+ {
+ _amrwb_vlpt_text_start = ABSOLUTE(.);
+ *(.amrwb_vlpt.literal .amrwb_vlpt.text)
+ _amrwb_vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_amrwb_vlpt_end = ALIGN(0x8);
+ } >amrwb_vlpt_seg :amrwb_vlpt_phdr
+
+ .vlpt.text : ALIGN(4)
+ {
+ _vlpt_text_start = ABSOLUTE(.);
+ *(.vlpt.literal .vlpt.text)
+ _vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_vlpt_end = ALIGN(0x8);
+ } >vlpt_seg :vlpt_phdr
+
+ .low_power_dyn_alloc : ALIGN(4)
+ {
+ _low_power_dyn_alloc_start = ABSOLUTE(.);
+ *(.low_power_dyn_alloc)
+ _low_power_dyn_alloc_end = ABSOLUTE(.);
+ _memmap_seg_vlpd_end = ALIGN(0x8);
+ } >vlpd_seg :vlpd_phdr
+
+ .ulpp.rodata : ALIGN(4)
+ {
+ _ulpp_rodata_start = ABSOLUTE(.);
+ *(.ulpp.rodata)
+ _ulpp_rodata_end = ABSOLUTE(.);
+ } >ulpp_seg :ulpp_phdr
+
+ .ulpp.data : ALIGN(4)
+ {
+ _ulpp_data_start = ABSOLUTE(.);
+ *(.ulpp.data)
+ _ulpp_data_end = ABSOLUTE(.);
+ } >ulpp_seg :ulpp_phdr
+
+ .ulpp.text : ALIGN(4)
+ {
+ _ulpp_text_start = ABSOLUTE(.);
+ *(.ulpp.literal .ulpp.text)
+ _ulpp_text_end = ABSOLUTE(.);
+ } >ulpp_seg :ulpp_phdr
+
+ .ulpp.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _ulpp_bss_start = ABSOLUTE(.);
+ *(.ulpp.bss)
+ . = ALIGN (8);
+ _ulpp_bss_end = ABSOLUTE(.);
+ _memmap_seg_ulpp_end = ALIGN(0x8);
+ } >ulpp_seg :ulpp_bss_phdr
+
+ .dtsv3.rodata : ALIGN(4)
+ {
+ _dtsv3_rodata_start = ABSOLUTE(.);
+ *(.dtsv3.rodata)
+ _dtsv3_rodata_end = ABSOLUTE(.);
+ } >dtsv3_seg :dtsv3_phdr
+
+ .dtsv3.data : ALIGN(4)
+ {
+ _dtsv3_data_start = ABSOLUTE(.);
+ *(.dtsv3.data)
+ _dtsv3_data_end = ABSOLUTE(.);
+ } >dtsv3_seg :dtsv3_phdr
+
+ .dtsv3.text : ALIGN(4)
+ {
+ _dtsv3_text_start = ABSOLUTE(.);
+ *(.dtsv3.literal .dtsv3.text)
+ _dtsv3_text_end = ABSOLUTE(.);
+ } >dtsv3_seg :dtsv3_phdr
+
+ .dtsv3.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _dtsv3_bss_start = ABSOLUTE(.);
+ *(.dtsv3.bss)
+ . = ALIGN (8);
+ _dtsv3_bss_end = ABSOLUTE(.);
+ _memmap_seg_dtsv3_end = ALIGN(0x8);
+ } >dtsv3_seg :dtsv3_bss_phdr
+
+ .dtsv4.rodata : ALIGN(4)
+ {
+ _dtsv4_rodata_start = ABSOLUTE(.);
+ *(.dtsv4.rodata)
+ _dtsv4_rodata_end = ABSOLUTE(.);
+ } >dtsv4_seg :dtsv4_phdr
+
+ .dtsv4.data : ALIGN(4)
+ {
+ _dtsv4_data_start = ABSOLUTE(.);
+ *(.dtsv4.data)
+ _dtsv4_data_end = ABSOLUTE(.);
+ } >dtsv4_seg :dtsv4_phdr
+
+ .dtsv4.text : ALIGN(4)
+ {
+ _dtsv4_text_start = ABSOLUTE(.);
+ *(.dtsv4.literal .dtsv4.text)
+ _dtsv4_text_end = ABSOLUTE(.);
+ } >dtsv4_seg :dtsv4_phdr
+
+ .dtsv4.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _dtsv4_bss_start = ABSOLUTE(.);
+ *(.dtsv4.bss)
+ . = ALIGN (8);
+ _dtsv4_bss_end = ABSOLUTE(.);
+ _memmap_seg_dtsv4_end = ALIGN(0x8);
+ } >dtsv4_seg :dtsv4_bss_phdr
+
+ .dram0.rodata : ALIGN(4)
+ {
+ _dram0_rodata_start = ABSOLUTE(.);
+ *(.dram0.rodata)
+ *(.dram.rodata)
+ _dram0_rodata_end = ABSOLUTE(.);
+ } >dram0_0_seg :dram0_0_phdr
+
+ .dram0.literal : ALIGN(4)
+ {
+ _dram0_literal_start = ABSOLUTE(.);
+ *(.dram0.literal)
+ *(.dram.literal)
+ _dram0_literal_end = ABSOLUTE(.);
+ } >dram0_0_seg :dram0_0_phdr
+
+ .dram0.data : ALIGN(4)
+ {
+ _dram0_data_start = ABSOLUTE(.);
+ *(.dram0.data)
+ *(.dram.data)
+ _dram0_data_end = ABSOLUTE(.);
+ } >dram0_0_seg :dram0_0_phdr
+
+ .dram0.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _dram0_bss_start = ABSOLUTE(.);
+ *(.dram0.bss)
+ *(.om.debug.bss)
+ *(.os.stack.bss)
+ . = ALIGN (8);
+ _dram0_bss_end = ABSOLUTE(.);
+ _end = ALIGN(0x8);
+ PROVIDE(end = ALIGN(0x8));
+ _stack_sentry = ALIGN(0x8);
+ _memmap_seg_dram0_0_end = ALIGN(0x8);
+ } >dram0_0_seg :dram0_0_bss_phdr
+ __stack = 0xe8080000;
+ _heap_sentry = 0xe8080000;
+
+ .ResetVector.text : ALIGN(4)
+ {
+ _ResetVector_text_start = ABSOLUTE(.);
+ KEEP (*(.ResetVector.text))
+ _ResetVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_0_end = ALIGN(0x8);
+ } >iram0_0_seg :iram0_0_phdr
+
+ .Reset.literal : ALIGN(4)
+ {
+ _Reset_literal_start = ABSOLUTE(.);
+ *(.Reset.literal)
+ _Reset_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_1_end = ALIGN(0x8);
+ } >iram0_1_seg :iram0_1_phdr
+
+ .WindowVectors.text : ALIGN(4)
+ {
+ _WindowVectors_text_start = ABSOLUTE(.);
+ KEEP (*(.WindowVectors.text))
+ _WindowVectors_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_2_end = ALIGN(0x8);
+ } >iram0_2_seg :iram0_2_phdr
+
+ .Level2InterruptVector.literal : ALIGN(4)
+ {
+ _Level2InterruptVector_literal_start = ABSOLUTE(.);
+ *(.Level2InterruptVector.literal)
+ _Level2InterruptVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_3_end = ALIGN(0x8);
+ } >iram0_3_seg :iram0_3_phdr
+
+ .Level2InterruptVector.text : ALIGN(4)
+ {
+ _Level2InterruptVector_text_start = ABSOLUTE(.);
+ KEEP (*(.Level2InterruptVector.text))
+ _Level2InterruptVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_4_end = ALIGN(0x8);
+ } >iram0_4_seg :iram0_4_phdr
+
+ .Level3InterruptVector.literal : ALIGN(4)
+ {
+ _Level3InterruptVector_literal_start = ABSOLUTE(.);
+ *(.Level3InterruptVector.literal)
+ _Level3InterruptVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_5_end = ALIGN(0x8);
+ } >iram0_5_seg :iram0_5_phdr
+
+ .Level3InterruptVector.text : ALIGN(4)
+ {
+ _Level3InterruptVector_text_start = ABSOLUTE(.);
+ KEEP (*(.Level3InterruptVector.text))
+ _Level3InterruptVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_6_end = ALIGN(0x8);
+ } >iram0_6_seg :iram0_6_phdr
+
+ .Level4InterruptVector.literal : ALIGN(4)
+ {
+ _Level4InterruptVector_literal_start = ABSOLUTE(.);
+ *(.Level4InterruptVector.literal)
+ _Level4InterruptVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_7_end = ALIGN(0x8);
+ } >iram0_7_seg :iram0_7_phdr
+
+ .Level4InterruptVector.text : ALIGN(4)
+ {
+ _Level4InterruptVector_text_start = ABSOLUTE(.);
+ KEEP (*(.Level4InterruptVector.text))
+ _Level4InterruptVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_8_end = ALIGN(0x8);
+ } >iram0_8_seg :iram0_8_phdr
+
+ .DebugExceptionVector.literal : ALIGN(4)
+ {
+ _DebugExceptionVector_literal_start = ABSOLUTE(.);
+ *(.DebugExceptionVector.literal)
+ _DebugExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_9_end = ALIGN(0x8);
+ } >iram0_9_seg :iram0_9_phdr
+
+ .DebugExceptionVector.text : ALIGN(4)
+ {
+ _DebugExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.DebugExceptionVector.text))
+ _DebugExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_10_end = ALIGN(0x8);
+ } >iram0_10_seg :iram0_10_phdr
+
+ .NMIExceptionVector.literal : ALIGN(4)
+ {
+ _NMIExceptionVector_literal_start = ABSOLUTE(.);
+ *(.NMIExceptionVector.literal)
+ _NMIExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_11_end = ALIGN(0x8);
+ } >iram0_11_seg :iram0_11_phdr
+
+ .NMIExceptionVector.text : ALIGN(4)
+ {
+ _NMIExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.NMIExceptionVector.text))
+ _NMIExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_12_end = ALIGN(0x8);
+ } >iram0_12_seg :iram0_12_phdr
+
+ .KernelExceptionVector.literal : ALIGN(4)
+ {
+ _KernelExceptionVector_literal_start = ABSOLUTE(.);
+ *(.KernelExceptionVector.literal)
+ _KernelExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_13_end = ALIGN(0x8);
+ } >iram0_13_seg :iram0_13_phdr
+
+ .KernelExceptionVector.text : ALIGN(4)
+ {
+ _KernelExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.KernelExceptionVector.text))
+ _KernelExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_14_end = ALIGN(0x8);
+ } >iram0_14_seg :iram0_14_phdr
+
+ .UserExceptionVector.literal : ALIGN(4)
+ {
+ _UserExceptionVector_literal_start = ABSOLUTE(.);
+ *(.UserExceptionVector.literal)
+ _UserExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_15_end = ALIGN(0x8);
+ } >iram0_15_seg :iram0_15_phdr
+
+ .UserExceptionVector.text : ALIGN(4)
+ {
+ _UserExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.UserExceptionVector.text))
+ _UserExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_16_end = ALIGN(0x8);
+ } >iram0_16_seg :iram0_16_phdr
+
+ .DoubleExceptionVector.literal : ALIGN(4)
+ {
+ _DoubleExceptionVector_literal_start = ABSOLUTE(.);
+ *(.DoubleExceptionVector.literal)
+ _DoubleExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_17_end = ALIGN(0x8);
+ } >iram0_17_seg :iram0_17_phdr
+
+ .DoubleExceptionVector.text : ALIGN(4)
+ {
+ _DoubleExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.DoubleExceptionVector.text))
+ _DoubleExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_18_end = ALIGN(0x8);
+ } >iram0_18_seg :iram0_18_phdr
+
+ .Reset.text : ALIGN(4)
+ {
+ _Reset_text_start = ABSOLUTE(.);
+ *(.Reset.text)
+ _Reset_text_end = ABSOLUTE(.);
+ } >iram0_19_seg :iram0_19_phdr
+
+ .iram0.text : ALIGN(4)
+ {
+ _iram0_text_start = ABSOLUTE(.);
+ *(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text)
+ _iram0_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_19_end = ALIGN(0x8);
+ } >iram0_19_seg :iram0_19_phdr
+
+ .sram.shareaddr : ALIGN(4)
+ {
+ _sram_shareaddr_start = ABSOLUTE(.);
+ *(.sram.shareaddr)
+ _sram_shareaddr_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .sram.rodata : ALIGN(4)
+ {
+ _sram_rodata_start = ABSOLUTE(.);
+ *(.sram.rodata)
+ _sram_rodata_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .rodata : ALIGN(4)
+ {
+ _rodata_start = ABSOLUTE(.);
+ *(.rodata)
+ *(.rodata.*)
+ *(.gnu.linkonce.r.*)
+ *(.rodata1)
+ __XT_EXCEPTION_TABLE__ = ABSOLUTE(.);
+ KEEP (*(.xt_except_table))
+ KEEP (*(.gcc_except_table))
+ *(.gnu.linkonce.e.*)
+ *(.gnu.version_r)
+ KEEP (*(.eh_frame))
+ /* C++ constructor and destructor tables, properly ordered: */
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ /* C++ exception handlers table: */
+ __XT_EXCEPTION_DESCS__ = ABSOLUTE(.);
+ *(.xt_except_desc)
+ *(.gnu.linkonce.h.*)
+ __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
+ *(.xt_except_desc_end)
+ *(.dynamic)
+ *(.gnu.version_d)
+ . = ALIGN(4); /* this table MUST be 4-byte aligned */
+ _bss_table_start = ABSOLUTE(.);
+ LONG(_vlpd_bss_start)
+ LONG(_vlpd_bss_end)
+ LONG(_efr_fr_hr_vlpd_bss_start)
+ LONG(_efr_fr_hr_vlpd_bss_end)
+ LONG(_amr_vlpd_bss_start)
+ LONG(_amr_vlpd_bss_end)
+ LONG(_amrwb_vlpd_bss_start)
+ LONG(_amrwb_vlpd_bss_end)
+ LONG(_ulpp_bss_start)
+ LONG(_ulpp_bss_end)
+ LONG(_dtsv3_bss_start)
+ LONG(_dtsv3_bss_end)
+ LONG(_dtsv4_bss_start)
+ LONG(_dtsv4_bss_end)
+ LONG(_dram0_bss_start)
+ LONG(_dram0_bss_end)
+ LONG(_bss_start)
+ LONG(_bss_end)
+ _bss_table_end = ABSOLUTE(.);
+ _rodata_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .sram.text : ALIGN(4)
+ {
+ _sram_text_start = ABSOLUTE(.);
+ *(.sram.literal .sram.text)
+ _sram_text_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .text : ALIGN(4)
+ {
+ _stext = .;
+ _text_start = ABSOLUTE(.);
+ *(.entry.text)
+ *(.init.literal)
+ KEEP(*(.init))
+ *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
+ *(.fini.literal)
+ KEEP(*(.fini))
+ *(.gnu.version)
+ _text_end = ABSOLUTE(.);
+ _etext = .;
+ } >sram0_seg :sram0_phdr
+
+ .sram.data : ALIGN(4)
+ {
+ _sram_data_start = ABSOLUTE(.);
+ *(.sram.data)
+ _sram_data_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .data : ALIGN(4)
+ {
+ _data_start = ABSOLUTE(.);
+ *(.data)
+ *(.data.*)
+ *(.gnu.linkonce.d.*)
+ KEEP(*(.gnu.linkonce.d.*personality*))
+ *(.data1)
+ *(.sdata)
+ *(.sdata.*)
+ *(.gnu.linkonce.s.*)
+ *(.sdata2)
+ *(.sdata2.*)
+ *(.gnu.linkonce.s2.*)
+ KEEP(*(.jcr))
+ _data_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .sram.uninit : ALIGN(4)
+ {
+ _sram_uninit_start = ABSOLUTE(.);
+ *(.sram.uninit)
+ _sram_uninit_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _bss_start = ABSOLUTE(.);
+ *(.dynsbss)
+ *(.sbss)
+ *(.sbss.*)
+ *(.gnu.linkonce.sb.*)
+ *(.scommon)
+ *(.sbss2)
+ *(.sbss2.*)
+ *(.gnu.linkonce.sb2.*)
+ *(.dynbss)
+ *(.bss)
+ *(.bss.*)
+ *(.gnu.linkonce.b.*)
+ *(COMMON)
+ *(.sram.pool.bss)
+ *(.sram.bss)
+ . = ALIGN (8);
+ _bss_end = ABSOLUTE(.);
+ _memmap_seg_sram0_end = ALIGN(0x8);
+ } >sram0_seg :sram0_bss_phdr
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ .debug_info 0 : { *(.debug_info) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+ .xt.insn 0 :
+ {
+ KEEP (*(.xt.insn))
+ KEEP (*(.gnu.linkonce.x.*))
+ }
+ .xt.prop 0 :
+ {
+ KEEP (*(.xt.prop))
+ KEEP (*(.xt.prop.*))
+ KEEP (*(.gnu.linkonce.prop.*))
+ }
+ .xt.lit 0 :
+ {
+ KEEP (*(.xt.lit))
+ KEEP (*(.xt.lit.*))
+ KEEP (*(.gnu.linkonce.p.*))
+ }
+ .debug.xt.callgraph 0 :
+ {
+ KEEP (*(.debug.xt.callgraph .debug.xt.callgraph.* .gnu.linkonce.xt.callgraph.*))
+ }
+}
+
diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xn b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xn
new file mode 100644
index 00000000..17c05e16
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xn
@@ -0,0 +1,827 @@
+/* This linker script generated from xt-genldscripts.tpp for LSP hifi_hikey_lsp */
+/* Linker Script for ld -n */
+MEMORY
+{
+ sram0_seg : org = 0xC0000000, len = 0x408000
+ old_vlpd_seg : org = 0xC0408000, len = 0x10000
+ efr_fr_hr_vlpd_seg : org = 0xC0418000, len = 0x10000
+ amr_vlpd_seg : org = 0xC0428000, len = 0x10000
+ amrwb_vlpd_seg : org = 0xC0438000, len = 0x10000
+ evrc_evrcb_vlpt_seg : org = 0xC0448000, len = 0x48000
+ efr_fr_hr_vlpt_seg : org = 0xC0490000, len = 0x30000
+ amr_vlpt_seg : org = 0xC04C0000, len = 0x20000
+ amrwb_vlpt_seg : org = 0xC04E0000, len = 0x30000
+ vlpt_seg : org = 0xC0510000, len = 0x48000
+ vlpd_seg : org = 0xC0558000, len = 0x20000
+ ulpp_seg : org = 0xC0578000, len = 0x40000
+ dtsv3_seg : org = 0xC05B8000, len = 0x20000
+ dtsv4_seg : org = 0xC05D8000, len = 0x28000
+ dram0_0_seg : org = 0xE8058000, len = 0x28000
+ iram0_0_seg : org = 0xE8080000, len = 0x300
+ iram0_1_seg : org = 0xE8080300, len = 0x100
+ iram0_2_seg : org = 0xE8080400, len = 0x178
+ iram0_3_seg : org = 0xE8080578, len = 0x8
+ iram0_4_seg : org = 0xE8080580, len = 0x38
+ iram0_5_seg : org = 0xE80805B8, len = 0x8
+ iram0_6_seg : org = 0xE80805C0, len = 0x38
+ iram0_7_seg : org = 0xE80805F8, len = 0x8
+ iram0_8_seg : org = 0xE8080600, len = 0x38
+ iram0_9_seg : org = 0xE8080638, len = 0x8
+ iram0_10_seg : org = 0xE8080640, len = 0x38
+ iram0_11_seg : org = 0xE8080678, len = 0x48
+ iram0_12_seg : org = 0xE80806C0, len = 0x38
+ iram0_13_seg : org = 0xE80806F8, len = 0x8
+ iram0_14_seg : org = 0xE8080700, len = 0x38
+ iram0_15_seg : org = 0xE8080738, len = 0x8
+ iram0_16_seg : org = 0xE8080740, len = 0x38
+ iram0_17_seg : org = 0xE8080778, len = 0x48
+ iram0_18_seg : org = 0xE80807C0, len = 0x40
+ iram0_19_seg : org = 0xE8080800, len = 0xB800
+}
+
+PHDRS
+{
+ sram0_phdr PT_LOAD;
+ sram0_bss_phdr PT_LOAD;
+ old_vlpd_phdr PT_LOAD;
+ old_vlpd_bss_phdr PT_LOAD;
+ efr_fr_hr_vlpd_phdr PT_LOAD;
+ efr_fr_hr_vlpd_bss_phdr PT_LOAD;
+ amr_vlpd_phdr PT_LOAD;
+ amr_vlpd_bss_phdr PT_LOAD;
+ amrwb_vlpd_phdr PT_LOAD;
+ amrwb_vlpd_bss_phdr PT_LOAD;
+ evrc_evrcb_vlpt_phdr PT_LOAD;
+ efr_fr_hr_vlpt_phdr PT_LOAD;
+ amr_vlpt_phdr PT_LOAD;
+ amrwb_vlpt_phdr PT_LOAD;
+ vlpt_phdr PT_LOAD;
+ vlpd_phdr PT_LOAD;
+ ulpp_phdr PT_LOAD;
+ ulpp_bss_phdr PT_LOAD;
+ dtsv3_phdr PT_LOAD;
+ dtsv3_bss_phdr PT_LOAD;
+ dtsv4_phdr PT_LOAD;
+ dtsv4_bss_phdr PT_LOAD;
+ dram0_0_phdr PT_LOAD;
+ dram0_0_bss_phdr PT_LOAD;
+ iram0_0_phdr PT_LOAD;
+ iram0_1_phdr PT_LOAD;
+ iram0_2_phdr PT_LOAD;
+ iram0_3_phdr PT_LOAD;
+ iram0_4_phdr PT_LOAD;
+ iram0_5_phdr PT_LOAD;
+ iram0_6_phdr PT_LOAD;
+ iram0_7_phdr PT_LOAD;
+ iram0_8_phdr PT_LOAD;
+ iram0_9_phdr PT_LOAD;
+ iram0_10_phdr PT_LOAD;
+ iram0_11_phdr PT_LOAD;
+ iram0_12_phdr PT_LOAD;
+ iram0_13_phdr PT_LOAD;
+ iram0_14_phdr PT_LOAD;
+ iram0_15_phdr PT_LOAD;
+ iram0_16_phdr PT_LOAD;
+ iram0_17_phdr PT_LOAD;
+ iram0_18_phdr PT_LOAD;
+ iram0_19_phdr PT_LOAD;
+}
+
+
+/* Default entry point: */
+ENTRY(_ResetVector)
+
+/* Memory boundary addresses: */
+_memmap_mem_iram0_start = 0xe8080000;
+_memmap_mem_iram0_end = 0xe808c000;
+_memmap_mem_dram0_start = 0xe8058000;
+_memmap_mem_dram0_end = 0xe8080000;
+_memmap_mem_sram_start = 0xc0000000;
+_memmap_mem_sram_end = 0xc0600000;
+
+/* Memory segment boundary addresses: */
+_memmap_seg_sram0_start = 0xc0000000;
+_memmap_seg_sram0_max = 0xc0408000;
+_memmap_seg_old_vlpd_start = 0xc0408000;
+_memmap_seg_old_vlpd_max = 0xc0418000;
+_memmap_seg_efr_fr_hr_vlpd_start = 0xc0418000;
+_memmap_seg_efr_fr_hr_vlpd_max = 0xc0428000;
+_memmap_seg_amr_vlpd_start = 0xc0428000;
+_memmap_seg_amr_vlpd_max = 0xc0438000;
+_memmap_seg_amrwb_vlpd_start = 0xc0438000;
+_memmap_seg_amrwb_vlpd_max = 0xc0448000;
+_memmap_seg_evrc_evrcb_vlpt_start = 0xc0448000;
+_memmap_seg_evrc_evrcb_vlpt_max = 0xc0490000;
+_memmap_seg_efr_fr_hr_vlpt_start = 0xc0490000;
+_memmap_seg_efr_fr_hr_vlpt_max = 0xc04c0000;
+_memmap_seg_amr_vlpt_start = 0xc04c0000;
+_memmap_seg_amr_vlpt_max = 0xc04e0000;
+_memmap_seg_amrwb_vlpt_start = 0xc04e0000;
+_memmap_seg_amrwb_vlpt_max = 0xc0510000;
+_memmap_seg_vlpt_start = 0xc0510000;
+_memmap_seg_vlpt_max = 0xc0558000;
+_memmap_seg_vlpd_start = 0xc0558000;
+_memmap_seg_vlpd_max = 0xc0578000;
+_memmap_seg_ulpp_start = 0xc0578000;
+_memmap_seg_ulpp_max = 0xc05b8000;
+_memmap_seg_dtsv3_start = 0xc05b8000;
+_memmap_seg_dtsv3_max = 0xc05d8000;
+_memmap_seg_dtsv4_start = 0xc05d8000;
+_memmap_seg_dtsv4_max = 0xc0600000;
+_memmap_seg_dram0_0_start = 0xe8058000;
+_memmap_seg_dram0_0_max = 0xe8080000;
+_memmap_seg_iram0_0_start = 0xe8080000;
+_memmap_seg_iram0_0_max = 0xe8080300;
+_memmap_seg_iram0_1_start = 0xe8080300;
+_memmap_seg_iram0_1_max = 0xe8080400;
+_memmap_seg_iram0_2_start = 0xe8080400;
+_memmap_seg_iram0_2_max = 0xe8080578;
+_memmap_seg_iram0_3_start = 0xe8080578;
+_memmap_seg_iram0_3_max = 0xe8080580;
+_memmap_seg_iram0_4_start = 0xe8080580;
+_memmap_seg_iram0_4_max = 0xe80805b8;
+_memmap_seg_iram0_5_start = 0xe80805b8;
+_memmap_seg_iram0_5_max = 0xe80805c0;
+_memmap_seg_iram0_6_start = 0xe80805c0;
+_memmap_seg_iram0_6_max = 0xe80805f8;
+_memmap_seg_iram0_7_start = 0xe80805f8;
+_memmap_seg_iram0_7_max = 0xe8080600;
+_memmap_seg_iram0_8_start = 0xe8080600;
+_memmap_seg_iram0_8_max = 0xe8080638;
+_memmap_seg_iram0_9_start = 0xe8080638;
+_memmap_seg_iram0_9_max = 0xe8080640;
+_memmap_seg_iram0_10_start = 0xe8080640;
+_memmap_seg_iram0_10_max = 0xe8080678;
+_memmap_seg_iram0_11_start = 0xe8080678;
+_memmap_seg_iram0_11_max = 0xe80806c0;
+_memmap_seg_iram0_12_start = 0xe80806c0;
+_memmap_seg_iram0_12_max = 0xe80806f8;
+_memmap_seg_iram0_13_start = 0xe80806f8;
+_memmap_seg_iram0_13_max = 0xe8080700;
+_memmap_seg_iram0_14_start = 0xe8080700;
+_memmap_seg_iram0_14_max = 0xe8080738;
+_memmap_seg_iram0_15_start = 0xe8080738;
+_memmap_seg_iram0_15_max = 0xe8080740;
+_memmap_seg_iram0_16_start = 0xe8080740;
+_memmap_seg_iram0_16_max = 0xe8080778;
+_memmap_seg_iram0_17_start = 0xe8080778;
+_memmap_seg_iram0_17_max = 0xe80807c0;
+_memmap_seg_iram0_18_start = 0xe80807c0;
+_memmap_seg_iram0_18_max = 0xe8080800;
+_memmap_seg_iram0_19_start = 0xe8080800;
+_memmap_seg_iram0_19_max = 0xe808c000;
+
+_rom_store_table = 0;
+PROVIDE(_memmap_vecbase_reset = 0xe8080400);
+PROVIDE(_memmap_reset_vector = 0xe8080000);
+/* Various memory-map dependent cache attribute settings: */
+_memmap_cacheattr_wb_base = 0x44000000;
+_memmap_cacheattr_wt_base = 0x11000000;
+_memmap_cacheattr_bp_base = 0x22000000;
+_memmap_cacheattr_unused_mask = 0x00FFFFFF;
+_memmap_cacheattr_wb_trapnull = 0x4422222F;
+_memmap_cacheattr_wba_trapnull = 0x4422222F;
+_memmap_cacheattr_wbna_trapnull = 0x5522222F;
+_memmap_cacheattr_wt_trapnull = 0x1122222F;
+_memmap_cacheattr_bp_trapnull = 0x2222222F;
+_memmap_cacheattr_wb_strict = 0x44FFFFFF;
+_memmap_cacheattr_wt_strict = 0x11FFFFFF;
+_memmap_cacheattr_bp_strict = 0x22FFFFFF;
+_memmap_cacheattr_wb_allvalid = 0x44222222;
+_memmap_cacheattr_wt_allvalid = 0x11222222;
+_memmap_cacheattr_bp_allvalid = 0x22222222;
+PROVIDE(_memmap_cacheattr_reset = _memmap_cacheattr_wb_trapnull);
+
+SECTIONS
+{
+
+ .vlpd.rodata : ALIGN(4)
+ {
+ _vlpd_rodata_start = ABSOLUTE(.);
+ *(.vlpd.rodata)
+ _vlpd_rodata_end = ABSOLUTE(.);
+ } >old_vlpd_seg :old_vlpd_phdr
+
+ .vlpd.data : ALIGN(4)
+ {
+ _vlpd_data_start = ABSOLUTE(.);
+ *(.vlpd.data)
+ _vlpd_data_end = ABSOLUTE(.);
+ } >old_vlpd_seg :old_vlpd_phdr
+
+ .vlpd.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _vlpd_bss_start = ABSOLUTE(.);
+ *(.vlpd.bss)
+ . = ALIGN (8);
+ _vlpd_bss_end = ABSOLUTE(.);
+ _memmap_seg_old_vlpd_end = ALIGN(0x8);
+ } >old_vlpd_seg :old_vlpd_bss_phdr
+
+ .efr_fr_hr_vlpd.rodata : ALIGN(4)
+ {
+ _efr_fr_hr_vlpd_rodata_start = ABSOLUTE(.);
+ *(.efr_fr_hr_vlpd.rodata)
+ _efr_fr_hr_vlpd_rodata_end = ABSOLUTE(.);
+ } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_phdr
+
+ .efr_fr_hr_vlpd.data : ALIGN(4)
+ {
+ _efr_fr_hr_vlpd_data_start = ABSOLUTE(.);
+ *(.efr_fr_hr_vlpd.data)
+ _efr_fr_hr_vlpd_data_end = ABSOLUTE(.);
+ } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_phdr
+
+ .efr_fr_hr_vlpd.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _efr_fr_hr_vlpd_bss_start = ABSOLUTE(.);
+ *(.efr_fr_hr_vlpd.bss)
+ . = ALIGN (8);
+ _efr_fr_hr_vlpd_bss_end = ABSOLUTE(.);
+ _memmap_seg_efr_fr_hr_vlpd_end = ALIGN(0x8);
+ } >efr_fr_hr_vlpd_seg :efr_fr_hr_vlpd_bss_phdr
+
+ .amr_vlpd.rodata : ALIGN(4)
+ {
+ _amr_vlpd_rodata_start = ABSOLUTE(.);
+ *(.amr_vlpd.rodata)
+ _amr_vlpd_rodata_end = ABSOLUTE(.);
+ } >amr_vlpd_seg :amr_vlpd_phdr
+
+ .amr_vlpd.data : ALIGN(4)
+ {
+ _amr_vlpd_data_start = ABSOLUTE(.);
+ *(.amr_vlpd.data)
+ _amr_vlpd_data_end = ABSOLUTE(.);
+ } >amr_vlpd_seg :amr_vlpd_phdr
+
+ .amr_vlpd.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _amr_vlpd_bss_start = ABSOLUTE(.);
+ *(.amr_vlpd.bss)
+ . = ALIGN (8);
+ _amr_vlpd_bss_end = ABSOLUTE(.);
+ _memmap_seg_amr_vlpd_end = ALIGN(0x8);
+ } >amr_vlpd_seg :amr_vlpd_bss_phdr
+
+ .amrwb_vlpd.rodata : ALIGN(4)
+ {
+ _amrwb_vlpd_rodata_start = ABSOLUTE(.);
+ *(.amrwb_vlpd.rodata)
+ _amrwb_vlpd_rodata_end = ABSOLUTE(.);
+ } >amrwb_vlpd_seg :amrwb_vlpd_phdr
+
+ .amrwb_vlpd.data : ALIGN(4)
+ {
+ _amrwb_vlpd_data_start = ABSOLUTE(.);
+ *(.amrwb_vlpd.data)
+ _amrwb_vlpd_data_end = ABSOLUTE(.);
+ } >amrwb_vlpd_seg :amrwb_vlpd_phdr
+
+ .amrwb_vlpd.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _amrwb_vlpd_bss_start = ABSOLUTE(.);
+ *(.amrwb_vlpd.bss)
+ . = ALIGN (8);
+ _amrwb_vlpd_bss_end = ABSOLUTE(.);
+ _memmap_seg_amrwb_vlpd_end = ALIGN(0x8);
+ } >amrwb_vlpd_seg :amrwb_vlpd_bss_phdr
+
+ .evrc_evrcb_vlpt.text : ALIGN(4)
+ {
+ _evrc_evrcb_vlpt_text_start = ABSOLUTE(.);
+ *(.evrc_evrcb_vlpt.literal .evrc_evrcb_vlpt.text)
+ _evrc_evrcb_vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_evrc_evrcb_vlpt_end = ALIGN(0x8);
+ } >evrc_evrcb_vlpt_seg :evrc_evrcb_vlpt_phdr
+
+ .efr_fr_hr_vlpt.text : ALIGN(4)
+ {
+ _efr_fr_hr_vlpt_text_start = ABSOLUTE(.);
+ *(.efr_fr_hr_vlpt.literal .efr_fr_hr_vlpt.text)
+ _efr_fr_hr_vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_efr_fr_hr_vlpt_end = ALIGN(0x8);
+ } >efr_fr_hr_vlpt_seg :efr_fr_hr_vlpt_phdr
+
+ .amr_vlpt.text : ALIGN(4)
+ {
+ _amr_vlpt_text_start = ABSOLUTE(.);
+ *(.amr_vlpt.literal .amr_vlpt.text)
+ _amr_vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_amr_vlpt_end = ALIGN(0x8);
+ } >amr_vlpt_seg :amr_vlpt_phdr
+
+ .amrwb_vlpt.text : ALIGN(4)
+ {
+ _amrwb_vlpt_text_start = ABSOLUTE(.);
+ *(.amrwb_vlpt.literal .amrwb_vlpt.text)
+ _amrwb_vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_amrwb_vlpt_end = ALIGN(0x8);
+ } >amrwb_vlpt_seg :amrwb_vlpt_phdr
+
+ .vlpt.text : ALIGN(4)
+ {
+ _vlpt_text_start = ABSOLUTE(.);
+ *(.vlpt.literal .vlpt.text)
+ _vlpt_text_end = ABSOLUTE(.);
+ _memmap_seg_vlpt_end = ALIGN(0x8);
+ } >vlpt_seg :vlpt_phdr
+
+ .low_power_dyn_alloc : ALIGN(4)
+ {
+ _low_power_dyn_alloc_start = ABSOLUTE(.);
+ *(.low_power_dyn_alloc)
+ _low_power_dyn_alloc_end = ABSOLUTE(.);
+ _memmap_seg_vlpd_end = ALIGN(0x8);
+ } >vlpd_seg :vlpd_phdr
+
+ .ulpp.rodata : ALIGN(4)
+ {
+ _ulpp_rodata_start = ABSOLUTE(.);
+ *(.ulpp.rodata)
+ _ulpp_rodata_end = ABSOLUTE(.);
+ } >ulpp_seg :ulpp_phdr
+
+ .ulpp.data : ALIGN(4)
+ {
+ _ulpp_data_start = ABSOLUTE(.);
+ *(.ulpp.data)
+ _ulpp_data_end = ABSOLUTE(.);
+ } >ulpp_seg :ulpp_phdr
+
+ .ulpp.text : ALIGN(4)
+ {
+ _ulpp_text_start = ABSOLUTE(.);
+ *(.ulpp.literal .ulpp.text)
+ _ulpp_text_end = ABSOLUTE(.);
+ } >ulpp_seg :ulpp_phdr
+
+ .ulpp.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _ulpp_bss_start = ABSOLUTE(.);
+ *(.ulpp.bss)
+ . = ALIGN (8);
+ _ulpp_bss_end = ABSOLUTE(.);
+ _memmap_seg_ulpp_end = ALIGN(0x8);
+ } >ulpp_seg :ulpp_bss_phdr
+
+ .dtsv3.rodata : ALIGN(4)
+ {
+ _dtsv3_rodata_start = ABSOLUTE(.);
+ *(.dtsv3.rodata)
+ _dtsv3_rodata_end = ABSOLUTE(.);
+ } >dtsv3_seg :dtsv3_phdr
+
+ .dtsv3.data : ALIGN(4)
+ {
+ _dtsv3_data_start = ABSOLUTE(.);
+ *(.dtsv3.data)
+ _dtsv3_data_end = ABSOLUTE(.);
+ } >dtsv3_seg :dtsv3_phdr
+
+ .dtsv3.text : ALIGN(4)
+ {
+ _dtsv3_text_start = ABSOLUTE(.);
+ *(.dtsv3.literal .dtsv3.text)
+ _dtsv3_text_end = ABSOLUTE(.);
+ } >dtsv3_seg :dtsv3_phdr
+
+ .dtsv3.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _dtsv3_bss_start = ABSOLUTE(.);
+ *(.dtsv3.bss)
+ . = ALIGN (8);
+ _dtsv3_bss_end = ABSOLUTE(.);
+ _memmap_seg_dtsv3_end = ALIGN(0x8);
+ } >dtsv3_seg :dtsv3_bss_phdr
+
+ .dtsv4.rodata : ALIGN(4)
+ {
+ _dtsv4_rodata_start = ABSOLUTE(.);
+ *(.dtsv4.rodata)
+ _dtsv4_rodata_end = ABSOLUTE(.);
+ } >dtsv4_seg :dtsv4_phdr
+
+ .dtsv4.data : ALIGN(4)
+ {
+ _dtsv4_data_start = ABSOLUTE(.);
+ *(.dtsv4.data)
+ _dtsv4_data_end = ABSOLUTE(.);
+ } >dtsv4_seg :dtsv4_phdr
+
+ .dtsv4.text : ALIGN(4)
+ {
+ _dtsv4_text_start = ABSOLUTE(.);
+ *(.dtsv4.literal .dtsv4.text)
+ _dtsv4_text_end = ABSOLUTE(.);
+ } >dtsv4_seg :dtsv4_phdr
+
+ .dtsv4.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _dtsv4_bss_start = ABSOLUTE(.);
+ *(.dtsv4.bss)
+ . = ALIGN (8);
+ _dtsv4_bss_end = ABSOLUTE(.);
+ _memmap_seg_dtsv4_end = ALIGN(0x8);
+ } >dtsv4_seg :dtsv4_bss_phdr
+
+ .dram0.rodata : ALIGN(4)
+ {
+ _dram0_rodata_start = ABSOLUTE(.);
+ *(.dram0.rodata)
+ *(.dram.rodata)
+ _dram0_rodata_end = ABSOLUTE(.);
+ } >dram0_0_seg :dram0_0_phdr
+
+ .dram0.literal : ALIGN(4)
+ {
+ _dram0_literal_start = ABSOLUTE(.);
+ *(.dram0.literal)
+ *(.dram.literal)
+ _dram0_literal_end = ABSOLUTE(.);
+ } >dram0_0_seg :dram0_0_phdr
+
+ .dram0.data : ALIGN(4)
+ {
+ _dram0_data_start = ABSOLUTE(.);
+ *(.dram0.data)
+ *(.dram.data)
+ _dram0_data_end = ABSOLUTE(.);
+ } >dram0_0_seg :dram0_0_phdr
+
+ .dram0.bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _dram0_bss_start = ABSOLUTE(.);
+ *(.dram0.bss)
+ *(.om.debug.bss)
+ *(.os.stack.bss)
+ . = ALIGN (8);
+ _dram0_bss_end = ABSOLUTE(.);
+ _end = ALIGN(0x8);
+ PROVIDE(end = ALIGN(0x8));
+ _stack_sentry = ALIGN(0x8);
+ _memmap_seg_dram0_0_end = ALIGN(0x8);
+ } >dram0_0_seg :dram0_0_bss_phdr
+ __stack = 0xe8080000;
+ _heap_sentry = 0xe8080000;
+
+ .ResetVector.text : ALIGN(4)
+ {
+ _ResetVector_text_start = ABSOLUTE(.);
+ KEEP (*(.ResetVector.text))
+ _ResetVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_0_end = ALIGN(0x8);
+ } >iram0_0_seg :iram0_0_phdr
+
+ .Reset.literal : ALIGN(4)
+ {
+ _Reset_literal_start = ABSOLUTE(.);
+ *(.Reset.literal)
+ _Reset_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_1_end = ALIGN(0x8);
+ } >iram0_1_seg :iram0_1_phdr
+
+ .WindowVectors.text : ALIGN(4)
+ {
+ _WindowVectors_text_start = ABSOLUTE(.);
+ KEEP (*(.WindowVectors.text))
+ _WindowVectors_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_2_end = ALIGN(0x8);
+ } >iram0_2_seg :iram0_2_phdr
+
+ .Level2InterruptVector.literal : ALIGN(4)
+ {
+ _Level2InterruptVector_literal_start = ABSOLUTE(.);
+ *(.Level2InterruptVector.literal)
+ _Level2InterruptVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_3_end = ALIGN(0x8);
+ } >iram0_3_seg :iram0_3_phdr
+
+ .Level2InterruptVector.text : ALIGN(4)
+ {
+ _Level2InterruptVector_text_start = ABSOLUTE(.);
+ KEEP (*(.Level2InterruptVector.text))
+ _Level2InterruptVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_4_end = ALIGN(0x8);
+ } >iram0_4_seg :iram0_4_phdr
+
+ .Level3InterruptVector.literal : ALIGN(4)
+ {
+ _Level3InterruptVector_literal_start = ABSOLUTE(.);
+ *(.Level3InterruptVector.literal)
+ _Level3InterruptVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_5_end = ALIGN(0x8);
+ } >iram0_5_seg :iram0_5_phdr
+
+ .Level3InterruptVector.text : ALIGN(4)
+ {
+ _Level3InterruptVector_text_start = ABSOLUTE(.);
+ KEEP (*(.Level3InterruptVector.text))
+ _Level3InterruptVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_6_end = ALIGN(0x8);
+ } >iram0_6_seg :iram0_6_phdr
+
+ .Level4InterruptVector.literal : ALIGN(4)
+ {
+ _Level4InterruptVector_literal_start = ABSOLUTE(.);
+ *(.Level4InterruptVector.literal)
+ _Level4InterruptVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_7_end = ALIGN(0x8);
+ } >iram0_7_seg :iram0_7_phdr
+
+ .Level4InterruptVector.text : ALIGN(4)
+ {
+ _Level4InterruptVector_text_start = ABSOLUTE(.);
+ KEEP (*(.Level4InterruptVector.text))
+ _Level4InterruptVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_8_end = ALIGN(0x8);
+ } >iram0_8_seg :iram0_8_phdr
+
+ .DebugExceptionVector.literal : ALIGN(4)
+ {
+ _DebugExceptionVector_literal_start = ABSOLUTE(.);
+ *(.DebugExceptionVector.literal)
+ _DebugExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_9_end = ALIGN(0x8);
+ } >iram0_9_seg :iram0_9_phdr
+
+ .DebugExceptionVector.text : ALIGN(4)
+ {
+ _DebugExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.DebugExceptionVector.text))
+ _DebugExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_10_end = ALIGN(0x8);
+ } >iram0_10_seg :iram0_10_phdr
+
+ .NMIExceptionVector.literal : ALIGN(4)
+ {
+ _NMIExceptionVector_literal_start = ABSOLUTE(.);
+ *(.NMIExceptionVector.literal)
+ _NMIExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_11_end = ALIGN(0x8);
+ } >iram0_11_seg :iram0_11_phdr
+
+ .NMIExceptionVector.text : ALIGN(4)
+ {
+ _NMIExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.NMIExceptionVector.text))
+ _NMIExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_12_end = ALIGN(0x8);
+ } >iram0_12_seg :iram0_12_phdr
+
+ .KernelExceptionVector.literal : ALIGN(4)
+ {
+ _KernelExceptionVector_literal_start = ABSOLUTE(.);
+ *(.KernelExceptionVector.literal)
+ _KernelExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_13_end = ALIGN(0x8);
+ } >iram0_13_seg :iram0_13_phdr
+
+ .KernelExceptionVector.text : ALIGN(4)
+ {
+ _KernelExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.KernelExceptionVector.text))
+ _KernelExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_14_end = ALIGN(0x8);
+ } >iram0_14_seg :iram0_14_phdr
+
+ .UserExceptionVector.literal : ALIGN(4)
+ {
+ _UserExceptionVector_literal_start = ABSOLUTE(.);
+ *(.UserExceptionVector.literal)
+ _UserExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_15_end = ALIGN(0x8);
+ } >iram0_15_seg :iram0_15_phdr
+
+ .UserExceptionVector.text : ALIGN(4)
+ {
+ _UserExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.UserExceptionVector.text))
+ _UserExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_16_end = ALIGN(0x8);
+ } >iram0_16_seg :iram0_16_phdr
+
+ .DoubleExceptionVector.literal : ALIGN(4)
+ {
+ _DoubleExceptionVector_literal_start = ABSOLUTE(.);
+ *(.DoubleExceptionVector.literal)
+ _DoubleExceptionVector_literal_end = ABSOLUTE(.);
+ _memmap_seg_iram0_17_end = ALIGN(0x8);
+ } >iram0_17_seg :iram0_17_phdr
+
+ .DoubleExceptionVector.text : ALIGN(4)
+ {
+ _DoubleExceptionVector_text_start = ABSOLUTE(.);
+ KEEP (*(.DoubleExceptionVector.text))
+ _DoubleExceptionVector_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_18_end = ALIGN(0x8);
+ } >iram0_18_seg :iram0_18_phdr
+
+ .Reset.text : ALIGN(4)
+ {
+ _Reset_text_start = ABSOLUTE(.);
+ *(.Reset.text)
+ _Reset_text_end = ABSOLUTE(.);
+ } >iram0_19_seg :iram0_19_phdr
+
+ .iram0.text : ALIGN(4)
+ {
+ _iram0_text_start = ABSOLUTE(.);
+ *(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text)
+ _iram0_text_end = ABSOLUTE(.);
+ _memmap_seg_iram0_19_end = ALIGN(0x8);
+ } >iram0_19_seg :iram0_19_phdr
+
+ .sram.shareaddr : ALIGN(4)
+ {
+ _sram_shareaddr_start = ABSOLUTE(.);
+ *(.sram.shareaddr)
+ _sram_shareaddr_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .sram.rodata : ALIGN(4)
+ {
+ _sram_rodata_start = ABSOLUTE(.);
+ *(.sram.rodata)
+ _sram_rodata_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .rodata : ALIGN(4)
+ {
+ _rodata_start = ABSOLUTE(.);
+ *(.rodata)
+ *(.rodata.*)
+ *(.gnu.linkonce.r.*)
+ *(.rodata1)
+ __XT_EXCEPTION_TABLE__ = ABSOLUTE(.);
+ KEEP (*(.xt_except_table))
+ KEEP (*(.gcc_except_table))
+ *(.gnu.linkonce.e.*)
+ *(.gnu.version_r)
+ KEEP (*(.eh_frame))
+ /* C++ constructor and destructor tables, properly ordered: */
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ /* C++ exception handlers table: */
+ __XT_EXCEPTION_DESCS__ = ABSOLUTE(.);
+ *(.xt_except_desc)
+ *(.gnu.linkonce.h.*)
+ __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
+ *(.xt_except_desc_end)
+ *(.dynamic)
+ *(.gnu.version_d)
+ . = ALIGN(4); /* this table MUST be 4-byte aligned */
+ _bss_table_start = ABSOLUTE(.);
+ LONG(_vlpd_bss_start)
+ LONG(_vlpd_bss_end)
+ LONG(_efr_fr_hr_vlpd_bss_start)
+ LONG(_efr_fr_hr_vlpd_bss_end)
+ LONG(_amr_vlpd_bss_start)
+ LONG(_amr_vlpd_bss_end)
+ LONG(_amrwb_vlpd_bss_start)
+ LONG(_amrwb_vlpd_bss_end)
+ LONG(_ulpp_bss_start)
+ LONG(_ulpp_bss_end)
+ LONG(_dtsv3_bss_start)
+ LONG(_dtsv3_bss_end)
+ LONG(_dtsv4_bss_start)
+ LONG(_dtsv4_bss_end)
+ LONG(_dram0_bss_start)
+ LONG(_dram0_bss_end)
+ LONG(_bss_start)
+ LONG(_bss_end)
+ _bss_table_end = ABSOLUTE(.);
+ _rodata_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .sram.text : ALIGN(4)
+ {
+ _sram_text_start = ABSOLUTE(.);
+ *(.sram.literal .sram.text)
+ _sram_text_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .text : ALIGN(4)
+ {
+ _stext = .;
+ _text_start = ABSOLUTE(.);
+ *(.entry.text)
+ *(.init.literal)
+ KEEP(*(.init))
+ *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
+ *(.fini.literal)
+ KEEP(*(.fini))
+ *(.gnu.version)
+ _text_end = ABSOLUTE(.);
+ _etext = .;
+ } >sram0_seg :sram0_phdr
+
+ .sram.data : ALIGN(4)
+ {
+ _sram_data_start = ABSOLUTE(.);
+ *(.sram.data)
+ _sram_data_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .data : ALIGN(4)
+ {
+ _data_start = ABSOLUTE(.);
+ *(.data)
+ *(.data.*)
+ *(.gnu.linkonce.d.*)
+ KEEP(*(.gnu.linkonce.d.*personality*))
+ *(.data1)
+ *(.sdata)
+ *(.sdata.*)
+ *(.gnu.linkonce.s.*)
+ *(.sdata2)
+ *(.sdata2.*)
+ *(.gnu.linkonce.s2.*)
+ KEEP(*(.jcr))
+ _data_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .sram.uninit : ALIGN(4)
+ {
+ _sram_uninit_start = ABSOLUTE(.);
+ *(.sram.uninit)
+ _sram_uninit_end = ABSOLUTE(.);
+ } >sram0_seg :sram0_phdr
+
+ .bss (NOLOAD) : ALIGN(8)
+ {
+ . = ALIGN (8);
+ _bss_start = ABSOLUTE(.);
+ *(.dynsbss)
+ *(.sbss)
+ *(.sbss.*)
+ *(.gnu.linkonce.sb.*)
+ *(.scommon)
+ *(.sbss2)
+ *(.sbss2.*)
+ *(.gnu.linkonce.sb2.*)
+ *(.dynbss)
+ *(.bss)
+ *(.bss.*)
+ *(.gnu.linkonce.b.*)
+ *(COMMON)
+ *(.sram.pool.bss)
+ *(.sram.bss)
+ . = ALIGN (8);
+ _bss_end = ABSOLUTE(.);
+ _memmap_seg_sram0_end = ALIGN(0x8);
+ } >sram0_seg :sram0_bss_phdr
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ .debug_info 0 : { *(.debug_info) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+ .xt.insn 0 :
+ {
+ KEEP (*(.xt.insn))
+ KEEP (*(.gnu.linkonce.x.*))
+ }
+ .xt.prop 0 :
+ {
+ KEEP (*(.xt.prop))
+ KEEP (*(.xt.prop.*))
+ KEEP (*(.gnu.linkonce.prop.*))
+ }
+ .xt.lit 0 :
+ {
+ KEEP (*(.xt.lit))
+ KEEP (*(.xt.lit.*))
+ KEEP (*(.gnu.linkonce.p.*))
+ }
+ .debug.xt.callgraph 0 :
+ {
+ KEEP (*(.debug.xt.callgraph .debug.xt.callgraph.* .gnu.linkonce.xt.callgraph.*))
+ }
+}
+
diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xr b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xr
new file mode 100644
index 00000000..3e9f189a
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xr
@@ -0,0 +1,42 @@
+/* This linker script generated from xt-genldscripts.tpp for LSP hifi_hikey_lsp */
+/* Linker Script for ld -r or ld -i */
+
+/* Default entry point: */
+ENTRY(_ResetVector)
+
+SECTIONS
+{
+
+ .text 0 :
+ {
+ *(.literal .text)
+ }
+
+ .bss 0 :
+ {
+ *(.dynsbss)
+ *(.sbss)
+ *(.scommon)
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ }
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ .debug_info 0 : { *(.debug_info) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+}
+
diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xu b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xu
new file mode 100644
index 00000000..d8e1986d
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/ldscripts/elf32xtensa.xu
@@ -0,0 +1,42 @@
+/* This linker script generated from xt-genldscripts.tpp for LSP hifi_hikey_lsp */
+/* Linker Script for ld -Ur */
+
+/* Default entry point: */
+ENTRY(_ResetVector)
+
+SECTIONS
+{
+
+ .text 0 :
+ {
+ *(.literal .text)
+ }
+
+ .bss 0 :
+ {
+ *(.dynsbss)
+ *(.sbss)
+ *(.scommon)
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ }
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ .debug_info 0 : { *(.debug_info) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+}
+
diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/memmap.xmm b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/memmap.xmm
new file mode 100644
index 00000000..c7a94bc8
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/memmap.xmm
@@ -0,0 +1,49 @@
+
+
+BEGIN iram0
+0xe8080000: instRam : iram0 : 0xc000 : executable, writable ;
+ iram0_0 : F : 0xe8080000 - 0xe80802ff : .ResetVector.text;
+ iram0_1 : C : 0xe8080300 - 0xe80803ff : .Reset.literal;
+ iram0_2 : F : 0xe8080400 - 0xe8080577 : .WindowVectors.text;
+ iram0_3 : C : 0xe8080578 - 0xe808057f : .Level2InterruptVector.literal;
+ iram0_4 : F : 0xe8080580 - 0xe80805b7 : .Level2InterruptVector.text;
+ iram0_5 : C : 0xe80805b8 - 0xe80805bf : .Level3InterruptVector.literal;
+ iram0_6 : F : 0xe80805c0 - 0xe80805f7 : .Level3InterruptVector.text;
+ iram0_7 : C : 0xe80805f8 - 0xe80805ff : .Level4InterruptVector.literal;
+ iram0_8 : F : 0xe8080600 - 0xe8080637 : .Level4InterruptVector.text;
+ iram0_9 : C : 0xe8080638 - 0xe808063f : .DebugExceptionVector.literal;
+ iram0_10 : F : 0xe8080640 - 0xe8080677 : .DebugExceptionVector.text;
+ iram0_11 : C : 0xe8080678 - 0xe80806bf : .NMIExceptionVector.literal;
+ iram0_12 : F : 0xe80806c0 - 0xe80806f7 : .NMIExceptionVector.text;
+ iram0_13 : C : 0xe80806f8 - 0xe80806ff : .KernelExceptionVector.literal;
+ iram0_14 : F : 0xe8080700 - 0xe8080737 : .KernelExceptionVector.text;
+ iram0_15 : C : 0xe8080738 - 0xe808073f : .UserExceptionVector.literal;
+ iram0_16 : F : 0xe8080740 - 0xe8080777 : .UserExceptionVector.text;
+ iram0_17 : C : 0xe8080778 - 0xe80807bf : .DoubleExceptionVector.literal;
+ iram0_18 : F : 0xe80807c0 - 0xe80807ff : .DoubleExceptionVector.text;
+ iram0_19 : C : 0xe8080800 - 0xe808bfff : .iram0.literal .Reset.text .iram0.text;
+END iram0
+
+BEGIN dram0
+0xe8058000: dataRam : dram0 : 0x28000 : writable ;
+ dram0_0 : C : 0xe8058000 - 0xe807ffff : STACK : HEAP : .dram0.rodata .dram0.literal .dram0.data .dram0.bss .om.debug.bss .os.stack.bss;
+END dram0
+
+BEGIN sram
+0xc0000000: sysram : sram : 0x600000 : executable, writable ;
+ sram0 : C : 0xc0000000 - 0xC0407FFF : .sram.shareaddr .sram.rodata .rodata .sram.literal .literal .sram.text .text .sram.data .data .sram.uninit .sram.pool.bss .sram.bss .bss;
+ old_vlpd : C : 0xC0408000 - 0xC0417FFF : .vlpd.rodata .vlpd.data .vlpd.bss;
+ efr_fr_hr_vlpd : C : 0xC0418000 - 0xC0427FFF : .efr_fr_hr_vlpd.rodata .efr_fr_hr_vlpd.data .efr_fr_hr_vlpd.bss;
+ amr_vlpd : C : 0xC0428000 - 0xC0437FFF : .amr_vlpd.rodata .amr_vlpd.data .amr_vlpd.bss;
+ amrwb_vlpd : C : 0xC0438000 - 0xC0447FFF : .amrwb_vlpd.rodata .amrwb_vlpd.data .amrwb_vlpd.bss;
+ evrc_evrcb_vlpt : C : 0xC0448000 - 0xC048FFFF : .evrc_evrcb_vlpt.literal .evrc_evrcb_vlpt.text;
+ efr_fr_hr_vlpt : C : 0xC0490000 - 0xC04BFFFF : .efr_fr_hr_vlpt.literal .efr_fr_hr_vlpt.text;
+ amr_vlpt : C : 0xC04C0000 - 0xC04DFFFF : .amr_vlpt.literal .amr_vlpt.text;
+ amrwb_vlpt : C : 0xC04E0000 -0xC050FFFF : .amrwb_vlpt.literal .amrwb_vlpt.text;
+ vlpt : C : 0xC0510000 - 0xC0557FFF : .vlpt.literal .vlpt.text;
+ vlpd : C : 0xC0558000 - 0xC0577FFF : .low_power_dyn_alloc;
+ ulpp : C : 0xc0578000 - 0xc05b7fff : .ulpp.rodata .ulpp.data .ulpp.literal .ulpp.text .ulpp.bss;
+ dtsv3 : C : 0xc05b8000 - 0xc05d7fff : .dtsv3.rodata .dtsv3.data .dtsv3.literal .dtsv3.text .dtsv3.bss;
+ dtsv4 : C : 0xc05d8000 - 0xc05fffff : .dtsv4.rodata .dtsv4.data .dtsv4.literal .dtsv4.text .dtsv4.bss;
+END sram
+
diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/min-rt.parm b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/min-rt.parm
new file mode 100644
index 00000000..25083eeb
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/min-rt.parm
@@ -0,0 +1,15 @@
+// Memory map file to generate linker scripts for programs without board I/O.
+
+// $Id: //depot/rel/Cottonwood/Xtensa/SWConfig/ldscripts/min-rt.parm#1 $
+
+// Customer ID=9470; Build=0x42f97; Copyright (c) 2004-2007 by Tensilica Inc. ALL RIGHTS RESERVED.
+// These coded instructions, statements, and computer programs are the
+// copyrighted works and confidential proprietary information of Tensilica Inc.
+// They may not be modified, copied, reproduced, distributed, or disclosed to
+// third parties in any manner, medium, or form, in whole or in part, without
+// the prior written consent of Tensilica Inc.
+
+// Show more details if configuration targets the XT2000 board:
+INCLUDE_XT2000_MEMORIES = try
+RESERVE_SEGMENT_AREA = ".i_ocram.text 0x7800 + 0 start : .d_ocram.data 0x5000 + 0 start"
+
diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/specs b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/specs
new file mode 100644
index 00000000..2988e02a
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/specs
@@ -0,0 +1,22 @@
+# Customer ID=9470; Build=0x42f97; Copyright (c) 2001-2010 by Tensilica Inc. ALL RIGHTS RESERVED.
+# These coded instructions, statements, and computer programs are the
+# copyrighted works and confidential proprietary information of Tensilica Inc.
+# They may not be modified, copied, reproduced, distributed, or disclosed to
+# third parties in any manner, medium, or form, in whole or in part, without
+# the prior written consent of Tensilica Inc.
+
+
+# The %O suffix on the start and end files indicates that the system's
+# standard suffix for object files (e.g., ".o") should be appended.
+# The %s suffix tells the compiler driver to search for the file in the
+# list of known locations for startfiles.
+
+*startfile:
+crt1-boards%O%s crti%O%s crtbegin%O%s _sharedvectors%O%s _vectors%O%s
+
+*endfile:
+crtend%O%s crtn%O%s
+
+*lib:
+-lc -lgloss -lminrt -lc -lhandler-reset -lhandlers-board -lminrt -lhal -lc
+
diff --git a/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/tag b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/tag
new file mode 100644
index 00000000..7be80f2a
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/tag
@@ -0,0 +1,3 @@
+#This file is generated by Xplorer, do not edit.
+#Mon Aug 26 15:41:31 CST 2013
+standardlsp=min-rt
diff --git a/self-extractors/Android.mk b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/user.parm
index e69de29b..e69de29b 100644
--- a/self-extractors/Android.mk
+++ b/hifi/xaf/hifi-dpf/build_hikey/hifi_hikey_lsp/user.parm
diff --git a/hifi/xaf/hifi-dpf/build_hikey/map_hikey.txt b/hifi/xaf/hifi-dpf/build_hikey/map_hikey.txt
new file mode 100644
index 00000000..58a3efce
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/map_hikey.txt
@@ -0,0 +1,2167 @@
+Archive member included because of file (symbol)
+
+../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o)
+ objs/hikey/xa-vorbis-decoder.o (xa_vorbis_dec)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o)
+ objs/hikey/arch_hifi330.o (xthal_window_spill_nw)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o)
+ objs/hikey/xf-shmem.o (xthal_dcache_region_invalidate)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o)
+ objs/hikey/xf-shmem.o (xthal_dcache_region_writeback)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid0.o)
+ /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) (xthals_hw_configid0)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid1.o)
+ /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) (xthals_hw_configid1)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_major.o)
+ /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) (xthals_release_major)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_minor.o)
+ /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o) (xthals_release_minor)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o)
+ objs/hikey/cpu_c.o (xthal_get_intenable)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o)
+ objs/hikey/cpu_c.o (xthal_set_intenable)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o)
+ objs/hikey/arch_hifi330.o (xthal_restore_extra_nw)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o)
+ objs/hikey/arch_hifi330.o (xthal_save_extra_nw)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o)
+ objs/hikey/xf-main.o (_xtos_ints_on)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o)
+ objs/hikey/mutex.o (_xtos_ints_off)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o)
+ /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o) (_xtos_intstruct)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (memchr)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o)
+ ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (memcmp)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o)
+ objs/hikey/xf-io.o (memcpy)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o)
+ objs/hikey/xf-io.o (memset)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (qsort)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ objs/hikey/xa-factory.o (strncmp)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o)
+ ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (__divsi3)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o)
+ ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (__modsi3)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o)
+ objs/hikey/xf-core.o (__adddf3)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o)
+ objs/hikey/dsp_debug.o (__muldf3)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o)
+ objs/hikey/dsp_debug.o (__ltdf2)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o)
+ objs/hikey/xf-core.o (__fixunsdfsi)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o)
+ objs/hikey/dsp_debug.o (__fixunsdfdi)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o)
+ objs/hikey/xf-core.o (__floatunsidf)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o)
+ objs/hikey/dsp_debug.o (__floatundidf)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (__divdi3)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ objs/hikey/dsp_debug.o (__udivdi3)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ objs/hikey/dsp_debug.o (__umoddi3)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (__vec_memcpy)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o) (__vec_memset)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ objs/hikey/xf-core.o (__divdf3)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) (__propagateFloat64NaN)
+/scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+ /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o) (__estimateDiv64To32)
+
+Memory Configuration
+
+Name Origin Length Attributes
+sram0_seg 0xc0000000 0x00408000
+old_vlpd_seg 0xc0408000 0x00010000
+efr_fr_hr_vlpd_seg 0xc0418000 0x00010000
+amr_vlpd_seg 0xc0428000 0x00010000
+amrwb_vlpd_seg 0xc0438000 0x00010000
+evrc_evrcb_vlpt_seg 0xc0448000 0x00048000
+efr_fr_hr_vlpt_seg 0xc0490000 0x00030000
+amr_vlpt_seg 0xc04c0000 0x00020000
+amrwb_vlpt_seg 0xc04e0000 0x00030000
+vlpt_seg 0xc0510000 0x00048000
+vlpd_seg 0xc0558000 0x00020000
+ulpp_seg 0xc0578000 0x00040000
+dtsv3_seg 0xc05b8000 0x00020000
+dtsv4_seg 0xc05d8000 0x00028000
+dram0_0_seg 0xe8058000 0x00028000
+iram0_0_seg 0xe8080000 0x00000300
+iram0_1_seg 0xe8080300 0x00000100
+iram0_2_seg 0xe8080400 0x00000178
+iram0_3_seg 0xe8080578 0x00000008
+iram0_4_seg 0xe8080580 0x00000038
+iram0_5_seg 0xe80805b8 0x00000008
+iram0_6_seg 0xe80805c0 0x00000038
+iram0_7_seg 0xe80805f8 0x00000008
+iram0_8_seg 0xe8080600 0x00000038
+iram0_9_seg 0xe8080638 0x00000008
+iram0_10_seg 0xe8080640 0x00000038
+iram0_11_seg 0xe8080678 0x00000048
+iram0_12_seg 0xe80806c0 0x00000038
+iram0_13_seg 0xe80806f8 0x00000008
+iram0_14_seg 0xe8080700 0x00000038
+iram0_15_seg 0xe8080738 0x00000008
+iram0_16_seg 0xe8080740 0x00000038
+iram0_17_seg 0xe8080778 0x00000048
+iram0_18_seg 0xe80807c0 0x00000040
+iram0_19_seg 0xe8080800 0x0000b800
+*default* 0x00000000 0xffffffff
+
+Linker script and memory map
+
+LOAD objs/hikey/cpu_c.o
+LOAD objs/hikey/dsp_debug.o
+LOAD objs/hikey/dsp_comm.o
+LOAD objs/hikey/mutex.o
+LOAD objs/hikey/rbtree.o
+LOAD objs/hikey/xf-core.o
+LOAD objs/hikey/xf-io.o
+LOAD objs/hikey/xf-mem.o
+LOAD objs/hikey/xf-msg.o
+LOAD objs/hikey/xf-sched.o
+LOAD objs/hikey/xa-factory.o
+LOAD objs/hikey/xf-shmem.o
+LOAD objs/hikey/tinyvprintf.o
+LOAD objs/hikey/xf-isr.o
+LOAD objs/hikey/gdbstub.o
+LOAD objs/hikey/xa-class-base.o
+LOAD objs/hikey/xa-class-audio-codec.o
+LOAD objs/hikey/xa-class-mixer.o
+LOAD objs/hikey/xf-main.o
+LOAD objs/hikey/xa-pcm.o
+LOAD objs/hikey/xa-vorbis-decoder.o
+LOAD objs/hikey/xa-mixer.o
+LOAD objs/hikey/reset.o
+LOAD objs/hikey/int_vector.o
+LOAD objs/hikey/arch_hifi330.o
+LOAD objs/hikey/gdbstub-entry.o
+LOAD ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a
+LOAD /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a
+LOAD /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a
+LOAD /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a
+LOAD /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a
+ 0xe8080000 _memmap_mem_iram0_start = 0xe8080000
+ 0xe808c000 _memmap_mem_iram0_end = 0xe808c000
+ 0xe8058000 _memmap_mem_dram0_start = 0xe8058000
+ 0xe8080000 _memmap_mem_dram0_end = 0xe8080000
+ 0xc0000000 _memmap_mem_sram_start = 0xc0000000
+ 0xc0600000 _memmap_mem_sram_end = 0xc0600000
+ 0xc0000000 _memmap_seg_sram0_start = 0xc0000000
+ 0xc0408000 _memmap_seg_sram0_max = 0xc0408000
+ 0xc0408000 _memmap_seg_old_vlpd_start = 0xc0408000
+ 0xc0418000 _memmap_seg_old_vlpd_max = 0xc0418000
+ 0xc0418000 _memmap_seg_efr_fr_hr_vlpd_start = 0xc0418000
+ 0xc0428000 _memmap_seg_efr_fr_hr_vlpd_max = 0xc0428000
+ 0xc0428000 _memmap_seg_amr_vlpd_start = 0xc0428000
+ 0xc0438000 _memmap_seg_amr_vlpd_max = 0xc0438000
+ 0xc0438000 _memmap_seg_amrwb_vlpd_start = 0xc0438000
+ 0xc0448000 _memmap_seg_amrwb_vlpd_max = 0xc0448000
+ 0xc0448000 _memmap_seg_evrc_evrcb_vlpt_start = 0xc0448000
+ 0xc0490000 _memmap_seg_evrc_evrcb_vlpt_max = 0xc0490000
+ 0xc0490000 _memmap_seg_efr_fr_hr_vlpt_start = 0xc0490000
+ 0xc04c0000 _memmap_seg_efr_fr_hr_vlpt_max = 0xc04c0000
+ 0xc04c0000 _memmap_seg_amr_vlpt_start = 0xc04c0000
+ 0xc04e0000 _memmap_seg_amr_vlpt_max = 0xc04e0000
+ 0xc04e0000 _memmap_seg_amrwb_vlpt_start = 0xc04e0000
+ 0xc0510000 _memmap_seg_amrwb_vlpt_max = 0xc0510000
+ 0xc0510000 _memmap_seg_vlpt_start = 0xc0510000
+ 0xc0558000 _memmap_seg_vlpt_max = 0xc0558000
+ 0xc0558000 _memmap_seg_vlpd_start = 0xc0558000
+ 0xc0578000 _memmap_seg_vlpd_max = 0xc0578000
+ 0xc0578000 _memmap_seg_ulpp_start = 0xc0578000
+ 0xc05b8000 _memmap_seg_ulpp_max = 0xc05b8000
+ 0xc05b8000 _memmap_seg_dtsv3_start = 0xc05b8000
+ 0xc05d8000 _memmap_seg_dtsv3_max = 0xc05d8000
+ 0xc05d8000 _memmap_seg_dtsv4_start = 0xc05d8000
+ 0xc0600000 _memmap_seg_dtsv4_max = 0xc0600000
+ 0xe8058000 _memmap_seg_dram0_0_start = 0xe8058000
+ 0xe8080000 _memmap_seg_dram0_0_max = 0xe8080000
+ 0xe8080000 _memmap_seg_iram0_0_start = 0xe8080000
+ 0xe8080300 _memmap_seg_iram0_0_max = 0xe8080300
+ 0xe8080300 _memmap_seg_iram0_1_start = 0xe8080300
+ 0xe8080400 _memmap_seg_iram0_1_max = 0xe8080400
+ 0xe8080400 _memmap_seg_iram0_2_start = 0xe8080400
+ 0xe8080578 _memmap_seg_iram0_2_max = 0xe8080578
+ 0xe8080578 _memmap_seg_iram0_3_start = 0xe8080578
+ 0xe8080580 _memmap_seg_iram0_3_max = 0xe8080580
+ 0xe8080580 _memmap_seg_iram0_4_start = 0xe8080580
+ 0xe80805b8 _memmap_seg_iram0_4_max = 0xe80805b8
+ 0xe80805b8 _memmap_seg_iram0_5_start = 0xe80805b8
+ 0xe80805c0 _memmap_seg_iram0_5_max = 0xe80805c0
+ 0xe80805c0 _memmap_seg_iram0_6_start = 0xe80805c0
+ 0xe80805f8 _memmap_seg_iram0_6_max = 0xe80805f8
+ 0xe80805f8 _memmap_seg_iram0_7_start = 0xe80805f8
+ 0xe8080600 _memmap_seg_iram0_7_max = 0xe8080600
+ 0xe8080600 _memmap_seg_iram0_8_start = 0xe8080600
+ 0xe8080638 _memmap_seg_iram0_8_max = 0xe8080638
+ 0xe8080638 _memmap_seg_iram0_9_start = 0xe8080638
+ 0xe8080640 _memmap_seg_iram0_9_max = 0xe8080640
+ 0xe8080640 _memmap_seg_iram0_10_start = 0xe8080640
+ 0xe8080678 _memmap_seg_iram0_10_max = 0xe8080678
+ 0xe8080678 _memmap_seg_iram0_11_start = 0xe8080678
+ 0xe80806c0 _memmap_seg_iram0_11_max = 0xe80806c0
+ 0xe80806c0 _memmap_seg_iram0_12_start = 0xe80806c0
+ 0xe80806f8 _memmap_seg_iram0_12_max = 0xe80806f8
+ 0xe80806f8 _memmap_seg_iram0_13_start = 0xe80806f8
+ 0xe8080700 _memmap_seg_iram0_13_max = 0xe8080700
+ 0xe8080700 _memmap_seg_iram0_14_start = 0xe8080700
+ 0xe8080738 _memmap_seg_iram0_14_max = 0xe8080738
+ 0xe8080738 _memmap_seg_iram0_15_start = 0xe8080738
+ 0xe8080740 _memmap_seg_iram0_15_max = 0xe8080740
+ 0xe8080740 _memmap_seg_iram0_16_start = 0xe8080740
+ 0xe8080778 _memmap_seg_iram0_16_max = 0xe8080778
+ 0xe8080778 _memmap_seg_iram0_17_start = 0xe8080778
+ 0xe80807c0 _memmap_seg_iram0_17_max = 0xe80807c0
+ 0xe80807c0 _memmap_seg_iram0_18_start = 0xe80807c0
+ 0xe8080800 _memmap_seg_iram0_18_max = 0xe8080800
+ 0xe8080800 _memmap_seg_iram0_19_start = 0xe8080800
+ 0xe808c000 _memmap_seg_iram0_19_max = 0xe808c000
+ 0x00000000 _rom_store_table = 0x0
+ 0xe8080400 PROVIDE (_memmap_vecbase_reset, 0xe8080400)
+ 0xe8080000 PROVIDE (_memmap_reset_vector, 0xe8080000)
+ 0x44000000 _memmap_cacheattr_wb_base = 0x44000000
+ 0x11000000 _memmap_cacheattr_wt_base = 0x11000000
+ 0x22000000 _memmap_cacheattr_bp_base = 0x22000000
+ 0x00ffffff _memmap_cacheattr_unused_mask = 0xffffff
+ 0x4422222f _memmap_cacheattr_wb_trapnull = 0x4422222f
+ 0x4422222f _memmap_cacheattr_wba_trapnull = 0x4422222f
+ 0x5522222f _memmap_cacheattr_wbna_trapnull = 0x5522222f
+ 0x1122222f _memmap_cacheattr_wt_trapnull = 0x1122222f
+ 0x2222222f _memmap_cacheattr_bp_trapnull = 0x2222222f
+ 0x44ffffff _memmap_cacheattr_wb_strict = 0x44ffffff
+ 0x11ffffff _memmap_cacheattr_wt_strict = 0x11ffffff
+ 0x22ffffff _memmap_cacheattr_bp_strict = 0x22ffffff
+ 0x44222222 _memmap_cacheattr_wb_allvalid = 0x44222222
+ 0x11222222 _memmap_cacheattr_wt_allvalid = 0x11222222
+ 0x22222222 _memmap_cacheattr_bp_allvalid = 0x22222222
+ 0x4422222f PROVIDE (_memmap_cacheattr_reset, _memmap_cacheattr_wb_trapnull)
+
+.vlpd.rodata 0xc0408000 0x0
+ 0xc0408000 _vlpd_rodata_start = ABSOLUTE (.)
+ *(.vlpd.rodata)
+ 0xc0408000 _vlpd_rodata_end = ABSOLUTE (.)
+
+.vlpd.data 0xc0408000 0x0
+ 0xc0408000 _vlpd_data_start = ABSOLUTE (.)
+ *(.vlpd.data)
+ 0xc0408000 _vlpd_data_end = ABSOLUTE (.)
+
+.vlpd.bss 0xc0408000 0x0
+ 0xc0408000 . = ALIGN (0x8)
+ 0xc0408000 _vlpd_bss_start = ABSOLUTE (.)
+ *(.vlpd.bss)
+ 0xc0408000 . = ALIGN (0x8)
+ 0xc0408000 _vlpd_bss_end = ABSOLUTE (.)
+ 0xc0408000 _memmap_seg_old_vlpd_end = ALIGN (0x8)
+
+.efr_fr_hr_vlpd.rodata
+ 0xc0418000 0x0
+ 0xc0418000 _efr_fr_hr_vlpd_rodata_start = ABSOLUTE (.)
+ *(.efr_fr_hr_vlpd.rodata)
+ 0xc0418000 _efr_fr_hr_vlpd_rodata_end = ABSOLUTE (.)
+
+.efr_fr_hr_vlpd.data
+ 0xc0418000 0x0
+ 0xc0418000 _efr_fr_hr_vlpd_data_start = ABSOLUTE (.)
+ *(.efr_fr_hr_vlpd.data)
+ 0xc0418000 _efr_fr_hr_vlpd_data_end = ABSOLUTE (.)
+
+.efr_fr_hr_vlpd.bss
+ 0xc0418000 0x0
+ 0xc0418000 . = ALIGN (0x8)
+ 0xc0418000 _efr_fr_hr_vlpd_bss_start = ABSOLUTE (.)
+ *(.efr_fr_hr_vlpd.bss)
+ 0xc0418000 . = ALIGN (0x8)
+ 0xc0418000 _efr_fr_hr_vlpd_bss_end = ABSOLUTE (.)
+ 0xc0418000 _memmap_seg_efr_fr_hr_vlpd_end = ALIGN (0x8)
+
+.amr_vlpd.rodata
+ 0xc0428000 0x0
+ 0xc0428000 _amr_vlpd_rodata_start = ABSOLUTE (.)
+ *(.amr_vlpd.rodata)
+ 0xc0428000 _amr_vlpd_rodata_end = ABSOLUTE (.)
+
+.amr_vlpd.data 0xc0428000 0x0
+ 0xc0428000 _amr_vlpd_data_start = ABSOLUTE (.)
+ *(.amr_vlpd.data)
+ 0xc0428000 _amr_vlpd_data_end = ABSOLUTE (.)
+
+.amr_vlpd.bss 0xc0428000 0x0
+ 0xc0428000 . = ALIGN (0x8)
+ 0xc0428000 _amr_vlpd_bss_start = ABSOLUTE (.)
+ *(.amr_vlpd.bss)
+ 0xc0428000 . = ALIGN (0x8)
+ 0xc0428000 _amr_vlpd_bss_end = ABSOLUTE (.)
+ 0xc0428000 _memmap_seg_amr_vlpd_end = ALIGN (0x8)
+
+.amrwb_vlpd.rodata
+ 0xc0438000 0x0
+ 0xc0438000 _amrwb_vlpd_rodata_start = ABSOLUTE (.)
+ *(.amrwb_vlpd.rodata)
+ 0xc0438000 _amrwb_vlpd_rodata_end = ABSOLUTE (.)
+
+.amrwb_vlpd.data
+ 0xc0438000 0x0
+ 0xc0438000 _amrwb_vlpd_data_start = ABSOLUTE (.)
+ *(.amrwb_vlpd.data)
+ 0xc0438000 _amrwb_vlpd_data_end = ABSOLUTE (.)
+
+.amrwb_vlpd.bss
+ 0xc0438000 0x0
+ 0xc0438000 . = ALIGN (0x8)
+ 0xc0438000 _amrwb_vlpd_bss_start = ABSOLUTE (.)
+ *(.amrwb_vlpd.bss)
+ 0xc0438000 . = ALIGN (0x8)
+ 0xc0438000 _amrwb_vlpd_bss_end = ABSOLUTE (.)
+ 0xc0438000 _memmap_seg_amrwb_vlpd_end = ALIGN (0x8)
+
+.evrc_evrcb_vlpt.text
+ 0xc0448000 0x0
+ 0xc0448000 _evrc_evrcb_vlpt_text_start = ABSOLUTE (.)
+ *(.evrc_evrcb_vlpt.literal .evrc_evrcb_vlpt.text)
+ 0xc0448000 _evrc_evrcb_vlpt_text_end = ABSOLUTE (.)
+ 0xc0448000 _memmap_seg_evrc_evrcb_vlpt_end = ALIGN (0x8)
+
+.efr_fr_hr_vlpt.text
+ 0xc0490000 0x0
+ 0xc0490000 _efr_fr_hr_vlpt_text_start = ABSOLUTE (.)
+ *(.efr_fr_hr_vlpt.literal .efr_fr_hr_vlpt.text)
+ 0xc0490000 _efr_fr_hr_vlpt_text_end = ABSOLUTE (.)
+ 0xc0490000 _memmap_seg_efr_fr_hr_vlpt_end = ALIGN (0x8)
+
+.amr_vlpt.text 0xc04c0000 0x0
+ 0xc04c0000 _amr_vlpt_text_start = ABSOLUTE (.)
+ *(.amr_vlpt.literal .amr_vlpt.text)
+ 0xc04c0000 _amr_vlpt_text_end = ABSOLUTE (.)
+ 0xc04c0000 _memmap_seg_amr_vlpt_end = ALIGN (0x8)
+
+.amrwb_vlpt.text
+ 0xc04e0000 0x0
+ 0xc04e0000 _amrwb_vlpt_text_start = ABSOLUTE (.)
+ *(.amrwb_vlpt.literal .amrwb_vlpt.text)
+ 0xc04e0000 _amrwb_vlpt_text_end = ABSOLUTE (.)
+ 0xc04e0000 _memmap_seg_amrwb_vlpt_end = ALIGN (0x8)
+
+.vlpt.text 0xc0510000 0x0
+ 0xc0510000 _vlpt_text_start = ABSOLUTE (.)
+ *(.vlpt.literal .vlpt.text)
+ 0xc0510000 _vlpt_text_end = ABSOLUTE (.)
+ 0xc0510000 _memmap_seg_vlpt_end = ALIGN (0x8)
+
+.low_power_dyn_alloc
+ 0xc0558000 0x0
+ 0xc0558000 _low_power_dyn_alloc_start = ABSOLUTE (.)
+ *(.low_power_dyn_alloc)
+ 0xc0558000 _low_power_dyn_alloc_end = ABSOLUTE (.)
+ 0xc0558000 _memmap_seg_vlpd_end = ALIGN (0x8)
+
+.ulpp.rodata 0xc0578000 0x0
+ 0xc0578000 _ulpp_rodata_start = ABSOLUTE (.)
+ *(.ulpp.rodata)
+ 0xc0578000 _ulpp_rodata_end = ABSOLUTE (.)
+
+.ulpp.data 0xc0578000 0x0
+ 0xc0578000 _ulpp_data_start = ABSOLUTE (.)
+ *(.ulpp.data)
+ 0xc0578000 _ulpp_data_end = ABSOLUTE (.)
+
+.ulpp.text 0xc0578000 0x0
+ 0xc0578000 _ulpp_text_start = ABSOLUTE (.)
+ *(.ulpp.literal .ulpp.text)
+ 0xc0578000 _ulpp_text_end = ABSOLUTE (.)
+
+.ulpp.bss 0xc0578000 0x0
+ 0xc0578000 . = ALIGN (0x8)
+ 0xc0578000 _ulpp_bss_start = ABSOLUTE (.)
+ *(.ulpp.bss)
+ 0xc0578000 . = ALIGN (0x8)
+ 0xc0578000 _ulpp_bss_end = ABSOLUTE (.)
+ 0xc0578000 _memmap_seg_ulpp_end = ALIGN (0x8)
+
+.dtsv3.rodata 0xc05b8000 0x0
+ 0xc05b8000 _dtsv3_rodata_start = ABSOLUTE (.)
+ *(.dtsv3.rodata)
+ 0xc05b8000 _dtsv3_rodata_end = ABSOLUTE (.)
+
+.dtsv3.data 0xc05b8000 0x0
+ 0xc05b8000 _dtsv3_data_start = ABSOLUTE (.)
+ *(.dtsv3.data)
+ 0xc05b8000 _dtsv3_data_end = ABSOLUTE (.)
+
+.dtsv3.text 0xc05b8000 0x0
+ 0xc05b8000 _dtsv3_text_start = ABSOLUTE (.)
+ *(.dtsv3.literal .dtsv3.text)
+ 0xc05b8000 _dtsv3_text_end = ABSOLUTE (.)
+
+.dtsv3.bss 0xc05b8000 0x0
+ 0xc05b8000 . = ALIGN (0x8)
+ 0xc05b8000 _dtsv3_bss_start = ABSOLUTE (.)
+ *(.dtsv3.bss)
+ 0xc05b8000 . = ALIGN (0x8)
+ 0xc05b8000 _dtsv3_bss_end = ABSOLUTE (.)
+ 0xc05b8000 _memmap_seg_dtsv3_end = ALIGN (0x8)
+
+.dtsv4.rodata 0xc05d8000 0x0
+ 0xc05d8000 _dtsv4_rodata_start = ABSOLUTE (.)
+ *(.dtsv4.rodata)
+ 0xc05d8000 _dtsv4_rodata_end = ABSOLUTE (.)
+
+.dtsv4.data 0xc05d8000 0x0
+ 0xc05d8000 _dtsv4_data_start = ABSOLUTE (.)
+ *(.dtsv4.data)
+ 0xc05d8000 _dtsv4_data_end = ABSOLUTE (.)
+
+.dtsv4.text 0xc05d8000 0x0
+ 0xc05d8000 _dtsv4_text_start = ABSOLUTE (.)
+ *(.dtsv4.literal .dtsv4.text)
+ 0xc05d8000 _dtsv4_text_end = ABSOLUTE (.)
+
+.dtsv4.bss 0xc05d8000 0x0
+ 0xc05d8000 . = ALIGN (0x8)
+ 0xc05d8000 _dtsv4_bss_start = ABSOLUTE (.)
+ *(.dtsv4.bss)
+ 0xc05d8000 . = ALIGN (0x8)
+ 0xc05d8000 _dtsv4_bss_end = ABSOLUTE (.)
+ 0xc05d8000 _memmap_seg_dtsv4_end = ALIGN (0x8)
+
+.dram0.rodata 0xe8058000 0x0
+ 0xe8058000 _dram0_rodata_start = ABSOLUTE (.)
+ *(.dram0.rodata)
+ *(.dram.rodata)
+ 0xe8058000 _dram0_rodata_end = ABSOLUTE (.)
+
+.dram0.literal 0xe8058000 0x0
+ 0xe8058000 _dram0_literal_start = ABSOLUTE (.)
+ *(.dram0.literal)
+ *(.dram.literal)
+ 0xe8058000 _dram0_literal_end = ABSOLUTE (.)
+
+.dram0.data 0xe8058000 0x51
+ 0xe8058000 _dram0_data_start = ABSOLUTE (.)
+ *(.dram0.data)
+ .dram0.data 0xe8058000 0x50 objs/hikey/int_vector.o
+ 0xe8058030 g_awVosCoprocOwnerSa
+ 0xe8058038 g_strVosPanicMessage
+ .dram0.data 0xe8058050 0x1 objs/hikey/arch_hifi330.o
+ *(.dram.data)
+ 0xe8058051 _dram0_data_end = ABSOLUTE (.)
+
+.dram0.bss 0xe8058058 0x0
+ 0xe8058058 . = ALIGN (0x8)
+ 0xe8058058 _dram0_bss_start = ABSOLUTE (.)
+ *(.dram0.bss)
+ *(.om.debug.bss)
+ *(.os.stack.bss)
+ 0xe8058058 . = ALIGN (0x8)
+ 0xe8058058 _dram0_bss_end = ABSOLUTE (.)
+ 0xe8058058 _end = ALIGN (0x8)
+ 0xe8058058 PROVIDE (end, ALIGN (0x8))
+ 0xe8058058 _stack_sentry = ALIGN (0x8)
+ 0xe8058058 _memmap_seg_dram0_0_end = ALIGN (0x8)
+ 0xe8080000 __stack = 0xe8080000
+ 0xe8080000 _heap_sentry = 0xe8080000
+
+.ResetVector.text
+ 0xe8080000 0x3
+ 0xe8080000 _ResetVector_text_start = ABSOLUTE (.)
+ *(.ResetVector.text)
+ .ResetVector.text
+ 0xe8080000 0x3 objs/hikey/reset.o
+ 0xe8080000 _ResetVector
+ 0xe8080003 _ResetVector_text_end = ABSOLUTE (.)
+ 0xe8080008 _memmap_seg_iram0_0_end = ALIGN (0x8)
+
+.Reset.literal 0xe8080300 0x40
+ 0xe8080300 _Reset_literal_start = ABSOLUTE (.)
+ *(.Reset.literal)
+ .Reset.literal
+ 0xe8080300 0x40 objs/hikey/reset.o
+ 0xe8080340 _Reset_literal_end = ABSOLUTE (.)
+ 0xe8080340 _memmap_seg_iram0_1_end = ALIGN (0x8)
+
+.WindowVectors.text
+ 0xe8080400 0x16a
+ 0xe8080400 _WindowVectors_text_start = ABSOLUTE (.)
+ *(.WindowVectors.text)
+ .WindowVectors.text
+ 0xe8080400 0x16a objs/hikey/int_vector.o
+ 0xe8080400 _WindowOverflow4
+ 0xe8080440 _WindowUnderflow4
+ 0xe8080450 OS_AllocaException
+ 0xe8080480 _WindowOverflow8
+ 0xe80804c0 _WindowUnderflow8
+ 0xe8080500 _WindowOverflow12
+ 0xe8080540 _WindowUnderflow12
+ 0xe808056a _WindowVectors_text_end = ABSOLUTE (.)
+ 0xe8080570 _memmap_seg_iram0_2_end = ALIGN (0x8)
+
+.Level2InterruptVector.literal
+ 0xe8080578 0x0
+ 0xe8080578 _Level2InterruptVector_literal_start = ABSOLUTE (.)
+ *(.Level2InterruptVector.literal)
+ .Level2InterruptVector.literal
+ 0xe8080578 0x0 objs/hikey/int_vector.o
+ 0x4 (size before relaxing)
+ 0xe8080578 _Level2InterruptVector_literal_end = ABSOLUTE (.)
+ 0xe8080578 _memmap_seg_iram0_3_end = ALIGN (0x8)
+
+.Level2InterruptVector.text
+ 0xe8080580 0x6
+ 0xe8080580 _Level2InterruptVector_text_start = ABSOLUTE (.)
+ *(.Level2InterruptVector.text)
+ .Level2InterruptVector.text
+ 0xe8080580 0x6 objs/hikey/int_vector.o
+ 0x9 (size before relaxing)
+ 0xe8080580 OS_Level2Vector
+ 0xe8080586 _Level2InterruptVector_text_end = ABSOLUTE (.)
+ 0xe8080588 _memmap_seg_iram0_4_end = ALIGN (0x8)
+
+.Level3InterruptVector.literal
+ 0xe80805b8 0x0
+ 0xe80805b8 _Level3InterruptVector_literal_start = ABSOLUTE (.)
+ *(.Level3InterruptVector.literal)
+ .Level3InterruptVector.literal
+ 0xe80805b8 0x0 objs/hikey/int_vector.o
+ 0x4 (size before relaxing)
+ 0xe80805b8 _Level3InterruptVector_literal_end = ABSOLUTE (.)
+ 0xe80805b8 _memmap_seg_iram0_5_end = ALIGN (0x8)
+
+.Level3InterruptVector.text
+ 0xe80805c0 0x6
+ 0xe80805c0 _Level3InterruptVector_text_start = ABSOLUTE (.)
+ *(.Level3InterruptVector.text)
+ .Level3InterruptVector.text
+ 0xe80805c0 0x6 objs/hikey/int_vector.o
+ 0x9 (size before relaxing)
+ 0xe80805c0 OS_Level3Vector
+ 0xe80805c6 _Level3InterruptVector_text_end = ABSOLUTE (.)
+ 0xe80805c8 _memmap_seg_iram0_6_end = ALIGN (0x8)
+
+.Level4InterruptVector.literal
+ 0xe80805f8 0x0
+ 0xe80805f8 _Level4InterruptVector_literal_start = ABSOLUTE (.)
+ *(.Level4InterruptVector.literal)
+ 0xe80805f8 _Level4InterruptVector_literal_end = ABSOLUTE (.)
+ 0xe80805f8 _memmap_seg_iram0_7_end = ALIGN (0x8)
+
+.Level4InterruptVector.text
+ 0xe8080600 0x0
+ 0xe8080600 _Level4InterruptVector_text_start = ABSOLUTE (.)
+ *(.Level4InterruptVector.text)
+ 0xe8080600 _Level4InterruptVector_text_end = ABSOLUTE (.)
+ 0xe8080600 _memmap_seg_iram0_8_end = ALIGN (0x8)
+
+.DebugExceptionVector.literal
+ 0xe8080638 0x0
+ 0xe8080638 _DebugExceptionVector_literal_start = ABSOLUTE (.)
+ *(.DebugExceptionVector.literal)
+ .DebugExceptionVector.literal
+ 0xe8080638 0x0 objs/hikey/int_vector.o
+ 0x4 (size before relaxing)
+ 0xe8080638 _DebugExceptionVector_literal_end = ABSOLUTE (.)
+ 0xe8080638 _memmap_seg_iram0_9_end = ALIGN (0x8)
+
+.DebugExceptionVector.text
+ 0xe8080640 0x16
+ 0xe8080640 _DebugExceptionVector_text_start = ABSOLUTE (.)
+ *(.DebugExceptionVector.text)
+ .DebugExceptionVector.text
+ 0xe8080640 0x9 objs/hikey/int_vector.o
+ 0xc (size before relaxing)
+ 0xe8080640 OS_DebugExceptionVector
+ *fill* 0xe8080649 0x3
+ .DebugExceptionVector.text
+ 0xe808064c 0xa objs/hikey/gdbstub-entry.o
+ 0xe808064c DebugExceptionVector
+ 0xe8080656 _DebugExceptionVector_text_end = ABSOLUTE (.)
+ 0xe8080658 _memmap_seg_iram0_10_end = ALIGN (0x8)
+
+.NMIExceptionVector.literal
+ 0xe8080678 0x8
+ 0xe8080678 _NMIExceptionVector_literal_start = ABSOLUTE (.)
+ *(.NMIExceptionVector.literal)
+ .NMIExceptionVector.literal
+ 0xe8080678 0x8 objs/hikey/int_vector.o
+ 0xe8080680 _NMIExceptionVector_literal_end = ABSOLUTE (.)
+ 0xe8080680 _memmap_seg_iram0_11_end = ALIGN (0x8)
+
+.NMIExceptionVector.text
+ 0xe80806c0 0x1b
+ 0xe80806c0 _NMIExceptionVector_text_start = ABSOLUTE (.)
+ *(.NMIExceptionVector.text)
+ .NMIExceptionVector.text
+ 0xe80806c0 0x1b objs/hikey/int_vector.o
+ 0xe80806c0 OS_NMIExceptionVector
+ 0xe80806db _NMIExceptionVector_text_end = ABSOLUTE (.)
+ 0xe80806e0 _memmap_seg_iram0_12_end = ALIGN (0x8)
+
+.KernelExceptionVector.literal
+ 0xe80806f8 0x0
+ 0xe80806f8 _KernelExceptionVector_literal_start = ABSOLUTE (.)
+ *(.KernelExceptionVector.literal)
+ .KernelExceptionVector.literal
+ 0xe80806f8 0x0 objs/hikey/int_vector.o
+ 0x4 (size before relaxing)
+ 0xe80806f8 _KernelExceptionVector_literal_end = ABSOLUTE (.)
+ 0xe80806f8 _memmap_seg_iram0_13_end = ALIGN (0x8)
+
+.KernelExceptionVector.text
+ 0xe8080700 0x6
+ 0xe8080700 _KernelExceptionVector_text_start = ABSOLUTE (.)
+ *(.KernelExceptionVector.text)
+ .KernelExceptionVector.text
+ 0xe8080700 0x6 objs/hikey/int_vector.o
+ 0x9 (size before relaxing)
+ 0xe8080700 OS_KernelExceptionVector
+ 0xe8080706 _KernelExceptionVector_text_end = ABSOLUTE (.)
+ 0xe8080708 _memmap_seg_iram0_14_end = ALIGN (0x8)
+
+.UserExceptionVector.literal
+ 0xe8080738 0x0
+ 0xe8080738 _UserExceptionVector_literal_start = ABSOLUTE (.)
+ *(.UserExceptionVector.literal)
+ .UserExceptionVector.literal
+ 0xe8080738 0x0 objs/hikey/int_vector.o
+ 0x4 (size before relaxing)
+ 0xe8080738 _UserExceptionVector_literal_end = ABSOLUTE (.)
+ 0xe8080738 _memmap_seg_iram0_15_end = ALIGN (0x8)
+
+.UserExceptionVector.text
+ 0xe8080740 0x6
+ 0xe8080740 _UserExceptionVector_text_start = ABSOLUTE (.)
+ *(.UserExceptionVector.text)
+ .UserExceptionVector.text
+ 0xe8080740 0x6 objs/hikey/int_vector.o
+ 0x9 (size before relaxing)
+ 0xe8080740 OS_UserExceptionVector
+ 0xe8080746 _UserExceptionVector_text_end = ABSOLUTE (.)
+ 0xe8080748 _memmap_seg_iram0_16_end = ALIGN (0x8)
+
+.DoubleExceptionVector.literal
+ 0xe8080778 0x0
+ 0xe8080778 _DoubleExceptionVector_literal_start = ABSOLUTE (.)
+ *(.DoubleExceptionVector.literal)
+ .DoubleExceptionVector.literal
+ 0xe8080778 0x0 objs/hikey/int_vector.o
+ 0x4 (size before relaxing)
+ 0xe8080778 _DoubleExceptionVector_literal_end = ABSOLUTE (.)
+ 0xe8080778 _memmap_seg_iram0_17_end = ALIGN (0x8)
+
+.DoubleExceptionVector.text
+ 0xe80807c0 0x6
+ 0xe80807c0 _DoubleExceptionVector_text_start = ABSOLUTE (.)
+ *(.DoubleExceptionVector.text)
+ .DoubleExceptionVector.text
+ 0xe80807c0 0x6 objs/hikey/int_vector.o
+ 0x9 (size before relaxing)
+ 0xe80807c0 OS_DoubleExceptionVector
+ 0xe80807c6 _DoubleExceptionVector_text_end = ABSOLUTE (.)
+ 0xe80807c8 _memmap_seg_iram0_18_end = ALIGN (0x8)
+
+.Reset.text 0xe8080800 0x23d
+ 0xe8080800 _Reset_text_start = ABSOLUTE (.)
+ *(.Reset.text)
+ .Reset.text 0xe8080800 0x23d objs/hikey/reset.o
+ 0xe8080800 _Reset
+ 0xe8080a3d _Reset_text_end = ABSOLUTE (.)
+
+.iram0.text 0xe8080a40 0x600
+ 0xe8080a40 _iram0_text_start = ABSOLUTE (.)
+ *(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text)
+ .iram0.literal
+ 0xe8080a40 0x44 objs/hikey/int_vector.o
+ 0x88 (size before relaxing)
+ .iram0.literal
+ 0xe8080a84 0x2c objs/hikey/arch_hifi330.o
+ 0x58 (size before relaxing)
+ .iram0.text 0xe8080ab0 0x3b4 objs/hikey/int_vector.o
+ 0x3c0 (size before relaxing)
+ 0xe8080ab0 OS_Panic
+ 0xe8080ad0 OS_UserExc
+ 0xe8080b68 OS_UserExit
+ 0xe8080dc4 OS_Medint2Exit
+ 0xe8080e50 OS_Medint3Exit
+ .iram0.text 0xe8080e64 0x1dc objs/hikey/arch_hifi330.o
+ 0xe8080e64 VOSStartHighRdy
+ 0xe8080e7c VOSCtxSw
+ 0xe8080eac VOSIntCtxSw
+ 0xe8080ecc OSCPUSaveSR
+ 0xe8080ed8 OSCPURestoreSR
+ 0xe8080ee4 OS_TaskSwitch
+ 0xe8080f24 OS_ContextSave
+ 0xe8080f90 OS_ContextRestore
+ 0xe8080fd8 OS_IntEnter
+ 0xe8081008 OS_IntExit
+ 0xe8081020 OS_GetTaskCoprocState
+ 0xe8081040 _iram0_text_end = ABSOLUTE (.)
+ 0xe8081040 _memmap_seg_iram0_19_end = ALIGN (0x8)
+
+.sram.shareaddr
+ 0xc0000000 0x0
+ 0xc0000000 _sram_shareaddr_start = ABSOLUTE (.)
+ *(.sram.shareaddr)
+ 0xc0000000 _sram_shareaddr_end = ABSOLUTE (.)
+
+.sram.rodata 0xc0000000 0x0
+ 0xc0000000 _sram_rodata_start = ABSOLUTE (.)
+ *(.sram.rodata)
+ 0xc0000000 _sram_rodata_end = ABSOLUTE (.)
+
+.rodata 0xc0000000 0x75a0
+ 0xc0000000 _rodata_start = ABSOLUTE (.)
+ *(.rodata)
+ .rodata 0xc0000000 0x84 objs/hikey/dsp_debug.o
+ *fill* 0xc0000084 0xc
+ .rodata 0xc0000090 0x10f objs/hikey/xf-core.o
+ *fill* 0xc000019f 0x1
+ .rodata 0xc00001a0 0x197 objs/hikey/xf-io.o
+ *fill* 0xc0000337 0x9
+ .rodata 0xc0000340 0x1b objs/hikey/xf-mem.o
+ *fill* 0xc000035b 0x5
+ .rodata 0xc0000360 0x30 objs/hikey/xf-msg.o
+ .rodata 0xc0000390 0x1d objs/hikey/xf-sched.o
+ *fill* 0xc00003ad 0x3
+ .rodata 0xc00003b0 0x45 objs/hikey/xa-factory.o
+ *fill* 0xc00003f5 0xb
+ .rodata 0xc0000400 0x4e objs/hikey/xf-shmem.o
+ *fill* 0xc000044e 0x2
+ .rodata 0xc0000450 0x1ec objs/hikey/tinyvprintf.o
+ *fill* 0xc000063c 0x4
+ .rodata 0xc0000640 0x120 objs/hikey/gdbstub.o
+ 0xc0000640 rx
+ 0xc0000644 tx
+ .rodata 0xc0000760 0x140 objs/hikey/xa-class-base.o
+ .rodata 0xc00008a0 0x1e7 objs/hikey/xa-class-audio-codec.o
+ *fill* 0xc0000a87 0x9
+ .rodata 0xc0000a90 0x1d1 objs/hikey/xa-class-mixer.o
+ *fill* 0xc0000c61 0xf
+ .rodata 0xc0000c70 0x15 objs/hikey/xf-main.o
+ *fill* 0xc0000c85 0xb
+ .rodata 0xc0000c90 0x2ed objs/hikey/xa-pcm.o
+ *fill* 0xc0000f7d 0x3
+ .rodata 0xc0000f80 0xc objs/hikey/xa-vorbis-decoder.o
+ *fill* 0xc0000f8c 0x4
+ .rodata 0xc0000f90 0x269 objs/hikey/xa-mixer.o
+ *fill* 0xc00011f9 0x7
+ .rodata 0xc0001200 0x4a54 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o)
+ *(.rodata.*)
+ .rodata.str1.4
+ 0xc0005c54 0x7 objs/hikey/dsp_debug.o
+ *fill* 0xc0005c5b 0x1
+ .rodata.str1.4
+ 0xc0005c5c 0x2e1 objs/hikey/xf-core.o
+ *fill* 0xc0005f3d 0x3
+ .rodata.str1.4
+ 0xc0005f40 0x2fb objs/hikey/xf-io.o
+ 0x363 (size before relaxing)
+ *fill* 0xc000623b 0x1
+ .rodata.str1.4
+ 0xc000623c 0x50 objs/hikey/xf-mem.o
+ 0x8c (size before relaxing)
+ .rodata.str1.4
+ 0xc000628c 0x15 objs/hikey/xf-msg.o
+ 0x49 (size before relaxing)
+ *fill* 0xc00062a1 0x3
+ .rodata.str1.4
+ 0xc00062a4 0x56 objs/hikey/xf-sched.o
+ *fill* 0xc00062fa 0x2
+ .rodata.str1.4
+ 0xc00062fc 0x68 objs/hikey/xa-factory.o
+ 0x70 (size before relaxing)
+ .rodata.str1.4
+ 0xc0006364 0xa8 objs/hikey/xf-shmem.o
+ 0xe4 (size before relaxing)
+ .rodata.str1.4
+ 0xc000640c 0x11 objs/hikey/tinyvprintf.o
+ *fill* 0xc000641d 0x3
+ .rodata.str1.4
+ 0xc0006420 0x3f objs/hikey/gdbstub.o
+ *fill* 0xc000645f 0x1
+ .rodata.str1.4
+ 0xc0006460 0x6b6 objs/hikey/xa-class-base.o
+ 0x6f2 (size before relaxing)
+ *fill* 0xc0006b16 0x2
+ .rodata.str1.4
+ 0xc0006b18 0x41b objs/hikey/xa-class-audio-codec.o
+ 0x517 (size before relaxing)
+ *fill* 0xc0006f33 0x1
+ .rodata.str1.4
+ 0xc0006f34 0x3cf objs/hikey/xa-class-mixer.o
+ 0x58b (size before relaxing)
+ *fill* 0xc0007303 0x1
+ .rodata.str1.4
+ 0xc0007304 0x4c objs/hikey/xf-main.o
+ 0x8c (size before relaxing)
+ .rodata.str1.4
+ 0xc0007350 0x86 objs/hikey/xa-pcm.o
+ 0xc2 (size before relaxing)
+ *fill* 0xc00073d6 0x2
+ .rodata.str1.4
+ 0xc00073d8 0x129 objs/hikey/xa-mixer.o
+ 0x169 (size before relaxing)
+ *fill* 0xc0007501 0x3
+ .rodata.str1.4
+ 0xc0007504 0x8 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o)
+ 0x7 (size before relaxing)
+ *(.gnu.linkonce.r.*)
+ *(.rodata1)
+ 0xc000750c __XT_EXCEPTION_TABLE__ = ABSOLUTE (.)
+ *(.xt_except_table)
+ *(.gcc_except_table)
+ *(.gnu.linkonce.e.*)
+ *(.gnu.version_r)
+ *(.eh_frame)
+ .eh_frame 0xc000750c 0x24 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ .eh_frame 0xc0007530 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ 0x24 (size before relaxing)
+ .eh_frame 0xc0007544 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ 0x24 (size before relaxing)
+ *crtbegin.o(.ctors)
+ *(EXCLUDE_FILE(*crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+ *crtbegin.o(.dtors)
+ *(EXCLUDE_FILE(*crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+ 0xc0007558 __XT_EXCEPTION_DESCS__ = ABSOLUTE (.)
+ *(.xt_except_desc)
+ *(.gnu.linkonce.h.*)
+ 0xc0007558 __XT_EXCEPTION_DESCS_END__ = ABSOLUTE (.)
+ *(.xt_except_desc_end)
+ *(.dynamic)
+ *(.gnu.version_d)
+ 0xc0007558 . = ALIGN (0x4)
+ 0xc0007558 _bss_table_start = ABSOLUTE (.)
+ 0xc0007558 0x4 LONG 0xc0408000 _vlpd_bss_start
+ 0xc000755c 0x4 LONG 0xc0408000 _vlpd_bss_end
+ 0xc0007560 0x4 LONG 0xc0418000 _efr_fr_hr_vlpd_bss_start
+ 0xc0007564 0x4 LONG 0xc0418000 _efr_fr_hr_vlpd_bss_end
+ 0xc0007568 0x4 LONG 0xc0428000 _amr_vlpd_bss_start
+ 0xc000756c 0x4 LONG 0xc0428000 _amr_vlpd_bss_end
+ 0xc0007570 0x4 LONG 0xc0438000 _amrwb_vlpd_bss_start
+ 0xc0007574 0x4 LONG 0xc0438000 _amrwb_vlpd_bss_end
+ 0xc0007578 0x4 LONG 0xc0578000 _ulpp_bss_start
+ 0xc000757c 0x4 LONG 0xc0578000 _ulpp_bss_end
+ 0xc0007580 0x4 LONG 0xc05b8000 _dtsv3_bss_start
+ 0xc0007584 0x4 LONG 0xc05b8000 _dtsv3_bss_end
+ 0xc0007588 0x4 LONG 0xc05d8000 _dtsv4_bss_start
+ 0xc000758c 0x4 LONG 0xc05d8000 _dtsv4_bss_end
+ 0xc0007590 0x4 LONG 0xe8058058 _dram0_bss_start
+ 0xc0007594 0x4 LONG 0xe8058058 _dram0_bss_end
+ 0xc0007598 0x4 LONG 0xc001a300 _bss_start
+ 0xc000759c 0x4 LONG 0xc011b628 _bss_end
+ 0xc00075a0 _bss_table_end = ABSOLUTE (.)
+ 0xc00075a0 _rodata_end = ABSOLUTE (.)
+
+.sram.text 0xc00075a0 0x0
+ 0xc00075a0 _sram_text_start = ABSOLUTE (.)
+ *(.sram.literal .sram.text)
+ 0xc00075a0 _sram_text_end = ABSOLUTE (.)
+
+.text 0xc00075a0 0x12b4c
+ 0xc00075a0 _stext = .
+ 0xc00075a0 _text_start = ABSOLUTE (.)
+ *(.entry.text)
+ *(.init.literal)
+ *(.init)
+ *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
+ .text 0xc00075a0 0xc3 objs/hikey/cpu_c.o
+ 0xd9 (size before relaxing)
+ 0xc00075a4 OS_EnterIntHook
+ 0xc00075bc OS_ExitIntHook
+ 0xc00075d8 OS_UserexecHandler
+ 0xc00075f8 OS_InterruptHandler
+ 0xc0007610 OS_NmiHook
+ 0xc000762c VOS_ConnectInterrupt
+ 0xc000763c VOS_EnableInterrupt
+ 0xc0007658 VOS_DisableInterrupt
+ *fill* 0xc0007663 0x5
+ .text 0xc0007668 0x59a objs/hikey/dsp_debug.o
+ 0x5da (size before relaxing)
+ 0xc0007690 __xprintf
+ 0xc0007b60 dsp_debug_init
+ 0xc0007bd8 print_log
+ *fill* 0xc0007c02 0x6
+ .text 0xc0007c08 0x40 objs/hikey/mutex.o
+ .text 0xc0007c48 0x535 objs/hikey/rbtree.o
+ 0x53d (size before relaxing)
+ 0xc0007c80 rb_first
+ 0xc0007ca0 rb_last
+ 0xc0007cc0 rb_next
+ 0xc0007d00 rb_prev
+ 0xc0007d40 rb_init
+ 0xc0007d54 rb_insert
+ 0xc0007e84 rb_delete
+ 0xc0008138 rb_replace
+ *fill* 0xc000817d 0x3
+ .text 0xc0008180 0x899 objs/hikey/xf-core.o
+ 0xaa4 (size before relaxing)
+ 0xc0008538 xf_msg_submit
+ 0xc00085b4 xf_msg_complete
+ 0xc0008614 xf_core_init
+ 0xc000874c xf_core_service
+ 0xc0008a00 xf_global_init
+ *fill* 0xc0008a19 0x7
+ .text 0xc0008a20 0x79b objs/hikey/xf-io.o
+ 0x88b (size before relaxing)
+ 0xc0008a78 xf_input_port_init
+ 0xc0008b0c xf_input_port_put
+ 0xc0008bf4 xf_input_port_fill
+ 0xc0008c9c xf_input_port_pad
+ 0xc0008cc8 xf_input_port_consume
+ 0xc0008d38 xf_input_port_purge
+ 0xc0008da0 xf_input_port_control_save
+ 0xc0008de8 xf_input_port_purge_done
+ 0xc0008e34 xf_input_port_destroy
+ 0xc0008e84 xf_output_port_init
+ 0xc0008ec4 xf_output_port_route
+ 0xc0008fe0 xf_output_port_unroute_start
+ 0xc0008ff4 xf_output_port_unroute_done
+ 0xc0009020 xf_output_port_unroute
+ 0xc0009088 xf_output_port_put
+ 0xc00090ac xf_output_port_data
+ 0xc00090c0 xf_output_port_produce
+ 0xc00090f0 xf_output_port_flush
+ 0xc0009158 xf_output_port_flush_done
+ 0xc000918c xf_output_port_destroy
+ *fill* 0xc00091bb 0x5
+ .text 0xc00091c0 0x2e0 objs/hikey/xf-mem.o
+ 0x338 (size before relaxing)
+ 0xc000924c xf_mm_alloc
+ 0xc00092ec xf_mm_free
+ 0xc000940c xf_mm_init
+ .text 0xc00094a0 0x153 objs/hikey/xf-msg.o
+ 0x173 (size before relaxing)
+ 0xc00094f0 xf_msg_pool_init
+ 0xc000957c xf_msg_pool_destroy
+ 0xc00095b0 xf_msg_pool_get
+ 0xc00095e8 xf_msg_pool_put
+ *fill* 0xc00095f3 0x5
+ .text 0xc00095f8 0x127 objs/hikey/xf-sched.o
+ 0x14a (size before relaxing)
+ 0xc0009640 xf_sched_put
+ 0xc00096b0 xf_sched_get
+ 0xc00096f8 xf_sched_cancel
+ 0xc0009714 xf_sched_init
+ *fill* 0xc000971f 0x1
+ .text 0xc0009720 0x91 objs/hikey/xa-factory.o
+ 0xa1 (size before relaxing)
+ 0xc000976c xf_component_factory
+ *fill* 0xc00097b1 0x7
+ .text 0xc00097b8 0x532 objs/hikey/xf-shmem.o
+ 0x61a (size before relaxing)
+ 0xc0009a68 xf_shmem_process_queues
+ 0xc0009bd4 xf_msg_proxy_complete
+ 0xc0009c4c xf_shmem_init
+ *fill* 0xc0009cea 0x6
+ .text 0xc0009cf0 0x380 objs/hikey/tinyvprintf.o
+ 0xc0009d0c tiny_vsprintf
+ 0xc000a04c tiny_sprintf
+ .text 0xc000a070 0x108 objs/hikey/xf-isr.o
+ 0x120 (size before relaxing)
+ 0xc000a0b4 xf_msg_schedule_isr
+ 0xc000a11c xf_msg_complete_isr
+ .text 0xc000a178 0xe34 objs/hikey/gdbstub.o
+ 0x100c (size before relaxing)
+ 0xc000a18c init_debug_comm
+ 0xc000a1d4 poll_debug_ring
+ 0xc000a36c getpacket
+ 0xc000aa64 handle_exception
+ 0xc000af5c init_gdbstub
+ *fill* 0xc000afac 0x4
+ .text 0xc000afb0 0x1622 objs/hikey/xa-class-base.o
+ 0x1cea (size before relaxing)
+ 0xc000b0c4 xa_base_set_param
+ 0xc000b82c xa_base_get_param
+ 0xc000b968 xa_base_set_param_ext
+ 0xc000bb80 xa_base_get_param_ext
+ 0xc000c17c xa_base_schedule
+ 0xc000c1d4 xa_base_cancel
+ 0xc000c22c xa_base_destroy
+ 0xc000c2a8 xa_base_factory
+ *fill* 0xc000c5d2 0x6
+ .text 0xc000c5d8 0x14e3 objs/hikey/xa-class-audio-codec.o
+ 0x1afb (size before relaxing)
+ 0xc000da44 xa_audio_codec_factory
+ *fill* 0xc000dabb 0x5
+ .text 0xc000dac0 0x144a objs/hikey/xa-class-mixer.o
+ 0x1aaa (size before relaxing)
+ 0xc000ee98 xa_mixer_factory
+ *fill* 0xc000ef0a 0x6
+ .text 0xc000ef10 0x185 objs/hikey/xf-main.o
+ 0x205 (size before relaxing)
+ 0xc000ef6c xf_ipc_init
+ 0xc000efe8 main
+ *fill* 0xc000f095 0x3
+ .text 0xc000f098 0xf0f objs/hikey/xa-pcm.o
+ 0x13e7 (size before relaxing)
+ 0xc000ff3c xa_pcm_codec
+ *fill* 0xc000ffa7 0x1
+ .text 0xc000ffa8 0x46 objs/hikey/xa-vorbis-decoder.o
+ 0x4e (size before relaxing)
+ 0xc000ffb0 xa_vorbis_decoder
+ *fill* 0xc000ffee 0x2
+ .text 0xc000fff0 0xc77 objs/hikey/xa-mixer.o
+ 0x10cf (size before relaxing)
+ 0xc0010bfc xa_mixer
+ *fill* 0xc0010c67 0x1
+ .literal 0xc0010c68 0x10 objs/hikey/gdbstub-entry.o
+ 0x2c (size before relaxing)
+ .literal 0xc0010c78 0x4 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o)
+ .literal 0xc0010c7c 0x4 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o)
+ .literal 0xc0010c80 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o)
+ 0x4 (size before relaxing)
+ .literal 0xc0010c80 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ .literal 0xc0010c88 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ 0x8 (size before relaxing)
+ .literal 0xc0010c88 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o)
+ 0xc (size before relaxing)
+ .literal 0xc0010c90 0x4 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o)
+ 0x10 (size before relaxing)
+ .literal 0xc0010c94 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o)
+ 0x18 (size before relaxing)
+ .literal 0xc0010c94 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o)
+ 0x4 (size before relaxing)
+ .literal 0xc0010c94 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o)
+ 0x4 (size before relaxing)
+ .literal 0xc0010c94 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ 0x8 (size before relaxing)
+ .literal 0xc0010c94 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ 0x4 (size before relaxing)
+ .literal 0xc0010c94 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ 0x2c (size before relaxing)
+ .literal 0xc0010c9c 0xc /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ 0x1c (size before relaxing)
+ .literal 0xc0010ca8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+ 0xc (size before relaxing)
+ .text 0xc0010ca8 0x138 objs/hikey/gdbstub-entry.o
+ 0xc0010ca8 DebugExceptionEntry
+ 0xc0010dc8 init_debug_entry
+ 0xc0010dd8 breakpoint
+ *fill* 0xc0010de0 0x0
+ .text 0xc0010de0 0x7321 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o)
+ 0x7339 (size before relaxing)
+ 0xc0013ef8 xa_vorbis_dec
+ *fill* 0xc0018101 0x3
+ .text 0xc0018104 0x137 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o)
+ 0xc0018104 xthal_window_spill_nw
+ 0xc0018104 xthal_spill_registers_into_stack_nw
+ 0xc0018218 xthal_window_spill
+ *fill* 0xc001823b 0x1
+ .text 0xc001823c 0x22 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o)
+ 0xc001823c _xtos_ints_on
+ *fill* 0xc001825e 0x2
+ .text 0xc0018260 0x25 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o)
+ 0xc0018260 _xtos_ints_off
+ *fill* 0xc0018285 0x3
+ .text 0xc0018288 0x7c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ 0xc0018288 memchr
+ *fill* 0xc0018304 0x4
+ .text 0xc0018308 0x84 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ 0xc0018308 strncmp
+ .text 0xc001838c 0x2fa /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o)
+ 0xc00183ac __adddf3
+ 0xc0018500 __subdf3
+ *fill* 0xc0018686 0x2
+ .text 0xc0018688 0x1ff /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o)
+ 0xc0018768 __muldf3
+ *fill* 0xc0018887 0x1
+ .text 0xc0018888 0x176 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o)
+ 0xc0018888 __eqdf2
+ 0xc0018888 __nedf2
+ 0xc00188bc __gtdf2
+ 0xc00188e4 __ledf2
+ 0xc0018948 __gedf2
+ 0xc0018970 __ltdf2
+ 0xc00189d4 __unorddf2
+ *fill* 0xc00189fe 0x2
+ .text 0xc0018a00 0x5d /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o)
+ 0xc0018a00 __fixunsdfsi
+ *fill* 0xc0018a5d 0x3
+ .text 0xc0018a60 0x75 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o)
+ 0xc0018a60 __fixunsdfdi
+ *fill* 0xc0018ad5 0x3
+ .text 0xc0018ad8 0xa3 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ 0xc0018ad8 __vec_memcpy
+ *fill* 0xc0018b7b 0x5
+ .text 0xc0018b80 0x71 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ 0xc0018b80 __vec_memset
+ *fill* 0xc0018bf1 0x7
+ .text 0xc0018bf8 0x318 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ 0xc0018bf8 __divdf3
+ .text 0xc0018f10 0x29a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ 0xc0018f10 __propagateFloat64NaN
+ 0xc00190c0 __roundAndPackFloat64
+ *fill* 0xc00191aa 0x6
+ .text 0xc00191b0 0x6d /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+ 0xc00191b0 __estimateDiv64To32
+ *fill* 0xc001921d 0x3
+ .literal 0xc0019220 0x0 objs/hikey/cpu_c.o
+ *fill* 0xc0019220 0x0
+ .literal 0xc0019220 0x0 objs/hikey/dsp_debug.o
+ *fill* 0xc0019220 0x0
+ *fill* 0xc0019220 0x0
+ .literal 0xc0019220 0x0 objs/hikey/dsp_comm.o
+ *fill* 0xc0019220 0x0
+ .text 0xc0019220 0xda objs/hikey/dsp_comm.o
+ 0xc0019220 dsp_memcpy
+ 0xc00192a0 dsp_memset
+ 0xc00192d4 division
+ *fill* 0xc00192fa 0x2
+ .literal 0xc00192fc 0x0 objs/hikey/mutex.o
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/rbtree.o
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xf-core.o
+ .literal 0xc00192fc 0x0 objs/hikey/xf-io.o
+ *fill* 0xc00192fc 0x0
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xf-mem.o
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xf-msg.o
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xf-sched.o
+ *fill* 0xc00192fc 0x0
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xa-factory.o
+ *fill* 0xc00192fc 0x0
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xf-shmem.o
+ *fill* 0xc00192fc 0x0
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/tinyvprintf.o
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xf-isr.o
+ .literal 0xc00192fc 0x0 objs/hikey/gdbstub.o
+ .literal 0xc00192fc 0x0 objs/hikey/xa-class-base.o
+ *fill* 0xc00192fc 0x0
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xa-class-audio-codec.o
+ *fill* 0xc00192fc 0x0
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xa-class-mixer.o
+ *fill* 0xc00192fc 0x0
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xf-main.o
+ *fill* 0xc00192fc 0x0
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xa-pcm.o
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xa-vorbis-decoder.o
+ *fill* 0xc00192fc 0x0
+ .literal 0xc00192fc 0x0 objs/hikey/xa-mixer.o
+ .text 0xc00192fc 0x0 objs/hikey/reset.o
+ .text 0xc00192fc 0x0 objs/hikey/int_vector.o
+ .text 0xc00192fc 0x0 objs/hikey/arch_hifi330.o
+ *fill* 0xc00192fc 0x0
+ *fill* 0xc00192fc 0x0
+ *fill* 0xc00192fc 0x0
+ *fill* 0xc00192fc 0x4
+ .text 0xc0019300 0x1c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o)
+ 0xc0019300 xthal_dcache_region_invalidate
+ *fill* 0xc001931c 0x4
+ .text 0xc0019320 0x1c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o)
+ 0xc0019320 xthal_dcache_region_writeback
+ .text 0xc001933c 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid0.o)
+ .text 0xc001933c 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid1.o)
+ .text 0xc001933c 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_major.o)
+ .text 0xc001933c 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_minor.o)
+ .text 0xc001933c 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o)
+ 0xc001933c xthal_get_intenable
+ .text 0xc0019344 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o)
+ 0xc0019344 xthal_set_intenable
+ .text 0xc001934c 0x2a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o)
+ 0xc001934c xthal_restore_extra_nw
+ *fill* 0xc0019376 0x2
+ .text 0xc0019378 0x2a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o)
+ 0xc0019378 xthal_save_extra_nw
+ *fill* 0xc00193a2 0x0
+ *fill* 0xc00193a2 0x0
+ *fill* 0xc00193a2 0x2
+ .text 0xc00193a4 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o)
+ 0xc00193a4 _xtos_unhandled_interrupt
+ *fill* 0xc00193ac 0x4
+ .text 0xc00193b0 0x45 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o)
+ 0xc00193b0 memcmp
+ *fill* 0xc00193f5 0x3
+ .text 0xc00193f8 0x138 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o)
+ 0xc001943c memcpy
+ .text 0xc0019530 0x78 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o)
+ 0xc001955c memset
+ .literal 0xc00195a8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ .text 0xc00195a8 0x338 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ 0xc001962c qsort
+ .text 0xc00198e0 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o)
+ 0xc00198e0 __divsi3
+ .text 0xc00198e8 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o)
+ 0xc00198e8 __modsi3
+ *fill* 0xc00198f0 0x0
+ *fill* 0xc00198f0 0x0
+ *fill* 0xc00198f0 0x0
+ *fill* 0xc00198f0 0x0
+ *fill* 0xc00198f0 0x0
+ .text 0xc00198f0 0x3e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o)
+ 0xc00198f0 __floatunsidf
+ 0xc00198fc __floatsidf
+ *fill* 0xc001992e 0x2
+ .text 0xc0019930 0x84 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o)
+ 0xc0019930 __floatundidf
+ 0xc0019940 __floatdidf
+ *fill* 0xc00199b4 0x4
+ .text 0xc00199b8 0x271 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ 0xc00199b8 __divdi3
+ *fill* 0xc0019c29 0x7
+ .text 0xc0019c30 0x24c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ 0xc0019c30 __udivdi3
+ *fill* 0xc0019e7c 0x4
+ .text 0xc0019e80 0x26c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ 0xc0019e80 __umoddi3
+ *fill* 0xc001a0ec 0x0
+ *fill* 0xc001a0ec 0x0
+ *fill* 0xc001a0ec 0x0
+ *fill* 0xc001a0ec 0x0
+ *fill* 0xc001a0ec 0x0
+ *(.fini.literal)
+ *(.fini)
+ *(.gnu.version)
+ 0xc001a0ec _text_end = ABSOLUTE (.)
+ 0xc001a0ec _etext = .
+
+.sram.data 0xc001a0ec 0x0
+ 0xc001a0ec _sram_data_start = ABSOLUTE (.)
+ *(.sram.data)
+ 0xc001a0ec _sram_data_end = ABSOLUTE (.)
+
+.data 0xc001a0f0 0x208
+ 0xc001a0f0 _data_start = ABSOLUTE (.)
+ *(.data)
+ .data 0xc001a0f0 0x0 objs/hikey/cpu_c.o
+ .data 0xc001a0f0 0x0 objs/hikey/dsp_debug.o
+ .data 0xc001a0f0 0x0 objs/hikey/dsp_comm.o
+ .data 0xc001a0f0 0x0 objs/hikey/mutex.o
+ .data 0xc001a0f0 0x0 objs/hikey/rbtree.o
+ .data 0xc001a0f0 0x0 objs/hikey/xf-core.o
+ .data 0xc001a0f0 0x0 objs/hikey/xf-io.o
+ .data 0xc001a0f0 0x0 objs/hikey/xf-mem.o
+ .data 0xc001a0f0 0x0 objs/hikey/xf-msg.o
+ .data 0xc001a0f0 0x0 objs/hikey/xf-sched.o
+ .data 0xc001a0f0 0x0 objs/hikey/xa-factory.o
+ .data 0xc001a0f0 0x0 objs/hikey/xf-shmem.o
+ .data 0xc001a0f0 0x0 objs/hikey/tinyvprintf.o
+ .data 0xc001a0f0 0x0 objs/hikey/xf-isr.o
+ .data 0xc001a0f0 0x0 objs/hikey/gdbstub.o
+ .data 0xc001a0f0 0x0 objs/hikey/xa-class-base.o
+ .data 0xc001a0f0 0x0 objs/hikey/xa-class-audio-codec.o
+ .data 0xc001a0f0 0x0 objs/hikey/xa-class-mixer.o
+ .data 0xc001a0f0 0x0 objs/hikey/xf-main.o
+ .data 0xc001a0f0 0x0 objs/hikey/xa-pcm.o
+ .data 0xc001a0f0 0x0 objs/hikey/xa-vorbis-decoder.o
+ .data 0xc001a0f0 0x0 objs/hikey/xa-mixer.o
+ .data 0xc001a0f0 0x0 objs/hikey/reset.o
+ .data 0xc001a0f0 0x0 objs/hikey/int_vector.o
+ .data 0xc001a0f0 0x0 objs/hikey/arch_hifi330.o
+ .data 0xc001a0f0 0x0 objs/hikey/gdbstub-entry.o
+ .data 0xc001a0f0 0x0 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid0.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid1.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_major.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_minor.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o)
+ .data 0xc001a0f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o)
+ .data 0xc001a0f0 0x208 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o)
+ 0xc001a0f0 _xtos_enabled
+ 0xc001a0f0 _xtos_intstruct
+ 0xc001a0f4 _xtos_vpri_enabled
+ 0xc001a0f8 _xtos_interrupt_table
+ 0xc001a1f8 _xtos_interrupt_mask_table
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ .data 0xc001a2f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+ *(.data.*)
+ *(.gnu.linkonce.d.*)
+ *(.gnu.linkonce.d.*personality*)
+ *(.data1)
+ *(.sdata)
+ *(.sdata.*)
+ *(.gnu.linkonce.s.*)
+ *(.sdata2)
+ *(.sdata2.*)
+ *(.gnu.linkonce.s2.*)
+ *(.jcr)
+ 0xc001a2f8 _data_end = ABSOLUTE (.)
+
+.sram.uninit 0xc001a2f8 0x0
+ 0xc001a2f8 _sram_uninit_start = ABSOLUTE (.)
+ *(.sram.uninit)
+ 0xc001a2f8 _sram_uninit_end = ABSOLUTE (.)
+
+.bss 0xc001a300 0x101328
+ 0xc001a300 . = ALIGN (0x8)
+ 0xc001a300 _bss_start = ABSOLUTE (.)
+ *(.dynsbss)
+ *(.sbss)
+ *(.sbss.*)
+ *(.gnu.linkonce.sb.*)
+ *(.scommon)
+ *(.sbss2)
+ *(.sbss2.*)
+ *(.gnu.linkonce.sb2.*)
+ *(.dynbss)
+ *(.bss)
+ .bss 0xc001a300 0xb0 objs/hikey/cpu_c.o
+ 0xc001a300 g_ucVosIntNesting
+ 0xc001a301 g_ucVosPrioCur
+ 0xc001a302 g_ucVosPrioHighRdy
+ 0xc001a304 g_bVosRunning
+ 0xc001a308 g_pstVosTCBHighRdy
+ 0xc001a30c g_pstVosTCBCur
+ 0xc001a310 g_pfVosHookFuncTable
+ 0xc001a330 g_pfVosIntrFuncTable
+ .bss 0xc001a3b0 0x4 objs/hikey/dsp_debug.o
+ .bss 0xc001a3b4 0x0 objs/hikey/dsp_comm.o
+ .bss 0xc001a3b4 0x0 objs/hikey/mutex.o
+ .bss 0xc001a3b4 0x0 objs/hikey/rbtree.o
+ .bss 0xc001a3b4 0x0 objs/hikey/xf-core.o
+ .bss 0xc001a3b4 0x0 objs/hikey/xf-io.o
+ .bss 0xc001a3b4 0x0 objs/hikey/xf-mem.o
+ .bss 0xc001a3b4 0x0 objs/hikey/xf-msg.o
+ .bss 0xc001a3b4 0x0 objs/hikey/xf-sched.o
+ .bss 0xc001a3b4 0x0 objs/hikey/xa-factory.o
+ .bss 0xc001a3b4 0x0 objs/hikey/xf-shmem.o
+ .bss 0xc001a3b4 0x0 objs/hikey/tinyvprintf.o
+ .bss 0xc001a3b4 0x0 objs/hikey/xf-isr.o
+ *fill* 0xc001a3b4 0xc
+ .bss 0xc001a3c0 0xb70 objs/hikey/gdbstub.o
+ 0xc001a3c0 mem_err
+ 0xc001a530 sregs
+ 0xc001aa30 aregs
+ 0xc001ab30 stack
+ .bss 0xc001af30 0x0 objs/hikey/xa-class-base.o
+ .bss 0xc001af30 0x0 objs/hikey/xa-class-audio-codec.o
+ .bss 0xc001af30 0x0 objs/hikey/xa-class-mixer.o
+ *fill* 0xc001af30 0x50
+ .bss 0xc001af80 0x1006a8 objs/hikey/xf-main.o
+ 0xc001af80 xf_dsp_local_buffer
+ 0xc011b2c0 waitstate
+ 0xc011b2c8 prof
+ 0xc011b318 xf_ap_shmem_pool
+ 0xc011b340 xf_core_data
+ 0xc011b500 xf_core_rw_data
+ 0xc011b580 xf_core_ro_data
+ 0xc011b600 xf_dsp_local_pool
+ .bss 0xc011b628 0x0 objs/hikey/xa-pcm.o
+ .bss 0xc011b628 0x0 objs/hikey/xa-vorbis-decoder.o
+ .bss 0xc011b628 0x0 objs/hikey/xa-mixer.o
+ .bss 0xc011b628 0x0 objs/hikey/reset.o
+ .bss 0xc011b628 0x0 objs/hikey/int_vector.o
+ .bss 0xc011b628 0x0 objs/hikey/arch_hifi330.o
+ .bss 0xc011b628 0x0 objs/hikey/gdbstub-entry.o
+ .bss 0xc011b628 0x0 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid0.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid1.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_major.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_minor.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ .bss 0xc011b628 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+ *(.bss.*)
+ *(.gnu.linkonce.b.*)
+ *(COMMON)
+ *(.sram.pool.bss)
+ *(.sram.bss)
+ 0xc011b628 . = ALIGN (0x8)
+ 0xc011b628 _bss_end = ABSOLUTE (.)
+ 0xc011b628 _memmap_seg_sram0_end = ALIGN (0x8)
+
+.debug
+ *(.debug)
+
+.line
+ *(.line)
+
+.debug_srcinfo
+ *(.debug_srcinfo)
+
+.debug_sfnames
+ *(.debug_sfnames)
+
+.debug_aranges 0x00000000 0x7b0
+ *(.debug_aranges)
+ .debug_aranges
+ 0x00000000 0x20 objs/hikey/cpu_c.o
+ .debug_aranges
+ 0x00000020 0x20 objs/hikey/dsp_debug.o
+ .debug_aranges
+ 0x00000040 0x20 objs/hikey/dsp_comm.o
+ .debug_aranges
+ 0x00000060 0x20 objs/hikey/mutex.o
+ .debug_aranges
+ 0x00000080 0x20 objs/hikey/rbtree.o
+ .debug_aranges
+ 0x000000a0 0x20 objs/hikey/xf-core.o
+ .debug_aranges
+ 0x000000c0 0x20 objs/hikey/xf-io.o
+ .debug_aranges
+ 0x000000e0 0x20 objs/hikey/xf-mem.o
+ .debug_aranges
+ 0x00000100 0x20 objs/hikey/xf-msg.o
+ .debug_aranges
+ 0x00000120 0x20 objs/hikey/xf-sched.o
+ .debug_aranges
+ 0x00000140 0x20 objs/hikey/xa-factory.o
+ .debug_aranges
+ 0x00000160 0x20 objs/hikey/xf-shmem.o
+ .debug_aranges
+ 0x00000180 0x20 objs/hikey/tinyvprintf.o
+ .debug_aranges
+ 0x000001a0 0x20 objs/hikey/xf-isr.o
+ .debug_aranges
+ 0x000001c0 0x20 objs/hikey/gdbstub.o
+ .debug_aranges
+ 0x000001e0 0x20 objs/hikey/xa-class-base.o
+ .debug_aranges
+ 0x00000200 0x20 objs/hikey/xa-class-audio-codec.o
+ .debug_aranges
+ 0x00000220 0x20 objs/hikey/xa-class-mixer.o
+ .debug_aranges
+ 0x00000240 0x20 objs/hikey/xf-main.o
+ .debug_aranges
+ 0x00000260 0x20 objs/hikey/xa-pcm.o
+ .debug_aranges
+ 0x00000280 0x20 objs/hikey/xa-vorbis-decoder.o
+ .debug_aranges
+ 0x000002a0 0x20 objs/hikey/xa-mixer.o
+ .debug_aranges
+ 0x000002c0 0x28 objs/hikey/reset.o
+ .debug_aranges
+ 0x000002e8 0x60 objs/hikey/int_vector.o
+ .debug_aranges
+ 0x00000348 0x20 objs/hikey/arch_hifi330.o
+ .debug_aranges
+ 0x00000368 0x28 objs/hikey/gdbstub-entry.o
+ .debug_aranges
+ 0x00000390 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o)
+ .debug_aranges
+ 0x000003b0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o)
+ .debug_aranges
+ 0x000003d0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o)
+ .debug_aranges
+ 0x000003f0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o)
+ .debug_aranges
+ 0x00000410 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o)
+ .debug_aranges
+ 0x00000430 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o)
+ .debug_aranges
+ 0x00000450 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o)
+ .debug_aranges
+ 0x00000470 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o)
+ .debug_aranges
+ 0x00000490 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o)
+ .debug_aranges
+ 0x000004b0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o)
+ .debug_aranges
+ 0x000004d0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ .debug_aranges
+ 0x000004f0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o)
+ .debug_aranges
+ 0x00000510 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o)
+ .debug_aranges
+ 0x00000530 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o)
+ .debug_aranges
+ 0x00000550 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ .debug_aranges
+ 0x00000570 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ .debug_aranges
+ 0x00000590 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o)
+ .debug_aranges
+ 0x000005b0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o)
+ .debug_aranges
+ 0x000005d0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o)
+ .debug_aranges
+ 0x000005f0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o)
+ .debug_aranges
+ 0x00000610 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o)
+ .debug_aranges
+ 0x00000630 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o)
+ .debug_aranges
+ 0x00000650 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o)
+ .debug_aranges
+ 0x00000670 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o)
+ .debug_aranges
+ 0x00000690 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o)
+ .debug_aranges
+ 0x000006b0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ .debug_aranges
+ 0x000006d0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ .debug_aranges
+ 0x000006f0 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ .debug_aranges
+ 0x00000710 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ .debug_aranges
+ 0x00000730 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ .debug_aranges
+ 0x00000750 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ .debug_aranges
+ 0x00000770 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ .debug_aranges
+ 0x00000790 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+
+.debug_pubnames
+ 0x00000000 0xb7d
+ *(.debug_pubnames)
+ .debug_pubnames
+ 0x00000000 0x16f objs/hikey/cpu_c.o
+ .debug_pubnames
+ 0x0000016f 0x41 objs/hikey/dsp_debug.o
+ .debug_pubnames
+ 0x000001b0 0x3d objs/hikey/dsp_comm.o
+ .debug_pubnames
+ 0x000001ed 0x7a objs/hikey/rbtree.o
+ .debug_pubnames
+ 0x00000267 0x70 objs/hikey/xf-core.o
+ .debug_pubnames
+ 0x000002d7 0x21d objs/hikey/xf-io.o
+ .debug_pubnames
+ 0x000004f4 0x40 objs/hikey/xf-mem.o
+ .debug_pubnames
+ 0x00000534 0x67 objs/hikey/xf-msg.o
+ .debug_pubnames
+ 0x0000059b 0x5a objs/hikey/xf-sched.o
+ .debug_pubnames
+ 0x000005f5 0x2b objs/hikey/xa-factory.o
+ .debug_pubnames
+ 0x00000620 0x5a objs/hikey/xf-shmem.o
+ .debug_pubnames
+ 0x0000067a 0x35 objs/hikey/tinyvprintf.o
+ .debug_pubnames
+ 0x000006af 0x42 objs/hikey/xf-isr.o
+ .debug_pubnames
+ 0x000006f1 0xa6 objs/hikey/gdbstub.o
+ .debug_pubnames
+ 0x00000797 0xc2 objs/hikey/xa-class-base.o
+ .debug_pubnames
+ 0x00000859 0x2d objs/hikey/xa-class-audio-codec.o
+ .debug_pubnames
+ 0x00000886 0x27 objs/hikey/xa-class-mixer.o
+ .debug_pubnames
+ 0x000008ad 0xbe objs/hikey/xf-main.o
+ .debug_pubnames
+ 0x0000096b 0x23 objs/hikey/xa-pcm.o
+ .debug_pubnames
+ 0x0000098e 0x28 objs/hikey/xa-vorbis-decoder.o
+ .debug_pubnames
+ 0x000009b6 0x1f objs/hikey/xa-mixer.o
+ .debug_pubnames
+ 0x000009d5 0x1d /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ .debug_pubnames
+ 0x000009f2 0x1d /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o)
+ .debug_pubnames
+ 0x00000a0f 0x1c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ .debug_pubnames
+ 0x00000a2b 0x1e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ .debug_pubnames
+ 0x00000a49 0x1f /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ .debug_pubnames
+ 0x00000a68 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ .debug_pubnames
+ 0x00000a88 0x20 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ .debug_pubnames
+ 0x00000aa8 0x23 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ .debug_pubnames
+ 0x00000acb 0x23 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ .debug_pubnames
+ 0x00000aee 0x1f /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ .debug_pubnames
+ 0x00000b0d 0x46 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ .debug_pubnames
+ 0x00000b53 0x2a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+
+.debug_info 0x00000000 0x18e3c
+ *(.debug_info)
+ .debug_info 0x00000000 0x516 objs/hikey/cpu_c.o
+ .debug_info 0x00000516 0x3c2 objs/hikey/dsp_debug.o
+ .debug_info 0x000008d8 0x208 objs/hikey/dsp_comm.o
+ .debug_info 0x00000ae0 0xbd5 objs/hikey/mutex.o
+ .debug_info 0x000016b5 0xf10 objs/hikey/rbtree.o
+ .debug_info 0x000025c5 0x16ac objs/hikey/xf-core.o
+ .debug_info 0x00003c71 0x1826 objs/hikey/xf-io.o
+ .debug_info 0x00005497 0xef6 objs/hikey/xf-mem.o
+ .debug_info 0x0000638d 0xdc1 objs/hikey/xf-msg.o
+ .debug_info 0x0000714e 0xdf5 objs/hikey/xf-sched.o
+ .debug_info 0x00007f43 0xdfd objs/hikey/xa-factory.o
+ .debug_info 0x00008d40 0x1353 objs/hikey/xf-shmem.o
+ .debug_info 0x0000a093 0x2d0 objs/hikey/tinyvprintf.o
+ .debug_info 0x0000a363 0xc73 objs/hikey/xf-isr.o
+ .debug_info 0x0000afd6 0xa47 objs/hikey/gdbstub.o
+ .debug_info 0x0000ba1d 0x1c9b objs/hikey/xa-class-base.o
+ .debug_info 0x0000d6b8 0x1fe2 objs/hikey/xa-class-audio-codec.o
+ .debug_info 0x0000f69a 0x21c9 objs/hikey/xa-class-mixer.o
+ .debug_info 0x00011863 0x1203 objs/hikey/xf-main.o
+ .debug_info 0x00012a66 0x1841 objs/hikey/xa-pcm.o
+ .debug_info 0x000142a7 0x1f6 objs/hikey/xa-vorbis-decoder.o
+ .debug_info 0x0001449d 0x12e9 objs/hikey/xa-mixer.o
+ .debug_info 0x00015786 0x95 objs/hikey/reset.o
+ .debug_info 0x0001581b 0x9a objs/hikey/int_vector.o
+ .debug_info 0x000158b5 0xa0 objs/hikey/arch_hifi330.o
+ .debug_info 0x00015955 0x9c objs/hikey/gdbstub-entry.o
+ .debug_info 0x000159f1 0xdf /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o)
+ .debug_info 0x00015ad0 0xd9 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o)
+ .debug_info 0x00015ba9 0xd9 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o)
+ .debug_info 0x00015c82 0xd7 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o)
+ .debug_info 0x00015d59 0xd7 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o)
+ .debug_info 0x00015e30 0xd9 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o)
+ .debug_info 0x00015f09 0xd9 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o)
+ .debug_info 0x00015fe2 0xd9 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o)
+ .debug_info 0x000160bb 0xda /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o)
+ .debug_info 0x00016195 0xe1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o)
+ .debug_info 0x00016276 0x22e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ .debug_info 0x000164a4 0x20a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o)
+ .debug_info 0x000166ae 0x11c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o)
+ .debug_info 0x000167ca 0x11c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o)
+ .debug_info 0x000168e6 0x399 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ .debug_info 0x00016c7f 0x204 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ .debug_info 0x00016e83 0xf7 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o)
+ .debug_info 0x00016f7a 0xf7 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o)
+ .debug_info 0x00017071 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o)
+ .debug_info 0x00017167 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o)
+ .debug_info 0x0001725d 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o)
+ .debug_info 0x00017353 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o)
+ .debug_info 0x00017449 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o)
+ .debug_info 0x0001753f 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o)
+ .debug_info 0x00017635 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o)
+ .debug_info 0x0001772b 0x2b1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ .debug_info 0x000179dc 0x26e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ .debug_info 0x00017c4a 0x278 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ .debug_info 0x00017ec2 0x2c3 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ .debug_info 0x00018185 0x28b /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ .debug_info 0x00018410 0x3a7 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ .debug_info 0x000187b7 0x3ae /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ .debug_info 0x00018b65 0x2d7 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+
+.debug_abbrev 0x00000000 0x2ee0
+ *(.debug_abbrev)
+ .debug_abbrev 0x00000000 0xcd objs/hikey/cpu_c.o
+ .debug_abbrev 0x000000cd 0x156 objs/hikey/dsp_debug.o
+ .debug_abbrev 0x00000223 0xa2 objs/hikey/dsp_comm.o
+ .debug_abbrev 0x000002c5 0x140 objs/hikey/mutex.o
+ .debug_abbrev 0x00000405 0x201 objs/hikey/rbtree.o
+ .debug_abbrev 0x00000606 0x28c objs/hikey/xf-core.o
+ .debug_abbrev 0x00000892 0x255 objs/hikey/xf-io.o
+ .debug_abbrev 0x00000ae7 0x1ff objs/hikey/xf-mem.o
+ .debug_abbrev 0x00000ce6 0x1d3 objs/hikey/xf-msg.o
+ .debug_abbrev 0x00000eb9 0x1b2 objs/hikey/xf-sched.o
+ .debug_abbrev 0x0000106b 0x17d objs/hikey/xa-factory.o
+ .debug_abbrev 0x000011e8 0x1f8 objs/hikey/xf-shmem.o
+ .debug_abbrev 0x000013e0 0xf6 objs/hikey/tinyvprintf.o
+ .debug_abbrev 0x000014d6 0x184 objs/hikey/xf-isr.o
+ .debug_abbrev 0x0000165a 0x282 objs/hikey/gdbstub.o
+ .debug_abbrev 0x000018dc 0x269 objs/hikey/xa-class-base.o
+ .debug_abbrev 0x00001b45 0x20b objs/hikey/xa-class-audio-codec.o
+ .debug_abbrev 0x00001d50 0x20b objs/hikey/xa-class-mixer.o
+ .debug_abbrev 0x00001f5b 0x1b3 objs/hikey/xf-main.o
+ .debug_abbrev 0x0000210e 0x1aa objs/hikey/xa-pcm.o
+ .debug_abbrev 0x000022b8 0xa4 objs/hikey/xa-vorbis-decoder.o
+ .debug_abbrev 0x0000235c 0x1cc objs/hikey/xa-mixer.o
+ .debug_abbrev 0x00002528 0x12 objs/hikey/reset.o
+ .debug_abbrev 0x0000253a 0x12 objs/hikey/int_vector.o
+ .debug_abbrev 0x0000254c 0x14 objs/hikey/arch_hifi330.o
+ .debug_abbrev 0x00002560 0x12 objs/hikey/gdbstub-entry.o
+ .debug_abbrev 0x00002572 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o)
+ .debug_abbrev 0x00002586 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o)
+ .debug_abbrev 0x0000259a 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o)
+ .debug_abbrev 0x000025ae 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o)
+ .debug_abbrev 0x000025c2 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o)
+ .debug_abbrev 0x000025d6 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o)
+ .debug_abbrev 0x000025ea 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o)
+ .debug_abbrev 0x000025fe 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o)
+ .debug_abbrev 0x00002612 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o)
+ .debug_abbrev 0x00002626 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o)
+ .debug_abbrev 0x0000263a 0x8e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ .debug_abbrev 0x000026c8 0x85 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o)
+ .debug_abbrev 0x0000274d 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o)
+ .debug_abbrev 0x00002761 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o)
+ .debug_abbrev 0x00002775 0xcf /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ .debug_abbrev 0x00002844 0x80 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ .debug_abbrev 0x000028c4 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o)
+ .debug_abbrev 0x000028d8 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o)
+ .debug_abbrev 0x000028ec 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o)
+ .debug_abbrev 0x00002900 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o)
+ .debug_abbrev 0x00002914 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o)
+ .debug_abbrev 0x00002928 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o)
+ .debug_abbrev 0x0000293c 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o)
+ .debug_abbrev 0x00002950 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o)
+ .debug_abbrev 0x00002964 0x14 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o)
+ .debug_abbrev 0x00002978 0xbd /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ .debug_abbrev 0x00002a35 0xa1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ .debug_abbrev 0x00002ad6 0xae /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ .debug_abbrev 0x00002b84 0xa3 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ .debug_abbrev 0x00002c27 0x82 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ .debug_abbrev 0x00002ca9 0xbb /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ .debug_abbrev 0x00002d64 0xd0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ .debug_abbrev 0x00002e34 0xac /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+
+.debug_line 0x00000000 0xd0d8
+ *(.debug_line)
+ .debug_line 0x00000000 0x14b objs/hikey/cpu_c.o
+ .debug_line 0x0000014b 0x433 objs/hikey/dsp_debug.o
+ .debug_line 0x0000057e 0x105 objs/hikey/dsp_comm.o
+ .debug_line 0x00000683 0x1fc objs/hikey/mutex.o
+ .debug_line 0x0000087f 0x8f3 objs/hikey/rbtree.o
+ .debug_line 0x00001172 0x8a9 objs/hikey/xf-core.o
+ .debug_line 0x00001a1b 0xb08 objs/hikey/xf-io.o
+ .debug_line 0x00002523 0x4c3 objs/hikey/xf-mem.o
+ .debug_line 0x000029e6 0x2cf objs/hikey/xf-msg.o
+ .debug_line 0x00002cb5 0x32f objs/hikey/xf-sched.o
+ .debug_line 0x00002fe4 0x233 objs/hikey/xa-factory.o
+ .debug_line 0x00003217 0x70b objs/hikey/xf-shmem.o
+ .debug_line 0x00003922 0x268 objs/hikey/tinyvprintf.o
+ .debug_line 0x00003b8a 0x33e objs/hikey/xf-isr.o
+ .debug_line 0x00003ec8 0x9d7 objs/hikey/gdbstub.o
+ .debug_line 0x0000489f 0x92f objs/hikey/xa-class-base.o
+ .debug_line 0x000051ce 0xb85 objs/hikey/xa-class-audio-codec.o
+ .debug_line 0x00005d53 0xcd5 objs/hikey/xa-class-mixer.o
+ .debug_line 0x00006a28 0x2e7 objs/hikey/xf-main.o
+ .debug_line 0x00006d0f 0xbd0 objs/hikey/xa-pcm.o
+ .debug_line 0x000078df 0x145 objs/hikey/xa-vorbis-decoder.o
+ .debug_line 0x00007a24 0x94f objs/hikey/xa-mixer.o
+ .debug_line 0x00008373 0x36b objs/hikey/reset.o
+ .debug_line 0x000086de 0x7f7 objs/hikey/int_vector.o
+ .debug_line 0x00008ed5 0x463 objs/hikey/arch_hifi330.o
+ .debug_line 0x00009338 0x293 objs/hikey/gdbstub-entry.o
+ .debug_line 0x000095cb 0x337 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o)
+ .debug_line 0x00009902 0x91 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o)
+ .debug_line 0x00009993 0x91 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o)
+ .debug_line 0x00009a24 0x8e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o)
+ .debug_line 0x00009ab2 0x8f /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o)
+ .debug_line 0x00009b41 0x8a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o)
+ .debug_line 0x00009bcb 0x8a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o)
+ .debug_line 0x00009c55 0xc5 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o)
+ .debug_line 0x00009d1a 0xcc /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o)
+ .debug_line 0x00009de6 0x98 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o)
+ .debug_line 0x00009e7e 0x10f /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ .debug_line 0x00009f8d 0xf6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o)
+ .debug_line 0x0000a083 0x363 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o)
+ .debug_line 0x0000a3e6 0x19a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o)
+ .debug_line 0x0000a580 0x25a /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ .debug_line 0x0000a7da 0x110 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ .debug_line 0x0000a8ea 0xa9 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o)
+ .debug_line 0x0000a993 0xa8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o)
+ .debug_line 0x0000aa3b 0x6d1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o)
+ .debug_line 0x0000b10c 0x4c4 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o)
+ .debug_line 0x0000b5d0 0x3bf /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o)
+ .debug_line 0x0000b98f 0x167 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o)
+ .debug_line 0x0000baf6 0x191 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o)
+ .debug_line 0x0000bc87 0x119 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o)
+ .debug_line 0x0000bda0 0x1af /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o)
+ .debug_line 0x0000bf4f 0x1e3 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ .debug_line 0x0000c132 0x1c4 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ .debug_line 0x0000c2f6 0x220 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ .debug_line 0x0000c516 0x13d /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ .debug_line 0x0000c653 0x137 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ .debug_line 0x0000c78a 0x46e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ .debug_line 0x0000cbf8 0x36e /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ .debug_line 0x0000cf66 0x172 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+
+.debug_frame
+ *(.debug_frame)
+
+.debug_str
+ *(.debug_str)
+
+.debug_loc
+ *(.debug_loc)
+
+.debug_macinfo
+ *(.debug_macinfo)
+
+.debug_weaknames
+ *(.debug_weaknames)
+
+.debug_funcnames
+ *(.debug_funcnames)
+
+.debug_typenames
+ *(.debug_typenames)
+
+.debug_varnames
+ *(.debug_varnames)
+
+.xt.insn
+ *(.xt.insn)
+ *(.gnu.linkonce.x.*)
+
+.xt.prop 0x00000000 0xe8ec
+ *(.xt.prop)
+ .xt.prop 0x00000000 0x15c objs/hikey/cpu_c.o
+ 0x1ec (size before relaxing)
+ .xt.prop 0x0000015c 0x570 objs/hikey/dsp_debug.o
+ 0x594 (size before relaxing)
+ .xt.prop 0x000006cc 0x84 objs/hikey/dsp_comm.o
+ .xt.prop 0x00000750 0x3c objs/hikey/mutex.o
+ 0x48 (size before relaxing)
+ .xt.prop 0x0000078c 0x6e4 objs/hikey/rbtree.o
+ 0x6f0 (size before relaxing)
+ .xt.prop 0x00000e70 0x624 objs/hikey/xf-core.o
+ 0x6e4 (size before relaxing)
+ .xt.prop 0x00001494 0x7b0 objs/hikey/xf-io.o
+ 0x894 (size before relaxing)
+ .xt.prop 0x00001c44 0x354 objs/hikey/xf-mem.o
+ 0x390 (size before relaxing)
+ .xt.prop 0x00001f98 0x12c objs/hikey/xf-msg.o
+ 0x15c (size before relaxing)
+ .xt.prop 0x000020c4 0x150 objs/hikey/xf-sched.o
+ 0x18c (size before relaxing)
+ .xt.prop 0x00002214 0x9c objs/hikey/xa-factory.o
+ 0xb4 (size before relaxing)
+ .xt.prop 0x000022b0 0x36c objs/hikey/xf-shmem.o
+ 0x3a8 (size before relaxing)
+ .xt.prop 0x0000261c 0x498 objs/hikey/tinyvprintf.o
+ 0x4a4 (size before relaxing)
+ .xt.prop 0x00002ab4 0xe4 objs/hikey/xf-isr.o
+ 0x108 (size before relaxing)
+ .xt.prop 0x00002b98 0x9c0 objs/hikey/gdbstub.o
+ 0xa8c (size before relaxing)
+ .xt.prop 0x00003558 0xa80 objs/hikey/xa-class-base.o
+ 0xb28 (size before relaxing)
+ .xt.prop 0x00003fd8 0xbb8 objs/hikey/xa-class-audio-codec.o
+ 0xc84 (size before relaxing)
+ .xt.prop 0x00004b90 0xcf0 objs/hikey/xa-class-mixer.o
+ 0xdd4 (size before relaxing)
+ .xt.prop 0x00005880 0xe4 objs/hikey/xf-main.o
+ 0x18c (size before relaxing)
+ .xt.prop 0x00005964 0xdec objs/hikey/xa-pcm.o
+ 0xef4 (size before relaxing)
+ .xt.prop 0x00006750 0x48 objs/hikey/xa-vorbis-decoder.o
+ 0x60 (size before relaxing)
+ .xt.prop 0x00006798 0xaa4 objs/hikey/xa-mixer.o
+ 0xb7c (size before relaxing)
+ .xt.prop 0x0000723c 0x6c objs/hikey/reset.o
+ .xt.prop 0x000072a8 0x300 objs/hikey/int_vector.o
+ 0x390 (size before relaxing)
+ .xt.prop 0x000075a8 0x150 objs/hikey/arch_hifi330.o
+ 0x15c (size before relaxing)
+ .xt.prop 0x000076f8 0xf0 objs/hikey/gdbstub-entry.o
+ .xt.prop 0x000077e8 0x5154 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o)
+ 0x51d8 (size before relaxing)
+ .xt.prop 0x0000c93c 0xf0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o)
+ .xt.prop 0x0000ca2c 0x24 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o)
+ .xt.prop 0x0000ca50 0x24 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o)
+ .xt.prop 0x0000ca74 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o)
+ .xt.prop 0x0000ca8c 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o)
+ .xt.prop 0x0000caa4 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o)
+ .xt.prop 0x0000cabc 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o)
+ .xt.prop 0x0000cad4 0x24 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o)
+ .xt.prop 0x0000caf8 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o)
+ 0x24 (size before relaxing)
+ .xt.prop 0x0000cb10 0x24 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o)
+ .xt.prop 0x0000cb34 0x90 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ .xt.prop 0x0000cbc4 0x3c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o)
+ .xt.prop 0x0000cc00 0x144 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o)
+ .xt.prop 0x0000cd44 0xc0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o)
+ .xt.prop 0x0000ce04 0x3e4 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ 0x3f0 (size before relaxing)
+ .xt.prop 0x0000d1e8 0x9c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ 0xa8 (size before relaxing)
+ .xt.prop 0x0000d284 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o)
+ .xt.prop 0x0000d29c 0x18 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o)
+ .xt.prop 0x0000d2b4 0x444 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o)
+ .xt.prop 0x0000d6f8 0x264 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o)
+ .xt.prop 0x0000d95c 0x27c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o)
+ 0x288 (size before relaxing)
+ .xt.prop 0x0000dbd8 0x90 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o)
+ 0x9c (size before relaxing)
+ .xt.prop 0x0000dc68 0xc0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o)
+ 0xcc (size before relaxing)
+ .xt.prop 0x0000dd28 0x54 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o)
+ .xt.prop 0x0000dd7c 0x9c /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o)
+ .xt.prop 0x0000de18 0x150 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ .xt.prop 0x0000df68 0x120 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ .xt.prop 0x0000e088 0x120 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ .xt.prop 0x0000e1a8 0xa8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ 0xb4 (size before relaxing)
+ .xt.prop 0x0000e250 0x78 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ 0x84 (size before relaxing)
+ .xt.prop 0x0000e2c8 0x1ec /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ .xt.prop 0x0000e4b4 0x3a8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ .xt.prop 0x0000e85c 0x90 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+ 0x9c (size before relaxing)
+ *(.xt.prop.*)
+ *(.gnu.linkonce.prop.*)
+
+.xt.lit 0x00000000 0x518
+ *(.xt.lit)
+ .xt.lit 0x00000000 0x18 objs/hikey/cpu_c.o
+ 0x40 (size before relaxing)
+ .xt.lit 0x00000018 0x20 objs/hikey/dsp_debug.o
+ .xt.lit 0x00000038 0x8 objs/hikey/mutex.o
+ .xt.lit 0x00000040 0x8 objs/hikey/rbtree.o
+ .xt.lit 0x00000048 0x60 objs/hikey/xf-core.o
+ 0x68 (size before relaxing)
+ .xt.lit 0x000000a8 0x70 objs/hikey/xf-io.o
+ 0x98 (size before relaxing)
+ .xt.lit 0x00000118 0x18 objs/hikey/xf-mem.o
+ 0x28 (size before relaxing)
+ .xt.lit 0x00000130 0x20 objs/hikey/xf-msg.o
+ .xt.lit 0x00000150 0x18 objs/hikey/xf-sched.o
+ 0x28 (size before relaxing)
+ .xt.lit 0x00000168 0x10 objs/hikey/xa-factory.o
+ .xt.lit 0x00000178 0x20 objs/hikey/xf-shmem.o
+ 0x30 (size before relaxing)
+ .xt.lit 0x00000198 0x8 objs/hikey/tinyvprintf.o
+ .xt.lit 0x000001a0 0x18 objs/hikey/xf-isr.o
+ .xt.lit 0x000001b8 0x60 objs/hikey/gdbstub.o
+ 0x70 (size before relaxing)
+ .xt.lit 0x00000218 0x58 objs/hikey/xa-class-base.o
+ .xt.lit 0x00000270 0x70 objs/hikey/xa-class-audio-codec.o
+ 0x78 (size before relaxing)
+ .xt.lit 0x000002e0 0x78 objs/hikey/xa-class-mixer.o
+ 0x80 (size before relaxing)
+ .xt.lit 0x00000358 0x18 objs/hikey/xf-main.o
+ .xt.lit 0x00000370 0xa8 objs/hikey/xa-pcm.o
+ .xt.lit 0x00000418 0x8 objs/hikey/xa-vorbis-decoder.o
+ .xt.lit 0x00000420 0x80 objs/hikey/xa-mixer.o
+ .xt.lit 0x000004a0 0x8 objs/hikey/reset.o
+ .xt.lit 0x000004a8 0x10 objs/hikey/int_vector.o
+ 0x40 (size before relaxing)
+ .xt.lit 0x000004b8 0x8 objs/hikey/arch_hifi330.o
+ .xt.lit 0x000004c0 0x8 objs/hikey/gdbstub-entry.o
+ .xt.lit 0x000004c8 0x18 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o)
+ 0x78 (size before relaxing)
+ .xt.lit 0x000004e0 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o)
+ .xt.lit 0x000004e8 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o)
+ .xt.lit 0x000004f0 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o)
+ 0x8 (size before relaxing)
+ .xt.lit 0x000004f0 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ .xt.lit 0x000004f8 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ 0x8 (size before relaxing)
+ .xt.lit 0x000004f8 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o)
+ .xt.lit 0x00000500 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o)
+ .xt.lit 0x00000508 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o)
+ 0x8 (size before relaxing)
+ .xt.lit 0x00000508 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o)
+ 0x8 (size before relaxing)
+ .xt.lit 0x00000508 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o)
+ 0x8 (size before relaxing)
+ .xt.lit 0x00000508 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ 0x8 (size before relaxing)
+ .xt.lit 0x00000508 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ 0x8 (size before relaxing)
+ .xt.lit 0x00000508 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ .xt.lit 0x00000510 0x8 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ .xt.lit 0x00000518 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+ 0x8 (size before relaxing)
+ *(.xt.lit.*)
+ *(.gnu.linkonce.p.*)
+
+.comment 0x00000000 0x1351
+ .comment 0x00000000 0x59 objs/hikey/cpu_c.o
+ 0x5a (size before relaxing)
+ .comment 0x00000059 0x5d objs/hikey/dsp_debug.o
+ 0x5e (size before relaxing)
+ .comment 0x000000b6 0x5c objs/hikey/dsp_comm.o
+ 0x5d (size before relaxing)
+ .comment 0x00000112 0x50 objs/hikey/mutex.o
+ 0x51 (size before relaxing)
+ .comment 0x00000162 0x51 objs/hikey/rbtree.o
+ 0x52 (size before relaxing)
+ .comment 0x000001b3 0x4d objs/hikey/xf-core.o
+ 0x4e (size before relaxing)
+ .comment 0x00000200 0x4b objs/hikey/xf-io.o
+ 0x4c (size before relaxing)
+ .comment 0x0000024b 0x4c objs/hikey/xf-mem.o
+ 0x4d (size before relaxing)
+ .comment 0x00000297 0x4c objs/hikey/xf-msg.o
+ 0x4d (size before relaxing)
+ .comment 0x000002e3 0x4e objs/hikey/xf-sched.o
+ 0x4f (size before relaxing)
+ .comment 0x00000331 0x4f objs/hikey/xa-factory.o
+ 0x50 (size before relaxing)
+ .comment 0x00000380 0x4e objs/hikey/xf-shmem.o
+ 0x4f (size before relaxing)
+ .comment 0x000003ce 0x56 objs/hikey/tinyvprintf.o
+ 0x57 (size before relaxing)
+ .comment 0x00000424 0x4c objs/hikey/xf-isr.o
+ 0x4d (size before relaxing)
+ .comment 0x00000470 0x5a objs/hikey/gdbstub.o
+ 0x5b (size before relaxing)
+ .comment 0x000004ca 0x54 objs/hikey/xa-class-base.o
+ 0x55 (size before relaxing)
+ .comment 0x0000051e 0x5b objs/hikey/xa-class-audio-codec.o
+ 0x5c (size before relaxing)
+ .comment 0x00000579 0x55 objs/hikey/xa-class-mixer.o
+ 0x56 (size before relaxing)
+ .comment 0x000005ce 0x55 objs/hikey/xf-main.o
+ 0x56 (size before relaxing)
+ .comment 0x00000623 0x60 objs/hikey/xa-pcm.o
+ 0x61 (size before relaxing)
+ .comment 0x00000683 0x6d objs/hikey/xa-vorbis-decoder.o
+ 0x6e (size before relaxing)
+ .comment 0x000006f0 0x5f objs/hikey/xa-mixer.o
+ 0x60 (size before relaxing)
+ .comment 0x0000074f 0x573 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o)
+ 0x584 (size before relaxing)
+ .comment 0x00000cc2 0xa1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ 0xa2 (size before relaxing)
+ .comment 0x00000d63 0xa1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o)
+ 0xa2 (size before relaxing)
+ .comment 0x00000e04 0xa0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ 0xa1 (size before relaxing)
+ .comment 0x00000ea4 0xa2 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ 0xa3 (size before relaxing)
+ .comment 0x00000f46 0xa1 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ 0xa2 (size before relaxing)
+ .comment 0x00000000 0xa2 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ .comment 0x00000000 0xa2 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ .comment 0x00000fe7 0xa5 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ 0xa6 (size before relaxing)
+ .comment 0x0000108c 0xa5 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ 0xa6 (size before relaxing)
+ .comment 0x00001131 0xb5 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ 0xb6 (size before relaxing)
+ .comment 0x000011e6 0xb5 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ 0xb6 (size before relaxing)
+ .comment 0x0000129b 0xb6 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+ 0xb7 (size before relaxing)
+
+.xtensa.info 0x00000000 0x1d8
+ .xtensa.info 0x00000000 0x1d8 objs/hikey/cpu_c.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/dsp_debug.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/dsp_comm.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/mutex.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/rbtree.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xf-core.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xf-io.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xf-mem.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xf-msg.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xf-sched.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xa-factory.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xf-shmem.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/tinyvprintf.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xf-isr.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/gdbstub.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xa-class-base.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xa-class-audio-codec.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xa-class-mixer.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xf-main.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xa-pcm.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xa-vorbis-decoder.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/xa-mixer.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/reset.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/int_vector.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/arch_hifi330.o
+ .xtensa.info 0x00000000 0x0 objs/hikey/gdbstub-entry.o
+ .xtensa.info 0x00000000 0x0 ../plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a(xa_vorbis_dec.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(windowspill_asm.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_invalidate.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--dcache_region_writeback.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid0.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--hw_configid1.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_major.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(cache_asm--release_minor.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--get_intenable.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(int_asm--set_intenable.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--restore_extra_nw.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhal.a(state_asm--save_extra_nw.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-on.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(ints-off.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/arch/lib//libhandlers-board.a(interrupt-table.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memchr.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcmp.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memcpy.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-memset.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-qsort.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib//libc.a(lib_a-strncmp.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divsi3.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_modsi3.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_addsubdf3.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_muldf3.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_cmpdf2.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfsi.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_fixunsdfdi.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatsidf.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_floatdidf.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_divdi3.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_udivdi3.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(_umoddi3.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memcpy.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(vec_memset.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_div_df.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_df.o)
+ .xtensa.info 0x00000000 0x0 /scratch/speacial_projects/sof-sdk/xtensa_tools/tools/XtDevTools/install/builds/RG-2017.5-linux/hifi3_hikey960/xtensa-elf/lib/xcc//libgcc.a(softfloat_cmn_div.o)
+
+.debug.xt.callgraph
+ *(.debug.xt.callgraph .debug.xt.callgraph.* .gnu.linkonce.xt.callgraph.*)
+OUTPUT(objs/hikey/xa_hikey.o elf32-xtensa-le)
+
+.debug_ranges 0x00000000 0x98
+ .debug_ranges 0x00000000 0x20 objs/hikey/reset.o
+ .debug_ranges 0x00000020 0x58 objs/hikey/int_vector.o
+ .debug_ranges 0x00000078 0x20 objs/hikey/gdbstub-entry.o
diff --git a/hifi/xaf/hifi-dpf/build_hikey/tools/elftobin.sh b/hifi/xaf/hifi-dpf/build_hikey/tools/elftobin.sh
new file mode 100755
index 00000000..cebe6bf4
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/tools/elftobin.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+if [ $# != 2 ]
+then
+echo "elftobin.sh <input_elf_file> <output_img_file>"
+exit
+fi
+
+if [ $XTENSA_CORE == "" ]
+then
+echo "XTENSA_CORE is not set"
+exit
+fi
+
+if [ $XTENSA_SYSTEM == "" ]
+then
+echo "XTENSA_SYSTEM is not set"
+exit
+fi
+
+export INPUT_ELF_FILE=$1
+export OUTPUT_BIN_FILE=__hikey_temp.bin
+export OUTPUT_IMG_FILE=$2
+export OP_DIR=./
+
+xt-objdump -h $INPUT_ELF_FILE > __elfdump
+less __elfdump | sed -n '/ALLOC/{g;1!p;};h' > __header
+less __header | awk '{print $2 " " $3 " " $4}' > __proc
+
+sections=`less __proc | cut -f1 -d' ' | tr '\n' ',' | sed 's/\,$//g'`
+SECTION_NUM=`awk 'END {print NR}' __proc`
+echo "Total number of sections are $SECTION_NUM"
+#sections=(".dram0.data" ".ResetVector.text" ".Reset.literal" ".WindowVectors.text" ".Level2InterruptVector.literal" ".Level2InterruptVector.text" ".Level3InterruptVector.literal" ".Level3InterruptVector.text" ".DebugExceptionVector.literal" ".DebugExceptionVector.text" ".NMIExceptionVector.literal" ".NMIExceptionVector.text" ".KernelExceptionVector.literal" ".KernelExceptionVector.text" ".UserExceptionVector.literal" ".UserExceptionVector.text" ".DoubleExceptionVector.literal" ".DoubleExceptionVector.text" ".Reset.text" ".iram0.text" ".rodata" ".text" ".data" ".bss")
+#dst_addr=("0xe8058000" "0xe8080000" "0xe8080300" "0xe8080400" "0xe8080578" "0xe8080580" "0xe80805b8" "0xe80805c0" "0xe8080638" "0xe8080640" "0xe8080678" "0xe80806c0" "0xe80806f8" "0xe8080700" "0xe8080738" "0xe8080740" "0xe8080778" "0xe80807c0" "0xe8080800" "0xe8080a44" "0xc0000000" "0xc0000cc8" "0xc00025c0" "0xc0002a20")
+
+ID_Sec=("0x01010000" "0x01000001" "0x01000002" "0x01000003" "0x01000004" "0x01000005" "0x01000006" "0x01000007" "0x01000008" "0x01000009" "0x0100000A" "0x0100000B" "0x0100000C" "0x0100000D" "0x0100000E" "0x0100000F" "0x01000010" "0x01000011" "0x01000012" "0x01000013" "0x00000014" "0x00000015" "0x00010016" "0x00020017")
+
+head -c "4" /dev/zero > __zero.bin
+
+i=0
+for j in `seq 1 $SECTION_NUM`
+do
+ VAR=`less __proc | awk 'FNR == "'"$j"'" {print $1}'`
+ VARBIN=`echo "$VAR" | sed 's/^./__/' | sed "s/\..*//" | sed 's/$/.bin/' `
+ #echo "section: $VAR $VARBIN"
+ xt-objcopy $INPUT_ELF_FILE -O binary --only-section $VAR $VARBIN
+
+ size_sec[${i}]=$(cat $VARBIN | wc -c)
+ #echo "size : ${size_sec[${i}]}"
+ mod0=`expr ${size_sec[${i}]} % 4`
+ nbytes=`expr 4 - $mod0`
+ if [ "$nbytes" -ne "4" ] ; then
+ tail -c $nbytes __zero.bin >> $VARBIN
+ size_sec[$i]=`expr ${size_sec[${i}]} + $nbytes`
+ fi
+ cat $VARBIN >> $OUTPUT_BIN_FILE
+ i=`expr $i + 1`;
+done
+cd $OP_DIR
+
+tmp1=$(cat $OUTPUT_BIN_FILE | wc -c)
+total_sections=$SECTION_NUM
+main_header_size=32
+section_header_size=16
+size_total_img=`expr $main_header_size + $tmp1 + $total_sections \* $section_header_size`
+current_date_time=`date "+%Y/%m/%d %H:%M:%S"`
+echo "HIF:$current_date_time" > $OUTPUT_IMG_FILE
+
+printf "0: %.8x" $size_total_img | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 >> $OUTPUT_IMG_FILE
+printf "0: %.8x" $total_sections | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 >> $OUTPUT_IMG_FILE
+
+cnt1=`expr $main_header_size + $total_sections \* $section_header_size`
+i=0
+for j in `seq 1 $SECTION_NUM`
+do
+ DST_ADDR=`less __proc | awk 'FNR == "'"$j"'" {print $3}'`
+ printf "0: %.8x" ${ID_Sec[${i}]} | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 >> $OUTPUT_IMG_FILE
+ printf "0: %.8x" $cnt1 | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 >> $OUTPUT_IMG_FILE
+ printf "0: %.8x" 0x$DST_ADDR | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 >> $OUTPUT_IMG_FILE
+ printf "0: %.8x" ${size_sec[${i}]} | sed -e 's/0\: \(..\)\(..\)\(..\)\(..\)/0\: \4\3\2\1/' | xxd -r -g0 >> $OUTPUT_IMG_FILE
+ cnt_prev=$cnt1
+ cnt1=`expr ${size_sec[${i}]} + $cnt_prev`
+ i=`expr $i + 1`
+done
+
+cat $OUTPUT_BIN_FILE >> $OUTPUT_IMG_FILE
+rm $OUTPUT_BIN_FILE
+rm __*.bin
+rm __proc
+rm __elfdump
+rm __header
+
+echo "elftobin successful!"
+
diff --git a/hifi/xaf/hifi-dpf/build_hikey/xa_hikey.img b/hifi/xaf/hifi-dpf/build_hikey/xa_hikey.img
new file mode 100644
index 00000000..4c166528
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/build_hikey/xa_hikey.img
Binary files differ
diff --git a/hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub-entry.S b/hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub-entry.S
new file mode 100644
index 00000000..50a33a93
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub-entry.S
@@ -0,0 +1,198 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+#include "xtensa-defs.h"
+
+.macro SAVE_ reg, loc
+ rsr a1, \reg
+ s32i a1, a3, \loc * 4
+.endm
+.macro SAVE reg
+ SAVE_ \reg, \reg
+.endm
+
+.macro LOAD_ reg, loc
+ l32i a1, a3, \loc * 4
+ wsr a1, \reg
+.endm
+.macro LOAD reg
+ LOAD_ \reg, \reg
+.endm
+
+ .section ".DebugExceptionVector.text", "ax"
+ .global DebugExceptionVector
+
+DebugExceptionVector:
+ j 1f
+ .align 4
+ .literal_position
+1:
+ xsr a2, DEBUG_EXCSAVE
+ jx a2
+
+ .text
+ .global DebugExceptionEntry
+ .align 4
+
+DebugExceptionEntry:
+ j 1f
+ .align 4
+ .literal_position
+1:
+ movi a2, aregs
+ s32i a0, a2, 0
+ s32i a1, a2, 4
+ rsr a1, DEBUG_EXCSAVE
+ s32i a1, a2, 8
+ s32i a3, a2, 12
+
+ movi a3, sregs
+ SAVE LBEG
+ SAVE LEND
+ SAVE LCOUNT
+ SAVE SAR
+ SAVE WINDOWBASE
+ SAVE WINDOWSTART
+
+ rsr a1, DEBUG_PC
+ movi a2, initial_breakpoint
+ bne a1, a2, 1f
+ addi a1, a1, 3
+1:
+ s32i a1, a3, DEBUG_PC * 4
+
+ SAVE EXCSAVE_1
+ SAVE_ DEBUG_PS, PS
+ SAVE EXCCAUSE
+ SAVE DEBUGCAUSE
+ SAVE EXCVADDR
+
+ movi a1, XCHAL_NUM_AREGS / 4 - 1
+ movi a2, aregs
+1:
+ s32i a4, a2, 16
+ s32i a5, a2, 20
+ s32i a6, a2, 24
+ s32i a7, a2, 28
+
+ addi a6, a2, 16
+ addi a5, a1, -1
+ rotw 1
+ bnez a1, 1b
+
+ movi a1, 1
+ wsr a1, windowstart
+ movi a0, 0
+ wsr a0, windowbase
+ rsync
+
+ movi a0, 0
+ movi a1, stack + STACK_SIZE - 20
+ rsr a2, ps
+ addi a2, a2, -PS_EXCM_MASK
+ wsr a2, ps
+ rsync
+
+ movi a4, handle_exception
+ callx4 a4
+
+DebugExceptionExit:
+ movi a2, DebugExceptionEntry
+ wsr a2, DEBUG_EXCSAVE
+
+ rsr a2, ps
+ addi a2, a2, PS_EXCM_MASK
+ wsr a2, ps
+ rsync
+
+ movi a3, sregs
+ LOAD LBEG
+ LOAD LEND
+ LOAD LCOUNT
+ /* TODO: handle unlikely return-to-lend case */
+ LOAD SAR
+ LOAD WINDOWBASE
+ rsync
+ movi a3, sregs
+ LOAD WINDOWSTART
+ LOAD DEBUG_PC
+ LOAD EXCSAVE_1
+ LOAD_ DEBUG_PS, PS
+ LOAD EXCCAUSE
+ LOAD EXCVADDR
+
+ movi a6, aregs
+ movi a5, XCHAL_NUM_AREGS / 4 - 2
+1:
+ l32i a0, a6, 0
+ l32i a1, a6, 4
+ l32i a2, a6, 8
+ l32i a3, a6, 12
+
+ beqz a5, 2f
+ addi a10, a6, 16
+ addi a9, a5, -1
+ rotw 1
+ j 1b
+2:
+ l32i a4, a6, 16
+ l32i a5, a6, 20
+ l32i a7, a6, 28
+ l32i a6, a6, 24
+ rotw 2
+
+ rfi XCHAL_DEBUGLEVEL
+
+
+#ifdef LIBC_LEVEL1_HANDLER
+ .global fault_handler
+ .align 4
+fault_handler:
+ rsr a2, epc1
+ addi a2, a2, 3
+ wsr a2, epc1
+ rsync
+ movi a2, mem_err
+ s32i a2, a2, 0
+
+ l32i a2, a1, 16
+ l32i a3, a1, 20
+ addi a1, a1, 256
+ rfe
+#endif
+
+
+ .global init_debug_entry
+ .align 4
+init_debug_entry:
+ entry a1, 16
+ movi a2, DebugExceptionEntry
+ wsr a2, DEBUG_EXCSAVE
+ isync
+ retw
+
+ .global breakpoint
+ .align 4
+breakpoint:
+ entry a1, 16
+initial_breakpoint:
+ _break 0, 0
+ retw
diff --git a/hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub.c b/hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub.c
new file mode 100644
index 00000000..e125b94c
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/util/gdbstub/gdbstub.c
@@ -0,0 +1,756 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/****************************************************************************
+
+ THIS SOFTWARE IS NOT COPYRIGHTED
+
+ HP offers the following for use in the public domain. HP makes no
+ warranty with regard to the software or it's performance and the
+ user accepts the software "AS IS" with all faults.
+
+ HP DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD
+ TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+****************************************************************************/
+
+/****************************************************************************
+ * Header: remcom.c,v 1.34 91/03/09 12:29:49 glenne Exp $
+ *
+ * Module name: remcom.c $
+ * Revision: 1.34 $
+ * Date: 91/03/09 12:29:49 $
+ * Contributor: Lake Stevens Instrument Division$
+ *
+ * Description: low level support for gdb debugger. $
+ *
+ * Considerations: only works on target hardware $
+ *
+ * Written by: Glenn Engel $
+ * ModuleState: Experimental $
+ *
+ * NOTES: See Below $
+ *
+ * Modified for SPARC by Stu Grossman, Cygnus Support.
+ *
+ * This code has been extensively tested on the Fujitsu SPARClite demo board.
+ *
+ * To enable debugger support, two things need to happen. One, a
+ * call to set_debug_traps() is necessary in order to allow any breakpoints
+ * or error conditions to be properly intercepted and reported to gdb.
+ * Two, a breakpoint needs to be generated to begin communication. This
+ * is most easily accomplished by a call to breakpoint(). Breakpoint()
+ * simulates a breakpoint by executing a trap #1.
+ *
+ *************
+ *
+ * The following gdb commands are supported:
+ *
+ * command function Return value
+ *
+ * g return the value of the CPU registers hex data or ENN
+ * G set the value of the CPU registers OK or ENN
+ *
+ * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN
+ * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN
+ *
+ * c Resume at current address SNN ( signal NN)
+ * cAA..AA Continue at address AA..AA SNN
+ *
+ * s Step one instruction SNN
+ * sAA..AA Step one instruction from AA..AA SNN
+ *
+ * k kill
+ *
+ * ? What was the last sigval ? SNN (signal NN)
+ *
+ * All commands and responses are sent with a packet which includes a
+ * checksum. A packet consists of
+ *
+ * $<packet info>#<checksum>.
+ *
+ * where
+ * <packet info> :: <characters representing the command or response>
+ * <checksum> :: < two hex digits computed as modulo 256 sum of <packetinfo>>
+ *
+ * When a packet is received, it is first acknowledged with either '+' or '-'.
+ * '+' indicates a successful transfer. '-' indicates a failed transfer.
+ *
+ * Example:
+ *
+ * Host: Reply:
+ * $m0,10#2a +$00010203040506070809101112131415#42
+ *
+ ****************************************************************************/
+#ifdef XAF_ENABLE_NON_HIKEY
+#include "xf.h"
+#else
+#include <string.h>
+#include <signal.h>
+#include <stdint.h>
+#include <xtensa/xtruntime.h>
+#endif
+#include "xtensa-defs.h"
+
+/*******************************************************************************
+ * Ring-buffer definition
+ ******************************************************************************/
+
+#define RING_SIZE 256
+
+struct ring {
+ unsigned char head;
+ unsigned char fill1[63];
+ unsigned char tail;
+ unsigned char fill2[63];
+ unsigned char data[RING_SIZE];
+};
+
+#define GDB_INVALIDATE(p) \
+ xthal_dcache_region_invalidate((void *)(p), sizeof(*p))
+
+#define GDB_FLUSH(p) \
+ xthal_dcache_region_writeback((void *)(p), sizeof(*p))
+
+static inline unsigned int ring_next_head(const volatile struct ring *ring)
+{
+ return (ring->head + 1) & (RING_SIZE - 1);
+}
+
+static inline unsigned int ring_next_tail(const volatile struct ring *ring)
+{
+ return (ring->tail + 1) & (RING_SIZE - 1);
+}
+
+static inline int ring_have_space(const volatile struct ring *ring)
+{
+ /* ...invalidate tail pointer of tx-ring (updated by host) */
+ GDB_INVALIDATE(&ring->tail);
+
+ return ring_next_head(ring) != ring->tail;
+}
+
+static inline int ring_have_data(const volatile struct ring *ring)
+{
+ /* ...invalidate head pointer of rx-ring (updated by host) */
+ GDB_INVALIDATE(&ring->head);
+
+ return ring->head != ring->tail;
+}
+#ifdef XAF_ENABLE_NON_HIKEY
+#define DEBUG_RX_BASE XF_CFG_GDB_RING_RX
+#define DEBUG_TX_BASE XF_CFG_GDB_RING_TX
+#else
+//#define DEBUG_RX_BASE (0x72000000)
+//#define DEBUG_TX_BASE (0x72000800)
+#define DEBUG_RX_BASE (0x6FFFF000)
+#define DEBUG_TX_BASE (0x6FFFF800)
+#endif
+
+volatile struct ring * const rx = (void *)DEBUG_RX_BASE;
+volatile struct ring * const tx = (void *)DEBUG_TX_BASE;
+
+void init_debug_comm(void)
+{
+ rx->head = rx->tail = 0;
+ tx->head = tx->tail = 0;
+ GDB_FLUSH(&rx->head);
+ GDB_FLUSH(&rx->tail);
+ GDB_FLUSH(&tx->head);
+ GDB_FLUSH(&tx->tail);
+}
+
+/* ...functions defined in asm code */
+extern void breakpoint(void);
+extern void init_debug_entry(void);
+
+void poll_debug_ring(void)
+{
+ if (ring_have_data(rx)) {
+ breakpoint();
+ }
+}
+
+static void putDebugChar(char c)
+{
+ while (!ring_have_space(tx))
+ ;
+
+ tx->data[tx->head] = c;
+
+ /* ...flush data buffer to main memory */
+ GDB_FLUSH(&tx->data[tx->head]);
+
+ tx->head = ring_next_head(tx);
+
+ /* ...flush head pointer to main memory */
+ GDB_FLUSH(&tx->head);
+}
+
+static int getDebugChar(void)
+{
+ int v;
+ while (!ring_have_data(rx))
+ ;
+
+ /* ...inavlidate data buffer */
+ GDB_INVALIDATE(&rx->data[rx->tail]);
+
+ v = rx->data[rx->tail];
+ rx->tail = ring_next_tail(rx);
+
+ /* ...update tail index */
+ GDB_FLUSH(&rx->tail);
+
+ return v;
+}
+
+/************************************************************************/
+/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
+/* at least NUMREGBYTES*2 are needed for register packets */
+#define BUFMAX 256
+
+#ifdef USE_GDBSTUB
+#define bulk_data __attribute__((section (".ddr0.data")))
+#else
+#define bulk_data
+#endif
+uint32_t stack[STACK_SIZE / sizeof(uint32_t)] bulk_data;
+static uint8_t sregs_read[32] bulk_data;
+static uint8_t sregs_mod[32] bulk_data;
+static uint8_t sregs_late[32] bulk_data;
+uint32_t sregs[256] bulk_data;
+uint32_t aregs[XCHAL_NUM_AREGS] bulk_data;
+static uint8_t remcomInBuffer[BUFMAX] bulk_data;
+static uint8_t remcomOutBuffer[BUFMAX] bulk_data;
+
+static const char hexchars[]="0123456789abcdef";
+
+/* Convert ch from a hex digit to an int */
+
+static int hex(unsigned char ch)
+{
+ if (ch >= 'a' && ch <= 'f')
+ return ch-'a'+10;
+ if (ch >= '0' && ch <= '9')
+ return ch-'0';
+ if (ch >= 'A' && ch <= 'F')
+ return ch-'A'+10;
+ return -1;
+}
+
+/* scan for the sequence $<data>#<checksum> */
+
+unsigned char *getpacket(void)
+{
+ unsigned char *buffer = &remcomInBuffer[0];
+ unsigned char checksum;
+ unsigned char xmitcsum;
+ int count;
+ char ch;
+
+ while (1) {
+ /* wait around for the start character, ignore all other characters */
+ while ((ch = getDebugChar ()) != '$')
+ ;
+
+retry:
+ checksum = 0;
+ xmitcsum = -1;
+ count = 0;
+
+ /* now, read until a # or end of buffer is found */
+ while (count < BUFMAX - 1) {
+ ch = getDebugChar ();
+ if (ch == '$')
+ goto retry;
+ if (ch == '#')
+ break;
+ checksum = checksum + ch;
+ buffer[count] = ch;
+ count = count + 1;
+ }
+ buffer[count] = 0;
+
+ if (ch == '#') {
+ ch = getDebugChar ();
+ xmitcsum = hex (ch) << 4;
+ ch = getDebugChar ();
+ xmitcsum += hex (ch);
+
+ if (checksum != xmitcsum) {
+ putDebugChar ('-'); /* failed checksum */
+ } else {
+ putDebugChar ('+'); /* successful transfer */
+
+ /* if a sequence char is present, reply the sequence ID */
+ if (buffer[2] == ':') {
+ putDebugChar (buffer[0]);
+ putDebugChar (buffer[1]);
+
+ return &buffer[3];
+ }
+
+ return &buffer[0];
+ }
+ }
+ }
+}
+
+/* send the packet in buffer. */
+
+static void putpacket(uint8_t *buffer)
+{
+ unsigned char checksum;
+ int count;
+ unsigned char ch;
+
+ /* $<packet info>#<checksum>. */
+ do {
+ putDebugChar('$');
+ checksum = 0;
+ count = 0;
+
+ while ((ch = buffer[count]) != 0) {
+ putDebugChar(ch);
+ checksum += ch;
+ count += 1;
+ }
+
+ putDebugChar('#');
+ putDebugChar(hexchars[checksum >> 4]);
+ putDebugChar(hexchars[checksum & 0xf]);
+
+ } while (getDebugChar() != '+');
+}
+
+/* Indicate to caller of mem2hex or hex2mem that there has been an
+ error. */
+volatile int mem_err = 0;
+
+/* Convert the memory pointed to by mem into hex, placing result in buf.
+ * Return a pointer to the last char put in buf (null), in case of mem fault,
+ * return 0.
+ */
+
+static uint8_t * mem2hex(const void *mem_, uint8_t *buf, int count)
+{
+ const unsigned char *mem = mem_;
+ unsigned char ch;
+
+ mem_err = 0;
+ while (count-- > 0) {
+#ifdef __XTENSA__
+ unsigned long v;
+ unsigned long addr = (unsigned long)mem;
+ asm volatile ("_l32i %0, %1, 0\n"
+ : "=r"(v)
+ : "r"(addr & ~3)
+ : "memory");
+ ch = v >> (addr & 3) * 8;
+#endif
+ mem++;
+ if (mem_err)
+ return NULL;
+ *buf++ = hexchars[ch >> 4];
+ *buf++ = hexchars[ch & 0xf];
+ }
+
+ *buf = 0;
+
+ return buf;
+}
+
+/* convert the hex array pointed to by buf into binary to be placed in mem
+ * return a pointer to the character AFTER the last byte written */
+
+static uint8_t * hex2mem(const uint8_t *buf, void *mem_, int count)
+{
+ uint8_t *mem = mem_;
+ int i;
+ uint8_t ch;
+
+ if ((unsigned long)mem >= 0xece80000)
+ return NULL;
+
+ mem_err = 0;
+ for (i=0; i<count; i++) {
+ ch = hex(*buf++) << 4;
+ ch |= hex(*buf++);
+#ifdef __XTENSA__
+ unsigned long tmp;
+ unsigned long addr = (unsigned long)mem;
+ asm volatile ("_l32i %0, %1, 0\n"
+ "and %0, %0, %2\n"
+ "or %0, %0, %3\n"
+ "_s32i %0, %1, 0\n"
+ "dhwb %1, 0\n"
+ "ihi %1, 0\n"
+ : "=r"(tmp)
+ : "r"(addr & ~3), "r"(0xffffffff ^ (0xff << (addr & 3) * 8)), "r"(ch << (addr & 3) * 8)
+ : "memory");
+#endif
+ mem++;
+ if (mem_err)
+ return NULL;
+ }
+
+ return mem;
+}
+
+/*
+ * While we find nice hex chars, build an int.
+ * Return number of chars processed.
+ */
+
+static int hexToInt(uint8_t **ptr, int *intValue)
+{
+ int numChars = 0;
+ int hexValue;
+
+ *intValue = 0;
+
+ while (**ptr) {
+ hexValue = hex(**ptr);
+ if (hexValue < 0)
+ break;
+
+ *intValue = (*intValue << 4) | hexValue;
+ numChars ++;
+
+ (*ptr)++;
+ }
+
+ return (numChars);
+}
+
+static inline int test_bit(const uint8_t *p, int bit)
+{
+ return (p[bit / 8] >> (bit & 0x7)) & 1;
+}
+static inline int set_bit(uint8_t *p, int bit)
+{
+ return (p[bit / 8] |= 1u << (bit & 0x7));
+}
+
+static inline void mark_read(int sr)
+{
+ set_bit(sregs_read, sr);
+}
+static inline int is_read(int sr)
+{
+ return test_bit(sregs_read, sr);
+}
+static inline void mark_mod(int sr)
+{
+ set_bit(sregs_mod, sr);
+}
+static inline int is_mod(int sr)
+{
+ return test_bit(sregs_mod, sr);
+}
+static inline void mark_late(int sr)
+{
+ set_bit(sregs_late, sr);
+}
+static inline int is_late(int sr)
+{
+ return test_bit(sregs_late, sr);
+}
+
+static void read_sr(int sr)
+{
+ if (!is_read(sr)) {
+#ifdef __XTENSA__
+ uint32_t val;
+ asm volatile ("movi a3, 1f + 1\n"
+ "s8i %1, a3, 0\n"
+ "dhwb a3, 0\n"
+ "ihi a3, 0\n"
+ "isync\n"
+ "1:\n"
+ "rsr %0, lbeg\n"
+ : "=r"(val)
+ : "r"(sr)
+ : "a3", "memory");
+ sregs[sr] = val;
+#endif
+ mark_read(sr);
+ }
+}
+
+static void write_sr(int sr)
+{
+#ifdef __XTENSA__
+ asm volatile ("movi a3, 1f + 1\n"
+ "s8i %1, a3, 0\n"
+ "dhwb a3, 0\n"
+ "ihi a3, 0\n"
+ "isync\n"
+ "1:\n"
+ "wsr %0, lbeg\n"
+ :
+ : "r"(sregs[sr]), "r"(sr)
+ : "a3", "memory");
+#endif
+}
+
+static void restore_sr(void)
+{
+ int i;
+ for (i = 0; i < 256; ++i)
+ if (is_mod(i) && !is_late(i))
+ write_sr(i);
+}
+
+extern void *_xtos_exc_handler_table[];
+void fault_handler(void);
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
+
+void handle_exception(void)
+{
+ int sigval = 0;
+ int addr;
+ int length;
+ uint8_t *ptr;
+ unsigned i;
+ const unsigned windowbase = 4 * sregs[WINDOWBASE];
+ uint8_t stop_status[4] = "Sxx";
+#ifdef LIBC_LEVEL1_HANDLER
+ static const int cause[] = {
+ EXCCAUSE_LOAD_STORE_ERROR,
+ EXCCAUSE_LOAD_STORE_DATA_ERROR,
+ EXCCAUSE_LOAD_STORE_ADDR_ERROR,
+ EXCCAUSE_DTLB_MISS,
+ EXCCAUSE_DTLB_MULTIHIT,
+ EXCCAUSE_LOAD_PROHIBITED,
+ EXCCAUSE_STORE_PROHIBITED,
+ };
+ _xtos_handler handler[sizeof(cause) / sizeof(cause[0])];
+
+ for (i = 0; i < ARRAY_SIZE(cause); ++i) {
+ handler[i] = _xtos_exc_handler_table[cause[i]];
+ _xtos_exc_handler_table[cause[i]] = fault_handler;
+ }
+#endif
+ memcpy(sregs_read, sregs_late, sizeof(sregs_read));
+ memset(sregs_mod, 0, sizeof(sregs_mod));
+
+ sigval = 5;
+ stop_status[1] = hexchars[sigval >> 4];
+ stop_status[2] = hexchars[sigval & 0xf];
+
+ if (sregs[DEBUGCAUSE] & DEBUGCAUSE_ICOUNT_MASK) {
+ sregs[ICOUNTLEVEL] = 0;
+ mark_mod(ICOUNTLEVEL);
+ }
+ putpacket(stop_status);
+
+ while (1) {
+ remcomOutBuffer[0] = 0;
+
+ ptr = getpacket();
+ switch (*ptr++) {
+ case '?':
+ memcpy(remcomOutBuffer, stop_status, sizeof(stop_status));
+ break;
+
+ case 'c': /* cAA..AA Continue at address AA..AA(optional) */
+ /* try to read optional parameter, pc unchanged if no parm */
+
+ if (hexToInt(&ptr, &addr))
+ sregs[DEBUG_PC] = addr;
+ goto out;
+
+ case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
+ /* Try to read %x,%x. */
+
+ if (hexToInt(&ptr, &addr) && *ptr++ == ',' &&
+ hexToInt(&ptr, &length)) {
+ if (mem2hex((void *)addr, remcomOutBuffer, length))
+ break;
+
+ strcpy((char *)remcomOutBuffer, "E03");
+ } else {
+ strcpy((char *)remcomOutBuffer, "E01");
+ }
+ break;
+
+ case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
+ /* Try to read '%x,%x:'. */
+
+ if (hexToInt(&ptr, &addr) && *ptr++ == ',' &&
+ hexToInt(&ptr, &length) && *ptr++ == ':') {
+ if (hex2mem(ptr, (void *)addr, length))
+ strcpy((char *)remcomOutBuffer, "OK");
+ else
+ strcpy((char *)remcomOutBuffer, "E03");
+ } else {
+ strcpy((char *)remcomOutBuffer, "E02");
+ }
+ break;
+
+ case 'p': /* pAA..AA read register number AA..AA */
+ if (hexToInt(&ptr, &addr)) {
+ if (addr < 0x10) { /* read address register in the current window */
+ mem2hex(aregs + addr, remcomOutBuffer, 4);
+ } else if (addr == 0x20) { /* read PC */
+ mem2hex(sregs + DEBUG_PC, remcomOutBuffer, 4);
+ } else if (addr >= 0x100 && addr < 0x100 + XCHAL_NUM_AREGS) { /* read address register by absolute index */
+ mem2hex(aregs + ((addr - windowbase) & 0xff), remcomOutBuffer, 4);
+ } else if (addr >= 0x200 && addr < 0x300) { /* read special register */
+ addr &= 0xff;
+ read_sr(addr);
+ mem2hex(sregs + addr, remcomOutBuffer, 4);
+ } else if (addr >= 0x300 && addr < 0x400) { /* TODO read user register */
+ strcpy((char *)remcomOutBuffer, "deadbabe");
+ } else { /* unexpected register number */
+ strcpy((char *)remcomOutBuffer, "E00");
+ }
+ }
+ break;
+
+ case 'P': /* PAA..AA=VV..VV Set register number AA..AA to a value VV..VV */
+ if (hexToInt(&ptr, &addr) && *(ptr++) == '=') {
+ int ok = 1;
+
+ if (addr < 0x10) {
+ hex2mem(ptr, aregs + addr, 4);
+ } else if (addr == 0x20) {
+ hex2mem(ptr, sregs + DEBUG_PC, 4);
+ } else if (addr >= 0x100 && addr < 0x100 + XCHAL_NUM_AREGS) {
+ hex2mem(ptr, aregs + ((addr - windowbase) & 0xff), 4);
+ } else if (addr >= 0x200 && addr < 0x300) {
+ addr &= 0xff;
+ hex2mem(ptr, sregs + addr, 4);
+ mark_read(addr);
+ mark_mod(addr);
+ } else {
+ ok = 0;
+ strcpy((char *)remcomOutBuffer, "E00");
+ }
+ if (ok)
+ strcpy((char *)remcomOutBuffer, "OK");
+ }
+ break;
+
+ case 'q': /* generic query */
+ if (strncmp((char *)ptr, "Supported", 9) == 0)
+ strcpy((char *)remcomOutBuffer, "PacketSize=100"); /* must match BUFMAX */
+ break;
+
+ case 's': /* s[AA..AA] Single step */
+ if (hexToInt(&ptr, &addr))
+ sregs[DEBUG_PC] = addr;
+ sregs[ICOUNT] = 0xfffffffe;
+ mark_mod(ICOUNT);
+ sregs[ICOUNTLEVEL] = XCHAL_DEBUGLEVEL;
+ mark_mod(ICOUNTLEVEL);
+ goto out;
+
+ case 'Z': /* insert HW breakpoint*/
+ switch (*ptr++) {
+ case '1':
+ read_sr(IBREAKENABLE);
+ if (*ptr++ == ',' && hexToInt(&ptr, &addr) &&
+ *ptr++ == ',' && hexToInt(&ptr, &length) &&
+ *ptr == 0) {
+ for (i = 0; i < XCHAL_NUM_IBREAK; ++i) {
+ if (!(sregs[IBREAKENABLE] & (1 << i)) ||
+ sregs[IBREAKA + i] == addr) {
+ sregs[IBREAKA + i] = addr;
+ mark_mod(IBREAKA + i);
+ sregs[IBREAKENABLE] |= (1 << i);
+ mark_mod(IBREAKENABLE);
+ break;
+ }
+ }
+ if (i == XCHAL_NUM_IBREAK)
+ strcpy((char *)remcomOutBuffer, "E02");
+ else
+ strcpy((char *)remcomOutBuffer, "OK");
+ } else {
+ strcpy((char *)remcomOutBuffer, "E01");
+ }
+ break;
+ }
+ break;
+
+ case 'z': /* remove HW breakpoint */
+ switch (*ptr++) {
+ case '1':
+ read_sr(IBREAKENABLE);
+ if (*ptr++ == ',' && hexToInt(&ptr, &addr) &&
+ *ptr++ == ',' && hexToInt(&ptr, &length)) {
+ for (i = 0; i < XCHAL_NUM_IBREAK; ++i) {
+ read_sr(IBREAKA + i);
+ if (sregs[IBREAKENABLE] & (1 << i) &&
+ sregs[IBREAKA + i] == addr) {
+ sregs[IBREAKENABLE] &= ~(1 << i);
+ mark_mod(IBREAKENABLE);
+ break;
+ }
+ }
+ if (i == XCHAL_NUM_IBREAK)
+ strcpy((char *)remcomOutBuffer, "E02");
+ else
+ strcpy((char *)remcomOutBuffer, "OK");
+ } else {
+ strcpy((char *)remcomOutBuffer, "E01");
+ }
+ break;
+ }
+ break;
+ }
+
+ /* reply to the request */
+ putpacket(remcomOutBuffer);
+ }
+out:
+#ifdef LIBC_LEVEL1_HANDLER
+ for (i = 0; i < ARRAY_SIZE(cause); ++i) {
+ _xtos_exc_handler_table[cause[i]] = handler[i];
+ }
+#endif
+ restore_sr();
+}
+
+void init_gdbstub(void)
+{
+ mark_late(LBEG);
+ mark_late(LEND);
+ mark_late(LCOUNT);
+ mark_late(SAR);
+ mark_late(WINDOWBASE);
+ mark_late(WINDOWSTART);
+ mark_late(DEBUG_PC);
+ mark_late(EXCSAVE_1);
+ mark_late(PS);
+ mark_late(EXCCAUSE);
+ mark_late(DEBUGCAUSE);
+ mark_late(EXCVADDR);
+#ifdef __XTENSA__
+ init_debug_comm();
+ init_debug_entry();
+#endif
+}
diff --git a/hifi/xaf/hifi-dpf/core/util/gdbstub/xtensa-defs.h b/hifi/xaf/hifi-dpf/core/util/gdbstub/xtensa-defs.h
new file mode 100644
index 00000000..6ba485ff
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/util/gdbstub/xtensa-defs.h
@@ -0,0 +1,37 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 XTENSA_DEFS_H
+#define XTENSA_DEFS_H
+
+#include <xtensa/specreg.h>
+#include <xtensa/config/core-isa.h>
+#include <xtensa/corebits.h>
+
+#define _AREG0 256
+
+#define STACK_SIZE 1024
+#define DEBUG_PC (EPC + XCHAL_DEBUGLEVEL)
+#define DEBUG_EXCSAVE (EXCSAVE + XCHAL_DEBUGLEVEL)
+#define DEBUG_PS (EPS + XCHAL_DEBUGLEVEL)
+
+#endif /* XTENSA_DEFS_H */
diff --git a/hifi/xaf/hifi-dpf/core/util/mutex.c b/hifi/xaf/hifi-dpf/core/util/mutex.c
new file mode 100644
index 00000000..d62a6a17
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/util/mutex.c
@@ -0,0 +1,156 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * mutex.c
+ *
+ * Implementation of non-robust Szymanski linear-waiting algorithm. Types of
+ * failures tolerated by Szymanski's "robust" algorithm are not specific for
+ * Xtensa DSP cluster and therefore more lightweight version of the algorithm
+ * is used. FIFO servicing property is of low importance, and faster/smaller
+ * version with linear-wait property is preferable.
+ ******************************************************************************/
+
+#include "xf.h"
+
+/*******************************************************************************
+ * Local constants definitions
+ ******************************************************************************/
+
+/* ...communication variables */
+#define __M_A (1 << 0)
+#define __M_W (1 << 1)
+#define __M_S (1 << 2)
+
+/* ...process states (updated atomically) */
+#define M_PASSIVE (0)
+#define M_ENTRY (__M_A)
+#define M_INSIDE (__M_W)
+#define M_TRANSIENT (__M_S | __M_W)
+#define M_EXIT (__M_S)
+
+/* ...total number of cores */
+#define M_N XF_CFG_CORES_NUM
+
+/* ...do not compile the code if there is just a single core */
+#if M_N > 1
+/*******************************************************************************
+ * Entry points
+ ******************************************************************************/
+
+void mutex_lock(u32 i)
+{
+ u32 j;
+
+ /* ...p1: i-th core goes into "entry" state (aws = true,false,false) */
+ MUTEX_SHARED_WRITE(i, M_ENTRY);
+
+ /* ...p2: wait all processes have sj=false (waiting room door is open) */
+ for (j = 0; j < M_N; j++)
+ {
+ /* ...wait until sj = false */
+ while (MUTEX_SHARED_READ(j) & __M_S) (void) 0;
+ }
+
+ /* ...p3: i-th core enters "inside" state (aws = false,true,false) */
+ MUTEX_SHARED_WRITE(i, M_INSIDE);
+
+p4:
+ /* ...p4: wait in "inside" state */
+ for (j = 0; j < M_N; j++)
+ {
+ /* ...p5: check if any of the cores appears is in "entry" state (aj=true) */
+ if (MUTEX_SHARED_READ(j) & __M_A)
+ {
+ /* ...p5: found core in "entry" state (j < n); wait until it enters waiting room */
+ goto p7;
+ }
+ }
+
+ /* ...p6: j == n; enter into "transient" state (ai=false, wi=true, si=true) */
+ MUTEX_SHARED_WRITE(i, M_TRANSIENT);
+
+ /* ...p6.1: check for any core appearing in "entry" room */
+ for (j = 0; j < M_N; j++)
+ {
+ if (MUTEX_SHARED_READ(j) & __M_A)
+ {
+ /* ...p6.2: found core in "entry" state (j < n) */
+ MUTEX_SHARED_WRITE(i, M_INSIDE);
+
+ /* ...back of to the "inside" state */
+ goto p7;
+ }
+ }
+
+ /* ...p6.3: no cores in "entry" room (j == n); go to "exit" state (ai=false, wi=false, si=true) */
+ MUTEX_SHARED_WRITE(i, M_EXIT);
+
+ /* ...p6.4: allow all cores to leave "transient" state (i.e. switch to "exit") */
+ for (j = 0; j < M_N; j++)
+ {
+ while (MUTEX_SHARED_READ(j) & __M_W) (void) 0;
+ }
+
+ goto p9;
+
+p7:
+ /* ...j < n condition is met; find any cores in "inside" state (wj = true, sj = false) */
+ for (j = 0; j < M_N; j++)
+ {
+ /* ...check if the core is in "exit" state */
+ if (MUTEX_SHARED_READ(j) == M_EXIT)
+ {
+ /* ...p8.1: different core is a leader; go to "exit" state (ai=false, wi=false, si=true) */
+ MUTEX_SHARED_WRITE(i, M_EXIT);
+
+ goto p9;
+ }
+ }
+
+ /* ...wait in "inside" state while all transients settle */
+ goto p4;
+
+p9:
+ /* ...p9: i-th core is in "exit" state; enter critical section in accordance with numbering */
+ for (j = 0; j < i; j++)
+ {
+ /* ...wait until core with lower number in "inside"/"transient"/"exit" states leaves */
+ while (MUTEX_SHARED_READ(j) & (__M_W | __M_S)) (void) 0;
+ }
+
+ /* ...critical section entered */
+}
+
+/*******************************************************************************
+ * mutex_unlock
+ *
+ * Release multi-core mutex
+ ******************************************************************************/
+
+void mutex_unlock(u32 i)
+{
+ /* ...enter into "passive" state (ai=false, wi=false, si=false) */
+ MUTEX_SHARED_WRITE(i, M_PASSIVE);
+}
+
+#endif /* M_N > 1 */
diff --git a/hifi/xaf/hifi-dpf/core/util/rbtree.c b/hifi/xaf/hifi-dpf/core/util/rbtree.c
new file mode 100644
index 00000000..740e0255
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/util/rbtree.c
@@ -0,0 +1,842 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * rbtree.c
+ *
+ * Red-black tree library
+ ******************************************************************************/
+
+#include "xf.h"
+
+/*******************************************************************************
+ * Macros definitions
+ ******************************************************************************/
+
+/* ...node color */
+#define RB_RED (1)
+#define RB_BLK (0)
+
+/* ...pointer to parent node */
+#define RB_PARENT(tree, node) ((node)->parent)
+
+/* ...pointer to left child node */
+#define RB_LEFT(tree, node) ((node)->left)
+
+/* ...pointer to right child node */
+#define RB_RIGHT(tree, node) ((node)->right)
+
+/* ...pointer to right child node */
+#define RB_COLOR(tree, node) ((node)->color & 1)
+
+/* ...check if node is black */
+#define RB_IS_BLACK(tree, node) (!((node)->color & RB_RED))
+
+/* ...root node index of the tree - can be simplified? */
+#define RB_ROOT(tree) RB_LEFT((tree), &(tree)->root)
+
+/* ...empty node */
+#define RB_NULL(tree) (&(tree)->root)
+
+/*******************************************************************************
+ * Helpers
+ ******************************************************************************/
+
+#define RB_SET_P(t, n, p) \
+ ({ (n)->parent = (p); })
+
+#define RB_SET_L(t, n, l) \
+ ({ (n)->left = (l); })
+
+#define RB_SET_R(t, n, r) \
+ ({ (n)->right = (r); })
+
+#define RB_SET_C(t, n, c) \
+ RB_SET_C_##c((t), (n))
+
+#define RB_SET_C_RB_BLK(t, n) \
+ ({ (n)->color &= ~1; })
+
+#define RB_SET_C_RB_RED(t, n) \
+ ({ (n)->color |= 1; })
+
+#define RB_SET_P_C(t, n, p, c) \
+ ({ (n)->parent = (p); RB_SET_C_##c(t, n); })
+
+#define RB_SET_P_L(t, n, p, l) \
+ ({ (n)->parent = (p); (n)->left = (l); })
+
+#define RB_SET_P_L_C(t, n, p, l, c) \
+ ({ (n)->parent = (p); (n)->left = (l); RB_SET_C_##c(t, n); })
+
+#define RB_SET_P_R(t, n, p, r) \
+ ({ (n)->parent = (p); (n)->right = (r); })
+
+#define RB_SET_P_R_C(t, n, p, r, c) \
+ ({ (n)->parent = (p); (n)->right = (r); RB_SET_C_##c(t, n); })
+
+#define RB_SET_P_L_R(t, n, p, l, r) \
+ ({ (n)->parent = (p); (n)->left = (l); (n)->right = (r); })
+
+#define RB_SET_P_L_R_C(t, n, p, l, r, c)\
+ ({ (n)->parent = (p); (n)->left = (l); (n)->right = (r); RB_SET_C_##c(t, n); })
+
+#define RB_SET_ROOT(t, n) \
+ RB_SET_L((t), &(t)->root, (n))
+
+/*******************************************************************************
+ * RB-tree functions
+ ******************************************************************************/
+
+/*******************************************************************************
+ * rb_first, rb_last
+ *
+ * Return pointer to first/last item in the tree
+ ******************************************************************************/
+
+rb_idx_t rb_first(rb_tree_t *tree)
+{
+ rb_idx_t p_idx, t_idx;
+
+ if ((p_idx = RB_ROOT(tree)) != RB_NULL(tree))
+ {
+ /* ...find left-most item in non-empty tree */
+ while ((t_idx = RB_LEFT(tree, p_idx)) != RB_NULL(tree))
+ p_idx = t_idx;
+ }
+
+ return p_idx;
+}
+
+rb_idx_t rb_last(rb_tree_t *tree)
+{
+ rb_idx_t p_idx, t_idx;
+
+ if ((p_idx = RB_ROOT(tree)) != RB_NULL(tree))
+ {
+ /* ...find right-most item in non-empty tree */
+ while ((t_idx = RB_RIGHT(tree, p_idx)) != RB_NULL(tree))
+ p_idx = t_idx;
+ }
+
+ return p_idx;
+}
+
+/*******************************************************************************
+ * rb_next, rb_prev
+ *
+ * Return next / previous in-order item in the tree
+ ******************************************************************************/
+
+rb_idx_t rb_next(rb_tree_t *tree, rb_idx_t n_idx)
+{
+ rb_idx_t p_idx, c_idx, t_idx;
+
+ /* ...if we have any right children, process them */
+ if ((c_idx = RB_RIGHT(tree, n_idx)) != RB_NULL(tree))
+ {
+ /* ...descent to the left-most node starting from right child */
+ while ((t_idx = RB_LEFT(tree, c_idx)) != RB_NULL(tree))
+ c_idx = t_idx;
+ return c_idx;
+ }
+
+ /* ...no right children; ascend to our parent while we are right child */
+ while ((p_idx = RB_PARENT(tree, n_idx)) != RB_NULL(tree))
+ {
+ /* ...as soon as "n" is a left child, return "p" */
+ if (n_idx == RB_RIGHT(tree, p_idx))
+ n_idx = p_idx;
+ else
+ return p_idx;
+ }
+
+ /* ...we were right-most child */
+ return p_idx;
+}
+
+rb_idx_t rb_prev(rb_tree_t *tree, rb_idx_t n_idx)
+{
+ rb_idx_t p_idx, c_idx, t_idx;
+
+ /* ...if we have any left children, process them */
+ if ((c_idx = RB_LEFT(tree, n_idx)) != RB_NULL(tree))
+ {
+ /* ...descent to the right-most node starting from left child */
+ while ((t_idx = RB_RIGHT(tree, c_idx)) != RB_NULL(tree))
+ c_idx = t_idx;
+ return c_idx;
+ }
+
+ /* ...no left children; ascend to our parent while we are left child */
+ while ((p_idx = RB_PARENT(tree, n_idx)) != RB_NULL(tree))
+ {
+ /* ...as soon as "n" is a right child, return "p" */
+ if (n_idx == RB_LEFT(tree, p_idx))
+ n_idx = p_idx;
+ else
+ return p_idx;
+ }
+
+ /* ...we were left-most child */
+ return p_idx;
+}
+
+/*******************************************************************************
+ * rb_init
+ *
+ * Initialize rb-tree structure
+ ******************************************************************************/
+
+void rb_init(rb_tree_t *tree)
+{
+ /* ...initialize sentinel node of the empty tree */
+ RB_SET_P_L_R_C(tree, &tree->root, RB_NULL(tree), RB_NULL(tree), RB_NULL(tree), RB_BLK);
+}
+
+/*******************************************************************************
+ * rb_insert
+ *
+ * Insert new item into RB-tree. Returns non-zero node index on success
+ ******************************************************************************/
+
+/* ...internal tree balancing function */
+static void __rb_insert_balance(rb_tree_t *tree, rb_idx_t n_idx, rb_idx_t p_idx)
+{
+ rb_idx_t u_idx, g_idx, t_idx, cl_idx, cr_idx;
+
+rebalance:
+
+ /***************************************************************************
+ * Trivial case #1 - N (red) is a root
+ **************************************************************************/
+
+ if (p_idx == RB_NULL(tree))
+ {
+ RB_SET_C(tree, n_idx, RB_BLK);
+ goto root;
+ }
+
+ /***************************************************************************
+ * Trivial case #2 - P is black
+ **************************************************************************/
+
+ if (RB_IS_BLACK(tree, p_idx))
+ goto done;
+
+ /***************************************************************************
+ * Complex cases - P is red, N is red
+ **************************************************************************/
+
+ /* ...grandparent must exist and be black */
+ g_idx = RB_PARENT(tree, p_idx);
+ if (p_idx == RB_LEFT(tree, g_idx))
+ {
+ /* ...we are left grandchild; get uncle (if it exists) */
+ u_idx = RB_RIGHT(tree, g_idx);
+
+ /* ...if U is read, we have conditions of case #3 */
+ if (!RB_IS_BLACK(tree, u_idx))
+ goto case3;
+
+ /* ...we will need grand-grand-parent later */
+ t_idx = RB_PARENT(tree, g_idx);
+
+ /* ...U is black/null; if we are LL grandchild, we have case #5 */
+ if (n_idx == RB_LEFT(tree, p_idx))
+ goto case5_ll;
+
+ /* ...N is RL grandchild of G; case #4 */
+ goto case4_rl;
+ }
+ else
+ {
+ /* ...we are right grandchild; get uncle (if it exists) */
+ u_idx = RB_LEFT(tree, g_idx);
+
+ /* ...if U is read, we have conditions of case #3 */
+ if (!RB_IS_BLACK(tree, u_idx))
+ goto case3;
+
+ /* ...we will need grand-grand-parent later */
+ t_idx = RB_PARENT(tree, g_idx);
+
+ /* ...U is black/null; if we are RR grandchild, we have case #5 */
+ if (n_idx == RB_RIGHT(tree, p_idx))
+ goto case5_rr;
+
+ /* ...N is LR grandchild of G; case #4 */
+ goto case4_lr;
+ }
+
+case4_rl:
+
+ /***************************************************************************
+ * Case #4 - P is red, U is black, N is red RL grandchild of G. We will do
+ * two tree rotations - first the one described in case #4, second is the
+ * one described in case #5 (as have conditions for case #5(LL) with P and
+ * N changing roles
+ **************************************************************************/
+
+ cl_idx = RB_LEFT(tree, n_idx), cr_idx = RB_RIGHT(tree, n_idx);
+ RB_SET_P_L_R_C(tree, n_idx, t_idx, p_idx, g_idx, RB_BLK);
+ RB_SET_P_R(tree, p_idx, n_idx, cl_idx);
+ RB_SET_P(tree, cl_idx, p_idx);
+ RB_SET_P_L_C(tree, g_idx, n_idx, cr_idx, RB_RED);
+ RB_SET_P(tree, cr_idx, g_idx);
+
+ /* ...new root of subtree is N; adjust T pointer */
+ goto case5_xx;
+
+case4_lr:
+
+ /***************************************************************************
+ * Case #4 - P is red, U is black, N is red LR grandchild of G. We will do
+ * two tree rotations - first the one described in case #4, second is the
+ * one described in case #5 (as have conditions for case #5(RR) with P and
+ * N changing roles
+ **************************************************************************/
+
+ cl_idx = RB_LEFT(tree, n_idx), cr_idx = RB_RIGHT(tree, n_idx);
+ RB_SET_P_L_R_C(tree, n_idx, t_idx, g_idx, p_idx, RB_BLK);
+ RB_SET_P_L(tree, p_idx, n_idx, cr_idx);
+ RB_SET_P(tree, cr_idx, p_idx);
+ RB_SET_P_R_C(tree, g_idx, n_idx, cl_idx, RB_RED);
+ RB_SET_P(tree, cl_idx, g_idx);
+
+ /* ...new root of the subtree is N; adjust T pointer */
+ goto case5_xx;
+
+case5_ll:
+
+ /***************************************************************************
+ * Case #5: N is LL grandchild of P; N and P red, G and U black
+ **************************************************************************/
+
+ cr_idx = RB_RIGHT(tree, p_idx);
+ RB_SET_P_L_C(tree, g_idx, p_idx, cr_idx, RB_RED);
+ RB_SET_P(tree, cr_idx, g_idx);
+ RB_SET_P_R_C(tree, p_idx, t_idx, g_idx, RB_BLK);
+
+ /* ...new root of the subtree is P; relabel and adjust T pointer */
+ n_idx = p_idx;
+ goto case5_xx;
+
+case5_rr:
+
+ /***************************************************************************
+ * Case #5: N is RR grandchild of P; N and P red, G and U black
+ **************************************************************************/
+
+ cl_idx = RB_LEFT(tree, p_idx);
+ RB_SET_P_R_C(tree, g_idx, p_idx, cl_idx, RB_RED);
+ RB_SET_P(tree, cl_idx, g_idx);
+ RB_SET_P_L_C(tree, p_idx, t_idx, g_idx, RB_BLK);
+
+ /* ...new root of the subtree is P; relabel and adjust T pointer */
+ n_idx = p_idx;
+ goto case5_xx;
+
+case5_xx:
+
+ /* ...N is a (black) root of subtree; check if it is a root of tree as well */
+ if (t_idx == RB_NULL(tree))
+ goto root;
+ else if (g_idx == RB_LEFT(tree, t_idx))
+ RB_SET_L(tree, t_idx, n_idx);
+ else
+ RB_SET_R(tree, t_idx, n_idx);
+
+ goto done;
+
+case3:
+
+ /***************************************************************************
+ * Case #3 - P and U are red, G is black
+ **************************************************************************/
+
+ RB_SET_C(tree, p_idx, RB_BLK);
+ RB_SET_C(tree, u_idx, RB_BLK);
+ RB_SET_C(tree, g_idx, RB_RED);
+
+ /* ...rebalance the tree for a G */
+ n_idx = g_idx, p_idx = RB_PARENT(tree, g_idx);
+ goto rebalance;
+
+root:
+ /* ...adjust root pointer of the tree */
+ RB_SET_ROOT(tree, n_idx);
+
+done:
+ /* ...tree is balanced */
+ return;
+}
+
+/* ...high-level API function */
+void rb_insert(rb_tree_t *tree, rb_idx_t n_idx, rb_idx_t p_idx)
+{
+ if (p_idx == RB_NULL(tree))
+ {
+ /* ...set black root node */
+ RB_SET_P_L_R_C(tree, n_idx, p_idx, p_idx, p_idx, RB_BLK);
+
+ /* ...tree consists of the only root node; is balanced */
+ RB_SET_ROOT(tree, n_idx);
+ }
+ else
+ {
+ /* ...create new node - set parent pointer and paint red */
+ RB_SET_P_L_R_C(tree, n_idx, p_idx, RB_NULL(tree), RB_NULL(tree), RB_RED);
+
+ /* ...and rebalance the tree */
+ __rb_insert_balance(tree, n_idx, p_idx);
+ }
+}
+
+/*******************************************************************************
+ * rb_delete
+ *
+ * Remove item from RB-key (by key). Returns zero on success
+ ******************************************************************************/
+
+/* ...internal tree balancing function */
+static void __rb_delete_rebalance(rb_tree_t *tree, rb_idx_t p_idx)
+{
+ rb_idx_t n_idx, s_idx, sl_idx, sr_idx, g_idx, c_idx, cl_idx, cr_idx;
+
+ /* ...initialize rebalancing procedure with null-child of P */
+ n_idx = RB_NULL(tree);
+
+rebalance:
+
+ /* ...save grand-parent pointer (may be null) */
+ g_idx = RB_PARENT(tree, p_idx);
+
+ /***************************************************************************
+ * Check for complex cases
+ **************************************************************************/
+
+ if (n_idx == RB_LEFT(tree, p_idx))
+ {
+ /* ...N is left child; get sibling (must exist) and its children */
+ s_idx = RB_RIGHT(tree, p_idx);
+ sl_idx = RB_LEFT(tree, s_idx);
+ sr_idx = RB_RIGHT(tree, s_idx);
+
+ /* ...if S is black, test for conditions 3,4,5,6; otherwise - case 2 */
+ if (RB_IS_BLACK(tree, s_idx))
+ goto test3_l;
+ else
+ goto case2_l;
+ }
+ else
+ {
+ /* ...N is right child; get sibling (must exist) and its children */
+ s_idx = RB_LEFT(tree, p_idx);
+ sl_idx = RB_LEFT(tree, s_idx);
+ sr_idx = RB_RIGHT(tree, s_idx);
+
+ /* ...if S is black, test for conditions 3,4,5,6; otherwise - case 2 */
+ if (RB_IS_BLACK(tree, s_idx))
+ goto test3_r;
+ else
+ goto case2_r;
+ }
+
+case2_l:
+
+ /***************************************************************************
+ * Case #2: N is a left child of P; S is red
+ **************************************************************************/
+
+ c_idx = sl_idx;
+ RB_SET_P_L_C(tree, s_idx, g_idx, p_idx, RB_BLK);
+ RB_SET_P_R_C(tree, p_idx, s_idx, c_idx, RB_RED);
+ RB_SET_P(tree, c_idx, p_idx);
+
+ /* ...S is new root of subtree, Sl(C) is new sibling of N; update G */
+ goto case2_x;
+
+case2_r:
+
+ /***************************************************************************
+ * Case #2: N is a right child of P; S is red
+ **************************************************************************/
+
+ c_idx = sr_idx;
+ RB_SET_P_R_C(tree, s_idx, g_idx, p_idx, RB_BLK);
+ RB_SET_P_L_C(tree, p_idx, s_idx, c_idx, RB_RED);
+ RB_SET_P(tree, c_idx, p_idx);
+
+ /* ...S is new root of subtree, Sr(C) is new sibling of N; update G */
+ goto case2_x;
+
+case2_x:
+
+ /* ...check if S is becoming new (black) root of the tree */
+ if (g_idx == RB_NULL(tree))
+ RB_SET_ROOT(tree, s_idx);
+ else if (p_idx == RB_LEFT(tree, g_idx))
+ RB_SET_L(tree, g_idx, s_idx);
+ else
+ RB_SET_R(tree, g_idx, s_idx);
+
+ /* ...relabel new N's grandparent (now S) as G and new sibling (now C) as S */
+ g_idx = s_idx, s_idx = c_idx;
+ sl_idx = RB_LEFT(tree, s_idx);
+ sr_idx = RB_RIGHT(tree, s_idx);
+
+ /* ...N is still one of P's children; select proper side */
+ if (n_idx == RB_LEFT(tree, p_idx))
+ goto test3_l;
+ else
+ goto test3_r;
+
+test3_l:
+
+ /***************************************************************************
+ * Test for cases 3,4,5,6; P is any, S is black. N is left child of P
+ **************************************************************************/
+
+ if (!RB_IS_BLACK(tree, sr_idx))
+ /* ...Sr is red, Sl of any color; conditions for case #6 are met */
+ goto case6_l;
+ else if (!RB_IS_BLACK(tree, sl_idx))
+ /* ...Sr is black and Sl is red; conditions for case #5 are met */
+ goto case5_l;
+ else if (RB_IS_BLACK(tree, p_idx))
+ /* ...Sl and Sr are of the same (black) color and P is black */
+ goto case3;
+ else
+ /* ...Sl and Sr are of the same (black) color and P is red */
+ goto case4;
+
+test3_r:
+
+ /***************************************************************************
+ * Test for cases 3,4,5,6; P is any, S is black. N is right child of P
+ **************************************************************************/
+
+ if (!RB_IS_BLACK(tree, sl_idx))
+ /* ...Sl is red, Sr of any color; conditions for case #6 are met */
+ goto case6_r;
+ else if (!RB_IS_BLACK(tree, sr_idx))
+ /* ...Sl is black and Sr is red; conditions for case #5 are met */
+ goto case5_r;
+ else if (RB_IS_BLACK(tree, p_idx))
+ /* ...Sl and Sr are of the same (black) color and P is black */
+ goto case3;
+ else
+ /* ...Sl and Sr are of the same (black) color and P is red */
+ goto case4;
+
+case3:
+
+ /***************************************************************************
+ * Case #3: N, P, S, Sl and Sr are black
+ **************************************************************************/
+
+ RB_SET_C(tree, s_idx, RB_RED);
+
+ /* ...and rebalance the tree for parent */
+ n_idx = p_idx, p_idx = RB_PARENT(tree, p_idx);
+
+ if (p_idx == RB_NULL(tree))
+ goto done;
+ else
+ goto rebalance;
+
+case4:
+
+ /***************************************************************************
+ * Case #4: N and S are black, P is red, Sl and Sr are all black
+ **************************************************************************/
+
+ RB_SET_C(tree, s_idx, RB_RED);
+ RB_SET_C(tree, p_idx, RB_BLK);
+
+ goto done;
+
+case5_l:
+ /***************************************************************************
+ * Case #5: S is black, Sl is red, Sr is black; N is left child of P. We
+ * have two subsequent transformations (case #5 and case #6) combined
+ **************************************************************************/
+
+ cl_idx = RB_LEFT(tree, sl_idx);
+ cr_idx = RB_RIGHT(tree, sl_idx);
+
+ if (RB_IS_BLACK(tree, p_idx))
+ RB_SET_P_L_R_C(tree, sl_idx, g_idx, p_idx, s_idx, RB_BLK);
+ else
+ RB_SET_P_L_R_C(tree, sl_idx, g_idx, p_idx, s_idx, RB_RED);
+
+ RB_SET_P_R_C(tree, p_idx, sl_idx, cl_idx, RB_BLK);
+ RB_SET_P(tree, cl_idx, p_idx);
+ RB_SET_P_L(tree, s_idx, sl_idx, cr_idx);
+ RB_SET_P(tree, cr_idx, s_idx);
+
+ /* ...relabel new root as S (for common processing in case #6) */
+ s_idx = sl_idx;
+ goto case6_x;
+
+case5_r:
+ /***************************************************************************
+ * Case #5: S is black, Sr is red, Sl is black; N is right child of P. We
+ * have two subsequent transformations (case #5 and case #6) combined
+ **************************************************************************/
+
+ cl_idx = RB_LEFT(tree, sr_idx);
+ cr_idx = RB_RIGHT(tree, sr_idx);
+
+ if (RB_IS_BLACK(tree, p_idx))
+ RB_SET_P_L_R_C(tree, sr_idx, g_idx, s_idx, p_idx, RB_BLK);
+ else
+ RB_SET_P_L_R_C(tree, sr_idx, g_idx, s_idx, p_idx, RB_RED);
+
+ RB_SET_P_L_C(tree, p_idx, sr_idx, cr_idx, RB_BLK);
+ RB_SET_P(tree, cr_idx, p_idx);
+ RB_SET_P_R(tree, s_idx, sr_idx, cl_idx);
+ RB_SET_P(tree, cl_idx, s_idx);
+
+ /* ...relabel new root as S (for common processing in case #6) */
+ s_idx = sr_idx;
+ goto case6_x;
+
+case6_l:
+
+ /***************************************************************************
+ * Case #6: S is black, N is the left child of P, Sr is red
+ **************************************************************************/
+
+ if (RB_IS_BLACK(tree, p_idx))
+ RB_SET_P_L(tree, s_idx, g_idx, p_idx);
+ else
+ RB_SET_P_L_C(tree, s_idx, g_idx, p_idx, RB_RED);
+
+ RB_SET_P_R_C(tree, p_idx, s_idx, sl_idx, RB_BLK);
+ RB_SET_P(tree, sl_idx, p_idx);
+ RB_SET_C(tree, sr_idx, RB_BLK);
+
+ /* ...S is a new root of subtree; update G */
+ goto case6_x;
+
+case6_r:
+
+ /***************************************************************************
+ * Case #6: S is black, N is the right child of P, Sl is red
+ **************************************************************************/
+
+ if (RB_IS_BLACK(tree, p_idx))
+ RB_SET_P_R(tree, s_idx, g_idx, p_idx);
+ else
+ RB_SET_P_R_C(tree, s_idx, g_idx, p_idx, RB_RED);
+
+ RB_SET_P_L_C(tree, p_idx, s_idx, sr_idx, RB_BLK);
+ RB_SET_P(tree, sr_idx, p_idx);
+ RB_SET_C(tree, sl_idx, RB_BLK);
+
+ /* ...S is a new root of subtree; update G */
+ goto case6_x;
+
+case6_x:
+
+ /* ...S is a new root of subtree; update G's pointer */
+ if (g_idx == RB_NULL(tree))
+ RB_SET_ROOT(tree, s_idx);
+ else if (p_idx == RB_LEFT(tree, g_idx))
+ RB_SET_L(tree, g_idx, s_idx);
+ else
+ RB_SET_R(tree, g_idx, s_idx);
+
+ /* ...tree is balanced; pass through */
+
+done:
+
+ return;
+}
+
+/* ...high-level API function */
+rb_idx_t rb_delete(rb_tree_t *tree, rb_idx_t n_idx)
+{
+ rb_idx_t p_idx, t_idx, m_idx, c_idx, l_idx, r_idx, k_idx;
+ u32 color;
+
+ /* ...save parent of element N that we are going to remove */
+ p_idx = RB_PARENT(tree, n_idx);
+
+ /* ...get in-order predecessor/successor of n_idx, if possible */
+ if ((m_idx = RB_LEFT(tree, n_idx)) != RB_NULL(tree))
+ {
+ while ((t_idx = RB_RIGHT(tree, m_idx)) != RB_NULL(tree))
+ m_idx = t_idx;
+
+ /* ...set the child of in-order predecessor (may be null) */
+ c_idx = RB_LEFT(tree, m_idx);
+ }
+ else if ((m_idx = RB_RIGHT(tree, n_idx)) != RB_NULL(tree))
+ {
+ while ((t_idx = RB_LEFT(tree, m_idx)) != RB_NULL(tree))
+ m_idx = t_idx;
+
+ /* ...set the child of in-order successor (may be null) */
+ c_idx = RB_RIGHT(tree, m_idx);
+ }
+ else if (p_idx == RB_NULL(tree))
+ {
+ /* ...tree consists of the only root node N that we are removing */
+ RB_SET_ROOT(tree, m_idx);
+
+ /* ..return tree null pointer */
+ return m_idx;
+ }
+ else
+ {
+ /* ...N is a (non-root) leaf node; M and C are null */
+ c_idx = m_idx;
+
+ /* ...save the color of the node we are going to delete */
+ color = RB_COLOR(tree, n_idx);
+
+ /* ...set new parent of C */
+ t_idx = p_idx;
+
+ /* ...pointer that we return as in-order predecessor/successor */
+ k_idx = p_idx;
+
+ /* ...adjust only parent of the N */
+ goto adjust_parent;
+ }
+
+ /* ...node that replaces our component is M */
+ k_idx = m_idx;
+
+ /***************************************************************************
+ * Replace node N with M
+ **************************************************************************/
+
+ /* ...save original color of M (the node that we are deleting) */
+ color = RB_COLOR(tree, m_idx);
+
+ /* ...put M in place of N; get N's children */
+ l_idx = RB_LEFT(tree, n_idx);
+ r_idx = RB_RIGHT(tree, n_idx);
+
+ /* ...see if M is a child of N */
+ if ((t_idx = RB_PARENT(tree, m_idx)) != n_idx)
+ {
+ /* ...C becomes left or right child of M's original parent T */
+ if (c_idx == RB_LEFT(tree, m_idx))
+ RB_SET_R(tree, t_idx, c_idx);
+ else
+ RB_SET_L(tree, t_idx, c_idx);
+
+ /* ...adjust C parent pointer (okay if it's null) */
+ RB_SET_P(tree, c_idx, t_idx);
+
+ /* ...set all pointers of node M (it replaces N) */
+ RB_SET_P_L_R(tree, m_idx, p_idx, l_idx, r_idx);
+ RB_SET_P(tree, l_idx, m_idx);
+ RB_SET_P(tree, r_idx, m_idx);
+ }
+ else
+ {
+ /* ...M is a left or right child of N; it gets to N's place, and C remains intact */
+ if (m_idx == l_idx)
+ {
+ RB_SET_P_R(tree, m_idx, p_idx, r_idx);
+ RB_SET_P(tree, r_idx, m_idx);
+ }
+ else
+ {
+ RB_SET_P_L(tree, m_idx, p_idx, l_idx);
+ RB_SET_P(tree, l_idx, m_idx);
+ }
+
+ /* ...parent of C is still M (we label it as T) */
+ t_idx = m_idx;
+ }
+
+ /* ...paint M in the same color as N which it replaced */
+ if (RB_IS_BLACK(tree, n_idx))
+ RB_SET_C(tree, m_idx, RB_BLK);
+ else
+ RB_SET_C(tree, m_idx, RB_RED);
+
+adjust_parent:
+
+ /* ...adjust N's parent node to point to M */
+ if (p_idx == RB_NULL(tree))
+ RB_SET_ROOT(tree, m_idx);
+ else if (n_idx == RB_LEFT(tree, p_idx))
+ RB_SET_L(tree, p_idx, m_idx);
+ else
+ RB_SET_R(tree, p_idx, m_idx);
+
+ /* ...check for a color of deleted item (M or N in case it is a leaf) */
+ if (color == RB_BLK)
+ {
+ if (c_idx == RB_NULL(tree))
+ /* ...rebalance the tree for a T node (it is never a null)*/
+ __rb_delete_rebalance(tree, t_idx);
+ else
+ /* ...C node exists and is necessarily red; repaint it black */
+ RB_SET_C(tree, c_idx, RB_BLK);
+ }
+
+ /* ....return the node K which replaced deleted node N */
+ return k_idx;
+}
+
+/*******************************************************************************
+ * rb_replace
+ *
+ * Replace the node with the same-key node - adjust tree pointers
+ ******************************************************************************/
+
+void rb_replace(rb_tree_t *tree, rb_idx_t n_idx, rb_idx_t t_idx)
+{
+ rb_idx_t p_idx, l_idx, r_idx;
+
+ /* ...get node pointers */
+ p_idx = RB_PARENT(tree, n_idx), l_idx = RB_LEFT(tree, n_idx), r_idx = RB_RIGHT(tree, n_idx);
+
+ /* ...set new node pointers */
+ RB_SET_P_L_R(tree, t_idx, p_idx, l_idx, r_idx);
+
+ /* ...set node color */
+ if (RB_IS_BLACK(tree, n_idx))
+ RB_SET_C(tree, t_idx, RB_BLK);
+ else
+ RB_SET_C(tree, t_idx, RB_RED);
+
+ /* ...update parent node */
+ if (p_idx == RB_NULL(tree))
+ RB_SET_ROOT(tree, t_idx);
+ else if (n_idx == RB_LEFT(tree, p_idx))
+ RB_SET_L(tree, p_idx, t_idx);
+ else
+ RB_SET_R(tree, p_idx, t_idx);
+
+ /* ...update children's parent node (okay if null) */
+ RB_SET_P(tree, l_idx, t_idx), RB_SET_P(tree, r_idx, t_idx);
+}
diff --git a/hifi/xaf/hifi-dpf/core/util/tinyvprintf.c b/hifi/xaf/hifi-dpf/core/util/tinyvprintf.c
new file mode 100644
index 00000000..25d7e03e
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/util/tinyvprintf.c
@@ -0,0 +1,198 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+
+#include <string.h>
+#include "lib/tinyput.h"
+
+
+/*
+ * Simple formatted output routine.
+ * Designed primarily for small size (and secondarily for efficiency).
+ * Only a common subset of printf formats and options are handled:
+ *
+ * %[-+ ][0][width]i decimal signed integer
+ * %[-+ ][0][width]d decimal signed integer
+ * %[-][0][width]u decimal unsigned integer
+ * %[-][0][width]x hex unsigned integer
+ * %[-][0][width]p hex unsigned integer with 0x prefix ("pointer")
+ * %[-][width]c single character
+ * %[-][width]s string
+ *
+ * These modifiers are ignored (legally on 32-bit Xtensa):
+ * # (alternate format)
+ * h (short) expands to int on 32-bit Xtensa
+ * l (long) same as int on 32-bit Xtensa
+ * j (intmax_t or uintmax_t) same as int on 32-bit Xtensa
+ * z (size_t or ssize_t) same as int on 32-bit Xtensa
+ * t (ptrdiff_t) same as int on 32-bit Xtensa
+ *
+ * Does NOT support:
+ * width.prec (precision modifier)
+ * %X (capitalized hex; handles this as lowercase hex)
+ * %o (octal)
+ * %[L][feEgG] (floating point formats)
+ * %a %A (hex floating point formats, C99)
+ * %C (multibyte character)
+ * %S (multibyte character string)
+ * %n (returning count of character written)
+ * ll (long long)
+ * q j z t (other size modifiers, eg. see glibc)
+ */
+int tiny_vsprintf(char *out, const char *fmt, va_list ap)
+{
+ int total = 0;
+ char c, space = ' ', buf[11]; /* largest 32-bit integer output (octal) */
+
+ while ((c = *(char*)fmt++) != 0) {
+ if (c != '%') {
+ *out++ = c;
+ total++;
+ } else {
+ int width = 0, len = 1, rightjust = 1;
+ unsigned n;
+ char *s = buf, *t, pad = ' ', sign = 0;
+ while (1) {
+ c = *(char*)fmt++;
+ switch (c) {
+ case 'c': buf[0] = va_arg(ap, int); goto donefmt;
+ case 's': s = va_arg(ap, char*);
+ if (s == 0)
+ len = 0;
+ else {
+ for (t = s; *t; t++) ;
+ len = t - s;
+ }
+ goto donefmt;
+
+ case '#': /* ignore (not supported) */
+ case 'h': /* ignore (short; passed as int) */
+ case 'l': /* ignore (long; same as int) */
+ case 'j': /* ignore (intmax_t or uintmax_t; same as int) */
+ case 'z': /* ignore (size_t or ssize_t; same as int) */
+ case 't': /* ignore (ptrdiff_t; same as int) */
+ break;
+
+ case ' ': sign = ' '; break;
+ case '+': sign = '+'; break;
+ case '-': rightjust = 0; break;
+
+ case 'i': /*FALLTHROUGH*/
+ case 'd': n = va_arg(ap, int);
+ if ((int)n < 0) {
+ sign = '-';
+ n = -(int)n;
+ }
+ if (sign) {
+ if (rightjust && pad == ' ')
+ *s++ = sign;
+ else {
+ *out++ = sign;
+ width--;
+ total++;
+ }
+ }
+ goto do_decimal;
+ case 'u': n = va_arg(ap, int);
+ do_decimal:
+ {
+ /* (avoids division or multiplication) */
+ int digit, i, seen = 0;
+ for (digit = 0; n >= 1000000000; digit++)
+ n -= 1000000000;
+ for (i = 9;;) {
+ if (!seen && digit != 0)
+ seen = i;
+ if (seen)
+ *s++ = '0' + digit;
+ for (digit = 0; n >= 100000000; digit++)
+ n -= 100000000;
+ if (--i == 0) {
+ *s++ = '0' + digit;
+ len = s - buf;
+ s = buf;
+ goto donefmt;
+ }
+ n = ((n << 1) + (n << 3));
+ }
+ }
+ /*NOTREACHED*/
+
+#if 0
+ case 'o': n = va_arg(ap, unsigned);
+ s = buf + 11;
+ do {
+ *--s = '0' + (n & 7);
+ n = (unsigned)n >> 3;
+ } while (n);
+ len = buf + 11 - s;
+ goto donefmt;
+#endif
+
+ case 'p': *out++ = '0', *out++ = 'x';
+ total += 2;
+ /*FALLTHROUGH*/
+ case 'X': /*FALLTHROUGH*/
+ case 'x': n = va_arg(ap, unsigned);
+ s = buf + 8;
+ do {
+ *--s = "0123456789abcdef"[n & 0xF];
+ n = (unsigned)n >> 4;
+ } while (n);
+ len = buf + 8 - s;
+ goto donefmt;
+
+ case 0: goto done;
+ case '0': if (width == 0) pad = '0'; /*FALLTHROUGH*/
+ default: if (c >= '0' && c <= '9')
+ width = ((width<<1) + (width<<3)) + (c - '0');
+ else {
+ buf[0] = c; /* handles case of '%' */
+ goto donefmt;
+ }
+ }
+ }
+ /*NOTREACHED*/
+ donefmt:
+ if (len < width) {
+ total += width;
+ if (rightjust)
+ do { *out++ = pad; } while (len < --width);
+ } else
+ total += len;
+ for(n = len; n > 0; n--) *out++ = *s++;
+ for (; len < width; len++) *out++ = space;
+ }
+ }
+done:
+ return total;
+}
+
+int tiny_sprintf(char *out, const char *fmt, ...)
+{
+ int n = 0;
+ va_list ap;
+ va_start(ap, fmt);
+ n = tiny_vsprintf(out, fmt, ap);
+ va_end(ap);
+ return n;
+}
diff --git a/hifi/xaf/hifi-dpf/core/xf-core.c b/hifi/xaf/hifi-dpf/core/xf-core.c
new file mode 100644
index 00000000..95bca129
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/xf-core.c
@@ -0,0 +1,709 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-core.c
+ *
+ * DSP processing framework core
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG CORE
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+
+/*******************************************************************************
+ * Tracing tags
+ ******************************************************************************/
+
+/* ...general initialization sequence */
+TRACE_TAG(INIT, 1);
+
+/* ...message dispatching */
+TRACE_TAG(DISP, 1);
+
+/* ...client registration procedures */
+TRACE_TAG(REG, 1);
+
+/* ...ports routing/unrouting */
+TRACE_TAG(ROUTE, 1);
+
+#ifdef XAF_PROFILE_DSP
+/* ... MCPS/profile info */
+#include "xa_profiler.h"
+#endif
+/*******************************************************************************
+ * Internal helpers
+ ******************************************************************************/
+
+/* ...translate client-id into component handle */
+static inline xf_component_t * xf_client_lookup(xf_core_data_t *cd, u32 client)
+{
+ xf_cmap_link_t *link = &cd->cmap[client];
+
+ /* ...if link pointer is less than XF_CFG_MAX_CLIENTS, it is a free descriptor */
+ return (link->next > XF_CFG_MAX_CLIENTS ? link->c : NULL);
+}
+
+/* ...allocate client-id */
+static inline u32 xf_client_alloc(xf_core_data_t *cd)
+{
+ u32 client = cd->free;
+
+ /* ...advance list head to next free id */
+ (client < XF_CFG_MAX_CLIENTS ? cd->free = cd->cmap[client].next : 0);
+
+ return client;
+}
+
+/* ...recycle client-id */
+static inline void xf_client_free(xf_core_data_t *cd, u32 client)
+{
+ /* ...put client into the head of the free id list */
+ cd->cmap[client].next = cd->free, cd->free = client;
+}
+
+/*******************************************************************************
+ * Process commands to a proxy
+ ******************************************************************************/
+
+/* ...register new client */
+static int xf_proxy_register(u32 core, xf_message_t *m)
+{
+ xf_core_data_t *cd = XF_CORE_DATA(core);
+ u32 src = XF_MSG_SRC(m->id);
+ u32 client;
+ xf_component_t *component;
+
+ /* ...allocate new client-id */
+ XF_CHK_ERR((client = xf_client_alloc(cd)) != XF_CFG_MAX_CLIENTS, -EBUSY);
+
+ /* ...create component via class factory */
+ if ((component = xf_component_factory(core, m->buffer, m->length)) == NULL)
+ {
+ TRACE(ERROR, _x("Component creation failed"));
+
+ /* ...recycle client-id */
+ xf_client_free(cd, client);
+
+ /* ...return generic out-of-memory code always (tbd) */
+ return -ENOMEM;
+ }
+
+ /* ...register component in a map */
+ cd->cmap[client].c = component;
+
+ /* ...set component "default" port specification ("destination") */
+ component->id = __XF_PORT_SPEC(core, client, 0);
+
+ /* ...adjust session-id to include newly created component-id */
+ m->id = __XF_MSG_ID(src, component->id);
+
+ /* ...do system-specific registration of component within IPC layer */
+ xf_ipc_component_addref(m->id);
+
+ TRACE(REG, _b("registered client: %u:%u (%s)"), core, client, (xf_id_t)m->buffer);
+
+ /* ...and return success to remote proxy (zero-length output) */
+ xf_response_ok(m);
+
+ return 0;
+}
+
+/* ...shared buffer allocation request */
+static int xf_proxy_alloc(u32 core, xf_message_t *m)
+{
+ /* ...command is valid only if shared memory interface for core is specified */
+ XF_CHK_ERR(xf_shmem_enabled(core), -EPERM);
+
+ /* ...allocate shared memory buffer (system-specific function; may fail) */
+ xf_shmem_alloc(core, m);
+
+ /* ...pass result to remote proxy (on success buffer is non-null) */
+ xf_response(m);
+
+ return 0;
+}
+
+/* ...shared buffer freeing request */
+static int xf_proxy_free(u32 core, xf_message_t *m)
+{
+ /* ...command is valid only if shared memory interface for core is specified */
+ XF_CHK_ERR(xf_shmem_enabled(core), -EPERM);
+
+ /* ...pass buffer freeing request to system-specific function */
+ xf_shmem_free(core, m);
+
+ /* ...return success to remote proxy (function never fails) */
+ xf_response(m);
+
+ return 0;
+}
+
+#if 0
+/* ...port routing command processing */
+static int xf_proxy_route(u32 core, xf_message_t *m)
+{
+ xf_route_port_msg_t *cmd = m->buffer;
+ u32 src = cmd->src;
+ u32 dst = cmd->dst;
+ xf_component_t *component;
+ xf_output_port_t *port;
+
+ /* ...source component must reside on the local core */
+ XF_CHK_ERR(XF_MSG_SRC_CORE(src) == core, -EINVAL);
+
+ /* ...make sure the "src" component is valid ("dst" may reside on other core) */
+ if ((component = xf_client_lookup(XF_CORE_DATA(core), XF_PORT_CLIENT(src))) == NULL)
+ {
+ TRACE(ERROR, _x("Source port lookup failed: %x"), src);
+ return -ENOENT;
+ }
+ else if (!component->port || !(port = component->port(component, XF_PORT_ID(src))))
+ {
+ TRACE(ERROR, _b("Source port doesn't exist: %x"), src);
+ return -ENOENT;
+ }
+ else if (xf_output_port_routed(port))
+ {
+ TRACE(ERROR, _b("Source port is already routed: %x"), src);
+ return -EBUSY;
+ }
+
+ /* ...route output port with source port set as destination */
+ XF_CHK_API(xf_output_port_route(port, __XF_MSG_ID(dst, src), cmd->alloc_number, cmd->alloc_size, cmd->alloc_align));
+
+ TRACE(ROUTE, _b("Ports routed: %03x -> %03x"), src, dst);
+
+ /* ...invoke component data-processing function directly (ignore errors? - tbd) */
+ component->entry(component, NULL);
+
+ /* ...return success result code (no output attached) */
+ xf_response_ok(m);
+
+ return 0;
+}
+
+/* ...disconnect ports */
+static int xf_proxy_unroute(u32 core, xf_message_t *m)
+{
+ xf_unroute_port_msg_t *cmd = m->buffer;
+ u32 src = cmd->src;
+ xf_component_t *component;
+ xf_output_port_t *port;
+
+ /* ...source component must reside on the local core */
+ XF_CHK_ERR(XF_MSG_SRC_CORE(src) == core, -EINVAL);
+
+ /* ...lookup source (output) port */
+ if ((component = xf_client_lookup(XF_CORE_DATA(core), XF_PORT_CLIENT(src))) == NULL)
+ {
+ TRACE(ERROR, _b("Source port lookup failed: %x"), src);
+ return -ENOENT;
+ }
+ else if (!component->port || !(port = component->port(component, XF_PORT_ID(src))))
+ {
+ TRACE(ERROR, _b("Source port doesn't exist: %x"), src);
+ return -ENOENT;
+ }
+ else if (!xf_output_port_routed(port))
+ {
+ /* ...port is not routed; satisfy immediately */
+ goto done;
+ }
+ else if (!xf_output_port_idle(port))
+ {
+ TRACE(ERROR, _b("Source port is not idle: %x"), src);
+ return -EBUSY;
+ }
+
+ /* ...unroute port (call must succeed) */
+ xf_output_port_unroute(port);
+
+ /* ...we cannot satisfy the command now, and need to propagate it to a sink - tbd */
+ //return 0;
+
+done:
+ /* ...pass success result code to caller */
+ xf_response_ok(m);
+
+ return 0;
+}
+#endif
+
+/* ...fill-this-buffer command processing */
+static int xf_proxy_output(u32 core, xf_message_t *m)
+{
+ /* ...determine destination "client" */
+ switch (XF_MSG_SRC_CLIENT(m->id))
+ {
+#if XF_TRACE_REMOTE
+ case 0:
+ /* ...destination is a tracer facility; submit buffer to tracer */
+ xf_trace_submit(core, m);
+ return 0;
+#endif
+
+ default:
+ /* ...unrecognized destination; return general failure response */
+ return XF_CHK_ERR(0, -EINVAL);
+ }
+}
+
+/* ...flush command processing */
+static int xf_proxy_flush(u32 core, xf_message_t *m)
+{
+ /* ...determine destination "client" */
+ switch (XF_MSG_SRC_CLIENT(m->id))
+ {
+#if XF_TRACE_REMOTE
+ case 0:
+ /* ...destination is a tracer facility; flush current buffer */
+ xf_trace_flush(core, m);
+ return 0;
+#endif
+
+ default:
+ /* ...unrecognized destination; return general failure response */
+ return XF_CHK_ERR(0, -EINVAL);
+ }
+}
+
+/* ...proxy command processing table */
+static int (* const xf_proxy_cmd[])(u32, xf_message_t *) =
+{
+ [XF_OPCODE_TYPE(XF_REGISTER)] = xf_proxy_register,
+ [XF_OPCODE_TYPE(XF_ALLOC)] = xf_proxy_alloc,
+ [XF_OPCODE_TYPE(XF_FREE)] = xf_proxy_free,
+#if 0
+ [XF_OPCODE_TYPE(XF_ROUTE)] = xf_proxy_route,
+ [XF_OPCODE_TYPE(XF_UNROUTE)] = xf_proxy_unroute,
+#endif
+ [XF_OPCODE_TYPE(XF_FILL_THIS_BUFFER)] = xf_proxy_output,
+ [XF_OPCODE_TYPE(XF_FLUSH)] = xf_proxy_flush,
+};
+
+/* ...total number of commands supported */
+#define XF_PROXY_CMD_NUM (sizeof(xf_proxy_cmd) / sizeof(xf_proxy_cmd[0]))
+
+/* ...process commands to a proxy */
+static void xf_proxy_command(u32 core, xf_message_t *m)
+{
+ u32 opcode = m->opcode;
+ int res;
+
+ /* ...dispatch command to proper hook */
+ if (XF_OPCODE_TYPE(opcode) < XF_PROXY_CMD_NUM)
+ {
+ if ((res = xf_proxy_cmd[XF_OPCODE_TYPE(opcode)](core, m)) >= 0)
+ {
+ /* ...command processed successfully; do nothing */
+ return;
+ }
+ }
+ else
+ {
+ TRACE(ERROR, _x("invalid opcode: %x"), opcode);
+ }
+
+ /* ...command processing failed; return generic failure response */
+ xf_response_err(m);
+}
+
+/*******************************************************************************
+ * Message completion helper
+ ******************************************************************************/
+
+/* ...put message into local IPC command queue on remote core (src != dst) */
+static inline void xf_msg_local_ipc_put(u32 src, u32 dst, xf_message_t *m)
+{
+ xf_core_rw_data_t *rw = XF_CORE_RW_DATA(dst);
+ int first;
+
+ /* ...flush message payload if needed */
+ if (XF_LOCAL_IPC_NON_COHERENT)
+ {
+ /* ...it may be a command with output payload only - tbd */
+ XF_PROXY_FLUSH(m->buffer, m->length);
+ }
+
+ /* ...acquire mutex to target rw-data (running on source core) */
+ xf_mutex_lock(src);
+
+ /* ...assure memory coherency as needed */
+ if (XF_LOCAL_IPC_NON_COHERENT)
+ {
+ /* ...invalidate local queue data */
+ XF_PROXY_INVALIDATE(&rw->local, sizeof(rw->local));
+
+ /* ...place message into queue */
+ first = xf_msg_enqueue(&rw->local, m);
+
+ /* ...flush both queue and message data */
+ XF_PROXY_FLUSH(&rw->local, sizeof(rw->local)), XF_PROXY_FLUSH(m, sizeof(*m));
+ }
+ else
+ {
+ /* ...just enqueue the message */
+ first = xf_msg_enqueue(&rw->local, m);
+ }
+
+ /* ...release global rw-memory access lock */
+ xf_mutex_unlock(src);
+
+ /* ...signal IPI interrupt on destination core as needed */
+ (first ? xf_ipi_assert(dst), 1 : 0);
+}
+
+/* ...dequeue message from core-specific dispatch queue */
+static inline xf_message_t * xf_msg_local_ipc_get(u32 core)
+{
+ xf_core_rw_data_t *rw = XF_CORE_RW_DATA(core);
+ xf_message_t *m;
+
+ /* ...retrieve message from queue in atomic fashion */
+ xf_mutex_lock(core);
+
+ /* ...process memory coherency as required */
+ if (XF_LOCAL_IPC_NON_COHERENT)
+ {
+ /* ...inavlidate local rw-data */
+ XF_PROXY_INVALIDATE(&rw->local, sizeof(rw->local));
+
+ /* ...get message from the queue */
+ if ((m = xf_msg_dequeue(&rw->local)) != NULL)
+ {
+ /* ...flush rw-queue data */
+ XF_PROXY_FLUSH(&rw->local, sizeof(rw->local));
+ }
+ }
+ else
+ {
+ /* ...just dequeue message from the queue */
+ m = xf_msg_dequeue(&rw->local);
+ }
+
+ /* ...release rw-memory access lock */
+ xf_mutex_unlock(core);
+
+ /* ...invalidate message header and data as needed */
+ if (XF_LOCAL_IPC_NON_COHERENT && m != NULL)
+ {
+ /* ...invalidate message header */
+ XF_PROXY_INVALIDATE(m, sizeof(*m));
+
+ /* ...and data if needed (it may not be always needed - tbd) */
+ (m->length ? XF_PROXY_INVALIDATE(m->buffer, m->length) : 0);
+ }
+
+ /* ...return message */
+ return m;
+}
+
+/* ...retrieve message from local queue (protected from ISR) */
+static inline int xf_msg_local_put(u32 core, xf_message_t *m)
+{
+ xf_core_data_t *cd = XF_CORE_DATA(core);
+ int first;
+ u32 status;
+
+ /* ...use interrupt masking protocol to protect message queue */
+ status = xf_isr_disable(core);
+ first = xf_msg_enqueue(&cd->queue, m);
+ xf_isr_restore(core, status);
+
+ return first;
+}
+
+/* ...retrieve message from local queue (protected from ISR) */
+static inline xf_message_t * xf_msg_local_get(u32 core)
+{
+ xf_core_data_t *cd = XF_CORE_DATA(core);
+ xf_message_t *m;
+ u32 status;
+
+ /* ...use interrupt masking protocol to protect message queue */
+ status = xf_isr_disable(core);
+ m = xf_msg_dequeue(&cd->queue);
+ xf_isr_restore(core, status);
+
+ return m;
+}
+
+/* ...retrieve message from local queue (protected from ISR) */
+static inline xf_message_t * xf_msg_local_response_get(u32 core)
+{
+ xf_core_data_t *cd = XF_CORE_DATA(core);
+ xf_message_t *m;
+ u32 status;
+
+ /* ...use interrupt masking protocol to protect message queue */
+ status = xf_isr_disable(core);
+ m = xf_msg_dequeue(&cd->response);
+ xf_isr_restore(core, status);
+
+ return m;
+}
+
+/* ...call component data processing function */
+static inline void xf_core_process(xf_component_t *component)
+{
+ u32 id = component->id;
+
+ /* ...client look-up successfull */
+ TRACE(DISP, _b("core[%u]::client[%u]::process"), XF_PORT_CORE(id), XF_PORT_CLIENT(id));
+
+ /* ...call data-processing interface */
+ if (component->entry(component, NULL) < 0)
+ {
+ TRACE(ERROR, _b("execution error (ignored)"));
+ }
+}
+
+/* ...dispatch message queue execution */
+static inline void xf_core_dispatch(xf_core_data_t *cd, u32 core, xf_message_t *m)
+{
+ u32 client;
+ xf_component_t *component;
+
+ /* ...do client-id/component lookup */
+ if (XF_MSG_DST_PROXY(m->id))
+ {
+ TRACE(DISP, _b("core[%u]::proxy-cmd(id=%x, opcode=%x)"), core, m->id, m->opcode);
+
+ /* ...process message addressed to proxy */
+ xf_proxy_command(core, m);
+
+ /* ...do not like this return statement... - tbd */
+ return;
+ }
+
+ /* ...message goes to local component */
+ client = XF_MSG_DST_CLIENT(m->id);
+
+ /* ...check if client is alive */
+ if ((component = xf_client_lookup(cd, client)) != NULL)
+ {
+ /* ...client look-up successfull */
+ TRACE(DISP, _b("core[%u]::client[%u]::cmd(id=%x, opcode=%x)"), core, client, m->id, m->opcode);
+
+ /* ...pass message to component entry point */
+ if (component->entry(component, m) < 0)
+ {
+ /* ...call component destructor */
+ if (component->exit(component, m) == 0)
+ {
+ /* ...component cleanup completed; recycle component-id */
+ xf_client_free(cd, client);
+
+ /* ...do system-specific deregistration of component within IPC layer */
+ xf_ipc_component_rmref(__XF_PORT_SPEC(core, client, 0));
+ }
+ }
+ }
+ else
+ {
+ TRACE(DISP, _b("Discard message id=%x - client %u:%u not registered"), m->id, core, client);
+
+ /* ...complete message with general failure response */
+ xf_response_err(m);
+ }
+}
+
+/*******************************************************************************
+ * Entry points
+ ******************************************************************************/
+
+/* ...submit message for instant execution on some core */
+void xf_msg_submit(xf_message_t *m)
+{
+ u32 src = XF_MSG_SRC_CORE(m->id);
+ u32 dst = XF_MSG_DST_CORE(m->id);
+
+ /* ...check if message shall go through local IPC layer */
+ if (src ^ dst)
+ {
+ /* ...put message into local IPC queue */
+ xf_msg_local_ipc_put(src, dst, m);
+ }
+ else
+ {
+ /* ...message is addressed to same core */
+ xf_msg_local_put(src, m);
+ }
+}
+
+/* ...complete message and pass response to a caller */
+void xf_msg_complete(xf_message_t *m)
+{
+ u32 src = XF_MSG_SRC(m->id);
+ u32 dst = XF_MSG_DST(m->id);
+
+ /* ...swap src/dst specifiers */
+ m->id = __XF_MSG_ID(dst, src);
+
+ /* ...check if message goes to remote IPC layer */
+ if (XF_MSG_DST_PROXY(m->id))
+ {
+ /* ...return message to proxy */
+ xf_msg_proxy_complete(m);
+ }
+ else
+ {
+ /* ...destination is within DSP cluster; check if that is a data buffer */
+ switch (m->opcode)
+ {
+ case XF_EMPTY_THIS_BUFFER:
+ /* ...emptied buffer goes back to the output port */
+ m->opcode = XF_FILL_THIS_BUFFER;
+ break;
+
+ case XF_FILL_THIS_BUFFER:
+ /* ...filled buffer is passed to the input port */
+ m->opcode = XF_EMPTY_THIS_BUFFER;
+ break;
+ }
+
+ /* ...submit message for execution */
+ xf_msg_submit(m);
+ }
+}
+
+/* ...initialize per-core framework data */
+int xf_core_init(u32 core)
+{
+ xf_core_data_t *cd = XF_CORE_DATA(core);
+ xf_cmap_link_t *link;
+ u32 i;
+
+ /* ...create list of free client descriptors */
+ for (link = &cd->cmap[i = 0]; i < XF_CFG_MAX_CLIENTS; i++, link++)
+ {
+ link->next = i + 1;
+ }
+
+ /* ...set head of free clients list */
+ cd->free = 0;
+
+ /* ...initialize local queue scheduler */
+ xf_sched_init(&cd->sched);
+
+ /* ...initialize IPI subsystem */
+ XF_CHK_API(xf_ipi_init(core));
+
+ /* ...initialize shared read-write memory */
+ XF_CHK_API(xf_shmem_enabled(core) ? xf_shmem_init(core) : 0);
+
+ /* ...initialize scratch memory */
+ XF_CHK_ERR(cd->scratch = xf_scratch_mem_init(core), -ENOMEM);
+
+ /* ...okay... it's all good */
+ TRACE(INIT, _b("core-%u initialized"), core);
+
+ return 0;
+}
+
+/* ...core executive loop function */
+void xf_core_service(u32 core)
+{
+ xf_core_data_t *cd = &xf_core_data[core];
+ u32 status;
+ xf_message_t *m;
+ xf_task_t *t;
+
+#ifdef XAF_PROFILE_DSP
+ START_TIME_XA_PROFILER(prof);
+#endif
+ do
+ {
+ /* ...clear local status change */
+ status = 0;
+
+ /* ...if core is servicing shared memory with AP, do it first - actually, they all need to support it */
+ if (xf_shmem_enabled(core))
+ {
+ /* ...process all commands */
+ xf_shmem_process_queues(core);
+ }
+
+ /* ...check if we have a backlog message placed into interim queue */
+ while ((m = xf_msg_local_ipc_get(core)) || (m = xf_msg_local_get(core)))
+ {
+ /* ...dispatch message execution */
+ xf_core_dispatch(cd, core, m);
+
+ /* ...set local status change */
+ status = 1;
+ }
+
+ /* ...check if we have pending responses (submitted from ISR) we need to process */
+ while ((m = xf_msg_local_response_get(core)) != NULL)
+ {
+ /* ...call completion handler on current stack */
+ xf_msg_complete(m);
+
+ /* ...set local status change */
+ status = 1;
+
+ }
+
+ /* ...if scheduler queue is empty, break the loop and pause the core */
+ if ((t = xf_sched_get(&cd->sched)) != NULL)
+ {
+ /* ...data-processing execution (ignore internal errors) */
+ xf_core_process((xf_component_t *)t);
+
+ /* ...set local status change */
+ status = 1;
+ }
+ }
+ while (status);
+
+#ifdef XAF_PROFILE_DSP
+ STOP_TIME_XA_PROFILER(prof);
+
+ if(prof.g_output_bytes)
+ {
+ unsigned long output_samples = prof.g_output_bytes;
+ output_samples >>= (prof.channels == 2 ? 1 : 0);
+ output_samples >>= (prof.pcm_width == 24 ? 2 : 1);
+
+ COMPUTE_MHZ_XA_PROFILER(prof, output_samples, prof.sample_rate, 0);
+
+ prof.g_output_bytes = prof.cycles = 0; /* reset counters */
+ }
+#endif
+
+}
+
+/* ...global data initialization function */
+int xf_global_init(void)
+{
+ /* ...what global data we have to initialize? - tbd */
+ TRACE(INIT, _b("Global data initialized"));
+
+ return 0;
+}
diff --git a/hifi/xaf/hifi-dpf/core/xf-io.c b/hifi/xaf/hifi-dpf/core/xf-io.c
new file mode 100644
index 00000000..4ec415c2
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/xf-io.c
@@ -0,0 +1,644 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-io.c
+ *
+ * Generic input/output ports handling
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG IO
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+
+/*******************************************************************************
+ * Tracing configuration
+ ******************************************************************************/
+
+TRACE_TAG(INIT, 1);
+TRACE_TAG(INPUT, 1);
+TRACE_TAG(OUTPUT, 1);
+TRACE_TAG(ROUTE, 1);
+
+/*******************************************************************************
+ * Input port API
+ ******************************************************************************/
+
+/* ...initialize input port structure */
+int xf_input_port_init(xf_input_port_t *port, u32 size, u32 align, u32 core)
+{
+ /* ...allocate local internal buffer of particular size and alignment */
+ if (size)
+ {
+ /* ...internal buffer is used */
+ XF_CHK_ERR(port->buffer = xf_mem_alloc(size, align, core, 0), -ENOMEM);
+ }
+ else
+ {
+ /* ...no internal buffering is used */
+ port->buffer = NULL;
+ }
+
+ /* ...initialize message queue */
+ xf_msg_queue_init(&port->queue);
+
+ /* ...set buffer size */
+ port->length = size;
+
+ /* ...enable input by default */
+ port->flags = XF_INPUT_FLAG_ENABLED | XF_INPUT_FLAG_CREATED;
+
+ /* ...mark buffer is empty */
+ port->filled = 0, port->access = NULL;
+
+ TRACE(INIT, _b("input-port[%p] created - %p@%u[%u]"), port, port->buffer, align, size);
+
+ return 0;
+}
+
+/* ...put message into input port queue; return non-zero if queue was empty */
+int xf_input_port_put(xf_input_port_t *port, xf_message_t *m)
+{
+ /* ...check if input is enabled */
+ if ((port->flags & XF_INPUT_FLAG_ENABLED) == 0)
+ {
+ /* ...input disabled; this is an error condition, likely */
+ TRACE(INPUT, _b("input-port[%p] disabled"), port);
+
+ /* ...release the message instantly */
+ xf_response_ok(m);
+
+ /* ...buffer has not been accepted - no actions to take */
+ return 0;
+ }
+ else if (m->length == 0)
+ {
+ /* ...it is forbidden to pass more than one zero-length message */
+ BUG(port->flags & XF_INPUT_FLAG_EOS, _x("invalid state: %x"), port->flags);
+
+ /* ...received a message with zero-length; mark end-of-stream condition */
+ port->flags ^= XF_INPUT_FLAG_ENABLED | XF_INPUT_FLAG_EOS;
+
+ /* ...still enqueue that zero-length message; it will be processed afterwards */
+ TRACE(INPUT, _b("input-port[%p]: zero-length buffer received"), port);
+ }
+ else
+ {
+ TRACE(INPUT, _b("input-port[%p]: buffer received - %u bytes"), port, m->length);
+ }
+
+ /* ...enqueue message and set access pointer as needed */
+ if (xf_msg_enqueue(&port->queue, m))
+ {
+ /* ...first message put - set access pointer and length */
+ port->access = m->buffer, port->remaining = m->length;
+
+ /* ...if first message is empty, mark port is done */
+ (!port->access ? port->flags ^= XF_INPUT_FLAG_EOS | XF_INPUT_FLAG_DONE : 0);
+
+ /* ...return non-zero to indicate the first buffer is placed into port */
+ return 1;
+ }
+ else
+ {
+ /* ...subsequent message placed into buffer */
+ return 0;
+ }
+}
+
+/* ...internal helper - input message completion */
+static inline int xf_input_port_complete(xf_input_port_t *port)
+{
+ /* ...dequeue message from queue */
+ xf_message_t *m = xf_msg_dequeue(&port->queue);
+
+ /* ...message cannot be NULL */
+ BUG(m == NULL, _x("invalid port state"));
+
+ /* ...complete current message (EMPTY-THIS-BUFFER always; no length adjustment) */
+ xf_response(m);
+
+ /* ...set up next head */
+ if ((m = xf_msg_queue_head(&port->queue)) != NULL)
+ {
+ /* ...set new access pointers */
+ port->access = m->buffer, port->remaining = m->length;
+
+ /* ...return indication that there is an input message */
+ return 1;
+ }
+ else
+ {
+ /* ...no more messages; reset access pointer */
+ port->access = NULL;
+
+ /* ...return indication that input port has no data available */
+ return 0;
+ }
+}
+
+/* ...fill-in required amount of data into input port buffer */
+int xf_input_port_fill(xf_input_port_t *port)
+{
+ u32 filled = port->filled;
+ u32 remaining = port->remaining;
+ u32 copied = 0;
+ s32 n;
+
+ /* ...function shall not be called if no internal buffering is used */
+ BUG(xf_input_port_bypass(port), _x("Invalid transaction"));
+
+ /* ...if there is no message pending, bail out */
+ if (!xf_msg_queue_head(&port->queue))
+ {
+ TRACE(INPUT, _b("No message ready"));
+ return 0;
+ }
+
+ /* ...calculate total amount of bytes we need to copy */
+ n = (s32)(port->length - filled);
+
+ /* ...get at most "n" bytes from input message(s) buffer(s) */
+ while (n > 0)
+ {
+ u32 k;
+
+ /* ...determine the size of the chunk to copy */
+ ((k = remaining) > n ? k = n : 0);
+
+ /* ...process zero-length input message separately */
+ if (k == 0)
+ {
+ /* ...end-of-stream condition must be set */
+ BUG((port->flags & XF_INPUT_FLAG_EOS) == 0, _x("port[%p]: invalid state: %x"), port, port->flags);
+
+ /* ...mark stream is completed */
+ port->flags ^= XF_INPUT_FLAG_EOS | XF_INPUT_FLAG_DONE;
+
+ /* ...reset total amount of bytes to fill */
+ n = 0;
+
+ /* ...do not release message yet */
+ TRACE(INPUT, _b("input-port[%p] done"), port);
+
+ /* ...and break the loop */
+ break;
+ }
+
+ /* ...buffer must be set */
+ BUG(!port->access, _x("invalid port state"));
+
+ /* ...get required amount from input buffer */
+ memcpy(port->buffer + filled, port->access, k), port->access += k;
+
+ /* ...advance buffer positions */
+ filled += k, copied += k, n -= k;
+
+ /* ...check if input buffer is processed completely */
+ if ((remaining -= k) == 0)
+ {
+ if (!xf_input_port_complete(port))
+ {
+ /* ...no more input messages; break the loop */
+ break;
+ }
+ else
+ {
+ /* ...update remaining counter */
+ remaining = port->remaining;
+ }
+ }
+ }
+
+ /* ...update buffer positions */
+ port->filled = filled, port->remaining = remaining;
+
+ /* ...return indicator whether input buffer is prefilled */
+ return (n == 0);
+}
+
+/* ...pad input buffer with given pattern */
+void xf_input_port_pad(xf_input_port_t *port, u8 pad)
+{
+ u32 filled = port->filled;
+ s32 k;
+
+ /* ...do padding if port buffer is not filled */
+ if ((k = port->length - filled) > 0)
+ {
+ memset(port->buffer + filled, pad, k);
+
+ /* ...indicate port is filled */
+ port->filled = port->length;
+ }
+}
+
+/* ...consume input buffer data */
+void xf_input_port_consume(xf_input_port_t *port, u32 n)
+{
+ /* ...check whether input port is in bypass mode */
+ if (xf_input_port_bypass(port))
+ {
+ /* ...port is in bypass mode; advance access pointer */
+ if ((port->remaining -= n) == 0)
+ {
+ /* ...complete message and try to rearm input port */
+ xf_input_port_complete(port);
+
+ /* ...check if end-of-stream flag is set */
+ if (xf_msg_queue_head(&port->queue) && !port->access)
+ {
+ BUG((port->flags & XF_INPUT_FLAG_EOS) == 0, _x("port[%p]: invalid state: %x"), port, port->flags);
+
+ /* ...mark stream is completed */
+ port->flags ^= XF_INPUT_FLAG_EOS | XF_INPUT_FLAG_DONE;
+
+ TRACE(INPUT, _b("input-port[%p] done"), port);
+ }
+ }
+ else
+ {
+ /* ...advance message buffer pointer */
+ port->access += n;
+ }
+ }
+ else if (port->filled > n)
+ {
+ u32 k = port->filled - n;
+
+ /* ...move tail of buffer to the head (safe to use memcpy) */
+ memcpy(port->buffer, port->buffer + n, k);
+
+ /* ...adjust filled position */
+ port->filled = k;
+ }
+ else
+ {
+ /* ...entire buffer is consumed; reset fill level */
+ port->filled = 0;
+ }
+}
+
+/* ...purge input port queue */
+void xf_input_port_purge(xf_input_port_t *port)
+{
+ xf_message_t *m;
+
+ /* ...bail out early if port is not created */
+ if (!xf_input_port_created(port)) return;
+
+ /* ...free all queued messages with generic "ok" response */
+ while ((m = xf_msg_dequeue(&port->queue)) != NULL)
+ {
+ xf_response_ok(m);
+ }
+
+ /* ...reset internal buffer position */
+ port->filled = 0, port->access = NULL;
+
+ /* ...reset port flags */
+ port->flags = (port->flags & ~__XF_INPUT_FLAGS(~0)) | XF_INPUT_FLAG_ENABLED | XF_INPUT_FLAG_CREATED;
+
+ TRACE(INPUT, _b("input-port[%p] purged"), port);
+}
+
+/* ...save flow-control message for propagated input port purging sequence */
+void xf_input_port_control_save(xf_input_port_t *port, xf_message_t *m)
+{
+ /* ...make sure purging sequence is not active */
+ BUG(port->flags & XF_INPUT_FLAG_PURGING, _x("invalid state: %x"), port->flags);
+
+ /* ...place message into internal queue */
+ xf_msg_enqueue(&port->queue, m);
+
+ /* ...set port purging flag */
+ port->flags ^= XF_INPUT_FLAG_PURGING;
+
+ TRACE(INPUT, _b("port[%p] start purge sequence"), port);
+}
+
+/* ...mark flushing sequence is completed */
+void xf_input_port_purge_done(xf_input_port_t *port)
+{
+ /* ...make sure flushing sequence is ongoing */
+ BUG((port->flags & XF_INPUT_FLAG_PURGING) == 0, _x("invalid state: %x"), port->flags);
+
+ /* ...complete saved flow-control message */
+ xf_response_ok(xf_msg_dequeue(&port->queue));
+
+ /* ...clear port purging flag */
+ port->flags ^= XF_INPUT_FLAG_PURGING;
+
+ TRACE(INPUT, _b("port[%p] purge sequence completed"), port);
+}
+
+/* ...destroy input port data */
+void xf_input_port_destroy(xf_input_port_t *port, u32 core)
+{
+ /* ...bail out earlier if port is not created */
+ if (!xf_input_port_created(port)) return;
+
+ /* ...deallocate input buffer if needed */
+ (port->buffer ? xf_mem_free(port->buffer, port->length, core, 0), port->buffer = NULL : 0);
+
+ /* ...reset input port flags */
+ port->flags = 0;
+
+ TRACE(INIT, _b("input-port[%p] destroyed"), port);
+}
+
+/*******************************************************************************
+ * Output port API
+ ******************************************************************************/
+
+/* ...initialize output port (structure must be zero-initialized) */
+int xf_output_port_init(xf_output_port_t *port, u32 size)
+{
+ /* ...initialize message queue */
+ xf_msg_queue_init(&port->queue);
+
+ /* ...set output buffer length */
+ port->length = size;
+
+ /* ...mark port is created */
+ port->flags = XF_OUTPUT_FLAG_CREATED;
+
+ TRACE(INIT, _b("output-port[%p] initialized"), port);
+
+ return 0;
+}
+
+/* ...route output port */
+int xf_output_port_route(xf_output_port_t *port, u32 id, u32 n, u32 length, u32 align)
+{
+ u32 core = XF_MSG_DST_CORE(id);
+ u32 shared = XF_MSG_SHARED(id);
+ xf_message_t *m;
+ u32 i;
+
+ /* ...allocate message pool for a port; extra message for control */
+ XF_CHK_API(xf_msg_pool_init(&port->pool, n + 1, core));
+
+ /* ...allocate required amount of buffers */
+ for (i = 1; i <= n; i++)
+ {
+ /* ...get message from pool (directly; bypass that "get" interface) */
+ m = xf_msg_pool_item(&port->pool, i);
+
+ /* ...wipe out message link pointer (debugging) */
+ m->next = NULL;
+
+ /* ...set message parameters */
+ m->id = id;
+ m->opcode = XF_FILL_THIS_BUFFER;
+ m->length = length;
+ m->buffer = xf_mem_alloc(length, align, core, shared);
+
+ /* ...if allocation failed, do a cleanup */
+ if (!m->buffer) goto error;
+
+ /* ...place message into output port */
+ xf_msg_enqueue(&port->queue, m);
+ }
+
+ /* ...setup flow-control message */
+ m = xf_output_port_control_msg(port);
+ m->id = id;
+ m->length = 0;
+ m->buffer = NULL;
+
+ /* ...wipe out message link pointer (debugging) */
+ m->next = NULL;
+
+ /* ...save port length */
+ port->length = length;
+
+ /* ...mark port is routed */
+ port->flags |= XF_OUTPUT_FLAG_ROUTED | XF_OUTPUT_FLAG_IDLE;
+
+ TRACE(ROUTE, _b("output-port[%p] routed: %x -> %x"), port, XF_MSG_DST(id), XF_MSG_SRC(id));
+
+ return 0;
+
+error:
+ /* ...allocation failed; do a cleanup */
+ while (--i)
+ {
+ m = xf_msg_pool_item(&port->pool, i);
+
+ /* ...free item */
+ xf_mem_free(m->buffer, length, core, shared);
+ }
+
+ /* ...destroy pool data */
+ xf_msg_pool_destroy(&port->pool, core);
+
+ return -ENOMEM;
+}
+
+/* ...start output port unrouting sequence */
+void xf_output_port_unroute_start(xf_output_port_t *port, xf_message_t *m)
+{
+ /* ...port must be routed */
+ BUG(!xf_output_port_routed(port), _x("invalid state: %x"), port->flags);
+
+ /* ...save message in the queue */
+ port->unroute = m;
+
+ /* ...put port unrouting flag */
+ port->flags |= XF_OUTPUT_FLAG_UNROUTING;
+}
+
+/* ...complete port unrouting sequence */
+void xf_output_port_unroute_done(xf_output_port_t *port)
+{
+ xf_message_t *m;
+
+ /* ...make sure we have an outstanding port unrouting sequence */
+ BUG(!xf_output_port_unrouting(port), _x("invalid state: %x"), port->flags);
+
+ /* ...retrieve enqueued control-flow message */
+ m = port->unroute, port->unroute = NULL;
+
+ /* ...destroy port buffers */
+ xf_output_port_unroute(port);
+
+ /* ...and pass response to the caller */
+ xf_response_ok(m);
+}
+
+/* ...unroute output port and destroy all memory buffers allocated */
+void xf_output_port_unroute(xf_output_port_t *port)
+{
+ xf_message_t *m = xf_output_port_control_msg(port);
+ u32 core = XF_MSG_DST_CORE(m->id);
+ u32 shared = XF_MSG_SHARED(m->id);
+ u32 n = port->pool.n - 1;
+ u32 i;
+
+ /* ...free all messages (we are running on "dst" core) */
+ for (i = 1; i <= n; i++)
+ {
+ /* ...directly obtain message item */
+ m = xf_msg_pool_item(&port->pool, i);
+
+ /* ...free message buffer (must exist) */
+ xf_mem_free(m->buffer, port->length, core, shared);
+ }
+
+ /* ...destroy pool data */
+ xf_msg_pool_destroy(&port->pool, core);
+
+ /* ...reset all flags */
+ port->flags = XF_OUTPUT_FLAG_CREATED;
+
+ /* ...reset message queue (it is empty again) */
+ xf_msg_queue_init(&port->queue);
+
+ TRACE(ROUTE, _b("output-port[%p] unrouted"), port);
+}
+
+/* ...put next message to the port */
+int xf_output_port_put(xf_output_port_t *port, xf_message_t *m)
+{
+ /* ...in case of port unrouting sequence the flag returned will always be 0 */
+ return xf_msg_enqueue(&port->queue, m);
+}
+
+/* ...retrieve next message from the port */
+void * xf_output_port_data(xf_output_port_t *port)
+{
+ xf_message_t *m = xf_msg_queue_head(&port->queue);
+
+ /* ...bail out if there is nothing enqueued */
+ if (m == NULL) return NULL;
+
+ /* ...it is not permitted to access port data when port is being unrouted */
+ BUG(xf_output_port_unrouting(port), _x("invalid transaction"));
+
+ /* ...make sure message length is sane */
+ BUG(m->length < port->length, _x("Insufficient buffer length: %u < %u"), m->length, port->length);
+
+ /* ...return access buffer pointer */
+ return m->buffer;
+}
+
+/* ...produce output message marking amount of bytes produced */
+int xf_output_port_produce(xf_output_port_t *port, u32 n)
+{
+ xf_message_t *m = xf_msg_dequeue(&port->queue);
+
+ /* ...message cannot be NULL */
+ BUG(m == NULL, _x("Invalid transaction"));
+
+ /* ...it is not permitted to invoke this when port is being unrouted (or flushed - tbd) */
+ BUG(xf_output_port_unrouting(port), _x("invalid transaction"));
+
+ /* ...complete message with specified amount of bytes produced */
+ xf_response_data(m, n);
+
+ /* ...clear port idle flag (technically, not needed for unrouted port) */
+ port->flags &= ~XF_OUTPUT_FLAG_IDLE;
+
+ /* ...return indication of pending message availability */
+ return (xf_msg_queue_head(&port->queue) != NULL);
+}
+
+/* ...flush output port */
+int xf_output_port_flush(xf_output_port_t *port, u32 opcode)
+{
+ xf_message_t *m;
+
+ /* ...if port is routed, we shall pass flush command to sink port */
+ if (xf_output_port_routed(port))
+ {
+ /* ...if port is idle, satisfy immediately */
+ if (port->flags & XF_OUTPUT_FLAG_IDLE) return 1;
+
+ /* ...start flushing sequence if not already started */
+ if ((port->flags & XF_OUTPUT_FLAG_FLUSHING) == 0)
+ {
+ /* ...put flushing flag */
+ port->flags ^= XF_OUTPUT_FLAG_FLUSHING;
+
+ /* ...get control message from associated pool */
+ m = xf_output_port_control_msg(port);
+
+ /* ...set flow-control operation */
+ m->opcode = opcode;
+
+ /* ...message is a command, but source and destination are swapped */
+ xf_response(m);
+ }
+
+ /* ...zero-result indicates the flushing is in progress */
+ return 0;
+ }
+ else
+ {
+ /* ...for non-routed port just complete all queued messages */
+ while ((m = xf_msg_dequeue(&port->queue)) != NULL)
+ {
+ /* ...pass generic zero-length "okay" response - tbd */
+ xf_response_ok(m);
+ }
+
+ /* ...non-zero result indicates the flushing is done */
+ return 1;
+ }
+}
+
+/* ...mark flushing sequence is completed */
+void xf_output_port_flush_done(xf_output_port_t *port)
+{
+ /* ...make sure flushing sequence is ongoing */
+ BUG((port->flags & XF_OUTPUT_FLAG_FLUSHING) == 0, _x("invalid state: %x"), port->flags);
+
+ /* ...clear flushing flag and set idle flag */
+ port->flags ^= XF_OUTPUT_FLAG_IDLE | XF_OUTPUT_FLAG_FLUSHING;
+
+ TRACE(OUTPUT, _b("port[%p] flush sequence completed"), port);
+}
+
+/* ...destroy output port */
+void xf_output_port_destroy(xf_output_port_t *port, u32 core)
+{
+ /* ...check if port is routed */
+ if (xf_output_port_routed(port))
+ {
+ /* ...port must be in idle state */
+ BUG(!xf_output_port_idle(port), _x("destroying non-idle port[%p]"), port);
+
+ /* ...unroute port */
+ xf_output_port_unroute(port);
+ }
+
+ /* ...reset port flags */
+ port->flags = 0;
+
+ TRACE(INIT, _b("output-port[%p] destroyed"), port);
+}
diff --git a/hifi/xaf/hifi-dpf/core/xf-isr.c b/hifi/xaf/hifi-dpf/core/xf-isr.c
new file mode 100644
index 00000000..4e2add1e
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/xf-isr.c
@@ -0,0 +1,68 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-isr.c
+ *
+ * DSP processing framework - code running from interrupt context
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG ISR
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+
+/*******************************************************************************
+ * API functions definitions
+ ******************************************************************************/
+
+/* ...submit command message from interrupt context on local core */
+void xf_msg_schedule_isr(xf_message_t *m)
+{
+ u32 core = XF_MSG_DST_CORE(m->id);
+ xf_core_data_t *cd = XF_CORE_DATA(core);
+
+ /* ...interrupt masking protocol is used for protecting local message queue */
+ if (xf_msg_enqueue(&cd->queue, m))
+ {
+ /* ...resume local scheduler if that is the first message */
+ xf_ipi_resume(core);
+ }
+}
+
+/* ...complete message from interrupt handler */
+void xf_msg_complete_isr(xf_message_t *m)
+{
+ u32 core = XF_MSG_DST_CORE(m->id);
+ xf_core_data_t *cd = XF_CORE_DATA(core);
+
+ /* ...place message into response queue */
+ if (xf_msg_enqueue(&cd->response, m))
+ {
+ /* ...notify local scheduler if that is the first message */
+ xf_ipi_resume(core);
+ }
+}
diff --git a/hifi/xaf/hifi-dpf/core/xf-mem.c b/hifi/xaf/hifi-dpf/core/xf-mem.c
new file mode 100644
index 00000000..ce5d8a6a
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/xf-mem.c
@@ -0,0 +1,361 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-mem.c
+ *
+ * Dynamic memory allocator implementation (based on rb-tree index)
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG MM
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+
+/*******************************************************************************
+ * Tracing configuration
+ ******************************************************************************/
+
+TRACE_TAG(INIT, 1);
+
+/*******************************************************************************
+ * Internal helpers
+ ******************************************************************************/
+
+/* ...initialize block */
+static inline xf_mm_block_t * xf_mm_block_init(void *addr, u32 size)
+{
+ xf_mm_block_t *b = (xf_mm_block_t *)addr;
+
+ /* ...use 31 available bits of node color to keep aligned size */
+ return b->l_node.color = size, b;
+}
+
+/* ...check if the length of the block is less than given */
+static inline int xf_mm_block_length_less(xf_mm_block_t *b, u32 size)
+{
+ /* ...we don't really care about LSB of color */
+ return (b->l_node.color < size);
+}
+
+/* ...return exact block length */
+static inline u32 xf_mm_block_length(xf_mm_block_t *b)
+{
+ /* ...wipe out least-significant bit from node color */
+ return (b->l_node.color & ~1);
+}
+
+/* ...increase block length */
+static inline u32 xf_mm_block_length_add(xf_mm_block_t *b, u32 size)
+{
+ /* ...return exact block length after increase */
+ return ((b->l_node.color += size) & ~1);
+}
+
+/* ...decrease block length */
+static inline u32 xf_mm_block_length_sub(xf_mm_block_t *b, u32 size)
+{
+ /* ...return exact block length after decrease */
+ return ((b->l_node.color -= size) & ~1);
+}
+
+/*******************************************************************************
+ * Internal functions
+ ******************************************************************************/
+
+/* ...find best-match node given requested size */
+static inline xf_mm_block_t * xf_mm_find_by_size(xf_mm_pool_t *pool, u32 size)
+{
+ rb_tree_t *tree = &pool->l_map;
+ rb_idx_t p_idx, t_idx;
+
+ /* ...find first block having length greater than requested */
+ for (p_idx = rb_root(tree); p_idx != rb_null(tree); p_idx = rb_right(tree, p_idx))
+ {
+ xf_mm_block_t *b = container_of(p_idx, xf_mm_block_t, l_node);
+
+ /* ...break upon finding first matching candidate */
+ if (!xf_mm_block_length_less(b, size))
+ break;
+ }
+
+ /* ...bail out if haven't found a block with sufficient size */
+ if (p_idx == rb_null(tree))
+ return NULL;
+
+ /* ...try to find better match in left subtree */
+ for (t_idx = rb_left(tree, p_idx); t_idx != rb_null(tree); )
+ {
+ xf_mm_block_t *b = container_of(t_idx, xf_mm_block_t, l_node);
+
+ /* ...check the size of the block */
+ if (!xf_mm_block_length_less(b, size))
+ {
+ /* ...update best match */
+ p_idx = t_idx;
+
+ /* ...and check if we have anything better in left sbtree */
+ t_idx = rb_left(tree, t_idx);
+ }
+ else
+ {
+ /* ...move towards higher block sizes in that subtree */
+ t_idx = rb_right(tree, t_idx);
+ }
+ }
+
+ /* ...p_idx is our best choice */
+ return container_of(p_idx, xf_mm_block_t, l_node);
+}
+
+/* ...find the neighbours of the block basing on its address */
+static void xf_mm_find_by_addr(xf_mm_pool_t *pool, void *addr, xf_mm_block_t **n)
+{
+ rb_tree_t *tree = &pool->a_map;
+ rb_idx_t p_idx, l_idx, r_idx;
+
+ /* ...it is not possible to have exact match in this map */
+ for (p_idx = rb_root(tree), l_idx = r_idx = NULL; p_idx != rb_null(tree); )
+ {
+ /* ...only "is less than" comparison is valid (as "a_node" pointer is biased) */
+ if ((u32)p_idx < (u32)addr)
+ {
+ /* ...update lower neighbour */
+ l_idx = p_idx;
+
+ /* ...and move towards higher addresses */
+ p_idx = rb_right(tree, p_idx);
+ }
+ else
+ {
+ /* ...update higher neighbour */
+ r_idx = p_idx;
+
+ /* ...and move towards lower addresses */
+ p_idx = rb_left(tree, p_idx);
+ }
+ }
+
+ /* ...translate nodes into blocks */
+ n[0] = (l_idx ? container_of(l_idx, xf_mm_block_t, a_node) : NULL);
+ n[1] = (r_idx ? container_of(r_idx, xf_mm_block_t, a_node) : NULL);
+}
+
+/* ...insert the block into L-map */
+static void xf_mm_insert_size(xf_mm_pool_t *pool, xf_mm_block_t *b, u32 size)
+{
+ rb_tree_t *tree = &pool->l_map;
+ rb_idx_t p_idx, t_idx;
+
+ /* ...find the parent node for the next block */
+ for (p_idx = rb_root(tree); p_idx != rb_null(tree); p_idx = t_idx)
+ {
+ /* ...check for the size */
+ if (xf_mm_block_length_less(container_of(p_idx, xf_mm_block_t, l_node), size))
+ {
+ /* ...move towards higher addresses */
+ if ((t_idx = rb_right(tree, p_idx)) == rb_null(tree))
+ {
+ /* ...node becomes a right child of parent p */
+ rb_set_right(tree, p_idx, &b->l_node);
+ break;
+ }
+ }
+ else
+ {
+ /* ...move towards lower addresses (ok if exact size match is found) */
+ if ((t_idx = rb_left(tree, p_idx)) == rb_null(tree))
+ {
+ /* ...node becomes a left child of parent p */
+ rb_set_left(tree, p_idx, &b->l_node);
+ break;
+ }
+ }
+ }
+
+ /* ...insert node into tree */
+ rb_insert(tree, &b->l_node, p_idx);
+}
+
+/* ...insert the block into A-map */
+static void xf_mm_insert_addr(xf_mm_pool_t *pool, xf_mm_block_t *b)
+{
+ rb_tree_t *tree = &pool->a_map;
+ rb_idx_t p_idx, t_idx;
+
+ /* ...find the parent node for the next block */
+ for (p_idx = rb_root(tree); p_idx != rb_null(tree); p_idx = t_idx)
+ {
+ /* ...check for the address (only "is less than" comparison is valid) */
+ if ((u32)p_idx < (u32)b)
+ {
+ /* ...move towards higher addresses */
+ if ((t_idx = rb_right(tree, p_idx)) == rb_null(tree))
+ {
+ /* ...node becomes a right child of parent p */
+ rb_set_right(tree, p_idx, &b->a_node);
+ break;
+ }
+ }
+ else
+ {
+ /* ...move towards lower addresses (by design there cannot be exact match) */
+ if ((t_idx = rb_left(tree, p_idx)) == rb_null(tree))
+ {
+ /* ...node becomes a left child of parent p */
+ rb_set_left(tree, p_idx, &b->a_node);
+ break;
+ }
+ }
+ }
+
+ /* ...insert node into tree */
+ rb_insert(tree, &b->a_node, p_idx);
+}
+
+/*******************************************************************************
+ * Entry points
+ ******************************************************************************/
+
+/* ...block allocation */
+void * xf_mm_alloc(xf_mm_pool_t *pool, u32 size)
+{
+ xf_mm_block_t *b;
+
+ /* ...find best-fit free block */
+ XF_CHK_ERR(b = xf_mm_find_by_size(pool, size), NULL);
+
+ /* ...remove the block from the L-map */
+ rb_delete(&pool->l_map, &b->l_node);
+
+ /* ...check if the size is exactly the same as requested */
+ if ((size = xf_mm_block_length_sub(b, size)) == 0)
+ {
+ /* ...the block needs to be removed from the A-map as well */
+ rb_delete(&pool->a_map, &b->a_node);
+
+ /* ...entire block goes to user */
+ return (void *) b;
+ }
+ else
+ {
+ /* ...insert the block into L-map */
+ xf_mm_insert_size(pool, b, size);
+
+ /* ...A-map remains intact; tail of the block goes to user */
+ return (void *) b + size;
+ }
+}
+
+/* ...block deallocation */
+void xf_mm_free(xf_mm_pool_t *pool, void *addr, u32 size)
+{
+ xf_mm_block_t *b = xf_mm_block_init(addr, size);
+ xf_mm_block_t *n[2];
+
+ /* ...find block neighbours in A-map */
+ xf_mm_find_by_addr(pool, addr, n);
+
+ /* ...check if we can merge block to left neighbour */
+ if (n[0])
+ {
+ if ((void *)n[0] + xf_mm_block_length(n[0]) == addr)
+ {
+ /* ...merge free block with left neighbour; delete it from L-map */
+ rb_delete(&pool->l_map, &n[0]->l_node);
+
+ /* ...adjust block length (block remains in A-map) */
+ addr = (void *)(b = n[0]), size = xf_mm_block_length_add(b, size);
+ }
+ else
+ {
+ /* ...mark there is no left-merge */
+ n[0] = NULL;
+ }
+ }
+
+ /* ...check if we can merge block to right neighbour */
+ if (n[1])
+ {
+ if ((void *)n[1] == addr + size)
+ {
+ /* ...merge free block with right neighbour; delete it from L-map */
+ rb_delete(&pool->l_map, &n[1]->l_node);
+
+ /* ...adjust block length */
+ size = xf_mm_block_length_add(b, xf_mm_block_length(n[1]));
+
+ /* ...check if left merge took place as well */
+ if (n[0])
+ {
+ /* ...left neighbour covers now all three blocks; drop record from A-map */
+ rb_delete(&pool->a_map, &n[1]->a_node);
+ }
+ else
+ {
+ /* ...fixup tree pointers (equivalent to remove/reinsert the same key) */
+ rb_replace(&pool->a_map, &n[1]->a_node, &b->a_node);
+ }
+ }
+ else
+ {
+ n[1] = NULL;
+ }
+ }
+
+ /* ...if any merge has occured, A-map is updated */
+ if (n[0] == NULL && n[1] == NULL)
+ {
+ /* ...add new block into A-map */
+ xf_mm_insert_addr(pool, b);
+ }
+
+ /* ...add (new or adjusted) block into L-map */
+ xf_mm_insert_size(pool, b, size);
+}
+
+/* ...initialize memory allocator */
+int xf_mm_init(xf_mm_pool_t *pool, void *addr, u32 size)
+{
+ /* ...check pool alignment validity */
+ XF_CHK_ERR(((u32)addr & (sizeof(xf_mm_block_t) - 1)) == 0, -EINVAL);
+
+ /* ...check pool size validity */
+ XF_CHK_ERR(((size) & (sizeof(xf_mm_block_t) - 1)) == 0, -EINVAL);
+
+ /* ...set pool parameters (need that stuff at all? - tbd) */
+ pool->addr = addr, pool->size = size;
+
+ /* ...initialize rb-trees */
+ rb_init(&pool->l_map), rb_init(&pool->a_map);
+
+ /* ..."free" the entire block */
+ xf_mm_free(pool, addr, size);
+
+ TRACE(INIT, _b("memory allocator initialized: [%p..%p)"), addr, addr + size);
+
+ return 0;
+}
diff --git a/hifi/xaf/hifi-dpf/core/xf-msg.c b/hifi/xaf/hifi-dpf/core/xf-msg.c
new file mode 100644
index 00000000..4253e1e3
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/xf-msg.c
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-msg.c
+ *
+ * Message/message pool handling
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG MSG
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+
+/*******************************************************************************
+ * Entry points
+ ******************************************************************************/
+
+/* ...allocate message pool */
+int xf_msg_pool_init(xf_msg_pool_t *pool, u32 n, u32 core)
+{
+ u32 i;
+
+ /* ...allocate shared memory from global pool */
+ XF_CHK_ERR(pool->p = xf_mem_alloc(XF_MM(sizeof(*pool->p) * n), XF_PROXY_ALIGNMENT, core, 1), -ENOMEM);
+
+ /* ...place all messages into single-liked list */
+ for (pool->head = &pool->p[i = 0]; i < n - 1; i++)
+ {
+ /* ...set message pointer to next message in the pool */
+ xf_msg_pool_item(pool, i)->next = xf_msg_pool_item(pool, i + 1);
+ }
+
+ /* ...set tail of the list */
+ xf_msg_pool_item(pool, i)->next = NULL;
+
+ /* ...save pool size */
+ pool->n = n;
+
+ return 0;
+}
+
+/* ...destroy memory pool */
+void xf_msg_pool_destroy(xf_msg_pool_t *pool, u32 core)
+{
+ /* ...release pool memory (from shared local-IPC memory) */
+ xf_mem_free(pool->p, XF_MM(sizeof(*pool->p) * pool->n), core, 1);
+}
+
+/* ...allocate message from a pool (no concurrent access from other cores) */
+xf_message_t * xf_msg_pool_get(xf_msg_pool_t *pool)
+{
+ __xf_message_t *_m;
+
+ /* ...pop message from the head of the pool */
+ XF_CHK_ERR(_m = pool->head, NULL);
+
+ /* ...advance list head */
+ pool->head = (__xf_message_t *)(((xf_message_t *) _m)->next);
+
+ /* ...debug - wipe out message "next" pointer */
+ ((xf_message_t *) _m)->next = NULL;
+
+ /* ...return properly aligned message pointer */
+ return (xf_message_t *) _m;
+}
+
+/* ...return message back to the pool (no concurrent access from other cores) */
+void xf_msg_pool_put(xf_msg_pool_t *pool, xf_message_t *m)
+{
+ __xf_message_t *_m = (__xf_message_t *) m;
+
+ /* ...make sure the message is properly aligned object */
+ BUG(!XF_IS_ALIGNED(_m), _x("Corrupted message pointer: %p"), _m);
+
+ /* ...make sure it is returned to the same pool (need a length for that - tbd) */
+ BUG(!xf_msg_from_pool(pool, m) < 0, _x("Bad pool/message: %p/%p"), pool->p, _m);
+
+ /* ...place message into the head */
+ m->next = (xf_message_t *) pool->head;
+
+ /* ...advance pool head */
+ pool->head = _m;
+}
diff --git a/hifi/xaf/hifi-dpf/core/xf-sched.c b/hifi/xaf/hifi-dpf/core/xf-sched.c
new file mode 100644
index 00000000..cc1b4e8d
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/xf-sched.c
@@ -0,0 +1,153 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-sched.c
+ *
+ * Non-preemptive earliest-deadline-first scheduler
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG SCHED
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+
+/*******************************************************************************
+ * Tracing configuration
+ ******************************************************************************/
+
+TRACE_TAG(DEBUG, 1);
+
+/*******************************************************************************
+ * Global functions definitions
+ ******************************************************************************/
+
+/* ...place task into scheduler queue */
+void xf_sched_put(xf_sched_t *sched, xf_task_t *t, u32 ts)
+{
+ rb_tree_t *tree = (rb_tree_t *)sched;
+ rb_node_t *node = (rb_node_t *)t;
+ rb_idx_t p_idx, t_idx;
+ u32 _ts;
+
+ /* ...set scheduling timestamp */
+ xf_task_timestamp_set(t, ts);
+
+ /* ...find a place in the tree where the message should be inserted */
+ for (p_idx = rb_root(tree); p_idx != rb_null(tree); p_idx = t_idx)
+ {
+ /* ...get timestamp of the p_idx */
+ _ts = xf_task_timestamp((xf_task_t *)p_idx);
+
+ /* ...ordering respects FIFO order of messages with same timestamp */
+ if (xf_timestamp_before(ts, _ts))
+ {
+ if ((t_idx = rb_left(tree, p_idx)) == rb_null(tree))
+ {
+ /* ...p_idx is a direct successor of the message */
+ rb_set_left(tree, p_idx, node);
+
+ /* ...adjust head of the tree if needed */
+ if (p_idx == rb_cache(tree)) goto insert_head;
+ else goto insert;
+ }
+ }
+ else
+ {
+ if ((t_idx = rb_right(tree, p_idx)) == rb_null(tree))
+ {
+ /* ...p_idx is a direct predeccessor of the message */
+ rb_set_right(tree, p_idx, node);
+
+ goto insert;
+ }
+ }
+ }
+
+insert_head:
+ /* ...adjust scheduler head element */
+ rb_set_cache(tree, node);
+
+insert:
+ /* ...insert item and rebalance the tree */
+ rb_insert(tree, node, p_idx);
+
+ /* ...head cannot be NULL */
+ BUG(rb_cache(tree) == rb_null(tree), _x("Invalid scheduler state"));
+
+ TRACE(DEBUG, _b("in: %x:[%p] (ts:%x)"), ts, node, xf_sched_timestamp(sched));
+}
+
+/* ...get first item from the scheduler */
+xf_task_t * xf_sched_get(xf_sched_t *sched)
+{
+ rb_tree_t *tree = (rb_tree_t *)sched;
+ rb_idx_t n_idx, t_idx;
+ u32 ts;
+
+ /* ...head of the tree is cached; replace it with its parent (direct successor) */
+ if ((n_idx = rb_cache(tree)) == rb_null(tree))
+ {
+ /* ...tree is empty; bail out */
+ return NULL;
+ }
+ else
+ {
+ /* ...delete current node and rebalance the tree */
+ t_idx = rb_delete(tree, n_idx), rb_set_cache(tree, t_idx);
+
+ /* ...get task timestamp */
+ ts = xf_task_timestamp((xf_task_t *)n_idx);
+
+ /* ...advance scheduler timestamp */
+ xf_sched_timestamp_set(sched, ts);
+
+ TRACE(DEBUG, _b("out: %x:[%p]"), ts, n_idx);
+
+ /* ...return task */
+ return (xf_task_t *)n_idx;
+ }
+}
+
+/* ...cancel specified task execution (must be scheduled!) */
+void xf_sched_cancel(xf_sched_t *sched, xf_task_t *t)
+{
+ rb_tree_t *tree = (rb_tree_t *)sched;
+ rb_idx_t n_idx = t;
+ rb_idx_t t_idx;
+
+ /* ...delete message from tree */
+ t_idx = rb_delete(tree, n_idx);
+
+ /* ...adjust head if that was the first message */
+ (n_idx == rb_cache(tree) ? rb_set_cache(tree, t_idx), 1 : 0);
+}
+
+/* ...initialize scheduler data */
+void xf_sched_init(xf_sched_t *sched)
+{
+ rb_init((rb_tree_t *)sched);
+}
diff --git a/hifi/xaf/hifi-dpf/core/xf-shmem.c b/hifi/xaf/hifi-dpf/core/xf-shmem.c
new file mode 100644
index 00000000..15d3b1d9
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/core/xf-shmem.c
@@ -0,0 +1,350 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-shmem.c
+ *
+ * DSP shared memory interface implementation
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG SHMEM
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+
+/*******************************************************************************
+ * Tracing tags
+ ******************************************************************************/
+
+/* ...general initialization sequence */
+TRACE_TAG(INIT, 1);
+
+/* ...interface status change */
+TRACE_TAG(EXEC, 0);
+
+/* ...command reception */
+TRACE_TAG(CMD, 1);
+
+/* ...response generation */
+TRACE_TAG(RSP, 1);
+
+#ifdef XAF_PROFILE_DSP
+#include "xa_profiler.h"
+#endif
+/*******************************************************************************
+ * Local constants definitions
+ ******************************************************************************/
+
+/* ...local interface status change flag */
+#define XF_PROXY_STATUS_LOCAL (1 << 0)
+
+/* ...remote status change notification flag */
+#define XF_PROXY_STATUS_REMOTE (1 << 1)
+
+/*******************************************************************************
+ * Internal helpers
+ ******************************************************************************/
+
+/* ...put message into proxy queue */
+static inline void xf_msg_proxy_put(xf_message_t *m)
+{
+ u32 dst = XF_MSG_DST_CORE(m->id);
+ u32 src = XF_MSG_SRC_CORE(m->id);
+ xf_core_rw_data_t *rw = XF_CORE_RW_DATA(dst);
+ int first;
+
+ /* ...get an access to shared rw-memory (we are running on "source" core) */
+ xf_mutex_lock(src);
+
+ /* ...assure memory coherency if needed */
+ if (XF_REMOTE_IPC_NON_COHERENT)
+ {
+ /* ...invalidate rw-shared memory region */
+ XF_PROXY_INVALIDATE(rw, sizeof(*rw));
+
+ /* ...put message into shared queue */
+ first = xf_msg_enqueue(&rw->remote, m);
+
+ /* ...flush both message and shared queue data */
+ XF_PROXY_FLUSH(rw, sizeof(*rw)), XF_PROXY_FLUSH(m, sizeof(*m));
+ }
+ else
+ {
+ /* ...no memory coherency concerns; just place a message in the queue */
+ first = xf_msg_enqueue(&rw->remote, m);
+ }
+
+ /* ...release rw-memory region lock */
+ xf_mutex_unlock(src);
+
+ /* ...assert IPI interrupt on target ("destination") core if needed */
+ if (first && (dst ^ src))
+ {
+ xf_ipi_assert(dst);
+ }
+}
+
+/* ...retrieve message from proxy queue */
+static inline xf_message_t * xf_msg_proxy_get(u32 core)
+{
+ xf_core_rw_data_t *rw = XF_CORE_RW_DATA(core);
+ xf_message_t *m;
+
+ /* ...retrieve message from queue in atomic fashion */
+ xf_mutex_lock(core);
+
+ /* ...assure memory coherency if needed */
+ if (XF_REMOTE_IPC_NON_COHERENT)
+ {
+ /* ...invalidate rw-memory */
+ XF_PROXY_INVALIDATE(rw, sizeof(*rw));
+
+ /* ...dequeue message from response queue */
+ m = xf_msg_dequeue(&rw->remote);
+
+ /* ...flush rw memory */
+ XF_PROXY_FLUSH(rw, sizeof(*rw));
+
+ /* ...invalidate message data if found */
+ (m ? XF_PROXY_INVALIDATE(m, sizeof(*m)) : 0);
+ }
+ else
+ {
+ /* ...just dequeue message from response queue */
+ m = xf_msg_dequeue(&rw->remote);
+ }
+
+ /* ...release the rw-lock */
+ xf_mutex_unlock(core);
+
+ return m;
+}
+
+/*******************************************************************************
+ * Internal functions definitions
+ ******************************************************************************/
+
+/* ...retrieve all incoming commands from shared memory ring-buffer */
+static u32 xf_shmem_process_input(u32 core)
+{
+ xf_message_t *m;
+ u32 read_idx;
+ u32 write_idx;
+ u32 status = 0;
+
+ /* ...get current value of write pointer */
+ read_idx = XF_PROXY_READ(core, cmd_read_idx);
+ write_idx = XF_PROXY_READ(core, cmd_write_idx);
+
+ TRACE(EXEC, _b("Command queue: write = %x / read = %x"), write_idx, read_idx);
+
+ /* ...process all committed commands */
+ while (!XF_QUEUE_EMPTY(read_idx, write_idx))
+ {
+ xf_proxy_message_t *command;
+
+ /* ...allocate message; the call should not fail */
+ if ((m = xf_msg_pool_get(&XF_CORE_RO_DATA(core)->pool)) == NULL)
+ break;
+
+ /* ...if queue was full, set global proxy update flag */
+ if (XF_QUEUE_FULL(read_idx, write_idx))
+ status |= XF_PROXY_STATUS_REMOTE | XF_PROXY_STATUS_LOCAL;
+ else
+ status |= XF_PROXY_STATUS_LOCAL;
+
+ /* ...get oldest not processed command */
+ command = XF_PROXY_COMMAND(core, XF_QUEUE_IDX(read_idx));
+
+ /* ...synchronize memory contents */
+ XF_PROXY_INVALIDATE(command, sizeof(*command));
+
+ /* ...fill message parameters */
+ m->id = command->session_id;
+ m->opcode = command->opcode;
+ m->length = command->length;
+ m->buffer = xf_ipc_a2b(core, command->address);
+ TRACE(CMD, _b("C[%x]:(%x,%u,%p)"), m->id, m->opcode, m->length, m->buffer);
+
+ /* ...invalidate message buffer contents as required - not here - tbd */
+ (XF_OPCODE_CDATA(m->opcode) ? XF_PROXY_INVALIDATE(m->buffer, m->length) : 0);
+
+ /* ...advance local reading index copy */
+ read_idx = XF_QUEUE_ADVANCE_IDX(read_idx);
+
+ /* ...update shadow copy of reading index */
+ XF_PROXY_WRITE(core, cmd_read_idx, read_idx);
+
+ /* ...and schedule message execution on proper core */
+ xf_msg_submit(m);
+ }
+
+ return status;
+}
+
+/* ...send out all pending outgoing responses to the shared memory ring-buffer */
+static u32 xf_shmem_process_output(u32 core)
+{
+ xf_message_t *m;
+ u32 read_idx;
+ u32 write_idx;
+ u32 status = 0;
+
+ /* ...get current value of peer read pointer */
+ write_idx = XF_PROXY_READ(core, rsp_write_idx);
+ read_idx = XF_PROXY_READ(core, rsp_read_idx);
+
+ TRACE(EXEC, _b("Response queue: write = %08X / read = %08X"), write_idx, read_idx);
+
+ /* ...while we have response messages and there's space to write out one */
+ while (!XF_QUEUE_FULL(read_idx, write_idx))
+ {
+ xf_proxy_message_t *response;
+
+ /* ...remove message from internal queue */
+ if ((m = xf_msg_proxy_get(core)) == NULL)
+ break;
+
+ /* ...notify remote interface each time we send it a message (only if it was empty?) */
+ status = XF_PROXY_STATUS_REMOTE | XF_PROXY_STATUS_LOCAL;
+
+#if 0
+ /* ...need to decide on best strategy - tbd */
+ if (XF_QUEUE_EMPTY(read_idx, write_idx))
+ status |= XF_PROXY_STATUS_REMOTE | XF_PROXY_STATUS_LOCAL;
+ else
+ status |= XF_PROXY_STATUS_LOCAL;
+#endif
+
+ /* ...flush message buffer contents to main memory as required - too late - different core - tbd */
+ (XF_OPCODE_RDATA(m->opcode) ? XF_PROXY_FLUSH(m->buffer, m->length) : 0);
+
+ /* ...find place in a queue for next response */
+ response = XF_PROXY_RESPONSE(core, XF_QUEUE_IDX(write_idx));
+
+ /* ...put the response message fields */
+ response->session_id = m->id;
+ response->opcode = m->opcode;
+ response->length = m->length;
+ response->address = xf_ipc_b2a(core, m->buffer);
+ /* ...flush the content of the caches to main memory */
+ XF_PROXY_FLUSH(response, sizeof(*response));
+
+#ifdef XAF_PROFILE_DSP
+ if((m->opcode == XF_FILL_THIS_BUFFER))
+ {
+ if((m->length != 0) && (m->length != 20))
+ {
+ prof.g_output_bytes += (unsigned long)m->length;
+ }
+ else if (m->length == 20)
+ {
+ /* Profiler re-initialization */
+ INIT_XA_PROFILER(prof,"DSP core");
+
+ /* update stream params on re-init */
+ xf_start_msg_t *sm = (xf_start_msg_t *)m->buffer;
+ prof.sample_rate = sm->sample_rate;
+ prof.channels = sm->channels;
+ prof.pcm_width = sm->pcm_width;
+ }
+ }
+#endif
+ TRACE(RSP, _b("R[%x]:(%x,%u,%p)"), m->id, m->opcode, m->length, m->buffer);
+
+ /* ...return message back to the pool */
+ xf_msg_pool_put(&XF_CORE_RO_DATA(core)->pool, m);
+
+ /* ...advance local writing index copy */
+ write_idx = XF_QUEUE_ADVANCE_IDX(write_idx);
+
+ /* ...update shared copy of queue write pointer */
+ XF_PROXY_WRITE(core, rsp_write_idx, write_idx);
+ }
+
+ /* ...return interface status change flags */
+ return status;
+}
+
+/*******************************************************************************
+ * Entry points
+ ******************************************************************************/
+
+/* ...process local/remote shared memory interface status change */
+void xf_shmem_process_queues(u32 core)
+{
+ u32 status;
+
+ do
+ {
+ /* ...acknowledge/clear any pending incoming interrupt */
+ XF_PROXY_SYNC_PEER(core);
+
+ /* ...send out pending response messages (frees message buffers, so do it first) */
+ status = xf_shmem_process_output(core);
+
+ /* ...receive and forward incoming command messages (allocates message buffers) */
+ status |= xf_shmem_process_input(core);
+
+ /* ...assert remote mailbox interrupt if global update bit is set */
+ if (status & XF_PROXY_STATUS_REMOTE)
+ {
+ XF_PROXY_NOTIFY_PEER(core);
+ }
+ }
+ while (status);
+}
+
+/* ...completion callback for message originating from remote proxy */
+void xf_msg_proxy_complete(xf_message_t *m)
+{
+ /* ...place message into proxy response queue */
+ xf_msg_proxy_put(m);
+}
+
+/* ...initialize shared memory interface (DSP side) */
+int xf_shmem_init(u32 core)
+{
+ xf_core_rw_data_t *rw = XF_CORE_RW_DATA(core);
+ xf_core_ro_data_t *ro = XF_CORE_RO_DATA(core);
+
+ /* ...initialize local/remote message queues */
+ xf_msg_queue_init(&rw->local);
+ xf_msg_queue_init(&rw->remote);
+
+ /* ...initialize global message list */
+ XF_CHK_API(xf_msg_pool_init(&ro->pool, XF_CFG_MESSAGE_POOL_SIZE, core));
+
+ /* ...flush memory content as needed */
+ (XF_REMOTE_IPC_NON_COHERENT ? XF_PROXY_FLUSH(rw, sizeof(*rw)) : 0);
+
+ /* ...system-specific initialization of IPC layer */
+ XF_CHK_API(xf_ipc_init(core));
+
+ TRACE(INIT, _b("SHMEM-%u subsystem initialized"), core);
+
+ return 0;
+}
diff --git a/hifi/xaf/hifi-dpf/include/audio/xa-audio-decoder-api.h b/hifi/xaf/hifi-dpf/include/audio/xa-audio-decoder-api.h
new file mode 100644
index 00000000..797bf231
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/audio/xa-audio-decoder-api.h
@@ -0,0 +1,66 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-audio-decoder-api.h
+ *
+ * Generic audio decoder API
+ *
+ ******************************************************************************/
+
+#ifndef __XA_ADEC_API_H__
+#define __XA_ADEC_API_H__
+
+/* ...includes */
+#include "xa_type_def.h"
+#include "xa_error_standards.h"
+#include "xa_apicmd_standards.h"
+#include "xa_memory_standards.h"
+
+/* ...generic audio-decoder configuration parameters */
+enum xa_config_param_codec {
+ XA_CODEC_CONFIG_PARAM_CHANNELS = 0x10000 + 0,
+ XA_CODEC_CONFIG_PARAM_SAMPLE_RATE = 0x10000 + 1,
+ XA_CODEC_CONFIG_PARAM_PCM_WIDTH = 0x10000 + 2,
+ XA_CODEC_CONFIG_PARAM_PRODUCED = 0x10000 + 3
+};
+
+/* ...ports indices */
+enum xa_codec_ports {
+ XA_CODEC_INPUT_PORT = 0,
+ XA_CODEC_OUTPUT_PORT = 1
+};
+
+/* ...non-fatal execution errors */
+enum
+{
+ XA_CODEC_EXEC_NO_DATA = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_GENERIC, 0)
+};
+
+/* ...fatal execution errors */
+enum
+{
+ XA_CODEC_EXEC_SEQUENCE = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_GENERIC, 0),
+ XA_CODEC_EXEC_MISBEHAVING = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_GENERIC, 1),
+};
+
+#endif
diff --git a/hifi/xaf/hifi-dpf/include/audio/xa-mixer-api.h b/hifi/xaf/hifi-dpf/include/audio/xa-mixer-api.h
new file mode 100644
index 00000000..0de1745d
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/audio/xa-mixer-api.h
@@ -0,0 +1,157 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-mixer-api.h
+ *
+ * Mixer component API
+ *
+ ******************************************************************************/
+
+#ifndef __XA_MIXER_API_H__
+#define __XA_MIXER_API_H__
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xa_type_def.h"
+#include "xa_error_standards.h"
+#include "xa_apicmd_standards.h"
+#include "xa_memory_standards.h"
+
+/*******************************************************************************
+ * Constants definitions
+ ******************************************************************************/
+
+/* ...mixer-specific configuration parameters */
+enum xa_config_param_mixer {
+ XA_MIXER_CONFIG_PARAM_INPUT_TRACKS = 0,
+ XA_MIXER_CONFIG_PARAM_PCM_WIDTH = 1,
+ XA_MIXER_CONFIG_PARAM_CHANNELS = 2,
+ XA_MIXER_CONFIG_PARAM_SAMPLE_RATE = 4,
+ XA_MIXER_CONFIG_PARAM_FRAME_SIZE = 5,
+ XA_MIXER_CONFIG_PARAM_BUFFER_SIZE = 6,
+ XA_MIXER_CONFIG_PARAM_VOLUME = 7,
+ XA_MIXER_CONFIG_PARAM_NUM = 8
+};
+
+/* ...component identifier (informative) */
+#define XA_CODEC_MIXER 1
+
+/* ...global limitation - maximal mixer track number */
+#define XA_MIXER_MAX_TRACK_NUMBER 4
+
+/* ...volume representation */
+#define __XA_MIXER_VOLUME(v) \
+ ({ u32 __v = (u32)((v) * (1 << 12)); (__v > 0xFFFF ? __v = 0xFFFF : 0); (u16)__v; })
+
+/* ...mixer volume setting command encoding */
+#define XA_MIXER_VOLUME(track, channel, volume) \
+ (__XA_MIXER_VOLUME(volume) | ((track) << 16) | ((channel) << 20))
+
+/*******************************************************************************
+ * Class 0: API Errors
+ ******************************************************************************/
+
+#define XA_MIXER_API_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_api, XA_CODEC_MIXER, (e))
+
+#define XA_MIXER_API_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_MIXER, (e))
+
+enum xa_error_nonfatal_api_mixer {
+ XA_MIXER_API_NONFATAL_MAX = XA_MIXER_API_NONFATAL(0)
+};
+
+enum xa_error_fatal_api_mixer {
+ XA_MIXER_API_FATAL_MAX = XA_MIXER_API_FATAL(0)
+};
+
+/*******************************************************************************
+ * Class 1: Configuration Errors
+ ******************************************************************************/
+
+#define XA_MIXER_CONFIG_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_MIXER, (e))
+
+#define XA_MIXER_CONFIG_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_MIXER, (e))
+
+enum xa_error_nonfatal_config_mixer {
+ XA_MIXER_CONFIG_NONFATAL_RANGE = XA_MIXER_CONFIG_NONFATAL(0),
+ XA_MIXER_CONFIG_NONFATAL_STATE = XA_MIXER_CONFIG_NONFATAL(1),
+ XA_MIXER_CONFIG_NONFATAL_MAX = XA_MIXER_CONFIG_NONFATAL(2)
+};
+
+enum xa_error_fatal_config_mixer {
+ XA_MIXER_CONFIG_FATAL_RANGE = XA_MIXER_CONFIG_FATAL(0),
+ XA_MIXER_CONFIG_FATAL_TRACK_STATE = XA_MIXER_CONFIG_FATAL(0 + XA_MIXER_CONFIG_NONFATAL_MAX),
+ XA_MIXER_CONFIG_FATAL_MAX = XA_MIXER_CONFIG_FATAL(1)
+};
+
+/*******************************************************************************
+ * Class 2: Execution Class Errors
+ ******************************************************************************/
+
+#define XA_MIXER_EXEC_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_MIXER, (e))
+
+#define XA_MIXER_EXEC_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_MIXER, (e))
+
+enum xa_error_nonfatal_execute_mixer {
+ XA_MIXER_EXEC_NONFATAL_STATE = XA_MIXER_EXEC_NONFATAL(0),
+ XA_MIXER_EXEC_NONFATAL_NO_DATA = XA_MIXER_EXEC_NONFATAL(1),
+ XA_MIXER_EXEC_NONFATAL_INPUT = XA_MIXER_EXEC_NONFATAL(2),
+ XA_MIXER_EXEC_NONFATAL_OUTPUT = XA_MIXER_EXEC_NONFATAL(3),
+ XA_MIXER_EXEC_NONFATAL_MAX = XA_MIXER_EXEC_NONFATAL(4)
+};
+
+enum xa_error_fatal_execute_mixer {
+ XA_MIXER_EXEC_FATAL_STATE = XA_MIXER_EXEC_FATAL(0),
+ XA_MIXER_EXEC_FATAL_INPUT = XA_MIXER_EXEC_FATAL(1),
+ XA_MIXER_EXEC_FATAL_OUTPUT = XA_MIXER_EXEC_FATAL(2),
+ XA_MIXER_EXEC_FATAL_MAX = XA_MIXER_EXEC_FATAL(3)
+};
+
+/*******************************************************************************
+ * API function definition (tbd)
+ ******************************************************************************/
+
+#if defined(USE_DLL) && defined(_WIN32)
+#define DLL_SHARED __declspec(dllimport)
+#elif defined (_WINDLL)
+#define DLL_SHARED __declspec(dllexport)
+#else
+#define DLL_SHARED
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif /* __cplusplus */
+DLL_SHARED xa_codec_func_t xa_mixer;
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus */
+
+#endif /* __XA_MIXER_API_H__ */
diff --git a/hifi/xaf/hifi-dpf/include/audio/xa_apicmd_standards.h b/hifi/xaf/hifi-dpf/include/audio/xa_apicmd_standards.h
new file mode 100644
index 00000000..eb1b78e1
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/audio/xa_apicmd_standards.h
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+#ifndef __XA_API_CMD_STANDARDS_H__
+#define __XA_API_CMD_STANDARDS_H__
+
+/*****************************************************************************/
+/* Standard API commands */
+/*****************************************************************************/
+
+enum xa_api_cmd_generic {
+ XA_API_CMD_GET_LIB_ID_STRINGS = 0x0001,
+
+ XA_API_CMD_GET_API_SIZE = 0x0002,
+ XA_API_CMD_INIT = 0x0003,
+
+ XA_API_CMD_SET_CONFIG_PARAM = 0x0004,
+ XA_API_CMD_GET_CONFIG_PARAM = 0x0005,
+
+ XA_API_CMD_GET_MEMTABS_SIZE = 0x0006,
+ XA_API_CMD_SET_MEMTABS_PTR = 0x0007,
+ XA_API_CMD_GET_N_MEMTABS = 0x0008,
+
+ XA_API_CMD_EXECUTE = 0x0009,
+
+ XA_API_CMD_PUT_INPUT_QUERY = 0x000A,
+ XA_API_CMD_GET_CURIDX_INPUT_BUF = 0x000B,
+ XA_API_CMD_SET_INPUT_BYTES = 0x000C,
+ XA_API_CMD_GET_OUTPUT_BYTES = 0x000D,
+ XA_API_CMD_INPUT_OVER = 0x000E,
+
+ XA_API_CMD_GET_MEM_INFO_SIZE = 0x0010,
+ XA_API_CMD_GET_MEM_INFO_ALIGNMENT = 0x0011,
+ XA_API_CMD_GET_MEM_INFO_TYPE = 0x0012,
+ XA_API_CMD_GET_MEM_INFO_PLACEMENT = 0x0013,
+ XA_API_CMD_GET_MEM_INFO_PRIORITY = 0x0014,
+ XA_API_CMD_SET_MEM_PTR = 0x0015,
+ XA_API_CMD_SET_MEM_INFO_SIZE = 0x0016,
+ XA_API_CMD_SET_MEM_PLACEMENT = 0x0017,
+
+ XA_API_CMD_GET_N_TABLES = 0x0018,
+ XA_API_CMD_GET_TABLE_INFO_SIZE = 0x0019,
+ XA_API_CMD_GET_TABLE_INFO_ALIGNMENT = 0x001A,
+ XA_API_CMD_GET_TABLE_INFO_PRIORITY = 0x001B,
+ XA_API_CMD_SET_TABLE_PTR = 0x001C,
+ XA_API_CMD_GET_TABLE_PTR = 0x001D
+};
+
+/*****************************************************************************/
+/* Standard API command indices */
+/*****************************************************************************/
+
+enum xa_cmd_type_generic {
+ /* XA_API_CMD_GET_LIB_ID_STRINGS indices */
+ XA_CMD_TYPE_LIB_NAME = 0x0100,
+ XA_CMD_TYPE_LIB_VERSION = 0x0200,
+ XA_CMD_TYPE_API_VERSION = 0x0300,
+
+ /* XA_API_CMD_INIT indices */
+ XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS = 0x0100,
+ XA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS = 0x0200,
+ XA_CMD_TYPE_INIT_PROCESS = 0x0300,
+ XA_CMD_TYPE_INIT_DONE_QUERY = 0x0400,
+
+ /* XA_API_CMD_EXECUTE indices */
+ XA_CMD_TYPE_DO_EXECUTE = 0x0100,
+ XA_CMD_TYPE_DONE_QUERY = 0x0200,
+ XA_CMD_TYPE_DO_RUNTIME_INIT = 0x0300
+};
+
+
+/*****************************************************************************/
+/* Standard API configuration parameters */
+/*****************************************************************************/
+
+enum xa_config_param_generic {
+ XA_CONFIG_PARAM_CUR_INPUT_STREAM_POS = 0x0100,
+ XA_CONFIG_PARAM_GEN_INPUT_STREAM_POS = 0x0200,
+};
+
+#endif /* __XA_API_CMD_STANDARDS_H__ */
diff --git a/hifi/xaf/hifi-dpf/include/audio/xa_error_standards.h b/hifi/xaf/hifi-dpf/include/audio/xa_error_standards.h
new file mode 100644
index 00000000..1b67b52f
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/audio/xa_error_standards.h
@@ -0,0 +1,79 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+#ifndef __XA_ERROR_STANDARDS_H__
+#define __XA_ERROR_STANDARDS_H__
+
+/*****************************************************************************/
+/* File includes */
+/* xa_type_def.h */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Constant hash defines */
+/*****************************************************************************/
+#define XA_NO_ERROR 0
+#define XA_FATAL_ERROR 0x80000000
+
+enum xa_error_severity {
+ xa_severity_nonfatal = 0,
+ xa_severity_fatal = 0xffffffff
+};
+
+enum xa_error_class {
+ xa_class_api = 0,
+ xa_class_config = 1,
+ xa_class_execute = 2,
+ xa_class_proxy = 3
+};
+
+#define XA_CODEC_GENERIC 0
+
+#define XA_ERROR_CODE(severity, class, codec, index) ((severity << 15) | (class << 11) | (codec << 6) | index)
+#define XA_ERROR_SEVERITY(code) (((code) & XA_FATAL_ERROR) != 0)
+#define XA_ERROR_CLASS(code) (((code) >> 11) & 0x0f)
+#define XA_ERROR_CODEC(code) (((code) >> 6) & 0x1f)
+#define XA_ERROR_SUBCODE(code) (((code) >> 0) & 0x3f)
+
+/* Our convention is that only api-class errors can be generic ones. */
+
+/*****************************************************************************/
+/* Class 0: API Errors */
+/*****************************************************************************/
+/* Non Fatal Errors */
+/* (none) */
+/* Fatal Errors */
+enum xa_error_fatal_api_generic {
+ XA_API_FATAL_MEM_ALLOC = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 0),
+ XA_API_FATAL_MEM_ALIGN = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 1),
+ XA_API_FATAL_INVALID_CMD = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 2),
+ XA_API_FATAL_INVALID_CMD_TYPE = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 3)
+};
+
+#endif /* __XA_ERROR_STANDARDS_H__ */
diff --git a/hifi/xaf/hifi-dpf/include/audio/xa_memory_standards.h b/hifi/xaf/hifi-dpf/include/audio/xa_memory_standards.h
new file mode 100644
index 00000000..27ec455f
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/audio/xa_memory_standards.h
@@ -0,0 +1,104 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+#ifndef __XA_MEMORY_STANDARDS_H__
+#define __XA_MEMORY_STANDARDS_H__
+
+/*****************************************************************************/
+/* Constant hash defines */
+/*****************************************************************************/
+/* when you don't need alignment, pass this to memory library */
+#define XA_MEM_NO_ALIGN 0x01
+
+/* standard memory types */
+/* to be used inter frames */
+#define XA_MEMTYPE_PERSIST 0x00
+/* read write, to be used intra frames */
+#define XA_MEMTYPE_SCRATCH 0x01
+/* read only memory, intra frame */
+#define XA_MEMTYPE_INPUT 0x02
+/* read-write memory, for usable output, intra frame */
+#define XA_MEMTYPE_OUTPUT 0x03
+/* readonly memory, inter frame */
+#define XA_MEMTYPE_TABLE 0x04
+/* input buffer before mem tabs allocation */
+#define XA_MEMTYPE_PRE_FRAME_INPUT 0x05
+/* input buffer before mem tabs allocation */
+#define XA_MEMTYPE_PRE_FRAME_SCRATCH 0x06
+/* for local variables */
+#define XA_MEMTYPE_AUTO_VAR 0x80
+
+/* standard memory priorities */
+#define XA_MEMPRIORITY_ANYWHERE 0x00
+#define XA_MEMPRIORITY_LOWEST 0x01
+#define XA_MEMPRIORITY_LOW 0x02
+#define XA_MEMPRIORITY_NORM 0x03
+#define XA_MEMPRIORITY_ABOVE_NORM 0x04
+#define XA_MEMPRIORITY_HIGH 0x05
+#define XA_MEMPRIORITY_HIGHER 0x06
+#define XA_MEMPRIORITY_CRITICAL 0x07
+
+/* standard memory placements */
+/* placement is defined by 64 bits */
+
+#define XA_MEMPLACE_FAST_RAM_0 0x000001
+#define XA_MEMPLACE_FAST_RAM_1 0x000002
+#define XA_MEMPLACE_FAST_RAM_2 0x000004
+#define XA_MEMPLACE_FAST_RAM_3 0x000008
+#define XA_MEMPLACE_FAST_RAM_4 0x000010
+#define XA_MEMPLACE_FAST_RAM_5 0x000020
+#define XA_MEMPLACE_FAST_RAM_6 0x000040
+#define XA_MEMPLACE_FAST_RAM_7 0x000080
+
+#define XA_MEMPLACE_INT_RAM_0 0x000100
+#define XA_MEMPLACE_INT_RAM_1 0x000200
+#define XA_MEMPLACE_INT_RAM_2 0x000400
+#define XA_MEMPLACE_INT_RAM_3 0x000800
+#define XA_MEMPLACE_INT_RAM_4 0x001000
+#define XA_MEMPLACE_INT_RAM_5 0x002000
+#define XA_MEMPLACE_INT_RAM_6 0x004000
+#define XA_MEMPLACE_INT_RAM_7 0x008000
+
+#define XA_MEMPLACE_EXT_RAM_0 0x010000
+#define XA_MEMPLACE_EXT_RAM_1 0x020000
+#define XA_MEMPLACE_EXT_RAM_2 0x040000
+#define XA_MEMPLACE_EXT_RAM_3 0x080000
+#define XA_MEMPLACE_EXT_RAM_4 0x100000
+#define XA_MEMPLACE_EXT_RAM_5 0x200000
+#define XA_MEMPLACE_EXT_RAM_6 0x400000
+#define XA_MEMPLACE_EXT_RAM_7 0x800000
+
+#define XA_MEMPLACE_DONTCARE_H 0xFFFFFFFF
+#define XA_MEMPLACE_DONTCARE_L 0xFFFFFFFF
+
+/* the simple common PC RAM */
+#define XA_PC_RAM_H 0x00000000
+#define XA_PC_RAM_L XA_MEMPLACE_EXT_RAM_0
+
+#endif /* __XA_MEMORY_STANDARDS_H__ */
diff --git a/hifi/xaf/hifi-dpf/include/audio/xa_type_def.h b/hifi/xaf/hifi-dpf/include/audio/xa_type_def.h
new file mode 100644
index 00000000..e83cdd34
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/audio/xa_type_def.h
@@ -0,0 +1,98 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+#ifndef __XA_TYPE_DEF_H__
+#define __XA_TYPE_DEF_H__
+
+/****************************************************************************/
+/* types type define prefix examples bytes */
+/************************ *********** ****** **************** ***** */
+typedef signed char WORD8 ;/* b WORD8 b_name 1 */
+typedef signed char * pWORD8 ;/* pb pWORD8 pb_nmae 1 */
+typedef unsigned char UWORD8 ;/* ub UWORD8 ub_count 1 */
+typedef unsigned char * pUWORD8 ;/* pub pUWORD8 pub_count 1 */
+
+typedef signed short WORD16 ;/* s WORD16 s_count 2 */
+typedef signed short * pWORD16 ;/* ps pWORD16 ps_count 2 */
+typedef unsigned short UWORD16 ;/* us UWORD16 us_count 2 */
+typedef unsigned short * pUWORD16;/* pus pUWORD16 pus_count 2 */
+
+typedef signed int WORD24 ;/* k WORD24 k_count 3 */
+typedef signed int * pWORD24 ;/* pk pWORD24 pk_count 3 */
+typedef unsigned int UWORD24 ;/* uk UWORD24 uk_count 3 */
+typedef unsigned int * pUWORD24;/* puk pUWORD24 puk_count 3 */
+
+typedef signed int WORD32 ;/* i WORD32 i_count 4 */
+typedef signed int * pWORD32 ;/* pi pWORD32 pi_count 4 */
+typedef unsigned int UWORD32 ;/* ui UWORD32 ui_count 4 */
+typedef unsigned int * pUWORD32;/* pui pUWORD32 pui_count 4 */
+
+typedef signed long long WORD40 ;/* m WORD40 m_count 5 */
+typedef signed long long * pWORD40 ;/* pm pWORD40 pm_count 5 */
+typedef unsigned long long UWORD40 ;/* um UWORD40 um_count 5 */
+typedef unsigned long long * pUWORD40;/* pum pUWORD40 pum_count 5 */
+
+typedef signed long long WORD64 ;/* h WORD64 h_count 8 */
+typedef signed long long * pWORD64 ;/* ph pWORD64 ph_count 8 */
+typedef unsigned long long UWORD64 ;/* uh UWORD64 uh_count 8 */
+typedef unsigned long long * pUWORD64;/* puh pUWORD64 puh_count 8 */
+
+typedef float FLOAT32 ;/* f FLOAT32 f_count 4 */
+typedef float * pFLOAT32;/* pf pFLOAT32 pf_count 4 */
+typedef double FLOAT64 ;/* d UFLOAT64 d_count 8 */
+typedef double * pFlOAT64;/* pd pFLOAT64 pd_count 8 */
+
+typedef void VOID ;/* v VOID v_flag 4 */
+typedef void * pVOID ;/* pv pVOID pv_flag 4 */
+
+/* variable size types: platform optimized implementation */
+//typedef signed int BOOL ;/* bool BOOL bool_true */
+//typedef unsigned int UBOOL ;/* ubool BOOL ubool_true */
+typedef signed int FLAG ;/* flag FLAG flag_false */
+typedef unsigned int UFLAG ;/* uflag FLAG uflag_false */
+typedef signed int LOOPIDX ;/* lp LOOPIDX lp_index */
+typedef unsigned int ULOOPIDX;/* ulp SLOOPIDX ulp_index */
+typedef signed int WORD ;/* lp LOOPIDX lp_index */
+typedef unsigned int UWORD ;/* ulp SLOOPIDX ulp_index */
+
+typedef LOOPIDX LOOPINDEX; /* lp LOOPIDX lp_index */
+typedef ULOOPIDX ULOOPINDEX;/* ulp SLOOPIDX ulp_index */
+
+#define PLATFORM_INLINE __inline
+
+typedef struct xa_codec_opaque { WORD32 _; } *xa_codec_handle_t;
+
+typedef int XA_ERRORCODE;
+
+typedef XA_ERRORCODE xa_codec_func_t(xa_codec_handle_t p_xa_module_obj,
+ WORD32 i_cmd,
+ WORD32 i_idx,
+ pVOID pv_value);
+
+#endif /* __XA_TYPE_DEF_H__ */
diff --git a/hifi/xaf/hifi-dpf/include/lib/mutex.h b/hifi/xaf/hifi-dpf/include/lib/mutex.h
new file mode 100644
index 00000000..2aef0f6e
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/lib/mutex.h
@@ -0,0 +1,59 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * mutex.h
+ *
+ *
+ * Implementation of "non-robust" Szymanski linear-waiting algorithm. Types of
+ * failures tolerated by Szymanski's "robust" algorithm are not specific for
+ * Xtensa DSP cluster and therefore more lightweight version of the algorithm
+ * is used. FIFO servicing property is of low importance, and faster/smaller
+ * version with linear-wait property is preferable.
+ *
+ * We assume there is just a single mutex in the system, and all communication
+ * variables are defined somewhere in board-specific headers and imported here
+ * by means of macros MUTEX_SHARED_READ/WRITE.
+ ******************************************************************************/
+
+#ifndef __MUTEX_H
+#define __MUTEX_H
+
+/*******************************************************************************
+ * Imported macros
+ ******************************************************************************/
+
+#if !defined(MUTEX_SHARED_READ) || !defined(MUTEX_SHARED_WRITE)
+#error "Macros MUTEX_SHARED_READ and/or MUTEX_SHARED_WRITE not defined"
+#endif
+
+/*******************************************************************************
+ * Entry points
+ ******************************************************************************/
+
+/* ...acquire global mutex from i-th core */
+extern void mutex_lock(u32 i);
+
+/* ...release global mutex from i-th core */
+extern void mutex_unlock(u32 i);
+
+#endif /* __MUTEX_H */
diff --git a/hifi/xaf/hifi-dpf/include/lib/rbtree.h b/hifi/xaf/hifi-dpf/include/lib/rbtree.h
new file mode 100644
index 00000000..7f02cdf3
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/lib/rbtree.h
@@ -0,0 +1,157 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * rbtree.h
+ *
+ * Generic implmentation of red-black trees
+ *
+ *******************************************************************************/
+
+#ifndef __RBTREE_H
+#define __RBTREE_H
+
+/*******************************************************************************
+ * Red-black tree node definition
+ ******************************************************************************/
+
+/* ...reference to rb-tree node */
+typedef struct rb_node *rb_idx_t;
+
+/* ...rb-tree node */
+typedef struct rb_node
+{
+ /* ...pointers to parent and two children */
+ rb_idx_t parent, left, right;
+
+ /* ...node color (least-significant-bit only) */
+ u32 color;
+
+} rb_node_t;
+
+/* ...rb-tree data */
+typedef struct rb_tree_t
+{
+ /* ...tree sentinel node */
+ rb_node_t root;
+
+} rb_tree_t;
+
+/*******************************************************************************
+ * Helpers
+ ******************************************************************************/
+
+/* ...left child accessor */
+static inline rb_idx_t rb_left(rb_tree_t *tree, rb_idx_t n_idx)
+{
+ return n_idx->left;
+}
+
+/* ...right child accessor */
+static inline rb_idx_t rb_right(rb_tree_t *tree, rb_idx_t n_idx)
+{
+ return n_idx->right;
+}
+
+/* ...parent node accessor */
+static inline rb_idx_t rb_parent(rb_tree_t *tree, rb_idx_t n_idx)
+{
+ return n_idx->parent;
+}
+
+/* ...tree root node accessor */
+static inline rb_idx_t rb_root(rb_tree_t *tree)
+{
+ return rb_left(tree, &tree->root);
+}
+
+/* ...tree data pointer accessor */
+static inline rb_idx_t rb_cache(rb_tree_t *tree)
+{
+ return rb_right(tree, &tree->root);
+}
+
+/* ...tree null node */
+static inline rb_idx_t rb_null(rb_tree_t *tree)
+{
+ return &tree->root;
+}
+
+/* ...get user-bits stored in node color */
+static inline u32 rb_node_data(rb_tree_t *tree, rb_idx_t n_idx)
+{
+ return (n_idx->color >> 1);
+}
+
+/* ...left child assignment */
+static inline void rb_set_left(rb_tree_t *tree, rb_idx_t n_idx, rb_node_t *child)
+{
+ n_idx->left = child;
+}
+
+/* ...right child assignment */
+static inline void rb_set_right(rb_tree_t *tree, rb_idx_t n_idx, rb_node_t *child)
+{
+ n_idx->right = child;
+}
+
+/* ...cache tree client index */
+static inline void rb_set_cache(rb_tree_t *tree, rb_idx_t c_idx)
+{
+ tree->root.right = c_idx;
+}
+
+/* ...get user-bits stored in node color */
+static inline void rb_set_node_data(rb_tree_t *tree, rb_idx_t n_idx, u32 data)
+{
+ n_idx->color = (n_idx->color & 0x1) | (data << 1);
+}
+
+/*******************************************************************************
+ * API functions
+ ******************************************************************************/
+
+/* ...initialize rb-tree */
+extern void rb_init(rb_tree_t *tree);
+
+/* ...insert node into tree as a child of p */
+extern void rb_insert(rb_tree_t *tree, rb_idx_t n_idx, rb_idx_t p_idx);
+
+/* ...replace the node with same-key value and fixup tree pointers */
+extern void rb_replace(rb_tree_t *tree, rb_idx_t n_idx, rb_idx_t t_idx);
+
+/* ...delete node from the tree and return its in-order predecessor/successor */
+extern rb_idx_t rb_delete(rb_tree_t *tree, rb_idx_t n_idx);
+
+/* ...first in-order item in the tree */
+extern rb_idx_t rb_first(rb_tree_t *tree);
+
+/* ...last in-order item in the tree */
+extern rb_idx_t rb_last(rb_tree_t *tree);
+
+/* ...forward tree iterator */
+extern rb_idx_t rb_next(rb_tree_t *tree, rb_idx_t n_idx);
+
+/* ...backward tree iterator */
+extern rb_idx_t rb_prev(rb_tree_t *tree, rb_idx_t n_idx);
+
+#endif /* __RBTREE_H */
diff --git a/hifi/xaf/hifi-dpf/include/lib/tinyput.h b/hifi/xaf/hifi-dpf/include/lib/tinyput.h
new file mode 100644
index 00000000..dadd0885
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/lib/tinyput.h
@@ -0,0 +1,31 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/* $Id: //depot/dev/Cottonwood/Xtensa/OS/mpg2/tinyput.h#2 $ */
+
+#include <stdarg.h>
+
+extern void tiny_putc(char c);
+extern int tiny_puts(const char *s);
+extern int tiny_atoi(const char *s);
+extern int tiny_vsprintf(char *out, const char *fmt, va_list ap);
+extern int tiny_sprintf(char *out, const char *fmt, ...);
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/arch_hifi330.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/arch_hifi330.h
new file mode 100644
index 00000000..74b12220
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/arch_hifi330.h
@@ -0,0 +1,134 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#include <xtensa/simcall.h>
+#include <xtensa/corebits.h>
+#include <xtensa/config/system.h>
+#include <xtensa/config/core.h>
+
+#ifndef __ARCH_HIFI330_H__
+#define __ARCH_HIFI330_H__
+
+#ifdef __ASSEMBLER__
+#include <xtensa/coreasm.h>
+#endif
+
+#include <xtensa/corebits.h>
+#include <xtensa/config/system.h>
+
+/*
+Align a value up to nearest n-byte boundary, where n is a power of 2.
+*/
+#define ALIGNUP(n, val) (((val) + (n)-1) & -(n))
+
+
+/*******************************************************************************
+INTERRUPT STACK FRAME FOR A THREAD OR NESTED INTERRUPT
+*******************************************************************************/
+#define XT_STK_EXIT 0x00 /* (offset 0) exit point for dispatch */
+#define XT_STK_PC 0x04 /* return address */
+#define XT_STK_PS 0x08 /* at level 1 PS.EXCM is set here */
+#define XT_STK_A0 0x0C
+#define XT_STK_A1 0x10 /* stack ptr before interrupt */
+#define XT_STK_A2 0x14
+#define XT_STK_A3 0x18
+#define XT_STK_A4 0x1C
+#define XT_STK_A5 0x20
+#define XT_STK_A6 0x24
+#define XT_STK_A7 0x28
+#define XT_STK_A8 0x2C
+#define XT_STK_A9 0x30
+#define XT_STK_A10 0x34
+#define XT_STK_A11 0x38
+#define XT_STK_A12 0x3C /* Call0 callee-save */
+#define XT_STK_A13 0x40 /* Call0 callee-save */
+#define XT_STK_A14 0x44 /* Call0 callee-save */
+#define XT_STK_A15 0x48 /* Call0 callee-save */
+#define XT_STK_SAR 0x4C
+
+#define XT_STK_LBEG 0x50
+#define XT_STK_LEND 0x54
+#define XT_STK_LCOUNT 0x58
+#define XT_STK_NEXT1 0x5C /* next unused offset */
+
+#define XT_STK_EXTRA ALIGNUP(XCHAL_EXTRA_SA_ALIGN, XT_STK_NEXT1)
+
+#define XT_STK_NEXT2 (XT_STK_EXTRA + XCHAL_EXTRA_SA_SIZE)
+
+#define XT_STK_N_TMP 3 /* # of 4-byte temp. slots */
+#define XT_STK_TMP XT_STK_NEXT2
+#define XT_STK_NEXT3 XT_STK_TMP + (4 * XT_STK_N_TMP)
+#define XT_STK_FRMSZ (ALIGNUP(0x10, XT_STK_NEXT3) + 0x20)
+
+
+/*******************************************************************************
+SIMPLE STACK FRAME FOR A THREAD
+*******************************************************************************/
+#define XT_SOL_EXIT XT_STK_EXIT /* code indicates solicited frame */
+#define XT_SOL_PC 0x04 /* return address (b30-31=callinc) */
+#define XT_SOL_PS 0x08
+#define XT_SOL_NEXT 0x0c /* next unused offset */
+ /* there may be some unused space here */
+#define XT_SOL_A0 ALIGNUP(0x10, XT_SOL_NEXT)
+#define XT_SOL_A1 XT_SOL_A0 + 4
+#define XT_SOL_A2 XT_SOL_A1 + 4
+#define XT_SOL_A3 XT_SOL_A2 + 4
+#define XT_SOL_FRMSZ ALIGNUP(0x10, XT_SOL_A3)
+
+
+/*******************************************************************************
+CO-PROCESSOR STATE SAVE AREA FOR A THREAD
+*******************************************************************************/
+#define XT_CPENABLE 0
+#define XT_CPSTORED (XT_CPENABLE + 1)
+#define XT_CP0_SA ALIGNUP(XCHAL_CP0_SA_ALIGN, XT_CPSTORED + 1)
+#define XT_CP1_SA ALIGNUP(XCHAL_CP1_SA_ALIGN, XT_CP0_SA + XCHAL_CP0_SA_SIZE)
+#define XT_CP2_SA ALIGNUP(XCHAL_CP2_SA_ALIGN, XT_CP1_SA + XCHAL_CP1_SA_SIZE)
+#define XT_CP3_SA ALIGNUP(XCHAL_CP3_SA_ALIGN, XT_CP2_SA + XCHAL_CP2_SA_SIZE)
+#define XT_CP4_SA ALIGNUP(XCHAL_CP4_SA_ALIGN, XT_CP3_SA + XCHAL_CP3_SA_SIZE)
+#define XT_CP5_SA ALIGNUP(XCHAL_CP5_SA_ALIGN, XT_CP4_SA + XCHAL_CP4_SA_SIZE)
+#define XT_CP6_SA ALIGNUP(XCHAL_CP6_SA_ALIGN, XT_CP5_SA + XCHAL_CP5_SA_SIZE)
+#define XT_CP7_SA ALIGNUP(XCHAL_CP7_SA_ALIGN, XT_CP6_SA + XCHAL_CP6_SA_SIZE)
+#define XT_CP_SIZE ALIGNUP(4 , XT_CP7_SA + XCHAL_CP7_SA_SIZE)
+
+#ifdef __ASSEMBLER__
+/* Windowed */
+#define ENTRY(sz) entry sp, sz
+#define ENTRY0 entry sp, 0x10
+#define RET(sz) retw
+#define RET0 retw
+#endif
+
+#define XT_TICK_PER_SEC 100
+#define XT_RTOS_INT_ENTER OS_IntEnter
+#define XT_RTOS_INT_EXIT OS_IntExit
+#define XT_RTOS_CP_STATE OS_GetTaskCoprocState
+
+#ifdef __ASSEMBLER__
+// typedef struct vos_tcb {
+#define OSTCBStkPtr 0x00 // OSTCBStkPtr
+#define OSTCBStkBottom 0x10 // StackAddress
+//...
+// } VOS_TCB;
+#endif /* __ASSEMBLER__ */
+
+#endif /* end of arch_balongV7r1.h */
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/cpu_c.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/cpu_c.h
new file mode 100644
index 00000000..0cc0da93
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/cpu_c.h
@@ -0,0 +1,109 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __CPU_C_H__
+#define __CPU_C_H__
+
+enum OS_HOOK_TYPE_ENUM
+{
+ OS_HOOK_TYPE_ENTER_INTR=0,
+ OS_HOOK_TYPE_EXIT_INTR,
+ OS_HOOK_TYPE_TASK_SWITCH,
+ OS_HOOK_TYPE_MSG_GET,
+ OS_HOOK_TYPE_NMI,
+ OS_HOOK_TYPE_EXCEPTION,
+ OS_HOOK_TYPE_APPINIT,
+ OS_HOOK_TYPE_IDLE,
+ OS_HOOK_TYPE_BUTT
+};
+
+enum OS_INTR_CONNECT_TYPE_ENUM
+{
+ OS_INTR_CONNECT_00=0, /*Int 0 type / priority level NMI / 6 */
+ OS_INTR_CONNECT_01, /*Int 1 type / priority level Software / 3 */
+ OS_INTR_CONNECT_02, /*Int 2 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_03, /*Int 3 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_04, /*Int 4 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_05, /*Int 5 type / priority level Timer / 3 */
+ OS_INTR_CONNECT_06, /*Int 6 type / priority level Timer / 4 */
+ OS_INTR_CONNECT_07, /*Int 7 type / priority level ExtLevel / 3 */
+ OS_INTR_CONNECT_08, /*Int 8 type / priority level ExtLevel / 3 */
+ OS_INTR_CONNECT_09, /*Int 9 type / priority level ExtLevel / 3 */
+ OS_INTR_CONNECT_10, /*Int 10 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_11, /*Int 11 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_12, /*Int 12 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_13, /*Int 13 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_14, /*Int 14 type / priority level ExtLevel / 2 */
+ OS_INTR_CONNECT_15, /*Int 15 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_16, /*Int 16 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_17, /*Int 17 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_18, /*Int 18 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_19, /*Int 19 type / priority level Timer / 2 */
+ OS_INTR_CONNECT_20, /*Int 20 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_21, /*Int 21 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_22, /*Int 22 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_23, /*Int 23 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_24, /*Int 24 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_25, /*Int 25 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_26, /*Int 26 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_27, /*Int 27 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_28, /*Int 28 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_29, /*Int 29 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_30, /*Int 30 type / priority level ExtLevel / 1 */
+ OS_INTR_CONNECT_31, /*Int 31 type / priority level ExtEdge / 1 */
+ OS_INTR_CONNECT_BUTT
+};
+
+#define UCOM_SET_WFI_NMI(var1) asm ("waiti 5": :)
+
+#define UCOM_FlushCache(pAddr, uwSize) \
+ xthal_dcache_region_writeback(pAddr, uwSize)
+
+#define UCOM_FlushCacheAll() \
+ xthal_dcache_all_writeback()
+
+#define UCOM_InvalidateCache(pAddr, uwSize) \
+ xthal_dcache_region_invalidate(pAddr, uwSize)
+
+#define UCOM_InvalidateCacheAll() \
+ xthal_dcache_all_invalidate()
+
+#define ADD_TAG asm("movi a1, 0xdeadbaaf \n movi a2, 0xe8075e80 \n s32i a1, a2, 0": :)
+
+//typedef void (*HOOK_FUN_TYPE)(void);
+typedef void (*HOOK_FUN_TYPE)(unsigned int);
+
+typedef void (*INTR_HOOK_FUN_TYPE )(unsigned int uwIntNo);
+
+typedef void (*VOS_EXCEPTION_HOOK_FUNC)( unsigned int uwExceptionNo);
+
+extern void *g_pfVosHookFuncTable[OS_HOOK_TYPE_BUTT];
+
+extern void VOS_ConnectInterrupt(unsigned int uwIntrNo, HOOK_FUN_TYPE pfnInterruptHook);
+
+extern void VOS_EnableInterrupt(unsigned int uwIntNo);
+extern void VOS_DisableInterrupt(unsigned int uwIntNo);
+
+extern void OS_UserExit(void);
+
+
+#endif /* end of cpu_c.h */
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_comm.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_comm.h
new file mode 100644
index 00000000..37646777
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_comm.h
@@ -0,0 +1,45 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __DSP_COMM_H__
+#define __DSP_COMM_H__
+
+#include <xtensa/config/core.h>
+#include <xtensa/simcall.h>
+
+#define DSP_FLUSH_PIECE_CACHE(addr, size) xthal_dcache_region_writeback(addr, size)
+#define DSP_FLUSH_ALL_CACHE() xthal_dcache_all_writeback()
+#define DSP_INVALIDATE_PIECE_CACHE(addr, size) xthal_dcache_region_invalidate(addr, size)
+#define DSP_INVALIDATE_ALL_CACHE() xthal_dcache_all_invalidate()
+
+#define memset(d,uCData,size) dsp_memset(d,uCData,size)
+#define memcpy(d,s,size) dsp_memcpy(d,s,size)
+#define divsi3(a,b) division(a,b)
+#define _divsi3(a,b) division(a,b)
+
+void dsp_memcpy(void *d, void *s, unsigned int size);
+void dsp_memset(void *d, unsigned char ucData, unsigned int size);
+int division(int a, int b);
+
+#endif /* end of dsp_comm.h */
+
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_debug.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_debug.h
new file mode 100644
index 00000000..0ca2d373
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_debug.h
@@ -0,0 +1,71 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __DSP_DEBUG_H__
+#define __DSP_DEBUG_H__
+
+
+#define DEBUG_LEVEL 0
+#define INFO_LEVEL 1
+#define WARNING_LEVEL 1
+#define ERROR_LEVEL 1
+#define TRACE_DUMP 1
+
+#define LOG_TAG " DSP_LOG"
+
+#if TRACE_DUMP
+#define DSP_TRACE(fmt, ...) print_log(fmt" @%s:%d \n", ##__VA_ARGS__, __FUNCTION__, __LINE__)
+#else
+#define DSP_TRACE(fmt, ...)
+#endif
+
+#if DEBUG_LEVEL
+#define DSP_LOGD(fmt, ...) print_log(LOG_TAG"[D]%s:%d: "fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#else
+#define DSP_LOGD(fmt, ...)
+#endif
+
+#if INFO_LEVEL
+#define DSP_LOGI(fmt, ...) print_log(LOG_TAG"[I]%s:%d: "fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#else
+#define DSP_LOGI(fmt, ...)
+#endif
+
+#if WARNING_LEVEL
+#define DSP_LOGW(fmt, ...) print_log(LOG_TAG"[W]%s:%d: "fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#else
+#define DSP_LOGW(fmt, ...)
+#endif
+
+#if ERROR_LEVEL
+#define DSP_LOGE(fmt, ...) print_log(LOG_TAG"[E]%s:%d: "fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#else
++#define DSP_LOGE(fmt, ...)
+#endif
+
+
+void print_log(const char *fmt, ...);
+void dsp_debug_init();
+#ifdef HIKEY_XAF_IPC_COMMENT_OUT
+void dsp_om_func_proc(char *om_str, unsigned int str_len);
+#endif
+#endif
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_ipc.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_ipc.h
new file mode 100644
index 00000000..2228f32a
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_ipc.h
@@ -0,0 +1,61 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __DSP_DRIVER_IPC_H__
+#define __DSP_DRIVER_IPC_H__
+
+#if 0
+#define DSP_IPC_FROM_AP_INT_NO (3)
+#define DSP_SYS_IPC_BASE_ADDR_NS (0xe896b000)
+#define DSP_AP_TO_DSP_MAILBOX_NO (18)
+#define DSP_DSP_TO_AP_MAILBOX_NO (2)
+#define IPC_BUSY_RETRY_COUNT (1000)
+#define IPC_ACPU_INT_SRC_HIFI_MSG (1)
+#define BIT_MASK(n) (1 << (n))
+
+#define WORD_REF(address) (* ((unsigned int volatile *) (address)))
+
+#define SYS_IPC_LOCK(base) WORD_REF(base + 0xA00)
+#define SYS_IPC_ICLR(base, box) WORD_REF(base + ((box) << 6) + 0x18)
+#define SYS_IPC_DATA(base, box, num) WORD_REF(base + ((box) << 6) + 0x20 + ((num) << 2))
+#define SYS_IPC_CPUIRST(base, core) WORD_REF(base + 0x804 + ((core) << 3))
+#define SYS_IPC_MODE(base, box) WORD_REF(base + ((box) << 6) + 0x10)
+#define SYS_IPC_SOURCE(base, box) WORD_REF(base + ((box) << 6))
+#define SYS_IPC_DEST(base, box) WORD_REF(base + ((box) * 64) + 0x04)
+#define SYS_IPC_SEND(base, box) WORD_REF(base + ((box) << 6) + 0x1c)
+#define SYS_IPC_IMASK(base, box) WORD_REF(base + ((box) << 6) + 0x14)
+#define SYS_IPC_DCLR(base, box) WORD_REF(base + ((box) * 64) + 0x08)
+#define SYS_IPC_CPUIMST(base, core) WORD_REF(base + 0x800 + ((core) * 8))
+#define SYS_IPC_MODE_ACK (7)
+#define SYS_IPC_MODE_IDLE (4)
+#define SYS_IPC_MODE_AUTOACK (0)
+
+#define SYS_IPC_CORE_HIFI (4)
+#define SYS_IPC_CORE_A15 (0)
+#define SYS_IPC_CORE_LPM3 (3)
+#endif
+#if 0
+extern void dsp_ipc_init(void);
+extern void dsp_ipc_wait(void);
+#endif
+#endif
+
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_mailbox.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_mailbox.h
new file mode 100644
index 00000000..5fdcca9a
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_mailbox.h
@@ -0,0 +1,171 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __DSP_DRIVER_MAILBOX_H__
+#define __DSP_DRIVER_MAILBOX_H__
+
+#include <stdint.h>
+
+#define HIKEY_MSG_HEAD_PROTECT_WORD 0xffff1234
+#define HIKEY_MSG_BODY_PROTECT_WORD 0xffff4321
+
+#define HIKEY_MSG_ID_AP_DSP_OM_CMD 0xDDCB
+#define HIKEY_AUDIO_DSP_AP_OM_CMD 0xDDC9
+
+typedef enum HIFI_MSG_ID_ {
+
+ /*DTS command id from ap*/
+ ID_AP_AUDIO_SET_DTS_ENABLE_CMD = 0xDD36,
+ ID_AP_AUDIO_SET_DTS_DEV_CMD = 0xDD38,
+ ID_AP_AUDIO_SET_DTS_GEQ_CMD = 0xDD39,
+ ID_AP_AUDIO_SET_DTS_GEQ_ENABLE_CMD = 0xDD3B,
+
+ /* APºÍHIFIµÄ¿ØÖÆÍâÖöú»úHIFI codecœ»»¥ÏûÏ¢ */
+ ID_AP_AUDIO_SET_EXCODEC_ENABLE_CMD = 0xDD3D,
+
+ /* Voice Record */
+ ID_AP_HIFI_VOICE_RECORD_START_CMD = 0xDD40,
+ ID_AP_HIFI_VOICE_RECORD_STOP_CMD = 0xDD41,
+
+ /* voicePP MSG_ID */
+ ID_AP_VOICEPP_START_REQ = 0xDD42, /* Æô¶¯VOICEPPÍš»° */
+ ID_VOICEPP_MSG_START = ID_AP_VOICEPP_START_REQ,
+ ID_VOICEPP_AP_START_CNF = 0xDD43,
+ ID_AP_VOICEPP_STOP_REQ = 0xDD44, /* ÖÕÖ¹VOICEPPÍš»° */
+ ID_VOICEPP_AP_STOP_CNF = 0xDD45,
+ ID_VOICEPP_MSG_END = 0xDD4A,
+
+ ID_AP_AUDIO_PLAY_START_REQ = 0xDD51,/* APÆô¶¯Hifi audio player requestÃüÁî */
+ ID_AUDIO_AP_PLAY_START_CNF = 0xDD52,/* HifiÆô¶¯audio playerºó»ØžŽAP confirmÃüÁî */
+ ID_AP_AUDIO_PLAY_PAUSE_REQ = 0xDD53,/* APÍ£Ö¹Hifi audio player requestÃüÁî */
+ ID_AUDIO_AP_PLAY_PAUSE_CNF = 0xDD54,/* HifiÍ£Ö¹audio playerºó»ØžŽAP confirmÃüÁî */
+ ID_AUDIO_AP_PLAY_DONE_IND = 0xDD56,/* HifiÍšÖªAP audio playerÒ»¿éÊýŸÝ²¥·ÅÍê±Ï»òÕß²¥·ÅÖжÏindication */
+ ID_AP_AUDIO_PLAY_UPDATE_BUF_CMD = 0xDD57,/* APÍšÖªHifiÐÂÊýŸÝ¿éžüÐÂcommand */
+ ID_AP_AUDIO_PLAY_QUERY_TIME_REQ = 0xDD59,/* AP²éѯHifi audio player²¥·Åœø¶ÈrequestÃüÁî */
+ ID_AP_AUDIO_PLAY_WAKEUPTHREAD_REQ = 0xDD5A,
+ ID_AUDIO_AP_PLAY_QUERY_TIME_CNF = 0xDD60,/* Hifi»ØžŽAP audio player²¥·Åœø¶ÈconfirmÃüÁî */
+ ID_AP_AUDIO_PLAY_QUERY_STATUS_REQ = 0xDD61,/* AP²éѯHifi audio player²¥·Å׎̬requestÃüÁî */
+ ID_AUDIO_AP_PLAY_QUERY_STATUS_CNF = 0xDD62,/* Hifi»ØžŽAP audio player²¥·Å׎̬confirmÃüÁî */
+ ID_AP_AUDIO_PLAY_SEEK_REQ = 0xDD63,/* AP seek Hifi audio playerµœÄ³Ò»Î»ÖÃrequestÃüÁî */
+ ID_AUDIO_AP_PLAY_SEEK_CNF = 0xDD64,/* Hifi»ØžŽAP seekœá¹ûconfirmÃüÁî */
+ ID_AP_AUDIO_PLAY_SET_VOL_CMD = 0xDD70,/* APÉèÖÃÒôÁ¿ÃüÁî */
+ ID_AP_AUDIO_RECORD_PCM_HOOK_CMD = 0xDD7A,/* AP ÍšÖªHIFI¿ªÊŒ×¥È¡PCMÊýŸÝ */
+ ID_AUDIO_AP_UPDATE_PCM_BUFF_CMD = 0xDD7C,
+ ID_AP_AUDIO_DYN_EFFECT_GET_PARAM = 0xDD7D,
+ ID_AP_AUDIO_DYN_EFFECT_GET_PARAM_CNF = 0xDD7E,
+ ID_AP_AUDIO_DYN_EFFECT_TRIGGER = 0xDD7F,
+ /* enhance msgid between ap and hifi */
+ ID_AP_HIFI_ENHANCE_START_REQ = 0xDD81,
+ ID_HIFI_AP_ENHANCE_START_CNF = 0xDD82,
+ ID_AP_HIFI_ENHANCE_STOP_REQ = 0xDD83,
+ ID_HIFI_AP_ENHANCE_STOP_CNF = 0xDD84,
+ ID_AP_HIFI_ENHANCE_SET_DEVICE_REQ = 0xDD85,
+ ID_HIFI_AP_ENHANCE_SET_DEVICE_CNF = 0xDD86,
+
+ /* audio enhance msgid between ap and hifi */
+ ID_AP_AUDIO_ENHANCE_SET_DEVICE_IND = 0xDD91,
+ ID_AP_AUDIO_MLIB_SET_PARA_IND = 0xDD92,
+ ID_AP_AUDIO_CMD_SET_SOURCE_CMD = 0xDD95,
+ ID_AP_AUDIO_CMD_SET_DEVICE_CMD = 0xDD96,
+ ID_AP_AUDIO_CMD_SET_MODE_CMD = 0xDD97,
+ ID_AP_AUDIO_CMD_SET_ANGLE_CMD = 0xDD99,
+
+ /* for 3mic */
+ ID_AP_AUDIO_ROUTING_COMPLETE_REQ = 0xDDC0,/*AP ÍšÖªHIFI 3Mic/4Mic ͚·ÒÑœšÁ¢*/
+ ID_AUDIO_AP_DP_CLK_EN_IND = 0xDDC1,/* HIFI ÍšÖªAºËŽò¿ª»ò¹Ø±ÕCodec DPʱÖÓ */
+ ID_AP_AUDIO_DP_CLK_STATE_IND = 0xDDC2,/* AºËÍšÖªHIFI £¬Codec DPʱÖÓ׎̬( Žò¿ª»ò¹Ø±Õ) */
+ ID_AUDIO_AP_OM_DUMP_CMD = 0xDDC3,/* HIFI ÍšÖªAºËdumpÈÕÖŸ */
+ ID_AUDIO_AP_FADE_OUT_REQ = 0xDDC4,/* HIFIÍšÖªAP×öµ­³öŽŠÀí */
+ ID_AP_AUDIO_FADE_OUT_IND = 0xDDC5,/* APÍšÖªHIFIµ­³öÍê±Ï */
+
+ ID_AUDIO_AP_OM_CMD = 0xDDC9,
+ ID_AP_AUDIO_STR_CMD = 0xDDCB,/* APžøHIFI·¢ËÍÒ»žö×Ö·ûŽ®£¬ŸßÌ庬ÒåhifiÖÐœâÎö */
+ ID_AUDIO_AP_VOICE_BSD_PARAM_CMD = 0xDDCC,/* VOICE BSD ²ÎÊýÉϱš */
+
+ ID_AP_ENABLE_MODEM_LOOP_REQ = 0xDDCD,/* the audio hal notify HIFI to start/stop MODEM LOOP*/
+ ID_AP_HIFI_REQUEST_VOICE_PARA_REQ = 0xDF00, /*AP REQUEST VOICE MSG*/
+ ID_HIFI_AP_REQUEST_VOICE_PARA_CNF = 0xDF01, /*HIFI REPLAY VOICE MSG*/
+
+ /* XAF message IDs */
+ ID_XAF_AP_TO_DSP = 0xDF10,
+ ID_XAF_DSP_TO_AP = 0xDF11,
+} HIFI_MSG_ID;
+
+#define HIKEY_AP2DSP_MSG_QUEUE_ADDR HIFI_HIKEY_SHARE_MEM_ADDR
+
+#define HIKEY_AP2DSP_MSG_QUEUE_SIZE 0x1800
+#define HIKEY_DSP2AP_MSG_QUEUE_ADDR (HIKEY_AP2DSP_MSG_QUEUE_ADDR + HIKEY_AP2DSP_MSG_QUEUE_SIZE)
+#define HIKEY_DSP2AP_MSG_QUEUE_SIZE 0x1800
+
+#define HIKEY_AP_DSP_MSG_MAX_LEN 100
+/////////////////////////////////////////////////////////////////////
+// XAF STRUCTURES //
+/////////////////////////////////////////////////////////////////////
+#ifdef GJB_CHANGE
+/* ...command/response message */
+typedef struct xf_proxy_msg {
+ /* ...session ID */
+ uint32_t id;
+
+ /* ...proxy API command/reponse code */
+ uint32_t opcode;
+
+ /* ...length of attached buffer */
+ uint32_t length;
+
+ /* ...physical address of message buffer */
+ uint64_t address;
+ uint64_t v_address;
+
+} __attribute__((__packed__)) xf_proxy_msg_t;
+
+struct hikey_ap_dsp_msg_head {
+ unsigned int head_protect_word;
+ unsigned int msg_num;
+ unsigned int read_pos;
+ unsigned int write_pos;
+};
+
+/*struct hikey_ap_dsp_msg_body {
+ unsigned short msg_id;
+ unsigned short msg_len;
+ char msg_content[0];
+};*/
+
+struct hikey_ap_dsp_msg_body {
+ unsigned short msg_id;
+ unsigned short msg_len;
+ union {
+ char msg_content[0];
+ struct xf_proxy_msg xf_dsp_msg;
+ };
+};
+struct hikey_msg_with_content {
+ struct hikey_ap_dsp_msg_body msg_info;
+ char msg_content[HIKEY_AP_DSP_MSG_MAX_LEN];
+};
+void dsp_init_share_mem(char *share_mem_addr, unsigned int share_mem_size);
+int dsp_mailbox_read(struct hikey_msg_with_content *hikey_msg);
+void dsp_msg_process(struct hikey_msg_with_content *hikey_msg);
+#else
+#endif
+#endif
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_memory_config.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_memory_config.h
new file mode 100644
index 00000000..fd5a93d3
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_memory_config.h
@@ -0,0 +1,96 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __DSP_MEMORY_CONFIG_H__
+#define __DSP_MEMORY_CONFIG_H__
+
+/** for chicago only **/
+/**Non Secure 3.5M **/
+/* |0x8B300000|0x8B432000|0x8B532000|0x8B5B1000|0x8B5B2000|0x8B5C5000|0x8B5C6000|0x8B5C7000|0x8B5F9800|~~0x8B609800~~|~~0x8B618800~~|~0x8B618880~|0x8B627880|~0x8B629880~|0x8B62C880~~~| */
+/* |Music data|~~PCM data|~hifi uart|panicstack|icc debug~|flag data~|DDRsechead|~~AP NV ~~|AP&HIFIMB~|codec dma buff|codecdmaconfig|soundtrigger|pcm upload|~hikey share|unsec reserve| */
+/* |~~~~1.2M~~|~~~~1M~~~~|~~508k~~~~|~~~~~4k~~~|~~76k~~~~~|~~~4k~~~~~|~~~4k~~~~~|~~202k~~~~|~~~64k~~~~|~~~~60k~~~~~~~|~~~~128b~~~~~~|~~~~60k~~~~~|~~~8k~~~~~|~~~~~12k~~~~|~~334k-128b~~| */
+/* |0x8B431fff|0x8B531fff|0x8B5B0fff|0x8B5B1fff|0x8B5C4fff|0x8B5C5fff|0x8B5C6fff|0x8B5F97ff|0x8B6097ff|~~0x8B6187FF~~|~~0x8B61887F~~|~0x8B62787F~|0x8B62987F|0x8B62C87F~~|~~0x8B67FFFF~| */
+
+/** Secure9.5M **/
+/* |~~~0x89200000~~~|~~~0x89800000~~~|~~~0x89830000~~|~~~0x89864000~~~| */
+/* |~~HIFI RUNNING~~|~OCRAM img bak~~|~~TCM img bak~~|~~~~IMG bak~~~~~| */
+/* |~~~~~~~6M~~~~~~~|~~~~~~192K~~~~~~|~~~~~208k~~~~~~|~~~~~~3.1M ~~~~~| */
+/* |~~~0x897fffff~~~|~~~0x8982ffff~~~|~~~0x89863fff~~|~~~0x89B80000~~~| */
+
+
+#define HIFI_UNSEC_REGION_SIZE (0x380000)
+#define HIFI_MUSIC_DATA_SIZE (0x132000)
+#define PCM_PLAY_BUFF_SIZE (0x100000)
+#define DRV_DSP_UART_TO_MEM_SIZE (0x7f000)
+#define DRV_DSP_UART_TO_MEM_RESERVE_SIZE (0x100)
+#define DRV_DSP_STACK_TO_MEM_SIZE (0x1000)
+#define HIFI_ICC_DEBUG_SIZE (0x13000)
+#define HIFI_FLAG_DATA_SIZE (0x1000)
+#define HIFI_SEC_HEAD_SIZE (0x1000)
+#define HIFI_AP_NV_DATA_SIZE (0x32800)
+#define HIFI_AP_MAILBOX_TOTAL_SIZE (0x10000)
+#define CODEC_DSP_OM_DMA_BUFFER_SIZE (0xF000)
+#define CODEC_DSP_OM_DMA_CONFIG_SIZE (0x80)
+#define CODEC_DSP_SOUNDTRIGGER_TOTAL_SIZE (0xF000)
+#define HIFI_PCM_UPLOAD_BUFFER_SIZE (0x2000)
+#define HIFI_HIKEY_SHARE_SIZE (0x1800 * 2)
+#define HIFI_UNSEC_RESERVE_SIZE (0x53780)
+
+#define HIFI_UNSEC_BASE_ADDR (0x8B300000)
+#define HIFI_MUSIC_DATA_LOCATION (HIFI_UNSEC_BASE_ADDR)
+#define PCM_PLAY_BUFF_LOCATION (HIFI_MUSIC_DATA_LOCATION + HIFI_MUSIC_DATA_SIZE)
+#define DRV_DSP_UART_TO_MEM (PCM_PLAY_BUFF_LOCATION + PCM_PLAY_BUFF_SIZE)
+#define DRV_DSP_STACK_TO_MEM (DRV_DSP_UART_TO_MEM + DRV_DSP_UART_TO_MEM_SIZE)
+#define HIFI_ICC_DEBUG_LOCATION (DRV_DSP_STACK_TO_MEM + DRV_DSP_STACK_TO_MEM_SIZE)
+#define HIFI_FLAG_DATA_ADDR (HIFI_ICC_DEBUG_LOCATION + HIFI_ICC_DEBUG_SIZE)
+#define HIFI_SEC_HEAD_BACKUP (HIFI_FLAG_DATA_ADDR + HIFI_FLAG_DATA_SIZE)
+#define HIFI_AP_NV_DATA_ADDR (HIFI_SEC_HEAD_BACKUP + HIFI_SEC_HEAD_SIZE)
+#define HIFI_AP_MAILBOX_BASE_ADDR (HIFI_AP_NV_DATA_ADDR + HIFI_AP_NV_DATA_SIZE)
+#define CODEC_DSP_OM_DMA_BUFFER_ADDR (HIFI_AP_MAILBOX_BASE_ADDR + HIFI_AP_MAILBOX_TOTAL_SIZE)
+#define CODEC_DSP_OM_DMA_CONFIG_ADDR (CODEC_DSP_OM_DMA_BUFFER_ADDR + CODEC_DSP_OM_DMA_BUFFER_SIZE)
+#define CODEC_DSP_SOUNDTRIGGER_BASE_ADDR (CODEC_DSP_OM_DMA_CONFIG_ADDR + CODEC_DSP_OM_DMA_CONFIG_SIZE)
+#define HIFI_PCM_UPLOAD_BUFFER_ADDR (CODEC_DSP_SOUNDTRIGGER_BASE_ADDR + CODEC_DSP_SOUNDTRIGGER_TOTAL_SIZE)
+#define HIFI_HIKEY_SHARE_MEM_ADDR (HIFI_PCM_UPLOAD_BUFFER_ADDR+HIFI_AP_MAILBOX_TOTAL_SIZE)
+#define HIFI_UNSEC_RESERVE_ADDR (HIFI_HIKEY_SHARE_MEM_ADDR + HIFI_HIKEY_SHARE_SIZE)
+
+#define DRV_DSP_PANIC_MARK (HIFI_FLAG_DATA_ADDR)
+#define DRV_DSP_UART_LOG_LEVEL (DRV_DSP_PANIC_MARK + 4)
+#define DRV_DSP_UART_TO_MEM_CUR_ADDR (DRV_DSP_UART_LOG_LEVEL + 4)
+
+#define HIFI_SEC_REGION_SIZE (0x980000)
+#define HIFI_IMAGE_OCRAMBAK_SIZE (0x30000)
+#define HIFI_RUN_SIZE (0x600000)
+#define HIFI_IMAGE_TCMBAK_SIZE (0x34000)
+#define HIFI_IMAGE_SIZE (0x31C000)
+#define HIFI_RUN_ITCM_BASE (0xe8080000)
+#define HIFI_RUN_ITCM_SIZE (0x9000)
+#define HIFI_RUN_DTCM_BASE (0xe8058000)
+#define HIFI_RUN_DTCM_SIZE (0x28000)
+
+
+#define HIFI_SEC_REGION_ADDR (0x89200000) /* chciago */
+#define HIFI_RUN_LOCATION (HIFI_SEC_REGION_ADDR)
+#define HIFI_IMAGE_OCRAMBAK_LOCATION (HIFI_RUN_LOCATION + HIFI_RUN_SIZE)
+#define HIFI_IMAGE_TCMBAK_LOCATION (HIFI_IMAGE_OCRAMBAK_LOCATION + HIFI_IMAGE_OCRAMBAK_SIZE)
+#define HIFI_IMAGE_LOCATION (HIFI_IMAGE_TCMBAK_LOCATION + HIFI_IMAGE_TCMBAK_SIZE)
+
+#endif
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_pcm_gain.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_pcm_gain.h
new file mode 100644
index 00000000..24f94ec1
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_pcm_gain.h
@@ -0,0 +1,37 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 DSP_PCM_GAIN_H
+#define __DSP_PCM_GAIN_H__
+#include "dsp_memory_config.h"
+#define FRAME_SIZE 480 // 10 ms @ 48 KHz.
+#define HOLD_BUF_SIZE 228404
+#define MSG_RECV 1 // Msg received
+#define MSG_PROC 2 // Msg processed.
+#define MSG_COMP 8
+#define MSG_INCOMP 9
+#define MUSIC_DATA_MEM_READ_ADDR HIFI_MUSIC_DATA_LOCATION // Address of the Music data memory.. !!! change this if necessary..
+#define PCM_DATA_MEM_WRITE_ADDR PCM_PLAY_BUFF_LOCATION // Address of some random element in PCM data memory.. !!! change this if necessary..
+int ReadData( char *pDst, int Size );
+int WriteData( char *pSrc, int Size );
+int processAudio( int *pDst, int *pSrc, int Size );
+#endif
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/reset.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/reset.h
new file mode 100644
index 00000000..5a77a97d
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/reset.h
@@ -0,0 +1,62 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+
+#include <xtensa/coreasm.h>
+#include <xtensa/simcall.h>
+#define PIF_CACHED 1
+#define PIF_BYPASS 2
+#define PIF_CACHED_WBA 4
+#define PIF_CACHED_WBNA 5
+#define PIF_INVALID 15
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif
+#endif
+
+
+
+/*set memory mapping attribute*/
+.macro set_access_mode am
+ rdtlb1 a4, a3
+ ritlb1 a5, a3
+ srli a4, a4, 4
+ slli a4, a4, 4
+ srli a5, a5, 4
+ slli a5, a5, 4
+ addi a4, a4, \am
+ addi a5, a5, \am
+ wdtlb a4, a3
+ witlb a5, a3
+.endm
+
+
+
+
+#ifdef __cplusplus
+ #if __cplusplus
+ }
+ #endif
+#endif
+
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/xf-board.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/xf-board.h
new file mode 100644
index 00000000..e42ab1b9
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/xf-board.h
@@ -0,0 +1,180 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * board-hikey/xf-board.h
+ *
+ * HiKey960-specific definitions
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-board.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Global constants definitions
+ ******************************************************************************/
+
+/* ...shared memory interface address */
+#define XF_CFG_SHMEM_ADDRESS(core) HIFI_HIKEY_SHARE_MEM_ADDR
+
+/* ...tracing buffer configuration (place at the end of memory) */
+#define XF_CFG_TRACE_START(core) 0x78000000
+#define XF_CFG_TRACE_END(core) 0x7FFFFFFF
+#if 1
+#define DSP_IPC_FROM_AP_INT_NO (3)
+#define DSP_SYS_IPC_BASE_ADDR_NS (0xe896b000)
+#define DSP_AP_TO_DSP_MAILBOX_NO (18)
+#define DSP_DSP_TO_AP_MAILBOX_NO (2)
+#define IPC_BUSY_RETRY_COUNT (1000)
+#define IPC_ACPU_INT_SRC_HIFI_MSG (1)
+#define BIT_MASK(n) (1 << (n))
+
+#define WORD_REF(address) (* ((unsigned int volatile *) (address)))
+
+#define SYS_IPC_LOCK(base) WORD_REF(base + 0xA00)
+#define SYS_IPC_ICLR(base, box) WORD_REF(base + ((box) << 6) + 0x18)
+#define SYS_IPC_DATA(base, box, num) WORD_REF(base + ((box) << 6) + 0x20 + ((num) << 2))
+#define SYS_IPC_CPUIRST(base, core) WORD_REF(base + 0x804 + ((core) << 3))
+#define SYS_IPC_MODE(base, box) WORD_REF(base + ((box) << 6) + 0x10)
+#define SYS_IPC_SOURCE(base, box) WORD_REF(base + ((box) << 6))
+#define SYS_IPC_DEST(base, box) WORD_REF(base + ((box) * 64) + 0x04)
+#define SYS_IPC_SEND(base, box) WORD_REF(base + ((box) << 6) + 0x1c)
+#define SYS_IPC_IMASK(base, box) WORD_REF(base + ((box) << 6) + 0x14)
+#define SYS_IPC_DCLR(base, box) WORD_REF(base + ((box) * 64) + 0x08)
+#define SYS_IPC_CPUIMST(base, core) WORD_REF(base + 0x800 + ((core) * 8))
+#define SYS_IPC_MODE_ACK (7)
+#define SYS_IPC_MODE_IDLE (4)
+#define SYS_IPC_MODE_AUTOACK (0)
+
+#define SYS_IPC_CORE_HIFI (4)
+#define SYS_IPC_CORE_A15 (0)
+#define SYS_IPC_CORE_LPM3 (3)
+#endif
+/* ...inter-processor interrupt number (SEL:10 - LEVEL:15) */
+#define XF_PROXY_IPI_NUM(core) 15
+
+/*******************************************************************************
+ * External functions
+ ******************************************************************************/
+
+/* ...gdb stub initialization */
+extern void init_gdbstub(void);
+
+/* ...emit breakpoint */
+extern void breakpoint(void);
+#if 0// def HIKEY_XAF_IPC_COMMENT_OUT
+/*******************************************************************************
+ * Public proxy API
+ ******************************************************************************/
+
+/* ...notify remote side about status change */
+#define XF_PROXY_NOTIFY_PEER(core) h2_wake_core()
+
+/* ...clear pending interrupt mask */
+#define XF_PROXY_SYNC_PEER(core) h2_local_ack()
+
+/*******************************************************************************
+ * Auxiliary helper functions
+ ******************************************************************************/
+
+/* ...generate inter-processor interrupt for remote core */
+static inline void h2_wake_core(void)
+{
+ /* ...we have single INPUT-interrupt pin */
+ *(volatile unsigned int *)0xec800044 = 1;
+}
+
+/* ...acknowledge pending IPI interrupt */
+static inline void h2_local_ack(void)
+{
+ /* ...asserted interrupt cannot be cleared */
+}
+
+/*******************************************************************************
+ * Board specific init
+ ******************************************************************************/
+
+static inline void xf_board_init(void)
+{
+ /* ...initialize GDB debugging interface */
+ init_gdbstub();
+
+ /* ...indicate the board has started */
+ *(volatile unsigned int *)0xec800100 = 1;
+}
+#else
+//#define XF_PROXY_NOTIFY_PEER(core) dsp_ipc_send_irq_to_ap()
+#define XF_PROXY_NOTIFY_PEER(core) h2_wake_core()
+/* ...clear pending interrupt mask */
+#define XF_PROXY_SYNC_PEER(core) h2_local_ack()
+
+/* ...generate inter-processor interrupt for remote core */
+static inline void h2_wake_core(void)
+{
+ unsigned int mode = 0;
+ unsigned int mode_1 = 0;
+
+ // mode = SYS_IPC_MODE(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO);
+ //mode = (* ((unsigned int volatile *) (0xe896b000 + ((2) << 6) + 0x10)));
+ mode = * (volatile unsigned int*) 0xe896b090;
+
+ //if (mode & BIT_MASK(SYS_IPC_MODE_IDLE)) {
+ //if (mode & (1 << (4))) {
+ if (mode & 0x10) {
+ mode_1=0;
+ } else {
+ return;
+ }
+
+ //SYS_IPC_SOURCE(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = BIT_MASK(SYS_IPC_CORE_HIFI);
+ //(* ((unsigned int volatile *) (0xe896b000 + ((2) << 6))))= (1 << (4));
+ * (volatile unsigned int *) 0xe896b080 = (0x10);
+
+ //SYS_IPC_IMASK(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = ~((unsigned int)(BIT_MASK(SYS_IPC_CORE_HIFI)|BIT_MASK(SYS_IPC_CORE_A15)));
+ //(* ((unsigned int volatile *) (0xe896b000 + ((2) << 6) + 0x14))) = ~ ((unsigned int)((1 << (4))|(1 << (0))));
+ * (volatile unsigned int *)0xe896b094 = ~ ((unsigned int)(0x11));
+
+ //SYS_IPC_DATA(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO, 0) = IPC_ACPU_INT_SRC_HIFI_MSG;
+ //(* ((unsigned int volatile *) (0xe896b000 + ((2) << 6) + 0x20 + ((0) << 2)))) = 1;
+ * (volatile unsigned int *) 0xe896b0A0 = 1;
+
+ //SYS_IPC_MODE(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = BIT_MASK(SYS_IPC_MODE_AUTOACK);
+ //(* ((unsigned int volatile *) (0xe896b000 + ((2) << 6) + 0x10))) = (1 << (0));
+ * (volatile unsigned int *) 0xe896b090 = 1;
+
+ //SYS_IPC_SEND(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = BIT_MASK(SYS_IPC_CORE_HIFI);
+ //(* ((unsigned int volatile *) (0xe896b000 + ((2) << 6) + 0x1c))) = (1 << (4));
+ * (volatile unsigned int *) 0xe896b09C = 0x10;
+
+ return;
+}
+
+/* ...acknowledge pending IPI interrupt */
+static inline void h2_local_ack(void)
+{
+ /* ...asserted interrupt cannot be cleared */
+}
+
+#endif
+
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-config.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-config.h
new file mode 100644
index 00000000..4775e807
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-config.h
@@ -0,0 +1,63 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-config.h
+ *
+ * Xtensa target configuration parameters
+ *
+ *******************************************************************************/
+
+/* ...number of DSP cores */
+#define XF_CFG_CORES_NUM 1
+
+/* ...size of the internal message pool (make it equal to at least ring-buffer) */
+#define XF_CFG_MESSAGE_POOL_SIZE 256
+
+/* ...local IPC is coherent (say) */
+#define XF_LOCAL_IPC_NON_COHERENT 0
+
+/* ...remote IPC is non coherent (say) */
+#define XF_REMOTE_IPC_NON_COHERENT 1
+
+/* ...size of the local memory pool (in bytes) */
+#define XF_CFG_LOCAL_POOL_SIZE (1024 << 10)
+
+/* ...size of the shared memory pool (in bytes) */
+#if 1//def XAF_ENABLE_NON_HIKEY
+#define XF_CFG_REMOTE_IPC_POOL_SIZE (256 << 10)
+#else
+#define XF_CFG_REMOTE_IPC_POOL_SIZE (HIFI_MUSIC_DATA_SIZE)
+#endif
+
+/* ...size of the local memory pool (in bytes) */
+#define XF_CFG_LOCAL_IPC_POOL_SIZE (1024 << 10)
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...maximal size of scratch memory is 80 KB */
+#define XF_CFG_CODEC_SCRATCHMEM_SIZE (80 << 10)
+#else
+/* ...maximal size of scratch memory is 56 KB */
+#define XF_CFG_CODEC_SCRATCHMEM_SIZE (56 << 10)
+#endif
+
+/* ...scratch memory is 8-bytes aligned */
+#define XF_CFG_CODEC_SCRATCHMEM_ALIGN 8
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-hal.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-hal.h
new file mode 100644
index 00000000..82cf3c11
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-hal.h
@@ -0,0 +1,151 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-hal.h
+ *
+ * Platform-specific HAL definitions
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-hal.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/* ...primitive types */
+#include "xf-types.h"
+
+/* ...XTOS runtime */
+#include <xtensa/xtruntime.h>
+
+/*******************************************************************************
+ * Auxilliary macros definitions
+ ******************************************************************************/
+
+/* ...use system-specific cache-line size */
+#define XF_PROXY_ALIGNMENT XCHAL_DCACHE_LINESIZE
+
+/* ...properly aligned shared memory structure */
+#define __xf_shmem__ __attribute__((__aligned__(XF_PROXY_ALIGNMENT)))
+
+/*******************************************************************************
+ * Interrupt control
+ ******************************************************************************/
+
+/* ...disable interrupts on given core */
+static inline u32 xf_isr_disable(u32 core)
+{
+ /* ...no actual dependency on the core identifier */
+ return XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL);
+}
+
+/* ...enable interrupts on given core */
+static inline void xf_isr_restore(u32 core, u32 status)
+{
+ /* ...no actual dependency on the core identifier */
+ XTOS_RESTORE_INTLEVEL(status);
+}
+
+/*******************************************************************************
+ * Auxiliary system-specific functions
+ ******************************************************************************/
+
+#if XF_CFG_CORES_NUM > 1
+/* ...current core identifier (from HW) */
+static inline u32 xf_core_id(void)
+{
+ /* ...retrieve core identifier from HAL */
+ return (u32) xthal_get_prid();
+}
+#else
+#define xf_core_id() 0
+#endif
+
+/*******************************************************************************
+ * Atomic operations (atomicity is assured on local core only)
+ ******************************************************************************/
+
+static inline int xf_atomic_test_and_set(volatile u32 *bitmap, u32 mask)
+{
+ u32 status;
+ u32 v;
+
+ /* ...atomicity is assured by interrupts masking */
+ status = XTOS_DISABLE_ALL_INTERRUPTS;
+ v = *bitmap, *bitmap = v | mask;
+ XTOS_RESTORE_INTLEVEL(status);
+
+ return !(v & mask);
+}
+
+static inline int xf_atomic_test_and_clear(volatile u32 *bitmap, u32 mask)
+{
+ u32 status;
+ u32 v;
+
+ /* ...atomicity is assured by interrupts masking */
+ status = XTOS_DISABLE_ALL_INTERRUPTS;
+ v = *bitmap, *bitmap = v & ~mask;
+ XTOS_RESTORE_INTLEVEL(status);
+
+ return (v & mask);
+}
+
+static inline u32 xf_atomic_set(volatile u32 *bitmap, u32 mask)
+{
+ u32 status;
+ u32 v;
+
+ /* ...atomicity is assured by interrupts masking */
+ status = XTOS_DISABLE_ALL_INTERRUPTS;
+ v = *bitmap, *bitmap = (v |= mask);
+ XTOS_RESTORE_INTLEVEL(status);
+
+ return v;
+}
+
+static inline u32 xf_atomic_clear(volatile u32 *bitmap, u32 mask)
+{
+ u32 status;
+ u32 v;
+
+ /* ...atomicity is assured by interrupts masking */
+ status = XTOS_DISABLE_ALL_INTERRUPTS;
+ v = *bitmap, *bitmap = (v &= ~mask);
+ XTOS_RESTORE_INTLEVEL(status);
+
+ return v;
+}
+
+/*******************************************************************************
+ * Abortion macro (debugger should be configured)
+ ******************************************************************************/
+
+/* ...breakpoint function */
+extern void breakpoint(void);
+
+/* ...abort execution (enter into debugger) */
+#define __xf_abort() breakpoint()
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-ipc.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-ipc.h
new file mode 100644
index 00000000..3ce5bd66
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-ipc.h
@@ -0,0 +1,345 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-ipc.h
+ *
+ * Xtensa IPC mechanism
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-ipc.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/* ...system-specific shared memory configuration */
+#include "xf-shmem.h"
+#ifndef XAF_ENABLE_NON_HIKEY
+#include <xtensa/xtruntime.h>
+extern volatile int waitstate;
+#endif
+
+#ifdef XAF_ENABLE_NON_HIKEY
+/*******************************************************************************
+ * Macros definitions (should better go to some other header)
+ ******************************************************************************/
+
+/*
+ * Execute WAITI 0 (enabling interrupts) only if *(ptr) is zero.
+ * The decision to execute WAITI is done atomically by disabling
+ * interrupts at level 'level' (level must be a constant)
+ * before checking the pointer. Interrupts are always re-enabled
+ * on exit from this macro.
+ */
+#define _WAITI_ON_PTR(ptr, level) \
+do { \
+ int __tmp; \
+ __asm__ (" rsil %0, " #level " \n" \
+ " l32i %0, %1, 0 \n" \
+ " bnez %0, 1f \n" \
+ " waiti 0 \n" \
+ "1:rsil %0, 0 \n" \
+ : "=a" (__tmp) : "a" (ptr) : "memory"); \
+} while(0)
+
+/* ...enable gdbstub */
+//#define XF_CFG_USE_GDBSTUB 0
+
+#ifndef XF_CFG_USE_GDBSTUB
+/* ...maybe "level" should be hidden here - we always magically set 15 */
+#define WAITI_ON_PTR(ptr, level) _WAITI_ON_PTR(ptr, level)
+#else
+/* ...if debugger is enabled, do polling instead of waiting */
+static inline void WAITI_ON_PTR(volatile u32 *ptr, u32 level)
+{
+ extern void poll_debug_ring(void);
+
+ while (*ptr == 0)
+ {
+ /* ...should be called with interrupts disabled - tbd */
+ poll_debug_ring();
+ }
+}
+#endif
+
+/*******************************************************************************
+ * Remote IPI interrupt mode
+ ******************************************************************************/
+
+/* ...enable/disable IPI interrupt */
+static inline void xf_ipi_enable(u32 core, int on)
+{
+ if (on)
+ _xtos_ints_on(1 << XF_PROXY_IPI_NUM(core));
+ else
+ _xtos_ints_off(1 << XF_PROXY_IPI_NUM(core));
+}
+
+/* ...wait in low-power mode for interrupt arrival if "ptr" is 0 */
+static inline void xf_ipi_wait(u32 core)
+{
+ xf_core_ro_data_t *ro = XF_CORE_RO_DATA(core);
+
+ /* ...enable IPI interrupt before sleeping */
+ xf_ipi_enable(core, 1);
+
+ /* ...wait in low-power mode, atomically checking *ipc != 0 */
+ WAITI_ON_PTR(&ro->ipc.wait, 15);
+
+ /* ...force disabling of IPI interrupts */
+ xf_ipi_enable(core, 0);
+
+ /* ...reset waiting object upon leaving */
+ ro->ipc.wait = 0;
+}
+#else
+#define _WAITI_ON_PTR(ptr, level) \
+ do { \
+ int __tmp; \
+ __asm__ (" rsil %0, " #level " \n" \
+ " l32i %0, %1, 0 \n" \
+ " bnez %0, 1f \n" \
+ " waiti 0 \n" \
+ "1:rsil %0, 0 \n" \
+ : "=a" (__tmp) : "a" (ptr) : "memory"); \
+ } while(0)
+
+#define WAITI_ON_PTR(ptr, level) _WAITI_ON_PTR(ptr, level)
+static inline void xf_ipi_wait(u32 core)
+{
+#if 0
+ // VOS_EnableInterrupt(DSP_IPC_FROM_AP_INT_NO);
+ _xtos_ints_on(1 << DSP_IPC_FROM_AP_INT_NO);
+ while(1)
+ {
+ if(waitstate ==1)
+ {
+ // VOS_DisableInterrupt(DSP_IPC_FROM_AP_INT_NO);
+ _xtos_ints_off(1 << DSP_IPC_FROM_AP_INT_NO);
+ waitstate = 0;
+ break;
+ }
+ }
+#else
+
+ _xtos_ints_on(1 << DSP_IPC_FROM_AP_INT_NO);
+ /* ...wait in low-power mode, atomically checking *ipc != 0 */
+ WAITI_ON_PTR(&waitstate, 15);
+
+ /* ...force disabling of IPI interrupts */
+
+ _xtos_ints_off(1 << DSP_IPC_FROM_AP_INT_NO);
+ /* ...reset waiting object upon leaving */
+ waitstate = 0;
+
+#endif
+}
+#endif
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...complete IPI waiting (may be called from any context on local core) */
+static inline void xf_ipi_resume(u32 core)
+{
+ xf_core_ro_data_t *ro = XF_CORE_RO_DATA(core);
+
+ /* ...single instruction is written atomically; no need to mask interrupts */
+ ro->ipc.wait = 1;
+}
+#else
+/* ...complete IPI waiting (may be called from any context on local core) */
+static inline void xf_ipi_resume(u32 core)
+{
+ unsigned int ipc_int_state = 0;
+ unsigned int ipc_data = 0;
+
+ _xtos_ints_off(1 << DSP_IPC_FROM_AP_INT_NO);
+
+ //process message
+ ipc_int_state = SYS_IPC_CPUIRST(DSP_SYS_IPC_BASE_ADDR_NS, SYS_IPC_CORE_HIFI);
+
+ if (ipc_int_state & BIT_MASK(DSP_AP_TO_DSP_MAILBOX_NO)) { //mailbox-18
+ SYS_IPC_ICLR(DSP_SYS_IPC_BASE_ADDR_NS, DSP_AP_TO_DSP_MAILBOX_NO) = BIT_MASK(SYS_IPC_CORE_HIFI);
+ waitstate = 1;
+ }
+
+ //_xtos_ints_on(1 << DSP_IPC_FROM_AP_INT_NO);
+
+ return;
+}
+#endif
+#if 0//ndef HIKEY_XAF_IPC_COMMENT_OUT
+/* ...notify remote side about status change */
+//#define XF_PROXY_NOTIFY_PEER(core) dsp_ipc_send_irq_to_ap()
+
+static inline void dsp_ipc_send_irq_to_ap(void)
+{
+ unsigned int mode = 0;
+ unsigned int mode_1 = 0;
+
+ mode = SYS_IPC_MODE(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO);
+
+ if (mode & BIT_MASK(SYS_IPC_MODE_IDLE)) {
+ mode_1=0;
+ } else {
+ return;
+ }
+
+
+ SYS_IPC_SOURCE(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = BIT_MASK(SYS_IPC_CORE_HIFI);
+ SYS_IPC_IMASK(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = ~((unsigned int)(BIT_MASK(SYS_IPC_CORE_HIFI)|BIT_MASK(SYS_IPC_CORE_A15)));
+ SYS_IPC_DATA(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO, 0) = IPC_ACPU_INT_SRC_HIFI_MSG;
+ SYS_IPC_MODE(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = BIT_MASK(SYS_IPC_MODE_AUTOACK);
+ SYS_IPC_SEND(DSP_SYS_IPC_BASE_ADDR_NS, DSP_DSP_TO_AP_MAILBOX_NO) = BIT_MASK(SYS_IPC_CORE_HIFI);
+
+ return;
+}
+#endif
+/* ...assert IPI interrupt on remote core - board-specific */
+static inline void xf_ipi_assert(u32 core)
+{
+ XF_PROXY_NOTIFY_PEER(core);
+}
+
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...initialize IPI subsystem */
+static inline int xf_ipi_init(u32 core)
+{
+ xf_core_ro_data_t *ro = XF_CORE_RO_DATA(core);
+ extern void (* const xf_ipi_handlers[])(void);
+
+ /* ...reset IPC data - no interrupt yet */
+ ro->ipc.wait = 0;
+
+ /* ...install interrupt handler */
+ _xtos_set_interrupt_handler(XF_PROXY_IPI_NUM(core), xf_ipi_handlers[core]);
+
+ return 0;
+}
+#else
+/* ...initialize IPI subsystem */
+static inline int xf_ipi_init(u32 core)
+{
+
+ waitstate =0;
+
+ dsp_debug_init();
+ //dsp_init_share_mem(HIKEY_AP2DSP_MSG_QUEUE_ADDR,HIKEY_DSP2AP_MSG_QUEUE_SIZE);
+ /* unlock reg */
+ SYS_IPC_LOCK(DSP_SYS_IPC_BASE_ADDR_NS) = 0x1ACCE551;
+ //VOS_ConnectInterrupt(DSP_IPC_FROM_AP_INT_NO, _ap_to_dsp_ipc_irq_proc);
+ VOS_ConnectInterrupt(DSP_IPC_FROM_AP_INT_NO, xf_ipi_resume);
+
+// VOS_EnableInterrupt(DSP_IPC_FROM_AP_INT_NO);
+
+ return;
+}
+#endif
+
+/*******************************************************************************
+ * Shared memory operations
+ ******************************************************************************/
+
+/* ...NULL-address specification */
+#define XF_PROXY_NULL (~0U)
+
+/* ...invalid proxy address */
+#define XF_PROXY_BADADDR XF_CFG_REMOTE_IPC_POOL_SIZE
+/* ...translate buffer address to shared proxy address */
+static inline u32 xf_ipc_b2a(u32 core, void *b)
+{
+ xf_shmem_data_t *shmem = XF_CORE_DATA(core)->shmem;
+ void *start = shmem->buffer;
+
+ if (b == NULL)
+ return XF_PROXY_NULL;
+ else if ((s32)(b - start) < XF_CFG_REMOTE_IPC_POOL_SIZE)
+ return (u32)(b - start);
+ else
+ return XF_PROXY_BADADDR;
+}
+/* ...translate shared proxy address to local pointer */
+static inline void * xf_ipc_a2b(u32 core, u32 address)
+{
+ xf_shmem_data_t *shmem = XF_CORE_DATA(core)->shmem;
+ void *start = shmem->buffer;
+
+ if (address < XF_CFG_REMOTE_IPC_POOL_SIZE)
+ return start + address;
+ else if (address == XF_PROXY_NULL)
+ return NULL;
+ else
+ return (void *)-1;
+}
+
+/* ...component association with remote IPC client */
+static inline void xf_ipc_component_addref(u32 session)
+{
+}
+
+/* ...delete record about component association with remote IPC client */
+static inline void xf_ipc_component_rmref(u32 id)
+{
+}
+
+/* ...system-specific IPC layer initialization */
+extern int xf_ipc_init(u32 core);
+
+/*******************************************************************************
+ * Mutex definitions
+ ******************************************************************************/
+
+/* ...export shared memory access macros */
+#define MUTEX_SHARED_READ(core) \
+ ({ xf_core_ro_data_t *__ro = XF_CORE_RO_DATA(core); __ro->lock[0]; })
+
+#define MUTEX_SHARED_WRITE(core, val) \
+ ({ xf_core_ro_data_t *__ro = XF_CORE_RO_DATA(core); __ro->lock[0] = (val); })
+
+/* ...include library header */
+#include "lib/mutex.h"
+
+#if XF_CFG_CORES_NUM > 1
+/* ...rename API functions */
+static inline void xf_mutex_lock(u32 core)
+{
+ mutex_lock(core);
+}
+
+static inline void xf_mutex_unlock(u32 core)
+{
+ mutex_unlock(core);
+}
+
+#else
+/* ...for single-core setting no locking is actually needed */
+static inline void xf_mutex_lock(u32 core)
+{
+}
+
+static inline void xf_mutex_unlock(u32 core)
+{
+}
+
+#endif /* XF_CFG_CORES_NUM > 1 */
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-mem.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-mem.h
new file mode 100644
index 00000000..dc277871
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-mem.h
@@ -0,0 +1,180 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-mem.h
+ *
+ * System-specific memory allocator
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-mem.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * System specific memory pools
+ ******************************************************************************/
+
+#if XF_CFG_CORES_NUM > 1
+/* ...shared memory pool for communication within DSP-cluster */
+extern xf_mm_pool_t xf_dsp_shmem_pool;
+#endif
+
+/*******************************************************************************
+ * Platform-specific SHMEM allocation registering functions
+ ******************************************************************************/
+
+/* ...register shmem allocation address */
+static inline void xf_shmem_alloc_addref(u32 core, xf_message_t *m)
+{
+}
+
+/* ...unregister shmem allocation address */
+static inline void xf_shmem_alloc_rmref(u32 core, xf_message_t *m)
+{
+}
+
+/*******************************************************************************
+ * API functions
+ ******************************************************************************/
+
+/* ...allocate aligned memory on particular core specifying if it is shared */
+static inline void * xf_mem_alloc(u32 size, u32 align, u32 core, u32 shared)
+{
+#if XF_CFG_CORES_NUM > 1
+ if (shared)
+ {
+ /* ...if memory is shared, core is dropped */
+ return xf_mm_alloc(&xf_dsp_shmem_pool, size);
+ }
+#endif
+
+ /* ...select local memory pool basing on core specification */
+ return xf_mm_alloc(&XF_CORE_DATA(core)->local_pool, size);
+}
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...redefine macro to add bugchecks */
+#define xf_mem_alloc(size, align, core, shared) \
+({ \
+ void *__data; \
+ /* ...size must be properly aligned */ \
+ BUG(!XF_MM_ALIGNED(size), _x("Bad size: %u"), size); \
+ __data = (xf_mem_alloc)(size, align, core, shared); \
+ TRACE(1, _b("alloc-%u: %p[%u] (shared=%u)"), core, __data, size, shared); \
+ __data; \
+})
+#endif
+/* ...release allocated memory */
+static inline void xf_mem_free(void *p, u32 size, u32 core, u32 shared)
+{
+#if XF_CFG_CORES_NUM > 1
+ if (shared)
+ {
+ /* ...if memory is shared, core is dropped */
+ xf_mm_free(&xf_dsp_shmem_pool, p, size);
+ return;
+ }
+#endif
+
+ /* ...select proper pool basing on core specification */
+ xf_mm_free(&XF_CORE_DATA(core)->local_pool, p, size);
+}
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...redefine macro to add bugchecks */
+#define xf_mem_free(p, size, core, shared) \
+({ \
+ void *__data = (p); \
+ /* ...size must be properly aligned */ \
+ BUG(!XF_MM_ALIGNED(size), _x("Bad size: %u"), size); \
+ TRACE(1, _b("free-%u: %p[%u] (shared=%u)"), core, __data, size, shared); \
+ (xf_mem_free)(__data, size, core, shared); \
+})
+#endif
+/* ...allocate AP-DSP shared memory */
+static inline int xf_shmem_alloc(u32 core, xf_message_t *m)
+{
+ xf_mm_pool_t *pool = &XF_CORE_DATA(core)->shared_pool;
+
+ /* ...length is always cache-line aligned */
+ if ((m->buffer = xf_mm_alloc(pool, XF_ALIGNED(m->length))) != NULL)
+ {
+ /* ...register allocation address */
+ xf_shmem_alloc_addref(core, m);
+
+ return 0;
+ }
+ else
+ {
+ return -ENOMEM;
+ }
+}
+
+/* ...free AP-DSP shared memory */
+static inline void xf_shmem_free(u32 core, xf_message_t *m)
+{
+ xf_mm_pool_t *pool = &XF_CORE_DATA(core)->shared_pool;
+
+ /* ...length is always cache-line aligned */
+ xf_mm_free(pool, m->buffer, XF_ALIGNED(m->length));
+
+ /* ...unregister allocation address */
+ xf_shmem_alloc_rmref(core, m);
+}
+
+/*******************************************************************************
+ * Scratch memory management
+ ******************************************************************************/
+
+static inline void * xf_scratch_mem_init(u32 core)
+{
+ /* ...allocate scratch memory from local DSP memory */
+ return xf_mem_alloc(XF_CFG_CODEC_SCRATCHMEM_SIZE, XF_CFG_CODEC_SCRATCHMEM_ALIGN, core, 0);
+}
+
+/*******************************************************************************
+ * Helpers - hmm; they are platform-independent - tbd
+ ******************************************************************************/
+
+/* ...allocate local buffer */
+static inline int xf_mm_alloc_buffer(u32 size, u32 align, u32 core, xf_mm_buffer_t *b)
+{
+ /* ...allocate memory from proper local pool */
+ if ((size = XF_MM(size)) != 0)
+ XF_CHK_ERR(b->addr = xf_mem_alloc(size, align, core, 0), -ENOMEM);
+ else
+ b->addr = NULL;
+
+ /* ...save address */
+ b->size = size;
+
+ return 0;
+}
+
+/* ...free local buffer */
+static inline void xf_mm_free_buffer(xf_mm_buffer_t *b, u32 core)
+{
+ if (b->addr)
+ {
+ xf_mem_free(b->addr, b->size, core, 0);
+ }
+}
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-runtime.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-runtime.h
new file mode 100644
index 00000000..ab328ccf
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-runtime.h
@@ -0,0 +1,81 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-runtime.h
+ *
+ * Platform-specific runtime data definitions
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-runtime.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/* ...platform HAL layer */
+#include "xf-hal.h"
+
+/*******************************************************************************
+ * Mutex (opaque) data definition
+ ******************************************************************************/
+
+typedef volatile u32 xf_mutex_t[XF_CFG_CORES_NUM > 1 ? 1 : 0];
+
+/*******************************************************************************
+ * Local/remote/ISR IPC (opaque) data
+ ******************************************************************************/
+
+typedef struct xf_ipc_handle
+{
+ /* ...variable we are waiting on */
+ u32 wait;
+
+} xf_ipc_handle_t;
+
+/*******************************************************************************
+ * IPC events
+ ******************************************************************************/
+
+/* ...core resumption flag */
+#define XF_IPC_EVENT_CORE_ASSERT (1 << 0)
+
+/* ...core waiting flag */
+#define XF_IPC_EVENT_CORE_WAIT (1 << 1)
+
+/* ...shared memory assertion flag */
+#define XF_IPC_EVENT_SHMEM_ASSERT (1 << 2)
+
+/* ...shared memory waiting flag */
+#define XF_IPC_EVENT_SHMEM_WAIT (1 << 3)
+
+/* ...disabled interrupts status */
+#define XF_IPC_EVENT_ISR_OFF (1 << 4)
+
+/*******************************************************************************
+ * Shared memory interface (opaque) data
+ ******************************************************************************/
+
+typedef void * xf_shmem_handle_t;
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-shmem.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-shmem.h
new file mode 100644
index 00000000..813bfb48
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-shmem.h
@@ -0,0 +1,173 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-shmem.h
+ *
+ * Definitions for Xtensa SHMEM configuration
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-shmem.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Memory structures
+ ******************************************************************************/
+
+/* ...data managed by host CPU (remote) - in case of shunt it is a IPC layer */
+struct xf_proxy_host_data
+{
+ /* ...command queue */
+ xf_proxy_message_t command[XF_PROXY_MESSAGE_QUEUE_LENGTH];
+
+ /* ...writing index into command queue */
+ u32 cmd_write_idx;
+
+ /* ...reading index for response queue */
+ u32 rsp_read_idx;
+#ifdef XAF_ENABLE_NON_HIKEY
+} __attribute__((__packed__, __aligned__(XF_PROXY_ALIGNMENT)));
+#else
+}/* __attribute__((__packed__, __aligned__(XF_PROXY_ALIGNMENT)))*/;
+#endif
+
+/* ...data managed by DSP (local) */
+struct xf_proxy_dsp_data
+{
+ /* ...response queue */
+ xf_proxy_message_t response[XF_PROXY_MESSAGE_QUEUE_LENGTH];
+
+ /* ...writing index into response queue */
+ u32 rsp_write_idx;
+
+ /* ...reading index for command queue */
+ u32 cmd_read_idx;
+#ifdef XAF_ENABLE_NON_HIKEY
+} __attribute__((__packed__, __aligned__(XF_PROXY_ALIGNMENT)));
+#else
+}/* __attribute__((__packed__, __aligned__(XF_PROXY_ALIGNMENT)))*/;
+#endif
+/* ...shared memory data */
+typedef struct xf_shmem_data
+{
+ /* ...outgoing data (maintained by host CPU (remote side)) */
+#ifdef XAF_ENABLE_NON_HIKEY
+ struct xf_proxy_host_data remote __xf_shmem__;
+
+ /* ...ingoing data (maintained by DSP (local side)) */
+ struct xf_proxy_dsp_data local __xf_shmem__;
+
+ /* ...shared memory pool (page-aligned; why? we map memory to user-space) */
+ u8 buffer[XF_CFG_REMOTE_IPC_POOL_SIZE] __attribute__((__aligned__(4096)));
+#else
+ /* ...outgoing data (maintained by host CPU (remote side)) */
+ struct xf_proxy_host_data remote/* __xf_shmem__*/;
+
+ /* ...ingoing data (maintained by DSP (local side)) */
+ struct xf_proxy_dsp_data local/* __xf_shmem__*/;
+
+ /* ...shared memory pool (page-aligned; why? we map memory to user-space) */
+ uint8_t* buffer;
+#endif
+
+} xf_shmem_data_t;
+
+/*******************************************************************************
+ * Shared memory accessors
+ ******************************************************************************/
+
+/* ...shared memory pointer for a core */
+#define XF_SHMEM_DATA(core) \
+ ((xf_shmem_data_t *)XF_CORE_DATA(core)->shmem)
+
+/* ...atomic reading */
+#define XF_PROXY_READ_ATOMIC(var) \
+ ({ XF_PROXY_INVALIDATE(&(var), sizeof(var)); (var); })
+
+/* ...atomic writing */
+#define XF_PROXY_WRITE_ATOMIC(var, value) \
+ ({(var) = (value); XF_PROXY_FLUSH(&(var), sizeof(var)); (value); })
+
+/* ...accessors */
+#define XF_PROXY_READ(core, field) \
+ __XF_PROXY_READ_##field(XF_SHMEM_DATA(core))
+
+#define XF_PROXY_WRITE(core, field, v) \
+ __XF_PROXY_WRITE_##field(XF_SHMEM_DATA(core), (v))
+
+/* ...individual fields accessors */
+#define __XF_PROXY_READ_cmd_write_idx(proxy) \
+ XF_PROXY_READ_ATOMIC(proxy->remote.cmd_write_idx)
+
+#define __XF_PROXY_READ_cmd_read_idx(proxy) \
+ proxy->local.cmd_read_idx
+
+#define __XF_PROXY_READ_rsp_write_idx(proxy) \
+ proxy->local.rsp_write_idx
+
+#define __XF_PROXY_READ_rsp_read_idx(proxy) \
+ XF_PROXY_READ_ATOMIC(proxy->remote.rsp_read_idx)
+
+/* ...individual fields accessors */
+#define __XF_PROXY_WRITE_cmd_write_idx(proxy, v) \
+ XF_PROXY_WRITE_ATOMIC(proxy->remote.cmd_write_idx, v)
+
+#define __XF_PROXY_WRITE_cmd_read_idx(proxy, v) \
+ XF_PROXY_WRITE_ATOMIC(proxy->local.cmd_read_idx, v)
+
+#define __XF_PROXY_WRITE_rsp_read_idx(proxy, v) \
+ XF_PROXY_WRITE_ATOMIC(proxy->remote.rsp_read_idx, v)
+
+#define __XF_PROXY_WRITE_rsp_write_idx(proxy, v) \
+ XF_PROXY_WRITE_ATOMIC(proxy->local.rsp_write_idx, v)
+
+/* ...command buffer accessor */
+#define XF_PROXY_COMMAND(core, idx) \
+ (&XF_SHMEM_DATA((core))->remote.command[(idx)])
+
+/* ...response buffer accessor */
+#define XF_PROXY_RESPONSE(core, idx) \
+ (&XF_SHMEM_DATA((core))->local.response[(idx)])
+
+/*******************************************************************************
+ * Platform-specific SHMEM enable status
+ ******************************************************************************/
+
+static inline int xf_shmem_enabled(u32 core)
+{
+ return (core == 0);
+}
+
+/*******************************************************************************
+ * API functions
+ ******************************************************************************/
+
+/* ...process shared memory interface on given DSP core */
+extern void xf_shmem_process_queues(u32 core);
+
+/* ...completion callback for message originating from remote proxy */
+extern void xf_msg_proxy_complete(xf_message_t *m);
+
+/* ...initialize shared memory interface (DSP side) */
+extern int xf_shmem_init(u32 core);
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-sys.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-sys.h
new file mode 100644
index 00000000..b82c10eb
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-sys.h
@@ -0,0 +1,75 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-sys.h
+ *
+ * Definitions for Xtensa SHMEM configuration
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-sys.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Standard system includes
+ ******************************************************************************/
+
+/* ...from directory ./board-BOARDNAME */
+#include "xf-board.h"
+
+/*******************************************************************************
+ * Global abstractions
+ ******************************************************************************/
+
+/* ...prevent instructions reordering */
+#define barrier() \
+ __asm__ __volatile__("": : : "memory")
+
+/* ...memory barrier */
+#define XF_PROXY_BARRIER() \
+ __asm__ __volatile__("memw": : : "memory")
+
+/* ...memory invalidation */
+#define XF_PROXY_INVALIDATE(buf, length) \
+ ({ if ((length)) { xthal_dcache_region_invalidate((buf), (length)); barrier(); } buf; })
+
+/* ...memory flushing */
+#define XF_PROXY_FLUSH(buf, length) \
+ ({ if ((length)) { barrier(); xthal_dcache_region_writeback((buf), (length)); XF_PROXY_BARRIER(); } buf; })
+
+/*******************************************************************************
+ * Core-specific data accessor
+ ******************************************************************************/
+
+/* ...per-core execution data */
+extern xf_core_data_t xf_core_data[XF_CFG_CORES_NUM];
+
+/* ...local memory accessor */
+#define XF_CORE_DATA(core) (&xf_core_data[core])
+
+/*******************************************************************************
+ * Inter-processor communication and shared memory interface definition
+ ******************************************************************************/
+
+#include "xf-ipc.h"
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-types.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-types.h
new file mode 100644
index 00000000..5f58825f
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/xf-types.h
@@ -0,0 +1,55 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-types.h
+ *
+ * Platform-specific typedefs
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-types.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+#include <xtensa/config/core.h>
+
+/*******************************************************************************
+ * Primitive types
+ ******************************************************************************/
+
+typedef unsigned int u32;
+typedef signed int s32;
+typedef unsigned short u16;
+typedef signed short s16;
+typedef unsigned char u8;
+typedef signed char s8;
diff --git a/hifi/xaf/hifi-dpf/include/xa_profiler.h b/hifi/xaf/hifi-dpf/include/xa_profiler.h
new file mode 100644
index 00000000..675ff15c
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xa_profiler.h
@@ -0,0 +1,156 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XA_PROFILER_H__
+#define __XA_PROFILER_H__
+
+#if !defined(PROFILE) && __XCC__
+#define PROFILE 1
+#endif
+
+#if !defined(PREFETCH_CTL) && __XCC__
+#define PREFETCH_CTL 1
+#endif
+
+#ifdef PROFILE
+#include <xtensa/hal.h>
+#include <sys/times.h>
+
+#include "xa_type_def.h"
+#include "xa_timer.h"
+
+TRACE_TAG(MCPS,1);
+
+typedef struct XA_PROFILER {
+#if 1
+ unsigned long cstart;
+ unsigned long cstop;
+ unsigned long cycles;
+ unsigned long g_output_bytes;
+ unsigned long Peak;
+ unsigned long Sum;
+
+ unsigned long sample_rate;
+ unsigned long channels;
+ unsigned long pcm_width;
+#else
+ struct tms start;
+ struct tms stop;
+ double Peak;
+ double Sum;
+ long long cycles;
+#endif
+ int Peak_frame;
+ int frame_count;
+ long long output_bytes;
+ long long total_cycles;
+ long long total_samples;
+ char *id;
+} xa_profiler;
+
+extern xa_profiler prof;
+
+static inline void xa_compute_mcps(xa_profiler *p_prof, WORD32 samples_decoded, UWORD32 samp_freq, long long gen_strm_pos)
+{
+ double Ave=0.0, Curr;
+
+ if (samples_decoded <= 0)
+ return;
+
+ p_prof->total_samples += samples_decoded;
+ p_prof->frame_count++;
+
+ clock_t cycles = p_prof->cycles;
+ p_prof->total_cycles = 0;
+ Curr = ((double) cycles / samples_decoded * samp_freq / 1000000);
+
+ if (p_prof->frame_count > 1) {
+ p_prof->Sum += Curr;
+ Ave = p_prof->Sum / (p_prof->frame_count-1);
+
+ if (p_prof->Peak < Curr) {
+ p_prof->Peak = Curr;
+ p_prof->Peak_frame = (p_prof->frame_count);
+ }
+ }
+
+ unsigned long long total_msec =
+ (unsigned long long)((double)p_prof->total_samples / samp_freq * 1000.0);
+ int msec = (int)(total_msec % 1000);
+ unsigned long long total_seconds = total_msec / 1000;
+ int seconds = (int)(total_seconds % 60);
+ int minutes = (int)(total_seconds / 60);
+
+#if 1
+ TRACE(MCPS, _b("[%d] %d:%d.%d MCPS: %d Average: %d samples: %d\n"),
+ p_prof->frame_count, (uint32_t)minutes, (uint32_t)seconds, (uint32_t)msec,
+ (uint32_t)Curr, (uint32_t)Ave, samples_decoded);
+#else
+ TRACE(MCPS, _b("[%d|%lld] %d:%02d.%03d MCPS: %.2f Average: %.2f Peak: %.2f @ [%d] %s\n"),
+ p_prof->frame_count, gen_strm_pos, minutes, seconds, msec,
+ Curr, Ave, p_prof->Peak, p_prof->Peak_frame, p_prof->id);
+#endif
+
+ /* reset counters */
+ p_prof->g_output_bytes = 0;
+ p_prof->cycles = 0;
+}
+
+#define INIT_XA_PROFILER(x, a) do { memset(&x, 0, sizeof(xa_profiler)); \
+ x.sample_rate = 48000;\
+ x.channels = 2;\
+ x.pcm_width = 16;\
+ x.id = a; } while(0)
+
+#define START_TIME_XA_PROFILER(x) do { set_ccount(0); \
+ x.cstart=read_ccount(); } while(0)
+#define STOP_TIME_XA_PROFILER(x) do { x.cstop =read_ccount(); \
+ x.cycles += (x.cstop - x.cstart); } while(0)
+#define COMPUTE_MHZ_XA_PROFILER(x, a, b, c) do { xa_compute_mcps(&x, a, b, c); } while(0)
+#define SUMMARY_XA_PROFILER(x) do { fprintf(stdout,"\n%5s Peak MCPS = %f\n", x.id, x.Peak); \
+ fprintf(stdout,"%5s Peak frame = %d\n", x.id, x.Peak_frame); \
+ fprintf(stdout,"%5s Average MCPS = %f\n", x.id, (x.frame_count < 2) ? 0 : (x.Sum/(x.frame_count-1))); } while(0)
+
+#else
+
+typedef struct XA_PROFILER {
+ int place_holder;
+} xa_profiler;
+
+#define INIT_XA_PROFILER(x, a) do {} while(0)
+#define START_TIME_XA_PROFILER(x) do {} while(0)
+#define STOP_TIME_XA_PROFILER(x) do {} while(0)
+#define COMPUTE_MHZ_XA_PROFILER(x, a, b) do {} while(0)
+#define SUMMARY_XA_PROFILER(x) do {} while(0)
+#endif
+
+#ifdef PREFETCH_CTL
+#define PREFETCH_AGGRESSIVE(x) do { x = xthal_set_cache_prefetch ((XTHAL_DCACHE_PREFETCH_HIGH | XTHAL_ICACHE_PREFETCH_HIGH)); \
+ } while(0)
+#define PREFETCH_RESTORE(x) do { xthal_set_cache_prefetch (x); } while(0)
+#else
+#define PREFETCH_AGGRESSIVE(x) do {} while(0)
+#define PREFETCH_RESTORE(x) do {} while(0)
+#endif
+
+#endif /* __XA_PROFILER_H__ */
+
diff --git a/hifi/xaf/hifi-dpf/include/xa_timer.h b/hifi/xaf/hifi-dpf/include/xa_timer.h
new file mode 100644
index 00000000..d45cb4b8
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xa_timer.h
@@ -0,0 +1,111 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+#include <xtensa/xtruntime.h>
+#include <xtensa/config/specreg.h>
+
+extern const unsigned char Xthal_have_ccount;
+extern const unsigned char Xthal_num_ccompare;
+extern void xthal_set_ccompare(int n, unsigned value);
+extern unsigned xthal_get_ccompare(int n);
+
+/*--------------------------------------------*/
+#include <xtensa/config/core.h>
+#define TIMER_INTERVAL 0x1000
+
+#define TIMER_INT_MASK (1 << XCHAL_TIMER0_INTERRUPT)
+#define TIMER2_INT_MASK (1 << XCHAL_TIMER1_INTERRUPT)
+#define TWO_TIMERS_INT_MASK ( TIMER_INT_MASK + TIMER2_INT_MASK )
+#define _XTSTR(x) # x
+#define XTSTR(x) _XTSTR(x)
+
+static __inline__ int read_ccount()
+{
+ unsigned int ccount;
+ __asm__ __volatile__ (
+ "rsr %0, "XTSTR(CCOUNT)
+ : "=a" (ccount)
+ );
+ return ccount;
+}
+
+static __inline__ int read_ccompare0()
+{
+ unsigned int ccompare0;
+ __asm__ __volatile__ (
+ "rsr %0, "XTSTR(CCOMPARE_0)
+ : "=a" (ccompare0)
+ );
+ return ccompare0;
+}
+
+static __inline__ int read_ccompare1()
+{
+ unsigned int ccompare1;
+ __asm__ __volatile__ (
+ "rsr %0, "XTSTR(CCOMPARE_1)
+ : "=a" (ccompare1)
+ );
+ return ccompare1;
+}
+
+static __inline__ unsigned int read_intenable()
+{
+ unsigned int intenable;
+ __asm__ __volatile__ (
+ "rsr %0, "XTSTR(INTENABLE)
+ : "=a" (intenable)
+ );
+ return intenable;
+}
+
+static __inline__ void set_ccompare1(int val)
+{
+ __asm__ __volatile__ (
+ "wsr %0, "XTSTR(CCOMPARE_1)"\n\t"
+ "isync\n\t"
+ :
+ : "a" (val)
+ );
+}
+
+static __inline__ void set_ccompare0(int val)
+{
+ __asm__ __volatile__ (
+ "wsr %0, "XTSTR(CCOMPARE_0)"\n\t"
+ "isync\n\t"
+ :
+ : "a" (val)
+ );
+}
+
+/*---------------------------------------------------*/
+
+static __inline__ void set_ccount(int val)
+{
+ __asm__ __volatile__ (
+ "wsr %0, ccount\n"
+ "isync\n"
+ :
+ : "a" (val)
+ );
+}
+
diff --git a/hifi/xaf/hifi-dpf/include/xf-component.h b/hifi/xaf/hifi-dpf/include/xf-component.h
new file mode 100644
index 00000000..f97f2e48
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-component.h
@@ -0,0 +1,91 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-component.h
+ *
+ * Xtensa processing framework component definition
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-component.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+
+/* ...component literal identifier */
+typedef const char * const xf_id_t;
+
+/* ...component descriptor (base structure) */
+typedef struct xf_component
+{
+ /* ...scheduler node */
+ xf_task_t task;
+
+ /* ...component id */
+ u32 id;
+
+ /* ...message-processing function */
+ int (*entry)(struct xf_component *, xf_message_t *);
+
+ /* ...component destructor function */
+ int (*exit)(struct xf_component *, xf_message_t *);
+#ifndef XAF_ENABLE_NON_HIKEY
+ /* ...output port accessor */
+ xf_output_port_t * (*port)(struct xf_component *, u32);
+#endif
+
+} xf_component_t;
+
+/*******************************************************************************
+ * Helpers
+ ******************************************************************************/
+
+/* ...return core-id of the component */
+static inline u32 xf_component_core(xf_component_t *component)
+{
+ return XF_PORT_CORE(component->id);
+}
+
+/* ...schedule component execution */
+#define xf_component_schedule(c, dts) \
+({ \
+ xf_sched_t *__sched = &XF_CORE_DATA(xf_component_core((c)))->sched; \
+ xf_sched_put(__sched, &(c)->task, xf_sched_timestamp(__sched) + (dts)); \
+})
+
+/* ...cancel component execution */
+#define xf_component_cancel(c) \
+({ \
+ xf_sched_t *__sched = &XF_CORE_DATA(xf_component_core((c)))->sched; \
+ xf_sched_cancel(__sched, &(c)->task); \
+})
+
+/*******************************************************************************
+ * API functions
+ ******************************************************************************/
+
+/* ...component factory */
+extern xf_component_t * xf_component_factory(u32 core, xf_id_t id, u32 length);
diff --git a/hifi/xaf/hifi-dpf/include/xf-core.h b/hifi/xaf/hifi-dpf/include/xf-core.h
new file mode 100644
index 00000000..4daea6f2
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-core.h
@@ -0,0 +1,150 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-core.h
+ *
+ * DSP processing framework core definitions
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-core.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Shared core data
+ ******************************************************************************/
+
+/* ...core data with read-only access from remote cores */
+typedef struct xf_core_ro_data
+{
+ /* ...platform-specific multi-core mutex data (want to have an array? - tbd) */
+ xf_mutex_t lock;
+
+ /* ...opaque platform-specific IPC-data handle */
+ xf_ipc_handle_t ipc;
+
+ /* ...shared memory message pool data - here? - tbd */
+ xf_msg_pool_t pool;
+
+ /* ...anything else? - tbd */
+
+} xf_core_ro_data_t;
+
+/* ...core data with read-write access from remote cores */
+typedef struct xf_core_rw_data
+{
+ /* ...message queue containing local commands/responses */
+ xf_msg_queue_t local;
+
+ /* ...message queue containing responses to remote proxy (if enabled) */
+ xf_msg_queue_t remote;
+
+ /* ...pointer to shared memory data? anything else? - tbd */
+
+} xf_core_rw_data_t;
+
+/* ...proper cache-line aligned core data */
+XF_ALIGNED_TYPEDEF(xf_core_ro_data_t, __xf_core_ro_data_t);
+XF_ALIGNED_TYPEDEF(xf_core_rw_data_t, __xf_core_rw_data_t);
+
+/*******************************************************************************
+ * Global data definition - hmm... - tbd
+ ******************************************************************************/
+
+/* ...per-core shared memory with read-only remote access */
+extern __xf_core_ro_data_t xf_core_ro_data[XF_CFG_CORES_NUM];
+
+/* ...per-core shared memory with read-write remote access */
+extern __xf_core_rw_data_t xf_core_rw_data[XF_CFG_CORES_NUM];
+
+/* ...shared read-only memory access */
+#define XF_CORE_RO_DATA(core) ((xf_core_ro_data_t *)(&xf_core_ro_data[(core)]))
+
+/* ...shared read-write memory access */
+#define XF_CORE_RW_DATA(core) ((xf_core_rw_data_t *)(&xf_core_rw_data[(core)]))
+
+/*******************************************************************************
+ * Local core data (not accessible from remote cores)
+ ******************************************************************************/
+
+/* ...component map entry */
+typedef union xf_cmap_link
+{
+ /* ...poiner to active client */
+ xf_component_t *c;
+
+ /* ...index to a client in the list (values 0..XF_CFG_MAX_CLIENTS) */
+ u32 next;
+
+} xf_cmap_link_t;
+
+/* ...per-core local data */
+typedef struct xf_core_data
+{
+ /* ...scheduler queue (sorted by execution timestamp) */
+ xf_sched_t sched;
+
+ /* ...command/response queue for communication within local core (including ISRs) */
+ xf_msg_queue_t queue;
+
+ /* ...pending response queue (submitted from ISR context) */
+ xf_msg_queue_t response;
+
+ /* ...per-core component mapping */
+ xf_cmap_link_t cmap[XF_CFG_MAX_CLIENTS];
+
+ /* ...index of first free client */
+ u32 free;
+
+ /* ...local DSP memory pool */
+ xf_mm_pool_t local_pool;
+
+ /* ...shared AP-DSP memory pool (if enabled) */
+ xf_mm_pool_t shared_pool;
+
+ /* ...opaque system-specific shared memory data handle */
+ xf_shmem_handle_t shmem;
+
+ /* ...scratch memory pointer */
+ void *scratch;
+
+ /* ...tracer data */
+ xf_trace_data_t trace;
+
+ /* ...any debugging information? for memory allocation etc... ? */
+
+} xf_core_data_t;
+
+/*******************************************************************************
+ * API functions
+ ******************************************************************************/
+
+/* ...initialize per-core framework data */
+extern int xf_core_init(u32 core);
+
+/* ...global data initialization function */
+extern int xf_global_init(void);
+
+/* ...process core events */
+extern void xf_core_service(u32 core);
diff --git a/hifi/xaf/hifi-dpf/include/xf-debug.h b/hifi/xaf/hifi-dpf/include/xf-debug.h
new file mode 100644
index 00000000..c416cc01
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-debug.h
@@ -0,0 +1,216 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-debug.h
+ *
+ * Debugging interface for Xtensa Audio DSP codec server
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-debug.h mustn't be included directly"
+#endif
+
+#include "dsp_debug.h"
+
+/*******************************************************************************
+ * Auxiliary macros (put into "xf-types.h"?)
+ ******************************************************************************/
+
+#ifndef offset_of
+#define offset_of(type, member) \
+ ((int)&(((const type *)(0))->member))
+#endif
+
+#ifndef container_of
+#define container_of(ptr, type, member) \
+ ((type *)((void *)(ptr) - offset_of(type, member)))
+#endif
+
+/* ...next power-of-two calculation */
+#define xf_next_power_of_two(v) __xf_power_of_two_1((v) - 1)
+#define __xf_power_of_two_1(v) __xf_power_of_two_2((v) | ((v) >> 1))
+#define __xf_power_of_two_2(v) __xf_power_of_two_3((v) | ((v) >> 2))
+#define __xf_power_of_two_3(v) __xf_power_of_two_4((v) | ((v) >> 4))
+#define __xf_power_of_two_4(v) __xf_power_of_two_5((v) | ((v) >> 8))
+#define __xf_power_of_two_5(v) __xf_power_of_two_6((v) | ((v) >> 16))
+#define __xf_power_of_two_6(v) ((v) + 1)
+
+/* ...check if non-zero value is a power-of-two */
+#define xf_is_power_of_two(v) (((v) & ((v) - 1)) == 0)
+
+/*******************************************************************************
+ * Bug check for constant conditions (file scope)
+ ******************************************************************************/
+
+#define __C_BUG(n) __C_BUG2(n)
+#define __C_BUG2(n) __c_bug_##n
+#define C_BUG(expr) typedef char __C_BUG(__LINE__)[(expr) ? -1 : 1]
+
+/*******************************************************************************
+ * Compilation-time types control
+ ******************************************************************************/
+
+#if XF_DEBUG
+#define __C_TYPE_CONTROL(d, type) ((void) ((d) != (type*) 0))
+#else
+#define __C_TYPE_CONTROL(d, type) ((void) 0)
+#endif
+
+/*******************************************************************************
+ * Unused variable
+ ******************************************************************************/
+
+#define C_UNUSED(v) (void)(0 ? (v) = (v), 1 : 0)
+
+/*******************************************************************************
+ * Auxiliary macros
+ ******************************************************************************/
+
+/* ...define a stub for unused declarator */
+#define __xf_stub(tag, line) __xf_stub2(tag, line)
+#define __xf_stub2(tag, line) typedef int __xf_##tag##_##line
+
+/* ...convert anything into string */
+#define __xf_string(x) __xf_string2(x)
+#define __xf_string2(x) #x
+
+/*******************************************************************************
+ * Tracing facility
+ ******************************************************************************/
+
+#if XF_TRACE
+
+/* ...tracing to communication processor */
+extern int xf_trace(const char *format, ...) __attribute__((format (printf, 1, 2)));
+
+/* ...tracing facility initialization */
+extern void xf_trace_init(const char *banner);
+
+/* ...initialize tracing facility */
+//#define TRACE_INIT(banner) (xf_trace_init(banner))
+#define TRACE_INIT(banner) ({ dsp_debug_init(); DSP_TRACE("\n"banner); })
+
+/* ...trace tag definition */
+#define TRACE_TAG(tag, on) enum { __xf_trace_##tag = on }
+
+/* ...check if the trace tag is enabled */
+#define TRACE_CFG(tag) (__xf_trace_##tag)
+
+/* ...tagged tracing primitive */
+#define TRACE(tag, fmt, ...) (void)(__xf_trace_##tag ? __xf_trace(tag, __xf_format##fmt, ## __VA_ARGS__), 1 : 0)
+
+/*******************************************************************************
+ * Tagged tracing formats
+ ******************************************************************************/
+
+/* ...tracing primitive */
+#define __xf_trace(tag, fmt, ...) \
+ ({ __attribute__((unused)) const char *__xf_tag = #tag; DSP_TRACE(fmt, ## __VA_ARGS__); })
+
+/* ...just a format string */
+#define __xf_format_n(fmt) fmt
+
+/* ...module tag and trace tag shown */
+#define __xf_format_b(fmt) "[%s.%s] " fmt, __xf_string(MODULE_TAG), __xf_tag
+
+/* ...module tag, trace tag, file name and line shown */
+#define __xf_format_x(fmt) "[%s.%s] - %s@%d - " fmt, __xf_string(MODULE_TAG), __xf_tag, __FILE__, __LINE__
+
+/*******************************************************************************
+ * Globally defined tags
+ ******************************************************************************/
+
+/* ...unconditionally OFF */
+TRACE_TAG(0, 0);
+
+/* ...unconditionally ON */
+TRACE_TAG(1, 1);
+
+/* ...error output - on by default */
+TRACE_TAG(ERROR, 1);
+
+#else
+
+#define TRACE_INIT(banner) (void)0
+#define TRACE_TAG(tag, on) __xf_stub(trace_##tag, __LINE__)
+#define TRACE_CFG(tag) 0
+#define TRACE(tag, fmt, ...) (void)0
+#define __xf_trace(tag, fmt, ...) (void)0
+
+#endif /* XF_TRACE */
+
+/*******************************************************************************
+ * Bugchecks
+ ******************************************************************************/
+
+#if XF_DEBUG
+
+/* ...run-time bugcheck */
+#define BUG(cond, fmt, ...) \
+do \
+{ \
+ if (cond) \
+ { \
+ /* ...output message */ \
+ __xf_trace(BUG, __xf_format##fmt, ## __VA_ARGS__); \
+ \
+ /* ...and die (tbd) */ \
+ __xf_abort(); \
+ } \
+} \
+while (0)
+
+#else
+#define BUG(cond, fmt, ...) (void)0
+#endif /* XF_DEBUG */
+
+/*******************************************************************************
+ * Run-time error processing
+ ******************************************************************************/
+
+/* ...check the API call succeeds */
+#define XF_CHK_API(cond) \
+({ \
+ int __ret; \
+ \
+ if ((__ret = (int)(cond)) < 0) \
+ { \
+ TRACE(ERROR, _x("API error: %d"), __ret); \
+ return __ret; \
+ } \
+ __ret; \
+})
+
+/* ...check the condition is true */
+#define XF_CHK_ERR(cond, error) \
+({ \
+ int __ret; \
+ \
+ if (!(__ret = (int)(cond))) \
+ { \
+ TRACE(ERROR, _x("check failed: %d"), __ret); \
+ return (error); \
+ } \
+ __ret; \
+})
diff --git a/hifi/xaf/hifi-dpf/include/xf-io.h b/hifi/xaf/hifi-dpf/include/xf-io.h
new file mode 100644
index 00000000..17019a73
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-io.h
@@ -0,0 +1,298 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-io.h
+ *
+ * Input/output data ports
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-io.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+
+/* ...input port with interim buffer */
+typedef struct xf_input_port
+{
+ /* ...message queue */
+ xf_msg_queue_t queue;
+
+ /* ...internal contiguous buffer to store incoming data */
+ void *buffer;
+
+ /* ...size of internal buffer */
+ u32 length;
+
+ /* ...current writing position in the buffer */
+ u32 filled;
+
+ /* ...interim pointer to input message buffer */
+ void *access;
+
+ /* ...remaining length of current input message */
+ u32 remaining;
+
+ /* ...execution flags */
+ u32 flags;
+
+} xf_input_port_t;
+
+/*******************************************************************************
+ * Input port flags
+ ******************************************************************************/
+
+/* ...data enabled */
+#define XF_INPUT_FLAG_CREATED (1 << 0)
+
+/* ...data enabled */
+#define XF_INPUT_FLAG_ENABLED (1 << 1)
+
+/* ...end-of-stream condition */
+#define XF_INPUT_FLAG_EOS (1 << 2)
+
+/* ...stream completed */
+#define XF_INPUT_FLAG_DONE (1 << 3)
+
+/* ...stream purging sequence */
+#define XF_INPUT_FLAG_PURGING (1 << 4)
+
+/* ...base input port flags mask */
+#define __XF_INPUT_FLAGS(flags) ((flags) & ((1 << 5) - 1))
+
+/* ...custom input port flag */
+#define __XF_INPUT_FLAG(f) ((f) << 5)
+
+/*******************************************************************************
+ * Helpers
+ ******************************************************************************/
+
+/* ...test if input port is created */
+static inline int xf_input_port_created(xf_input_port_t *port)
+{
+ return (port->flags & XF_INPUT_FLAG_CREATED);
+}
+
+/* ...check if input port is ready (has pending message) */
+static inline int xf_input_port_ready(xf_input_port_t *port)
+{
+ return (xf_msg_queue_head(&port->queue) != NULL);
+}
+
+/* ...test if input port entered end-of-stream condition */
+static inline int xf_input_port_done(xf_input_port_t *port)
+{
+ return (port->flags & XF_INPUT_FLAG_DONE);
+}
+
+/* ...check if port is in bypass mode */
+static inline int xf_input_port_bypass(xf_input_port_t *port)
+{
+ return port->buffer == NULL;
+}
+
+/* ...bypass port only: check if there is a data available */
+static inline void * xf_input_port_data(xf_input_port_t *port)
+{
+ return port->access;
+}
+
+/* ...bypass port only: get remaining length of current message */
+static inline u32 xf_input_port_length(xf_input_port_t *port)
+{
+ return port->remaining;
+}
+
+/* ...non-bypass port only: get current fill level */
+static inline u32 xf_input_port_level(xf_input_port_t *port)
+{
+ return port->filled;
+}
+
+/*******************************************************************************
+ * Output port data
+ ******************************************************************************/
+
+typedef struct xf_output_port
+{
+ /* ...pending message queue */
+ xf_msg_queue_t queue;
+
+ /* ...message pool */
+ xf_msg_pool_t pool;
+
+ /* ...saved port unrouting message */
+ xf_message_t *unroute;
+
+ /* ...length of output buffer */
+ u32 length;
+
+ /* ...output port flags */
+ u32 flags;
+
+} xf_output_port_t;
+
+/*******************************************************************************
+ * Output port flags
+ ******************************************************************************/
+
+/* ...port is created */
+#define XF_OUTPUT_FLAG_CREATED (1 << 0)
+
+/* ...port is routed */
+#define XF_OUTPUT_FLAG_ROUTED (1 << 1)
+
+/* ...data enabled */
+#define XF_OUTPUT_FLAG_ENABLED (1 << 2)
+
+/* ...stream completed */
+#define XF_OUTPUT_FLAG_DONE (1 << 3)
+
+/* ...flushing sequence is on-going */
+#define XF_OUTPUT_FLAG_FLUSHING (1 << 4)
+
+/* ...port is idle - no outstanding messages */
+#define XF_OUTPUT_FLAG_IDLE (1 << 5)
+
+/* ...port is being unrouted */
+#define XF_OUTPUT_FLAG_UNROUTING (1 << 6)
+
+/* ...base output port flags accessor */
+#define __XF_OUTPUT_FLAGS(flags) ((flags) & ((1 << 7) - 1))
+
+/* ...custom output port flag */
+#define __XF_OUTPUT_FLAG(f) ((f) << 7)
+
+/*******************************************************************************
+ * Helpers
+ ******************************************************************************/
+
+/* ...test if input port is created */
+static inline int xf_output_port_created(xf_output_port_t *port)
+{
+ return (port->flags & XF_OUTPUT_FLAG_CREATED);
+}
+
+/* ...check if port is routed */
+static inline int xf_output_port_routed(xf_output_port_t *port)
+{
+ return ((port->flags & XF_OUTPUT_FLAG_ROUTED) != 0);
+}
+
+/* ...check if port unrouting sequence is ongoing */
+static inline int xf_output_port_unrouting(xf_output_port_t *port)
+{
+ return ((port->flags & XF_OUTPUT_FLAG_UNROUTING) != 0);
+}
+
+/* ...check if port is idle (owns all data buffers) */
+static inline int xf_output_port_idle(xf_output_port_t *port)
+{
+ return ((port->flags & XF_OUTPUT_FLAG_IDLE) != 0);
+}
+
+/* ...check if port is ready (has output buffers - better use flags - tbd) */
+static inline int xf_output_port_ready(xf_output_port_t *port)
+{
+ return (xf_msg_queue_head(&port->queue) != NULL && !xf_output_port_unrouting(port));
+}
+
+/* ...output port flow-control message accessor */
+static inline xf_message_t * xf_output_port_control_msg(xf_output_port_t *port)
+{
+ return xf_msg_pool_item(&port->pool, 0);
+}
+
+/*******************************************************************************
+ * Input port API
+ ******************************************************************************/
+
+/* ...initialize input port structure */
+extern int xf_input_port_init(xf_input_port_t *port, u32 size, u32 align, u32 core);
+
+/* ...put message into input port queue */
+extern int xf_input_port_put(xf_input_port_t *port, xf_message_t *m);
+
+/* ...fill-in required amount of data into input port buffer */
+extern int xf_input_port_fill(xf_input_port_t *port);
+
+/* ...pad input buffer with given value */
+extern void xf_input_port_pad(xf_input_port_t *port, u8 pad);
+
+/* ...consume bytes from input buffer */
+extern void xf_input_port_consume(xf_input_port_t *port, u32 n);
+
+/* ...purge input port queue */
+extern void xf_input_port_purge(xf_input_port_t *port);
+
+/* ...save flow-control message for propagated input port purging sequence */
+extern void xf_input_port_control_save(xf_input_port_t *port, xf_message_t *m);
+
+/* ...complete input port purging sequence */
+extern void xf_input_port_purge_done(xf_input_port_t *port);
+
+/* ...destroy input port data */
+extern void xf_input_port_destroy(xf_input_port_t *port, u32 core);
+
+/*******************************************************************************
+ * Output port API
+ ******************************************************************************/
+
+/* ...initialize output port structure */
+extern int xf_output_port_init(xf_output_port_t *port, u32 size);
+
+/* ...put next message to the output port */
+extern int xf_output_port_put(xf_output_port_t *port, xf_message_t *m);
+
+/* ...get data buffer of output message */
+extern void * xf_output_port_data(xf_output_port_t *port);
+
+/* ...route output port */
+extern int xf_output_port_route(xf_output_port_t *port, u32 id, u32 n, u32 length, u32 align);
+
+/* ...unroute output port */
+extern void xf_output_port_unroute(xf_output_port_t *port);
+
+/* ...start output port unrouting sequence */
+extern void xf_output_port_unroute_start(xf_output_port_t *port, xf_message_t *m);
+
+/* ...complete port unrouting sequence */
+extern void xf_output_port_unroute_done(xf_output_port_t *port);
+
+/* ...produce output message marking amount of bytes produced */
+extern int xf_output_port_produce(xf_output_port_t *port, u32 n);
+
+/* ...purge output port */
+extern void xf_output_port_purge(xf_output_port_t *port);
+
+/* ...flush output port and return non-zero result if sequence is over */
+extern int xf_output_port_flush(xf_output_port_t *port, u32 opcode);
+
+/* ...complete flushing sequence */
+extern void xf_output_port_flush_done(xf_output_port_t *port);
+
+/* ...destroy output port data */
+extern void xf_output_port_destroy(xf_output_port_t *port, u32 core);
diff --git a/hifi/xaf/hifi-dpf/include/xf-mm.h b/hifi/xaf/hifi-dpf/include/xf-mm.h
new file mode 100644
index 00000000..712ea14a
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-mm.h
@@ -0,0 +1,142 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-mm.h
+ *
+ * Generic dynamic memory manager (based on rb-tree index)
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-mem.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/* ...red-black trees library */
+#include "lib/rbtree.h"
+
+/*******************************************************************************
+ * Cache-line aligned types
+ ******************************************************************************/
+
+/* ...proper cache-line alignment */
+#define XF_ALIGNED(size) \
+ (((size) + XF_PROXY_ALIGNMENT - 1) & ~(XF_PROXY_ALIGNMENT - 1))
+
+/* ...cache-line aligned type identifier */
+#define XF_ALIGNED_TYPE(type) \
+ __xf_aligned_##type
+
+/* ...definition of cache-line aligned type */
+#define XF_ALIGNED_TYPEDEF(type, name) \
+typedef union \
+{ \
+ /* ...item of original type */ \
+ type __obj; \
+ \
+ /* ...padding to cache-line */ \
+ u8 __pad[XF_ALIGNED(sizeof(type))]; \
+ \
+} XF_ALIGNED_TYPE(type), name __xf_shmem__
+
+/* ...accessor to original type */
+#define XF_ALIGNED_OBJ(p) \
+ (&(p)->__obj)
+
+#define XF_IS_ALIGNED(p) \
+ (((u32)(p) & (XF_PROXY_ALIGNMENT - 1)) == 0)
+
+/*******************************************************************************
+ * Memory pool description
+ ******************************************************************************/
+
+/* ...memory allocator data */
+typedef struct xf_mm_pool
+{
+ /* ...free blocks map sorted by block length */
+ rb_tree_t l_map;
+
+ /* ...free blocks map sorted by address of the block */
+ rb_tree_t a_map;
+
+ /* ...address of memory pool (32-bytes aligned at least); need that? - tbd */
+ void *addr;
+
+ /* ...length of the pool (multiple of descriptor size); need that? - tbd */
+ u32 size;
+
+} xf_mm_pool_t;
+
+/* ...descriptor of free memory block */
+typedef struct xf_mm_block
+{
+ /* ...rb-tree node in a block-length map */
+ rb_node_t l_node;
+
+ /* ...rb-tree node in a block-address map */
+ rb_node_t a_node;
+
+} xf_mm_block_t;
+
+/* ...properly aligned allocation unit */
+typedef u8 xf_mm_item[xf_next_power_of_two(sizeof(xf_mm_block_t))];
+
+/* ...macro to assure proper alignment of dynamically allocated data */
+#define XF_MM(size) (((size) + sizeof(xf_mm_item) - 1) & ~(sizeof(xf_mm_item) - 1))
+
+/* ...check if memory is properly aligned */
+#define XF_MM_ALIGNED(size) (!((size) & (sizeof(xf_mm_item) - 1)))
+
+/* ...alignement definition */
+#define __xf_mm__ __attribute__((__aligned__(sizeof(xf_mm_item))))
+
+/*******************************************************************************
+ * Dynamically allocated buffer
+ ******************************************************************************/
+
+/* ...memory allocation metadata */
+typedef struct xf_mm_buffer
+{
+ /* ...allocation address */
+ void *addr;
+
+ /* ...length */
+ u32 size;
+
+} __xf_mm__ xf_mm_buffer_t;
+
+/*******************************************************************************
+ * API functions
+ ******************************************************************************/
+
+/* ...pool initialization */
+extern int xf_mm_init(xf_mm_pool_t *pool, void *addr, u32 size);
+
+/* ...block allocation */
+extern void * xf_mm_alloc(xf_mm_pool_t *pool, u32 size);
+
+/* ...block deallocation */
+extern void xf_mm_free(xf_mm_pool_t *pool, void *addr, u32 size);
diff --git a/hifi/xaf/hifi-dpf/include/xf-msg.h b/hifi/xaf/hifi-dpf/include/xf-msg.h
new file mode 100644
index 00000000..3448425b
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-msg.h
@@ -0,0 +1,252 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-msg.h
+ *
+ * Internal messages, and message queues.
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-msg.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+
+/* ...forward declaration */
+typedef struct xf_message xf_message_t;
+
+/* ...audio command/response message (internal to DSP processing framework) */
+struct xf_message
+{
+ /* ...pointer to next item in the list */
+ xf_message_t *next;
+
+ /* ...shmem session_id */
+ u32 id;
+
+ /* ...operation code */
+ u32 opcode;
+
+ /* ...length of attached message buffer */
+ u32 length;
+
+ /* ...message buffer (translated virtual address) */
+ void *buffer;
+#ifndef XAF_ENABLE_NON_HIKEY
+ uint64_t v_buffer;
+#endif
+};
+
+/* ...cache-line aligned message buffer */
+XF_ALIGNED_TYPEDEF(xf_message_t, __xf_message_t);
+
+/* ...message pool definition */
+typedef struct xf_msg_pool
+{
+ /* ...array of aligned messages */
+ __xf_message_t *p;
+
+ /* ...pointer to first free item in the pool */
+ __xf_message_t *head;
+
+ /* ...total size of the pool */
+ u32 n;
+
+} xf_msg_pool_t;
+
+/* ...message accessor */
+static inline xf_message_t * xf_msg_pool_item(xf_msg_pool_t *pool, u32 i)
+{
+ return (xf_message_t *) &pool->p[i];
+}
+
+/*******************************************************************************
+ * Message queue data
+ ******************************************************************************/
+
+/* ...message queue (single-linked FIFO list) */
+typedef struct xf_msg_queue
+{
+ /* ...head of the queue */
+ xf_message_t *head;
+
+ /* ...tail pointer */
+ xf_message_t *tail;
+
+} xf_msg_queue_t;
+
+/*******************************************************************************
+ * Message queue API
+ ******************************************************************************/
+
+/* ...initialize message queue */
+static inline void xf_msg_queue_init(xf_msg_queue_t *queue)
+{
+ queue->head = queue->tail = NULL;
+}
+
+/* ...push message in FIFO queue */
+static inline int xf_msg_enqueue(xf_msg_queue_t *queue, xf_message_t *m)
+{
+ int empty = (queue->head == NULL);
+
+ /* ...set list terminating pointer */
+ m->next = NULL;
+
+ if (empty)
+ queue->head = m;
+ else
+ queue->tail->next = m;
+
+ /* ...advance tail pointer */
+ queue->tail = m;
+
+ /* ...return emptiness status */
+ return empty;
+}
+
+#define xf_msg_enqueue(queue, m) \
+({ \
+ BUG((m)->next != NULL, _x("message is active: %p"), (m)); \
+ (xf_msg_enqueue)((queue), (m)); \
+})
+
+/* ...retrieve (pop) next message from FIFO queue */
+static inline xf_message_t * xf_msg_dequeue(xf_msg_queue_t *queue)
+{
+ xf_message_t *m = queue->head;
+
+ /* ...check if there is anything in the queue and dequeue it */
+ if (m != NULL)
+ {
+ /* ...advance head to the next entry in the queue */
+ if ((queue->head = m->next) == NULL)
+ queue->tail = NULL;
+
+ /* ...debug - wipe out next pointer */
+ m->next = NULL;
+ }
+
+ return m;
+}
+
+/* ...test if message queue is empty */
+static inline int xf_msg_queue_empty(xf_msg_queue_t *queue)
+{
+ return (queue->head == NULL);
+}
+
+/* ...get message queue head pointer */
+static inline xf_message_t * xf_msg_queue_head(xf_msg_queue_t *queue)
+{
+ return queue->head;
+}
+
+/* ...check if message belongs to a pool */
+static inline int xf_msg_from_pool(xf_msg_pool_t *pool, xf_message_t *m)
+{
+ return (u32)((__xf_message_t*)m - pool->p) < pool->n;
+}
+
+/*******************************************************************************
+ * Global message pool API
+ ******************************************************************************/
+
+/* ...submit message execution on local DSP core */
+extern void xf_msg_schedule(xf_message_t *m, u32 ts);
+
+/* ...schedule message execution from ISR context */
+extern void xf_msg_schedule_isr(xf_message_t *m);
+
+/* ...submit message for execution on some DSP */
+extern void xf_msg_submit(xf_message_t *m);
+
+/* ...cancel local (scheduled on current core) message execution */
+extern void xf_msg_cancel(xf_message_t *m);
+
+/* ...complete message processing */
+extern void xf_msg_complete(xf_message_t *m);
+
+/* ...complete message from ISR context */
+extern void xf_msg_complete_isr(xf_message_t *m);
+
+/* ...allocate message pool on specific core */
+extern int xf_msg_pool_init(xf_msg_pool_t *pool, u32 n, u32 core);
+
+/* ...allocate message from a pool (no concurrent access from other cores) */
+extern xf_message_t * xf_msg_pool_get(xf_msg_pool_t *pool);
+
+/* ...return message back to the pool (no concurrent access from other cores) */
+extern void xf_msg_pool_put(xf_msg_pool_t *pool, xf_message_t *m);
+
+/* ...destroy message pool */
+extern void xf_msg_pool_destroy(xf_msg_pool_t *pool, u32 core);
+
+/* ...indicate whether pool of free messages is empty */
+extern int xf_message_pool_empty(void);
+
+/* ...initialize global pool of messages */
+extern void xf_message_pool_init(void);
+
+/*******************************************************************************
+ * Auxiliary helpers
+ ******************************************************************************/
+
+/* ...send response message to caller */
+static inline void xf_response(xf_message_t *m)
+{
+ xf_msg_complete(m);
+}
+
+/* ...send response message with output buffer */
+static inline void xf_response_data(xf_message_t *m, u32 length)
+{
+ /* ...adjust message output buffer */
+ m->length = length;
+
+ /* ...return message to originator */
+ xf_msg_complete(m);
+}
+
+/* ...send generic "ok" message (no data buffer) */
+static inline void xf_response_ok(xf_message_t *m)
+{
+ /* ...adjust message output buffer */
+ m->length = 0;
+
+ /* ...return message to originator */
+ xf_msg_complete(m);
+}
+
+/* ...send error-response message */
+static inline void xf_response_err(xf_message_t *m)
+{
+ /* ...set generic error message */
+ m->opcode = XF_UNREGISTER, m->length = 0;
+
+ /* ...return message to originator */
+ xf_msg_complete(m);
+}
diff --git a/hifi/xaf/hifi-dpf/include/xf-opcode.h b/hifi/xaf/hifi-dpf/include/xf-opcode.h
new file mode 100644
index 00000000..6fa08465
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-opcode.h
@@ -0,0 +1,290 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-opcode.h
+ *
+ * Xtensa audio processing framework. Message API
+ *
+ ******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-opcode.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Message routing composition - move somewhere else - tbd
+ ******************************************************************************/
+
+/* ...adjust IPC client of message going from user-space */
+#define XF_MSG_AP_FROM_USER(id, client) \
+ (((id) & ~(0xF << 2)) | (client))
+
+/* ...wipe out IPC client from message going to user-space */
+#define XF_MSG_AP_TO_USER(id) \
+ ((id) & ~(0xF << 18))
+
+/* ...port specification (12 bits) */
+#define __XF_PORT_SPEC(core, id, port) ((core) | ((id) << 2) | ((port) << 8))
+#define __XF_PORT_SPEC2(id, port) ((id) | ((port) << 8))
+#define XF_PORT_CORE(spec) ((spec) & 0x3)
+#define XF_PORT_CLIENT(spec) (((spec) >> 2) & 0x3F)
+#define XF_PORT_ID(spec) (((spec) >> 8) & 0xF)
+
+/* ...message id contains source and destination ports specification */
+#define __XF_MSG_ID(src, dst) (((src) & 0xFFFF) | (((dst) & 0xFFFF) << 16))
+#define XF_MSG_SRC(id) (((id) >> 0) & 0xFFFF)
+#define XF_MSG_SRC_CORE(id) (((id) >> 0) & 0x3)
+#define XF_MSG_SRC_CLIENT(id) (((id) >> 2) & 0x3F)
+#define XF_MSG_SRC_ID(id) (((id) >> 0) & 0xFF)
+#define XF_MSG_SRC_PORT(id) (((id) >> 8) & 0xF)
+#define XF_MSG_SRC_PROXY(id) (((id) >> 15) & 0x1)
+#define XF_MSG_DST(id) (((id) >> 16) & 0xFFFF)
+#define XF_MSG_DST_CORE(id) (((id) >> 16) & 0x3)
+#define XF_MSG_DST_CLIENT(id) (((id) >> 18) & 0x3F)
+#define XF_MSG_DST_ID(id) (((id) >> 16) & 0xFF)
+#define XF_MSG_DST_PORT(id) (((id) >> 24) & 0xF)
+#define XF_MSG_DST_PROXY(id) (((id) >> 31) & 0x1)
+
+/* ...special treatment of AP-proxy destination field */
+#define XF_AP_IPC_CLIENT(id) (((id) >> 18) & 0xF)
+#define XF_AP_CLIENT(id) (((id) >> 22) & 0x1FF)
+#define __XF_AP_PROXY(core) ((core) | 0x8000)
+#define __XF_DSP_PROXY(core) ((core) | 0x8000)
+#define __XF_AP_CLIENT(core, client) ((core) | ((client) << 6) | 0x8000)
+
+/* ...check if DSP message is shared between cores */
+#define XF_MSG_SHARED(id) \
+ ({ u32 __id = (id); (XF_CFG_CORES_NUM > 1 ? (__id ^ (__id >> 16)) & 0x3 : 0); })
+
+/*******************************************************************************
+ * Opcode composition
+ ******************************************************************************/
+
+/* ...opcode composition with command/response data tags */
+#define __XF_OPCODE(c, r, op) (((c) << 31) | ((r) << 30) | ((op) & 0x3F))
+
+/* ...accessors */
+#define XF_OPCODE_CDATA(opcode) ((opcode) & (1 << 31))
+#define XF_OPCODE_RDATA(opcode) ((opcode) & (1 << 30))
+#define XF_OPCODE_TYPE(opcode) ((opcode) & (0x3F))
+
+/*******************************************************************************
+ * Opcode types
+ ******************************************************************************/
+
+/* ...unregister client */
+#define XF_UNREGISTER __XF_OPCODE(0, 0, 0)
+
+/* ...register client at proxy */
+#define XF_REGISTER __XF_OPCODE(1, 0, 1)
+
+/* ...port routing command */
+#define XF_ROUTE __XF_OPCODE(1, 0, 2)
+
+/* ...port unrouting command */
+#define XF_UNROUTE __XF_OPCODE(1, 0, 3)
+
+/* ...shared buffer allocation */
+#define XF_ALLOC __XF_OPCODE(0, 0, 4)
+
+/* ...shared buffer freeing */
+#define XF_FREE __XF_OPCODE(0, 0, 5)
+
+/* ...set component parameters */
+#define XF_SET_PARAM __XF_OPCODE(1, 0, 6)
+
+/* ...get component parameters */
+#define XF_GET_PARAM __XF_OPCODE(1, 1, 7)
+
+/* ...input buffer reception */
+#define XF_EMPTY_THIS_BUFFER __XF_OPCODE(1, 0, 8)
+
+/* ...output buffer reception */
+#define XF_FILL_THIS_BUFFER __XF_OPCODE(0, 1, 9)
+
+/* ...flush specific port */
+#define XF_FLUSH __XF_OPCODE(0, 0, 10)
+
+/* ...start component operation */
+#define XF_START __XF_OPCODE(0, 0, 11)
+
+/* ...stop component operation */
+#define XF_STOP __XF_OPCODE(0, 0, 12)
+
+/* ...pause component operation */
+#define XF_PAUSE __XF_OPCODE(0, 0, 13)
+
+/* ...resume component operation */
+#define XF_RESUME __XF_OPCODE(0, 0, 14)
+
+/* ...extended parameter setting function */
+#define XF_SET_PARAM_EXT __XF_OPCODE(1, 1, 15)
+
+/* ...extended parameter retrieval function */
+#define XF_GET_PARAM_EXT __XF_OPCODE(1, 1, 16)
+
+/* ...total amount of supported decoder commands */
+#define __XF_OP_NUM 17
+
+/*******************************************************************************
+ * XF_START message definition
+ ******************************************************************************/
+
+typedef struct xf_start_msg
+{
+ /* ...effective sample rate */
+ u32 sample_rate;
+
+ /* ...number of channels */
+ u32 channels;
+
+ /* ...sample width */
+ u32 pcm_width;
+
+ /* ...minimal size of intput buffer */
+ u32 input_length;
+
+ /* ...size of output buffer */
+ u32 output_length;
+
+} __attribute__((__packed__)) xf_start_msg_t;
+
+/*******************************************************************************
+ * XF_GET_PARAM message
+ ******************************************************************************/
+
+/* ...message body (command/response) */
+typedef union xf_get_param_msg
+{
+ /* ...command structure */
+ struct
+ {
+ /* ...array of parameters requested */
+ u32 id[0];
+
+ } __attribute__((__packed__)) c;
+
+ /* ...response structure */
+ struct
+ {
+ /* ...array of parameters values */
+ u32 value[0];
+
+ } __attribute__((__packed__)) r;
+
+} xf_get_param_msg_t;
+
+/* ...length of the XF_GET_PARAM command/response */
+#define XF_GET_PARAM_CMD_LEN(params) (sizeof(u32) * (params))
+#define XF_GET_PARAM_RSP_LEN(params) (sizeof(u32) * (params))
+
+/*******************************************************************************
+ * XF_SET_PARAM message
+ ******************************************************************************/
+
+/* ...component initialization parameter */
+typedef struct xf_set_param_item
+{
+ /* ...index of parameter passed to SET_CONFIG_PARAM call */
+ u32 id;
+
+ /* ...value of parameter */
+ u32 value;
+
+} __attribute__ ((__packed__)) xf_set_param_item_t;
+
+/* ...message body (no response message? - tbd) */
+typedef struct xf_set_param_msg
+{
+ /* ...command message */
+ xf_set_param_item_t item[0];
+
+} __attribute__ ((__packed__)) xf_set_param_msg_t;
+
+/* ...length of the command message */
+#define XF_SET_PARAM_CMD_LEN(params) (sizeof(xf_set_param_item_t) * (params))
+
+/*******************************************************************************
+ * XF_SET_PARAM_EXT/XF_GET_PARAM_EXT message
+ ******************************************************************************/
+
+/* ...extended parameter descriptor */
+typedef struct xf_ext_param_desc
+{
+ /* ...index of parameter passed to SET/GET_CONFIG_PARAM call (16-bits only) */
+ u16 id;
+
+ /* ...length of embedded input/output parameter data (in bytes) */
+ u16 length;
+
+} __attribute__ ((__packed__, __aligned__(4))) xf_ext_param_desc_t;
+
+/* ...message body (no response message? - tbd) */
+typedef struct xf_ext_param_msg
+{
+ /* ...extended parameter descriptor */
+ xf_ext_param_desc_t desc;
+
+ /* ...parameter data (in the format expected by codec; 4 bytes aligned) */
+ u8 data[0];
+
+} __attribute__ ((__packed__, __aligned__(4))) xf_ext_param_msg_t;
+
+/*******************************************************************************
+ * XF_ROUTE definition
+ ******************************************************************************/
+
+/* ...port routing command */
+typedef struct xf_route_port_msg
+{
+ /* ...source port specification */
+ u32 src;
+
+ /* ...destination port specification */
+ u32 dst;
+
+ /* ...number of buffers to allocate */
+ u32 alloc_number;
+
+ /* ...length of buffer to allocate */
+ u32 alloc_size;
+
+ /* ...alignment restriction for a buffer */
+ u32 alloc_align;
+
+} __attribute__((__packed__)) xf_route_port_msg_t;
+
+/*******************************************************************************
+ * XF_UNROUTE definition
+ ******************************************************************************/
+
+/* ...port unrouting command */
+typedef struct xf_unroute_port_msg
+{
+ /* ...source port specification */
+ u32 src;
+
+ /* ...destination port specification */
+ u32 dst;
+
+} __attribute__((__packed__)) xf_unroute_port_msg_t;
diff --git a/hifi/xaf/hifi-dpf/include/xf-plugin.h b/hifi/xaf/hifi-dpf/include/xf-plugin.h
new file mode 100644
index 00000000..5805e9ff
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-plugin.h
@@ -0,0 +1,48 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-plugin.h
+ *
+ * Xtensa audio processing framework - plugin infrastructure.
+ *
+ ******************************************************************************/
+
+#ifdef __XF_H
+#error "xf-plugin.h cannot be used together with xf.h"
+#endif
+
+#define __XF_H
+
+/*******************************************************************************
+ * Plugin debugging interface
+ ******************************************************************************/
+
+/* ...platform-specific HAL */
+#include "xf-hal.h"
+#ifdef XAF_ENABLE_NON_HIKEY
+//#define XF_TRACE 1
+#define XF_DEBUG 1
+#endif
+
+/* ...debugging facilities */
+#include "xf-debug.h"
diff --git a/hifi/xaf/hifi-dpf/include/xf-proxy.h b/hifi/xaf/hifi-dpf/include/xf-proxy.h
new file mode 100644
index 00000000..0260749c
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-proxy.h
@@ -0,0 +1,102 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-proxy.h
+ *
+ * Proxy commmand/response messages
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-proxy.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...command/response message */
+typedef struct xf_proxy_message
+{
+ /* ...session ID */
+ uint32_t session_id;
+
+ /* ...proxy API command/reponse code */
+ uint32_t opcode;
+
+ /* ...length of attached buffer */
+ uint32_t length;
+
+ /* ...physical address of message buffer */
+ uint64_t address;
+ uint64_t v_address;
+
+} __attribute__((__packed__)) xf_proxy_message_t;
+#else
+/* ...command/response message */
+typedef struct xf_proxy_message
+{
+ /* ...session ID */
+ uint32_t session_id;
+
+ /* ...proxy API command/reponse code */
+ uint32_t opcode;
+
+ /* ...length of attached buffer */
+ uint32_t length;
+
+ /* ...physical address of message buffer */
+ uint64_t address;
+ uint64_t v_address;
+
+} __attribute__((__packed__)) xf_proxy_message_t;
+#endif
+/*******************************************************************************
+ * Ring buffer support
+ ******************************************************************************/
+
+/* ...total length of shared memory queue (for commands and responses) */
+#define XF_PROXY_MESSAGE_QUEUE_LENGTH (1 << 8)
+
+/* ...index mask */
+#define XF_PROXY_MESSAGE_QUEUE_MASK 0xFF
+
+/* ...ring-buffer index */
+#define __XF_QUEUE_IDX(idx, counter) \
+ (((idx) & XF_PROXY_MESSAGE_QUEUE_MASK) | ((counter) << 16))
+
+/* ...retrieve ring-buffer index */
+#define XF_QUEUE_IDX(idx) \
+ ((idx) & XF_PROXY_MESSAGE_QUEUE_MASK)
+
+/* ...increment ring-buffer index */
+#define XF_QUEUE_ADVANCE_IDX(idx) \
+ (((idx) + 0x10001) & (0xFFFF0000 | XF_PROXY_MESSAGE_QUEUE_MASK))
+
+/* ...test if ring buffer is empty */
+#define XF_QUEUE_EMPTY(read, write) \
+ ((read) == (write))
+
+/* ...test if ring buffer is full */
+#define XF_QUEUE_FULL(read, write) \
+ ((write) == (read) + (XF_PROXY_MESSAGE_QUEUE_LENGTH << 16))
diff --git a/hifi/xaf/hifi-dpf/include/xf-sched.h b/hifi/xaf/hifi-dpf/include/xf-sched.h
new file mode 100644
index 00000000..3c04436c
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-sched.h
@@ -0,0 +1,98 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-sched.h
+ *
+ * Non-preemptive earliest-deadline-first scheduler
+ *
+ ******************************************************************************/
+
+#ifndef __XF_SCHED_H
+#define __XF_SCHED_H
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+
+/* ...scheduler data */
+typedef rb_tree_t xf_sched_t;
+
+/* ...scheduling item */
+typedef rb_node_t xf_task_t;
+
+/*******************************************************************************
+ * Helpers
+ ******************************************************************************/
+
+/* ...retrieve timestamp from task handle */
+static inline u32 xf_task_timestamp(xf_task_t *t)
+{
+ /* ...wipe out last bit of "color" */
+ return (((rb_node_t *)t)->color & ~1);
+}
+
+/* ...set task decoding timestamp */
+static inline u32 xf_task_timestamp_set(xf_task_t *t, u32 ts)
+{
+ /* ...technically, wiping out last bit of timestamp is not needed */
+ return (((rb_node_t *)t)->color = ts);
+}
+
+/* ...compare two timestamps with respect to wrap-around */
+static inline int xf_timestamp_before(u32 t0, u32 t1)
+{
+ /* ...distance between active items is never high */
+ return ((s32)(t0 - t1) < 0);
+}
+
+/* ...current scheduler timestamp */
+static inline u32 xf_sched_timestamp(xf_sched_t *sched)
+{
+ /* ...don't quite care about last bit */
+ return ((rb_tree_t *)sched)->root.color;
+}
+
+/* ...set scheduler timestamp */
+static inline u32 xf_sched_timestamp_set(xf_sched_t *sched, u32 ts)
+{
+ /* ...wipe out last bit (black color is 0) */
+ return (((rb_tree_t *)sched)->root.color = ts & ~0x1);
+}
+
+/*******************************************************************************
+ * Entry points
+ ******************************************************************************/
+
+/* ...place message into scheduler queue */
+extern void xf_sched_put(xf_sched_t *sched, xf_task_t *t, u32 ts);
+
+/* ...get first item from the scheduler */
+extern xf_task_t * xf_sched_get(xf_sched_t *sched);
+
+/* ...cancel task execution */
+extern void xf_sched_cancel(xf_sched_t *sched, xf_task_t *t);
+
+/* ...initialize scheduler */
+extern void xf_sched_init(xf_sched_t *sched);
+
+#endif /* __XF_SCHED_H */
diff --git a/hifi/xaf/hifi-dpf/include/xf-timebase.h b/hifi/xaf/hifi-dpf/include/xf-timebase.h
new file mode 100644
index 00000000..7b27d580
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-timebase.h
@@ -0,0 +1,132 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-timebase.h
+ *
+ * Common timebase for deadline-driven scheduler
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-timebase.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Timebase for deadline-driven scheduler
+ ******************************************************************************/
+#ifdef XAF_ENABLE_NON_HIKEY
+/* ...set internal scheduler frequency as a LCM of all supported sample rates;
+ * it is in general not a problem to have large number here, however it should
+ * be noted that maximal-size audio-buffer that we handle, when expressed in
+ * ticks of this virtual frequency, must not exceed 2**31 (for otherwise
+ * scheduler timestamp comparison function will misbehave).
+ */
+#define XF_TIMEBASE_FREQ (4 * 3 * 56448000U)
+/* ...add paranoic check considering maximal audio-buffer duration as 0.1 sec */
+C_BUG((u32)(XF_TIMEBASE_FREQ / 10) >= (1 << 31));
+#else
+/* ...set internal scheduler frequency as a LCM of all supported sample rates */
+#define XF_TIMEBASE_FREQ 56448000U
+#endif
+/* ...supported sampling rates */
+C_BUG(XF_TIMEBASE_FREQ % 4000);
+C_BUG(XF_TIMEBASE_FREQ % 8000);
+C_BUG(XF_TIMEBASE_FREQ % 11025);
+C_BUG(XF_TIMEBASE_FREQ % 12000);
+C_BUG(XF_TIMEBASE_FREQ % 16000);
+C_BUG(XF_TIMEBASE_FREQ % 22050);
+C_BUG(XF_TIMEBASE_FREQ % 24000);
+C_BUG(XF_TIMEBASE_FREQ % 32000);
+C_BUG(XF_TIMEBASE_FREQ % 44100);
+C_BUG(XF_TIMEBASE_FREQ % 48000);
+C_BUG(XF_TIMEBASE_FREQ % 64000);
+C_BUG(XF_TIMEBASE_FREQ % 88200);
+C_BUG(XF_TIMEBASE_FREQ % 96000);
+C_BUG(XF_TIMEBASE_FREQ % 128000);
+C_BUG(XF_TIMEBASE_FREQ % 176400);
+C_BUG(XF_TIMEBASE_FREQ % 192000);
+
+/* ...calculate upsampling factor for given sample rate */
+static inline u32 xf_timebase_factor(u32 sample_rate)
+{
+ /* ...probably we can tolerate single division */
+ switch(sample_rate)
+ {
+ case 4000:
+ return XF_TIMEBASE_FREQ / 4000;
+ case 8000:
+ return XF_TIMEBASE_FREQ / 8000;
+ case 11025:
+ return XF_TIMEBASE_FREQ / 11025;
+ case 12000:
+ return XF_TIMEBASE_FREQ / 11025;
+ case 16000:
+ return XF_TIMEBASE_FREQ / 16000;
+ case 22050:
+ return XF_TIMEBASE_FREQ / 22050;
+ case 24000:
+ return XF_TIMEBASE_FREQ / 24000;
+ case 32000:
+ return XF_TIMEBASE_FREQ / 32000;
+ case 44100:
+ return XF_TIMEBASE_FREQ / 44100;
+ case 48000:
+ return XF_TIMEBASE_FREQ / 48000;
+ case 64000:
+ return XF_TIMEBASE_FREQ / 64000;
+ case 88200:
+ return XF_TIMEBASE_FREQ / 88200;
+ case 96000:
+ return XF_TIMEBASE_FREQ / 96000;
+ case 128000:
+ return XF_TIMEBASE_FREQ / 128000;
+ case 176400:
+ return XF_TIMEBASE_FREQ / 176400;
+ case 192000:
+ return XF_TIMEBASE_FREQ / 192000;
+ default:
+ return 0;
+ }
+}
+
+/* ...core timebase */
+static inline u32 xf_core_timebase(u32 core)
+{
+ xf_core_data_t *cd = XF_CORE_DATA(core);
+
+ /* ...get local scheduler timebase */
+ return xf_sched_timestamp(&cd->sched);
+}
+
+/* ...compare timestamps */
+static inline int xf_time_after(u32 a, u32 b)
+{
+ return ((s32)(a - b) > 0);
+}
+
+/* ...compare timstamps */
+static inline int xf_time_before(u32 a, u32 b)
+{
+ return ((s32)(a - b) < 0);
+}
+
diff --git a/hifi/xaf/hifi-dpf/include/xf-trace.h b/hifi/xaf/hifi-dpf/include/xf-trace.h
new file mode 100644
index 00000000..97bb2905
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf-trace.h
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-debug.h
+ *
+ * Debugging interface for Xtensa Audio DSP codec server
+ *
+ *******************************************************************************/
+
+#ifndef __XF_H
+#error "xf-debug.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+
+#if XF_TRACE
+
+/* ...trace data definition */
+typedef struct xf_trace_data
+{
+ /* ...current write position in tracing buffer */
+ char *p;
+
+ /* ...threshold position for buffer submission */
+ char *end;
+
+#if XF_TRACE_REMOTE
+ /* ...beginning of non-commited internal tracing buffer */
+ char *start;
+
+ /* ...message queue */
+ xf_msg_queue_t queue;
+#endif
+
+} xf_trace_data_t;
+
+#else
+
+/* ...stub for disabled tracing */
+typedef u32 xf_trace_data_t[0];
+
+#endif /* XF_TRACE */
+
+/*******************************************************************************
+ * Internal API functions
+ ******************************************************************************/
+
+#if XF_TRACE_REMOTE
+/* ...submit buffer for tracing */
+extern void xf_trace_submit(u32 core, xf_message_t *m);
+
+/* ...flush current buffer */
+extern void xf_trace_flush(u32 core, xf_message_t *m);
+
+#else
+
+#define xf_trace_submit(core, m) (void)0
+#define xf_trace_flush(core, m) (void)0
+
+#endif /* XF_TRACE_REMOTE */
diff --git a/hifi/xaf/hifi-dpf/include/xf.h b/hifi/xaf/hifi-dpf/include/xf.h
new file mode 100644
index 00000000..f124d8ca
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/include/xf.h
@@ -0,0 +1,112 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf.h
+ *
+ * Xtensa audio processing framework. Main header
+ *
+ ******************************************************************************/
+
+#ifdef __XF_H
+#error "xf.h included more than once"
+#endif
+
+#define __XF_H
+
+/*******************************************************************************
+ * Global configuration parameters (changing is to be done carefully)
+ ******************************************************************************/
+
+/* ...allocate 6 bits for client number per core */
+#define XF_CFG_MAX_CLIENTS (1 << 6)
+
+/* ...allocate 2 bits for core id */
+#define XF_CFG_MAX_CORES (1 << 2)
+
+/* ...allocate 4 bits for maximal number of input/output ports per component */
+#define XF_CFG_MAX_PORTS (1 << 4)
+
+/* ...allocate 6 bits for opcode type */
+#define XF_CFG_MAX_CODES (1 << 6)
+
+/*******************************************************************************
+ * Common runtime framework
+ ******************************************************************************/
+#ifndef XAF_ENABLE_NON_HIKEY
+#include "cpu_c.h"
+
+#include "dsp_driver_ipc.h"
+
+#include "dsp_debug.h"
+
+#include "dsp_memory_config.h"
+
+#include "dsp_driver_mailbox.h"
+
+#include "dsp_pcm_gain.h"
+
+#endif
+/* ...target configuration */
+#include "xf-config.h"
+
+/* ...platform run-time */
+#include "xf-runtime.h"
+
+/* ...debugging facility */
+#include "xf-debug.h"
+
+/* ...generic memory allocator */
+#include "xf-mm.h"
+
+/* ...standard opcodes */
+#include "xf-opcode.h"
+
+/* ...proxy definitions (shared messages - tbd) */
+#include "xf-proxy.h"
+
+/* ...message API */
+#include "xf-msg.h"
+
+/* ...tracer data */
+#include "xf-trace.h"
+
+/* ...I/O ports */
+#include "xf-io.h"
+
+/* ...scheduler definition */
+#include "xf-sched.h"
+
+/* ...component definition */
+#include "xf-component.h"
+
+/* ...core data */
+#include "xf-core.h"
+
+/* ...system abstractions */
+#include "xf-sys.h"
+
+/* ...memory management */
+#include "xf-mem.h"
+
+/* ...common timebase */
+#include "xf-timebase.h"
diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/arch_hifi330.S b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/arch_hifi330.S
new file mode 100644
index 00000000..6d1eb7e7
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/arch_hifi330.S
@@ -0,0 +1,468 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/******************************************************************************
+ arch_hifi330.S
+******************************************************************************/
+
+#include <xtensa/coreasm.h>
+#include <xtensa/simcall.h>
+#include <xtensa/corebits.h>
+#include <xtensa/config/system.h>
+#include <xtensa/config/core.h>
+#include "arch_hifi330.h"
+
+ .global OSStartHighRdy
+ .global OSTaskSwHook
+ .global g_pstVosTCBHighRdy
+ .global g_bVosRunning
+
+// .data
+ .section .dram0.data, "aw"
+ .type OSIntCtxSw_Occur,@object
+OSIntCtxSw_Occur:
+ .byte 0
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .align 4
+ .globl VOSStartHighRdy
+ .type VOSStartHighRdy,@function
+ .align 4
+/*****************************************************************************
+ VOSStartHighRdy
+*****************************************************************************/
+VOSStartHighRdy:
+ ENTRY(16)
+
+ /*OSIntCtxSw_Occur*/
+ movi a2, OSIntCtxSw_Occur
+ movi a3, 0
+ s8i a3, a2, 0
+
+ movi a2, g_bVosRunning
+ movi a3, 1
+ s8i a3, a2, 0
+
+#if 0
+ /*OS_TaskSwHook */
+ movi a2, OS_TaskSwHook
+ callx4 a2
+#endif
+ call0 OS_TaskSwitch
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .globl VOSCtxSw
+ .type VOSCtxSw,@function
+ .align 4
+/*****************************************************************************
+ OSCtxSw
+*****************************************************************************/
+VOSCtxSw:
+ entry sp, XT_SOL_FRMSZ
+ rsr a2, PS
+ s32i a0, sp, XT_SOL_PC
+ s32i a2, sp, XT_SOL_PS
+ movi a2, g_pstVosTCBCur
+ movi a3, 0
+ l32i a2, a2, 0
+ s32i a3, sp, XT_SOL_EXIT
+ s32i sp, a2, OSTCBStkPtr /* g_pstVosTCBCur->OSTCBStkPtr = SP; */
+
+ call4 xthal_window_spill
+#if 0
+ /*OS_TaskSwHook */
+ movi a2, OS_TaskSwHook
+ callx4 a2
+#endif
+
+ /* CPENABLE, co-processor state. */
+ movi a3, g_pstVosTCBCur
+ l32i a3, a3, 0
+ l32i a2, a3, OSTCBStkBottom
+ movi a3, 0
+
+ wsr a3, CPENABLE /* disable all co-processors */
+ s8i a3, a2, XT_CPENABLE /* cp_state->cpenable = 0; */
+
+
+ call0 OS_TaskSwitch
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .globl VOSIntCtxSw
+ .type VOSIntCtxSw,@function
+ .align 4
+/*****************************************************************************
+ OSIntCtxSw
+*****************************************************************************/
+VOSIntCtxSw:
+ ENTRY(16)
+#if 0
+ /*OS_TaskSwHook */
+ movi a2, OS_TaskSwHook
+ callx4 a2
+#endif
+
+ /*CPENABLE task co-processor, CPENABLE. */
+ movi a3, g_pstVosTCBCur
+ l32i a3, a3, 0
+ l32i a2, a3, OSTCBStkBottom
+ rsr a3, CPENABLE
+ s8i a3, a2, XT_CPENABLE
+ movi a3, 0
+ wsr a3, CPENABLE
+
+ movi a2, OSIntCtxSw_Occur
+ movi a3, 1
+ s8i a3, a2, 0
+
+
+ RET(16)
+
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .global OSCPUSaveSR
+ .type OSCPUSaveSR,@function
+ .align 4
+/*****************************************************************************
+ OSCPUSaveSR
+*****************************************************************************/
+OSCPUSaveSR:
+ entry a1,32
+ rsil a2,15
+ esync
+ retw
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .global OSCPURestoreSR
+ .type OSCPURestoreSR,@function
+ .align 4
+/*****************************************************************************
+ OSCPURestoreSR
+*****************************************************************************/
+OSCPURestoreSR:
+ entry a1,32
+ wsr.ps a2
+ esync
+ retw
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .global OS_TaskSwitch
+ .type OS_TaskSwitch,@function
+ .align 4
+/*****************************************************************************
+ OS_TaskSwitch
+*****************************************************************************/
+OS_TaskSwitch:
+
+ /*1)
+ g_ucVosPrioCur = g_ucVosPrioHighRdy;
+ g_pstVosTCBCur = g_pstVosTCBHighRdy;
+ SP = g_pstVosTCBHighRdy->OSTCBStkPtr;
+ */
+ movi a2, g_ucVosPrioHighRdy
+ movi a3, g_ucVosPrioCur
+ l8ui a2, a2, 0
+ movi a4, g_pstVosTCBHighRdy
+ s8i a2, a3, 0
+ movi a2, g_pstVosTCBCur
+ l32i a3, a4, 0
+ l32i sp, a3, OSTCBStkPtr
+ s32i a3, a2, 0
+
+
+ l32i a2, sp, XT_STK_EXIT
+ bnez a2, .L_in_int
+
+
+ l32i a3, sp, XT_SOL_PS
+ l32i a0, sp, XT_SOL_PC
+
+ rsync
+
+ wsr a3, PS
+ retw
+
+.L_in_int:
+ /* co-processor CPENABLE*/
+ movi a3, g_pstVosTCBCur
+ l32i a3, a3, 0
+ l32i a2, a3, OSTCBStkBottom
+ l8ui a3, a2, XT_CPENABLE
+ wsr a3, CPENABLE
+
+
+ call0 OS_ContextRestore
+ rsync
+
+ l32i a0, sp, XT_STK_EXIT
+ ret
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .globl OS_ContextSave
+ .type OS_ContextSave,@function
+ .align 4
+/*****************************************************************************
+ OS_ContextSave
+*****************************************************************************/
+OS_ContextSave:
+
+ /*1):
+ A2
+ A3
+ A4
+ A5
+ A6
+ A7
+ A8
+ A9
+ A10
+ A11
+ SAR,LBENG,LEND,LCOUNT*/
+ s32i a2, sp, XT_STK_A2
+ s32i a3, sp, XT_STK_A3
+ s32i a4, sp, XT_STK_A4
+ s32i a5, sp, XT_STK_A5
+ s32i a6, sp, XT_STK_A6
+ s32i a7, sp, XT_STK_A7
+ s32i a8, sp, XT_STK_A8
+ s32i a9, sp, XT_STK_A9
+ s32i a10, sp, XT_STK_A10
+ s32i a11, sp, XT_STK_A11
+ s32i a14, sp, XT_STK_A14
+ s32i a15, sp, XT_STK_A15
+
+
+ rsr a3, SAR
+ s32i a3, sp, XT_STK_SAR
+
+ rsr a3, LBEG
+ s32i a3, sp, XT_STK_LBEG
+ rsr a3, LEND
+ s32i a3, sp, XT_STK_LEND
+ rsr a3, LCOUNT
+ s32i a3, sp, XT_STK_LCOUNT
+
+ /*2)*/
+ mov a9, a0
+ s32i a12, sp, XT_STK_TMP+0
+ s32i a13, sp, XT_STK_TMP+4
+ s32i a9, sp, XT_STK_TMP+8
+ l32i a12, sp, XT_STK_A12
+ l32i a13, sp, XT_STK_A13
+ l32i a9, sp, XT_STK_A9
+ addi sp, sp, XT_STK_FRMSZ
+ call0 xthal_window_spill_nw
+ addi sp, sp, -XT_STK_FRMSZ
+ l32i a12, sp, XT_STK_TMP+0
+ l32i a13, sp, XT_STK_TMP+4
+ l32i a9, sp, XT_STK_TMP+8
+
+ addi a2, sp, XT_STK_EXTRA
+ call0 xthal_save_extra_nw
+
+ mov a0, a9
+ ret
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .global OS_ContextRestore
+ .type OS_ContextRestore,@function
+ .align 4
+/*****************************************************************************
+ OS_ContextRestore
+*****************************************************************************/
+OS_ContextRestore:
+ /*
+ 1) xthal_restore_extra_nw*/
+ mov a13, a0
+ addi a2, sp, XT_STK_EXTRA
+ call0 xthal_restore_extra_nw
+ mov a0, a13
+
+ /*2):
+ LBEG
+ LEND
+ LCOUNT
+ A2
+ SAR
+ A3
+ A4
+ A5
+ A6
+ A7
+ A8
+ A9
+ A10
+ A11
+ A12
+ A13
+ A14
+ A15*/
+ l32i a2, sp, XT_STK_LBEG
+ l32i a3, sp, XT_STK_LEND
+ wsr a2, LBEG
+ l32i a2, sp, XT_STK_LCOUNT
+ wsr a3, LEND
+ wsr a2, LCOUNT
+
+ l32i a3, sp, XT_STK_SAR
+ l32i a2, sp, XT_STK_A2
+ wsr a3, SAR
+ l32i a3, sp, XT_STK_A3
+ l32i a4, sp, XT_STK_A4
+ l32i a5, sp, XT_STK_A5
+ l32i a6, sp, XT_STK_A6
+ l32i a7, sp, XT_STK_A7
+ l32i a8, sp, XT_STK_A8
+ l32i a9, sp, XT_STK_A9
+ l32i a10, sp, XT_STK_A10
+ l32i a11, sp, XT_STK_A11
+
+ l32i a12, sp, XT_STK_A12
+ l32i a13, sp, XT_STK_A13
+ l32i a14, sp, XT_STK_A14
+ l32i a15, sp, XT_STK_A15
+
+ ret
+
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .globl OS_IntEnter
+ .type OS_IntEnter,@function
+ .align 4
+OS_IntEnter:
+
+ /* Save a12-13 in the stack frame as required by _xt_context_save. */
+ s32i a12, sp, XT_STK_A12
+ s32i a13, sp, XT_STK_A13
+
+ /* Save return address in a safe place (free a0). */
+ mov a12, a0
+
+ /* Save the rest of the interrupted context (preserves A12-13). */
+ call0 OS_ContextSave
+
+ /*
+ Save interrupted task's SP in TCB only if not nesting.
+ Manage nesting directly rather than call the generic OSIntEnter()
+ (in windowed ABI we can't call a C function here anyway because PS.EXCM is still set).
+ */
+ movi a2, g_bVosRunning
+ movi a3, g_ucVosIntNesting
+ l8ui a2, a2, 0 /* if (g_bVosRunning == OS_TRUE) { */
+ beqz a2, 2f
+ l8ui a2, a3, 0 /* if (g_ucVosIntNesting == 0) { */
+ bnez a2, 1f
+ movi a4, g_pstVosTCBCur
+ l32i a4, a4, 0
+ s32i sp, a4, OSTCBStkPtr /* g_pstVosTCBCur->OSTCBStkPtr = SP; */
+1: /* } */
+ addi a2, a2, 1 /* if (g_ucVosIntNesting < 255u) { */
+ bgeui a2, 256, 2f /* g_ucVosIntNesting++; */
+ s8i a2, a3, 0 /* } */
+2: /* } */
+
+ /* Retrieve the return address and return to interrupt handler. */
+ mov a0, a12
+ ret
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .globl OS_IntExit
+ .type OS_IntExit,@function
+ .align 4
+OS_IntExit:
+#if 0
+ /* Call VOSIntExit() to deal with nesting and call the scheduler. */
+ movi a2, VOSIntExit
+
+ rsil a0, XCHAL_EXCM_LEVEL /* enter critical section */
+ callx4 a2 /* VOSIntExit() */
+#endif
+ /* Context-switch deferred from OSIntCtxSw(). Still in critical section. */
+ movi a2, OSIntCtxSw_Occur
+ l8ui a3, a2, 0
+ beqz a3, 1f /* if (OSIntCtxSw_Occur) { */
+ movi a3, 0 /* OSIntCtxSw_Occur = false; */
+ s8i a3, a2, 0
+ call0 OS_TaskSwitch /* tail-call dispatcher; */
+ /* Never returns here. */ /* } */
+1:
+
+ /*
+ We come here only if there was no context switch, that is if this
+ is a nested interrupt or the interrupted task was not preempted.
+ We are still on the same stack so there's no need to load the SP.
+ */
+
+ /* Restore full context from interrupt stack frame and return to exit dispatcher. */
+ call0 OS_ContextRestore
+
+ /*
+ Must return via the exit dispatcher corresponding to the entrypoint from which
+ this was called. Interruptee's A0, A1, PS, PC are restored and the interrupt
+ stack frame is deallocated in the exit dispatcher.
+ */
+ l32i a0, sp, XT_STK_EXIT
+ ret
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .globl OS_GetTaskCoprocState
+ .type OS_GetTaskCoprocState,@function
+ .align 4
+OS_GetTaskCoprocState:
+
+ movi a2, g_bVosRunning
+ movi a3, g_ucVosIntNesting
+ l8ui a2, a2, 0
+ l8ui a3, a3, 0
+ beqz a2, 1f
+ bnez a3, 1f
+ movi a15, g_pstVosTCBCur
+ l32i a15, a15, 0
+ beqz a15, 2f
+ l32i a15, a15, OSTCBStkBottom
+ ret
+
+1: movi a15, 0
+2: ret
+ .end literal_prefix
+
+
diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/cpu_c.c b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/cpu_c.c
new file mode 100644
index 00000000..12ce8b71
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/cpu_c.c
@@ -0,0 +1,152 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+
+#include "cpu_c.h"
+#include <xtensa/config/specreg.h>
+#include <xtensa/config/core.h>
+#include <xtensa/simcall.h>
+#include "arch_hifi330.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif
+#endif
+
+/*lint -e838 -e835 -e750 -e529 -e533 -e40*/
+
+//#define DSP_TRACES_TO_MEM_SIZE (0x800)
+
+void *g_pfVosHookFuncTable[OS_HOOK_TYPE_BUTT];
+
+void *g_pfVosIntrFuncTable[OS_INTR_CONNECT_BUTT];
+
+//unsigned int g_uwSoftIntInfo = 0;
+
+/* Interrupt nesting level */
+unsigned char g_ucVosIntNesting;
+
+/* Priority of current task */
+unsigned char g_ucVosPrioCur;
+
+/* Priority of highest priority task */
+unsigned char g_ucVosPrioHighRdy;
+
+/* Flag indicating that kernel is running */
+unsigned short g_bVosRunning;
+
+/* Pointer to highest priority TCB R-to-R */
+unsigned int *g_pstVosTCBHighRdy;
+
+/* Pointer to currently running TCB*/
+unsigned int *g_pstVosTCBCur;
+
+#define _XTSTR(x) #x
+#define XTSTR(x) _XTSTR(x)
+
+void OS_EnterIntHook(unsigned int uhwIntrNo)
+{
+ INTR_HOOK_FUN_TYPE pfIntrHook = (INTR_HOOK_FUN_TYPE)g_pfVosHookFuncTable[OS_HOOK_TYPE_ENTER_INTR];/*lint !e611*/
+
+ if (0 != pfIntrHook)
+ {
+ pfIntrHook(uhwIntrNo);
+ }
+}
+
+void OS_ExitIntHook(unsigned int uhwIntrNo)
+{
+ INTR_HOOK_FUN_TYPE pfIntrHook = (INTR_HOOK_FUN_TYPE)g_pfVosHookFuncTable[OS_HOOK_TYPE_EXIT_INTR];/*lint !e611*/
+
+ if (0 != pfIntrHook)
+ {
+ pfIntrHook(uhwIntrNo);
+ }
+}
+
+void OS_UserexecHandler(unsigned int uwExecCauseNo, unsigned int psAddr)
+{
+ VOS_EXCEPTION_HOOK_FUNC pfIntrHook = (VOS_EXCEPTION_HOOK_FUNC)g_pfVosHookFuncTable[OS_HOOK_TYPE_EXCEPTION];/*lint !e611*/
+
+ if (0 != pfIntrHook)
+ {
+ pfIntrHook(uwExecCauseNo);
+ }
+ else
+ {
+ extern void OS_Panic(void);
+ OS_Panic();
+ }
+}
+
+void OS_InterruptHandler(unsigned int uhwIntrNo)
+{
+ HOOK_FUN_TYPE pfIntrHook = (HOOK_FUN_TYPE)g_pfVosIntrFuncTable[uhwIntrNo];
+
+ if (0 != pfIntrHook)
+ //pfIntrHook();
+ pfIntrHook(0);
+}
+
+void OS_NmiHook(unsigned int uwExecCauseNo, unsigned int psAddr)
+{
+ HOOK_FUN_TYPE pfNmiHook = (HOOK_FUN_TYPE)g_pfVosHookFuncTable[OS_HOOK_TYPE_NMI];/*lint !e611*/
+
+ if (0 != pfNmiHook)
+ {
+ //pfNmiHook();
+ pfNmiHook(0);
+ }
+
+ //wait for hifi reset
+ UCOM_SET_WFI_NMI(5);
+}
+
+void VOS_ConnectInterrupt(unsigned int uwIntrNo, HOOK_FUN_TYPE pfnInterruptHook)
+{
+ g_pfVosIntrFuncTable[uwIntrNo] = (void *)pfnInterruptHook;/*lint !e611*/
+}
+
+void VOS_EnableInterrupt(unsigned int uwIntNo)
+{
+ unsigned int uwBitEnable;
+
+ uwBitEnable = xthal_get_intenable();
+ xthal_set_intenable(uwBitEnable | (((unsigned int)1) << uwIntNo ));
+
+}
+void VOS_DisableInterrupt(unsigned int uwIntNo)
+{
+ unsigned int uwBitEnable;
+
+ uwBitEnable = xthal_get_intenable();
+ xthal_set_intenable(uwBitEnable | (((unsigned int)0) << uwIntNo ));
+
+}
+
+#ifdef __cplusplus
+ #if __cplusplus
+ }
+ #endif
+#endif
+
diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_comm.c b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_comm.c
new file mode 100644
index 00000000..290ca9dd
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_comm.c
@@ -0,0 +1,75 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#include "dsp_comm.h"
+
+void dsp_memcpy(void *d, void *s, unsigned int size)
+{
+ unsigned char *dest = (unsigned char*)d;
+ unsigned char *src = (unsigned char*)s;
+
+ if (s == d) {
+ return;
+ } else if (src > dest) {
+ for (; dest < ((unsigned char*)d + size); dest++) {
+ *dest = *src;
+ src++;
+ }
+ } else {
+ src = src + (size - 1);
+ for (dest = dest + (size - 1); dest >= (unsigned char*)d; dest--) {
+ *dest = *src;
+ src--;
+ }
+ }
+}
+
+
+void dsp_memset(void *d, unsigned char ucData, unsigned int size)
+{
+ unsigned int i;
+ unsigned char *dest = (unsigned char*)d;
+
+ for(i = 0; i < size; i++)
+ *dest++ = ucData;
+}
+int division(int a, int b)
+{
+ const int bits_in_word_m1 = (int)(sizeof(int) * 8) - 1;
+ int s_a = a >> bits_in_word_m1; /* s_a = a < 0 ? -1 : 0 */
+ int s_b = b >> bits_in_word_m1; /* s_b = b < 0 ? -1 : 0 */
+ a = (a ^ s_a) - s_a; /* negate if s_a == -1 */
+ b = (b ^ s_b) - s_b; /* negate if s_b == -1 */
+ s_a ^= s_b; /* sign of quotient */
+ /*
+ * On CPUs without unsigned hardware division support,
+ * this calls __udivsi3 (notice the cast to su_int).
+ * On CPUs with unsigned hardware division support,
+ * this uses the unsigned division instruction.
+ */
+ return ((int)a/(int)b ^ s_a) - s_a; /* negate if s_a == -1 */
+
+}
+
+
+
+
diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_debug.c b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_debug.c
new file mode 100644
index 00000000..a74308e4
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/dsp_debug.c
@@ -0,0 +1,468 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include "dsp_debug.h"
+#include "dsp_memory_config.h"
+#include "dsp_driver_mailbox.h"
+#include "dsp_comm.h"
+#include "dsp_pcm_gain.h"
+extern int g_pcm_gain;
+extern int MsgFlag;
+extern int InpBuf[HOLD_BUF_SIZE]; // assumes 32 bit samples.
+extern int OutBuf[HOLD_BUF_SIZE]; // assumes 32 bit samples.
+
+static int hex2asc(int n)
+{
+ n &= 15;
+ if(n > 9){
+ return ('a' - 10) + n;
+ } else {
+ return '0' + n;
+ }
+}
+
+static void xputs(const char *s, void (*xputc)(unsigned n, void *cookie), void *cookie)
+{
+ while (*s) {
+ xputc(*s++, cookie);
+ }
+}
+
+void __xprintf(const char *fmt, va_list ap,void (*xputc)(unsigned n, void *cookie), void *cookie)
+{
+ char scratch[32];
+ for(;;){
+ switch(*fmt){
+ case 0:
+ va_end(ap);
+ return;
+ case '%':
+ switch(fmt[1]) {
+ case 'c': {
+ unsigned n = va_arg(ap, unsigned);
+ xputc(n, cookie);
+ fmt += 2;
+ continue;
+ }
+ case 'h': {
+ unsigned n = va_arg(ap, unsigned);
+ xputc(hex2asc(n >> 12), cookie);
+ xputc(hex2asc(n >> 8), cookie);
+ xputc(hex2asc(n >> 4), cookie);
+ xputc(hex2asc(n >> 0), cookie);
+ fmt += 2;
+ continue;
+ }
+ case 'b': {
+ unsigned n = va_arg(ap, unsigned);
+ xputc(hex2asc(n >> 4), cookie);
+ xputc(hex2asc(n >> 0), cookie);
+ fmt += 2;
+ continue;
+ }
+ case 'p':
+ case 'X':
+ case 'x': {
+ unsigned n = va_arg(ap, unsigned);
+ char *p = scratch + 15;
+ *p = 0;
+ do {
+ *--p = hex2asc(n);
+ n = n >> 4;
+ } while(n != 0);
+ while(p > (scratch + 7)) *--p = '0';
+ xputs(p, xputc, cookie);
+ fmt += 2;
+ continue;
+ }
+ case 'd': {
+ int n = va_arg(ap, int);
+ char *p = scratch + 15;
+ *p = 0;
+ if(n < 0) {
+ xputc('-', cookie);
+ n = -n;
+ }
+ do {
+ *--p = (n % 10) + '0';
+ n /= 10;
+ } while(n != 0);
+ xputs(p, xputc, cookie);
+ fmt += 2;
+ continue;
+ }
+
+ case 'f': {
+ double fnum = va_arg(ap, double);
+ unsigned long long ipart, fpart;
+ int i=4;
+ char *p = scratch + 31;
+ *p = '\0';
+
+ if(fnum < 0.0)
+ {
+ xputc('-', cookie);
+ fnum = -fnum;
+ }
+ ipart = (unsigned long long)fnum;
+ fpart = ((fnum-ipart)*10000); //10^i = 10000
+
+ while(i>0)
+ {
+ *--p = (fpart % 10) + '0';
+ fpart /= 10;
+ i--;
+ }
+ *--p = '.';
+ while(ipart > 0)
+ {
+ *--p = (ipart % 10) + '0';
+ ipart /= 10;
+ }
+
+ xputs(p, xputc, cookie);
+ fmt += 2;
+ continue;
+ }
+
+ case 'u': {
+ unsigned n = va_arg(ap, unsigned);
+ char *p = scratch + 15;
+ *p = 0;
+ do {
+ *--p = (n % 10) + '0';
+ n /= 10;
+ } while(n != 0);
+ xputs(p, xputc, cookie);
+ fmt += 2;
+ continue;
+ }
+ case 's': {
+ char *s = (char *)va_arg(ap, char*);
+ if(s == 0) s = "(null)";
+ xputs(s, xputc, cookie);
+ fmt += 2;
+ continue;
+ }
+ case 'l': {
+ if (fmt[2] == 'x') {
+ unsigned long long n = va_arg(ap, unsigned long long);
+ char *p = scratch + 23;
+ *p = 0;
+ do {
+ *--p = hex2asc((int)n);
+ n = n >> 4;
+ } while(n != 0);
+ while(p > (scratch + 7)) *--p = '0';
+ xputs(p, xputc, cookie);
+ fmt += 3;
+ continue;
+ }
+ }
+ }
+ xputc(*fmt++, cookie);
+ break;
+ case '\n':
+ xputc('\r', cookie);
+ default:
+ xputc(*fmt++, cookie);
+ }
+ }
+}
+
+static char* log_to_mem_head = 0;
+void dsp_debug_init()
+{
+ log_to_mem_head = (char *)(*((unsigned int *)DRV_DSP_UART_TO_MEM_CUR_ADDR) + DRV_DSP_UART_TO_MEM);
+
+}
+
+static void log_write_to_mem(const char c_data)
+{
+ *log_to_mem_head = c_data;
+
+ log_to_mem_head++;
+ if ((unsigned int)log_to_mem_head >= (DRV_DSP_UART_TO_MEM + DRV_DSP_UART_TO_MEM_SIZE - 1))
+ log_to_mem_head = (char *)DRV_DSP_UART_TO_MEM + DRV_DSP_UART_TO_MEM_RESERVE_SIZE;
+
+ *((unsigned int *)DRV_DSP_UART_TO_MEM_CUR_ADDR) = (unsigned int)log_to_mem_head - DRV_DSP_UART_TO_MEM;
+}
+
+
+static void print_char(const char c_data)
+{
+ if (c_data == '\n')
+ log_write_to_mem('\r');
+ log_write_to_mem(c_data);
+}
+
+typedef void (*xputc_type)(unsigned n, void *cookie);
+
+void print_log(const char *fmt, ...)
+{
+ va_list args;
+va_start(args, fmt);
+ __xprintf(fmt, args, (xputc_type)print_char, 0);
+ va_end(args);
+}
+#ifdef HIKEY_XAF_IPC_COMMENT_OUT
+#define ISSPACE(c) (c == ' ' || c == 0x09 || c == 0x0A || c == 0x0D || c == 0)
+
+char* dsp_om_trim_zero(char* str)
+{
+ char *str_begin = 0;
+ char *str_end = 0;
+
+ if (!str)
+ return 0;
+
+ str_begin = str;
+ str_end = str + strlen(str);
+
+ while (str_begin < str_end) {
+ if (ISSPACE(*str_begin)) {
+ *str_begin = 0;
+ str_begin++;
+ } else {
+ break;
+ }
+ }
+ while (str_begin < str_end) {
+ if (ISSPACE(*str_end)) {
+ *str_end = 0;
+ str_end--;
+ } else {
+ break;
+ }
+ }
+
+ return str_begin;
+}
+
+char * dsp_om_split_str(char* str, char** split_str)
+{
+ char *str_begin = 0;
+ char *str_end = 0;
+
+ if ((!str) || (!split_str)) {
+ DSP_LOGE("input param is null\n");
+ return str;
+ }
+
+ str_end = str + strlen(str);
+ str_begin = dsp_om_trim_zero(str);
+
+ if (str_begin == str_end) {
+ DSP_LOGE("input str all space\n");
+ return 0;
+ }
+
+ *split_str = dsp_om_trim_zero(strchr(str_begin, ' '));
+
+ return str_begin;
+}
+
+#ifdef GJB_CHANGE
+void send_msg_data_to_ap()
+{
+
+ struct hikey_msg_with_content hikey_msg;
+ DSP_LOGE("%s\n", __func__);
+ hikey_msg.msg_info.msg_id=HIKEY_AUDIO_DSP_AP_OM_CMD;
+ hikey_msg.msg_info.msg_len=HIKEY_AP_DSP_MSG_MAX_LEN;
+ strncpy(hikey_msg.msg_info.msg_content,"pcm_gain",HIKEY_AP_DSP_MSG_MAX_LEN);
+ dsp_mailbox_write(&hikey_msg);
+ DSP_LOGE("Exit %s\n", __func__);
+}
+
+void send_pcm_data_to_ap()
+{
+ struct hikey_ap_dsp_msg_body msg_info;
+ DSP_LOGE("Enter %s\n", __func__);
+ msg_info.msg_id = ID_XAF_DSP_TO_AP;
+ msg_info.msg_len = sizeof(msg_info);
+ msg_info.xf_dsp_msg.id= 0;
+ msg_info.xf_dsp_msg.opcode = 0xc;
+ msg_info.xf_dsp_msg.length = 0x400;
+ msg_info.xf_dsp_msg.address = 0x8B432000;
+ dsp_mailbox_write(&msg_info);
+ DSP_LOGE("Exit %s\n", __func__);
+}
+#else
+void send_msg_data_to_ap()
+{
+ xf_proxy_message_t hikey_msg;
+ DSP_LOGE("%s\n", __func__);
+ hikey_msg.id=HIKEY_AUDIO_DSP_AP_OM_CMD;
+ hikey_msg.length=HIKEY_AP_DSP_MSG_MAX_LEN;
+ strncpy(hikey_msg.address,"pcm_gain",HIKEY_AP_DSP_MSG_MAX_LEN);
+ dsp_mailbox_write(&hikey_msg);
+ DSP_LOGE("Exit %s\n", __func__);
+}
+
+void send_pcm_data_to_ap()
+{
+ xf_proxy_message_t msg_info;
+ DSP_LOGE("Enter %s\n", __func__);
+ msg_info.id = ID_XAF_DSP_TO_AP;
+ msg_info.opcode = 0xc;
+ msg_info.length = 0x400;
+ msg_info.address = 0x8B432000;
+ dsp_mailbox_write(&msg_info);
+ DSP_LOGE("Exit %s\n", __func__);
+}
+#endif
+static void dsp_om_read_mem(char *str)
+{
+ unsigned int addr = 0;
+ unsigned int val = 0;
+ if (!str) {
+ DSP_LOGE("str is null\n");
+ return;
+ }
+
+ addr = strtoul(str, 0, 16);
+ DSP_LOGD("str:%s addr:0x%x\n", str, addr);
+
+ val = *(unsigned int*)addr;
+ send_pcm_data_to_ap();
+//send_msg_data_to_ap();
+ dsp_ipc_send_irq_to_ap();
+ DSP_LOGI("read addr:0x%x value:0x%x\n", addr, val);
+ return;
+}
+
+static void dsp_om_write_mem(char *str)
+{
+ char* str_addr = 0;
+ char* str_val = 0;
+ unsigned int addr = 0;
+ unsigned int val = 0;
+ if (!str) {
+ DSP_LOGE("str is null\n");
+ return;
+ }
+
+ str_addr = dsp_om_split_str(str, &str_val);
+
+ if(!str_addr || !str_val) {
+ DSP_LOGE("str:%s str_addr:%s strValue:%s\n", str, str_addr ? str_addr : "null", str_val ? str_val : "null");
+ return;
+ }
+ addr = strtoul(str_addr, 0, 16);
+ val= strtoul(str_val, 0, 16);
+ DSP_LOGI("str_addr:%s addr:%x str_val:%s val:%x\n", str_addr ? str_addr : "null", addr, str_val ? str_val : "null", val);
+
+ *(unsigned int *)addr = val;
+
+ return;
+
+}
+
+static void dsp_om_pcm_gain(char *str)
+{
+ char* str_addr = 0;
+ char* str_val = 0;
+ unsigned int addr = 0;
+ unsigned int val = 0;
+ if (!str) {
+ DSP_LOGE("str is null\n");
+ return;
+ }
+ str_addr = dsp_om_split_str(str, &str_val);
+ if(!str_addr || !str_val) {
+ DSP_LOGE("str:%s str_addr:%s strValue:%s\n", str, str_addr ? str_addr : "null", str_val ? str_val : "null");
+ return;
+ }
+ addr = strtoul(str_addr, 0, 16);
+ val= strtoul(str_val, 0, 16);
+ DSP_LOGI("str_addr:%s addr:%x str_val:%s val:%x\n", str_addr ? str_addr : "null", addr, str_val ? str_val : "null", val);
+ if(ReadData((char*)InpBuf, val) ){
+ processAudio(OutBuf, InpBuf, (val/4));
+ if(WriteData((char*)OutBuf, val)) {
+ MsgFlag = MSG_PROC; // indicate that the msg is processed.
+ DSP_LOGI("PCM gain processed\n");
+ send_msg_data_to_ap();
+ dsp_ipc_send_irq_to_ap(); // Indicate data is ready to pickup... Maybe you need to send a msg to AP.
+ }
+ else {
+ DSP_LOGI("PCM gain Write error\n");
+ MsgFlag = MSG_INCOMP;
+ dsp_ipc_send_irq_to_ap();// Report error..
+ }
+ }
+ else {
+ DSP_LOGI("PCM gain Read error\n");
+ MsgFlag = MSG_INCOMP;
+ dsp_ipc_send_irq_to_ap();
+ }
+ return;
+}
+typedef void (*om_proc_func)(char *str);
+
+struct om_proc_info {
+ char *om_proc_name;
+ om_proc_func func;
+};
+
+struct om_proc_info om_proc_table[] = {
+ {"read_mem", dsp_om_read_mem},
+ {"write_mem", dsp_om_write_mem},
+ {"pcm_gain", dsp_om_pcm_gain},
+};
+
+om_proc_func dsp_om_get_func_by_name(char *name)
+{
+ unsigned int i = 0;
+ unsigned int func_num = sizeof(om_proc_table) / sizeof(om_proc_table[0]);
+
+ if (!name) {
+ DSP_LOGE("name is null\n");
+ return 0;
+ }
+
+ for (i = 0; i < func_num; i++)
+ if (!strncmp((char *)om_proc_table[i].om_proc_name, name, strlen((char *)om_proc_table[i].om_proc_name)))
+ return om_proc_table[i].func;
+
+ return 0;
+}
+
+void dsp_om_func_proc(char *om_str, unsigned int str_len)
+{
+ char * cmd_name = 0;
+ char * str_param = 0;
+ om_proc_func proc_func = 0;
+
+ cmd_name = dsp_om_split_str((char *)om_str, &str_param);
+
+ DSP_LOGI("cmd_name:%s\n", cmd_name);
+ proc_func = dsp_om_get_func_by_name(cmd_name);
+ if (proc_func)
+ proc_func(str_param);
+ else
+ DSP_LOGE("do not find func\n");
+}
+#endif
+
diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/int_vector.S b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/int_vector.S
new file mode 100644
index 00000000..d579a55e
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/int_vector.S
@@ -0,0 +1,830 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/******************************************************************************
+ int_vector.S
+******************************************************************************/
+#include <xtensa/coreasm.h>
+#include <xtensa/corebits.h>
+#include <xtensa/config/system.h>
+#include <xtensa/simcall.h>
+#include "arch_hifi330.h"
+
+// .data
+ .section .dram0.data, "aw"
+/* CP */
+ .type g_awVosCoprocSaOffset,@object
+ .align 16 /* minimize crossing cache boundaries */
+g_awVosCoprocSaOffset:
+ .word XT_CP0_SA, XT_CP1_SA, XT_CP2_SA, XT_CP3_SA
+ .word XT_CP4_SA, XT_CP5_SA, XT_CP6_SA, XT_CP7_SA
+
+/* CP n's CPENABLE bit. */
+ .type g_bVosCoprocMask,@object
+ .align 16,,8 /* try to keep it all in one cache line */
+g_bVosCoprocMask:
+ .byte 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80
+
+/* Owner of CP (0 = unowned). */
+ .global g_awVosCoprocOwnerSa
+ .type g_awVosCoprocOwnerSa,@object
+ .align 16,,XCHAL_CP_MAX<<2 /* minimize crossing cache boundaries */
+g_awVosCoprocOwnerSa:
+ .space XCHAL_CP_MAX << 2,0
+
+ .global g_strVosPanicMessage
+ .align 4
+g_strVosPanicMessage:
+ .string "\npanic at addr 0x%08x.\n"
+
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .global OS_Panic
+ .type OS_Panic,@function
+ .align 4
+/*****************************************************************************
+ OS_Panic
+*****************************************************************************/
+OS_Panic:
+
+#ifdef ZOS_SIM
+ /*panic at addr*/
+ addi a4, a0, -3 /* point to call0 */
+ movi a3, g_strVosPanicMessage
+ movi a2, SYS_log_msg
+ simcall
+ movi a2, SYS_gdb_abort
+ simcall
+#else
+ /*low & med*/
+ rsil a2, XCHAL_EXCM_LEVEL /* disable all low & med ints */
+1: j 1b /* loop infinitely */
+#endif
+
+ .end literal_prefix
+
+ .begin literal_prefix .DebugExceptionVector
+ .section .DebugExceptionVector.text, "ax"
+ .global OS_DebugExceptionVector
+ .align 4
+/*****************************************************************************
+_DebugExceptionVector
+*****************************************************************************/
+OS_DebugExceptionVector:
+#ifdef ZOS_SIM
+ wsr a2, EXCSAVE+XCHAL_DEBUGLEVEL
+ movi a2, SYS_gdb_enter_sktloop
+ simcall
+#else
+ wsr a0, EXCSAVE+XCHAL_DEBUGLEVEL
+ call0 OS_Panic
+ rfi XCHAL_DEBUGLEVEL
+#endif
+
+ .end literal_prefix
+
+
+ .begin literal_prefix .DoubleExceptionVector
+ .section .DoubleExceptionVector.text, "ax"
+ .global OS_DoubleExceptionVector
+ .align 4
+/*****************************************************************************
+ OS_DoubleExceptionVector
+*****************************************************************************/
+OS_DoubleExceptionVector:
+ call0 OS_Panic /* does not return */
+ rfde /* make a0 point here not later */
+
+ .end literal_prefix
+
+
+ .begin literal_prefix .KernelExceptionVector
+ .section .KernelExceptionVector.text, "ax"
+ .global OS_KernelExceptionVector
+ .align 4
+/*****************************************************************************
+ _KernelExceptionVector
+*****************************************************************************/
+OS_KernelExceptionVector:
+ call0 OS_Panic /* does not return */
+ rfe /* make a0 point here not later */
+
+ .end literal_prefix
+
+
+ .begin literal_prefix .UserExceptionVector
+ .section .UserExceptionVector.text, "ax"
+ .global OS_UserExceptionVector
+ .type OS_UserExceptionVector,@function
+ .align 4
+/*****************************************************************************
+ _UserExceptionVector
+*****************************************************************************/
+OS_UserExceptionVector:
+ wsr a0, EXCSAVE_1 /* preserve a0 */
+ call0 OS_UserExc /* user exception handler */
+ /* never returns here - call0 is used as a jump (see note at top) */
+
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+
+ .align 4
+OS_CoProcessorExc:
+ s32i a5, sp, XT_STK_A5 /* save a5 */
+ addi a5, a0, -EXCCAUSE_CP0_DISABLED /* a0 = CP index */
+ bgei a5, XCHAL_CP_MAX, .L_xt_user_exc_not_coproc
+ call0 OS_CoProcessorException /* in window vectors section */
+ /* never returns here - call0 is used as a jump (see note at top) */
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .align 4
+OS_AllocExc:
+ call0 OS_AllocaException /* in window vectors section */
+ /* never returns here - call0 is used as a jump (see note at top) */
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .align 4
+OS_SyscallExc:
+ call0 OS_SyscallException
+ /* never returns here - call0 is used as a jump (see note at top) */
+
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .global OS_UserExc
+ .type OS_UserExc,@function
+ .align 4
+OS_UserExc:
+ rsr a0, EXCCAUSE
+ beqi a0, EXCCAUSE_ALLOCA, OS_AllocExc
+ beqi a0, EXCCAUSE_SYSCALL, OS_SyscallExc
+
+ mov a0, sp /* sp == a1 */
+ addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */
+ s32i a0, sp, XT_STK_A1 /* save pre-interrupt SP */
+ rsr a0, PS /* save interruptee's PS */
+ s32i a0, sp, XT_STK_PS
+ rsr a0, EPC_1 /* save interruptee's PC */
+ s32i a0, sp, XT_STK_PC
+ rsr a0, EXCSAVE_1 /* save interruptee's a0 */
+ s32i a0, sp, XT_STK_A0
+ movi a0, OS_UserExit /* save exit point for dispatch */
+ s32i a0, sp, XT_STK_EXIT
+
+ rsr a0, EXCCAUSE
+ bgeui a0, EXCCAUSE_CP0_DISABLED, OS_CoProcessorExc
+
+.L_xt_user_exc_not_coproc:
+
+
+ call0 XT_RTOS_INT_ENTER
+
+
+ movi a0, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE
+ wsr a0, PS
+ rsync
+
+ rsr a2, EXCCAUSE
+ beqi a2, EXCCAUSE_LEVEL1INTERRUPT, .L_xt_user_int
+ mov a6,a2
+ mov a7,a1
+ /*User exception*/
+ call4 OS_UserexecHandler
+ j .L_xt_user_done
+
+.L_xt_user_int:
+ /* level 1 int */
+ rsr a2, INTENABLE
+ rsr a3, INTERRUPT
+ movi a4, XCHAL_INTLEVEL1_MASK
+ and a2, a2, a3
+ and a2, a2, a4
+ beqz a2, .L_int_done1
+
+ neg a3,a2
+ and a3,a3,a2
+ wsr a3,INTCLEAR
+
+ find_ls_one a2, a3
+ mov a6,a2
+ call4 OS_EnterIntHook
+
+ mov a6,a2
+ call4 OS_InterruptHandler
+
+ mov a6,a2
+ call4 OS_ExitIntHook
+ j .L_xt_user_int
+
+.L_int_done1:
+
+
+.L_xt_user_done:
+ call0 XT_RTOS_INT_EXIT
+
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .global OS_UserExit
+ .type OS_UserExit,@function
+ .align 4
+OS_UserExit:
+ l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */
+ wsr a0, PS
+ l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */
+ wsr a0, EPC_1
+ l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */
+ l32i sp, sp, XT_STK_A1 /* remove interrupt stack frame */
+ rsync /* ensure PS and EPC written */
+ rfe /* PS.EXCM is cleared */
+
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .type OS_SyscallException,@function
+ .align 4
+/*****************************************************************************
+ OS_SyscallException
+*****************************************************************************/
+OS_SyscallException:
+ addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */
+ s32i a12, sp, XT_STK_A12 /* _xt_context_save requires A12- */
+ s32i a13, sp, XT_STK_A13 /* A13 to have already been saved */
+ call0 OS_ContextSave
+
+
+ /*
+ 2)update PC*/
+ rsr a2, EPC_1
+ addi a3, a2, 3
+
+ rsr a0, LEND
+ bne a3, a0, 1f
+ rsr a0, LCOUNT
+ beqz a0, 1f
+ addi a0, a0, -1
+ rsr a3, LBEG
+ wsr a0, LCOUNT
+
+1: wsr a3, EPC_1
+
+ /* Restore context,exception */
+ call0 OS_ContextRestore
+ addi sp, sp, XT_STK_FRMSZ
+
+ movi a0, -1
+ movnez a2, a0, a2 /* return -1 if not syscall 0 */
+ rsr a0, EXCSAVE_1
+ rfe
+
+
+
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .type OS_CoProcessorException,@function
+ .align 4
+/*****************************************************************************
+ OS_CoProcessorException
+*****************************************************************************/
+OS_CoProcessorException: /* a5 = CP index */
+
+ s32i a2, sp, XT_STK_A2
+ s32i a3, sp, XT_STK_A3
+ s32i a4, sp, XT_STK_A4
+ s32i a15, sp, XT_STK_A15
+
+
+ /* co-processor old owner new owner. */
+ call0 XT_RTOS_CP_STATE /* a15 = new owner's save area */
+ beqz a15, .L_xt_coproc_invalid /* not in a thread (invalid) */
+
+ mov a0, a5 /* a0 = CP index */
+ movi a3, g_awVosCoprocOwnerSa
+ addx4 a3, a0, a3 /* a3 = &g_awVosCoprocOwnerSa[CP] */
+ l32i a2, a3, 0 /* a2 = old owner's save area */
+
+ /* Enable the co-processor's bit in CPENABLE. */
+ movi a4, g_bVosCoprocMask
+ rsr a5, CPENABLE /* a5 = CPENABLE */
+ add a4, a4, a0
+ l8ui a4, a4, 0 /* a4 = bitmask from CP index */
+ or a5, a5, a4 /* a5 = CPENABLE + CP */
+ wsr a5, CPENABLE
+
+
+ beq a15, a2, .L_xt_coproc_done /* new owner == old, we're done */
+
+ s32i a15, a3, 0 /* g_awVosCoprocOwnerSa[CP] = new */
+
+ l8ui a5, a15, XT_CPSTORED /* a5 = new owner's old CPSTORED */
+ neg a3, a4
+ addi a3, a3, -1 /* a3 = ~a4 (bitmask for CP) */
+ and a3, a5, a3 /* clr CP in new owner's CPSTORED */
+ s8i a3, a15, XT_CPSTORED /* update new owner's CPSTORED */
+
+ /* Adjust new owner's save area pointers to area for CP n. */
+ movi a3, g_awVosCoprocSaOffset
+ and a5, a5, a4 /* a5 = new owner's CP is stored */
+ addx4 a3, a0, a3 /* a3 = &OS_CoprocSaOffset[CP] */
+ l32i a3, a3, 0 /* a3 = XT_CP[CP]_SA */
+ add a15, a15, a3 /* a15 = new owner's area for CP */
+ moveqz a15, a5, a5 /* a15 = 0 if state not stored */
+
+ rsync /* ensure wsr.CPENABLE is complete */
+ beqz a2, .L_xt_coproc_new /* no old owner to save */
+
+ /* If old owner still needs CP, clear CP in CPENABLE and set in CPSTORED. */
+ l8ui a5, a2, XT_CPENABLE /* a5 = old owner's CPENABLE */
+ and a4, a5, a4 /* a4 = CP in old owner CPENABLE */
+ beqz a4, .L_xt_coproc_new /* discard old owner's CP state */
+
+ sub a5, a5, a4 /* clr CP in old owner's CPENABLE */
+ s8i a5, a2, XT_CPENABLE /* update old owner's CPENABLE */
+ l8ui a5, a2, XT_CPSTORED /* a5 = old owner's CPSTORED */
+ or a5, a5, a4 /* set CP in old owner's CPSTORED */
+ s8i a5, a2, XT_CPSTORED /* update old owner's CPSTORED */
+
+ /* Save co-processor state of old owner. */
+.Ln_xt_coproc_old:
+ add a2, a2, a3 /* a2 = old owner's area for CP */
+ mov a3, a0 /* a3 = CP index */
+ /*
+ The config-specific HAL macro invoked below destroys a2-5, preserves a0-1.
+ It is theoretically possible for Xtensa processor designers to write TIE
+ that causes more address registers to be affected, but it is generally
+ unlikely. If that ever happens, more registers needs to be saved/restored
+ around this macro invocation, and the value in a15 needs to be recomputed.
+ */
+ xchal_cpi_store_funcbody
+
+ /* Restore co-processor state of new owner. */
+.L_xt_coproc_new:
+ beqz a15, .L_xt_coproc_done /* no valid state to restore */
+ mov a2, a15 /* a2 = new owner's area for CP */
+ mov a3, a0 /* a3 = CP index */
+
+ xchal_cpi_load_funcbody
+
+
+.L_xt_coproc_done:
+ l32i a15, sp, XT_STK_A15
+ l32i a5, sp, XT_STK_A5
+ l32i a4, sp, XT_STK_A4
+ l32i a3, sp, XT_STK_A3
+ l32i a2, sp, XT_STK_A2
+ call0 OS_UserExit
+
+.L_xt_coproc_invalid:
+ call0 OS_Panic /* not in a thread (invalid) */
+ .end literal_prefix
+
+ .begin literal_prefix .Level2InterruptVector
+ .section .Level2InterruptVector.text, "ax"
+ .global OS_Level2Vector
+ .type OS_Level2Vector,@function
+ .align 4
+/*****************************************************************************
+ _Level2Vector
+*****************************************************************************/
+OS_Level2Vector:
+ wsr a0, EXCSAVE_2 /* preserve a0 */
+ call0 OS_Medint2 /* load interrupt handler */
+
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .extern OS_InterruptHandler
+ .type OS_Medint2,@function
+ .align 4
+OS_Medint2:
+
+#movi a1, 0xdeadbeef
+ movi a1, 0xe8075000
+ movi a2, 0xe8075e30 /*HIFI_RESERVE1_LOCATION*/
+ s32i a1, a2, 0
+
+ mov a0, sp /* sp == a1 */
+ addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */
+ s32i a0, sp, XT_STK_A1 /* save pre-interrupt SP */
+ rsr a0, EPS_2 /* save interruptee's PS */
+ s32i a0, sp, XT_STK_PS
+ rsr a0, EPC_2 /* save interruptee's PC */
+ s32i a0, sp, XT_STK_PC
+ rsr a0, EXCSAVE_2 /* save interruptee's a0 */
+ s32i a0, sp, XT_STK_A0
+ movi a0, OS_Medint2Exit /* save exit point for dispatch */
+ s32i a0, sp, XT_STK_EXIT
+
+ call0 XT_RTOS_INT_ENTER
+
+ movi a0, PS_INTLEVEL(2) | PS_UM | PS_WOE
+ wsr a0, PS
+ rsync
+
+
+.L_ProcAllInt2:
+ rsr a2, INTENABLE
+ rsr a3, INTERRUPT
+ movi a4, XCHAL_INTLEVEL2_MASK
+ and a2, a2, a3
+ and a2, a2, a4
+ beqz a2, .L_int_done2
+
+ neg a3,a2
+ and a3,a3,a2
+ wsr a3,INTCLEAR
+
+ find_ls_one a2, a3
+ mov a6,a2
+ call4 OS_EnterIntHook
+
+ mov a6,a2
+ call4 OS_InterruptHandler
+
+ mov a6,a2
+ call4 OS_ExitIntHook
+ j .L_ProcAllInt2
+
+.L_int_done2:
+ call0 XT_RTOS_INT_EXIT
+
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .global OS_Medint2Exit
+ .type OS_Medint2Exit,@function
+ .align 4
+OS_Medint2Exit:
+ /* Restore only level-specific regs (the rest were already restored) */
+ l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */
+ wsr a0, EPS_2
+ l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */
+ wsr a0, EPC_2
+ l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */
+ l32i sp, sp, XT_STK_A1 /* remove interrupt stack frame */
+ rsync /* ensure EPS and EPC written */
+ rfi 2
+ .end literal_prefix
+
+
+ .begin literal_prefix .Level3InterruptVector
+ .section .Level3InterruptVector.text, "ax"
+ .global OS_Level3Vector
+ .type OS_Level3Vector,@function
+ .align 4
+/*****************************************************************************
+ _Level3Vector
+*****************************************************************************/
+OS_Level3Vector:
+ wsr a0, EXCSAVE_3 /* preserve a0 */
+ call0 OS_MedInt3 /* load interrupt handler */
+
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .extern OS_InterruptHandler
+ .type OS_MedInt3,@function
+ .align 4
+OS_MedInt3:
+
+ mov a0, sp /* sp == a1 */
+ addi sp, sp, -XT_STK_FRMSZ /* allocate interrupt stack frame */
+ s32i a0, sp, XT_STK_A1 /* save pre-interrupt SP */
+ rsr a0, EPS_3 /* save interruptee's PS */
+ s32i a0, sp, XT_STK_PS
+ rsr a0, EPC_3 /* save interruptee's PC */
+ s32i a0, sp, XT_STK_PC
+ rsr a0, EXCSAVE_3 /* save interruptee's a0 */
+ s32i a0, sp, XT_STK_A0
+ movi a0, OS_Medint3Exit /* save exit point for dispatch */
+ s32i a0, sp, XT_STK_EXIT
+
+ call0 XT_RTOS_INT_ENTER
+
+ movi a0, PS_INTLEVEL(3) | PS_UM | PS_WOE
+ wsr a0, PS
+ rsync
+
+
+.L_ProcAllInt3:
+ rsr a2, INTENABLE
+ rsr a3, INTERRUPT
+ movi a4, XCHAL_INTLEVEL3_MASK
+ and a2, a2, a3
+ and a2, a2, a4
+ beqz a2, .L_int_done3
+
+ neg a3,a2
+ and a3,a3,a2
+ wsr a3,INTCLEAR
+
+ find_ls_one a2, a3
+ mov a6,a2
+ call4 OS_EnterIntHook
+
+ mov a6,a2
+ call4 OS_InterruptHandler
+
+ mov a6,a2
+ call4 OS_ExitIntHook
+ j .L_ProcAllInt3
+
+.L_int_done3:
+
+ call0 XT_RTOS_INT_EXIT
+
+ .end literal_prefix
+
+ .begin literal_prefix .iram0
+ .section .iram0.text, "ax"
+ .global OS_Medint3Exit
+ .type OS_Medint3Exit,@function
+ .align 4
+OS_Medint3Exit:
+ /* Restore only level-specific regs (the rest were already restored) */
+ l32i a0, sp, XT_STK_PS /* retrieve interruptee's PS */
+ wsr a0, EPS_3
+ l32i a0, sp, XT_STK_PC /* retrieve interruptee's PC */
+ wsr a0, EPC_3
+ l32i a0, sp, XT_STK_A0 /* retrieve interruptee's A0 */
+ l32i sp, sp, XT_STK_A1 /* remove interrupt stack frame */
+ rsync /* ensure EPS and EPC written */
+ rfi 3
+ .end literal_prefix
+
+
+ .begin literal_prefix .NMIExceptionVector
+ .section .NMIExceptionVector.text, "ax"
+ .global OS_NMIExceptionVector
+ .align 8
+/*****************************************************************************
+ OS_NMIExceptionVector
+*****************************************************************************/
+OS_NMIExceptionVector:
+ /*wsr a3, 213
+ wsr a4, 214*/
+
+ /*movi a3, 0x0
+ movi a4, 0xf711a510
+ s32i a3, a4, 0*/
+
+ /*rsr a3, 213
+ rsr a4, 214*/
+
+ movi a0, PS_INTLEVEL(3) | PS_UM | PS_WOE
+ wsr a0, PS
+ rsync
+ rsr a2, EXCCAUSE
+ mov a6,a2
+ mov a7,a1
+ call4 OS_NmiHook
+
+ rfi XCHAL_NMILEVEL
+
+ .end literal_prefix
+
+ .section .WindowVectors.text, "ax"
+
+/*
+--------------------------------------------------------------------------------
+Window Overflow Exception for Call4.
+
+Invoked if a call[i] referenced a register (a4-a15)
+that contains data from ancestor call[j];
+call[j] had done a call4 to call[j+1].
+On entry here:
+ window rotated to call[j] start point;
+ a0-a3 are registers to be saved;
+ a4-a15 must be preserved;
+ a5 is call[j+1]'s stack pointer.
+--------------------------------------------------------------------------------
+*/
+
+ .org 0x0
+ .global _WindowOverflow4
+_WindowOverflow4:
+
+ s32e a0, a5, -16 /* save a0 to call[j+1]'s stack frame */
+ s32e a1, a5, -12 /* save a1 to call[j+1]'s stack frame */
+ s32e a2, a5, -8 /* save a2 to call[j+1]'s stack frame */
+ s32e a3, a5, -4 /* save a3 to call[j+1]'s stack frame */
+ rfwo /* rotates back to call[i] position */
+
+/*
+--------------------------------------------------------------------------------
+Window Underflow Exception for Call4
+
+Invoked by RETW returning from call[i+1] to call[i]
+where call[i]'s registers must be reloaded (not live in ARs);
+where call[i] had done a call4 to call[i+1].
+On entry here:
+ window rotated to call[i] start point;
+ a0-a3 are undefined, must be reloaded with call[i].reg[0..3];
+ a4-a15 must be preserved (they are call[i+1].reg[0..11]);
+ a5 is call[i+1]'s stack pointer.
+--------------------------------------------------------------------------------
+*/
+
+ .org 0x40
+ .global _WindowUnderflow4
+_WindowUnderflow4:
+
+ l32e a0, a5, -16 /* restore a0 from call[i+1]'s stack frame */
+ l32e a1, a5, -12 /* restore a1 from call[i+1]'s stack frame */
+ l32e a2, a5, -8 /* restore a2 from call[i+1]'s stack frame */
+ l32e a3, a5, -4 /* restore a3 from call[i+1]'s stack frame */
+ rfwu
+
+ .global OS_AllocaException
+ .align 4
+/*****************************************************************************
+ OS_AllocaException
+*****************************************************************************/
+OS_AllocaException:
+
+ rsr a0, WINDOWBASE /* grab WINDOWBASE before rotw changes it */
+ rotw -1 /* WINDOWBASE goes to a4, new a0-a3 are scratch */
+ rsr a2, PS
+ extui a3, a2, XCHAL_PS_OWB_SHIFT, XCHAL_PS_OWB_BITS
+ xor a3, a3, a4 /* bits changed from old to current windowbase */
+ rsr a4, EXCSAVE_1 /* restore original a0 (now in a4) */
+ slli a3, a3, XCHAL_PS_OWB_SHIFT
+ xor a2, a2, a3 /* flip changed bits in old window base */
+ wsr a2, PS /* update PS.OWB to new window base */
+ rsync
+
+ _bbci.l a4, 31, _WindowUnderflow4
+ rotw -1 /* original a0 goes to a8 */
+ _bbci.l a8, 30, _WindowUnderflow8
+ rotw -1
+ j _WindowUnderflow12
+
+
+
+/*
+--------------------------------------------------------------------------------
+Window Overflow Exception for Call8
+
+Invoked if a call[i] referenced a register (a4-a15)
+that contains data from ancestor call[j];
+call[j] had done a call8 to call[j+1].
+On entry here:
+ window rotated to call[j] start point;
+ a0-a7 are registers to be saved;
+ a8-a15 must be preserved;
+ a9 is call[j+1]'s stack pointer.
+--------------------------------------------------------------------------------
+*/
+
+ .org 0x80
+ .global _WindowOverflow8
+_WindowOverflow8:
+
+ s32e a0, a9, -16 /* save a0 to call[j+1]'s stack frame */
+ l32e a0, a1, -12 /* a0 <- call[j-1]'s sp
+ (used to find end of call[j]'s frame) */
+ s32e a1, a9, -12 /* save a1 to call[j+1]'s stack frame */
+ s32e a2, a9, -8 /* save a2 to call[j+1]'s stack frame */
+ s32e a3, a9, -4 /* save a3 to call[j+1]'s stack frame */
+ s32e a4, a0, -32 /* save a4 to call[j]'s stack frame */
+ s32e a5, a0, -28 /* save a5 to call[j]'s stack frame */
+ s32e a6, a0, -24 /* save a6 to call[j]'s stack frame */
+ s32e a7, a0, -20 /* save a7 to call[j]'s stack frame */
+ rfwo /* rotates back to call[i] position */
+
+/*
+--------------------------------------------------------------------------------
+Window Underflow Exception for Call8
+
+Invoked by RETW returning from call[i+1] to call[i]
+where call[i]'s registers must be reloaded (not live in ARs);
+where call[i] had done a call8 to call[i+1].
+On entry here:
+ window rotated to call[i] start point;
+ a0-a7 are undefined, must be reloaded with call[i].reg[0..7];
+ a8-a15 must be preserved (they are call[i+1].reg[0..7]);
+ a9 is call[i+1]'s stack pointer.
+--------------------------------------------------------------------------------
+*/
+
+ .org 0xC0
+ .global _WindowUnderflow8
+_WindowUnderflow8:
+
+ l32e a0, a9, -16 /* restore a0 from call[i+1]'s stack frame */
+ l32e a1, a9, -12 /* restore a1 from call[i+1]'s stack frame */
+ l32e a2, a9, -8 /* restore a2 from call[i+1]'s stack frame */
+ l32e a7, a1, -12 /* a7 <- call[i-1]'s sp
+ (used to find end of call[i]'s frame) */
+ l32e a3, a9, -4 /* restore a3 from call[i+1]'s stack frame */
+ l32e a4, a7, -32 /* restore a4 from call[i]'s stack frame */
+ l32e a5, a7, -28 /* restore a5 from call[i]'s stack frame */
+ l32e a6, a7, -24 /* restore a6 from call[i]'s stack frame */
+ l32e a7, a7, -20 /* restore a7 from call[i]'s stack frame */
+ rfwu
+
+/*
+--------------------------------------------------------------------------------
+Window Overflow Exception for Call12
+
+Invoked if a call[i] referenced a register (a4-a15)
+that contains data from ancestor call[j];
+call[j] had done a call12 to call[j+1].
+On entry here:
+ window rotated to call[j] start point;
+ a0-a11 are registers to be saved;
+ a12-a15 must be preserved;
+ a13 is call[j+1]'s stack pointer.
+--------------------------------------------------------------------------------
+*/
+
+ .org 0x100
+ .global _WindowOverflow12
+_WindowOverflow12:
+
+ s32e a0, a13, -16 /* save a0 to call[j+1]'s stack frame */
+ l32e a0, a1, -12 /* a0 <- call[j-1]'s sp
+ (used to find end of call[j]'s frame) */
+ s32e a1, a13, -12 /* save a1 to call[j+1]'s stack frame */
+ s32e a2, a13, -8 /* save a2 to call[j+1]'s stack frame */
+ s32e a3, a13, -4 /* save a3 to call[j+1]'s stack frame */
+ s32e a4, a0, -48 /* save a4 to end of call[j]'s stack frame */
+ s32e a5, a0, -44 /* save a5 to end of call[j]'s stack frame */
+ s32e a6, a0, -40 /* save a6 to end of call[j]'s stack frame */
+ s32e a7, a0, -36 /* save a7 to end of call[j]'s stack frame */
+ s32e a8, a0, -32 /* save a8 to end of call[j]'s stack frame */
+ s32e a9, a0, -28 /* save a9 to end of call[j]'s stack frame */
+ s32e a10, a0, -24 /* save a10 to end of call[j]'s stack frame */
+ s32e a11, a0, -20 /* save a11 to end of call[j]'s stack frame */
+ rfwo /* rotates back to call[i] position */
+
+/*
+--------------------------------------------------------------------------------
+Window Underflow Exception for Call12
+
+Invoked by RETW returning from call[i+1] to call[i]
+where call[i]'s registers must be reloaded (not live in ARs);
+where call[i] had done a call12 to call[i+1].
+On entry here:
+ window rotated to call[i] start point;
+ a0-a11 are undefined, must be reloaded with call[i].reg[0..11];
+ a12-a15 must be preserved (they are call[i+1].reg[0..3]);
+ a13 is call[i+1]'s stack pointer.
+--------------------------------------------------------------------------------
+*/
+
+ .org 0x140
+ .global _WindowUnderflow12
+_WindowUnderflow12:
+
+ l32e a0, a13, -16 /* restore a0 from call[i+1]'s stack frame */
+ l32e a1, a13, -12 /* restore a1 from call[i+1]'s stack frame */
+ l32e a2, a13, -8 /* restore a2 from call[i+1]'s stack frame */
+ l32e a11, a1, -12 /* a11 <- call[i-1]'s sp
+ (used to find end of call[i]'s frame) */
+ l32e a3, a13, -4 /* restore a3 from call[i+1]'s stack frame */
+ l32e a4, a11, -48 /* restore a4 from end of call[i]'s stack frame */
+ l32e a5, a11, -44 /* restore a5 from end of call[i]'s stack frame */
+ l32e a6, a11, -40 /* restore a6 from end of call[i]'s stack frame */
+ l32e a7, a11, -36 /* restore a7 from end of call[i]'s stack frame */
+ l32e a8, a11, -32 /* restore a8 from end of call[i]'s stack frame */
+ l32e a9, a11, -28 /* restore a9 from end of call[i]'s stack frame */
+ l32e a10, a11, -24 /* restore a10 from end of call[i]'s stack frame */
+ l32e a11, a11, -20 /* restore a11 from end of call[i]'s stack frame */
+ rfwu
+
+
+
diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/reset.S b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/reset.S
new file mode 100644
index 00000000..b2cb2688
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/hikey/reset.S
@@ -0,0 +1,460 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/******************************************************************************
+ reset.S
+ reset vector for BALONGV7R1 architechure,Any problem pls refer
+ to the Xtensa Microprocessor Programmer's Guide.
+******************************************************************************/
+
+#include <xtensa/coreasm.h>
+#include <xtensa/simcall.h>
+#include "reset.h"
+
+ .begin literal_prefix .ResetVector
+ .section .ResetVector.text, "ax"
+ .global _ResetVector
+ .align 4
+
+_ResetVector:
+ j _Reset
+
+ .end literal_prefix
+
+ /*****************************************************************************
+ Reset
+ *****************************************************************************/
+ .begin literal_prefix .Reset
+ .section .Reset.text, "ax"
+ .global _Reset
+ .align 4
+
+_Reset:
+ /* clear all of interrupts*/
+ movi a0, 0
+ wsr a0, INTENABLE
+
+ wsr a0, IBREAKA_0
+ wsr a0, IBREAKA_1
+ wsr a0, DBREAKA_0
+ wsr a0, DBREAKA_1
+ wsr a0, DBREAKC_0
+ wsr a0, DBREAKC_1
+ wsr a0, IBREAKENABLE
+
+ /* ICOUNT,ICOUNTLEVEL,ICOUNTexception clear ICOUNT and ICOUNTLEVEL*/
+ wsr a0, ICOUNT
+ wsr a0, ICOUNTLEVEL
+ isync
+
+ /*debug disable XCHAL_DEBUGLEVEL*/
+ rsil a1, XCHAL_DEBUGLEVEL - 1
+
+// write windowbase and windowstart, then do rsync.
+// reload a0 with 0, because registers may have moved after
+// writing windowbase/windowstart.
+ wsr a0, CCOUNT
+ /* init register windows*/
+ wsr a0, WINDOWBASE
+ rsync
+ movi a1, 1
+ wsr a1, WINDOWSTART
+
+ ssai 0
+
+ /*Level-1 init EXCSAVE_1 level-1 interrupt*/
+ wsr a0, EXCSAVE_1
+ wsr a0, EPC_1
+ wsr a0, EXCCAUSE
+
+ /*Level-2 init EXCSAVE_1 level-2 interrupt*/
+ wsr a0, EPC_2
+ wsr a0, EPS_2
+ wsr a0, EXCSAVE_2
+
+ /*Level-3 init EXCSAVE_1 level-3 interrupt*/
+ wsr a0, EPC_3
+ wsr a0, EPS_3
+ wsr a0, EXCSAVE_3
+
+ /*Level-4 init EXCSAVE_1 level-4 interrupt*/
+ wsr a0, EPC_4
+ wsr a0, EPS_4
+ wsr a0, EXCSAVE_4
+
+ /*Level-5(DEBUG) init EXCSAVE_1 level-5 interrupt*/
+ wsr a0, EPC_5
+ wsr a0, EPS_5
+ wsr a0, EXCSAVE_5
+
+ /*NMI init EXCSAVE_1 level-6(NMI) interrupt */
+ wsr a0, EPC_6
+ wsr a0, EPS_6
+ wsr a0, EXCSAVE_6
+
+
+ /*0/1/2 init timer 0&1 */
+ wsr a0, CCOMPARE_0
+ wsr a0, CCOMPARE_1
+ //wsr a0, CCOMPARE_2 //hifi3 CCOMPARE_0 CCOMPARE_1
+
+ /* clear all of */
+ movi a2, XCHAL_INTTYPE_MASK_EXTERN_EDGE | XCHAL_INTTYPE_MASK_SOFTWARE
+ wsr a2, INTCLEAR
+
+ wsr a0, BR
+
+ /* disable coprocessor */
+ /*wsr a0, CPENABLE*/
+
+ movi a2, XCHAL_DEBUGLEVEL - 1
+ wsr a2, PS
+ rsync
+
+
+ /*icache init icache */
+#if (XCHAL_ICACHE_SIZE != 0)
+ #if (XCHAL_ICACHE_SIZE == 8192) //212GP and 330HiFi
+ movi a2, 64
+ #elif (XCHAL_ICACHE_SIZE == 16384) //232L and 570T
+ movi a2, 128
+ #elif (XCHAL_ICACHE_SIZE == 32768) //BALONGV7R1
+ movi a2, 256
+ #elif (XCHAL_ICACHE_SIZE == 65536) //CHICAGO HIFI
+ movi a2, 256
+ #endif
+
+ /*icache unlock icache */
+ #if (XCHAL_ICACHE_LINESIZE == 128)
+ movi a3, 0
+ loop a2, .L0
+ iiu a3, 0
+ iiu a3, XCHAL_ICACHE_LINESIZE
+ addi a3, a3, XCHAL_ICACHE_LINESIZE*2
+
+ iiu a3, 0
+ iiu a3, XCHAL_ICACHE_LINESIZE
+ addi a3, a3, XCHAL_ICACHE_LINESIZE*2
+.L0:
+
+ #else
+ movi a3, 0
+ loop a2, .L0
+ iiu a3, 0
+ iiu a3, XCHAL_ICACHE_LINESIZE
+ iiu a3, XCHAL_ICACHE_LINESIZE*2
+ iiu a3, XCHAL_ICACHE_LINESIZE*3
+ addi a3, a3, XCHAL_ICACHE_LINESIZE*4
+.L0:
+ #endif
+
+
+ #if (XCHAL_ICACHE_SIZE == 8192) //212GP and 330HiFi
+ movi a2, 64
+ #elif (XCHAL_ICACHE_SIZE == 16384) //232L and 570T
+ movi a2, 128
+ #elif (XCHAL_ICACHE_SIZE == 32768) //BALONGV7R1
+ movi a2, 256
+ #elif (XCHAL_ICACHE_SIZE == 65536) //CHICAGO HIFI
+ movi a2, 256
+ #endif
+
+ /*icache disable icache */
+ movi a3, 0
+ loop a2, .L1
+ iii a3, 0
+ iii a3, XCHAL_ICACHE_LINESIZE
+ iii a3, XCHAL_ICACHE_LINESIZE*2
+ iii a3, XCHAL_ICACHE_LINESIZE*3
+ addi a3, a3, XCHAL_ICACHE_LINESIZE*4
+.L1:
+ isync
+#endif
+
+
+
+
+ /*dcache init dcache */
+#if (XCHAL_DCACHE_SIZE != 0)
+ #if (XCHAL_DCACHE_SIZE == 8192) //212GP and 330HiFi
+ movi a2, 64
+ #elif (XCHAL_DCACHE_SIZE == 16384) //232L and 570T
+ movi a2, 128
+ #elif (XCHAL_DCACHE_SIZE == 32768) //BALONGV7R1
+ movi a2, 256
+ #elif (XCHAL_DCACHE_SIZE == 65536) //CHICAGO HIFI
+ movi a2, 256
+ #endif
+
+ /*dcache unlock dcache */
+ #if (XCHAL_DCACHE_LINESIZE == 128)
+ movi a3, 0
+ loop a2, .L2
+ diu a3, 0
+ diu a3, XCHAL_DCACHE_LINESIZE
+ addi a3, a3, XCHAL_DCACHE_LINESIZE*2
+
+ diu a3, 0
+ diu a3, XCHAL_DCACHE_LINESIZE
+ addi a3, a3, XCHAL_DCACHE_LINESIZE*2
+.L2:
+
+ #else
+ movi a3, 0
+ loop a2, .L2
+ diu a3, 0
+ diu a3, XCHAL_DCACHE_LINESIZE
+ diu a3, XCHAL_DCACHE_LINESIZE*2
+ diu a3, XCHAL_DCACHE_LINESIZE*3
+ addi a3, a3, XCHAL_DCACHE_LINESIZE*4
+.L2:
+ #endif
+ #if (XCHAL_DCACHE_SIZE == 8192) //212GP and 330HiFi
+ movi a2, 64
+ #elif (XCHAL_DCACHE_SIZE == 16384) //232L and 570T
+ movi a2, 128
+ #elif (XCHAL_DCACHE_SIZE == 32768) //BALONGV7R1
+ movi a2, 256
+ #elif (XCHAL_DCACHE_SIZE == 65536) //CHICAGO HIFI
+ movi a2, 256
+ #endif
+
+
+ /*dcache disable dcache */
+ movi a3, 0
+ loop a2, .L3
+ dii a3, 0
+ dii a3, XCHAL_DCACHE_LINESIZE
+ dii a3, XCHAL_DCACHE_LINESIZE*2
+ dii a3, XCHAL_DCACHE_LINESIZE*3
+ addi a3, a3, XCHAL_DCACHE_LINESIZE*4
+.L3:
+ dsync
+#endif
+
+ /*
+ 0x00000000-0x1fffffff : caches off(bypass)
+ 0x20000000-0x3fffffff : caches off(bypass)
+ 0x40000000-0x5fffffff : caches off(bypass)
+ 0x60000000-0x7fffffff : caches off(bypass)
+ 0x80000000-0x9fffffff : caches off(bypass)
+ 0xa0000000-0xbfffffff : caches off(bypass)
+ 0xc0000000-0xdfffffff : caches on,0x00000000-0x1fffffff
+ 0xe0000000-0xffffffff : caches off(bypass),:0xe0000000~0xefffffff 0x20000000~0x2fffffff
+ */
+ /* config the memory access right */
+ movi a3, 0x00000000 /*0x00000000-0x1fffffff*/
+ set_access_mode PIF_BYPASS /*can not access*/
+
+ movi a3, 0x20000000 /*0x20000000-0x3fffffff*/
+ set_access_mode PIF_BYPASS
+
+ movi a3, 0x40000000 /*0x40000000-0x5fffffff*/
+#if (XCHAL_DCACHE_LINESIZE == 128)
+ set_access_mode PIF_BYPASS
+#else
+ set_access_mode PIF_BYPASS
+#endif
+
+ movi a3, 0x60000000 /*0x60000000-0x7fffffff*/
+ set_access_mode PIF_BYPASS
+
+ movi a3, 0x80000000 /*0x80000000-0x9fffffff*/
+ #if (XCHAL_DCACHE_LINESIZE == 128)
+ set_access_mode PIF_BYPASS
+ #else
+ set_access_mode PIF_BYPASS
+ #endif
+
+ movi a3, 0xa0000000 /*0xa0000000-0xbfffffff*/
+ set_access_mode PIF_BYPASS
+
+ movi a3, 0xc0000000 /*0xc0000000-0xdfffffff*/
+ set_access_mode PIF_CACHED_WBA /*PIF_CACHED*/
+
+ movi a3, 0xe0000000 /*0xe0000000-0xffffffff*/
+ set_access_mode PIF_BYPASS
+
+ /* 0x40000000 0xe0000000, 0x50000000 0xf0000000,*/
+ /*movi a2, 0x40000000 //vpn
+ movi a3, 0xe0000000 //ppn
+ movi a5, 0xE0000000 // tlb mask, upper 3 bits
+ and a4, a3, a5 // upper 3 bits of PPN area
+ and a7, a2, a5 // upper 3 bits of VPN area
+
+ ritlb1 a5, a7 // get current PPN+AM of segment for I
+ rdtlb1 a6, a7 // get current PPN+AM of segment for D
+ extui a5, a5, 0, 4 // keep only AM for I
+ extui a6, a6, 0, 4 // keep only AM for D
+ add a2, a4, a5 // combine new PPN with orig AM for I
+ add a3, a4, a6 // combine new PPN with orig AM for D
+ witlb a2, a7 // write new tlb mapping for I
+ wdtlb a3, a7 // write new tlb mapping for D
+ */
+ isync
+ dsync
+
+ /*
+ prepare the environment of run C code
+ */
+ movi sp, __stack
+
+ movi a2, PS_WOE_MASK | PS_PROGSTACK_MASK
+ wsr a2, PS
+ rsync
+
+ movi a8, _bss_start
+ movi a10, _bss_end
+ sub a11, a10, a8
+ srli a11, a11, 2
+
+ movi a9, 0
+ loopnez a11, zerodone
+ s32i a9, a8, 0
+ addi a8, a8, 4
+zerodone:
+
+ movi a8, _ulpp_bss_start
+ movi a10, _ulpp_bss_end
+ sub a11, a10, a8
+ srli a11, a11, 2
+
+ movi a9, 0
+ loopnez a11, zerodone1
+ s32i a9, a8, 0
+ addi a8, a8, 4
+zerodone1:
+
+#ifdef HIFI_DTS_V3
+ movi a8, _dtsv3_bss_start
+ movi a10, _dtsv3_bss_end
+ sub a11, a10, a8
+ srli a11, a11, 2
+
+ movi a9, 0
+ loopnez a11, zerodone2
+ s32i a9, a8, 0
+ addi a8, a8, 4
+zerodone2:
+#endif
+
+#ifdef HIFI_DTS_V4
+ movi a8, _dtsv4_bss_start
+ movi a10, _dtsv4_bss_end
+ sub a11, a10, a8
+ srli a11, a11, 2
+
+ movi a9, 0
+ loopnez a11, zerodone3
+ s32i a9, a8, 0
+ addi a8, a8, 4
+zerodone3:
+#endif
+
+#ifdef HIFI_VLP
+ movi a8, _efr_fr_hr_vlpd_bss_start
+ movi a10, _efr_fr_hr_vlpd_bss_end
+ sub a11, a10, a8
+ srli a11, a11, 2
+
+ movi a9, 0
+ loopnez a11, zerodone4
+ s32i a9, a8, 0
+ addi a8, a8, 4
+zerodone4:
+
+ movi a8, _amr_vlpd_bss_start
+ movi a10, _amr_vlpd_bss_end
+ sub a11, a10, a8
+ srli a11, a11, 2
+
+ movi a9, 0
+ loopnez a11, zerodone5
+ s32i a9, a8, 0
+ addi a8, a8, 4
+zerodone5:
+
+ movi a8, _vlpd_bss_start
+ movi a10, _vlpd_bss_end
+ sub a11, a10, a8
+ srli a11, a11, 2
+
+ movi a9, 0
+ loopnez a11, zerodone6
+ s32i a9, a8, 0
+ addi a8, a8, 4
+zerodone6:
+
+ movi a8, _amrwb_vlpd_bss_start
+ movi a10, _amrwb_vlpd_bss_end
+ sub a11, a10, a8
+ srli a11, a11, 2
+
+ movi a9, 0
+ loopnez a11, zerodone7
+ s32i a9, a8, 0
+ addi a8, a8, 4
+zerodone7:
+#endif
+
+callmain:
+
+// Do NOT modify a1 here, it is the stack pointer.
+// Use another register instead (a3?)
+// Not sure why the NOPs are present.
+#movi a1, 0xdeadbeef
+ movi a1, 0xe8073000
+ movi a2, 0xe8075e10 /*HIFI_RESERVE1_LOCATION*/
+ s32i a1, a2, 0
+
+ movi a0, 0
+ movi a6, 0 /* clear argc*/
+ movi a7, 0 /* clear argv*/
+ movi a8, 0 /* clear envp*/
+ movi a4, main
+ nop
+ nop
+ callx4 a4
+
+reset_exit:
+ movi a2, SYS_exit
+// Where does it go from here ? execution will fall through into
+// whatever happens to follow. Either halt here or jump to some
+// specific code.
+
+ .end literal_prefix
+
+#ifdef VOS_VENUS_TEST_STUB
+ .text
+ .global sim_call
+ .type sim_call,@function
+ .align 4
+sim_call:
+ entry sp, 64
+ addi a4, a3,-3
+ movi a3, g_auwVosTestMessageBuf
+ movi a2, SYS_log_msg
+ simcall
+ retw
+
+#endif
+
+
diff --git a/hifi/xaf/hifi-dpf/ipc/xt-shmem/xf-main.c b/hifi/xaf/hifi-dpf/ipc/xt-shmem/xf-main.c
new file mode 100644
index 00000000..f9178004
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/ipc/xt-shmem/xf-main.c
@@ -0,0 +1,189 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xf-main.c
+ *
+ * DSP processing framework main file
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG MAIN
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+#ifndef XAF_ENABLE_NON_HIKEY
+volatile int waitstate;
+#endif
+
+#ifdef XAF_PROFILE_DSP
+/* ... MCPS/profile info */
+#include "xa_profiler.h"
+#endif
+
+/*******************************************************************************
+ * Global data definition
+ ******************************************************************************/
+/* ...per-core execution data */
+xf_core_data_t xf_core_data[XF_CFG_CORES_NUM];
+
+/* ...AP-DSP shared memory pool */
+xf_mm_pool_t xf_ap_shmem_pool;
+
+/* ...per-core local memory pool */
+xf_mm_pool_t xf_dsp_local_pool[XF_CFG_CORES_NUM];
+
+#if XF_CFG_CORES_NUM > 1
+/* ...DSP cluster shared memory pool */
+xf_mm_pool_t xf_dsp_shmem_pool;
+#endif
+
+/* ...per-core shared memory with read-only access */
+__xf_core_ro_data_t xf_core_ro_data[XF_CFG_CORES_NUM];
+
+/* ...per-core shared memory with read-write access */
+__xf_core_rw_data_t xf_core_rw_data[XF_CFG_CORES_NUM];
+
+/*******************************************************************************
+ * Memory buffers - take them from linker file somehow - tbd
+ ******************************************************************************/
+
+/* ...unallocated memory region - AP-DSP shared memory buffer - export from linker somehow */
+//u8 xf_ap_shmem_buffer[XF_CFG_REMOTE_IPC_POOL_SIZE] __xf_shmem__;
+
+#if XF_CFG_CORES_NUM > 1
+/* ...unallocated DSP shared memory buffer */
+u8 xf_dsp_shmem_buffer[XF_CFG_LOCAL_IPC_POOL_SIZE] __xf_shmem__;
+#endif
+
+/* ...unallocated per-core local memory (in 32-byte chunks) */
+#ifdef XAF_ENABLE_NON_HIKEY
+u8 xf_dsp_local_buffer[XF_CFG_CORES_NUM][XF_CFG_LOCAL_POOL_SIZE] __xf_mm__;
+#else
+u8 xf_dsp_local_buffer[XF_CFG_CORES_NUM][XF_CFG_LOCAL_POOL_SIZE];
+//u8 g_tmp[2];
+#endif
+
+#ifdef XAF_PROFILE_DSP
+xa_profiler prof;
+#endif
+
+/*******************************************************************************
+ * Timer interrupt - tbd
+ ******************************************************************************/
+
+/*******************************************************************************
+ * IPC layer initialization
+ ******************************************************************************/
+
+/* ...system-specific IPC layer initialization */
+int xf_ipc_init(u32 core)
+{
+ xf_core_data_t *cd = XF_CORE_DATA(core);
+ xf_shmem_data_t *shmem = (xf_shmem_data_t *)XF_CFG_SHMEM_ADDRESS(core);
+
+ /* ...initialize pointer to shared memory */
+ cd->shmem = (xf_shmem_handle_t *)shmem;
+ shmem->buffer = (uint8_t *) HIFI_MUSIC_DATA_LOCATION;
+ /* ...global memory pool initialization */
+#ifdef XAF_ENABLE_NON_HIKEY
+ XF_CHK_API(xf_mm_init(&cd->shared_pool, shmem->buffer, XF_CFG_REMOTE_IPC_POOL_SIZE));
+#else
+ XF_CHK_API(xf_mm_init(&cd->shared_pool, (void *) HIFI_MUSIC_DATA_LOCATION, XF_CFG_REMOTE_IPC_POOL_SIZE));
+#endif
+ return 0;
+}
+
+/*******************************************************************************
+ * Core executive loop
+ ******************************************************************************/
+
+static void xf_core_loop(u32 core)
+{
+ /* ...initialize internal core structures */
+ xf_core_init(core);
+
+#ifdef XAF_PROFILE_DSP
+/* Profiler initialization */
+ INIT_XA_PROFILER(prof,"DSP core");
+#endif
+
+ for(;;)
+ {
+ /* ...wait in a low-power mode until event is triggered */
+ xf_ipi_wait(core);
+
+ /* ...service core event */
+ xf_core_service(core);
+ }
+}
+
+/*******************************************************************************
+ * Global entry point
+ ******************************************************************************/
+
+int main(void)
+{
+#if XF_CFG_CORES_NUM > 1
+ u32 i;
+#endif
+
+ /* ...reset ro/rw core data - tbd */
+ memset(xf_core_rw_data, 0, sizeof(xf_core_rw_data));
+ memset(xf_core_ro_data, 0, sizeof(xf_core_ro_data));
+
+ TRACE_INIT("Xtensa Audio DSP Codec Server");
+#ifdef XAF_ENABLE_NON_HIKEY
+ /* ...initialize board */
+ xf_board_init();
+
+ /* ...global framework data initialization */
+ xf_global_init();
+#endif
+
+#if XF_CFG_CORES_NUM > 1
+ /* ...DSP shared memory pool initialization */
+ XF_CHK_API(xf_mm_init(&xf_dsp_shmem_pool, xf_dsp_shmem_buffer, XF_CFG_LOCAL_IPC_POOL_SIZE));
+#endif
+
+ /* ...initialize per-core memory loop */
+ XF_CHK_API(xf_mm_init(&xf_core_data[0].local_pool, xf_dsp_local_buffer[0], XF_CFG_LOCAL_POOL_SIZE));
+
+#if XF_CFG_CORES_NUM > 1
+ /* ...bring up all cores */
+ for (i = 1; i < XF_CFG_CORES_NUM; i++)
+ {
+ /* ...wake-up secondary core somehow and make it execute xf_core_loop */
+ xf_core_secondary_startup(i, xf_core_loop, i);
+
+ }
+#endif
+
+ /* ...enter execution loop on master core #0 */
+ xf_core_loop(0);
+
+ /* ...not reachable */
+ return 0;
+}
diff --git a/hifi/xaf/hifi-dpf/plugins/cadence/mixer/xa-mixer.c b/hifi/xaf/hifi-dpf/plugins/cadence/mixer/xa-mixer.c
new file mode 100644
index 00000000..0909d446
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/plugins/cadence/mixer/xa-mixer.c
@@ -0,0 +1,669 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-mixer.c
+ *
+ * Sample mixer plugin
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG MIXER
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf-plugin.h"
+#include "audio/xa-mixer-api.h"
+
+/*******************************************************************************
+ * Tracing configuration
+ ******************************************************************************/
+
+TRACE_TAG(INIT, 1);
+TRACE_TAG(PROCESS, 1);
+
+/*******************************************************************************
+ * Internal functions definitions
+ ******************************************************************************/
+
+/* ...API structure */
+typedef struct XAPcmMixer
+{
+ /* ...mixer state */
+ u32 state;
+
+ /* ...number of samples in a frame */
+ u32 frame_size;
+
+ /* ...number of channels (channel mask?) */
+ u32 channels;
+
+ /* ...PCM sample width */
+ u32 pcm_width;
+
+ /* ...sampling rate */
+ u32 sample_rate;
+
+ /* ...number of bytes in input/output buffer */
+ u32 buffer_size;
+
+ /* ...master volume and individual track volumes*/
+ u32 volume[XA_MIXER_MAX_TRACK_NUMBER + 1];
+
+ /* ...input buffers */
+ void *input[XA_MIXER_MAX_TRACK_NUMBER];
+
+ /* ...number of samples in individual buffers */
+ u32 input_length[XA_MIXER_MAX_TRACK_NUMBER];
+
+ /* ...output buffer */
+ void *output;
+
+ /* ...number of produced bytes - do I need that? have buffer-size already - tbd */
+ u32 produced;
+
+ /* ...scratch buffer pointer */
+ void *scratch;
+
+} XAPcmMixer;
+
+/*******************************************************************************
+ * Mixer state flags
+ ******************************************************************************/
+
+#define XA_MIXER_FLAG_PREINIT_DONE (1 << 0)
+#define XA_MIXER_FLAG_POSTINIT_DONE (1 << 1)
+#define XA_MIXER_FLAG_RUNNING (1 << 2)
+#define XA_MIXER_FLAG_OUTPUT (1 << 3)
+#define XA_MIXER_FLAG_COMPLETE (1 << 4)
+
+/*******************************************************************************
+ * DSP functions
+ ******************************************************************************/
+
+#define DSP_SATURATE_S16(s32) \
+ (s16)((s32) > 0x7fff ? 0x7fff : ((s32) < -0x8000 ? -0x8000 : (s32)))
+
+/* ...mixer preinitialization (default parameters) */
+static inline void xa_mixer_preinit(XAPcmMixer *d)
+{
+ u32 i;
+
+ /* ...pre-configuration initialization; reset internal data */
+ memset(d, 0, sizeof(*d));
+
+ /* ...set default parameters */
+ d->pcm_width = 16, d->channels = 2, d->frame_size = 512;
+
+ /* ...set default volumes (last index is a master volume)*/
+ for (i = 0; i <= XA_MIXER_MAX_TRACK_NUMBER; i++)
+ {
+ d->volume[i] = ((1 << 12) << 16) | (1 << 12);
+ }
+}
+
+/* ...do mixing of stereo PCM-16 streams */
+static XA_ERRORCODE xa_mixer_do_execute_stereo_16bit(XAPcmMixer *d)
+{
+ s16 *output = d->output;
+ s16 *b[XA_MIXER_MAX_TRACK_NUMBER];
+ u16 v_l[XA_MIXER_MAX_TRACK_NUMBER];
+ u16 v_r[XA_MIXER_MAX_TRACK_NUMBER];
+ u16 w_l, w_r;
+ u32 t32;
+ u32 i, j;
+
+ /* ...retrieve master volume - assume up to 24dB amplifying (4 bits) */
+ t32 = d->volume[XA_MIXER_MAX_TRACK_NUMBER];
+ w_l = (u16)(t32 & 0xFFFF), w_r = (u16)(t32 >> 16);
+
+ /* ...prepare individual tracks */
+ for (j = 0; j < XA_MIXER_MAX_TRACK_NUMBER; j++)
+ {
+ u32 n = d->input_length[j];
+
+ /* ...check if we have input buffer available */
+ if (n == 0)
+ {
+ /* ...output silence (multiply garbage in the scratch buffer by 0) */
+ b[j] = d->scratch;
+ v_l[j] = v_r[j] = 0;
+ }
+ else
+ {
+ s32 k = (s32)(d->buffer_size - n);
+
+ /* ...put input buffer */
+ XF_CHK_ERR(b[j] = d->input[j], XA_MIXER_EXEC_FATAL_INPUT);
+
+ /* ...if length is not sufficient, pad buffer remainder */
+ (k > 0 ? memset((void *)b[j] + n, 0x00, k) : 0);
+
+ /* ...set individual track volume/balance */
+ t32 = d->volume[j];
+ v_l[j] = (u16)(t32 & 0xFFFF), v_r[j] = (u16)(t32 >> 16);
+ }
+
+ TRACE(PROCESS, _b("b[%u] = %p%s"), j, b[j], (n == 0 ? " - scratch" : ""));
+ }
+
+ /* ...process all tracks */
+ for (i = 0; i < d->frame_size; i++)
+ {
+ s32 l32 = 0, r32 = 0;
+
+ /* ...fill-in every channel in our map (unrolls loop here) */
+ for (j = 0; j < XA_MIXER_MAX_TRACK_NUMBER; j++)
+ {
+ /* ...left channel processing (no saturation here yet) */
+ l32 += *b[j]++ * v_l[j];
+
+ /* ...right channel processing */
+ r32 += *b[j]++ * v_r[j];
+ }
+
+ /* ...normalize (truncate towards -inf) and multiply by master volume */
+ l32 = ((l32 >> 12) * w_l) >> 12;
+ r32 = ((r32 >> 12) * w_r) >> 12;
+
+ /* ...saturate and store in buffer */
+ *output++ = DSP_SATURATE_S16(l32);
+ *output++ = DSP_SATURATE_S16(r32);
+ }
+
+ /* ...save total number of produced bytes */
+ d->produced = (u32)((void *)output - d->output);
+
+ /* ...put flag saying we have output buffer */
+ d->state |= XA_MIXER_FLAG_OUTPUT;
+
+ TRACE(PROCESS, _b("produced: %u bytes (%u samples)"), d->produced, d->frame_size);
+
+ /* ...reset input buffer length? */
+ //memset(d->input_length, 0, sizeof(d->input_length));
+
+ /* ...return success result code */
+ return XA_NO_ERROR;
+}
+
+/* ...runtime reset */
+static XA_ERRORCODE xa_mixer_do_runtime_init(XAPcmMixer *d)
+{
+ /* ...no special processing is needed here */
+ return XA_NO_ERROR;
+}
+
+/*******************************************************************************
+ * Commands processing
+ ******************************************************************************/
+
+/* ...codec API size query */
+static XA_ERRORCODE xa_mixer_get_api_size(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...check parameters are sane */
+ XF_CHK_ERR(pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...retrieve API structure size */
+ *(WORD32 *)pv_value = sizeof(*d);
+
+ return XA_NO_ERROR;
+}
+
+/* ...standard codec initialization routine */
+static XA_ERRORCODE xa_mixer_init(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...sanity check - mixer must be valid */
+ XF_CHK_ERR(d, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...process particular initialization type */
+ switch (i_idx)
+ {
+ case XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS:
+ {
+ /* ...pre-configuration initialization; reset internal data */
+ xa_mixer_preinit(d);
+
+ /* ...and mark mixer has been created */
+ d->state = XA_MIXER_FLAG_PREINIT_DONE;
+
+ return XA_NO_ERROR;
+ }
+
+ case XA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS:
+ {
+ /* ...post-configuration initialization (all parameters are set) */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...calculate input/output buffer size in bytes */
+ d->buffer_size = d->channels * d->frame_size * (d->pcm_width == 16 ? sizeof(s16) : sizeof(s32));
+
+ /* ...mark post-initialization is complete */
+ d->state |= XA_MIXER_FLAG_POSTINIT_DONE;
+
+ return XA_NO_ERROR;
+ }
+
+ case XA_CMD_TYPE_INIT_PROCESS:
+ {
+ /* ...kick run-time initialization process; make sure mixer is setup */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...enter into execution stage */
+ d->state |= XA_MIXER_FLAG_RUNNING;
+
+ return XA_NO_ERROR;
+ }
+
+ case XA_CMD_TYPE_INIT_DONE_QUERY:
+ {
+ /* ...check if initialization is done; make sure pointer is sane */
+ XF_CHK_ERR(pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...put current status */
+ *(WORD32 *)pv_value = (d->state & XA_MIXER_FLAG_RUNNING ? 1 : 0);
+
+ return XA_NO_ERROR;
+ }
+
+ default:
+ /* ...unrecognized command type */
+ TRACE(ERROR, _x("Unrecognized command type: %X"), i_idx);
+ return XA_API_FATAL_INVALID_CMD_TYPE;
+ }
+}
+
+/* ...set mixer configuration parameter */
+static XA_ERRORCODE xa_mixer_set_config_param(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ u32 i_value;
+
+ /* ...sanity check - mixer pointer must be sane */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...pre-initialization must be completed, mixer must be idle */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...get parameter value */
+ i_value = (u32) *(WORD32 *)pv_value;
+
+ /* ...process individual configuration parameter */
+ switch (i_idx)
+ {
+ case XA_MIXER_CONFIG_PARAM_PCM_WIDTH:
+ /* ...check value is permitted (16 bits only) */
+ XF_CHK_ERR(i_value == 16, XA_MIXER_CONFIG_NONFATAL_RANGE);
+ d->pcm_width = (u32)i_value;
+ return XA_NO_ERROR;
+
+ case XA_MIXER_CONFIG_PARAM_CHANNELS:
+ /* ...allow stereo only */
+ XF_CHK_ERR(i_value == 2, XA_MIXER_CONFIG_NONFATAL_RANGE);
+ d->channels = (u32)i_value;
+ return XA_NO_ERROR;
+
+ case XA_MIXER_CONFIG_PARAM_SAMPLE_RATE:
+ /* ...set mixer sample rate */
+ d->sample_rate = (u32)i_value;
+ return XA_NO_ERROR;
+
+ default:
+ TRACE(ERROR, _x("Invalid parameter: %X"), i_idx);
+ return XA_API_FATAL_INVALID_CMD_TYPE;
+ }
+}
+
+/* ...retrieve configuration parameter */
+static XA_ERRORCODE xa_mixer_get_config_param(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...sanity check - mixer must be initialized */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...make sure pre-initialization is completed */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...process individual configuration parameter */
+ switch (i_idx)
+ {
+ case XA_MIXER_CONFIG_PARAM_INPUT_TRACKS:
+ /* ...return maximal number of input tracks supported */
+ *(WORD32 *)pv_value = XA_MIXER_MAX_TRACK_NUMBER;
+ return XA_NO_ERROR;
+
+ case XA_MIXER_CONFIG_PARAM_SAMPLE_RATE:
+ /* ...return mixer sample rate */
+ *(WORD32 *)pv_value = d->sample_rate;
+ return XA_NO_ERROR;
+
+ case XA_MIXER_CONFIG_PARAM_PCM_WIDTH:
+ /* ...return current PCM width */
+ *(WORD32 *)pv_value = d->pcm_width;
+ return XA_NO_ERROR;
+
+ case XA_MIXER_CONFIG_PARAM_CHANNELS:
+ /* ...return current channel number */
+ *(WORD32 *)pv_value = d->channels;
+ return XA_NO_ERROR;
+
+ case XA_MIXER_CONFIG_PARAM_FRAME_SIZE:
+ /* ...return current in/out frame length (in samples) */
+ *(WORD32 *)pv_value = d->frame_size;
+ return XA_NO_ERROR;
+
+ case XA_MIXER_CONFIG_PARAM_BUFFER_SIZE:
+ /* ...return current in/out frame length (in bytes) */
+ *(WORD32 *)pv_value = d->buffer_size;
+ return XA_NO_ERROR;
+
+ default:
+ TRACE(ERROR, _x("Invalid parameter: %X"), i_idx);
+ return XA_API_FATAL_INVALID_CMD_TYPE;
+ }
+}
+
+/* ...execution command */
+static XA_ERRORCODE xa_mixer_execute(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...sanity check - mixer must be valid */
+ XF_CHK_ERR(d, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...mixer must be in running state */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_RUNNING, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...process individual command type */
+ switch (i_idx)
+ {
+ case XA_CMD_TYPE_DO_EXECUTE:
+ /* ...perform mixing of the channels */
+ return xa_mixer_do_execute_stereo_16bit(d);
+
+ case XA_CMD_TYPE_DONE_QUERY:
+ /* ...check if processing is complete */
+ XF_CHK_ERR(pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+ *(WORD32 *)pv_value = (d->state & XA_MIXER_FLAG_COMPLETE ? 1 : 0);
+ return XA_NO_ERROR;
+
+ case XA_CMD_TYPE_DO_RUNTIME_INIT:
+ /* ...reset mixer operation */
+ return xa_mixer_do_runtime_init(d);
+
+ default:
+ /* ...unrecognized command */
+ TRACE(ERROR, _x("Invalid index: %X"), i_idx);
+ return XA_API_FATAL_INVALID_CMD_TYPE;
+ }
+}
+
+/* ...set number of input bytes */
+static XA_ERRORCODE xa_mixer_set_input_bytes(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ u32 size;
+
+ /* ...sanity check - check parameters */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...track index must be valid */
+ XF_CHK_ERR(i_idx >= 0 && i_idx < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...mixer must be initialized */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...input buffer must exist */
+ XF_CHK_ERR(d->input[i_idx], XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...input frame length should not be zero (in bytes) */
+ XF_CHK_ERR((size = (u32)*(WORD32 *)pv_value) > 0, XA_MIXER_EXEC_NONFATAL_INPUT);
+
+ /* ...all is correct; set input buffer length in bytes */
+ d->input_length[i_idx] = size;
+
+ return XA_NO_ERROR;
+}
+
+/* ...get number of output bytes */
+static XA_ERRORCODE xa_mixer_get_output_bytes(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...sanity check - check parameters */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...track index must be zero */
+ XF_CHK_ERR(i_idx == XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...mixer must be running */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_RUNNING, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...output buffer must exist */
+ XF_CHK_ERR(d->output, XA_MIXER_EXEC_NONFATAL_OUTPUT);
+
+ /* ...return number of produced bytes */
+ *(WORD32 *)pv_value = (d->state & XA_MIXER_FLAG_OUTPUT ? d->buffer_size : 0);
+
+ return XA_NO_ERROR;
+}
+
+/* ...get number of consumed bytes */
+static XA_ERRORCODE xa_mixer_get_curidx_input_buf(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...sanity check - check parameters */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...track index must be valid */
+ XF_CHK_ERR(i_idx >= 0 && i_idx < XA_MIXER_MAX_TRACK_NUMBER, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...mixer must be running */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_RUNNING, XA_MIXER_EXEC_FATAL_STATE);
+
+ /* ...input buffer must exist */
+ XF_CHK_ERR(d->input[i_idx], XA_MIXER_EXEC_FATAL_INPUT);
+
+ /* ...return number of bytes consumed (always consume fixed-length chunk) */
+ *(WORD32 *)pv_value = d->input_length[i_idx], d->input_length[i_idx] = 0;
+
+ return XA_NO_ERROR;
+}
+
+/*******************************************************************************
+ * Memory information API
+ ******************************************************************************/
+
+/* ..get total amount of data for memory tables */
+static XA_ERRORCODE xa_mixer_get_memtabs_size(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity checks */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...check mixer is pre-initialized */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...we have all our tables inside API structure - good? tbd */
+ *(WORD32 *)pv_value = 0;
+
+ return XA_NO_ERROR;
+}
+
+/* ..set memory tables pointer */
+static XA_ERRORCODE xa_mixer_set_memtabs_ptr(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity checks */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...check mixer is pre-initialized */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...do not do anything; just return success - tbd */
+ return XA_NO_ERROR;
+}
+
+/* ...return total amount of memory buffers */
+static XA_ERRORCODE xa_mixer_get_n_memtabs(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity checks */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...we have N input buffers, 1 output buffer and 1 scratch buffer */
+ *(WORD32 *)pv_value = XA_MIXER_MAX_TRACK_NUMBER + 1 + 1;
+
+ return XA_NO_ERROR;
+}
+
+/* ...return memory buffer data */
+static XA_ERRORCODE xa_mixer_get_mem_info_size(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity check */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...return frame buffer minimal size only after post-initialization is done */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...all buffers are of the same length */
+ *(WORD32 *)pv_value = (WORD32) d->buffer_size;
+
+ return XA_NO_ERROR;
+}
+
+/* ...return memory alignment data */
+static XA_ERRORCODE xa_mixer_get_mem_info_alignment(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity check */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...return frame buffer minimal size only after post-initialization is done */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...all buffers are 4-bytes aligned */
+ *(WORD32 *)pv_value = 4;
+
+ return XA_NO_ERROR;
+}
+
+/* ...return memory type data */
+static XA_ERRORCODE xa_mixer_get_mem_info_type(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity check */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...return frame buffer minimal size only after post-initialization is done */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ switch (i_idx)
+ {
+ case 0 ... XA_MIXER_MAX_TRACK_NUMBER - 1:
+ /* ...input buffers */
+ *(WORD32 *)pv_value = XA_MEMTYPE_INPUT;
+ return XA_NO_ERROR;
+
+ case XA_MIXER_MAX_TRACK_NUMBER:
+ /* ...output buffer */
+ *(WORD32 *)pv_value = XA_MEMTYPE_OUTPUT;
+ return XA_NO_ERROR;
+
+ case XA_MIXER_MAX_TRACK_NUMBER + 1:
+ /* ...scratch buffer */
+ *(WORD32 *)pv_value = XA_MEMTYPE_SCRATCH;
+ return XA_NO_ERROR;
+
+ default:
+ /* ...invalid index */
+ return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE);
+ }
+}
+
+/* ...set memory pointer */
+static XA_ERRORCODE xa_mixer_set_mem_ptr(XAPcmMixer *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity check */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...codec must be initialized */
+ XF_CHK_ERR(d->state & XA_MIXER_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...select memory buffer */
+ switch (i_idx)
+ {
+ case 0 ... XA_MIXER_MAX_TRACK_NUMBER - 1:
+ /* ...input buffers */
+ d->input[i_idx] = pv_value;
+ return XA_NO_ERROR;
+
+ case XA_MIXER_MAX_TRACK_NUMBER:
+ /* ...output buffer */
+ d->output = pv_value;
+ return XA_NO_ERROR;
+
+ case XA_MIXER_MAX_TRACK_NUMBER + 1:
+ /* ...scratch buffer */
+ d->scratch = pv_value;
+ return XA_NO_ERROR;
+
+ default:
+ /* ...invalid index */
+ return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE);
+ }
+}
+
+/*******************************************************************************
+ * API command hooks
+ ******************************************************************************/
+
+static XA_ERRORCODE (* const xa_mixer_api[])(XAPcmMixer *, WORD32, pVOID) =
+{
+ [XA_API_CMD_GET_API_SIZE] = xa_mixer_get_api_size,
+
+ [XA_API_CMD_INIT] = xa_mixer_init,
+ [XA_API_CMD_SET_CONFIG_PARAM] = xa_mixer_set_config_param,
+ [XA_API_CMD_GET_CONFIG_PARAM] = xa_mixer_get_config_param,
+
+ [XA_API_CMD_EXECUTE] = xa_mixer_execute,
+ [XA_API_CMD_SET_INPUT_BYTES] = xa_mixer_set_input_bytes,
+ [XA_API_CMD_GET_OUTPUT_BYTES] = xa_mixer_get_output_bytes,
+ [XA_API_CMD_GET_CURIDX_INPUT_BUF] = xa_mixer_get_curidx_input_buf,
+
+ [XA_API_CMD_GET_MEMTABS_SIZE] = xa_mixer_get_memtabs_size,
+ [XA_API_CMD_SET_MEMTABS_PTR] = xa_mixer_set_memtabs_ptr,
+ [XA_API_CMD_GET_N_MEMTABS] = xa_mixer_get_n_memtabs,
+ [XA_API_CMD_GET_MEM_INFO_SIZE] = xa_mixer_get_mem_info_size,
+ [XA_API_CMD_GET_MEM_INFO_ALIGNMENT] = xa_mixer_get_mem_info_alignment,
+ [XA_API_CMD_GET_MEM_INFO_TYPE] = xa_mixer_get_mem_info_type,
+ [XA_API_CMD_SET_MEM_PTR] = xa_mixer_set_mem_ptr,
+};
+
+/* ...total numer of commands supported */
+#define XA_MIXER_API_COMMANDS_NUM (sizeof(xa_mixer_api) / sizeof(xa_mixer_api[0]))
+
+/*******************************************************************************
+ * API entry point
+ ******************************************************************************/
+
+XA_ERRORCODE xa_mixer(xa_codec_handle_t p_xa_module_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value)
+{
+ XAPcmMixer *d = (XAPcmMixer *) p_xa_module_obj;
+
+ /* ...check if command index is sane */
+ XF_CHK_ERR(i_cmd < XA_MIXER_API_COMMANDS_NUM, XA_API_FATAL_INVALID_CMD);
+
+ /* ...see if command is defined */
+ XF_CHK_ERR(xa_mixer_api[i_cmd], XA_API_FATAL_INVALID_CMD);
+
+ /* ...execute requested command */
+ return xa_mixer_api[i_cmd](d, i_idx, pv_value);
+}
diff --git a/hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm-api.h b/hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm-api.h
new file mode 100644
index 00000000..cb14dad0
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm-api.h
@@ -0,0 +1,145 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-pcm-api.h
+ *
+ * Generic PCM format converter API
+ *
+ ******************************************************************************/
+
+#ifndef __XA_PCM_API_H__
+#define __XA_PCM_API_H__
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xa_type_def.h"
+#include "xa_error_standards.h"
+#include "xa_apicmd_standards.h"
+#include "xa_memory_standards.h"
+
+/*******************************************************************************
+ * Constants definitions
+ ******************************************************************************/
+
+/* ...codec-specific configuration parameters */
+enum xa_config_param_pcm {
+ XA_PCM_CONFIG_PARAM_SAMPLE_RATE = 0,
+ XA_PCM_CONFIG_PARAM_IN_PCM_WIDTH = 1,
+ XA_PCM_CONFIG_PARAM_IN_CHANNELS = 2,
+ XA_PCM_CONFIG_PARAM_OUT_PCM_WIDTH = 3,
+ XA_PCM_CONFIG_PARAM_OUT_CHANNELS = 4,
+ XA_PCM_CONFIG_PARAM_CHANROUTING = 5,
+ XA_PCM_CONFIG_PARAM_NUM = 6,
+};
+
+/* ...component identifier (informative) */
+#define XA_CODEC_PCM 16
+
+/*******************************************************************************
+ * Class 0: API Errors
+ ******************************************************************************/
+
+#define XA_PCM_API_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_api, XA_CODEC_PCM, (e))
+
+#define XA_PCM_API_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_PCM, (e))
+
+enum xa_error_nonfatal_api_pcm {
+ XA_PCM_API_NONFATAL_MAX = XA_PCM_API_NONFATAL(0)
+};
+
+enum xa_error_fatal_api_pcm {
+ XA_PCM_API_FATAL_MAX = XA_PCM_API_FATAL(0)
+};
+
+/*******************************************************************************
+ * Class 1: Configuration Errors
+ ******************************************************************************/
+
+#define XA_PCM_CONFIG_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_PCM, (e))
+
+#define XA_PCM_CONFIG_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_PCM, (e))
+
+enum xa_error_nonfatal_config_pcm {
+ XA_PCM_CONFIG_NONFATAL_RANGE = XA_PCM_CONFIG_NONFATAL(0),
+ XA_PCM_CONFIG_NONFATAL_STATE = XA_PCM_CONFIG_NONFATAL(1),
+ XA_PCM_CONFIG_NONFATAL_MAX = XA_PCM_CONFIG_NONFATAL(2)
+};
+
+enum xa_error_fatal_config_pcm {
+ XA_PCM_CONFIG_FATAL_RANGE = XA_PCM_CONFIG_FATAL(0),
+ XA_PCM_CONFIG_FATAL_MAX = XA_PCM_CONFIG_FATAL(1)
+};
+
+/*******************************************************************************
+ * Class 2: Execution Class Errors
+ ******************************************************************************/
+
+#define XA_PCM_EXEC_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_PCM, (e))
+
+#define XA_PCM_EXEC_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_PCM, (e))
+
+enum xa_error_nonfatal_execute_pcm {
+ XA_PCM_EXEC_NONFATAL_STATE = XA_PCM_EXEC_NONFATAL(0),
+ XA_PCM_EXEC_NONFATAL_NO_DATA = XA_PCM_EXEC_NONFATAL(1),
+ XA_PCM_EXEC_NONFATAL_INPUT = XA_PCM_EXEC_NONFATAL(2),
+ XA_PCM_EXEC_NONFATAL_OUTPUT = XA_PCM_EXEC_NONFATAL(3),
+ XA_PCM_EXEC_NONFATAL_MAX = XA_PCM_EXEC_NONFATAL(4)
+};
+
+enum xa_error_fatal_execute_pcm {
+ XA_PCM_EXEC_FATAL_STATE = XA_PCM_EXEC_FATAL(0),
+ XA_PCM_EXEC_FATAL_INPUT = XA_PCM_EXEC_FATAL(1),
+ XA_PCM_EXEC_FATAL_OUTPUT = XA_PCM_EXEC_FATAL(2),
+ XA_PCM_EXEC_FATAL_MAX = XA_PCM_EXEC_FATAL(3)
+};
+
+/*******************************************************************************
+ * API function definition
+ ******************************************************************************/
+
+#if defined(USE_DLL) && defined(_WIN32)
+#define DLL_SHARED __declspec(dllimport)
+#elif defined (_WINDLL)
+#define DLL_SHARED __declspec(dllexport)
+#else
+#define DLL_SHARED
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif /* __cplusplus */
+DLL_SHARED xa_codec_func_t xa_pcm_codec;
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus */
+
+#endif /* __XA_PCM_API_H__ */
+
diff --git a/hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm.c b/hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm.c
new file mode 100644
index 00000000..43067144
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/plugins/cadence/pcm_proc/xa-pcm.c
@@ -0,0 +1,841 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-pcm.c
+ *
+ * PCM format converter plugin
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG PCM
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf-plugin.h"
+#include "xa-audio-decoder-api.h"
+#include "xa-pcm-api.h"
+
+#include <fcntl.h>
+
+/*******************************************************************************
+ * Tracing configuration
+ ******************************************************************************/
+
+TRACE_TAG(INIT, 1);
+TRACE_TAG(PROCESS, 0);
+
+/*******************************************************************************
+ * Local typedefs
+ ******************************************************************************/
+
+/* ...API structure */
+typedef struct XAPcmCodec
+{
+ /* ...codec state */
+ u32 state;
+
+ /* ...sampling rate of input/output signal (informative only) */
+ u32 sample_rate;
+
+ /* ...number of input/output channels */
+ u8 in_channels, out_channels;
+
+ /* ...PCM sample width of input/output streams */
+ u8 in_pcm_width, out_pcm_width;
+
+ /* ...input/output stride size */
+ u8 in_stride, out_stride;
+
+ /* ...channel routing map between input and output */
+ u32 chan_routing;
+
+ /* ...data processing hook */
+ XA_ERRORCODE (*process)(struct XAPcmCodec *);
+
+ /* ...number of samples in input/output buffers */
+ u32 insize, outsize;
+
+ /* ...input/output memory indices */
+ u32 input_idx, output_idx;
+
+ /* ...input/output buffers passed from/to caller */
+ void *input, *output;
+
+ /* ...number of input bytes consumed/produced */
+ u32 consumed, produced;
+
+ /* ...debug - file handles */
+ int f_input, f_output;
+
+} XAPcmCodec;
+
+/*******************************************************************************
+ * Local execution flags
+ ******************************************************************************/
+
+#define XA_PCM_FLAG_PREINIT_DONE (1 << 0)
+#define XA_PCM_FLAG_POSTINIT_DONE (1 << 1)
+#define XA_PCM_FLAG_RUNNING (1 << 2)
+#define XA_PCM_FLAG_EOS (1 << 3)
+#define XA_PCM_FLAG_COMPLETE (1 << 4)
+
+/*******************************************************************************
+ * Local constants definitions
+ ******************************************************************************/
+
+/* ...process at most 1024 samples per call */
+#define XA_PCM_MAX_SAMPLES 1024
+
+/*******************************************************************************
+ * Internal processing functions
+ ******************************************************************************/
+
+/* ...identity translation of PCM16/24 */
+static XA_ERRORCODE xa_pcm_do_execute_copy(XAPcmCodec *d)
+{
+ u32 n = d->insize;
+ u8 k = d->in_channels;
+ u32 length = n * k * (d->in_pcm_width == 16 ? 2 : 4);
+ s16 *input = d->input, *output = d->output;
+
+ TRACE(PROCESS, _b("Copy PCM%d %p to %p (%u samples)"), d->in_pcm_width, input, output, n);
+
+ /* ...check if we have all data setup */
+ XF_CHK_ERR(input && n && output, XA_PCM_EXEC_FATAL_STATE);
+
+ /* ...copy the samples without any processing */
+ memcpy(output, input, length);
+
+ /* ...set number of consumed/produced bytes */
+ d->consumed = length;
+ d->produced = length;
+
+ /* ...reset input buffer length */
+ d->insize = 0;
+
+ /* ...copy input to output */
+ return XA_NO_ERROR;
+}
+
+/* ...data processing for PCM16, channel mapping case */
+static XA_ERRORCODE xa_pcm_do_execute_pcm16_chmap(XAPcmCodec *d)
+{
+ u32 n = d->insize, i;
+ u8 k = d->in_channels, j;
+ u32 chmap = d->chan_routing, map;
+ s16 *input = d->input, *output = d->output;
+ u32 length = n * k * (d->in_pcm_width == 16 ? 2 : 4);
+
+ TRACE(PROCESS, _b("Map PCM16 %p to %p (%u samples, map: %X)"), input, output, n, chmap);
+
+ /* ...check if we have all data setup */
+ XF_CHK_ERR(input && n && output, XA_PCM_EXEC_FATAL_STATE);
+
+#if 0
+ /* ...convert individual samples (that function could be CPU-optimized - tbd) */
+ for (i = 0; i < n; i++, input += k)
+ {
+ /* ...process individual channels in a sample */
+ for (j = 0, map = chmap; j < k; j++, map >>= 4)
+ {
+ u8 m = map & 0xF;
+
+ /* ...fill output channel (zero unused channel) */
+ *output++ = (m < 8 ? input[m] : 0);
+ }
+ }
+
+ /* ...set number of consumed/produced bytes */
+ d->consumed = (u32)((u8 *)input - (u8 *)d->input);
+ d->produced = (u32)((u8 *)output - (u8 *)d->output);
+#else
+ memcpy(output, input, length);
+ /* ...set number of consumed/produced bytes */
+ d->consumed = length;
+ d->produced = length;
+#endif
+ /* ...reset input buffer length */
+ d->insize = 0;
+
+ /* ...copy input to output */
+ return XA_NO_ERROR;
+}
+
+/* ...data processing for PCM24/PCM32, channel mapping case */
+static XA_ERRORCODE xa_pcm_do_execute_pcm24_chmap(XAPcmCodec *d)
+{
+ u32 n = d->insize, i;
+ u8 k = d->in_channels, j;
+ u32 chmap = d->chan_routing, map;
+ s32 *input = d->input, *output = d->output;
+
+ TRACE(PROCESS, _b("Map PCM24 %p to %p (%u samples, map: %X)"), input, output, n, chmap);
+
+ /* ...check if we have all data setup */
+ XF_CHK_ERR(input && n && output, XA_PCM_EXEC_FATAL_STATE);
+
+ /* ...convert individual samples (that function could be CPU-optimized - tbd) */
+ for (i = 0; i < n; i++, input += k)
+ {
+ /* ...process individual channels in a sample */
+ for (j = 0, map = chmap; j < k; j++, map >>= 4)
+ {
+ u8 m = map & 0xF;
+
+ /* ...fill output channel (zero unused channel) */
+ *output++ = (m < 8 ? input[m] : 0);
+ }
+ }
+
+ /* ...set number of consumed/produced bytes */
+ d->consumed = (u32)((u8 *)input - (u8 *)d->input);
+ d->produced = (u32)((u8 *)output - (u8 *)d->output);
+
+ /* ...reset input buffer length */
+ d->insize = 0;
+
+ /* ...copy input to output */
+ return XA_NO_ERROR;
+}
+
+/* ...convert multichannel 24-bit PCM to 16-bit PCM with channel mapping */
+static XA_ERRORCODE xa_pcm_do_execute_pcm24_to_pcm16(XAPcmCodec *d)
+{
+ u32 n = d->insize, i;
+ u8 k = d->in_channels, j;
+ u32 chmap = d->chan_routing, map;
+ s32 *input = d->input;
+ s16 *output = d->output;
+
+ TRACE(PROCESS, _b("Convert PCM24 %p to PCM16 %p (%u samples, map: %X)"), input, output, n, chmap);
+
+ /* ...check if we have all data setup */
+ XF_CHK_ERR(input && n && output, XA_PCM_EXEC_FATAL_STATE);
+
+ /* ...convert individual samples (that function could be CPU-optimized - tbd) */
+ for (i = 0; i < n; i++, input += k)
+ {
+ /* ...process individual channels in a sample */
+ for (j = 0, map = chmap; j < k; j++, map >>= 4)
+ {
+ u8 m = map & 0xF;
+
+ /* ...convert and zero out unused channels */
+ *output++ = (m < 8 ? input[m] >> 16 : 0);
+ }
+ }
+
+ /* ...set number of consumed/produced bytes */
+ d->consumed = (u32)((u8 *)input - (u8 *)d->input);
+ d->produced = (u32)((u8 *)output - (u8 *)d->output);
+
+ /* ...dump output data */
+ //BUG(write(d->f_input, d->input, d->consumed) != d->consumed, _x("%m"));
+ //BUG(write(d->f_output, d->output, d->produced) != d->produced, _x("%m"));
+
+ /* ...reset input buffer length (tbd - need that?) */
+ d->insize = 0;
+
+ /* ...copy input to output */
+ return XA_NO_ERROR;
+}
+
+/* ...convert multichannel 16-bit PCM to 24-bit PCM with channel mapping */
+static XA_ERRORCODE xa_pcm_do_execute_pcm16_to_pcm24(XAPcmCodec *d)
+{
+ u32 n = d->insize, i;
+ u8 k = d->in_channels, j;
+ u32 chmap = d->chan_routing, map;
+ s16 *input = d->input;
+ s32 *output = d->output;
+
+ TRACE(PROCESS, _b("Convert PCM16 %p to PCM24 %p (%u samples, map: %X)"), input, output, n, chmap);
+
+ /* ...check if we have all data setup */
+ XF_CHK_ERR(input && n && output, XA_PCM_EXEC_FATAL_STATE);
+
+ /* ...convert individual samples (that function could be CPU-optimized - tbd) */
+ for (i = 0; i < n; i++, input += k)
+ {
+ /* ...process individual channels in a sample */
+ for (j = 0, map = chmap; j < k; j++, map >>= 4)
+ {
+ u8 m = map & 0xF;
+
+ /* ...convert and zero out unused channels */
+ *output++ = (m < 8 ? input[m] << 16 : 0);
+ }
+ }
+
+ /* ...set number of consumed/produced bytes */
+ d->consumed = (u32)((u8 *)input - (u8 *)d->input);
+ d->produced = (u32)((u8 *)output - (u8 *)d->output);
+
+ /* ...reset input buffer length (tbd - need that?) */
+ d->insize = 0;
+
+ /* ...copy input to output */
+ return XA_NO_ERROR;
+}
+
+/* ...determine if we need to do a channel routing */
+static inline int xa_pcm_is_identity_mapping(u32 chmap, u8 k)
+{
+ u8 j;
+
+ for (j = 0; j < k; j++, chmap >>= 4)
+ if ((chmap & 0xF) != j)
+ return 0;
+
+ return 1;
+}
+
+/* ...runtime initialization */
+static inline XA_ERRORCODE xa_pcm_do_runtime_init(XAPcmCodec *d)
+{
+ u8 in_width = d->in_pcm_width, out_width = d->out_pcm_width;
+ u8 in_ch = d->in_channels, out_ch = d->out_channels;
+ u32 chmap = d->chan_routing;
+
+ /* ...check for supported processing schemes */
+ if (in_width == out_width)
+ {
+ /* ...check if we need to do a channel mapping */
+ if (in_ch != out_ch || !xa_pcm_is_identity_mapping(chmap, in_ch))
+ {
+ /* ...mapping is needed */
+ d->process = (in_width == 16 ? xa_pcm_do_execute_pcm16_chmap : xa_pcm_do_execute_pcm24_chmap);
+ }
+ else
+ {
+ /* ...setup identity translation */
+ d->process = xa_pcm_do_execute_copy;
+ }
+ }
+ else
+ {
+ /* ...samples converion is required */
+ d->process = (in_width == 16 ? xa_pcm_do_execute_pcm16_to_pcm24 : xa_pcm_do_execute_pcm24_to_pcm16);
+ }
+
+ /* ...mark the runtime initialization is completed */
+ d->state = XA_PCM_FLAG_PREINIT_DONE | XA_PCM_FLAG_POSTINIT_DONE | XA_PCM_FLAG_RUNNING;
+
+ TRACE(INIT, _b("PCM format converter initialized: PCM%u -> PCM%u, ich=%u, och=%u, map=%X"), in_width, out_width, in_ch, out_ch, chmap);
+
+ return XA_NO_ERROR;
+}
+
+/*******************************************************************************
+ * Commands processing
+ ******************************************************************************/
+
+/* ...standard codec initialization routine */
+static XA_ERRORCODE xa_pcm_get_api_size(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...return API structure size */
+ *(WORD32 *)pv_value = sizeof(*d);
+
+ return XA_NO_ERROR;
+}
+
+/* ...standard codec initialization routine */
+static XA_ERRORCODE xa_pcm_init(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...sanity check */
+ XF_CHK_ERR(d, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...process particular initialization type */
+ switch (i_idx)
+ {
+ case XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS:
+ {
+ /* ...pre-configuration initialization; reset internal data */
+ memset(d, 0, sizeof(*d));
+
+ /* ...set default parameters */
+ d->in_pcm_width = d->out_pcm_width = 16;
+ d->in_channels = d->out_channels = 2;
+ d->chan_routing = (0 << 0) | (1 << 1);
+ d->sample_rate = 48000;
+
+ /* ...open debug files */
+ //BUG((d->f_input = open("pcm-in.dat", O_WRONLY | O_CREAT, 0664)) < 0, _x("%m"));
+ //BUG((d->f_output = open("pcm-out.dat", O_WRONLY | O_CREAT, 0664)) < 0, _x("%m"));
+
+ /* ...mark pre-initialization is done */
+ d->state = XA_PCM_FLAG_PREINIT_DONE;
+
+ return XA_NO_ERROR;
+ }
+
+ case XA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS:
+ {
+ /* ...post-configuration initialization (all parameters are set) */
+ XF_CHK_ERR(d->state & XA_PCM_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...calculate input sample stride size */
+ d->in_stride = d->in_channels * (d->in_pcm_width == 16 ? 2 : 4);
+ d->out_stride = d->out_channels * (d->out_pcm_width == 16 ? 2 : 4);
+
+ /* ...mark post-initialization is complete */
+ d->state |= XA_PCM_FLAG_POSTINIT_DONE;
+
+ return XA_NO_ERROR;
+ }
+
+ case XA_CMD_TYPE_INIT_PROCESS:
+ {
+ /* ...run-time initialization process; make sure post-init is complete */
+ XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...initialize runtime for specified transformation function */
+ return xa_pcm_do_runtime_init(d);
+ }
+
+ case XA_CMD_TYPE_INIT_DONE_QUERY:
+ {
+ /* ...check for runtime initialization completion; maske usre post-init is complete */
+ XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...put current status */
+ *(WORD32 *)pv_value = (d->state & XA_PCM_FLAG_RUNNING ? 1 : 0);
+
+ return XA_NO_ERROR;
+ }
+
+ default:
+ /* ...unrecognized command */
+ return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE);
+ }
+}
+
+/* ...set configuration parameter */
+static XA_ERRORCODE xa_pcm_set_config_param(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ WORD32 i_value;
+
+ /* ...sanity check */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...configuration is allowed only in PRE-CONFIG state */
+ XF_CHK_ERR(d->state == XA_PCM_FLAG_PREINIT_DONE, XA_PCM_CONFIG_NONFATAL_STATE);
+
+ /* ...get integer parameter value */
+ i_value = *(WORD32 *)pv_value;
+
+ /* ...process individual configuration parameter */
+ switch (i_idx)
+ {
+ case XA_CODEC_CONFIG_PARAM_SAMPLE_RATE:
+ case XA_PCM_CONFIG_PARAM_SAMPLE_RATE:
+ /* ...accept any sampling rate */
+ d->sample_rate = (u32)i_value;
+ return XA_NO_ERROR;
+
+ case XA_PCM_CONFIG_PARAM_IN_PCM_WIDTH:
+ /* ...return input sample bit-width */
+ XF_CHK_ERR(i_value == 16 || i_value == 24, XA_PCM_CONFIG_NONFATAL_RANGE);
+ d->in_pcm_width = (u8)i_value;
+ return XA_NO_ERROR;
+
+ case XA_PCM_CONFIG_PARAM_IN_CHANNELS:
+ /* ...support at most 8-channels stream */
+ XF_CHK_ERR(i_value > 0 && i_value <= 8, XA_PCM_CONFIG_NONFATAL_RANGE);
+ d->in_channels = (u8)i_value;
+ return XA_NO_ERROR;
+
+ case XA_CODEC_CONFIG_PARAM_PCM_WIDTH:
+ case XA_PCM_CONFIG_PARAM_OUT_PCM_WIDTH:
+ /* ...we only support PCM16 and PCM24 */
+ XF_CHK_ERR(i_value == 16 || i_value == 24, XA_PCM_CONFIG_NONFATAL_RANGE);
+ d->out_pcm_width = (u8)i_value;
+ return XA_NO_ERROR;
+
+ case XA_CODEC_CONFIG_PARAM_CHANNELS:
+ case XA_PCM_CONFIG_PARAM_OUT_CHANNELS:
+ /* ...support at most 8-channels stream */
+ XF_CHK_ERR(i_value > 0 && i_value <= 8, XA_API_FATAL_INVALID_CMD_TYPE);
+ d->out_channels = (u8)i_value;
+ return XA_NO_ERROR;
+
+ case XA_PCM_CONFIG_PARAM_CHANROUTING:
+ /* ...accept any channel routing mask */
+ d->chan_routing = (u32)i_value;
+ return XA_NO_ERROR;
+
+ default:
+ /* ...unrecognized parameter */
+ return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE);
+ }
+}
+
+/* ...retrieve configuration parameter */
+static XA_ERRORCODE xa_pcm_get_config_param(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...sanity check */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...make sure pre-configuration is completed */
+ XF_CHK_ERR(d->state & XA_PCM_FLAG_PREINIT_DONE, XA_PCM_CONFIG_NONFATAL_STATE);
+
+ /* ...process individual parameter */
+ switch (i_idx)
+ {
+ case XA_CODEC_CONFIG_PARAM_SAMPLE_RATE:
+ case XA_PCM_CONFIG_PARAM_SAMPLE_RATE:
+ /* ...return output sampling frequency */
+ *(WORD32 *)pv_value = d->sample_rate;
+ return XA_NO_ERROR;
+
+ case XA_PCM_CONFIG_PARAM_IN_PCM_WIDTH:
+ /* ...return input sample bit-width */
+ *(WORD32 *)pv_value = d->in_pcm_width;
+ return XA_NO_ERROR;
+
+ case XA_PCM_CONFIG_PARAM_IN_CHANNELS:
+ /* ...return number of input channels */
+ *(WORD32 *)pv_value = d->in_channels;
+ return XA_NO_ERROR;
+
+ case XA_CODEC_CONFIG_PARAM_PCM_WIDTH:
+ case XA_PCM_CONFIG_PARAM_OUT_PCM_WIDTH:
+ /* ...return output sample bit-width */
+ *(WORD32 *)pv_value = d->out_pcm_width;
+ return XA_NO_ERROR;
+
+ case XA_CODEC_CONFIG_PARAM_CHANNELS:
+ case XA_PCM_CONFIG_PARAM_OUT_CHANNELS:
+ /* ...return number of output channels */
+ *(WORD32 *)pv_value = d->out_channels;
+ return XA_NO_ERROR;
+
+ case XA_PCM_CONFIG_PARAM_CHANROUTING:
+ /* ...return current channel routing mask */
+ *(WORD32 *)pv_value = d->chan_routing;
+ return XA_NO_ERROR;
+
+ default:
+ /* ...unrecognized parameter */
+ return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE);
+ }
+}
+
+/* ...execution command */
+static XA_ERRORCODE xa_pcm_execute(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity check */
+ XF_CHK_ERR(d, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...codec must be in running state */
+ XF_CHK_ERR(d->state & XA_PCM_FLAG_RUNNING, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...process individual command type */
+ switch (i_idx)
+ {
+ case XA_CMD_TYPE_DO_EXECUTE:
+ /* ...do data processing (tbd - result code is bad) */
+ if (d->insize != 0)
+ {
+ XF_CHK_ERR(!XA_ERROR_SEVERITY(d->process(d)), XA_PCM_EXEC_FATAL_STATE);
+ }
+
+ /* ...process end-of-stream condition */
+ (d->state & XA_PCM_FLAG_EOS ? d->state ^= XA_PCM_FLAG_EOS | XA_PCM_FLAG_COMPLETE : 0);
+
+ return XA_NO_ERROR;
+
+ case XA_CMD_TYPE_DONE_QUERY:
+ /* ...check if processing is complete */
+ XF_CHK_ERR(pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...return completion status */
+ *(WORD32 *)pv_value = (d->state & XA_PCM_FLAG_COMPLETE ? 1 : 0);
+
+ return XA_NO_ERROR;
+
+ case XA_CMD_TYPE_DO_RUNTIME_INIT:
+ /* ...reset codec operation */
+ return xa_pcm_do_runtime_init(d);
+
+ default:
+ /* ...unrecognized command */
+ return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE);
+ }
+}
+
+/* ...set number of input bytes */
+static XA_ERRORCODE xa_pcm_set_input_bytes(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ u32 in_stride = d->in_stride;
+ u32 insize;
+
+ /* ...sanity check */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...track index must be valid */
+ XF_CHK_ERR(i_idx == 0, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...component must be initialized */
+ XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...input buffer must exist */
+ XF_CHK_ERR(d->input, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...convert bytes into samples (don't like division, but still...) */
+ insize = *(WORD32 *)pv_value / in_stride;
+
+ /* ...make sure we have integral amount of samples */
+ XF_CHK_ERR(*(WORD32 *)pv_value == insize * in_stride, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...limit input buffer size to maximal value*/
+ d->insize = (insize > XA_PCM_MAX_SAMPLES ? XA_PCM_MAX_SAMPLES : insize);
+
+ return XA_NO_ERROR;
+}
+
+/* ...get number of output bytes produced */
+static XA_ERRORCODE xa_pcm_get_output_bytes(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...sanity check */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...buffer index must be sane */
+ XF_CHK_ERR(i_idx == 1, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...component must be initialized */
+ XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...output buffer must exist */
+ XF_CHK_ERR(d->output, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...return number of produced bytes (and reset instantly? - tbd) */
+ *(WORD32 *)pv_value = d->produced;
+
+ return XA_NO_ERROR;
+}
+
+/* ...get number of consumed bytes */
+static XA_ERRORCODE xa_pcm_get_curidx_input_buf(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...sanity check */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...index must be valid */
+ XF_CHK_ERR(i_idx == 0, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...input buffer must exist */
+ XF_CHK_ERR(d->input, XA_PCM_EXEC_NONFATAL_INPUT);
+
+ /* ...return number of bytes consumed */
+ *(WORD32 *)pv_value = d->consumed;
+
+ return XA_NO_ERROR;
+}
+
+/* ...end-of-stream processing */
+static XA_ERRORCODE xa_pcm_input_over(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...sanity check */
+ XF_CHK_ERR(d, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...put end-of-stream flag */
+ d->state |= XA_PCM_FLAG_EOS;
+
+ TRACE(PROCESS, _b("Input-over-condition signalled"));
+
+ return XA_NO_ERROR;
+}
+
+/* ..get total amount of data for memory tables */
+static XA_ERRORCODE xa_pcm_get_memtabs_size(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity checks */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...check mixer is pre-initialized */
+ XF_CHK_ERR(d->state & XA_PCM_FLAG_PREINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...we have all our tables inside API structure */
+ *(WORD32 *)pv_value = 0;
+
+ return XA_NO_ERROR;
+}
+
+/* ...return total amount of memory buffers */
+static XA_ERRORCODE xa_pcm_get_n_memtabs(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity checks */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...we have 1 input buffer and 1 output buffer */
+ *(WORD32 *)pv_value = 1 + 1;
+
+ return XA_NO_ERROR;
+}
+
+/* ...return memory type data */
+static XA_ERRORCODE xa_pcm_get_mem_info_type(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity check */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...codec must be in post-init state */
+ XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...check buffer type */
+ switch (i_idx)
+ {
+ case 0:
+ *(WORD32 *)pv_value = XA_MEMTYPE_INPUT;
+ return XA_NO_ERROR;
+
+ case 1:
+ *(WORD32 *)pv_value = XA_MEMTYPE_OUTPUT;
+ return XA_NO_ERROR;
+
+ default:
+ return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE);
+ }
+}
+
+/* ...return memory buffer size */
+static XA_ERRORCODE xa_pcm_get_mem_info_size(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity check */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...codec must be in post-init state */
+ XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...determine particular buffer */
+ switch (i_idx)
+ {
+ case 0:
+ /* ...input buffer size can be any */
+ *(WORD32 *)pv_value = 0;
+ return XA_NO_ERROR;
+
+ case 1:
+ /* ...output buffer size is dependent on stride */
+ *(WORD32 *)pv_value = XA_PCM_MAX_SAMPLES * d->out_stride;
+ return XA_NO_ERROR;
+
+ default:
+ /* ...invalid buffer index */
+ return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE);
+ }
+}
+
+/* ...return memory alignment data */
+static XA_ERRORCODE xa_pcm_get_mem_info_alignment(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity check */
+ XF_CHK_ERR(d && pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...codec must be in post-initialization state */
+ XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...all buffers are 4-bytes aligned */
+ *(WORD32 *)pv_value = 4;
+
+ return XA_NO_ERROR;
+}
+
+/* ...set memory pointer */
+static XA_ERRORCODE xa_pcm_set_mem_ptr(XAPcmCodec *d, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...basic sanity check */
+ XF_CHK_ERR(d, XA_API_FATAL_INVALID_CMD_TYPE);
+ XF_CHK_ERR(pv_value, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...codec must be in post-initialized state */
+ XF_CHK_ERR(d->state & XA_PCM_FLAG_POSTINIT_DONE, XA_API_FATAL_INVALID_CMD_TYPE);
+
+ /* ...select memory buffer */
+ switch (i_idx)
+ {
+ case 0:
+ /* ...input buffer */
+ d->input = pv_value;
+ return XA_NO_ERROR;
+
+ case 1:
+ /* ...output buffer */
+ d->output = pv_value;
+ return XA_NO_ERROR;
+
+ default:
+ /* ...invalid index */
+ return XF_CHK_ERR(0, XA_API_FATAL_INVALID_CMD_TYPE);
+ }
+}
+
+/*******************************************************************************
+ * API command hooks
+ ******************************************************************************/
+
+static XA_ERRORCODE (* const xa_pcm_api[])(XAPcmCodec *, WORD32, pVOID) =
+{
+ [XA_API_CMD_GET_API_SIZE] = xa_pcm_get_api_size,
+
+ [XA_API_CMD_INIT] = xa_pcm_init,
+ [XA_API_CMD_SET_CONFIG_PARAM] = xa_pcm_set_config_param,
+ [XA_API_CMD_GET_CONFIG_PARAM] = xa_pcm_get_config_param,
+
+ [XA_API_CMD_EXECUTE] = xa_pcm_execute,
+ [XA_API_CMD_SET_INPUT_BYTES] = xa_pcm_set_input_bytes,
+ [XA_API_CMD_GET_OUTPUT_BYTES] = xa_pcm_get_output_bytes,
+ [XA_API_CMD_GET_CURIDX_INPUT_BUF] = xa_pcm_get_curidx_input_buf,
+ [XA_API_CMD_INPUT_OVER] = xa_pcm_input_over,
+
+ [XA_API_CMD_GET_MEMTABS_SIZE] = xa_pcm_get_memtabs_size,
+ [XA_API_CMD_GET_N_MEMTABS] = xa_pcm_get_n_memtabs,
+ [XA_API_CMD_GET_MEM_INFO_TYPE] = xa_pcm_get_mem_info_type,
+ [XA_API_CMD_GET_MEM_INFO_SIZE] = xa_pcm_get_mem_info_size,
+ [XA_API_CMD_GET_MEM_INFO_ALIGNMENT] = xa_pcm_get_mem_info_alignment,
+ [XA_API_CMD_SET_MEM_PTR] = xa_pcm_set_mem_ptr,
+};
+
+/* ...total numer of commands supported */
+#define XA_PCM_API_COMMANDS_NUM (sizeof(xa_pcm_api) / sizeof(xa_pcm_api[0]))
+
+/*******************************************************************************
+ * API entry point
+ ******************************************************************************/
+
+XA_ERRORCODE xa_pcm_codec(xa_codec_handle_t p_xa_module_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value)
+{
+ XAPcmCodec *d = (XAPcmCodec *) p_xa_module_obj;
+
+ /* ...check if command index is sane */
+ XF_CHK_ERR(i_cmd < XA_PCM_API_COMMANDS_NUM, XA_API_FATAL_INVALID_CMD);
+
+ /* ...see if command is defined */
+ XF_CHK_ERR(xa_pcm_api[i_cmd], XA_API_FATAL_INVALID_CMD);
+
+ /* ...execute requested command */
+ return xa_pcm_api[i_cmd](d, i_idx, pv_value);
+}
diff --git a/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a b/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a
new file mode 100644
index 00000000..cb284459
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/lib/hifi3/xa_vorbis_dec.a
Binary files differ
diff --git a/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa-vorbis-decoder.c b/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa-vorbis-decoder.c
new file mode 100644
index 00000000..43220ef3
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa-vorbis-decoder.c
@@ -0,0 +1,84 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/*******************************************************************************
+ * xa-vorbis-decoder.c
+ *
+ * VORBIS decoder plugin - thin wrapper around VORBISDEC library
+ *
+ ******************************************************************************/
+
+#define MODULE_TAG VORBISDEC
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf-plugin.h"
+#include "audio/xa-audio-decoder-api.h"
+#include "xa_vorbis_dec_api.h"
+
+/*******************************************************************************
+ * Override GET-CONFIG-PARAM function
+ ******************************************************************************/
+
+static inline XA_ERRORCODE xa_vorbis_get_config_param(xa_codec_handle_t handle, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...translate "standard" parameter index into internal value */
+ switch (i_idx)
+ {
+ case XA_CODEC_CONFIG_PARAM_CHANNELS:
+ /* ...return number of output channels */
+ i_idx = XA_VORBISDEC_CONFIG_PARAM_NUM_CHANNELS;
+ break;
+
+ case XA_CODEC_CONFIG_PARAM_SAMPLE_RATE:
+ /* ...return output sampling frequency */
+ i_idx = XA_VORBISDEC_CONFIG_PARAM_SAMP_FREQ;
+ break;
+
+ case XA_CODEC_CONFIG_PARAM_PCM_WIDTH:
+ /* ...return sample bit-width */
+ i_idx = XA_VORBISDEC_CONFIG_PARAM_PCM_WDSZ;
+ break;
+ }
+
+ /* ...pass to library */
+ return xa_vorbis_dec(handle, XA_API_CMD_GET_CONFIG_PARAM, i_idx, pv_value);
+}
+
+/*******************************************************************************
+ * API entry point
+ ******************************************************************************/
+
+XA_ERRORCODE xa_vorbis_decoder(xa_codec_handle_t p_xa_module_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value)
+{
+ /* ...process common audio-decoder commands */
+ if (i_cmd == XA_API_CMD_GET_CONFIG_PARAM)
+ {
+ return xa_vorbis_get_config_param(p_xa_module_obj, i_idx, pv_value);
+ }
+ else
+ {
+ return xa_vorbis_dec(p_xa_module_obj, i_cmd, i_idx, pv_value);
+ }
+}
diff --git a/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa_vorbis_dec_api.h b/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa_vorbis_dec_api.h
new file mode 100644
index 00000000..f99660f8
--- /dev/null
+++ b/hifi/xaf/hifi-dpf/plugins/cadence/vorbis_dec/xa_vorbis_dec_api.h
@@ -0,0 +1,121 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+
+#ifndef __XA_VORBIS_DEC_API_H__
+#define __XA_VORBIS_DEC_API_H__
+
+#include <xa_memory_standards.h>
+
+/* vorbis_dec-specific configuration parameters */
+enum xa_config_param_vorbis_dec
+{
+ XA_VORBISDEC_CONFIG_PARAM_SAMP_FREQ = 0,
+ XA_VORBISDEC_CONFIG_PARAM_NUM_CHANNELS = 1,
+ XA_VORBISDEC_CONFIG_PARAM_PCM_WDSZ = 2,
+ XA_VORBISDEC_CONFIG_PARAM_COMMENT_MEM_PTR = 3,
+ XA_VORBISDEC_CONFIG_PARAM_COMMENT_MEM_SIZE = 4,
+ XA_VORBISDEC_CONFIG_PARAM_GET_CUR_BITRATE = 5,
+ XA_VORBISDEC_CONFIG_PARAM_RAW_VORBIS_FILE_MODE = 6,
+ XA_VORBISDEC_CONFIG_PARAM_RAW_VORBIS_LAST_PKT_GRANULE_POS = 7,
+ XA_VORBISDEC_CONFIG_PARAM_OGG_MAX_PAGE_SIZE = 8,
+ XA_VORBISDEC_CONFIG_PARAM_RUNTIME_MEM = 9
+};
+
+/* commands */
+#include <xa_apicmd_standards.h>
+
+/* vorbis_dec-specific command types */
+/* (none) */
+
+/* error codes */
+#include <xa_error_standards.h>
+#define XA_CODEC_VORBIS_DEC 7
+
+/* vorbis_dec-specific error codes */
+
+/*****************************************************************************/
+/* Class 1: Configuration Errors */
+/*****************************************************************************/
+/* Nonfatal Errors */
+enum xa_error_nonfatal_config_vorbis_dec
+{
+ XA_VORBISDEC_CONFIG_NONFATAL_GROUPED_STREAM = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_VORBIS_DEC, 0),
+ XA_VORBISDEC_CONFIG_NONFATAL_BAD_PARAM = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_VORBIS_DEC, 1)
+};
+
+/* Fatal Errors */
+enum xa_error_fatal_config_vorbis_dec
+{
+ XA_VORBISDEC_CONFIG_FATAL_BADHDR = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 0),
+ XA_VORBISDEC_CONFIG_FATAL_NOTVORBIS = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 1),
+ XA_VORBISDEC_CONFIG_FATAL_BADINFO = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 2),
+ XA_VORBISDEC_CONFIG_FATAL_BADVERSION = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 3),
+ XA_VORBISDEC_CONFIG_FATAL_BADBOOKS = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 4),
+ XA_VORBISDEC_CONFIG_FATAL_CODEBOOK_DECODE = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 5),
+ XA_VORBISDEC_CONFIG_FATAL_INVALID_PARAM = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 6)
+};
+
+/*****************************************************************************/
+/* Class 2: Execution Errors */
+/*****************************************************************************/
+/* Nonfatal Errors */
+enum xa_error_nonfatal_execute_vorbis_dec
+{
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_HOLE = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 0),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_NOTAUDIO = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 1),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_BADPACKET = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 2),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_RUNTIME_DECODE_FLUSH_IN_PROGRESS = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 3),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_INVALID_STRM_POS = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 4),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_INSUFFICIENT_DATA = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 5),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_UNEXPECTED_IDENT_PKT_RECEIVED = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 6),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_UNEXPECTED_HEADER_PKT_RECEIVED = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 7)
+};
+/* Fatal Errors */
+enum xa_error_fatal_execute_vorbis_dec
+{
+ XA_VORBISDEC_EXECUTE_FATAL_PERSIST_ALLOC = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 0),
+ XA_VORBISDEC_EXECUTE_FATAL_SCRATCH_ALLOC = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 1),
+ XA_VORBISDEC_EXECUTE_FATAL_CORRUPT_STREAM = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 2),
+ XA_VORBISDEC_EXECUTE_FATAL_INSUFFICIENT_INP_BUF_SIZE = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 3)
+};
+
+#include "xa_type_def.h"
+
+#ifdef __cplusplus
+ extern "C" {
+#endif /* __cplusplus */
+
+ xa_codec_func_t xa_vorbis_dec;
+
+#ifdef __cplusplus
+ }
+#endif /* __cplusplus */
+
+#endif /* __XA_VORBIS_DEC_API_H__ */
diff --git a/hifi/xaf/host-apf/Android.mk b/hifi/xaf/host-apf/Android.mk
new file mode 100644
index 00000000..28e71011
--- /dev/null
+++ b/hifi/xaf/host-apf/Android.mk
@@ -0,0 +1,66 @@
+LOCAL_PATH := $(call my-dir)
+################################################################################
+# libxtensa_proxy library building
+################################################################################
+
+include $(CLEAR_VARS)
+common_C_INCLUDES := \
+ $(LOCAL_PATH)/include \
+ $(LOCAL_PATH)/include/audio \
+ $(LOCAL_PATH)/include/os/android \
+ $(LOCAL_PATH)/include/sys/fio \
+ $(LOCAL_PATH)/playback \
+ $(LOCAL_PATH)/playback/tinyalsa \
+ $(LOCAL_PATH)/utest/include
+
+LOCAL_SRC_FILES := \
+ proxy/xf-proxy.c \
+ proxy/xaf-api.c \
+ proxy/xf-trace.c \
+ proxy/xf-fio.c \
+ playback/xa_playback.c \
+ playback/tinyalsa/pcm.c \
+ utest/xaf-utils-test.c \
+ utest/xaf-mem-test.c
+
+C_FLAGS := -DXF_TRACE=0 -Wall -Werror -Wno-everything
+
+LOCAL_C_INCLUDES := $(common_C_INCLUDES)
+LOCAL_CFLAGS := $(C_FLAGS)
+LOCAL_MODULE := libxtensa_proxy
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_STATIC_LIBRARY)
+
+################################################################################
+# xaf-dec-test: fileinput->ogg/pcm decoder->speaker output
+################################################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE := xaf-dec-test
+
+LOCAL_SRC_FILES := \
+ utest/xaf-dec-test.c
+
+LOCAL_C_INCLUDES := $(common_C_INCLUDES)
+LOCAL_CFLAGS := $(C_FLAGS)
+LOCAL_STATIC_LIBRARIES := libxtensa_proxy
+LOCAL_SHARED_LIBRARIES := liblog libcutils
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
+
+################################################################################
+# xaf-dec-mix-test: fileinput->ogg orpcm decoder->Mixer->speaker output
+################################################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE := xaf-dec-mix-test
+
+LOCAL_SRC_FILES := \
+ utest/xaf-dec-mix-test.c
+
+LOCAL_C_INCLUDES := $(common_C_INCLUDES)
+LOCAL_CFLAGS := $(C_FLAGS)
+LOCAL_STATIC_LIBRARIES := libxtensa_proxy
+LOCAL_SHARED_LIBRARIES := liblog libcutils
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_EXECUTABLE)
+
diff --git a/hifi/xaf/host-apf/include/audio/xa-audio-decoder-api.h b/hifi/xaf/host-apf/include/audio/xa-audio-decoder-api.h
new file mode 100644
index 00000000..f82544c8
--- /dev/null
+++ b/hifi/xaf/host-apf/include/audio/xa-audio-decoder-api.h
@@ -0,0 +1,46 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XA_ADEC_API_H__
+#define __XA_ADEC_API_H__
+
+/* ...generic audio-decoder configuration parameters */
+enum xa_config_param_codec {
+ XA_CODEC_CONFIG_PARAM_CHANNELS = 0x10000 + 0,
+ XA_CODEC_CONFIG_PARAM_SAMPLE_RATE = 0x10000 + 1,
+ XA_CODEC_CONFIG_PARAM_PCM_WIDTH = 0x10000 + 2,
+ XA_CODEC_CONFIG_PARAM_PRODUCED = 0x10000 + 3
+};
+
+/* ...ports indices */
+enum xa_codec_ports {
+ XA_CODEC_INPUT_PORT = 0,
+ XA_CODEC_OUTPUT_PORT = 1
+};
+
+/* ...non-fatal execution errors */
+enum
+{
+ XA_CODEC_EXEC_NO_DATA = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_GENERIC, 0)
+};
+
+#endif
diff --git a/hifi/xaf/host-apf/include/audio/xa-mixer-api.h b/hifi/xaf/host-apf/include/audio/xa-mixer-api.h
new file mode 100644
index 00000000..c9695b40
--- /dev/null
+++ b/hifi/xaf/host-apf/include/audio/xa-mixer-api.h
@@ -0,0 +1,154 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XA_MIXER_API_H__
+#define __XA_MIXER_API_H__
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/* ...generic commands */
+#include "xa_apicmd_standards.h"
+
+/* ...generic error codes */
+#include "xa_error_standards.h"
+
+/* ...common types */
+#include "xa_type_def.h"
+
+/*******************************************************************************
+ * Constants definitions
+ ******************************************************************************/
+
+/* ...mixer-specific configuration parameters */
+enum xa_config_param_mixer {
+ XA_MIXER_CONFIG_PARAM_INPUT_TRACKS = 0,
+ XA_MIXER_CONFIG_PARAM_PCM_WIDTH = 1,
+ XA_MIXER_CONFIG_PARAM_CHANNELS = 2,
+ XA_MIXER_CONFIG_PARAM_SAMPLE_RATE = 4,
+ XA_MIXER_CONFIG_PARAM_FRAME_SIZE = 5,
+ XA_MIXER_CONFIG_PARAM_BUFFER_SIZE = 6,
+ XA_MIXER_CONFIG_PARAM_VOLUME = 7,
+ XA_MIXER_CONFIG_PARAM_NUM = 8
+};
+
+/* ...component identifier (informative) */
+#define XA_CODEC_MIXER 1
+
+/* ...global limitation - maximal mixer track number */
+#define XA_MIXER_MAX_TRACK_NUMBER 4
+
+/* ...volume representation */
+#define __XA_MIXER_VOLUME(v) \
+ ({ u32 __v = (u32)((v) * (1 << 12)); (__v > 0xFFFF ? __v = 0xFFFF : 0); (u16)__v; })
+
+/* ...mixer volume setting command encoding */
+#define XA_MIXER_VOLUME(track, channel, volume) \
+ (__XA_MIXER_VOLUME(volume) | ((track) << 16) | ((channel) << 20))
+
+/*******************************************************************************
+ * Class 0: API Errors
+ ******************************************************************************/
+
+#define XA_MIXER_API_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_api, XA_CODEC_MIXER, (e))
+
+#define XA_MIXER_API_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_MIXER, (e))
+
+enum xa_error_nonfatal_api_mixer {
+ XA_MIXER_API_NONFATAL_MAX = XA_MIXER_API_NONFATAL(0)
+};
+
+enum xa_error_fatal_api_mixer {
+ XA_MIXER_API_FATAL_MAX = XA_MIXER_API_FATAL(0)
+};
+
+/*******************************************************************************
+ * Class 1: Configuration Errors
+ ******************************************************************************/
+
+#define XA_MIXER_CONFIG_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_MIXER, (e))
+
+#define XA_MIXER_CONFIG_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_MIXER, (e))
+
+enum xa_error_nonfatal_config_mixer {
+ XA_MIXER_CONFIG_NONFATAL_RANGE = XA_MIXER_CONFIG_NONFATAL(0),
+ XA_MIXER_CONFIG_NONFATAL_STATE = XA_MIXER_CONFIG_NONFATAL(1),
+ XA_MIXER_CONFIG_NONFATAL_MAX = XA_MIXER_CONFIG_NONFATAL(2)
+};
+
+enum xa_error_fatal_config_mixer {
+ XA_MIXER_CONFIG_FATAL_RANGE = XA_MIXER_CONFIG_FATAL(0),
+ XA_MIXER_CONFIG_FATAL_TRACK_STATE = XA_MIXER_CONFIG_FATAL(0 + XA_MIXER_CONFIG_NONFATAL_MAX),
+ XA_MIXER_CONFIG_FATAL_MAX = XA_MIXER_CONFIG_FATAL(1)
+};
+
+/*******************************************************************************
+ * Class 2: Execution Class Errors
+ ******************************************************************************/
+
+#define XA_MIXER_EXEC_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_MIXER, (e))
+
+#define XA_MIXER_EXEC_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_MIXER, (e))
+
+enum xa_error_nonfatal_execute_mixer {
+ XA_MIXER_EXEC_NONFATAL_STATE = XA_MIXER_EXEC_NONFATAL(0),
+ XA_MIXER_EXEC_NONFATAL_NO_DATA = XA_MIXER_EXEC_NONFATAL(1),
+ XA_MIXER_EXEC_NONFATAL_INPUT = XA_MIXER_EXEC_NONFATAL(2),
+ XA_MIXER_EXEC_NONFATAL_OUTPUT = XA_MIXER_EXEC_NONFATAL(3),
+ XA_MIXER_EXEC_NONFATAL_MAX = XA_MIXER_EXEC_NONFATAL(4)
+};
+
+enum xa_error_fatal_execute_mixer {
+ XA_MIXER_EXEC_FATAL_STATE = XA_MIXER_EXEC_FATAL(0),
+ XA_MIXER_EXEC_FATAL_INPUT = XA_MIXER_EXEC_FATAL(1),
+ XA_MIXER_EXEC_FATAL_OUTPUT = XA_MIXER_EXEC_FATAL(2),
+ XA_MIXER_EXEC_FATAL_MAX = XA_MIXER_EXEC_FATAL(3)
+};
+
+/*******************************************************************************
+ * API function definition (tbd)
+ ******************************************************************************/
+
+#if defined(USE_DLL) && defined(_WIN32)
+#define DLL_SHARED __declspec(dllimport)
+#elif defined (_WINDLL)
+#define DLL_SHARED __declspec(dllexport)
+#else
+#define DLL_SHARED
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif /* __cplusplus */
+DLL_SHARED xa_codec_func_t xa_mixer;
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus */
+
+#endif /* __XA_MIXER_API_H__ */
diff --git a/hifi/xaf/host-apf/include/audio/xa-pcm-api.h b/hifi/xaf/host-apf/include/audio/xa-pcm-api.h
new file mode 100644
index 00000000..94fb1362
--- /dev/null
+++ b/hifi/xaf/host-apf/include/audio/xa-pcm-api.h
@@ -0,0 +1,138 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XA_PCM_API_H__
+#define __XA_PCM_API_H__
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xa_type_def.h"
+#include "xa_error_standards.h"
+#include "xa_apicmd_standards.h"
+#include "xa_memory_standards.h"
+
+/*******************************************************************************
+ * Constants definitions
+ ******************************************************************************/
+
+/* ...codec-specific configuration parameters */
+enum xa_config_param_pcm {
+ XA_PCM_CONFIG_PARAM_SAMPLE_RATE = 0,
+ XA_PCM_CONFIG_PARAM_IN_PCM_WIDTH = 1,
+ XA_PCM_CONFIG_PARAM_IN_CHANNELS = 2,
+ XA_PCM_CONFIG_PARAM_OUT_PCM_WIDTH = 3,
+ XA_PCM_CONFIG_PARAM_OUT_CHANNELS = 4,
+ XA_PCM_CONFIG_PARAM_CHANROUTING = 5,
+ XA_PCM_CONFIG_PARAM_NUM = 6,
+};
+
+/* ...component identifier (informative) */
+#define XA_CODEC_PCM 16
+
+/*******************************************************************************
+ * Class 0: API Errors
+ ******************************************************************************/
+
+#define XA_PCM_API_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_api, XA_CODEC_PCM, (e))
+
+#define XA_PCM_API_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_PCM, (e))
+
+enum xa_error_nonfatal_api_pcm {
+ XA_PCM_API_NONFATAL_MAX = XA_PCM_API_NONFATAL(0)
+};
+
+enum xa_error_fatal_api_pcm {
+ XA_PCM_API_FATAL_MAX = XA_PCM_API_FATAL(0)
+};
+
+/*******************************************************************************
+ * Class 1: Configuration Errors
+ ******************************************************************************/
+
+#define XA_PCM_CONFIG_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_PCM, (e))
+
+#define XA_PCM_CONFIG_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_PCM, (e))
+
+enum xa_error_nonfatal_config_pcm {
+ XA_PCM_CONFIG_NONFATAL_RANGE = XA_PCM_CONFIG_NONFATAL(0),
+ XA_PCM_CONFIG_NONFATAL_STATE = XA_PCM_CONFIG_NONFATAL(1),
+ XA_PCM_CONFIG_NONFATAL_MAX = XA_PCM_CONFIG_NONFATAL(2)
+};
+
+enum xa_error_fatal_config_pcm {
+ XA_PCM_CONFIG_FATAL_RANGE = XA_PCM_CONFIG_FATAL(0),
+ XA_PCM_CONFIG_FATAL_MAX = XA_PCM_CONFIG_FATAL(1)
+};
+
+/*******************************************************************************
+ * Class 2: Execution Class Errors
+ ******************************************************************************/
+
+#define XA_PCM_EXEC_NONFATAL(e) \
+ XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_PCM, (e))
+
+#define XA_PCM_EXEC_FATAL(e) \
+ XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_PCM, (e))
+
+enum xa_error_nonfatal_execute_pcm {
+ XA_PCM_EXEC_NONFATAL_STATE = XA_PCM_EXEC_NONFATAL(0),
+ XA_PCM_EXEC_NONFATAL_NO_DATA = XA_PCM_EXEC_NONFATAL(1),
+ XA_PCM_EXEC_NONFATAL_INPUT = XA_PCM_EXEC_NONFATAL(2),
+ XA_PCM_EXEC_NONFATAL_OUTPUT = XA_PCM_EXEC_NONFATAL(3),
+ XA_PCM_EXEC_NONFATAL_MAX = XA_PCM_EXEC_NONFATAL(4)
+};
+
+enum xa_error_fatal_execute_pcm {
+ XA_PCM_EXEC_FATAL_STATE = XA_PCM_EXEC_FATAL(0),
+ XA_PCM_EXEC_FATAL_INPUT = XA_PCM_EXEC_FATAL(1),
+ XA_PCM_EXEC_FATAL_OUTPUT = XA_PCM_EXEC_FATAL(2),
+ XA_PCM_EXEC_FATAL_MAX = XA_PCM_EXEC_FATAL(3)
+};
+
+/*******************************************************************************
+ * API function definition
+ ******************************************************************************/
+
+#if defined(USE_DLL) && defined(_WIN32)
+#define DLL_SHARED __declspec(dllimport)
+#elif defined (_WINDLL)
+#define DLL_SHARED __declspec(dllexport)
+#else
+#define DLL_SHARED
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif /* __cplusplus */
+DLL_SHARED xa_codec_func_t xa_pcm_codec;
+#if defined(__cplusplus)
+}
+#endif /* __cplusplus */
+
+#endif /* __XA_PCM_API_H__ */
+
diff --git a/hifi/xaf/host-apf/include/audio/xa_apicmd_standards.h b/hifi/xaf/host-apf/include/audio/xa_apicmd_standards.h
new file mode 100644
index 00000000..eb1b78e1
--- /dev/null
+++ b/hifi/xaf/host-apf/include/audio/xa_apicmd_standards.h
@@ -0,0 +1,107 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+#ifndef __XA_API_CMD_STANDARDS_H__
+#define __XA_API_CMD_STANDARDS_H__
+
+/*****************************************************************************/
+/* Standard API commands */
+/*****************************************************************************/
+
+enum xa_api_cmd_generic {
+ XA_API_CMD_GET_LIB_ID_STRINGS = 0x0001,
+
+ XA_API_CMD_GET_API_SIZE = 0x0002,
+ XA_API_CMD_INIT = 0x0003,
+
+ XA_API_CMD_SET_CONFIG_PARAM = 0x0004,
+ XA_API_CMD_GET_CONFIG_PARAM = 0x0005,
+
+ XA_API_CMD_GET_MEMTABS_SIZE = 0x0006,
+ XA_API_CMD_SET_MEMTABS_PTR = 0x0007,
+ XA_API_CMD_GET_N_MEMTABS = 0x0008,
+
+ XA_API_CMD_EXECUTE = 0x0009,
+
+ XA_API_CMD_PUT_INPUT_QUERY = 0x000A,
+ XA_API_CMD_GET_CURIDX_INPUT_BUF = 0x000B,
+ XA_API_CMD_SET_INPUT_BYTES = 0x000C,
+ XA_API_CMD_GET_OUTPUT_BYTES = 0x000D,
+ XA_API_CMD_INPUT_OVER = 0x000E,
+
+ XA_API_CMD_GET_MEM_INFO_SIZE = 0x0010,
+ XA_API_CMD_GET_MEM_INFO_ALIGNMENT = 0x0011,
+ XA_API_CMD_GET_MEM_INFO_TYPE = 0x0012,
+ XA_API_CMD_GET_MEM_INFO_PLACEMENT = 0x0013,
+ XA_API_CMD_GET_MEM_INFO_PRIORITY = 0x0014,
+ XA_API_CMD_SET_MEM_PTR = 0x0015,
+ XA_API_CMD_SET_MEM_INFO_SIZE = 0x0016,
+ XA_API_CMD_SET_MEM_PLACEMENT = 0x0017,
+
+ XA_API_CMD_GET_N_TABLES = 0x0018,
+ XA_API_CMD_GET_TABLE_INFO_SIZE = 0x0019,
+ XA_API_CMD_GET_TABLE_INFO_ALIGNMENT = 0x001A,
+ XA_API_CMD_GET_TABLE_INFO_PRIORITY = 0x001B,
+ XA_API_CMD_SET_TABLE_PTR = 0x001C,
+ XA_API_CMD_GET_TABLE_PTR = 0x001D
+};
+
+/*****************************************************************************/
+/* Standard API command indices */
+/*****************************************************************************/
+
+enum xa_cmd_type_generic {
+ /* XA_API_CMD_GET_LIB_ID_STRINGS indices */
+ XA_CMD_TYPE_LIB_NAME = 0x0100,
+ XA_CMD_TYPE_LIB_VERSION = 0x0200,
+ XA_CMD_TYPE_API_VERSION = 0x0300,
+
+ /* XA_API_CMD_INIT indices */
+ XA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS = 0x0100,
+ XA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS = 0x0200,
+ XA_CMD_TYPE_INIT_PROCESS = 0x0300,
+ XA_CMD_TYPE_INIT_DONE_QUERY = 0x0400,
+
+ /* XA_API_CMD_EXECUTE indices */
+ XA_CMD_TYPE_DO_EXECUTE = 0x0100,
+ XA_CMD_TYPE_DONE_QUERY = 0x0200,
+ XA_CMD_TYPE_DO_RUNTIME_INIT = 0x0300
+};
+
+
+/*****************************************************************************/
+/* Standard API configuration parameters */
+/*****************************************************************************/
+
+enum xa_config_param_generic {
+ XA_CONFIG_PARAM_CUR_INPUT_STREAM_POS = 0x0100,
+ XA_CONFIG_PARAM_GEN_INPUT_STREAM_POS = 0x0200,
+};
+
+#endif /* __XA_API_CMD_STANDARDS_H__ */
diff --git a/hifi/xaf/host-apf/include/audio/xa_error_standards.h b/hifi/xaf/host-apf/include/audio/xa_error_standards.h
new file mode 100644
index 00000000..1b67b52f
--- /dev/null
+++ b/hifi/xaf/host-apf/include/audio/xa_error_standards.h
@@ -0,0 +1,79 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+#ifndef __XA_ERROR_STANDARDS_H__
+#define __XA_ERROR_STANDARDS_H__
+
+/*****************************************************************************/
+/* File includes */
+/* xa_type_def.h */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Constant hash defines */
+/*****************************************************************************/
+#define XA_NO_ERROR 0
+#define XA_FATAL_ERROR 0x80000000
+
+enum xa_error_severity {
+ xa_severity_nonfatal = 0,
+ xa_severity_fatal = 0xffffffff
+};
+
+enum xa_error_class {
+ xa_class_api = 0,
+ xa_class_config = 1,
+ xa_class_execute = 2,
+ xa_class_proxy = 3
+};
+
+#define XA_CODEC_GENERIC 0
+
+#define XA_ERROR_CODE(severity, class, codec, index) ((severity << 15) | (class << 11) | (codec << 6) | index)
+#define XA_ERROR_SEVERITY(code) (((code) & XA_FATAL_ERROR) != 0)
+#define XA_ERROR_CLASS(code) (((code) >> 11) & 0x0f)
+#define XA_ERROR_CODEC(code) (((code) >> 6) & 0x1f)
+#define XA_ERROR_SUBCODE(code) (((code) >> 0) & 0x3f)
+
+/* Our convention is that only api-class errors can be generic ones. */
+
+/*****************************************************************************/
+/* Class 0: API Errors */
+/*****************************************************************************/
+/* Non Fatal Errors */
+/* (none) */
+/* Fatal Errors */
+enum xa_error_fatal_api_generic {
+ XA_API_FATAL_MEM_ALLOC = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 0),
+ XA_API_FATAL_MEM_ALIGN = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 1),
+ XA_API_FATAL_INVALID_CMD = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 2),
+ XA_API_FATAL_INVALID_CMD_TYPE = XA_ERROR_CODE(xa_severity_fatal, xa_class_api, XA_CODEC_GENERIC, 3)
+};
+
+#endif /* __XA_ERROR_STANDARDS_H__ */
diff --git a/hifi/xaf/host-apf/include/audio/xa_memory_standards.h b/hifi/xaf/host-apf/include/audio/xa_memory_standards.h
new file mode 100644
index 00000000..27ec455f
--- /dev/null
+++ b/hifi/xaf/host-apf/include/audio/xa_memory_standards.h
@@ -0,0 +1,104 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+#ifndef __XA_MEMORY_STANDARDS_H__
+#define __XA_MEMORY_STANDARDS_H__
+
+/*****************************************************************************/
+/* Constant hash defines */
+/*****************************************************************************/
+/* when you don't need alignment, pass this to memory library */
+#define XA_MEM_NO_ALIGN 0x01
+
+/* standard memory types */
+/* to be used inter frames */
+#define XA_MEMTYPE_PERSIST 0x00
+/* read write, to be used intra frames */
+#define XA_MEMTYPE_SCRATCH 0x01
+/* read only memory, intra frame */
+#define XA_MEMTYPE_INPUT 0x02
+/* read-write memory, for usable output, intra frame */
+#define XA_MEMTYPE_OUTPUT 0x03
+/* readonly memory, inter frame */
+#define XA_MEMTYPE_TABLE 0x04
+/* input buffer before mem tabs allocation */
+#define XA_MEMTYPE_PRE_FRAME_INPUT 0x05
+/* input buffer before mem tabs allocation */
+#define XA_MEMTYPE_PRE_FRAME_SCRATCH 0x06
+/* for local variables */
+#define XA_MEMTYPE_AUTO_VAR 0x80
+
+/* standard memory priorities */
+#define XA_MEMPRIORITY_ANYWHERE 0x00
+#define XA_MEMPRIORITY_LOWEST 0x01
+#define XA_MEMPRIORITY_LOW 0x02
+#define XA_MEMPRIORITY_NORM 0x03
+#define XA_MEMPRIORITY_ABOVE_NORM 0x04
+#define XA_MEMPRIORITY_HIGH 0x05
+#define XA_MEMPRIORITY_HIGHER 0x06
+#define XA_MEMPRIORITY_CRITICAL 0x07
+
+/* standard memory placements */
+/* placement is defined by 64 bits */
+
+#define XA_MEMPLACE_FAST_RAM_0 0x000001
+#define XA_MEMPLACE_FAST_RAM_1 0x000002
+#define XA_MEMPLACE_FAST_RAM_2 0x000004
+#define XA_MEMPLACE_FAST_RAM_3 0x000008
+#define XA_MEMPLACE_FAST_RAM_4 0x000010
+#define XA_MEMPLACE_FAST_RAM_5 0x000020
+#define XA_MEMPLACE_FAST_RAM_6 0x000040
+#define XA_MEMPLACE_FAST_RAM_7 0x000080
+
+#define XA_MEMPLACE_INT_RAM_0 0x000100
+#define XA_MEMPLACE_INT_RAM_1 0x000200
+#define XA_MEMPLACE_INT_RAM_2 0x000400
+#define XA_MEMPLACE_INT_RAM_3 0x000800
+#define XA_MEMPLACE_INT_RAM_4 0x001000
+#define XA_MEMPLACE_INT_RAM_5 0x002000
+#define XA_MEMPLACE_INT_RAM_6 0x004000
+#define XA_MEMPLACE_INT_RAM_7 0x008000
+
+#define XA_MEMPLACE_EXT_RAM_0 0x010000
+#define XA_MEMPLACE_EXT_RAM_1 0x020000
+#define XA_MEMPLACE_EXT_RAM_2 0x040000
+#define XA_MEMPLACE_EXT_RAM_3 0x080000
+#define XA_MEMPLACE_EXT_RAM_4 0x100000
+#define XA_MEMPLACE_EXT_RAM_5 0x200000
+#define XA_MEMPLACE_EXT_RAM_6 0x400000
+#define XA_MEMPLACE_EXT_RAM_7 0x800000
+
+#define XA_MEMPLACE_DONTCARE_H 0xFFFFFFFF
+#define XA_MEMPLACE_DONTCARE_L 0xFFFFFFFF
+
+/* the simple common PC RAM */
+#define XA_PC_RAM_H 0x00000000
+#define XA_PC_RAM_L XA_MEMPLACE_EXT_RAM_0
+
+#endif /* __XA_MEMORY_STANDARDS_H__ */
diff --git a/hifi/xaf/host-apf/include/audio/xa_type_def.h b/hifi/xaf/host-apf/include/audio/xa_type_def.h
new file mode 100644
index 00000000..e83cdd34
--- /dev/null
+++ b/hifi/xaf/host-apf/include/audio/xa_type_def.h
@@ -0,0 +1,98 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+#ifndef __XA_TYPE_DEF_H__
+#define __XA_TYPE_DEF_H__
+
+/****************************************************************************/
+/* types type define prefix examples bytes */
+/************************ *********** ****** **************** ***** */
+typedef signed char WORD8 ;/* b WORD8 b_name 1 */
+typedef signed char * pWORD8 ;/* pb pWORD8 pb_nmae 1 */
+typedef unsigned char UWORD8 ;/* ub UWORD8 ub_count 1 */
+typedef unsigned char * pUWORD8 ;/* pub pUWORD8 pub_count 1 */
+
+typedef signed short WORD16 ;/* s WORD16 s_count 2 */
+typedef signed short * pWORD16 ;/* ps pWORD16 ps_count 2 */
+typedef unsigned short UWORD16 ;/* us UWORD16 us_count 2 */
+typedef unsigned short * pUWORD16;/* pus pUWORD16 pus_count 2 */
+
+typedef signed int WORD24 ;/* k WORD24 k_count 3 */
+typedef signed int * pWORD24 ;/* pk pWORD24 pk_count 3 */
+typedef unsigned int UWORD24 ;/* uk UWORD24 uk_count 3 */
+typedef unsigned int * pUWORD24;/* puk pUWORD24 puk_count 3 */
+
+typedef signed int WORD32 ;/* i WORD32 i_count 4 */
+typedef signed int * pWORD32 ;/* pi pWORD32 pi_count 4 */
+typedef unsigned int UWORD32 ;/* ui UWORD32 ui_count 4 */
+typedef unsigned int * pUWORD32;/* pui pUWORD32 pui_count 4 */
+
+typedef signed long long WORD40 ;/* m WORD40 m_count 5 */
+typedef signed long long * pWORD40 ;/* pm pWORD40 pm_count 5 */
+typedef unsigned long long UWORD40 ;/* um UWORD40 um_count 5 */
+typedef unsigned long long * pUWORD40;/* pum pUWORD40 pum_count 5 */
+
+typedef signed long long WORD64 ;/* h WORD64 h_count 8 */
+typedef signed long long * pWORD64 ;/* ph pWORD64 ph_count 8 */
+typedef unsigned long long UWORD64 ;/* uh UWORD64 uh_count 8 */
+typedef unsigned long long * pUWORD64;/* puh pUWORD64 puh_count 8 */
+
+typedef float FLOAT32 ;/* f FLOAT32 f_count 4 */
+typedef float * pFLOAT32;/* pf pFLOAT32 pf_count 4 */
+typedef double FLOAT64 ;/* d UFLOAT64 d_count 8 */
+typedef double * pFlOAT64;/* pd pFLOAT64 pd_count 8 */
+
+typedef void VOID ;/* v VOID v_flag 4 */
+typedef void * pVOID ;/* pv pVOID pv_flag 4 */
+
+/* variable size types: platform optimized implementation */
+//typedef signed int BOOL ;/* bool BOOL bool_true */
+//typedef unsigned int UBOOL ;/* ubool BOOL ubool_true */
+typedef signed int FLAG ;/* flag FLAG flag_false */
+typedef unsigned int UFLAG ;/* uflag FLAG uflag_false */
+typedef signed int LOOPIDX ;/* lp LOOPIDX lp_index */
+typedef unsigned int ULOOPIDX;/* ulp SLOOPIDX ulp_index */
+typedef signed int WORD ;/* lp LOOPIDX lp_index */
+typedef unsigned int UWORD ;/* ulp SLOOPIDX ulp_index */
+
+typedef LOOPIDX LOOPINDEX; /* lp LOOPIDX lp_index */
+typedef ULOOPIDX ULOOPINDEX;/* ulp SLOOPIDX ulp_index */
+
+#define PLATFORM_INLINE __inline
+
+typedef struct xa_codec_opaque { WORD32 _; } *xa_codec_handle_t;
+
+typedef int XA_ERRORCODE;
+
+typedef XA_ERRORCODE xa_codec_func_t(xa_codec_handle_t p_xa_module_obj,
+ WORD32 i_cmd,
+ WORD32 i_idx,
+ pVOID pv_value);
+
+#endif /* __XA_TYPE_DEF_H__ */
diff --git a/hifi/xaf/host-apf/include/audio/xa_vorbis_dec_api.h b/hifi/xaf/host-apf/include/audio/xa_vorbis_dec_api.h
new file mode 100644
index 00000000..f99660f8
--- /dev/null
+++ b/hifi/xaf/host-apf/include/audio/xa_vorbis_dec_api.h
@@ -0,0 +1,121 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+/*******************************************************************************
+*
+* NOTE, ANY CHANGES TO THIS FILE MAY AFFECT UNDERLYING AUDIO / SPEECH CODEC
+* LIBRARY COMPONENT FROM CADENCE DESIGN SYSTEMS, INC.
+*
+******************************************************************************/
+
+
+
+#ifndef __XA_VORBIS_DEC_API_H__
+#define __XA_VORBIS_DEC_API_H__
+
+#include <xa_memory_standards.h>
+
+/* vorbis_dec-specific configuration parameters */
+enum xa_config_param_vorbis_dec
+{
+ XA_VORBISDEC_CONFIG_PARAM_SAMP_FREQ = 0,
+ XA_VORBISDEC_CONFIG_PARAM_NUM_CHANNELS = 1,
+ XA_VORBISDEC_CONFIG_PARAM_PCM_WDSZ = 2,
+ XA_VORBISDEC_CONFIG_PARAM_COMMENT_MEM_PTR = 3,
+ XA_VORBISDEC_CONFIG_PARAM_COMMENT_MEM_SIZE = 4,
+ XA_VORBISDEC_CONFIG_PARAM_GET_CUR_BITRATE = 5,
+ XA_VORBISDEC_CONFIG_PARAM_RAW_VORBIS_FILE_MODE = 6,
+ XA_VORBISDEC_CONFIG_PARAM_RAW_VORBIS_LAST_PKT_GRANULE_POS = 7,
+ XA_VORBISDEC_CONFIG_PARAM_OGG_MAX_PAGE_SIZE = 8,
+ XA_VORBISDEC_CONFIG_PARAM_RUNTIME_MEM = 9
+};
+
+/* commands */
+#include <xa_apicmd_standards.h>
+
+/* vorbis_dec-specific command types */
+/* (none) */
+
+/* error codes */
+#include <xa_error_standards.h>
+#define XA_CODEC_VORBIS_DEC 7
+
+/* vorbis_dec-specific error codes */
+
+/*****************************************************************************/
+/* Class 1: Configuration Errors */
+/*****************************************************************************/
+/* Nonfatal Errors */
+enum xa_error_nonfatal_config_vorbis_dec
+{
+ XA_VORBISDEC_CONFIG_NONFATAL_GROUPED_STREAM = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_VORBIS_DEC, 0),
+ XA_VORBISDEC_CONFIG_NONFATAL_BAD_PARAM = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_config, XA_CODEC_VORBIS_DEC, 1)
+};
+
+/* Fatal Errors */
+enum xa_error_fatal_config_vorbis_dec
+{
+ XA_VORBISDEC_CONFIG_FATAL_BADHDR = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 0),
+ XA_VORBISDEC_CONFIG_FATAL_NOTVORBIS = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 1),
+ XA_VORBISDEC_CONFIG_FATAL_BADINFO = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 2),
+ XA_VORBISDEC_CONFIG_FATAL_BADVERSION = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 3),
+ XA_VORBISDEC_CONFIG_FATAL_BADBOOKS = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 4),
+ XA_VORBISDEC_CONFIG_FATAL_CODEBOOK_DECODE = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 5),
+ XA_VORBISDEC_CONFIG_FATAL_INVALID_PARAM = XA_ERROR_CODE(xa_severity_fatal, xa_class_config, XA_CODEC_VORBIS_DEC, 6)
+};
+
+/*****************************************************************************/
+/* Class 2: Execution Errors */
+/*****************************************************************************/
+/* Nonfatal Errors */
+enum xa_error_nonfatal_execute_vorbis_dec
+{
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_HOLE = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 0),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_NOTAUDIO = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 1),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_BADPACKET = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 2),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_RUNTIME_DECODE_FLUSH_IN_PROGRESS = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 3),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_INVALID_STRM_POS = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 4),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_INSUFFICIENT_DATA = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 5),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_UNEXPECTED_IDENT_PKT_RECEIVED = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 6),
+ XA_VORBISDEC_EXECUTE_NONFATAL_OV_UNEXPECTED_HEADER_PKT_RECEIVED = XA_ERROR_CODE(xa_severity_nonfatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 7)
+};
+/* Fatal Errors */
+enum xa_error_fatal_execute_vorbis_dec
+{
+ XA_VORBISDEC_EXECUTE_FATAL_PERSIST_ALLOC = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 0),
+ XA_VORBISDEC_EXECUTE_FATAL_SCRATCH_ALLOC = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 1),
+ XA_VORBISDEC_EXECUTE_FATAL_CORRUPT_STREAM = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 2),
+ XA_VORBISDEC_EXECUTE_FATAL_INSUFFICIENT_INP_BUF_SIZE = XA_ERROR_CODE(xa_severity_fatal, xa_class_execute, XA_CODEC_VORBIS_DEC, 3)
+};
+
+#include "xa_type_def.h"
+
+#ifdef __cplusplus
+ extern "C" {
+#endif /* __cplusplus */
+
+ xa_codec_func_t xa_vorbis_dec;
+
+#ifdef __cplusplus
+ }
+#endif /* __cplusplus */
+
+#endif /* __XA_VORBIS_DEC_API_H__ */
diff --git a/hifi/xaf/host-apf/include/os/android/xf-osal.h b/hifi/xaf/host-apf/include/os/android/xf-osal.h
new file mode 100644
index 00000000..7d2f5a95
--- /dev/null
+++ b/hifi/xaf/host-apf/include/os/android/xf-osal.h
@@ -0,0 +1,215 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XF_H
+#error "xf-osal.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include <pthread.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <cutils/log.h>
+
+/*******************************************************************************
+ * Tracing primitive
+ ******************************************************************************/
+
+#define __xf_puts(str) \
+ ALOG(LOG_INFO, "PROXY", "%s", (str))
+
+/*******************************************************************************
+ * Lock operation
+ ******************************************************************************/
+
+/* ...lock definition */
+typedef pthread_mutex_t xf_lock_t;
+
+/* ...lock initialization */
+static inline void __xf_lock_init(xf_lock_t *lock)
+{
+ pthread_mutex_init(lock, NULL);
+}
+
+/* ...lock acquisition */
+static inline void __xf_lock(xf_lock_t *lock)
+{
+ pthread_mutex_lock(lock);
+}
+
+/* ...lock release */
+static inline void __xf_unlock(xf_lock_t *lock)
+{
+ pthread_mutex_unlock(lock);
+}
+
+/*******************************************************************************
+ * Waiting object
+ ******************************************************************************/
+
+/* ...waiting object handle */
+typedef struct __xf_wait
+{
+ /* ...conditional variable */
+ pthread_cond_t wait;
+
+ /* ...waiting mutex */
+ pthread_mutex_t mutex;
+
+} xf_wait_t;
+
+/* ...initialize waiting object */
+static inline void __xf_wait_init(xf_wait_t *w)
+{
+ pthread_cond_init(&w->wait, NULL);
+ pthread_mutex_init(&w->mutex, NULL);
+}
+
+/* ...prepare to waiting */
+static inline void __xf_wait_prepare(xf_wait_t *w)
+{
+ pthread_mutex_lock(&w->mutex);
+}
+
+#define __xf_wait_prepare(w) \
+({ \
+ TRACE(1, _x("prepare-wait")); \
+ (__xf_wait_prepare)(w); \
+})
+
+/* ...wait until event is signalled */
+static inline int __xf_wait(xf_wait_t *w, u32 timeout)
+{
+ struct timespec ts;
+ struct timeval tv;
+ int r;
+
+ /* ...wait with or without timeout (communication mutex is taken) */
+ if (!timeout)
+ {
+ r = -pthread_cond_wait(&w->wait, &w->mutex);
+ }
+ else
+ {
+ /* ...get current time */
+ gettimeofday(&tv, NULL);
+
+ /* ...set absolute timeout */
+ ts.tv_sec = tv.tv_sec + timeout / 1000;
+ ts.tv_nsec = tv.tv_usec * 1000 + (timeout % 1000) * 1000000;
+ (ts.tv_nsec >= 1000000000 ? ts.tv_sec++, ts.tv_nsec -= 1000000000 : 0);
+
+ /* ...wait conditionally with absolute timeout*/
+ r = -pthread_cond_timedwait(&w->wait, &w->mutex, &ts);
+ }
+
+ /* ...leave with communication mutex taken */
+ return r;
+}
+
+#define __xf_wait(w, timeout) \
+({ \
+ int __r; \
+ TRACE(1, _x("wait")); \
+ __r = (__xf_wait)(w, timeout); \
+ TRACE(1, _x("resume")); \
+ __r; \
+})
+
+/* ...wake up waiting handle */
+static inline void __xf_wakeup(xf_wait_t *w)
+{
+ /* ...take communication mutex before signaling */
+ pthread_mutex_lock(&w->mutex);
+
+ /* ...signalling will resume waiting thread */
+ pthread_cond_signal(&w->wait);
+
+ /* ...assure that waiting task will not resume until we say this - is that really needed? - tbd */
+ pthread_mutex_unlock(&w->mutex);
+}
+
+#define __xf_wakeup(w) \
+({ \
+ TRACE(1, _x("wakeup")); \
+ (__xf_wakeup)(w); \
+})
+
+/* ...complete waiting operation */
+static inline void __xf_wait_complete(xf_wait_t *w)
+{
+ pthread_mutex_unlock(&w->mutex);
+}
+
+#define __xf_wait_complete(w) \
+({ \
+ TRACE(1, _x("wait-complete")); \
+ (__xf_wait_complete)(w); \
+})
+
+/*******************************************************************************
+ * Thread support
+ ******************************************************************************/
+
+/* ...thread handle definition */
+typedef pthread_t xf_thread_t;
+
+/* ...thread creation */
+static inline int __xf_thread_create(xf_thread_t *thread, void * (*f)(void *), void *arg)
+{
+ pthread_attr_t attr;
+ int r;
+
+ /* ...initialize thread attributes - joinable with minimal stack */
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+ pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
+
+ /* ...create proxy asynchronous thread managing SHMEM */
+ r = -pthread_create(thread, &attr, f, arg);
+
+ /* ...destroy thread attributes */
+ pthread_attr_destroy(&attr);
+
+ return r;
+}
+
+/* ...terminate thread operation */
+static inline int __xf_thread_destroy(xf_thread_t *thread)
+{
+ void *r;
+
+ /* ...tell the thread to terminate */
+ pthread_kill(*thread,SIGUSR1);
+
+ /* ...wait until thread terminates */
+ pthread_join(*thread, &r);
+
+ /* ...return final status */
+ return (int)(intptr_t)r;
+}
diff --git a/hifi/xaf/host-apf/include/os/xos/xf-osal.h b/hifi/xaf/host-apf/include/os/xos/xf-osal.h
new file mode 100644
index 00000000..c3468000
--- /dev/null
+++ b/hifi/xaf/host-apf/include/os/xos/xf-osal.h
@@ -0,0 +1,206 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XF_H
+#error "xf-osal.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+#include "xos.h"
+
+/*******************************************************************************
+ * Tracing primitive
+ ******************************************************************************/
+
+#define __xf_puts(str) \
+ puts((str))
+
+/*******************************************************************************
+ * Lock operation
+ ******************************************************************************/
+
+/* ...lock definition */
+typedef XosMutex xf_lock_t;
+
+/* ...lock initialization */
+static inline void __xf_lock_init(xf_lock_t *lock)
+{
+ xos_mutex_create(lock, XOS_MUTEX_WAIT_PRIORITY, 0);
+}
+
+/* ...lock acquisition */
+static inline void __xf_lock(xf_lock_t *lock)
+{
+ xos_mutex_lock(lock);
+}
+
+/* ...lock release */
+static inline void __xf_unlock(xf_lock_t *lock)
+{
+ xos_mutex_unlock(lock);
+}
+
+/*******************************************************************************
+ * Waiting object
+ ******************************************************************************/
+
+#if 0
+/* ...waiting object handle */
+typedef struct __xf_wait
+{
+ /* ...conditional variable */
+ pthread_cond_t wait;
+
+ /* ...waiting mutex */
+ pthread_mutex_t mutex;
+
+} xf_wait_t;
+
+/* ...initialize waiting object */
+static inline void __xf_wait_init(xf_wait_t *w)
+{
+ pthread_cond_init(&w->wait, NULL);
+ pthread_mutex_init(&w->mutex, NULL);
+}
+
+/* ...prepare to waiting */
+static inline void __xf_wait_prepare(xf_wait_t *w)
+{
+ pthread_mutex_lock(&w->mutex);
+}
+
+#define __xf_wait_prepare(w) \
+({ \
+ TRACE(1, _x("prepare-wait")); \
+ (__xf_wait_prepare)(w); \
+})
+
+/* ...wait until event is signalled */
+static inline int __xf_wait(xf_wait_t *w, u32 timeout)
+{
+ struct timespec ts;
+ struct timeval tv;
+ int r;
+
+ /* ...wait with or without timeout (communication mutex is taken) */
+ if (!timeout)
+ {
+ r = -pthread_cond_wait(&w->wait, &w->mutex);
+ }
+ else
+ {
+ /* ...get current time */
+ gettimeofday(&tv, NULL);
+
+ /* ...set absolute timeout */
+ ts.tv_sec = tv.tv_sec + timeout / 1000;
+ ts.tv_nsec = tv.tv_usec * 1000 + (timeout % 1000) * 1000000;
+ (ts.tv_nsec >= 1000000000 ? ts.tv_sec++, ts.tv_nsec -= 1000000000 : 0);
+
+ /* ...wait conditionally with absolute timeout*/
+ r = -pthread_cond_timedwait(&w->wait, &w->mutex, &ts);
+ }
+
+ /* ...leave with communication mutex taken */
+ return r;
+}
+
+#define __xf_wait(w, timeout) \
+({ \
+ int __r; \
+ TRACE(1, _x("wait")); \
+ __r = (__xf_wait)(w, timeout); \
+ TRACE(1, _x("resume")); \
+ __r; \
+})
+
+/* ...wake up waiting handle */
+static inline void __xf_wakeup(xf_wait_t *w)
+{
+ /* ...take communication mutex before signaling */
+ pthread_mutex_lock(&w->mutex);
+
+ /* ...signalling will resume waiting thread */
+ pthread_cond_signal(&w->wait);
+
+ /* ...assure that waiting task will not resume until we say this - is that really needed? - tbd */
+ pthread_mutex_unlock(&w->mutex);
+}
+
+#define __xf_wakeup(w) \
+({ \
+ TRACE(1, _x("wakeup")); \
+ (__xf_wakeup)(w); \
+})
+
+/* ...complete waiting operation */
+static inline void __xf_wait_complete(xf_wait_t *w)
+{
+ pthread_mutex_unlock(&w->mutex);
+}
+
+#define __xf_wait_complete(w) \
+({ \
+ TRACE(1, _x("wait-complete")); \
+ (__xf_wait_complete)(w); \
+})
+#endif
+
+/*******************************************************************************
+ * Thread support
+ ******************************************************************************/
+
+/* ...thread handle definition */
+typedef XosThread xf_thread_t;
+typedef XosThreadFunc xf_entry_t;
+
+/* ...thread creation */
+static inline int __xf_thread_create(xf_thread_t *thread, xf_entry_t *f,
+ void *arg, const char *name, void * stack,
+ unsigned int stack_size, int priority)
+{
+ int r;
+
+ /* ...create proxy asynchronous thread managing SHMEM */
+ r = xos_thread_create(thread, 0, f, arg, name, stack, stack_size, priority, 0, 0);
+
+ return r;
+}
+
+/* ...terminate thread operation */
+static inline int __xf_thread_destroy(xf_thread_t *thread)
+{
+ int r;
+
+ /* ...wait until thread terminates */
+ /* v-tbd - avoid infinite wait for join */
+ //xos_thread_join(thread, &r);
+
+ /* ...delete thread, free up TCB, stack */
+ r = xos_thread_delete(thread);
+
+ /* ...return final status */
+ return r;
+}
+
diff --git a/hifi/xaf/host-apf/include/sys/fio/xf-config.h b/hifi/xaf/host-apf/include/sys/fio/xf-config.h
new file mode 100644
index 00000000..2e1d4c61
--- /dev/null
+++ b/hifi/xaf/host-apf/include/sys/fio/xf-config.h
@@ -0,0 +1,36 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/* ...number of DSP cores */
+#define XF_CFG_CORES_NUM 4
+
+/* ...maximal number of clients supported by proxy */
+#define XF_CFG_PROXY_MAX_CLIENTS 256
+
+/* ...size of the shared memory pool (in bytes) */
+#define XF_CFG_REMOTE_IPC_POOL_SIZE (256 << 10)
+
+/* ...size of the component(DSP) local memory pool (in bytes) */
+#define XF_CFG_LOCAL_POOL_SIZE (1024<< 10)
+
+/* ...alignment for shared buffers */
+#define XF_PROXY_ALIGNMENT 64
diff --git a/hifi/xaf/host-apf/include/sys/fio/xf-hal.h b/hifi/xaf/host-apf/include/sys/fio/xf-hal.h
new file mode 100644
index 00000000..15a82b03
--- /dev/null
+++ b/hifi/xaf/host-apf/include/sys/fio/xf-hal.h
@@ -0,0 +1,34 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XF_H
+#error "xf-hal.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/* ...primitive types */
+#include "xf-types.h"
+
+/* ...anything else? - tbd */
diff --git a/hifi/xaf/host-apf/include/sys/fio/xf-ipc.h b/hifi/xaf/host-apf/include/sys/fio/xf-ipc.h
new file mode 100644
index 00000000..2ee859a8
--- /dev/null
+++ b/hifi/xaf/host-apf/include/sys/fio/xf-ipc.h
@@ -0,0 +1,127 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XF_H
+#error "xf-ipc.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Types definitions
+ ******************************************************************************/
+
+/* ...proxy IPC data */
+typedef struct xf_proxy_ipc_data
+{
+ /* ...shared memory buffer pointer */
+ void *shmem;
+
+ /* ...file descriptor */
+ int fd;
+
+ /* ...pipe for asynchronous response delivery */
+ int pipe[2];
+
+} xf_proxy_ipc_data_t;
+
+/*******************************************************************************
+ * Helpers for asynchronous response delivery
+ ******************************************************************************/
+
+#define xf_proxy_ipc_response_put(ipc, msg) \
+ (write((ipc)->pipe[1], (msg), sizeof(*(msg))) == sizeof(*(msg)) ? 0 : -errno)
+
+#define xf_proxy_ipc_response_get(ipc, msg) \
+ (read((ipc)->pipe[0], (msg), sizeof(*(msg))) == sizeof(*(msg)) ? 0 : -errno)
+
+/*******************************************************************************
+ * Shared memory translation
+ ******************************************************************************/
+
+/* ...translate proxy shared address into local virtual address */
+static inline void * xf_ipc_a2b(xf_proxy_ipc_data_t *ipc, u32 address)
+{
+ if (address < XF_CFG_REMOTE_IPC_POOL_SIZE)
+ return (unsigned char *) ipc->shmem + address;
+ else if (address == XF_PROXY_NULL)
+ return NULL;
+ else
+ return (void *) -1;
+}
+
+/* ...translate local virtual address into shared proxy address */
+static inline u32 xf_ipc_b2a(xf_proxy_ipc_data_t *ipc, void *b)
+{
+ u32 a;
+
+ if (b == NULL)
+ return XF_PROXY_NULL;
+ if ((a = (u32)((u8 *)b - (u8 *)ipc->shmem)) < XF_CFG_REMOTE_IPC_POOL_SIZE)
+ return a;
+ else
+ return XF_PROXY_BADADDR;
+}
+
+/*******************************************************************************
+ * Component inter-process communication
+ ******************************************************************************/
+
+typedef struct xf_ipc_data
+{
+ /* ...asynchronous response delivery pipe */
+ int pipe[2];
+
+} xf_ipc_data_t;
+
+/*******************************************************************************
+ * Helpers for asynchronous response delivery
+ ******************************************************************************/
+
+#define xf_ipc_response_put(ipc, msg) \
+ (write((ipc)->pipe[1], (msg), sizeof(*(msg))) == sizeof(*(msg)) ? 0 : -errno)
+
+#define xf_ipc_response_get(ipc, msg) \
+ (read((ipc)->pipe[0], (msg), sizeof(*(msg))) == sizeof(*(msg)) ? 0 : -errno)
+
+#define xf_ipc_data_init(ipc) \
+ (pipe((ipc)->pipe) == 0 ? 0 : -errno)
+
+#define xf_ipc_data_destroy(ipc) \
+ (close((ipc)->pipe[0]), close((ipc)->pipe[1]))
+
+/*******************************************************************************
+* API functions
+ ******************************************************************************/
+
+/* ...send asynchronous command */
+extern int xf_ipc_send(xf_proxy_ipc_data_t *ipc, xf_proxy_msg_t *msg, void *b);
+
+/* ...wait for response from remote proxy */
+extern int xf_ipc_wait(xf_proxy_ipc_data_t *ipc, u32 timeout);
+
+/* ...receive response from IPC layer */
+extern int xf_ipc_recv(xf_proxy_ipc_data_t *ipc, xf_proxy_msg_t *msg, void **b);
+
+/* ...open proxy interface on proper DSP partition */
+extern int xf_ipc_open(xf_proxy_ipc_data_t *proxy, u32 core, void *p_shmem);
+
+/* ...close proxy handle */
+extern void xf_ipc_close(xf_proxy_ipc_data_t *proxy, u32 core);
diff --git a/hifi/xaf/host-apf/include/sys/fio/xf-runtime.h b/hifi/xaf/host-apf/include/sys/fio/xf-runtime.h
new file mode 100644
index 00000000..9cad95f4
--- /dev/null
+++ b/hifi/xaf/host-apf/include/sys/fio/xf-runtime.h
@@ -0,0 +1,35 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XF_H
+#error "xf-runtime.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+/* ...platform HAL layer */
+#include "xf-hal.h"
+
+/* ...OS abstraction layer */
+#include "xf-osal.h"
diff --git a/hifi/xaf/host-apf/include/sys/fio/xf-types.h b/hifi/xaf/host-apf/include/sys/fio/xf-types.h
new file mode 100644
index 00000000..a610c8e1
--- /dev/null
+++ b/hifi/xaf/host-apf/include/sys/fio/xf-types.h
@@ -0,0 +1,88 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XF_H
+#error "xf-types.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Standard includes
+ ******************************************************************************/
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <signal.h>
+#include <limits.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+
+/*******************************************************************************
+ * Primitive types
+ ******************************************************************************/
+
+typedef uint32_t u32;
+typedef int32_t s32;
+typedef uint16_t u16;
+typedef int16_t s16;
+typedef uint8_t u8;
+typedef int8_t s8;
+
+/*******************************************************************************
+ * Macros definitions
+ ******************************************************************************/
+
+/* ...NULL-address specification */
+#define XF_PROXY_NULL (~0U)
+
+/* ...invalid proxy address */
+#define XF_PROXY_BADADDR XF_CFG_REMOTE_IPC_POOL_SIZE
+
+/*******************************************************************************
+ * Auxiliary helpers
+ ******************************************************************************/
+
+/* ...next power-of-two calculation */
+#define xf_next_power_of_two(v) __xf_power_of_two_1((v) - 1)
+#define __xf_power_of_two_1(v) __xf_power_of_two_2((v) | ((v) >> 1))
+#define __xf_power_of_two_2(v) __xf_power_of_two_3((v) | ((v) >> 2))
+#define __xf_power_of_two_3(v) __xf_power_of_two_4((v) | ((v) >> 4))
+#define __xf_power_of_two_4(v) __xf_power_of_two_5((v) | ((v) >> 8))
+#define __xf_power_of_two_5(v) __xf_power_of_two_6((v) | ((v) >> 16))
+#define __xf_power_of_two_6(v) ((v) + 1)
+
+/* ...check if non-zero value is a power-of-two */
+#define xf_is_power_of_two(v) (((v) & ((v) - 1)) == 0)
+
diff --git a/hifi/xaf/host-apf/include/xaf-api.h b/hifi/xaf/host-apf/include/xaf-api.h
new file mode 100644
index 00000000..5cebb430
--- /dev/null
+++ b/hifi/xaf/host-apf/include/xaf-api.h
@@ -0,0 +1,139 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+
+/* ...number of max input buffers */
+#define XAF_MAX_INBUFS 2
+#define XAF_INBUF_SIZE 8192
+
+typedef enum {
+ XAF_DECODER = 0,
+ XAF_ENCODER = 1,
+ XAF_MIXER = 2,
+ XAF_PRE_PROC = 3,
+ XAF_POST_PROC = 4,
+} xaf_comp_type;
+
+typedef enum {
+ XAF_STARTING = 0,
+ XAF_INIT_DONE = 1,
+ XAF_NEED_INPUT = 2,
+ XAF_OUTPUT_READY = 3,
+ XAF_EXEC_DONE = 4,
+} xaf_comp_status;
+
+typedef enum {
+ XAF_START_FLAG = 1,
+ XAF_EXEC_FLAG = 2,
+ XAF_INPUT_OVER_FLAG = 3,
+ XAF_INPUT_READY_FLAG = 4,
+ XAF_NEED_OUTPUT_FLAG = 5,
+} xaf_comp_flag;
+
+typedef enum {
+ XAF_NO_ERROR = 0,
+ XAF_PTR_ERROR = -1,
+ XAF_INVALID_VALUE = -2,
+ XAF_ROUTING_ERROR = -3,
+ /*XAF_XOS_ERROR = -4,*/
+ XAF_API_ERR = -5,
+} XAF_ERR_CODE;
+
+typedef enum {
+ XAF_MEM_ID_DEV = 0,
+ XAF_MEM_ID_COMP = 1,
+} XAF_MEM_ID;
+
+/* structure for component memory sizes */
+typedef struct xaf_mem_size_s{
+ u32 persist;
+ u32 scratch;
+ u32 input;
+ u32 output;
+}xaf_mem_size_t;
+
+/* structure for host-side utility handles */
+typedef struct xaf_ap_utils_s{
+ int xf_cfg_remote_ipc_pool_size;
+ xaf_mem_size_t mem_size;
+}xaf_ap_utils_t;
+
+typedef struct xaf_format_s {
+ u32 sample_rate;
+ u32 channels;
+ u32 pcm_width;
+ u32 input_length;
+ u32 output_length;
+} xaf_format_t;
+
+#ifndef XAF_HOSTLESS
+typedef struct xaf_info_s {
+ void * buf;
+ u32 length;
+} xaf_info_t;
+#endif
+
+XAF_ERR_CODE xaf_adev_open(void **pp_adev, s32 audio_frmwk_buf_size, s32 audio_comp_buf_size, xaf_mem_malloc_fxn_t mm_malloc, xaf_mem_free_fxn_t mm_free);
+XAF_ERR_CODE xaf_adev_close(void *adev_ptr, xaf_comp_flag flag);
+
+XAF_ERR_CODE xaf_comp_create(void* p_adev, void **p_comp, xf_id_t comp_id, u32 ninbuf, u32 noutbuf, void *pp_inbuf[], xaf_comp_type comp_type);
+XAF_ERR_CODE xaf_comp_delete(void* p_comp);
+XAF_ERR_CODE xaf_comp_set_config(void *p_comp, s32 num_param, s32 *p_param);
+XAF_ERR_CODE xaf_comp_get_config(void *p_comp, s32 num_param, s32 *p_param);
+XAF_ERR_CODE xaf_comp_process(void *p_adev, void *p_comp, void *p_buf, u32 length, xaf_comp_flag flag);
+XAF_ERR_CODE xaf_connect(void *p_src, void *p_dest, s32 num_buf);
+
+/* Not available in this version yet.
+XAF_ERR_CODE xaf_disconnect(xaf_comp_t *p_comp);
+*/
+
+XAF_ERR_CODE xaf_comp_get_status(void *p_adev, void *p_comp, xaf_comp_status *p_status, xaf_info_t *p_info);
+
+/* ...check null pointer */
+#define XAF_CHK_PTR(ptr) \
+({ \
+ int __ret; \
+ \
+ if ((__ret = (int)(ptr)) == 0) \
+ { \
+ TRACE(ERROR, _x("Null pointer error: %d"), __ret); \
+ return XAF_PTR_ERROR; \
+ } \
+ __ret; \
+})
+
+/* ...check range */
+#define XAF_CHK_RANGE(val, min, max) \
+({ \
+ int __ret = val; \
+ \
+ if ((__ret < (int)min) || (__ret > (int)max)) \
+ { \
+ TRACE(ERROR, _x("Invalid value: %d"), __ret); \
+ return XAF_INVALID_VALUE; \
+ } \
+ __ret; \
+})
+
+
+
+
diff --git a/hifi/xaf/host-apf/include/xaf-structs.h b/hifi/xaf/host-apf/include/xaf-structs.h
new file mode 100644
index 00000000..f632600a
--- /dev/null
+++ b/hifi/xaf/host-apf/include/xaf-structs.h
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+/* ...size of auxiliary pool for communication with HiFi */
+#define XAF_AUX_POOL_SIZE 32
+
+/* ...length of auxiliary pool messages */
+#define XAF_AUX_POOL_MSG_LENGTH 128
+#define XAF_MAX_CONFIG_PARAMS (XAF_AUX_POOL_MSG_LENGTH >> 3)
+
+typedef struct xaf_comp xaf_comp_t;
+
+struct xaf_comp {
+ xf_handle_t handle;
+
+ u32 inp_routed;
+ u32 out_routed;
+ u32 inp_ports;
+ u32 out_ports;
+ u32 init_done;
+ u32 pending_resp;
+ u32 expect_out_cmd;
+ u32 input_over;
+
+ xaf_comp_type comp_type;
+ xaf_comp_status comp_status;
+ u32 start_cmd_issued;
+ u32 exec_cmd_issued;
+ void *start_buf;
+
+ xaf_format_t inp_format;
+ xaf_format_t out_format;
+
+ xf_pool_t *inpool;
+ xf_pool_t *outpool;
+ u32 noutbuf;
+
+ xaf_comp_t *next;
+
+ u32 ninbuf;
+ void *p_adev;
+ //xaf_comp_state comp_state;
+ void *comp_ptr;
+};
+
+typedef struct xaf_adev_s {
+ xf_proxy_t proxy;
+ xaf_comp_t *comp_chain;
+
+ u32 n_comp;
+ void *adev_ptr;
+ void *p_dspMem;
+ void *p_apMem;
+ void *p_dspLocalBuff;
+ void *p_apSharedMem;
+
+ xaf_ap_utils_t *p_ap_utils; //host-side utility structure handle
+ void *(*pxf_mem_malloc_fxn)(s32, s32);
+ void (*pxf_mem_free_fxn)(void *,s32);
+ //xaf_adev_state adev_state;
+
+} xaf_adev_t;
+
diff --git a/hifi/xaf/host-apf/include/xf-debug.h b/hifi/xaf/host-apf/include/xf-debug.h
new file mode 100644
index 00000000..83172302
--- /dev/null
+++ b/hifi/xaf/host-apf/include/xf-debug.h
@@ -0,0 +1,194 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XF_H
+#error "xf-debug.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Auxiliary macros (put into "xf-types.h"?)
+ ******************************************************************************/
+
+#ifndef offset_of
+#define offset_of(type, member) \
+ ((int)(intptr_t)&(((const type *)(0))->member))
+#endif
+
+#ifndef container_of
+#define container_of(ptr, type, member) \
+ ((type *)((void *)(ptr) - offset_of(type, member)))
+#endif
+
+/*******************************************************************************
+ * Bug check for constant conditions (file scope)
+ ******************************************************************************/
+
+#define __C_BUG(n) __C_BUG2(n)
+#define __C_BUG2(n) __c_bug_##n
+#define C_BUG(expr) typedef char __C_BUG(__LINE__)[(expr) ? -1 : 1]
+
+/*******************************************************************************
+ * Compilation-time types control
+ ******************************************************************************/
+
+#if XF_DEBUG
+#define __C_TYPE_CONTROL(d, type) ((void) ((d) != (type*) 0))
+#else
+#define __C_TYPE_CONTROL(d, type) ((void) 0)
+#endif
+
+/*******************************************************************************
+ * Unused variable
+ ******************************************************************************/
+
+#define C_UNUSED(v) (void)(0 ? (v) = (v), 1 : 0)
+
+/*******************************************************************************
+ * Auxiliary macros
+ ******************************************************************************/
+
+/* ...define a stub for unused declarator */
+#define __xf_stub(tag, line) __xf_stub2(tag, line)
+#define __xf_stub2(tag, line) typedef int __xf_##tag##_##line
+
+/* ...convert anything into string */
+#define __xf_string(x) __xf_string2(x)
+#define __xf_string2(x) #x
+
+/*******************************************************************************
+ * Tracing facility
+ ******************************************************************************/
+
+#if XF_TRACE
+
+/* ...tracing to communication processor */
+extern int xf_trace(const char *format, ...);
+
+/* ...tracing facility initialization */
+extern void xf_trace_init(const char *banner);
+
+/* ...initialize tracing facility */
+#define TRACE_INIT(banner) (xf_trace_init(banner))
+
+/* ...trace tag definition */
+#define TRACE_TAG(tag, on) enum { __xf_trace_##tag = on }
+
+/* ...check if the trace tag is enabled */
+#define TRACE_CFG(tag) (__xf_trace_##tag)
+
+/* ...tagged tracing primitive */
+#define TRACE(tag, fmt, ...) (void)(__xf_trace_##tag ? __xf_trace(tag, __xf_format##fmt, ## __VA_ARGS__), 1 : 0)
+
+/*******************************************************************************
+ * Tagged tracing formats
+ ******************************************************************************/
+
+/* ...tracing primitive */
+#define __xf_trace(tag, fmt, ...) \
+ ({ __attribute__((unused)) const char *__xf_tag = #tag; xf_trace(fmt, ## __VA_ARGS__); })
+
+/* ...just a format string */
+#define __xf_format_n(fmt) fmt
+
+/* ...module tag and trace tag shown */
+#define __xf_format_b(fmt) "[%s.%s] " fmt, __xf_string(MODULE_TAG), __xf_tag
+
+/* ...module tag, trace tag, file name and line shown */
+#define __xf_format_x(fmt) "[%s.%s] - %s@%d - " fmt, __xf_string(MODULE_TAG), __xf_tag, __FILE__, __LINE__
+
+/*******************************************************************************
+ * Globally defined tags
+ ******************************************************************************/
+
+/* ...unconditionally OFF */
+TRACE_TAG(0, 0);
+
+/* ...unconditionally ON */
+TRACE_TAG(1, 1);
+
+/* ...error output - on by default */
+TRACE_TAG(ERROR, 1);
+
+#else
+
+#define TRACE_INIT(banner) (void)0
+#define TRACE_TAG(tag, on) __xf_stub(trace_##tag, __LINE__)
+#define TRACE(tag, fmt, ...) (void)0
+#define __xf_trace(tag, fmt, ...) (void)0
+
+#endif /* XF_TRACE */
+
+/*******************************************************************************
+ * Bugchecks
+ ******************************************************************************/
+
+#if XF_DEBUG
+
+/* ...run-time bugcheck */
+#define BUG(cond, fmt, ...) \
+do \
+{ \
+ if (cond) \
+ { \
+ /* ...output message */ \
+ __xf_trace(BUG, __xf_format##fmt, ## __VA_ARGS__); \
+ \
+ /* ...and die */ \
+ abort(); \
+ } \
+} \
+while (0)
+
+#else
+#define BUG(cond, fmt, ...) (void)0
+#endif /* XF_DEBUG */
+
+/*******************************************************************************
+ * Run-time error processing
+ ******************************************************************************/
+
+/* ...check the API call succeeds */
+#define XF_CHK_API(cond) \
+({ \
+ int __ret; \
+ \
+ if ((__ret = (int)(cond)) < 0) \
+ { \
+ TRACE(ERROR, _x("API error: %d"), __ret); \
+ return __ret; \
+ } \
+ __ret; \
+})
+
+/* ...check the condition is true */
+#define XF_CHK_ERR(cond, error) \
+({ \
+ intptr_t __ret; \
+ \
+ if (!(__ret = (intptr_t)(cond))) \
+ { \
+ TRACE(ERROR, _x("check failed")); \
+ return (error); \
+ } \
+ (int)__ret; \
+})
+
diff --git a/hifi/xaf/host-apf/include/xf-opcode.h b/hifi/xaf/host-apf/include/xf-opcode.h
new file mode 100644
index 00000000..f585f5c2
--- /dev/null
+++ b/hifi/xaf/host-apf/include/xf-opcode.h
@@ -0,0 +1,297 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XF_H
+#error "xf-opcode.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Message routing composition - move somewhere else - tbd
+ ******************************************************************************/
+
+/* ...adjust IPC client of message going from user-space */
+#define XF_MSG_AP_FROM_USER(id, client) \
+ (((id) & ~(0xF << 2)) | (client))
+
+/* ...wipe out IPC client from message going to user-space */
+#define XF_MSG_AP_TO_USER(id) \
+ ((id) & ~(0xF << 18))
+
+/* ...port specification (12 bits) */
+#define __XF_PORT_SPEC(core, id, port) ((core) | ((id) << 2) | ((port) << 8))
+#define __XF_PORT_SPEC2(id, port) ((id) | ((port) << 8))
+#define XF_PORT_CORE(spec) ((spec) & 0x3)
+#define XF_PORT_CLIENT(spec) (((spec) >> 2) & 0x3F)
+#define XF_PORT_ID(spec) (((spec) >> 8) & 0xF)
+
+/* ...message id contains source and destination ports specification */
+#define __XF_MSG_ID(src, dst) (((src) & 0xFFFF) | (((dst) & 0xFFFF) << 16))
+#define XF_MSG_SRC(id) (((id) >> 0) & 0xFFFF)
+#define XF_MSG_SRC_CORE(id) (((id) >> 0) & 0x3)
+#define XF_MSG_SRC_CLIENT(id) (((id) >> 2) & 0x3F)
+#define XF_MSG_SRC_ID(id) (((id) >> 0) & 0xFF)
+#define XF_MSG_SRC_PORT(id) (((id) >> 8) & 0xF)
+#define XF_MSG_SRC_PROXY(id) (((id) >> 15) & 0x1)
+#define XF_MSG_DST(id) (((id) >> 16) & 0xFFFF)
+#define XF_MSG_DST_CORE(id) (((id) >> 16) & 0x3)
+#define XF_MSG_DST_CLIENT(id) (((id) >> 18) & 0x3F)
+#define XF_MSG_DST_ID(id) (((id) >> 16) & 0xFF)
+#define XF_MSG_DST_PORT(id) (((id) >> 24) & 0xF)
+#define XF_MSG_DST_PROXY(id) (((id) >> 31) & 0x1)
+
+/* ...special treatment of AP-proxy destination field */
+#define XF_AP_IPC_CLIENT(id) (((id) >> 18) & 0xF)
+#define XF_AP_CLIENT(id) (((id) >> 22) & 0x1FF)
+#define __XF_AP_PROXY(core) ((core) | 0x8000)
+#define __XF_DSP_PROXY(core) ((core) | 0x8000)
+#define __XF_AP_CLIENT(core, client) ((core) | ((client) << 6) | 0x8000)
+
+/*******************************************************************************
+ * Opcode composition
+ ******************************************************************************/
+
+/* ...opcode composition with command/response data tags */
+#define __XF_OPCODE(c, r, op) (((c) << 31) | ((r) << 30) | ((op) & 0x3F))
+
+/* ...accessors */
+#define XF_OPCODE_CDATA(opcode) ((opcode) & (1 << 31))
+#define XF_OPCODE_RDATA(opcode) ((opcode) & (1 << 30))
+#define XF_OPCODE_TYPE(opcode) ((opcode) & (0x3F))
+
+/*******************************************************************************
+ * Opcode types
+ ******************************************************************************/
+
+/* ...unregister client */
+#define XF_UNREGISTER __XF_OPCODE(0, 0, 0)
+
+/* ...register client at proxy */
+#define XF_REGISTER __XF_OPCODE(1, 0, 1)
+
+/* ...port routing command */
+#define XF_ROUTE __XF_OPCODE(1, 0, 2)
+
+/* ...port unrouting command */
+#define XF_UNROUTE __XF_OPCODE(1, 0, 3)
+
+/* ...shared buffer allocation */
+#define XF_ALLOC __XF_OPCODE(0, 0, 4)
+
+/* ...shared buffer freeing */
+#define XF_FREE __XF_OPCODE(0, 0, 5)
+
+/* ...set component parameters */
+#define XF_SET_PARAM __XF_OPCODE(1, 0, 6)
+
+/* ...get component parameters */
+#define XF_GET_PARAM __XF_OPCODE(1, 1, 7)
+
+/* ...input buffer reception */
+#define XF_EMPTY_THIS_BUFFER __XF_OPCODE(1, 0, 8)
+
+/* ...output buffer reception */
+#define XF_FILL_THIS_BUFFER __XF_OPCODE(0, 1, 9)
+
+/* ...flush specific port */
+#define XF_FLUSH __XF_OPCODE(0, 0, 10)
+
+/* ...start component operation */
+#define XF_START __XF_OPCODE(0, 0, 11)
+
+/* ...stop component operation */
+#define XF_STOP __XF_OPCODE(0, 0, 12)
+
+/* ...pause component operation */
+#define XF_PAUSE __XF_OPCODE(0, 0, 13)
+
+/* ...resume component operation */
+#define XF_RESUME __XF_OPCODE(0, 0, 14)
+
+/* ...extended parameter setting function */
+#define XF_SET_PARAM_EXT __XF_OPCODE(1, 1, 15)
+
+/* ...extended parameter retrieval function */
+#define XF_GET_PARAM_EXT __XF_OPCODE(1, 1, 16)
+
+/* ...total amount of supported decoder commands */
+#define __XF_OP_NUM 17
+
+/*******************************************************************************
+ * XF_START message definition
+ ******************************************************************************/
+
+typedef struct xf_start_msg
+{
+ /* ...effective sample rate */
+ u32 sample_rate;
+
+ /* ...number of channels */
+ u32 channels;
+
+ /* ...sample width */
+ u32 pcm_width;
+
+ /* ...minimal size of intput buffer */
+ u32 input_length;
+
+ /* ...size of output buffer */
+ u32 output_length;
+
+} __attribute__((__packed__)) xf_start_msg_t;
+
+/*******************************************************************************
+ * XF_GET_PARAM message
+ ******************************************************************************/
+
+/* ...message body (command/response) */
+typedef union xf_get_param_msg
+{
+ /* ...command structure */
+ struct
+ {
+ /* ...array of parameters requested */
+ u32 id[0];
+
+ } __attribute__((__packed__)) c;
+
+ /* ...response structure */
+ struct
+ {
+ /* ...array of parameters values */
+ u32 value[0];
+
+ } __attribute__((__packed__)) r;
+
+} xf_get_param_msg_t;
+
+/* ...length of the XF_GET_PARAM command/response */
+#define XF_GET_PARAM_CMD_LEN(params) (sizeof(u32) * (params))
+#define XF_GET_PARAM_RSP_LEN(params) (sizeof(u32) * (params))
+
+/*******************************************************************************
+ * XF_SET_PARAM message
+ ******************************************************************************/
+
+/* ...component initialization parameter */
+typedef struct xf_set_param_item
+{
+ /* ...index of parameter passed to SET_CONFIG_PARAM call */
+ u32 id;
+
+ /* ...value of parameter */
+ u32 value;
+
+} __attribute__ ((__packed__)) xf_set_param_item_t;
+
+/* ...message body (no response message? - tbd) */
+typedef struct xf_set_param_msg
+{
+ /* ...command message */
+ xf_set_param_item_t item[0];
+
+} __attribute__ ((__packed__)) xf_set_param_msg_t;
+
+/* ...length of the command message */
+#define XF_SET_PARAM_CMD_LEN(params) (sizeof(xf_set_param_item_t) * (params))
+
+/*******************************************************************************
+ * XF_SET_PARAM_EXT/XF_GET_PARAM_EXT message
+ ******************************************************************************/
+
+/* ...extended parameter descriptor */
+typedef struct xf_ext_param_desc
+{
+ /* ...index of parameter passed to SET/GET_CONFIG_PARAM call (16-bits only) */
+ u16 id;
+
+ /* ...length of embedded input/output parameter data (in bytes) */
+ u16 length;
+
+} __attribute__ ((__packed__, __aligned__(4))) xf_ext_param_desc_t;
+
+/* ...message body (no response message? - tbd) */
+typedef struct xf_ext_param_msg
+{
+ /* ...extended parameter descriptor */
+ xf_ext_param_desc_t desc;
+
+ /* ...parameter data (in the format expected by codec) */
+ u8 data[0];
+
+} __attribute__ ((__packed__)) xf_ext_param_msg_t;
+
+/* ...access macros */
+
+#define xf_ext_param_first(e) \
+ (&(e)->desc)
+
+#define xf_ext_param_next(d) \
+ (xf_ext_param_desc_t *)(((xf_ext_param_msg_t *)(d))->data + (((d)->length + 3) & ~3))
+
+#define xf_ext_param_length(e, d) \
+ ((u32)((u8 *)(d) - (u8 *)(ext)))
+
+#define xf_ext_param_data(d, t) \
+ ((t *)&(d)[1])
+
+#define xf_ext_param_setup(d, i, t, s) \
+ ((d)->id = (i), (d)->length = (s), xf_ext_param_data(d, t))
+
+
+/*******************************************************************************
+ * XF_ROUTE definition
+ ******************************************************************************/
+
+/* ...port routing command */
+typedef struct xf_route_port_msg
+{
+ /* ...source port specification */
+ u32 src;
+
+ /* ...destination port specification */
+ u32 dst;
+
+ /* ...number of buffers to allocate */
+ u32 alloc_number;
+
+ /* ...length of buffer to allocate */
+ u32 alloc_size;
+
+ /* ...alignment restriction for a buffer */
+ u32 alloc_align;
+
+} __attribute__((__packed__)) xf_route_port_msg_t;
+
+/*******************************************************************************
+ * XF_UNROUTE definition
+ ******************************************************************************/
+
+/* ...port unrouting command */
+typedef struct xf_unroute_port_msg
+{
+ /* ...source port specification */
+ u32 src;
+
+ /* ...destination port specification */
+ u32 dst;
+
+} __attribute__((__packed__)) xf_unroute_port_msg_t;
diff --git a/hifi/xaf/host-apf/include/xf-proto.h b/hifi/xaf/host-apf/include/xf-proto.h
new file mode 100644
index 00000000..095e353a
--- /dev/null
+++ b/hifi/xaf/host-apf/include/xf-proto.h
@@ -0,0 +1,82 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XF_H
+#error "xf-proto.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * Forward types declarations
+ ******************************************************************************/
+
+/* ...component string identifier */
+typedef const char *xf_id_t;
+
+/* ...handle to proxy data */
+typedef struct xf_proxy xf_proxy_t;
+
+/* ...handle to component data */
+typedef struct xf_handle xf_handle_t;
+
+/* ...buffer pool */
+typedef struct xf_pool xf_pool_t;
+
+/* ...individual buffer from pool */
+typedef struct xf_buffer xf_buffer_t;
+
+/* ...buffer pool type */
+typedef u32 xf_pool_type_t;
+
+/* ...user-message */
+typedef struct xf_user_msg xf_user_msg_t;
+
+/* ...proxy-message */
+typedef struct xf_proxy_msg xf_proxy_msg_t;
+
+/* ...response callback */
+typedef void (*xf_response_cb)(xf_handle_t *h, xf_user_msg_t *msg);
+
+typedef void* xaf_mem_malloc_fxn_t(s32 size, s32 id);
+typedef void xaf_mem_free_fxn_t(void* ptr, s32 id);
+
+/*******************************************************************************
+ * High-level API functions
+ ******************************************************************************/
+
+/* ...component operations */
+extern int xf_open(xf_proxy_t *proxy, xf_handle_t *handle, xf_id_t id, u32 core, xf_response_cb cb);
+extern void xf_close(xf_handle_t *handle);
+extern int xf_command(xf_handle_t *handle, u32 dst, u32 opcode, void *buf, u32 length);
+extern int xf_route(xf_handle_t *src, u32 s_port, xf_handle_t *dst, u32 d_port, u32 num, u32 size, u32 align);
+extern int xf_unroute(xf_handle_t *src, u32 s_port);
+
+/* ...shared buffers operations */
+extern int xf_pool_alloc(xf_proxy_t *proxy, u32 number, u32 length, xf_pool_type_t type, xf_pool_t **pool, s32 id,
+ xaf_mem_malloc_fxn_t, xaf_mem_free_fxn_t);
+extern void xf_pool_free(xf_pool_t *pool, s32 id, xaf_mem_free_fxn_t);
+extern xf_buffer_t * xf_buffer_get(xf_pool_t *pool);
+extern void xf_buffer_put(xf_buffer_t *buffer);
+
+/* ...proxy operations */
+extern int xf_proxy_init(xf_proxy_t *proxy, u32 core, void *p_shmem);
+extern void xf_proxy_close(xf_proxy_t *proxy);
+
diff --git a/hifi/xaf/host-apf/include/xf-proxy.h b/hifi/xaf/host-apf/include/xf-proxy.h
new file mode 100644
index 00000000..90d70793
--- /dev/null
+++ b/hifi/xaf/host-apf/include/xf-proxy.h
@@ -0,0 +1,297 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 __XF_H
+#error "xf-proxy.h mustn't be included directly"
+#endif
+
+/*******************************************************************************
+ * User-message description - move from here to API - tbd
+ ******************************************************************************/
+
+/* ...need that at all? hope no */
+struct xf_user_msg
+{
+ /* ...source component specification */
+ u32 id;
+
+ /* ...message opcode */
+ u32 opcode;
+
+ /* ...buffer length */
+ u32 length;
+
+ /* ...buffer pointer */
+ void *buffer;
+};
+
+/* ...proxy message - bad placing of that thing here - tbd */
+struct xf_proxy_msg
+{
+ /* ...session-id field */
+ uint32_t id;
+
+ /* ...message opcode */
+ uint32_t opcode;
+
+ /* ...buffer length */
+ uint32_t length;
+
+ /* ...buffer pointer */
+ uint64_t address;
+ uint64_t v_address;
+
+} __attribute__((__packed__));
+
+typedef struct xf_proxy_msg_driv
+{
+ /* ...session ID */
+ uint32_t id;
+
+ /* ...proxy API command/reponse code */
+ uint32_t opcode;
+
+ /* ...length of attached buffer */
+ uint32_t length;
+
+ /* ...physical address of message buffer */
+ uint64_t address;
+ uint64_t v_address;
+
+}__attribute__((__packed__)) xf_proxy_message_driv_t;
+/*******************************************************************************
+ * Buffer pools
+ ******************************************************************************/
+
+/* ...buffer pool type */
+enum xf_pool_type
+{
+ XF_POOL_AUX = 0,
+ XF_POOL_INPUT = 1,
+ XF_POOL_OUTPUT = 2
+};
+
+/* ...buffer link pointer */
+typedef union xf_buffer_link
+{
+ /* ...pointer to next free buffer in a pool (for free buffer) */
+ xf_buffer_t *next;
+
+ /* ...reference to a buffer pool (for allocated buffer) */
+ xf_pool_t *pool;
+
+} xf_buffer_link_t;
+
+/* ...buffer descriptor */
+struct xf_buffer
+{
+ /* ...virtual address of contiguous buffer */
+ void *address;
+
+ /* ...link pointer */
+ xf_buffer_link_t link;
+};
+
+/* ...buffer pool */
+struct xf_pool
+{
+ /* ...reference to proxy data */
+ xf_proxy_t *proxy;
+
+ /* ...length of individual buffer in a pool */
+ u32 length;
+
+ /* ...number of buffers in a pool */
+ u32 number;
+
+ /* ...pointer to pool memory */
+ void *p;
+
+ /* ...pointer to first free buffer in a pool */
+ xf_buffer_t *free;
+
+ /* ...individual buffers */
+ xf_buffer_t buffer[0];
+};
+
+/* ...accessor to buffer data */
+static inline void * xf_buffer_data(xf_buffer_t *buffer)
+{
+ return buffer->address;
+}
+
+/* ...length of buffer data */
+static inline size_t xf_buffer_length(xf_buffer_t *buffer)
+{
+ return buffer->link.pool->length;
+}
+
+/*******************************************************************************
+ * Proxy handle definition
+ ******************************************************************************/
+
+/* ...free clients list */
+typedef union xf_proxy_cmap_link
+{
+ /* ...index of next free client in the list */
+ u32 next;
+
+ /* ...pointer to allocated component handle */
+ xf_handle_t *handle;
+
+} xf_proxy_cmap_link_t;
+
+/* ...proxy data structure */
+struct xf_proxy
+{
+ /* ...platform-specific IPC data */
+ xf_proxy_ipc_data_t ipc;
+
+ /* ...auxiliary buffer pool for clients */
+ xf_pool_t *aux;
+
+ /* ...global proxy lock */
+ xf_lock_t lock;
+
+ /* ...proxy thread handle */
+ xf_thread_t thread;
+
+ /* ...proxy identifier (core of remote DSP hosting SHMEM interface) */
+ u32 core;
+
+ /* ...client association map */
+ xf_proxy_cmap_link_t cmap[XF_CFG_PROXY_MAX_CLIENTS];
+};
+
+/*******************************************************************************
+ * Auxiliary proxy helpers
+ ******************************************************************************/
+
+/* ...get proxy identifier */
+static inline u32 xf_proxy_id(xf_proxy_t *proxy)
+{
+ return proxy->core;
+}
+
+/* ...lock proxy data */
+static inline void xf_proxy_lock(xf_proxy_t *proxy)
+{
+ __xf_lock(&proxy->lock);
+}
+
+/* ...unlock proxy data */
+static inline void xf_proxy_unlock(xf_proxy_t *proxy)
+{
+ __xf_unlock(&proxy->lock);
+}
+
+/* ...translate proxy shared address into local virtual address */
+static inline void * xf_proxy_a2b(xf_proxy_t *proxy, u32 address)
+{
+ return xf_ipc_a2b(&proxy->ipc, address);
+}
+
+/* ...translate local virtual address into shared proxy address */
+static inline u32 xf_proxy_b2a(xf_proxy_t *proxy, void *b)
+{
+ return xf_ipc_b2a(&proxy->ipc, b);
+}
+
+/* ...submit asynchronous response message */
+static inline int xf_proxy_response_put(xf_proxy_t *proxy, xf_proxy_msg_t *msg)
+{
+ return xf_proxy_ipc_response_put(&proxy->ipc, msg);
+}
+
+/* ...retrieve asynchronous response message */
+static inline int xf_proxy_response_get(xf_proxy_t *proxy, xf_proxy_msg_t *msg)
+{
+ return xf_proxy_ipc_response_get(&proxy->ipc, msg);
+}
+
+/*******************************************************************************
+ * Component handle definition
+ ******************************************************************************/
+
+struct xf_handle
+{
+ /* ...platform-specific IPC data */
+ xf_ipc_data_t ipc;
+
+ /* ...reference to proxy data */
+ xf_proxy_t *proxy;
+
+ /* ...component lock */
+ xf_lock_t lock;
+
+ /* ...auxiliary control buffer for control transactions */
+ xf_buffer_t *aux;
+
+ /* ...global client-id of the component */
+ u32 id;
+
+ /* ...local client number (think about merging into "id" field - tbd) */
+ u32 client;
+
+ /* ...response processing hook */
+ xf_response_cb response;
+};
+
+/*******************************************************************************
+ * Auxiliary component helpers
+ ******************************************************************************/
+
+/* ...component client-id (global scope) */
+static inline u32 xf_handle_id(xf_handle_t *handle)
+{
+ return handle->id;
+}
+
+/* ...pointer to auxiliary buffer */
+static inline void * xf_handle_aux(xf_handle_t *handle)
+{
+ return xf_buffer_data(handle->aux);
+}
+
+/* ...acquire component lock */
+static inline void xf_lock(xf_handle_t *handle)
+{
+ __xf_lock(&handle->lock);
+}
+
+/* ...release component lock */
+static inline void xf_unlock(xf_handle_t *handle)
+{
+ __xf_unlock(&handle->lock);
+}
+
+/* ...put asynchronous response into local IPC */
+static inline int xf_response_put(xf_handle_t *handle, xf_user_msg_t *msg)
+{
+ return xf_ipc_response_put(&handle->ipc, msg);
+}
+
+/* ...get asynchronous response from local IPC */
+static inline int xf_response_get(xf_handle_t *handle, xf_user_msg_t *msg)
+{
+ return xf_ipc_response_get(&handle->ipc, msg);
+}
diff --git a/hifi/xaf/host-apf/include/xf.h b/hifi/xaf/host-apf/include/xf.h
new file mode 100644
index 00000000..6af69ce6
--- /dev/null
+++ b/hifi/xaf/host-apf/include/xf.h
@@ -0,0 +1,53 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#ifdef __XF_H
+#error "xf.h included more than once"
+#endif
+
+#define __XF_H
+
+/*******************************************************************************
+ * Common runtime framework
+ ******************************************************************************/
+
+/* ...target configuration */
+#include "xf-config.h"
+
+/* ...platform run-time */
+#include "xf-runtime.h"
+
+/* ...debugging facility */
+#include "xf-debug.h"
+
+/* ...API prototypes */
+#include "xf-proto.h"
+
+/* ...standard opcodes */
+#include "xf-opcode.h"
+
+/* ...platform-specific IPC layer */
+#include "xf-ipc.h"
+
+/* ...proxy definitions */
+#include "xf-proxy.h"
+
diff --git a/hifi/xaf/host-apf/playback/tinyalsa/asoundlib.h b/hifi/xaf/host-apf/playback/tinyalsa/asoundlib.h
new file mode 100644
index 00000000..753a996b
--- /dev/null
+++ b/hifi/xaf/host-apf/playback/tinyalsa/asoundlib.h
@@ -0,0 +1,314 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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 ASOUNDLIB_H
+#define ASOUNDLIB_H
+
+#include <sys/time.h>
+#include <stddef.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/*
+ * PCM API
+ */
+
+struct pcm;
+
+#define PCM_OUT 0x00000000
+#define PCM_IN 0x10000000
+#define PCM_MMAP 0x00000001
+#define PCM_NOIRQ 0x00000002
+#define PCM_NORESTART 0x00000004 /* PCM_NORESTART - when set, calls to
+ * pcm_write for a playback stream will not
+ * attempt to restart the stream in the case
+ * of an underflow, but will return -EPIPE
+ * instead. After the first -EPIPE error, the
+ * stream is considered to be stopped, and a
+ * second call to pcm_write will attempt to
+ * restart the stream.
+ */
+#define PCM_MONOTONIC 0x00000008 /* see pcm_get_htimestamp */
+
+/* PCM runtime states */
+#define PCM_STATE_OPEN 0
+#define PCM_STATE_SETUP 1
+#define PCM_STATE_PREPARED 2
+#define PCM_STATE_RUNNING 3
+#define PCM_STATE_XRUN 4
+#define PCM_STATE_DRAINING 5
+#define PCM_STATE_PAUSED 6
+#define PCM_STATE_SUSPENDED 7
+#define PCM_STATE_DISCONNECTED 8
+
+/* TLV header size*/
+#define TLV_HEADER_SIZE (2 * sizeof(unsigned int))
+
+/* Bit formats */
+enum pcm_format {
+ PCM_FORMAT_INVALID = -1,
+ PCM_FORMAT_S16_LE = 0, /* 16-bit signed */
+ PCM_FORMAT_S32_LE, /* 32-bit signed */
+ PCM_FORMAT_S8, /* 8-bit signed */
+ PCM_FORMAT_S24_LE, /* 24-bits in 4-bytes */
+ PCM_FORMAT_S24_3LE, /* 24-bits in 3-bytes */
+
+ PCM_FORMAT_MAX,
+};
+
+/* Bitmask has 256 bits (32 bytes) in asound.h */
+struct pcm_mask {
+ unsigned int bits[32 / sizeof(unsigned int)];
+};
+
+/* Configuration for a stream */
+struct pcm_config {
+ unsigned int channels;
+ unsigned int rate;
+ unsigned int period_size;
+ unsigned int period_count;
+ enum pcm_format format;
+
+ /* Values to use for the ALSA start, stop and silence thresholds, and
+ * silence size. Setting any one of these values to 0 will cause the
+ * default tinyalsa values to be used instead.
+ * Tinyalsa defaults are as follows.
+ *
+ * start_threshold : period_count * period_size
+ * stop_threshold : period_count * period_size
+ * silence_threshold : 0
+ * silence_size : 0
+ */
+ unsigned int start_threshold;
+ unsigned int stop_threshold;
+ unsigned int silence_threshold;
+ unsigned int silence_size;
+
+ /* Minimum number of frames available before pcm_mmap_write() will actually
+ * write into the kernel buffer. Only used if the stream is opened in mmap mode
+ * (pcm_open() called with PCM_MMAP flag set). Use 0 for default.
+ */
+ int avail_min;
+};
+
+/* PCM parameters */
+enum pcm_param
+{
+ /* mask parameters */
+ PCM_PARAM_ACCESS,
+ PCM_PARAM_FORMAT,
+ PCM_PARAM_SUBFORMAT,
+ /* interval parameters */
+ PCM_PARAM_SAMPLE_BITS,
+ PCM_PARAM_FRAME_BITS,
+ PCM_PARAM_CHANNELS,
+ PCM_PARAM_RATE,
+ PCM_PARAM_PERIOD_TIME,
+ PCM_PARAM_PERIOD_SIZE,
+ PCM_PARAM_PERIOD_BYTES,
+ PCM_PARAM_PERIODS,
+ PCM_PARAM_BUFFER_TIME,
+ PCM_PARAM_BUFFER_SIZE,
+ PCM_PARAM_BUFFER_BYTES,
+ PCM_PARAM_TICK_TIME,
+};
+
+/* Mixer control types */
+enum mixer_ctl_type {
+ MIXER_CTL_TYPE_BOOL,
+ MIXER_CTL_TYPE_INT,
+ MIXER_CTL_TYPE_ENUM,
+ MIXER_CTL_TYPE_BYTE,
+ MIXER_CTL_TYPE_IEC958,
+ MIXER_CTL_TYPE_INT64,
+ MIXER_CTL_TYPE_UNKNOWN,
+
+ MIXER_CTL_TYPE_MAX,
+};
+
+/* Open and close a stream */
+struct pcm *pcm_open(unsigned int card, unsigned int device,
+ unsigned int flags, struct pcm_config *config);
+int pcm_close(struct pcm *pcm);
+int pcm_is_ready(struct pcm *pcm);
+
+/* Obtain the parameters for a PCM */
+struct pcm_params *pcm_params_get(unsigned int card, unsigned int device,
+ unsigned int flags);
+void pcm_params_free(struct pcm_params *pcm_params);
+
+struct pcm_mask *pcm_params_get_mask(struct pcm_params *pcm_params,
+ enum pcm_param param);
+unsigned int pcm_params_get_min(struct pcm_params *pcm_params,
+ enum pcm_param param);
+void pcm_params_set_min(struct pcm_params *pcm_params,
+ enum pcm_param param, unsigned int val);
+unsigned int pcm_params_get_max(struct pcm_params *pcm_params,
+ enum pcm_param param);
+void pcm_params_set_max(struct pcm_params *pcm_params,
+ enum pcm_param param, unsigned int val);
+
+/* Converts the pcm parameters to a human readable string.
+ * The string parameter is a caller allocated buffer of size bytes,
+ * which is then filled up to size - 1 and null terminated,
+ * if size is greater than zero.
+ * The return value is the number of bytes copied to string
+ * (not including null termination) if less than size; otherwise,
+ * the number of bytes required for the buffer.
+ */
+int pcm_params_to_string(struct pcm_params *params, char *string, unsigned int size);
+
+/* Returns 1 if the pcm_format is present (format bit set) in
+ * the pcm_params structure; 0 otherwise, or upon unrecognized format.
+ */
+int pcm_params_format_test(struct pcm_params *params, enum pcm_format format);
+
+/* Set and get config */
+int pcm_get_config(struct pcm *pcm, struct pcm_config *config);
+int pcm_set_config(struct pcm *pcm, struct pcm_config *config);
+
+/* Returns a human readable reason for the last error */
+const char *pcm_get_error(struct pcm *pcm);
+
+/* Returns the sample size in bits for a PCM format.
+ * As with ALSA formats, this is the storage size for the format, whereas the
+ * format represents the number of significant bits. For example,
+ * PCM_FORMAT_S24_LE uses 32 bits of storage.
+ */
+unsigned int pcm_format_to_bits(enum pcm_format format);
+
+/* Returns the buffer size (int frames) that should be used for pcm_write. */
+unsigned int pcm_get_buffer_size(struct pcm *pcm);
+unsigned int pcm_frames_to_bytes(struct pcm *pcm, unsigned int frames);
+unsigned int pcm_bytes_to_frames(struct pcm *pcm, unsigned int bytes);
+
+/* Returns the pcm latency in ms */
+unsigned int pcm_get_latency(struct pcm *pcm);
+
+/* Returns available frames in pcm buffer and corresponding time stamp.
+ * The clock is CLOCK_MONOTONIC if flag PCM_MONOTONIC was specified in pcm_open,
+ * otherwise the clock is CLOCK_REALTIME.
+ * For an input stream, frames available are frames ready for the
+ * application to read.
+ * For an output stream, frames available are the number of empty frames available
+ * for the application to write.
+ */
+int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail,
+ struct timespec *tstamp);
+
+/* Returns the subdevice on which the pcm has been opened */
+unsigned int pcm_get_subdevice(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, const void *data, unsigned int count);
+int pcm_read(struct pcm *pcm, void *data, unsigned int count);
+
+/*
+ * mmap() support.
+ */
+int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count);
+int pcm_mmap_read(struct pcm *pcm, void *data, unsigned int count);
+int pcm_mmap_begin(struct pcm *pcm, void **areas, unsigned int *offset,
+ unsigned int *frames);
+int pcm_mmap_commit(struct pcm *pcm, unsigned int offset, unsigned int frames);
+int pcm_mmap_avail(struct pcm *pcm);
+
+/* Prepare the PCM substream to be triggerable */
+int pcm_prepare(struct pcm *pcm);
+/* Start and stop a PCM channel that doesn't transfer data */
+int pcm_start(struct pcm *pcm);
+int pcm_stop(struct pcm *pcm);
+
+/* ioctl function for PCM driver */
+int pcm_ioctl(struct pcm *pcm, int request, ...);
+
+/* Interrupt driven API */
+int pcm_wait(struct pcm *pcm, int timeout);
+int pcm_get_poll_fd(struct pcm *pcm);
+
+/* Change avail_min after the stream has been opened with no need to stop the stream.
+ * Only accepted if opened with PCM_MMAP and PCM_NOIRQ flags
+ */
+int pcm_set_avail_min(struct pcm *pcm, int avail_min);
+
+/*
+ * MIXER API
+ */
+
+struct mixer;
+struct mixer_ctl;
+
+/* Open and close a mixer */
+struct mixer *mixer_open(unsigned int card);
+void mixer_close(struct mixer *mixer);
+
+/* Get info about a mixer */
+const char *mixer_get_name(struct mixer *mixer);
+
+/* Obtain mixer controls */
+unsigned int mixer_get_num_ctls(struct mixer *mixer);
+struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id);
+struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name);
+
+/* Get info about mixer controls */
+const char *mixer_ctl_get_name(struct mixer_ctl *ctl);
+enum mixer_ctl_type mixer_ctl_get_type(struct mixer_ctl *ctl);
+const char *mixer_ctl_get_type_string(struct mixer_ctl *ctl);
+unsigned int mixer_ctl_get_num_values(struct mixer_ctl *ctl);
+unsigned int mixer_ctl_get_num_enums(struct mixer_ctl *ctl);
+const char *mixer_ctl_get_enum_string(struct mixer_ctl *ctl,
+ unsigned int enum_id);
+
+/* Some sound cards update their controls due to external events,
+ * such as HDMI EDID byte data changing when an HDMI cable is
+ * connected. This API allows the count of elements to be updated.
+ */
+void mixer_ctl_update(struct mixer_ctl *ctl);
+
+/* Set and get mixer controls */
+int mixer_ctl_get_percent(struct mixer_ctl *ctl, unsigned int id);
+int mixer_ctl_set_percent(struct mixer_ctl *ctl, unsigned int id, int percent);
+
+int mixer_ctl_get_value(struct mixer_ctl *ctl, unsigned int id);
+int mixer_ctl_is_access_tlv_rw(struct mixer_ctl *ctl);
+int mixer_ctl_get_array(struct mixer_ctl *ctl, void *array, size_t count);
+int mixer_ctl_set_value(struct mixer_ctl *ctl, unsigned int id, int value);
+int mixer_ctl_set_array(struct mixer_ctl *ctl, const void *array, size_t count);
+int mixer_ctl_set_enum_by_string(struct mixer_ctl *ctl, const char *string);
+
+/* Determe range of integer mixer controls */
+int mixer_ctl_get_range_min(struct mixer_ctl *ctl);
+int mixer_ctl_get_range_max(struct mixer_ctl *ctl);
+
+int mixer_subscribe_events(struct mixer *mixer, int subscribe);
+int mixer_wait_event(struct mixer *mixer, int timeout);
+
+#if defined(__cplusplus)
+} /* extern "C" */
+#endif
+
+#endif
diff --git a/hifi/xaf/host-apf/playback/tinyalsa/pcm.c b/hifi/xaf/host-apf/playback/tinyalsa/pcm.c
new file mode 100644
index 00000000..e0dc7bb7
--- /dev/null
+++ b/hifi/xaf/host-apf/playback/tinyalsa/pcm.c
@@ -0,0 +1,1311 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <poll.h>
+
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <limits.h>
+
+#include <linux/ioctl.h>
+#define __force
+//#define __bitwise
+#define __user
+#include <sound/asound.h>
+
+#include <tinyalsa/asoundlib.h>
+
+#define PARAM_MAX SNDRV_PCM_HW_PARAM_LAST_INTERVAL
+
+/* Logs information into a string; follows snprintf() in that
+ * offset may be greater than size, and though no characters are copied
+ * into string, characters are still counted into offset. */
+#define STRLOG(string, offset, size, ...) \
+ do { int temp, clipoffset = offset > size ? size : offset; \
+ temp = snprintf(string + clipoffset, size - clipoffset, __VA_ARGS__); \
+ if (temp > 0) offset += temp; } while (0)
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#endif
+
+/* refer to SNDRV_PCM_ACCESS_##index in sound/asound.h. */
+static const char * const access_lookup[] = {
+ "MMAP_INTERLEAVED",
+ "MMAP_NONINTERLEAVED",
+ "MMAP_COMPLEX",
+ "RW_INTERLEAVED",
+ "RW_NONINTERLEAVED",
+};
+
+/* refer to SNDRV_PCM_FORMAT_##index in sound/asound.h. */
+static const char * const format_lookup[] = {
+ /*[0] =*/ "S8",
+ "U8",
+ "S16_LE",
+ "S16_BE",
+ "U16_LE",
+ "U16_BE",
+ "S24_LE",
+ "S24_BE",
+ "U24_LE",
+ "U24_BE",
+ "S32_LE",
+ "S32_BE",
+ "U32_LE",
+ "U32_BE",
+ "FLOAT_LE",
+ "FLOAT_BE",
+ "FLOAT64_LE",
+ "FLOAT64_BE",
+ "IEC958_SUBFRAME_LE",
+ "IEC958_SUBFRAME_BE",
+ "MU_LAW",
+ "A_LAW",
+ "IMA_ADPCM",
+ "MPEG",
+ /*[24] =*/ "GSM",
+ /* gap */
+ [31] = "SPECIAL",
+ "S24_3LE",
+ "S24_3BE",
+ "U24_3LE",
+ "U24_3BE",
+ "S20_3LE",
+ "S20_3BE",
+ "U20_3LE",
+ "U20_3BE",
+ "S18_3LE",
+ "S18_3BE",
+ "U18_3LE",
+ /*[43] =*/ "U18_3BE",
+#if 0
+ /* recent additions, may not be present on local asound.h */
+ "G723_24",
+ "G723_24_1B",
+ "G723_40",
+ "G723_40_1B",
+ "DSD_U8",
+ "DSD_U16_LE",
+#endif
+};
+
+/* refer to SNDRV_PCM_SUBFORMAT_##index in sound/asound.h. */
+static const char * const subformat_lookup[] = {
+ "STD",
+};
+
+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 int 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 int val)
+{
+ if (param_is_interval(n)) {
+ struct snd_interval *i = param_to_interval(p, n);
+ i->min = val;
+ }
+}
+
+static unsigned int param_get_min(struct snd_pcm_hw_params *p, int n)
+{
+ if (param_is_interval(n)) {
+ struct snd_interval *i = param_to_interval(p, n);
+ return i->min;
+ }
+ return 0;
+}
+
+static void param_set_max(struct snd_pcm_hw_params *p, int n, unsigned int val)
+{
+ if (param_is_interval(n)) {
+ struct snd_interval *i = param_to_interval(p, n);
+ i->max = val;
+ }
+}
+
+static unsigned int param_get_max(struct snd_pcm_hw_params *p, int n)
+{
+ if (param_is_interval(n)) {
+ struct snd_interval *i = param_to_interval(p, n);
+ return i->max;
+ }
+ return 0;
+}
+
+static void param_set_int(struct snd_pcm_hw_params *p, int n, unsigned int 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 unsigned int param_get_int(struct snd_pcm_hw_params *p, int n)
+{
+ if (param_is_interval(n)) {
+ struct snd_interval *i = param_to_interval(p, n);
+ if (i->integer)
+ return i->max;
+ }
+ return 0;
+}
+
+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;
+ }
+ p->rmask = ~0U;
+ p->cmask = 0;
+ p->info = ~0U;
+}
+
+#define PCM_ERROR_MAX 128
+
+struct pcm {
+ int fd;
+ unsigned int flags;
+ int running:1;
+ int prepared:1;
+ int underruns;
+ unsigned int buffer_size;
+ unsigned int boundary;
+ char error[PCM_ERROR_MAX];
+ struct pcm_config config;
+ struct snd_pcm_mmap_status *mmap_status;
+ struct snd_pcm_mmap_control *mmap_control;
+ struct snd_pcm_sync_ptr *sync_ptr;
+ void *mmap_buffer;
+ unsigned int noirq_frames_per_msec;
+ int wait_for_avail_min;
+ unsigned int subdevice;
+};
+
+unsigned int pcm_get_buffer_size(struct pcm *pcm)
+{
+ return pcm->buffer_size;
+}
+
+const char* pcm_get_error(struct pcm *pcm)
+{
+ return pcm->error;
+}
+
+unsigned int pcm_get_subdevice(struct pcm *pcm)
+{
+ return pcm->subdevice;
+}
+
+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;
+}
+
+static unsigned int pcm_format_to_alsa(enum pcm_format format)
+{
+ switch (format) {
+ case PCM_FORMAT_S32_LE:
+ return SNDRV_PCM_FORMAT_S32_LE;
+ case PCM_FORMAT_S8:
+ return SNDRV_PCM_FORMAT_S8;
+ case PCM_FORMAT_S24_3LE:
+ return SNDRV_PCM_FORMAT_S24_3LE;
+ case PCM_FORMAT_S24_LE:
+ return SNDRV_PCM_FORMAT_S24_LE;
+ default:
+ case PCM_FORMAT_S16_LE:
+ return SNDRV_PCM_FORMAT_S16_LE;
+ };
+}
+
+unsigned int pcm_format_to_bits(enum pcm_format format)
+{
+ switch (format) {
+ case PCM_FORMAT_S32_LE:
+ case PCM_FORMAT_S24_LE:
+ return 32;
+ case PCM_FORMAT_S24_3LE:
+ return 24;
+ default:
+ case PCM_FORMAT_S16_LE:
+ return 16;
+ };
+}
+
+unsigned int pcm_bytes_to_frames(struct pcm *pcm, unsigned int bytes)
+{
+ return bytes / (pcm->config.channels *
+ (pcm_format_to_bits(pcm->config.format) >> 3));
+}
+
+unsigned int pcm_frames_to_bytes(struct pcm *pcm, unsigned int frames)
+{
+ return frames * pcm->config.channels *
+ (pcm_format_to_bits(pcm->config.format) >> 3);
+}
+
+static int pcm_sync_ptr(struct pcm *pcm, int flags) {
+ if (pcm->sync_ptr) {
+ pcm->sync_ptr->flags = flags;
+ if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SYNC_PTR, pcm->sync_ptr) < 0)
+ return -1;
+ }
+ return 0;
+}
+
+static int pcm_hw_mmap_status(struct pcm *pcm) {
+
+ if (pcm->sync_ptr)
+ return 0;
+
+ int page_size = sysconf(_SC_PAGE_SIZE);
+ pcm->mmap_status = mmap(NULL, page_size, PROT_READ, MAP_FILE | MAP_SHARED,
+ pcm->fd, SNDRV_PCM_MMAP_OFFSET_STATUS);
+ if (pcm->mmap_status == MAP_FAILED)
+ pcm->mmap_status = NULL;
+ if (!pcm->mmap_status)
+ goto mmap_error;
+
+ pcm->mmap_control = mmap(NULL, page_size, PROT_READ | PROT_WRITE,
+ MAP_FILE | MAP_SHARED, pcm->fd, SNDRV_PCM_MMAP_OFFSET_CONTROL);
+ if (pcm->mmap_control == MAP_FAILED)
+ pcm->mmap_control = NULL;
+ if (!pcm->mmap_control) {
+ munmap(pcm->mmap_status, page_size);
+ pcm->mmap_status = NULL;
+ goto mmap_error;
+ }
+ if (pcm->flags & PCM_MMAP)
+ pcm->mmap_control->avail_min = pcm->config.avail_min;
+ else
+ pcm->mmap_control->avail_min = 1;
+
+ return 0;
+
+mmap_error:
+
+ pcm->sync_ptr = calloc(1, sizeof(*pcm->sync_ptr));
+ if (!pcm->sync_ptr)
+ return -ENOMEM;
+ pcm->mmap_status = &pcm->sync_ptr->s.status;
+ pcm->mmap_control = &pcm->sync_ptr->c.control;
+ if (pcm->flags & PCM_MMAP)
+ pcm->mmap_control->avail_min = pcm->config.avail_min;
+ else
+ pcm->mmap_control->avail_min = 1;
+
+ pcm_sync_ptr(pcm, 0);
+
+ return 0;
+}
+
+static void pcm_hw_munmap_status(struct pcm *pcm) {
+ if (pcm->sync_ptr) {
+ free(pcm->sync_ptr);
+ pcm->sync_ptr = NULL;
+ } else {
+ int page_size = sysconf(_SC_PAGE_SIZE);
+ if (pcm->mmap_status)
+ munmap(pcm->mmap_status, page_size);
+ if (pcm->mmap_control)
+ munmap(pcm->mmap_control, page_size);
+ }
+ pcm->mmap_status = NULL;
+ pcm->mmap_control = NULL;
+}
+
+static int pcm_areas_copy(struct pcm *pcm, unsigned int pcm_offset,
+ char *buf, unsigned int src_offset,
+ unsigned int frames)
+{
+ int size_bytes = pcm_frames_to_bytes(pcm, frames);
+ int pcm_offset_bytes = pcm_frames_to_bytes(pcm, pcm_offset);
+ int src_offset_bytes = pcm_frames_to_bytes(pcm, src_offset);
+
+ /* interleaved only atm */
+ if (pcm->flags & PCM_IN)
+ memcpy(buf + src_offset_bytes,
+ (char*)pcm->mmap_buffer + pcm_offset_bytes,
+ size_bytes);
+ else
+ memcpy((char*)pcm->mmap_buffer + pcm_offset_bytes,
+ buf + src_offset_bytes,
+ size_bytes);
+ return 0;
+}
+
+static int pcm_mmap_transfer_areas(struct pcm *pcm, char *buf,
+ unsigned int offset, unsigned int size)
+{
+ void *pcm_areas;
+ int commit;
+ unsigned int pcm_offset, frames, count = 0;
+
+ while (size > 0) {
+ frames = size;
+ pcm_mmap_begin(pcm, &pcm_areas, &pcm_offset, &frames);
+ pcm_areas_copy(pcm, pcm_offset, buf, offset, frames);
+ commit = pcm_mmap_commit(pcm, pcm_offset, frames);
+ if (commit < 0) {
+ oops(pcm, commit, "failed to commit %d frames\n", frames);
+ return commit;
+ }
+
+ offset += commit;
+ count += commit;
+ size -= commit;
+ }
+ return count;
+}
+
+int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail,
+ struct timespec *tstamp)
+{
+ int frames;
+ int rc;
+ snd_pcm_uframes_t hw_ptr;
+
+ if (!pcm_is_ready(pcm))
+ return -1;
+
+ rc = pcm_sync_ptr(pcm, SNDRV_PCM_SYNC_PTR_APPL|SNDRV_PCM_SYNC_PTR_HWSYNC);
+ if (rc < 0)
+ return -1;
+
+ if ((pcm->mmap_status->state != PCM_STATE_RUNNING) &&
+ (pcm->mmap_status->state != PCM_STATE_DRAINING))
+ return -1;
+
+ *tstamp = pcm->mmap_status->tstamp;
+ if (tstamp->tv_sec == 0 && tstamp->tv_nsec == 0)
+ return -1;
+
+ hw_ptr = pcm->mmap_status->hw_ptr;
+ if (pcm->flags & PCM_IN)
+ frames = hw_ptr - pcm->mmap_control->appl_ptr;
+ else
+ frames = hw_ptr + pcm->buffer_size - pcm->mmap_control->appl_ptr;
+
+ if (frames < 0)
+ frames += pcm->boundary;
+ else if (frames > (int)pcm->boundary)
+ frames -= pcm->boundary;
+
+ *avail = (unsigned int)frames;
+
+ return 0;
+}
+
+int pcm_write(struct pcm *pcm, const void *data, unsigned int count)
+{
+ struct snd_xferi x;
+
+ if (pcm->flags & PCM_IN)
+ return -EINVAL;
+
+ x.buf = (void*)data;
+ x.frames = count / (pcm->config.channels *
+ pcm_format_to_bits(pcm->config.format) / 8);
+
+ for (;;) {
+ if (!pcm->running) {
+ int prepare_error = pcm_prepare(pcm);
+ if (prepare_error)
+ return prepare_error;
+ 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->prepared = 0;
+ pcm->running = 0;
+ if (errno == EPIPE) {
+ /* we failed to make our window -- try to restart if we are
+ * allowed to do so. Otherwise, simply allow the EPIPE error to
+ * propagate up to the app level */
+ pcm->underruns++;
+ if (pcm->flags & PCM_NORESTART)
+ return -EPIPE;
+ continue;
+ }
+ return oops(pcm, errno, "cannot write stream data");
+ }
+ return 0;
+ }
+}
+
+int pcm_read(struct pcm *pcm, void *data, unsigned int count)
+{
+ struct snd_xferi x;
+
+ if (!(pcm->flags & PCM_IN))
+ return -EINVAL;
+
+ x.buf = data;
+ x.frames = count / (pcm->config.channels *
+ pcm_format_to_bits(pcm->config.format) / 8);
+
+ for (;;) {
+ if (!pcm->running) {
+ if (pcm_start(pcm) < 0) {
+ fprintf(stderr, "start error");
+ return -errno;
+ }
+ }
+ if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_READI_FRAMES, &x)) {
+ pcm->prepared = 0;
+ 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");
+ }
+ return 0;
+ }
+}
+
+static struct pcm bad_pcm = {
+ .fd = -1,
+};
+
+struct pcm_params *pcm_params_get(unsigned int card, unsigned int device,
+ unsigned int flags)
+{
+ struct snd_pcm_hw_params *params;
+ char fn[256];
+ int fd;
+
+ snprintf(fn, sizeof(fn), "/dev/snd/pcmC%uD%u%c", card, device,
+ flags & PCM_IN ? 'c' : 'p');
+
+ fd = open(fn, O_RDWR);
+ if (fd < 0) {
+ fprintf(stderr, "cannot open device '%s'\n", fn);
+ goto err_open;
+ }
+
+ params = calloc(1, sizeof(struct snd_pcm_hw_params));
+ if (!params)
+ goto err_calloc;
+
+ param_init(params);
+ if (ioctl(fd, SNDRV_PCM_IOCTL_HW_REFINE, params)) {
+ fprintf(stderr, "SNDRV_PCM_IOCTL_HW_REFINE error (%d)\n", errno);
+ goto err_hw_refine;
+ }
+
+ close(fd);
+
+ return (struct pcm_params *)params;
+
+err_hw_refine:
+ free(params);
+err_calloc:
+ close(fd);
+err_open:
+ return NULL;
+}
+
+void pcm_params_free(struct pcm_params *pcm_params)
+{
+ struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params;
+
+ if (params)
+ free(params);
+}
+
+static int pcm_param_to_alsa(enum pcm_param param)
+{
+ switch (param) {
+ case PCM_PARAM_ACCESS:
+ return SNDRV_PCM_HW_PARAM_ACCESS;
+ case PCM_PARAM_FORMAT:
+ return SNDRV_PCM_HW_PARAM_FORMAT;
+ case PCM_PARAM_SUBFORMAT:
+ return SNDRV_PCM_HW_PARAM_SUBFORMAT;
+ case PCM_PARAM_SAMPLE_BITS:
+ return SNDRV_PCM_HW_PARAM_SAMPLE_BITS;
+ break;
+ case PCM_PARAM_FRAME_BITS:
+ return SNDRV_PCM_HW_PARAM_FRAME_BITS;
+ break;
+ case PCM_PARAM_CHANNELS:
+ return SNDRV_PCM_HW_PARAM_CHANNELS;
+ break;
+ case PCM_PARAM_RATE:
+ return SNDRV_PCM_HW_PARAM_RATE;
+ break;
+ case PCM_PARAM_PERIOD_TIME:
+ return SNDRV_PCM_HW_PARAM_PERIOD_TIME;
+ break;
+ case PCM_PARAM_PERIOD_SIZE:
+ return SNDRV_PCM_HW_PARAM_PERIOD_SIZE;
+ break;
+ case PCM_PARAM_PERIOD_BYTES:
+ return SNDRV_PCM_HW_PARAM_PERIOD_BYTES;
+ break;
+ case PCM_PARAM_PERIODS:
+ return SNDRV_PCM_HW_PARAM_PERIODS;
+ break;
+ case PCM_PARAM_BUFFER_TIME:
+ return SNDRV_PCM_HW_PARAM_BUFFER_TIME;
+ break;
+ case PCM_PARAM_BUFFER_SIZE:
+ return SNDRV_PCM_HW_PARAM_BUFFER_SIZE;
+ break;
+ case PCM_PARAM_BUFFER_BYTES:
+ return SNDRV_PCM_HW_PARAM_BUFFER_BYTES;
+ break;
+ case PCM_PARAM_TICK_TIME:
+ return SNDRV_PCM_HW_PARAM_TICK_TIME;
+ break;
+
+ default:
+ return -1;
+ }
+}
+
+struct pcm_mask *pcm_params_get_mask(struct pcm_params *pcm_params,
+ enum pcm_param param)
+{
+ int p;
+ struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params;
+ if (params == NULL) {
+ return NULL;
+ }
+
+ p = pcm_param_to_alsa(param);
+ if (p < 0 || !param_is_mask(p)) {
+ return NULL;
+ }
+
+ return (struct pcm_mask *)param_to_mask(params, p);
+}
+
+unsigned int pcm_params_get_min(struct pcm_params *pcm_params,
+ enum pcm_param param)
+{
+ struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params;
+ int p;
+
+ if (!params)
+ return 0;
+
+ p = pcm_param_to_alsa(param);
+ if (p < 0)
+ return 0;
+
+ return param_get_min(params, p);
+}
+
+void pcm_params_set_min(struct pcm_params *pcm_params,
+ enum pcm_param param, unsigned int val)
+{
+ struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params;
+ int p;
+
+ if (!params)
+ return;
+
+ p = pcm_param_to_alsa(param);
+ if (p < 0)
+ return;
+
+ param_set_min(params, p, val);
+}
+
+unsigned int pcm_params_get_max(struct pcm_params *pcm_params,
+ enum pcm_param param)
+{
+ struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params;
+ int p;
+
+ if (!params)
+ return 0;
+
+ p = pcm_param_to_alsa(param);
+ if (p < 0)
+ return 0;
+
+ return param_get_max(params, p);
+}
+
+void pcm_params_set_max(struct pcm_params *pcm_params,
+ enum pcm_param param, unsigned int val)
+{
+ struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params;
+ int p;
+
+ if (!params)
+ return;
+
+ p = pcm_param_to_alsa(param);
+ if (p < 0)
+ return;
+
+ param_set_max(params, p, val);
+}
+
+static int pcm_mask_test(struct pcm_mask *m, unsigned int index)
+{
+ const unsigned int bitshift = 5; /* for 32 bit integer */
+ const unsigned int bitmask = (1 << bitshift) - 1;
+ unsigned int element;
+
+ element = index >> bitshift;
+ if (element >= ARRAY_SIZE(m->bits))
+ return 0; /* for safety, but should never occur */
+ return (m->bits[element] >> (index & bitmask)) & 1;
+}
+
+static int pcm_mask_to_string(struct pcm_mask *m, char *string, unsigned int size,
+ char *mask_name,
+ const char * const *bit_array_name, size_t bit_array_size)
+{
+ unsigned int i;
+ unsigned int offset = 0;
+
+ if (m == NULL)
+ return 0;
+ if (bit_array_size < 32) {
+ STRLOG(string, offset, size, "%12s:\t%#08x\n", mask_name, m->bits[0]);
+ } else { /* spans two or more bitfields, print with an array index */
+ for (i = 0; i < (bit_array_size + 31) >> 5; ++i) {
+ STRLOG(string, offset, size, "%9s[%d]:\t%#08x\n",
+ mask_name, i, m->bits[i]);
+ }
+ }
+ for (i = 0; i < bit_array_size; ++i) {
+ if (pcm_mask_test(m, i)) {
+ STRLOG(string, offset, size, "%12s \t%s\n", "", bit_array_name[i]);
+ }
+ }
+ return offset;
+}
+
+int pcm_params_to_string(struct pcm_params *params, char *string, unsigned int size)
+{
+ struct pcm_mask *m;
+ unsigned int min, max;
+ unsigned int clipoffset, offset;
+
+ m = pcm_params_get_mask(params, PCM_PARAM_ACCESS);
+ offset = pcm_mask_to_string(m, string, size,
+ "Access", access_lookup, ARRAY_SIZE(access_lookup));
+ m = pcm_params_get_mask(params, PCM_PARAM_FORMAT);
+ clipoffset = offset > size ? size : offset;
+ offset += pcm_mask_to_string(m, string + clipoffset, size - clipoffset,
+ "Format", format_lookup, ARRAY_SIZE(format_lookup));
+ m = pcm_params_get_mask(params, PCM_PARAM_SUBFORMAT);
+ clipoffset = offset > size ? size : offset;
+ offset += pcm_mask_to_string(m, string + clipoffset, size - clipoffset,
+ "Subformat", subformat_lookup, ARRAY_SIZE(subformat_lookup));
+ min = pcm_params_get_min(params, PCM_PARAM_RATE);
+ max = pcm_params_get_max(params, PCM_PARAM_RATE);
+ STRLOG(string, offset, size, " Rate:\tmin=%uHz\tmax=%uHz\n", min, max);
+ min = pcm_params_get_min(params, PCM_PARAM_CHANNELS);
+ max = pcm_params_get_max(params, PCM_PARAM_CHANNELS);
+ STRLOG(string, offset, size, " Channels:\tmin=%u\t\tmax=%u\n", min, max);
+ min = pcm_params_get_min(params, PCM_PARAM_SAMPLE_BITS);
+ max = pcm_params_get_max(params, PCM_PARAM_SAMPLE_BITS);
+ STRLOG(string, offset, size, " Sample bits:\tmin=%u\t\tmax=%u\n", min, max);
+ min = pcm_params_get_min(params, PCM_PARAM_PERIOD_SIZE);
+ max = pcm_params_get_max(params, PCM_PARAM_PERIOD_SIZE);
+ STRLOG(string, offset, size, " Period size:\tmin=%u\t\tmax=%u\n", min, max);
+ min = pcm_params_get_min(params, PCM_PARAM_PERIODS);
+ max = pcm_params_get_max(params, PCM_PARAM_PERIODS);
+ STRLOG(string, offset, size, "Period count:\tmin=%u\t\tmax=%u\n", min, max);
+ return offset;
+}
+
+int pcm_params_format_test(struct pcm_params *params, enum pcm_format format)
+{
+ unsigned int alsa_format = pcm_format_to_alsa(format);
+
+ if (alsa_format == SNDRV_PCM_FORMAT_S16_LE && format != PCM_FORMAT_S16_LE)
+ return 0; /* caution: format not recognized is equivalent to S16_LE */
+ return pcm_mask_test(pcm_params_get_mask(params, PCM_PARAM_FORMAT), alsa_format);
+}
+
+int pcm_close(struct pcm *pcm)
+{
+ if (pcm == &bad_pcm)
+ return 0;
+
+ pcm_hw_munmap_status(pcm);
+
+ if (pcm->flags & PCM_MMAP) {
+ pcm_stop(pcm);
+ munmap(pcm->mmap_buffer, pcm_frames_to_bytes(pcm, pcm->buffer_size));
+ }
+
+ if (pcm->fd >= 0)
+ close(pcm->fd);
+ pcm->prepared = 0;
+ pcm->running = 0;
+ pcm->buffer_size = 0;
+ pcm->fd = -1;
+ free(pcm);
+ return 0;
+}
+
+struct pcm *pcm_open(unsigned int card, unsigned int device,
+ unsigned int flags, struct pcm_config *config)
+{
+ struct pcm *pcm;
+ struct snd_pcm_info info;
+ struct snd_pcm_hw_params params;
+ struct snd_pcm_sw_params sparams;
+ char fn[256];
+ int rc;
+
+ pcm = calloc(1, sizeof(struct pcm));
+ if (!pcm || !config)
+ return &bad_pcm; /* TODO: could support default config here */
+
+ pcm->config = *config;
+
+ snprintf(fn, sizeof(fn), "/dev/snd/pcmC%uD%u%c", card, device,
+ flags & PCM_IN ? 'c' : 'p');
+
+ pcm->flags = flags;
+ pcm->fd = open(fn, O_RDWR|O_NONBLOCK);
+ if (pcm->fd < 0) {
+ oops(pcm, errno, "cannot open device '%s'", fn);
+ return pcm;
+ }
+
+ if (fcntl(pcm->fd, F_SETFL, fcntl(pcm->fd, F_GETFL) &
+ ~O_NONBLOCK) < 0) {
+ oops(pcm, errno, "failed to reset blocking mode '%s'", fn);
+ goto fail_close;
+ }
+
+ if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_INFO, &info)) {
+ oops(pcm, errno, "cannot get info");
+ goto fail_close;
+ }
+ pcm->subdevice = info.subdevice;
+
+ param_init(&params);
+ param_set_mask(&params, SNDRV_PCM_HW_PARAM_FORMAT,
+ pcm_format_to_alsa(config->format));
+ param_set_mask(&params, SNDRV_PCM_HW_PARAM_SUBFORMAT,
+ SNDRV_PCM_SUBFORMAT_STD);
+ param_set_min(&params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, config->period_size);
+ param_set_int(&params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
+ pcm_format_to_bits(config->format));
+ param_set_int(&params, SNDRV_PCM_HW_PARAM_FRAME_BITS,
+ pcm_format_to_bits(config->format) * config->channels);
+ param_set_int(&params, SNDRV_PCM_HW_PARAM_CHANNELS,
+ config->channels);
+ param_set_int(&params, SNDRV_PCM_HW_PARAM_PERIODS, config->period_count);
+ param_set_int(&params, SNDRV_PCM_HW_PARAM_RATE, config->rate);
+
+ if (flags & PCM_NOIRQ) {
+ if (!(flags & PCM_MMAP)) {
+ oops(pcm, -EINVAL, "noirq only currently supported with mmap().");
+ goto fail_close;
+ }
+
+ params.flags |= SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP;
+ pcm->noirq_frames_per_msec = config->rate / 1000;
+ }
+
+ if (flags & PCM_MMAP)
+ param_set_mask(&params, SNDRV_PCM_HW_PARAM_ACCESS,
+ SNDRV_PCM_ACCESS_MMAP_INTERLEAVED);
+ else
+ param_set_mask(&params, SNDRV_PCM_HW_PARAM_ACCESS,
+ SNDRV_PCM_ACCESS_RW_INTERLEAVED);
+
+ if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_HW_PARAMS, &params)) {
+ oops(pcm, errno, "cannot set hw params");
+ goto fail_close;
+ }
+
+ /* get our refined hw_params */
+ config->period_size = param_get_int(&params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
+ config->period_count = param_get_int(&params, SNDRV_PCM_HW_PARAM_PERIODS);
+ pcm->buffer_size = config->period_count * config->period_size;
+
+ if (flags & PCM_MMAP) {
+ pcm->mmap_buffer = mmap(NULL, pcm_frames_to_bytes(pcm, pcm->buffer_size),
+ PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, pcm->fd, 0);
+ if (pcm->mmap_buffer == MAP_FAILED) {
+ oops(pcm, -errno, "failed to mmap buffer %d bytes\n",
+ pcm_frames_to_bytes(pcm, pcm->buffer_size));
+ goto fail_close;
+ }
+ }
+
+ memset(&sparams, 0, sizeof(sparams));
+ sparams.tstamp_mode = SNDRV_PCM_TSTAMP_ENABLE;
+ sparams.period_step = 1;
+
+ if (!config->start_threshold) {
+ if (pcm->flags & PCM_IN)
+ pcm->config.start_threshold = sparams.start_threshold = 1;
+ else
+ pcm->config.start_threshold = sparams.start_threshold =
+ config->period_count * config->period_size / 2;
+ } else
+ sparams.start_threshold = config->start_threshold;
+
+ /* pick a high stop threshold - todo: does this need further tuning */
+ if (!config->stop_threshold) {
+ if (pcm->flags & PCM_IN)
+ pcm->config.stop_threshold = sparams.stop_threshold =
+ config->period_count * config->period_size * 10;
+ else
+ pcm->config.stop_threshold = sparams.stop_threshold =
+ config->period_count * config->period_size;
+ }
+ else
+ sparams.stop_threshold = config->stop_threshold;
+
+ if (!pcm->config.avail_min) {
+ if (pcm->flags & PCM_MMAP)
+ pcm->config.avail_min = sparams.avail_min = pcm->config.period_size;
+ else
+ pcm->config.avail_min = sparams.avail_min = 1;
+ } else
+ sparams.avail_min = config->avail_min;
+
+ sparams.xfer_align = config->period_size / 2; /* needed for old kernels */
+ sparams.silence_threshold = config->silence_threshold;
+ sparams.silence_size = config->silence_size;
+ pcm->boundary = sparams.boundary = pcm->buffer_size;
+
+ while (pcm->boundary * 2 <= INT_MAX - pcm->buffer_size)
+ pcm->boundary *= 2;
+
+ if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sparams)) {
+ oops(pcm, errno, "cannot set sw params");
+ goto fail;
+ }
+
+ rc = pcm_hw_mmap_status(pcm);
+ if (rc < 0) {
+ oops(pcm, rc, "mmap status failed");
+ goto fail;
+ }
+
+#ifdef SNDRV_PCM_IOCTL_TTSTAMP
+ if (pcm->flags & PCM_MONOTONIC) {
+ int arg = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC;
+ rc = ioctl(pcm->fd, SNDRV_PCM_IOCTL_TTSTAMP, &arg);
+ if (rc < 0) {
+ oops(pcm, rc, "cannot set timestamp type");
+ goto fail;
+ }
+ }
+#endif
+
+ pcm->underruns = 0;
+ return pcm;
+
+fail:
+ if (flags & PCM_MMAP)
+ munmap(pcm->mmap_buffer, pcm_frames_to_bytes(pcm, pcm->buffer_size));
+fail_close:
+ close(pcm->fd);
+ pcm->fd = -1;
+ return pcm;
+}
+
+int pcm_is_ready(struct pcm *pcm)
+{
+ return pcm->fd >= 0;
+}
+
+int pcm_prepare(struct pcm *pcm)
+{
+ if (pcm->prepared)
+ return 0;
+
+ if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_PREPARE) < 0)
+ return oops(pcm, errno, "cannot prepare channel");
+
+ pcm->prepared = 1;
+ return 0;
+}
+
+int pcm_start(struct pcm *pcm)
+{
+ int prepare_error = pcm_prepare(pcm);
+ if (prepare_error)
+ return prepare_error;
+
+ if (pcm->flags & PCM_MMAP)
+ pcm_sync_ptr(pcm, 0);
+
+ if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_START) < 0)
+ return oops(pcm, errno, "cannot start channel");
+
+ pcm->running = 1;
+ return 0;
+}
+
+int pcm_stop(struct pcm *pcm)
+{
+ if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_DROP) < 0)
+ return oops(pcm, errno, "cannot stop channel");
+
+ pcm->prepared = 0;
+ pcm->running = 0;
+ return 0;
+}
+
+static inline int pcm_mmap_playback_avail(struct pcm *pcm)
+{
+ int avail;
+
+ avail = pcm->mmap_status->hw_ptr + pcm->buffer_size - pcm->mmap_control->appl_ptr;
+
+ if (avail < 0)
+ avail += pcm->boundary;
+ else if (avail > (int)pcm->boundary)
+ avail -= pcm->boundary;
+
+ return avail;
+}
+
+static inline int pcm_mmap_capture_avail(struct pcm *pcm)
+{
+ int avail = pcm->mmap_status->hw_ptr - pcm->mmap_control->appl_ptr;
+ if (avail < 0)
+ avail += pcm->boundary;
+ return avail;
+}
+
+int pcm_mmap_avail(struct pcm *pcm)
+{
+ pcm_sync_ptr(pcm, SNDRV_PCM_SYNC_PTR_HWSYNC);
+ if (pcm->flags & PCM_IN)
+ return pcm_mmap_capture_avail(pcm);
+ else
+ return pcm_mmap_playback_avail(pcm);
+}
+
+static void pcm_mmap_appl_forward(struct pcm *pcm, int frames)
+{
+ unsigned int appl_ptr = pcm->mmap_control->appl_ptr;
+ appl_ptr += frames;
+
+ /* check for boundary wrap */
+ if (appl_ptr > pcm->boundary)
+ appl_ptr -= pcm->boundary;
+ pcm->mmap_control->appl_ptr = appl_ptr;
+}
+
+int pcm_mmap_begin(struct pcm *pcm, void **areas, unsigned int *offset,
+ unsigned int *frames)
+{
+ unsigned int continuous, copy_frames, avail;
+
+ /* return the mmap buffer */
+ *areas = pcm->mmap_buffer;
+
+ /* and the application offset in frames */
+ *offset = pcm->mmap_control->appl_ptr % pcm->buffer_size;
+
+ avail = pcm_mmap_avail(pcm);
+ if (avail > pcm->buffer_size)
+ avail = pcm->buffer_size;
+ continuous = pcm->buffer_size - *offset;
+
+ /* we can only copy frames if the are availabale and continuos */
+ copy_frames = *frames;
+ if (copy_frames > avail)
+ copy_frames = avail;
+ if (copy_frames > continuous)
+ copy_frames = continuous;
+ *frames = copy_frames;
+
+ return 0;
+}
+
+int pcm_mmap_commit(struct pcm *pcm, unsigned int offset __attribute__((unused)), unsigned int frames)
+{
+ /* update the application pointer in userspace and kernel */
+ pcm_mmap_appl_forward(pcm, frames);
+ pcm_sync_ptr(pcm, 0);
+
+ return frames;
+}
+
+int pcm_avail_update(struct pcm *pcm)
+{
+ pcm_sync_ptr(pcm, 0);
+ return pcm_mmap_avail(pcm);
+}
+
+int pcm_state(struct pcm *pcm)
+{
+ int err = pcm_sync_ptr(pcm, 0);
+ if (err < 0)
+ return err;
+
+ return pcm->mmap_status->state;
+}
+
+int pcm_set_avail_min(struct pcm *pcm, int avail_min)
+{
+ if ((~pcm->flags) & (PCM_MMAP | PCM_NOIRQ))
+ return -ENOSYS;
+
+ pcm->config.avail_min = avail_min;
+ return 0;
+}
+
+int pcm_wait(struct pcm *pcm, int timeout)
+{
+ struct pollfd pfd;
+ int err;
+
+ pfd.fd = pcm->fd;
+ pfd.events = POLLOUT | POLLERR | POLLNVAL;
+
+ do {
+ /* let's wait for avail or timeout */
+ err = poll(&pfd, 1, timeout);
+ if (err < 0)
+ return -errno;
+
+ /* timeout ? */
+ if (err == 0)
+ return 0;
+
+ /* have we been interrupted ? */
+ if (errno == -EINTR)
+ continue;
+
+ /* check for any errors */
+ if (pfd.revents & (POLLERR | POLLNVAL)) {
+ switch (pcm_state(pcm)) {
+ case PCM_STATE_XRUN:
+ return -EPIPE;
+ case PCM_STATE_SUSPENDED:
+ return -ESTRPIPE;
+ case PCM_STATE_DISCONNECTED:
+ return -ENODEV;
+ default:
+ return -EIO;
+ }
+ }
+ /* poll again if fd not ready for IO */
+ } while (!(pfd.revents & (POLLIN | POLLOUT)));
+
+ return 1;
+}
+
+int pcm_get_poll_fd(struct pcm *pcm)
+{
+ return pcm->fd;
+}
+
+int pcm_mmap_transfer(struct pcm *pcm, const void *buffer, unsigned int bytes)
+{
+ int err = 0, frames, avail;
+ unsigned int offset = 0, count;
+
+ if (bytes == 0)
+ return 0;
+
+ count = pcm_bytes_to_frames(pcm, bytes);
+
+ while (count > 0) {
+
+ /* get the available space for writing new frames */
+ avail = pcm_avail_update(pcm);
+ if (avail < 0) {
+ fprintf(stderr, "cannot determine available mmap frames");
+ return err;
+ }
+
+ /* start the audio if we reach the threshold */
+ if (!pcm->running &&
+ (pcm->buffer_size - avail) >= pcm->config.start_threshold) {
+ if (pcm_start(pcm) < 0) {
+ fprintf(stderr, "start error: hw 0x%x app 0x%x avail 0x%x\n",
+ (unsigned int)pcm->mmap_status->hw_ptr,
+ (unsigned int)pcm->mmap_control->appl_ptr,
+ avail);
+ return -errno;
+ }
+ pcm->wait_for_avail_min = 0;
+ }
+
+ /* sleep until we have space to write new frames */
+ if (pcm->running) {
+ /* enable waiting for avail_min threshold when less frames than we have to write
+ * are available. */
+ if (!pcm->wait_for_avail_min && (count > (unsigned int)avail))
+ pcm->wait_for_avail_min = 1;
+
+ if (pcm->wait_for_avail_min && (avail < pcm->config.avail_min)) {
+ int time = -1;
+
+ /* disable waiting for avail_min threshold to allow small amounts of data to be
+ * written without waiting as long as there is enough room in buffer. */
+ pcm->wait_for_avail_min = 0;
+
+ if (pcm->flags & PCM_NOIRQ)
+ time = (pcm->config.avail_min - avail) / pcm->noirq_frames_per_msec;
+
+ err = pcm_wait(pcm, time);
+ if (err < 0) {
+ pcm->prepared = 0;
+ pcm->running = 0;
+ oops(pcm, err, "wait error: hw 0x%x app 0x%x avail 0x%x\n",
+ (unsigned int)pcm->mmap_status->hw_ptr,
+ (unsigned int)pcm->mmap_control->appl_ptr,
+ avail);
+ pcm->mmap_control->appl_ptr = 0;
+ return err;
+ }
+ continue;
+ }
+ }
+
+ frames = count;
+ if (frames > avail)
+ frames = avail;
+
+ if (!frames)
+ break;
+
+ /* copy frames from buffer */
+ frames = pcm_mmap_transfer_areas(pcm, (void *)buffer, offset, frames);
+ if (frames < 0) {
+ fprintf(stderr, "write error: hw 0x%x app 0x%x avail 0x%x\n",
+ (unsigned int)pcm->mmap_status->hw_ptr,
+ (unsigned int)pcm->mmap_control->appl_ptr,
+ avail);
+ return frames;
+ }
+
+ offset += frames;
+ count -= frames;
+ }
+
+ return 0;
+}
+
+int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count)
+{
+ if ((~pcm->flags) & (PCM_OUT | PCM_MMAP))
+ return -ENOSYS;
+
+ return pcm_mmap_transfer(pcm, (void *)data, count);
+}
+
+int pcm_mmap_read(struct pcm *pcm, void *data, unsigned int count)
+{
+ if ((~pcm->flags) & (PCM_IN | PCM_MMAP))
+ return -ENOSYS;
+
+ return pcm_mmap_transfer(pcm, data, count);
+}
+
+int pcm_ioctl(struct pcm *pcm, int request, ...)
+{
+ va_list ap;
+ void * arg;
+
+ if (!pcm_is_ready(pcm))
+ return -1;
+
+ va_start(ap, request);
+ arg = va_arg(ap, void *);
+ va_end(ap);
+
+ return ioctl(pcm->fd, request, arg);
+}
diff --git a/hifi/xaf/host-apf/playback/xa_playback.c b/hifi/xaf/host-apf/playback/xa_playback.c
new file mode 100644
index 00000000..2a8eefdf
--- /dev/null
+++ b/hifi/xaf/host-apf/playback/xa_playback.c
@@ -0,0 +1,366 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#define MODULE_TAG PLYBK
+
+#include <tinyalsa/asoundlib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "xf.h"
+#include "xa_playback.h"
+
+#if 0
+#define ID_RIFF 0x46464952
+#define ID_WAVE 0x45564157
+#define ID_FMT 0x20746d66
+#define ID_DATA 0x61746164
+
+#define HIFI_MISC_IOCTL_PCM_GAIN _IOW('A', 0x7b, struct misc_io_pcm_buf_param)
+#define HIFI_DSP_MISC_DRIVER "/dev/hifi_misc"
+struct misc_io_pcm_buf_param {
+ uint64_t buf;
+ uint32_t buf_size;
+};
+
+struct riff_wave_header {
+ uint32_t riff_id;
+ uint32_t riff_sz;
+ uint32_t wave_id;
+};
+
+struct chunk_header {
+ uint32_t id;
+ uint32_t sz;
+};
+
+struct chunk_fmt {
+ uint16_t audio_format;
+ uint16_t num_channels;
+ uint32_t sample_rate;
+ uint32_t byte_rate;
+ uint16_t block_align;
+ uint16_t bits_per_sample;
+};
+
+static int s_close = 0;
+
+void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned int channels,
+ unsigned int rate, unsigned int bits, unsigned int period_size,
+ unsigned int period_count);
+
+void stream_close(int sig)
+{
+ /* allow the stream to be closed gracefully */
+ signal(sig, SIG_IGN);
+ s_close = 1;
+}
+#endif
+
+#if 0
+int main(int argc, char **argv)
+{
+ FILE *file;
+ struct riff_wave_header riff_wave_header;
+ struct chunk_header chunk_header;
+ struct chunk_fmt chunk_fmt;
+ unsigned int device = 0;
+ unsigned int card = 0;
+ unsigned int period_size = 1024;
+ unsigned int period_count = 4;
+ char *filename;
+ int more_chunks = 1;
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s file.wav [-D card] [-d device] [-p period_size]"
+ " [-n n_periods] \n", argv[0]);
+ return 1;
+ }
+
+ filename = argv[1];
+ file = fopen(filename, "rb");
+ if (!file) {
+ fprintf(stderr, "Unable to open file '%s'\n", filename);
+ return 1;
+ }
+
+ fread(&riff_wave_header, sizeof(riff_wave_header), 1, file);
+ if ((riff_wave_header.riff_id != ID_RIFF) ||
+ (riff_wave_header.wave_id != ID_WAVE)) {
+ fprintf(stderr, "Error: '%s' is not a riff/wave file\n", filename);
+ fclose(file);
+ return 1;
+ }
+
+ do {
+ fread(&chunk_header, sizeof(chunk_header), 1, file);
+
+ switch (chunk_header.id) {
+ case ID_FMT:
+ fread(&chunk_fmt, sizeof(chunk_fmt), 1, file);
+ /* If the format header is larger, skip the rest */
+ if (chunk_header.sz > sizeof(chunk_fmt))
+ fseek(file, chunk_header.sz - sizeof(chunk_fmt), SEEK_CUR);
+ break;
+ case ID_DATA:
+ /* Stop looking for chunks */
+ more_chunks = 0;
+ break;
+ default:
+ /* Unknown chunk, skip bytes */
+ fseek(file, chunk_header.sz, SEEK_CUR);
+ }
+ } while (more_chunks);
+
+ /* parse command line arguments */
+ argv += 2;
+ while (*argv) {
+ if (strcmp(*argv, "-d") == 0) {
+ argv++;
+ if (*argv)
+ device = atoi(*argv);
+ }
+ if (strcmp(*argv, "-p") == 0) {
+ argv++;
+ if (*argv)
+ period_size = atoi(*argv);
+ }
+ if (strcmp(*argv, "-n") == 0) {
+ argv++;
+ if (*argv)
+ period_count = atoi(*argv);
+ }
+ if (strcmp(*argv, "-D") == 0) {
+ argv++;
+ if (*argv)
+ card = atoi(*argv);
+ }
+ if (*argv)
+ argv++;
+ }
+
+ play_sample(file, card, device, chunk_fmt.num_channels, chunk_fmt.sample_rate,
+ chunk_fmt.bits_per_sample, period_size, period_count);
+
+ fclose(file);
+
+ return 0;
+}
+#endif
+
+static int check_param(struct pcm_params *params, unsigned int param, unsigned int value,
+ char *param_name, char *param_unit)
+{
+ unsigned int min;
+ unsigned int max;
+ int is_within_bounds = 1;
+
+ min = pcm_params_get_min(params, param);
+ if (value < min) {
+ TRACE(ERROR, _x("%s is %u%s, device only supports >= %u%s\n"), param_name, value,
+ param_unit, min, param_unit);
+ is_within_bounds = 0;
+ }
+
+ max = pcm_params_get_max(params, param);
+ if (value > max) {
+ TRACE(ERROR, _x("%s is %u%s, device only supports <= %u%s\n"), param_name, value,
+ param_unit, max, param_unit);
+ is_within_bounds = 0;
+ }
+
+ return is_within_bounds;
+}
+
+static int sample_is_playable(unsigned int card, unsigned int device, unsigned int channels,
+ unsigned int rate, unsigned int bits, unsigned int period_size,
+ unsigned int period_count)
+{
+ struct pcm_params *params;
+ int can_play;
+
+ params = pcm_params_get(card, device, PCM_OUT);
+ if (params == NULL) {
+ TRACE(ERROR, _x("Unable to open PCM device %u.\n"), device);
+ return 0;
+ }
+
+ can_play = check_param(params, PCM_PARAM_RATE, rate, "Sample rate", "Hz");
+ can_play &= check_param(params, PCM_PARAM_CHANNELS, channels, "Sample", " channels");
+ can_play &= check_param(params, PCM_PARAM_SAMPLE_BITS, bits, "Bitrate", " bits");
+ can_play &= check_param(params, PCM_PARAM_PERIOD_SIZE, period_size, "Period size", "Hz");
+ can_play &= check_param(params, PCM_PARAM_PERIODS, period_count, "Period count", "Hz");
+
+ pcm_params_free(params);
+
+ return can_play;
+}
+
+void *xa_playback_open(unsigned int card,
+ unsigned int device,
+ unsigned int channels,
+ unsigned int rate,
+ unsigned int bits,
+ unsigned int period_size,
+ unsigned int period_count)
+{
+ struct pcm_config config;
+ struct pcm *pcm;
+
+ memset(&config, 0, sizeof(config));
+ config.channels = channels;
+ config.rate = rate;
+ config.period_size = period_size;
+ config.period_count = period_count;
+ if (bits == 32)
+ config.format = PCM_FORMAT_S32_LE;
+ else if (bits == 16)
+ config.format = PCM_FORMAT_S16_LE;
+ config.start_threshold = 0;
+ config.stop_threshold = 0;
+ config.silence_threshold = 0;
+
+ if (!sample_is_playable(card, device, channels, rate, bits, period_size, period_count)) {
+ return NULL;
+ }
+
+ pcm = pcm_open(card, device, PCM_OUT, &config);
+ if (!pcm || !pcm_is_ready(pcm)) {
+ TRACE(ERROR, _x("Unable to open PCM device %u (%s)\n"),
+ device, pcm_get_error(pcm));
+ return NULL;
+ }
+
+ return pcm;
+}
+
+int xa_playback_buf(void *handle,
+ const void *data,
+ unsigned int nbytes)
+{
+ int err;
+
+ if (!handle || !data)
+ return XA_PLAYBACK_INVALID_PARAM;
+
+ if (nbytes > 0) {
+ err = pcm_write(handle, data, nbytes);
+
+ if (err == -EINVAL) return XA_PLAYBACK_INVALID_PARAM;
+ if (err == -EPIPE ) return XA_PLAYBACK_UNDERRUN;
+ }
+
+ return XA_PLAYBACK_OK;
+}
+
+int xa_playback_close(void *handle)
+{
+ return pcm_close(handle);
+}
+
+#if 0
+void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned int channels,
+ unsigned int rate, unsigned int bits, unsigned int period_size,
+ unsigned int period_count)
+{
+ struct pcm_config config;
+ struct pcm *pcm;
+ char *buffer;
+ int size;
+ int num_read;
+ int hifi_dsp_fd;
+ struct misc_io_pcm_buf_param pcmbuf;
+
+ hifi_dsp_fd = open(HIFI_DSP_MISC_DRIVER, O_RDWR, 0);
+ if(hifi_dsp_fd < 0){
+ printf("Error opening hifi dsp device %d", errno);
+ }
+
+ memset(&config, 0, sizeof(config));
+ config.channels = channels;
+ config.rate = rate;
+ config.period_size = period_size;
+ config.period_count = period_count;
+ if (bits == 32)
+ config.format = PCM_FORMAT_S32_LE;
+ else if (bits == 16)
+ config.format = PCM_FORMAT_S16_LE;
+ config.start_threshold = 0;
+ config.stop_threshold = 0;
+ config.silence_threshold = 0;
+
+ if (!sample_is_playable(card, device, channels, rate, bits, period_size, period_count)) {
+ return;
+ }
+
+ pcm = pcm_open(card, device, PCM_OUT, &config);
+ if (!pcm || !pcm_is_ready(pcm)) {
+ fprintf(stderr, "Unable to open PCM device %u (%s)\n",
+ device, pcm_get_error(pcm));
+ return;
+ }
+
+ size = pcm_frames_to_bytes(pcm, pcm_get_buffer_size(pcm));
+ buffer = malloc(size);
+ if (!buffer) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", size);
+ free(buffer);
+ pcm_close(pcm);
+ return;
+ }
+
+ printf("Playing sample: %u ch, %u hz, %u bit\n", channels, rate, bits);
+
+ /* catch ctrl-c to shutdown cleanly */
+ signal(SIGINT, stream_close);
+
+ do {
+ num_read = fread(buffer, 1, size, file);
+
+ pcmbuf.buf =(uint64_t) buffer;
+ pcmbuf.buf_size = num_read;
+ if(hifi_dsp_fd) {
+ // printf("ioctl send \n");
+ ioctl(hifi_dsp_fd,HIFI_MISC_IOCTL_PCM_GAIN, &pcmbuf);
+ // printf("ioctl complete \n");
+ }
+
+ if (num_read > 0) {
+ if (pcm_write(pcm, buffer, num_read)) {
+ fprintf(stderr, "Error playing sample\n");
+ break;
+ }
+ }
+ } while (!s_close && num_read > 0);
+
+ free(buffer);
+ pcm_close(pcm);
+ close(hifi_dsp_fd);
+}
+#endif
diff --git a/hifi/xaf/host-apf/playback/xa_playback.h b/hifi/xaf/host-apf/playback/xa_playback.h
new file mode 100644
index 00000000..8e4b3c63
--- /dev/null
+++ b/hifi/xaf/host-apf/playback/xa_playback.h
@@ -0,0 +1,42 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+enum xa_playback_error {
+ XA_PLAYBACK_OK = 0,
+ XA_PLAYBACK_INVALID_PARAM = -1,
+ XA_PLAYBACK_UNDERRUN = -2,
+};
+
+void *xa_playback_open(unsigned int card,
+ unsigned int device,
+ unsigned int channels,
+ unsigned int rate,
+ unsigned int bits,
+ unsigned int period_size,
+ unsigned int period_count);
+
+int xa_playback_buf(void *handle,
+ const void *data,
+ unsigned int nbytes);
+
+int xa_playback_close(void *handle);
+
diff --git a/hifi/xaf/host-apf/proxy/xaf-api.c b/hifi/xaf/host-apf/proxy/xaf-api.c
new file mode 100644
index 00000000..6b5862df
--- /dev/null
+++ b/hifi/xaf/host-apf/proxy/xaf-api.c
@@ -0,0 +1,597 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+#include "xf.h"
+#include "xaf-api.h"
+#include "xaf-structs.h"
+
+#ifdef XAF_HOSTLESS
+#include "xos-msgq-if.h"
+#endif
+#define MODULE_TAG DEVAPI
+
+/*******************************************************************************
+ * Tracing configuration
+ ******************************************************************************/
+
+TRACE_TAG(INIT, 1);
+TRACE_TAG(DEBUG, 1);
+TRACE_TAG(INFO, 1);
+
+#define XAF_4BYTE_ALIGN 4
+#define XAF_8BYTE_ALIGN 8
+#define XAF_32BYTE_ALIGN 32
+
+
+static void xaf_comp_response(xf_handle_t *h, xf_user_msg_t *msg)
+{
+ if (msg->opcode == XF_UNREGISTER)
+ {
+ /* ...component execution failed unexpectedly; die */
+ BUG(1, _x("[%p] Abnormal termination"), h);
+ }
+ else
+ {
+ /* ...submit response to asynchronous delivery queue */
+ xf_response_put(h, msg);
+ }
+}
+
+static XAF_ERR_CODE xaf_comp_add(xaf_comp_t **pp_comp_chain, xaf_comp_t *p_comp)
+{
+ XAF_CHK_PTR(pp_comp_chain);
+ XAF_CHK_PTR(p_comp);
+
+ p_comp->next = *pp_comp_chain;
+ *pp_comp_chain = p_comp;
+
+ return XAF_NO_ERROR;
+}
+
+static XAF_ERR_CODE xaf_comp_post_init_config(xaf_adev_t *p_adev, xaf_comp_t *p_comp, void *p_msg)
+{
+ xf_proxy_t *p_proxy = &p_adev->proxy;
+ xf_start_msg_t *smsg = p_msg;
+
+ p_comp->out_format.sample_rate = smsg->sample_rate;
+ p_comp->out_format.channels = smsg->channels;
+ p_comp->out_format.pcm_width = smsg->pcm_width;
+ p_comp->out_format.input_length = smsg->input_length;
+ p_comp->out_format.output_length = smsg->output_length;
+
+ TRACE(INFO, _b("Component[%x] Params: f=%d, c=%d, w=%d i=%d o=%d"), p_comp->handle.id, smsg->sample_rate, smsg->channels, smsg->pcm_width, smsg->input_length, smsg->output_length);
+
+ if (p_comp->noutbuf)
+ {
+ XF_CHK_API(xf_pool_alloc(p_proxy, p_comp->noutbuf, smsg->output_length, XF_POOL_OUTPUT, &p_comp->outpool, XAF_MEM_ID_COMP,
+ p_adev->pxf_mem_malloc_fxn, p_adev->pxf_mem_free_fxn));
+ }
+
+ p_comp->init_done = 1;
+ p_comp->comp_status = XAF_INIT_DONE;
+
+ return XAF_NO_ERROR;
+}
+
+#ifdef XAF_HOSTLESS
+XAF_ERR_CODE xaf_xos_start()
+{
+#if defined BOARD
+ xos_set_clock_freq(xtbsp_clock_freq_hz());
+#else
+ xos_set_clock_freq(XOS_CLOCK_FREQ);
+#endif
+
+ xos_start("main", 7, 0);
+#if XCHAL_NUM_TIMERS > 0
+ xos_start_system_timer(0, TICK_CYCLES);
+#endif
+
+ return XAF_NO_ERROR;
+}
+#endif
+
+XAF_ERR_CODE xaf_adev_open(void** pp_adev, s32 audio_frmwk_buf_size, s32 audio_comp_buf_size, xaf_mem_malloc_fxn_t mem_malloc, xaf_mem_free_fxn_t mem_free)
+{
+ int size;
+ void * pTmp;
+ xaf_adev_t *p_adev;
+ xf_proxy_t *p_proxy;
+
+ XAF_CHK_PTR(pp_adev);
+ XAF_CHK_PTR(mem_malloc);
+ XAF_CHK_PTR(mem_free);
+
+ /* ...unused arg */
+ (void) audio_comp_buf_size;
+
+ //Memory allocation for adev struct pointer
+ size = (sizeof(xaf_adev_t) +(XAF_4BYTE_ALIGN-1));
+ pTmp = mem_malloc(size, XAF_MEM_ID_DEV);
+ XAF_CHK_PTR(pTmp);
+ memset(pTmp, 0, size);
+
+ p_adev = (xaf_adev_t *) (((unsigned long)pTmp + (XAF_4BYTE_ALIGN-1))& ~(XAF_4BYTE_ALIGN-1));
+ p_adev->adev_ptr = pTmp;
+ *pp_adev = (void *)p_adev;
+
+ p_proxy = &p_adev->proxy;
+
+ // Host side Memory allocation (BSS)
+ p_adev->pxf_mem_malloc_fxn = mem_malloc;
+ p_adev->pxf_mem_free_fxn = mem_free;
+
+ size = sizeof(xaf_ap_utils_t)+(XAF_8BYTE_ALIGN-1);
+ p_adev->p_ap_utils = mem_malloc(size, XAF_MEM_ID_DEV);
+ XAF_CHK_PTR(p_adev->p_ap_utils);
+ //reset memory size stats
+ memset(p_adev->p_ap_utils, 0, sizeof(xaf_ap_utils_t));
+
+ // shmmem Memory allocation
+ p_adev->p_ap_utils->xf_cfg_remote_ipc_pool_size = audio_frmwk_buf_size; //minimum size 256 KB, mmap multiple is 0x1000
+
+ //DSP localbuf allocation is done in the DSP core; nothing to be done here
+
+ /* ...open DSP proxy - specify "DSP#0" */
+ XF_CHK_API(xf_proxy_init(p_proxy, 0, (void *)&p_adev->p_ap_utils->xf_cfg_remote_ipc_pool_size));
+
+ /* ...create auxiliary buffers pool for control commands */
+ XF_CHK_API(xf_pool_alloc(p_proxy, XAF_AUX_POOL_SIZE, XAF_AUX_POOL_MSG_LENGTH, XF_POOL_AUX, &p_proxy->aux, XAF_MEM_ID_DEV,
+ p_adev->pxf_mem_malloc_fxn, p_adev->pxf_mem_free_fxn));
+
+ return XAF_NO_ERROR;
+}
+
+XAF_ERR_CODE xaf_adev_close(void* adev_ptr, xaf_comp_flag flag)
+{
+ xaf_adev_t *p_adev;
+ xf_proxy_t *p_proxy;
+
+ XAF_CHK_PTR(adev_ptr);
+ p_adev = (xaf_adev_t *)adev_ptr;
+
+ /* ...unused arg */
+ (void) flag;
+
+ p_proxy = &p_adev->proxy;
+ if(p_proxy->aux != NULL)
+ {
+ xf_pool_free(p_proxy->aux, XAF_MEM_ID_DEV, p_adev->pxf_mem_free_fxn);
+ }
+
+ xf_proxy_close(p_proxy);
+
+ p_adev->pxf_mem_free_fxn(p_adev->p_ap_utils, XAF_MEM_ID_DEV);
+ p_adev->p_ap_utils = NULL;
+ p_adev->pxf_mem_free_fxn(p_adev->adev_ptr, XAF_MEM_ID_DEV);
+ p_adev->adev_ptr = NULL;
+
+ p_adev->pxf_mem_malloc_fxn = NULL;
+ p_adev->pxf_mem_free_fxn = NULL;
+
+ return XAF_NO_ERROR;
+}
+
+XAF_ERR_CODE xaf_comp_create(void *adev_ptr, void **pp_comp, xf_id_t comp_id, u32 ninbuf, u32 noutbuf, void *pp_inbuf[], xaf_comp_type comp_type)
+{
+ xf_handle_t *p_handle;
+ void * pTmp;
+ int size;
+
+ xaf_adev_t *p_adev;
+ p_adev = (xaf_adev_t *)adev_ptr;
+ xaf_comp_t *p_comp;
+
+ XAF_CHK_PTR(p_adev);
+ XAF_CHK_PTR(pp_comp);
+ XAF_CHK_PTR(comp_id);
+ if (ninbuf) XAF_CHK_PTR(pp_inbuf);
+
+ XAF_CHK_RANGE(ninbuf, 0, XAF_MAX_INBUFS);
+ XAF_CHK_RANGE(noutbuf, 0, 1);
+ XAF_CHK_RANGE(comp_type, XAF_DECODER, XAF_POST_PROC);
+
+ //Memory allocation for component struct pointer
+ size = (sizeof(xaf_comp_t) + (XAF_4BYTE_ALIGN-1));
+ pTmp = p_adev->pxf_mem_malloc_fxn(size, XAF_MEM_ID_COMP);
+ XAF_CHK_PTR(pTmp);
+ memset(pTmp, 0, size);
+ p_comp = (xaf_comp_t *) (((unsigned long)pTmp + (XAF_4BYTE_ALIGN-1))& ~(XAF_4BYTE_ALIGN-1));
+
+ p_comp->comp_ptr = pTmp;
+ *pp_comp = (void*)p_comp;
+
+ memset(p_comp, 0, sizeof(xaf_comp_t));
+ p_handle = &p_comp->handle;
+
+ /* ...create component instance (select core-0) */
+ XF_CHK_API(xf_open(&p_adev->proxy, p_handle, comp_id, 0, xaf_comp_response));
+
+ xaf_comp_add(&p_adev->comp_chain, p_comp);
+
+ // Temporary solution in place of component chain handling
+ p_comp->p_adev = p_adev;
+ p_adev->n_comp += 1;
+ p_comp->ninbuf = ninbuf;
+
+ /* ...allocate input buffer */
+ if (ninbuf)
+ {
+ xf_buffer_t *buf;
+ u32 i;
+ XF_CHK_API(xf_pool_alloc(&p_adev->proxy, ninbuf, XAF_INBUF_SIZE, XF_POOL_INPUT, &p_comp->inpool, XAF_MEM_ID_COMP,
+ p_adev->pxf_mem_malloc_fxn, p_adev->pxf_mem_free_fxn));
+
+ for (i=0; i<ninbuf; i++)
+ {
+ buf = xf_buffer_get(p_comp->inpool);
+ pp_inbuf[i] = xf_buffer_data(buf);
+ }
+
+ }
+ p_comp->noutbuf = noutbuf;
+
+ p_comp->comp_type = comp_type;
+ p_comp->comp_status = XAF_STARTING;
+
+ switch (comp_type)
+ {
+ case XAF_DECODER:
+ case XAF_ENCODER:
+ case XAF_PRE_PROC:
+ case XAF_POST_PROC:
+ p_comp->inp_ports = 1; p_comp->out_ports = 1;
+ break;
+ case XAF_MIXER:
+ p_comp->inp_ports = 4; p_comp->out_ports = 1;
+ break;
+ }
+
+ return XAF_NO_ERROR;
+}
+
+XAF_ERR_CODE xaf_comp_delete(void *comp_ptr)
+{
+ xaf_adev_t *p_adev;
+
+ xaf_comp_t *p_comp;
+ p_comp = (xaf_comp_t *)comp_ptr;
+
+ XAF_CHK_PTR(p_comp);
+
+ // Temporary solution in place of component chain handling
+ p_adev = (xaf_adev_t *)(p_comp->p_adev);
+ XF_CHK_ERR((p_adev->n_comp > 0), XAF_API_ERR);
+ p_adev->n_comp -= 1;
+
+
+ if (p_comp->inpool) xf_pool_free(p_comp->inpool, XAF_MEM_ID_COMP, p_adev->pxf_mem_free_fxn);
+ if (p_comp->outpool) xf_pool_free(p_comp->outpool, XAF_MEM_ID_COMP, p_adev->pxf_mem_free_fxn);
+
+ xf_close(&p_comp->handle);
+
+ /* ...tbd - remove from chain */
+ p_adev->pxf_mem_free_fxn(p_comp->comp_ptr, XAF_MEM_ID_COMP);
+ p_comp->comp_ptr = NULL;
+
+ return XAF_NO_ERROR;
+}
+
+XAF_ERR_CODE xaf_comp_set_config(void *comp_ptr, s32 num_param, s32 *p_param)
+{
+ xaf_comp_t *p_comp;
+ xf_user_msg_t rmsg;
+ xf_set_param_msg_t *smsg;
+ xf_handle_t *p_handle;
+ s32 i, j;
+
+ p_comp = (xaf_comp_t *)comp_ptr;
+
+ XAF_CHK_PTR(p_comp);
+ XAF_CHK_PTR(p_param);
+ XAF_CHK_RANGE(num_param, 1, XAF_MAX_CONFIG_PARAMS);
+
+ p_handle = &p_comp->handle;
+ XAF_CHK_PTR(p_handle);
+
+ /* ...set persistent stream characteristics */
+ smsg = xf_buffer_data(p_handle->aux);
+
+ j = 0;
+ for (i=0; i<num_param; i++)
+ {
+ smsg->item[i].id = p_param[j++];
+ smsg->item[i].value = p_param[j++];
+ }
+
+ /* ...pass command to the component */
+ /* ...tbd - command goes port 0 always, check if okay */
+ XF_CHK_API(xf_command(p_handle, 0, XF_SET_PARAM, smsg, sizeof(xf_set_param_item_t)*num_param));
+
+ /* ...wait until result is delivered */
+ XF_CHK_API(xf_response_get(p_handle, &rmsg));
+
+ /* ...make sure response is expected */
+ XF_CHK_ERR(rmsg.opcode == (u32) XF_SET_PARAM && rmsg.buffer == smsg, XAF_API_ERR);
+
+ return XAF_NO_ERROR;
+}
+
+XAF_ERR_CODE xaf_comp_get_config(void *comp_ptr, s32 num_param, s32 *p_param)
+{
+ xaf_comp_t *p_comp;
+ xf_user_msg_t rmsg;
+ xf_get_param_msg_t *smsg;
+ xf_handle_t *p_handle;
+ s32 i;
+
+ p_comp = (xaf_comp_t *)comp_ptr;
+
+ XAF_CHK_PTR(p_comp);
+ XAF_CHK_PTR(p_param);
+ XAF_CHK_RANGE(num_param, 1, XAF_MAX_CONFIG_PARAMS);
+
+ p_handle = &p_comp->handle;
+ XAF_CHK_PTR(p_handle);
+
+ /* ...set persistent stream characteristics */
+ smsg = xf_buffer_data(p_handle->aux);
+
+ for (i=0; i<num_param; i++)
+ {
+ smsg->c.id[i] = p_param[i];
+ }
+
+ /* ...pass command to the component */
+ /* ...tbd - command goes port 0 always, check if okay */
+ XF_CHK_API(xf_command(p_handle, 0, XF_GET_PARAM, smsg, XF_GET_PARAM_CMD_LEN(num_param)));
+
+ /* ...wait until result is delivered */
+ XF_CHK_API(xf_response_get(p_handle, &rmsg));
+
+ /* ...make sure response is expected */
+ XF_CHK_ERR(rmsg.opcode == (u32) XF_GET_PARAM && rmsg.buffer == smsg, XAF_API_ERR);
+
+ for (i=0; i<num_param; i++)
+ {
+ p_param[i] = smsg->r.value[i];
+ }
+
+ return XAF_NO_ERROR;
+}
+#ifdef XAF_HOSTLESS
+XAF_ERR_CODE xaf_comp_get_status(xaf_adev_t *p_adev, xaf_comp_t *p_comp, xaf_comp_status *p_status, void *p_info)
+#else
+XAF_ERR_CODE xaf_comp_get_status(void *adev_ptr, void *comp_ptr, xaf_comp_status *p_status, xaf_info_t *p_info)
+#endif
+{
+ xaf_adev_t *p_adev;
+ xaf_comp_t *p_comp;
+ xf_handle_t *p_handle;
+
+ p_adev = (xaf_adev_t *)adev_ptr;
+ p_comp = (xaf_comp_t *)comp_ptr;
+
+ XAF_CHK_PTR(p_comp);
+ XAF_CHK_PTR(p_status);
+ XAF_CHK_PTR(p_info);
+ if (!p_comp->init_done) XAF_CHK_PTR(p_adev);
+
+ p_handle = &p_comp->handle;
+
+ if (p_comp->pending_resp)
+ {
+ xf_user_msg_t rmsg;
+ /* ...wait until result is delivered */
+ XF_CHK_API(xf_response_get(p_handle, &rmsg));
+
+ if (rmsg.opcode == XF_FILL_THIS_BUFFER)
+ {
+ if (rmsg.buffer == p_comp->start_buf)
+ {
+ XF_CHK_API(xaf_comp_post_init_config(p_adev, p_comp, p_comp->start_buf));
+ }
+ else
+ {
+#ifdef XAF_HOSTLESS
+ s32 *p_buf = (s32 *) p_info;
+ p_buf[0] = (s32) rmsg.buffer;
+ p_buf[1] = (s32) rmsg.length;
+#else
+ p_info->buf = (void*) rmsg.buffer;
+ p_info->length = (s32) rmsg.length;
+#endif
+ if (!p_comp->inpool && p_comp->outpool) p_comp->pending_resp--;
+
+ if (!rmsg.length) p_comp->comp_status = XAF_EXEC_DONE;
+ else
+ {
+ p_comp->comp_status = XAF_OUTPUT_READY;
+ p_comp->expect_out_cmd++;
+ }
+ }
+ }
+ else
+ {
+ /* ...make sure response is expected */
+ XF_CHK_ERR(rmsg.opcode == (u32) XF_EMPTY_THIS_BUFFER, XAF_API_ERR);
+#ifdef XAF_HOSTLESS
+ s32 *p_buf = (s32 *) p_info;
+ p_buf[0] = (s32) rmsg.buffer;
+ p_buf[1] = (s32) rmsg.length;
+#else
+ p_info->buf = (void*) rmsg.buffer;
+ p_info->length = (s32) rmsg.length;
+#endif
+ p_comp->pending_resp--;
+
+ if (p_comp->input_over && rmsg.buffer == NULL) p_comp->comp_status = XAF_EXEC_DONE;
+ else p_comp->comp_status = XAF_NEED_INPUT;
+ }
+ }
+ else if ((p_comp->comp_status == XAF_STARTING && p_comp->start_cmd_issued) ||
+ (p_comp->comp_status == XAF_INIT_DONE && p_comp->exec_cmd_issued))
+ {
+ if (p_comp->inpool) p_comp->comp_status = XAF_NEED_INPUT;
+ }
+
+ *p_status = p_comp->comp_status;
+
+ return XAF_NO_ERROR;
+}
+
+XAF_ERR_CODE xaf_comp_process(void *adev_ptr, void *comp_ptr, void *p_buf, u32 length, xaf_comp_flag flag)
+{
+ xaf_adev_t *p_adev;
+ xaf_comp_t *p_comp;
+ xf_handle_t *p_handle;
+
+ p_adev = (xaf_adev_t *)adev_ptr;
+ p_comp = (xaf_comp_t *)comp_ptr;
+
+ XAF_CHK_PTR(p_comp);
+ if (!p_comp->init_done) XAF_CHK_PTR(p_adev);
+ XAF_CHK_RANGE(flag, XAF_START_FLAG, XAF_NEED_OUTPUT_FLAG);
+ if (flag == XAF_INPUT_READY_FLAG) XAF_CHK_RANGE(length, 0, XAF_INBUF_SIZE);
+
+ p_handle = &p_comp->handle;
+
+ switch (flag)
+ {
+ case XAF_START_FLAG:
+ if (p_comp->start_cmd_issued)
+ break;
+ else
+ {
+ p_comp->start_buf = xf_buffer_data(p_handle->aux);
+ XF_CHK_API(xf_command(p_handle, (p_comp->inp_ports), XF_FILL_THIS_BUFFER, p_comp->start_buf, 0));
+ p_comp->start_cmd_issued = 1;
+
+ if(p_comp->comp_type != XAF_DECODER)
+ {
+ xf_user_msg_t rmsg;
+ /* ...wait until result is delivered */
+ XF_CHK_API(xf_response_get(p_handle, &rmsg));
+
+ /* ...make sure response is expected */
+ XF_CHK_ERR(rmsg.opcode == XF_FILL_THIS_BUFFER && rmsg.buffer == p_comp->start_buf, XAF_API_ERR);
+
+ XF_CHK_API(xaf_comp_post_init_config(p_adev, p_comp, p_comp->start_buf));
+ }
+ }
+ break;
+
+ case XAF_EXEC_FLAG:
+ if (!p_comp->init_done || p_comp->exec_cmd_issued)
+ break;
+ p_comp->exec_cmd_issued = 1;
+ if (p_comp->outpool)
+ {
+ u32 i;
+ xf_buffer_t *p_buf;
+ void *p_data;
+
+ for (i=0; i<p_comp->noutbuf; i++)
+ {
+ p_buf = xf_buffer_get(p_comp->outpool);
+ p_data = xf_buffer_data(p_buf);
+
+ XF_CHK_API(xf_command(&p_comp->handle, (p_comp->inp_ports), XF_FILL_THIS_BUFFER, p_data, p_comp->out_format.output_length));
+ }
+
+ if (!p_comp->inpool) p_comp->pending_resp = p_comp->noutbuf;
+ }
+ break;
+
+ case XAF_INPUT_OVER_FLAG:
+ if (!p_comp->input_over)
+ {
+ XF_CHK_API(xf_command(p_handle, 0, XF_EMPTY_THIS_BUFFER, NULL, 0));
+ p_comp->input_over = 1;
+ p_comp->pending_resp++;
+ }
+ break;
+
+ case XAF_INPUT_READY_FLAG:
+ if (!p_comp->input_over)
+ {
+ XAF_CHK_PTR(p_buf);
+ XF_CHK_API(xf_command(p_handle, 0, XF_EMPTY_THIS_BUFFER, p_buf, length));
+ p_comp->pending_resp++;
+ }
+ break;
+
+ case XAF_NEED_OUTPUT_FLAG:
+ if (p_comp->expect_out_cmd)
+ {
+ XAF_CHK_PTR(p_buf);
+ XF_CHK_API(xf_command(p_handle, (p_comp->inp_ports), XF_FILL_THIS_BUFFER, p_buf, length));
+ p_comp->expect_out_cmd--;
+
+ if (!p_comp->inpool && p_comp->outpool) p_comp->pending_resp++;
+ }
+ break;
+ }
+
+ return XAF_NO_ERROR;
+}
+
+XAF_ERR_CODE xaf_connect(void *src_ptr, void *dest_ptr, s32 num_buf)
+{
+ xaf_comp_t *p_src;
+ xaf_comp_t *p_dest;
+
+ p_src = (xaf_comp_t *)src_ptr;
+ p_dest = (xaf_comp_t *)dest_ptr;
+
+ XAF_CHK_PTR(p_src);
+ XAF_CHK_PTR(p_dest);
+ XAF_CHK_RANGE(num_buf, 2, 4);
+
+ if (!p_src->init_done || p_src->out_routed == p_src->out_ports || p_dest->inp_routed == p_dest->inp_ports)
+ return XAF_ROUTING_ERROR;
+
+ XF_CHK_API(xf_route(&p_src->handle, (p_src->inp_ports + p_src->out_routed), &p_dest->handle, (p_dest->inp_routed), num_buf, p_src->out_format.output_length, 8));
+
+ p_src->out_routed++;
+ p_dest->inp_routed++;
+
+ return XAF_NO_ERROR;
+}
+
+XAF_ERR_CODE xaf_disconnect(xaf_comp_t *p_comp)
+{
+ XAF_CHK_PTR(p_comp);
+
+ /* ...tbd - support for multiple output ports */
+ if (!p_comp->init_done || p_comp->out_routed != p_comp->out_ports)
+ return XAF_ROUTING_ERROR;
+
+ XF_CHK_API(xf_unroute(&p_comp->handle, (p_comp->inp_ports)));
+
+ return XAF_NO_ERROR;
+}
+
+
+
+
+
+
diff --git a/hifi/xaf/host-apf/proxy/xf-fio.c b/hifi/xaf/host-apf/proxy/xf-fio.c
new file mode 100644
index 00000000..5c3c3dbf
--- /dev/null
+++ b/hifi/xaf/host-apf/proxy/xf-fio.c
@@ -0,0 +1,193 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#define MODULE_TAG FIO
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+
+/*******************************************************************************
+ * Tracing configuration
+ ******************************************************************************/
+
+TRACE_TAG(INIT, 1);
+TRACE_TAG(CMD, 1);
+TRACE_TAG(RSP, 1);
+
+/*******************************************************************************
+ * Local constants - tbd
+ ******************************************************************************/
+
+/* ...proxy setup ioctl */
+#define XF_PROXY_SETUP_IOCTL _IO('P', 0x0)
+
+/* ...proxy close ioctl */
+#define XF_PROXY_CLOSE_IOCTL _IO('P', 0x1)
+
+#define HIFI_DSP_MISC_DRIVER "/dev/hifi_misc"
+#ifndef GJB_COMMENT
+#define HIFI_MISC_IOCTL_XAF_IPC_MSG_SEND _IOW('A', 0x7c, xf_proxy_message_driv_t)
+#define HIFI_MISC_IOCTL_XAF_IPC_MSG_RECV _IOR('A', 0x7d, xf_proxy_message_driv_t)
+#define HIFI_MISC_IOCTL_XAF_IPC_VMSG_PTR _IOR('A', 0x7e, xf_proxy_message_driv_t)
+#endif
+//u8 remote_ipc_pool[XF_CFG_REMOTE_IPC_POOL_SIZE];
+/*******************************************************************************
+ * Internal IPC API implementation
+ ******************************************************************************/
+
+/* ...pass command to remote DSP */
+int xf_ipc_send(xf_proxy_ipc_data_t *ipc, xf_proxy_msg_t *msg, void *b)
+{
+ /* ...unused arg */
+ (void) b;
+
+ int fd = ipc->fd;
+ int ret;
+#ifdef GJB_COMMENT
+ TRACE(CMD, _b("C[%08x]:(%x,%08x,%u)"), msg->id, msg->opcode, msg->address, msg->length);
+
+ /* ...pass message to kernel driver */
+ XF_CHK_ERR(write(fd, msg, sizeof(*msg)) == sizeof(*msg), -errno);
+#else
+ ret = ioctl(fd, HIFI_MISC_IOCTL_XAF_IPC_MSG_SEND, msg);// GJB:-Verify th return value with driver implementation.
+#endif
+
+ /* ...communication mutex is still locked! */
+ return 0;
+}
+
+/* ...wait for response availability */
+int xf_ipc_wait(xf_proxy_ipc_data_t *ipc, u32 timeout)
+{
+ int fd = ipc->fd;
+ fd_set rfds;
+ struct timeval tv;
+
+ /* ...specify waiting set */
+ FD_ZERO(&rfds);
+ FD_SET(fd, &rfds);
+
+ /* ...set timeout value if given */
+ (timeout ? tv.tv_sec = timeout / 1000, tv.tv_usec = (timeout % 1000) * 1000 : 0);
+
+ /* ...wait until there is a data in file */
+// XF_CHK_ERR(select(fd + 1, &rfds, NULL, NULL, (timeout ? &tv : NULL)) >= 0, -errno);
+ select(fd+1,&rfds,NULL,NULL,(timeout? &tv: NULL));
+
+ /* ...check if descriptor is set */
+ return (FD_ISSET(fd, &rfds) ? 0 : -ETIMEDOUT);
+}
+
+/* ...read response from proxy */
+int xf_ipc_recv(xf_proxy_ipc_data_t *ipc, xf_proxy_msg_t *msg, void **buffer)
+{
+ int fd = ipc->fd;
+ int r;
+ xf_proxy_msg_t temp;
+#ifdef GJB_COMMENT
+ /* ...get message header from file */
+ if ((r = read(fd, msg, sizeof(*msg))) == sizeof(*msg))
+ {
+ TRACE(RSP, _b("R[%08x]:(%x,%u,%08x)"), msg->id, msg->opcode, msg->length, msg->address);
+
+ /* ...translate shared address into local pointer */
+ XF_CHK_ERR((*buffer = xf_ipc_a2b(ipc, msg->address)) != (void *)-1, -EBADFD);
+
+ /* ...return positive result indicating the message has been received */
+ return sizeof(*msg);
+ }
+#else
+ if ((r = ioctl(fd, HIFI_MISC_IOCTL_XAF_IPC_MSG_RECV, &temp)) == sizeof(temp))
+ {
+ msg->id = temp.id;
+ msg->opcode = temp.opcode;
+ msg->length = temp.length;
+ *buffer = xf_ipc_a2b(ipc, temp.address);
+ /* ...translate shared address into local pointer */
+ XF_CHK_ERR((*buffer = xf_ipc_a2b(ipc, temp.address)) != (void *)-1, -EBADFD);
+ msg->address = temp.address;
+ return sizeof(*msg);
+ }
+#endif
+ else
+ {
+ /* ...if no response is available, return 0 result */
+ return XF_CHK_API(errno == EAGAIN ? 0 : -errno);
+ }
+}
+
+/*******************************************************************************
+ * Internal API functions implementation
+ ******************************************************************************/
+
+/* ...open proxy interface on proper DSP partition */
+int xf_ipc_open(xf_proxy_ipc_data_t *ipc, u32 core, void *p_shmem)
+{
+ //XF_CHK_ERR((p_shmem != NULL), -errno);
+ //size_t xf_cfg_remote_ipc_pool_size = *(size_t *)p_shmem;//user configured shmem pool size: minimum 256 KB
+ /* ...unused arg */
+ (void) p_shmem;
+#ifdef GJB_COMMENT
+ /* ...open file handle */
+ XF_CHK_ERR((ipc->fd = open("/dev/xtensa-proxy", O_RDWR)) >= 0, -errno);
+
+ /* ...pass shread memory core for this proxy instance */
+ XF_CHK_ERR(ioctl(ipc->fd, XF_PROXY_SETUP_IOCTL, core) >= 0, -errno);
+#else
+ XF_CHK_ERR((ipc->fd = open(HIFI_DSP_MISC_DRIVER, O_RDWR,0)) >= 0, -errno);
+#endif
+ /* ...create pipe for asynchronous response delivery */
+ XF_CHK_ERR(pipe(ipc->pipe) == 0, -errno);
+
+ /* ...map entire shared memory region (not too good - tbd) */
+// ipc->shmem = remote_ipc_pool;
+// ioctl(ipc->fd, HIFI_MISC_IOCTL_XAF_IPC_VMSG_PTR, ipc->shmem);
+#if 1
+ //allocate 256 KB constant size
+ XF_CHK_ERR((ipc->shmem = mmap(NULL, XF_CFG_REMOTE_IPC_POOL_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, ipc->fd, 0)) != MAP_FAILED, -errno);
+#else
+ XF_CHK_ERR((ipc->shmem = mmap(NULL, xf_cfg_remote_ipc_pool_size, PROT_READ | PROT_WRITE, MAP_SHARED, ipc->fd, 0)) != MAP_FAILED, -errno);
+#endif
+ TRACE(INIT, _b("proxy-%u interface opened"), core);
+ return 0;
+}
+
+/* ...close proxy handle */
+void xf_ipc_close(xf_proxy_ipc_data_t *ipc, u32 core)
+{
+ /* ...unmap shared memory region */
+// (void)munmap(ipc->shmem, XF_CFG_REMOTE_IPC_POOL_SIZE);
+
+ /* ...close asynchronous response delivery pipe */
+ close(ipc->pipe[0]), close(ipc->pipe[1]);
+
+ /* ...close proxy file handle */
+ close(ipc->fd);
+
+ TRACE(INIT, _b("proxy-%u interface closed"), core);
+}
+
diff --git a/hifi/xaf/host-apf/proxy/xf-proxy.c b/hifi/xaf/host-apf/proxy/xf-proxy.c
new file mode 100644
index 00000000..9487f4ea
--- /dev/null
+++ b/hifi/xaf/host-apf/proxy/xf-proxy.c
@@ -0,0 +1,686 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#define MODULE_TAG PROXY
+
+/*******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include "xf.h"
+
+/*******************************************************************************
+ * Tracing configuration
+ ******************************************************************************/
+
+TRACE_TAG(INIT, 1);
+TRACE_TAG(CMD, 1);
+TRACE_TAG(EXEC, 1);
+TRACE_TAG(RSP, 1);
+TRACE_TAG(REG, 1);
+TRACE_TAG(MEM, 1);
+TRACE_TAG(GRAPH, 1);
+TRACE_TAG(BUFFER, 1);
+
+/*******************************************************************************
+ * Internal functions definitions
+ ******************************************************************************/
+
+/* ...execute proxy command synchronously */
+static inline int xf_proxy_cmd_exec(xf_proxy_t *proxy, xf_user_msg_t *msg)
+{
+ xf_proxy_msg_t m;
+
+ /* ...send command to remote proxy */
+ m.id = msg->id, m.opcode = msg->opcode, m.length = msg->length;
+
+ /* ...translate address */
+ XF_CHK_ERR((m.address = xf_proxy_b2a(proxy, msg->buffer)) != XF_PROXY_BADADDR, -EINVAL);
+
+ /* ...pass command to remote proxy */
+ XF_CHK_API(xf_ipc_send(&proxy->ipc, &m, msg->buffer));
+
+ /* ...wait for response reception indication from proxy thread */
+ XF_CHK_API(xf_proxy_response_get(proxy, &m));
+
+ /* ...copy parameters */
+ msg->id = m.id, msg->opcode = m.opcode, msg->length = m.length;
+
+ /* ...translate address back to virtual space */
+ XF_CHK_ERR((msg->buffer = xf_proxy_a2b(proxy, m.address)) != (void *)-1, -EBADFD);
+
+ TRACE(EXEC, _b("proxy[%p]: command done: [%08x:%p:%u]"), proxy, msg->opcode, msg->buffer, msg->length);
+
+ return 0;
+}
+
+#if 0
+/* ...pass command to remote DSP */
+static inline int xf_proxy_cmd(xf_proxy_t *proxy, xf_handle_t *handle, xf_user_msg_t *m)
+{
+ xf_proxy_msg_t msg;
+
+ /* ...set session-id of the message */
+ msg.id = __XF_MSG_ID(__XF_AP_CLIENT(proxy->core, handle->client), m->id);
+ msg.opcode = m->opcode;
+ msg.length = m->length;
+
+ /* ...translate buffer pointer to shared address */
+ XF_CHK_ERR((msg.address = xf_proxy_b2a(proxy, m->buffer)) != XF_PROXY_BADADDR, -EINVAL);
+
+ /* ...submit command message to IPC layer */
+ return XF_CHK_API(xf_ipc_send(&proxy->ipc, &msg, m->buffer));
+}
+#endif /* 0 */
+
+/* ...allocate local client-id number */
+static inline u32 xf_client_alloc(xf_proxy_t *proxy, xf_handle_t *handle)
+{
+ u32 client;
+
+ if ((client = proxy->cmap[0].next) != 0)
+ {
+ /* ...pop client from free clients list */
+ proxy->cmap[0].next = proxy->cmap[client].next;
+
+ /* ...put client handle into association map */
+ handle->client = client, proxy->cmap[client].handle = handle;
+ }
+
+ return client;
+}
+
+/* ...recycle local client-id number */
+static inline void xf_client_free(xf_proxy_t *proxy, xf_handle_t *handle)
+{
+ u32 client = handle->client;
+
+ /* ...push client into head of the free clients list */
+ proxy->cmap[client].next = proxy->cmap[0].next;
+
+ /* ...adjust head of free clients */
+ proxy->cmap[0].next = client;
+}
+
+/* ...lookup client basing on its local id */
+static inline xf_handle_t * xf_client_lookup(xf_proxy_t *proxy, u32 client)
+{
+ /* ...client index must be in proper range */
+ BUG(client >= XF_CFG_PROXY_MAX_CLIENTS, _x("Invalid client index: %u"), client);
+
+ /* ...check if client index is small */
+ if (proxy->cmap[client].next < XF_CFG_PROXY_MAX_CLIENTS)
+ return NULL;
+ else
+ return proxy->cmap[client].handle;
+}
+
+/* ...create new client on remote core */
+static inline int xf_client_register(xf_proxy_t *proxy, xf_handle_t *handle, xf_id_t id, u32 core)
+{
+ void *b = xf_handle_aux(handle);
+ xf_user_msg_t msg;
+
+ /* ...set session-id: source is local proxy, destination is remote proxy */
+ msg.id = __XF_MSG_ID(__XF_AP_PROXY(proxy->core), __XF_DSP_PROXY(core));
+ msg.opcode = XF_REGISTER;
+ msg.buffer = b;
+ msg.length = strlen(id) + 1;
+
+ /* ...copy component identifier */
+ strncpy(b, id, xf_buffer_length(handle->aux));
+
+ /* ...execute command synchronously */
+ XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg));
+
+ /* ...check operation is successfull */
+ XF_CHK_ERR(msg.opcode == (u32) XF_REGISTER, -EFAULT);
+
+ /* ...save received component global client-id */
+ handle->id = XF_MSG_SRC(msg.id);
+
+ TRACE(REG, _b("[%p]=[%s:%u:%u]"), handle, id, XF_PORT_CORE(handle->id), XF_PORT_CLIENT(handle->id));
+
+ return 0;
+}
+
+/* ...unregister client from remote proxy */
+static inline int xf_client_unregister(xf_proxy_t *proxy, xf_handle_t *handle)
+{
+ xf_user_msg_t msg;
+
+ /* ...make sure the client is consistent */
+ BUG(proxy->cmap[handle->client].handle != handle, _x("Invalid handle: %p"), handle);
+
+ /* ...set message parameters */
+ msg.id = __XF_MSG_ID(__XF_AP_PROXY(proxy->core), handle->id);
+ msg.opcode = XF_UNREGISTER;
+ msg.buffer = NULL;
+ msg.length = 0;
+
+ /* ...synchronously execute command on remote proxy */
+ XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg));
+
+ /* ...opcode must be XF_UNREGISTER - tbd */
+ BUG(msg.opcode != XF_UNREGISTER, _x("Invalid opcode: %X"), msg.opcode);
+
+ TRACE(REG, _b("%p[%u:%u] unregistered"), handle, XF_PORT_CORE(handle->id), XF_PORT_CLIENT(handle->id));
+
+ return 0;
+}
+
+/* ...allocate shared buffer */
+static inline int xf_proxy_buffer_alloc(xf_proxy_t *proxy, u32 length, void **buffer)
+{
+ u32 core = proxy->core;
+ xf_user_msg_t msg;
+
+ /* ...prepare command parameters */
+ msg.id = __XF_MSG_ID(__XF_AP_PROXY(core), __XF_DSP_PROXY(core));
+ msg.opcode = XF_ALLOC;
+ msg.length = length;
+ msg.buffer = NULL;
+
+ /* ...synchronously execute command on remote proxy */
+ XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg));
+
+ /* ...check if response is valid */
+ XF_CHK_ERR(msg.opcode == XF_ALLOC, -EBADFD);
+
+ /* ...check if allocation is successful */
+ XF_CHK_ERR(msg.buffer != NULL, -ENOMEM);
+
+ /* ...save output parameter */
+ *buffer = msg.buffer;
+
+ TRACE(MEM, _b("proxy-%u: allocated [%p:%u]"), core, *buffer, length);
+
+ return 0;
+}
+
+/* ...free shared AP-DSP memory */
+static inline int xf_proxy_buffer_free(xf_proxy_t *proxy, void *buffer, u32 length)
+{
+ u32 core = proxy->core;
+ xf_user_msg_t msg;
+
+ /* ...prepare command parameters */
+ msg.id = __XF_MSG_ID(__XF_AP_PROXY(core), __XF_DSP_PROXY(core));
+ msg.opcode = XF_FREE;
+ msg.length = length;
+ msg.buffer = buffer;
+
+ /* ...synchronously execute command on remote proxy */
+ XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg));
+
+ /* ...check if response is valid */
+ XF_CHK_ERR(msg.opcode == XF_FREE, -EBADFD);
+
+ TRACE(MEM, _b("proxy-%u: free [%p:%u]"), core, buffer, length);
+
+ return 0;
+}
+
+/*******************************************************************************
+ * Proxy interface asynchronous receiving thread
+ ******************************************************************************/
+
+static void * xf_proxy_thread(void *arg)
+{
+ xf_proxy_t *proxy = arg;
+ xf_handle_t *client;
+ int r;
+
+ /* ...start polling thread */
+ while (1)
+ {
+ xf_proxy_msg_t m;
+ xf_user_msg_t msg;
+
+ /* ...wait for response from remote proxy (infinite timeout) */
+ if ((r = xf_ipc_wait(&proxy->ipc, 0)) < 0)
+ break;
+
+ /* ...retrieve all responses received */
+ while ((r = xf_ipc_recv(&proxy->ipc, &m, &msg.buffer)) == sizeof(m))
+ {
+ /* ...make sure we have proper core identifier of SHMEM interface */
+ BUG(XF_MSG_DST_CORE(m.id) != proxy->core, _x("Invalid session-id: %X (core=%u)"), m.id, proxy->core);
+
+ /* ...make sure translation is successful */
+ BUG(msg.buffer == (void *)-1, _x("Invalid buffer address: %08x"), m.address);
+
+ /* ...retrieve information fields */
+ msg.id = XF_MSG_SRC(m.id), msg.opcode = m.opcode, msg.length = m.length;
+
+ TRACE(RSP, _b("R[%08x]:(%08x,%u,%08x)"), m.id, m.opcode, m.length, m.address);
+
+ /* ...lookup component basing on destination port specification */
+ if (XF_AP_CLIENT(m.id) == 0)
+ {
+ /* ...put proxy response to local IPC queue */
+ xf_proxy_response_put(proxy, &m);
+ }
+ else if ((client = xf_client_lookup(proxy, XF_AP_CLIENT(m.id))) != NULL)
+ {
+ /* ...client is found; invoke its response callback (must be non-blocking) */
+ client->response(client, &msg);
+ }
+ else
+ {
+ /* ...client has been disconnected already; drop message */
+ TRACE(RSP, _b("Client look-up failed - drop message"));
+ }
+ }
+
+ /* ...if result code is negative; terminate thread operation */
+ if (r < 0)
+ {
+ TRACE(ERROR, _x("abnormal proxy[%p] thread termination: %d"), proxy, r);
+ break;
+ }
+ }
+
+ TRACE(INIT, _b("IPC proxy[%p] thread terminated: %d"), proxy, r);
+
+ return (void *)(intptr_t)r;
+}
+
+/*******************************************************************************
+ * HiFi proxy API
+ ******************************************************************************/
+
+/* ...open HiFi proxy */
+int xf_proxy_init(xf_proxy_t *proxy, u32 core, void *p_shmem)
+{
+ u32 i;
+ int r;
+
+ /* ...initialize proxy lock */
+ __xf_lock_init(&proxy->lock);
+
+ /* ...open proxy IPC interface */
+ XF_CHK_API(xf_ipc_open(&proxy->ipc, core, p_shmem));
+
+ /* ...save proxy core - hmm, too much core identifiers - tbd */
+ proxy->core = core;
+
+ /* ...line-up all clients into single-linked list */
+ for (i = 0; i < XF_CFG_PROXY_MAX_CLIENTS - 1; i++)
+ {
+ proxy->cmap[i].next = i + 1;
+ }
+
+ /* ...tail of the list points back to head (list terminator) */
+ proxy->cmap[i].next = 0;
+
+ /* ...initialize thread attributes (joinable, with minimal stack) */
+ if ((r = __xf_thread_create(&proxy->thread, xf_proxy_thread, proxy)) < 0)
+ {
+ TRACE(ERROR, _x("Failed to create polling thread: %d"), r);
+ xf_ipc_close(&proxy->ipc, core);
+ return r;
+ }
+
+ TRACE(INIT, _b("proxy-%u[%p] opened"), core, proxy);
+
+ return 0;
+}
+
+/* ...close proxy handle */
+void xf_proxy_close(xf_proxy_t *proxy)
+{
+ u32 core = proxy->core;
+
+ /* ...terminate proxy thread */
+ __xf_thread_destroy(&proxy->thread);
+
+ /* ...close proxy IPC interface */
+ xf_ipc_close(&proxy->ipc, core);
+
+ TRACE(INIT, _b("proxy-%u[%p] closed"), core, proxy);
+}
+
+/*******************************************************************************
+ * HiFi component API
+ ******************************************************************************/
+
+/* ...open component handle */
+int xf_open(xf_proxy_t *proxy, xf_handle_t *handle, xf_id_t id, u32 core, xf_response_cb response)
+{
+ int r;
+
+ /* ...retrieve auxiliary control buffer from proxy - need I */
+ XF_CHK_ERR(handle->aux = xf_buffer_get(proxy->aux), -EBUSY);
+
+ /* ...initialize IPC data */
+ XF_CHK_API(xf_ipc_data_init(&handle->ipc));
+
+ /* ...register client in interlocked fashion */
+ xf_proxy_lock(proxy);
+
+ /* ...allocate local client */
+ if (xf_client_alloc(proxy, handle) == 0)
+ {
+ TRACE(ERROR, _x("client allocation failed"));
+ r = -EBUSY;
+ }
+ else if ((r = xf_client_register(proxy, handle, id, core)) < 0)
+ {
+ TRACE(ERROR, _x("client registering failed"));
+ xf_client_free(proxy, handle);
+ }
+
+ xf_proxy_unlock(proxy);
+
+ /* ...if failed, release buffer handle */
+ if (r < 0)
+ {
+ /* ...operation failed; return buffer back to proxy pool */
+ xf_buffer_put(handle->aux), handle->aux = NULL;
+ }
+ else
+ {
+ /* ...operation completed successfully; assign handle data */
+ handle->response = response;
+ handle->proxy = proxy;
+
+ TRACE(INIT, _b("component[%p]:(id=%s,core=%u) created"), handle, id, core);
+ }
+
+ return XF_CHK_API(r);
+}
+
+/* ...close component handle */
+void xf_close(xf_handle_t *handle)
+{
+ xf_proxy_t *proxy = handle->proxy;
+
+ /* ...do I need to take component lock here? guess no - tbd */
+
+ /* ...buffers and stuff? - tbd */
+
+ /* ...acquire global proxy lock */
+ xf_proxy_lock(proxy);
+
+ /* ...unregister component from remote DSP proxy (ignore result code) */
+ (void) xf_client_unregister(proxy, handle);
+
+ /* ...recycle client-id afterwards */
+ xf_client_free(proxy, handle);
+
+ /* ...release global proxy lock */
+ xf_proxy_unlock(proxy);
+
+ /* ...destroy IPC data */
+ xf_ipc_data_destroy(&handle->ipc);
+
+ /* ...clear handle data */
+ xf_buffer_put(handle->aux), handle->aux = NULL;
+
+ /* ...wipe out proxy pointer */
+ handle->proxy = NULL;
+
+ TRACE(INIT, _b("component[%p] destroyed"), handle);
+}
+
+/* ...port binding function */
+int xf_route(xf_handle_t *src, u32 src_port, xf_handle_t *dst, u32 dst_port, u32 num, u32 size, u32 align)
+{
+ xf_proxy_t *proxy = src->proxy;
+ xf_buffer_t *b;
+ xf_route_port_msg_t *m;
+ xf_user_msg_t msg;
+
+ /* ...sanity checks - proxy pointers are same */
+ XF_CHK_ERR(proxy == dst->proxy, -EINVAL);
+
+ /* ...buffer data is sane */
+ XF_CHK_ERR(num && size && xf_is_power_of_two(align), -EINVAL);
+
+ /* ...get control buffer */
+ XF_CHK_ERR(b = xf_buffer_get(proxy->aux), -EBUSY);
+
+ /* ...get message buffer */
+ m = xf_buffer_data(b);
+
+ /* ...fill-in message parameters */
+ //m->src = __XF_PORT_SPEC2(src->id, src_port);
+ m->dst = __XF_PORT_SPEC2(dst->id, dst_port);
+ m->alloc_number = num;
+ m->alloc_size = size;
+ m->alloc_align = align;
+
+ /* ...set command parameters */
+ msg.id = __XF_MSG_ID(__XF_AP_PROXY(proxy->core), __XF_PORT_SPEC2(src->id, src_port));
+ msg.opcode = XF_ROUTE;
+ msg.length = sizeof(*m);
+ msg.buffer = m;
+
+ /* ...synchronously execute command on remote DSP */
+ XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg));
+
+ /* ...return buffer to proxy */
+ xf_buffer_put(b);
+
+ /* ...check result is successfull */
+ XF_CHK_ERR(msg.opcode == (u32) XF_ROUTE, -ENOMEM);
+
+ /* ...port binding completed */
+ TRACE(GRAPH, _b("[%p]:%u bound to [%p]:%u"), src, src_port, dst, dst_port);
+
+ return 0;
+}
+
+/* ...port unbinding function */
+int xf_unroute(xf_handle_t *src, u32 src_port)
+{
+ xf_proxy_t *proxy = src->proxy;
+ xf_buffer_t *b;
+ xf_unroute_port_msg_t *m;
+ xf_user_msg_t msg;
+ int r;
+
+ /* ...get control buffer */
+ XF_CHK_ERR(b = xf_buffer_get(proxy->aux), -EBUSY);
+
+ /* ...get message buffer */
+ m = xf_buffer_data(b);
+
+ /* ...fill-in message parameters */
+ //m->src = __XF_PORT_SPEC2(src->id, src_port);
+
+ /* ...set command parameters */
+ msg.id = __XF_MSG_ID(__XF_AP_PROXY(proxy->core), __XF_PORT_SPEC2(src->id, src_port));
+ msg.opcode = XF_UNROUTE;
+ msg.length = sizeof(*m);
+ msg.buffer = m;
+
+ /* ...synchronously execute command on remote DSP */
+ if ((r = xf_proxy_cmd_exec(proxy, &msg)) != 0)
+ {
+ TRACE(ERROR, _x("Command failed: %d"), r);
+ goto out;
+ }
+ else if (msg.opcode != (u32) XF_UNROUTE)
+ {
+ TRACE(ERROR, _x("Port unbinding failed"));
+ r = -EBADFD;
+ goto out;
+ }
+
+ /* ...port binding completed */
+ TRACE(GRAPH, _b("[%p]:%u unbound"), src, src_port);
+
+out:
+ /* ...return buffer to proxy */
+ xf_buffer_put(b);
+
+ return r;
+}
+
+/* ...send a command message to component */
+int xf_command(xf_handle_t *handle, u32 port, u32 opcode, void *buffer, u32 length)
+{
+ xf_proxy_t *proxy = handle->proxy;
+ xf_proxy_msg_t msg;
+
+ /* ...fill-in message parameters */
+ msg.id = __XF_MSG_ID(__XF_AP_CLIENT(proxy->core, handle->client), __XF_PORT_SPEC2(handle->id, port));
+ msg.opcode = opcode;
+ msg.length = length;
+ XF_CHK_ERR((msg.address = xf_proxy_b2a(proxy, buffer)) != XF_PROXY_BADADDR, -EINVAL);
+
+ TRACE(CMD, _b("[%p]:[%08x]:(%08x,%u,%p)"), handle, msg.id, opcode, length, buffer);
+
+ /* ...pass command to IPC layer */
+ return XF_CHK_API(xf_ipc_send(&proxy->ipc, &msg, buffer));
+}
+
+/*******************************************************************************
+ * Buffer pool API
+ ******************************************************************************/
+
+/* ...allocate buffer pool */
+int xf_pool_alloc(xf_proxy_t *proxy, u32 number, u32 length, xf_pool_type_t type, xf_pool_t **pool, s32 id,
+ xaf_mem_malloc_fxn_t xaf_malloc, xaf_mem_free_fxn_t xaf_free)
+{
+ xf_pool_t *p;
+ xf_buffer_t *b;
+ void *data;
+ int r;
+
+ /* ...unused arg */
+ (void) type;
+
+ /* ...basic sanity checks; number of buffers is positive */
+ XF_CHK_ERR(number > 0, -EINVAL);
+
+ /* ...get properly aligned buffer length */
+ length = (length + XF_PROXY_ALIGNMENT - 1) & ~(XF_PROXY_ALIGNMENT - 1);
+
+ /* ...allocate data structure */
+ p = xaf_malloc(offset_of(xf_pool_t, buffer) + number * sizeof(xf_buffer_t), id);
+ XF_CHK_ERR(p, -ENOMEM);
+
+ /* ...issue memory pool allocation request to remote DSP */
+ xf_proxy_lock(proxy);
+ r = xf_proxy_buffer_alloc(proxy, number * length, &p->p);
+ xf_proxy_unlock(proxy);
+
+ /* ...if operation is failed, do cleanup */
+ if (r < 0)
+ {
+ TRACE(ERROR, _x("failed to allocate buffer: %d"), r);
+ xaf_free(p, id);
+ return r;
+ }
+ else
+ {
+ /* ...set pool parameters */
+ p->number = number, p->length = length;
+ p->proxy = proxy;
+ }
+
+ /* ...create individual buffers and link them into free list */
+ for (p->free = b = &p->buffer[0], data = p->p; number > 0; number--, b++)
+ {
+ /* ...set address of the buffer (no length there) */
+ b->address = data;
+
+ /* ...file buffer into the free list */
+ b->link.next = b + 1;
+
+ /* ...advance data pointer in contiguous buffer */
+ data = (unsigned char *) data + length;
+ }
+
+ /* ...terminate list of buffers (not too good - tbd) */
+ b[-1].link.next = NULL;
+
+ TRACE(BUFFER, _b("[%p]: pool[%p] created: %u * %u"), proxy, p, p->number, p->length);
+
+ /* ...return buffer pointer */
+ *pool = p;
+
+ return 0;
+}
+
+/* ...buffer pool destruction */
+void xf_pool_free(xf_pool_t *pool, s32 id, xaf_mem_free_fxn_t xaf_free)
+{
+ xf_proxy_t *proxy = pool->proxy;
+
+ /* ...check buffers are all freed - tbd */
+
+ /* ...use global proxy lock for pool operations protection */
+ xf_proxy_lock(proxy);
+
+ /* ...release allocated buffer on remote DSP */
+ xf_proxy_buffer_free(proxy, pool->p, pool->length * pool->number);
+
+ /* ...release global proxy lock */
+ xf_proxy_unlock(proxy);
+
+ /* ...deallocate pool structure itself */
+ xaf_free(pool, id);
+
+ TRACE(BUFFER, _b("[%p]::pool[%p] destroyed"), proxy, pool);
+}
+
+/* ...get new buffer from a pool */
+xf_buffer_t * xf_buffer_get(xf_pool_t *pool)
+{
+ xf_buffer_t *b;
+
+ /* ...use global proxy lock for pool operations protection */
+ xf_proxy_lock(pool->proxy);
+
+ /* ...take buffer from a head of the free list */
+ if ((b = pool->free) != NULL)
+ {
+ /* ...advance free list head */
+ pool->free = b->link.next, b->link.pool = pool;
+
+ TRACE(BUFFER, _b("pool[%p]::get[%p]"), pool, b);
+ }
+
+ xf_proxy_unlock(pool->proxy);
+
+ return b;
+}
+
+/* ...return buffer back to pool */
+void xf_buffer_put(xf_buffer_t *buffer)
+{
+ xf_pool_t *pool = buffer->link.pool;
+
+ /* ...use global proxy lock for pool operations protection */
+ xf_proxy_lock(pool->proxy);
+
+ /* ...put buffer back to a pool */
+ buffer->link.next = pool->free, pool->free = buffer;
+
+ TRACE(BUFFER, _b("pool[%p]::put[%p]"), pool, buffer);
+
+ xf_proxy_unlock(pool->proxy);
+}
diff --git a/hifi/xaf/host-apf/proxy/xf-trace.c b/hifi/xaf/host-apf/proxy/xf-trace.c
new file mode 100644
index 00000000..fb902676
--- /dev/null
+++ b/hifi/xaf/host-apf/proxy/xf-trace.c
@@ -0,0 +1,90 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#include "xf.h"
+#include <sys/time.h>
+
+#if XF_TRACE
+/*******************************************************************************
+ * Local data definitions
+ ******************************************************************************/
+
+/* ...tracing lock */
+static pthread_mutex_t xf_trace_mutex;
+
+/*******************************************************************************
+ * Tracing facility
+ ******************************************************************************/
+
+/* ...timestamp function */
+static u32 xf_timenow(void)
+{
+ struct timeval tv;
+
+ /* ...get current time value */
+ gettimeofday(&tv, NULL);
+
+ /* ...wrap over every 100 seconds */
+ return (u32)((tv.tv_sec % 100) * 1000000 + tv.tv_usec);
+}
+
+/* ...tracing initialization */
+void xf_trace_init(const char *banner)
+{
+ /* ...initialize tracing lock */
+ pthread_mutex_init(&xf_trace_mutex, NULL);
+
+ /* ...output banner */
+ xf_trace(banner);
+}
+
+/* ...tracing primitive */
+int xf_trace(const char *format, ...)
+{
+ va_list args;
+ static char buf[256];
+ char *b = buf;
+
+ /* ...get global tracing lock */
+ pthread_mutex_lock(&xf_trace_mutex);
+
+ /* ...output timestamp */
+ b += sprintf(b, "[%08u] ", xf_timenow());
+
+ /* ...output format string */
+ va_start(args, format);
+ b += vsprintf(b, format, args);
+ va_end(args);
+
+ /* ...put terminator */
+ *b = '\0';
+
+ /* ...output prepared string */
+ __xf_puts(buf);
+
+ /* ...release tracing lock */
+ pthread_mutex_unlock(&xf_trace_mutex);
+
+ return 0;
+}
+
+#endif /* XF_TRACE */
diff --git a/hifi/xaf/host-apf/tools/dhifimesg b/hifi/xaf/host-apf/tools/dhifimesg
new file mode 100755
index 00000000..88294880
--- /dev/null
+++ b/hifi/xaf/host-apf/tools/dhifimesg
Binary files differ
diff --git a/hifi/xaf/host-apf/utest/include/xaf-mem.h b/hifi/xaf/host-apf/utest/include/xaf-mem.h
new file mode 100644
index 00000000..68838035
--- /dev/null
+++ b/hifi/xaf/host-apf/utest/include/xaf-mem.h
@@ -0,0 +1,49 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#define MEM_NUM_MEM_ALLOC 32
+
+typedef struct {
+ void* heap_ptr;
+ int size;
+}mem_obj_dev_t;
+
+typedef struct {
+ void* heap_ptr;
+ int size;
+}mem_obj_comp_t;
+
+typedef struct {
+ mem_obj_dev_t mem_dev[MEM_NUM_MEM_ALLOC];
+ mem_obj_comp_t mem_comp[MEM_NUM_MEM_ALLOC];
+ int num_malloc_dev;
+ int num_malloc_comp;
+ int persi_mem_dev;
+ int persi_mem_comp;
+}mem_obj_t;
+
+void* mem_malloc(int size, int id);
+void mem_free(void * heap_ptr, int id);
+void* mem_init();
+void mem_exit();
+int mem_get_alloc_size(mem_obj_t* mem_handle, int id);
+
diff --git a/hifi/xaf/host-apf/utest/include/xaf-utils-test.h b/hifi/xaf/host-apf/utest/include/xaf-utils-test.h
new file mode 100644
index 00000000..e6c2ce03
--- /dev/null
+++ b/hifi/xaf/host-apf/utest/include/xaf-utils-test.h
@@ -0,0 +1,37 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#include <stdio.h>
+
+#include "xf.h"
+#include "xaf-api.h"
+#include "xa_type_def.h"
+
+#include "xaf-mem.h"
+
+/* exported global variables */
+extern int audio_frmwk_buf_size;
+extern int audio_comp_buf_size;
+
+int print_mem_mcps_info(mem_obj_t* mem_handle, int num_comp);
+int print_banner(char *app_name);
+
diff --git a/hifi/xaf/host-apf/utest/xaf-dec-mix-test.c b/hifi/xaf/host-apf/utest/xaf-dec-mix-test.c
new file mode 100644
index 00000000..28ac8767
--- /dev/null
+++ b/hifi/xaf/host-apf/utest/xaf-dec-mix-test.c
@@ -0,0 +1,421 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#define MODULE_TAG UTEST
+
+#include "xaf-utils-test.h"
+
+#include "audio/xa_vorbis_dec_api.h"
+#include "audio/xa-mixer-api.h"
+#include "audio/xa-audio-decoder-api.h"
+
+#include "xa_playback.h"
+
+#define PRINT_USAGE do { fprintf(stderr, "\nUsage: %s <input-file1> <input-file2>\n", argv[0]); \
+ fprintf(stderr, " Only .ogg and .pcm files are supported. \n"); \
+ fprintf(stderr, " Playback is configured @ 48kHz, 2 ch, 16 bits pcm. \n"); \
+ fprintf(stderr, " <input-file2> is optional. \n"); \
+ fprintf(stderr, " pcm output is written to dec-mix-out.pcm, by default. \n\n"); \
+ } while(0)
+
+#define MAX_INP_STRMS 2
+#define NUM_COMP_IN_GRAPH 3
+
+/* ...global variables */
+int g_pthread_exit_code=0x12345678;
+
+/* ...playback format */
+xaf_format_t pb_format;
+
+/* ...playback device parameters */
+void *pb_handle = NULL;
+
+void thread_exit_handler(int sig)
+{
+ /* ...unused arg */
+ (void) sig;
+
+ pthread_exit(0);
+}
+
+static int vorbis_setup(void *p_decoder)
+{
+ int param[2];
+
+ /* 1: Raw decode, 0: Ogg decode */
+ param[0] = XA_VORBISDEC_CONFIG_PARAM_RAW_VORBIS_FILE_MODE;
+ param[1] = 0;
+
+ XF_CHK_API(xaf_comp_set_config(p_decoder, 1, &param[0]));
+
+ return 0;
+}
+
+static int pcm_setup(void *p_pcm)
+{
+ int param[6];
+
+ param[0] = XA_CODEC_CONFIG_PARAM_SAMPLE_RATE;
+ param[1] = pb_format.sample_rate;
+ param[2] = XA_CODEC_CONFIG_PARAM_CHANNELS;
+ param[3] = pb_format.channels;
+ param[4] = XA_CODEC_CONFIG_PARAM_PCM_WIDTH;
+ param[5] = pb_format.pcm_width;
+
+ XF_CHK_API(xaf_comp_set_config(p_pcm, 3, &param[0]));
+
+ return 0;
+}
+
+static int mixer_setup(void *p_decoder, xaf_format_t *p_format)
+{
+ int param[6];
+
+ param[0] = XA_MIXER_CONFIG_PARAM_SAMPLE_RATE;
+ param[1] = p_format->sample_rate;
+ param[2] = XA_MIXER_CONFIG_PARAM_CHANNELS;
+ param[3] = p_format->channels;
+ param[4] = XA_MIXER_CONFIG_PARAM_PCM_WIDTH;
+ param[5] = p_format->pcm_width;
+
+ XF_CHK_API(xaf_comp_set_config(p_decoder, 3, &param[0]));
+
+ return 0;
+}
+
+static int consume_output(void *p_buf, int buf_length, void *p_output)
+{
+ XAF_CHK_PTR(p_buf);
+ XAF_CHK_PTR(p_output);
+
+#if !defined BOARD
+ FILE *fp = p_output;
+ fwrite(p_buf, 1, buf_length, fp);
+
+ if (xa_playback_buf(pb_handle, p_buf, buf_length)) {
+ TRACE(ERROR, _b("Playback Failed \n"));
+ return -1;
+ }
+#else
+#endif
+ return 0;
+}
+
+static int read_input(void *p_buf, int buf_length, int *read_length, void *p_input)
+{
+ XAF_CHK_PTR(p_buf);
+ XAF_CHK_PTR(read_length);
+ XAF_CHK_PTR(p_input);
+
+#if !defined BOARD
+ FILE *fp = p_input;
+ *read_length = fread(p_buf, 1, buf_length, fp);
+#else
+#endif
+ return 0;
+}
+
+static int comp_process_entry(void *arg)
+{
+ void *p_comp;
+ void *p_input, *p_output;
+ xaf_comp_status comp_status;
+ xaf_info_t comp_info;
+ int input_over, read_length;
+ void * (*arg_arr)[3];
+ void *pg_pthread_exit_code = (void*)&g_pthread_exit_code;
+
+ XAF_CHK_PTR(arg);
+
+ arg_arr = arg;
+ p_comp = (*arg_arr)[0];
+ p_input = (*arg_arr)[1];
+ p_output = (*arg_arr)[2];
+ input_over = 0;
+
+ XF_CHK_API(xaf_comp_process(NULL, p_comp, NULL, 0, XAF_EXEC_FLAG));
+
+ while (1)
+ {
+ XF_CHK_API(xaf_comp_get_status(NULL, p_comp, &comp_status, &comp_info));
+
+ if (comp_status == XAF_EXEC_DONE) break;
+
+ if (comp_status == XAF_NEED_INPUT && !input_over)
+ {
+ void *p_buf = (void *) comp_info.buf;
+ int size = comp_info.length;
+
+ XF_CHK_API(read_input(p_buf, size, &read_length, p_input));
+
+ if (read_length)
+ XF_CHK_API(xaf_comp_process(NULL, p_comp, (void *)comp_info.buf, read_length, XAF_INPUT_READY_FLAG));
+ else
+ {
+ XF_CHK_API(xaf_comp_process(NULL, p_comp, NULL, 0, XAF_INPUT_OVER_FLAG));
+ input_over = 1;
+ }
+ }
+
+ if (comp_status == XAF_OUTPUT_READY)
+ {
+ void *p_buf = (void *) comp_info.buf;
+ int size = comp_info.length;
+
+ XF_CHK_API(consume_output(p_buf, size, p_output));
+ XF_CHK_API(xaf_comp_process(NULL, p_comp, (void *)comp_info.buf, comp_info.length, XAF_NEED_OUTPUT_FLAG));
+ }
+ }
+ pthread_exit(pg_pthread_exit_code);
+
+ return 0;
+}
+
+int main(int argc, const char **argv)
+{
+ void *p_adev = NULL;
+ void *p_decoder[MAX_INP_STRMS];
+ void *p_mixer;
+ mem_obj_t* mem_handle;
+ int num_comp = NUM_COMP_IN_GRAPH;
+
+ xaf_comp_status dec_status;
+ xaf_info_t comp_info;
+
+ void *p_input[MAX_INP_STRMS], *p_output;
+
+ xf_id_t dec_id[MAX_INP_STRMS];
+ int (*dec_setup[MAX_INP_STRMS])(void *p_comp);
+
+ pthread_t dec_thread[MAX_INP_STRMS];
+ pthread_t mixer_thread;
+ void *dec_thread_args[MAX_INP_STRMS][3];
+ void *mixer_thread_args[3];
+
+ const char *ext;
+ FILE *fp, *ofp;
+ void *dec_inbuf[MAX_INP_STRMS][2];
+ int buf_length = XAF_INBUF_SIZE;
+ int read_length;
+ int input_over = 0;
+ int i, j;
+ int num_strms;
+
+ unsigned int card = 0;
+ unsigned int device = 0;
+ unsigned int period_size = 1024;
+ unsigned int period_count = 4;
+
+ int pthread_error;
+ void *pthread_exit_code[3];
+
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_exit_handler;
+ sigaction(SIGUSR1,&actions,NULL);
+
+ /* ...initialize playback format */
+ pb_format.sample_rate = 48000;
+ pb_format.channels = 2;
+ pb_format.pcm_width = 16;
+
+ audio_frmwk_buf_size = 0; //unused
+ audio_comp_buf_size = 0; //unused
+
+ print_banner("\'Audio decoder(PCM/Ogg-Vorbis) + Mixer\'");
+
+ /* ...initialize tracing facility */
+ TRACE_INIT("Xtensa Audio Framework - Sample Application");
+
+#if !defined BOARD
+ /* ...check input arguments */
+ if (argc < 2 || argc > (MAX_INP_STRMS+1))
+ {
+ TRACE(ERROR, _b("Usage: ./xaf-test <infile1> <infile2>\n"));
+ PRINT_USAGE;
+ return 0;
+ }
+
+ argc--;
+ for (i=0; i<argc; i++)
+ {
+ ext = strrchr(argv[i+1], '.');
+ if (!ext)
+ {
+ PRINT_USAGE;
+ return 0;
+ }
+ ext++;
+ if (!strcmp(ext, "pcm")) {
+ dec_id[i] = "audio-decoder/pcm";
+ dec_setup[i] = pcm_setup;
+ }
+ else if (!strcmp(ext, "ogg")) {
+ dec_id[i] = "audio-decoder/vorbis";
+ dec_setup[i] = vorbis_setup;
+ }
+ else {
+ TRACE(ERROR, _x("Unknown Decoder Extension '%s'"), ext);
+ PRINT_USAGE;
+ exit(-1);
+ }
+ /* ...open file */
+ if ((fp = fopen(argv[i+1], "rb")) == NULL)
+ {
+ TRACE(ERROR, _x("Failed to open '%s': %d"), argv[i+1], errno);
+ exit(-1);
+ }
+ p_input[i] = fp;
+ }
+ num_strms = i;
+
+ if ((ofp = fopen("dec-mix-out.pcm", "wb")) == NULL)
+ {
+ TRACE(ERROR, _x("Failed to open '%s': %d"), "dec-mix-out.pcm", errno);
+ exit(-1);
+ }
+ p_output = ofp;
+#endif
+
+ mem_handle = mem_init(); //initialize memory handler
+
+ XF_CHK_API(xaf_adev_open(&p_adev, audio_frmwk_buf_size, audio_comp_buf_size, mem_malloc, mem_free));
+
+ /* ...create mixer component */
+ XF_CHK_API(xaf_comp_create(p_adev, &p_mixer, "mixer", 0, 1, NULL, XAF_MIXER));
+ XF_CHK_API(mixer_setup(p_mixer, &pb_format));
+
+ for (i=0; i<num_strms; i++)
+ {
+ /* ...create decoder component */
+ XF_CHK_API(xaf_comp_create(p_adev, &p_decoder[i], dec_id[i], 2, 0, &dec_inbuf[i][0], XAF_DECODER));
+ XF_CHK_API((dec_setup[i])(p_decoder[i]));
+
+ /* ...start decoder component */
+ XF_CHK_API(xaf_comp_process(p_adev, p_decoder[i], NULL, 0, XAF_START_FLAG));
+
+ /* ...feed input to decoder component */
+ for (j=0; j<2; j++)
+ {
+ XF_CHK_API(read_input(dec_inbuf[i][j], buf_length, &read_length, p_input[i]));
+
+ if (read_length)
+ XF_CHK_API(xaf_comp_process(p_adev, p_decoder[i], dec_inbuf[i][j], read_length, XAF_INPUT_READY_FLAG));
+ else
+ break;
+ }
+
+ /* ...initialization loop */
+ while (1)
+ {
+ XF_CHK_API(xaf_comp_get_status(p_adev, p_decoder[i], &dec_status, &comp_info));
+
+ if (dec_status == XAF_INIT_DONE || dec_status == XAF_EXEC_DONE) break;
+
+ if (dec_status == XAF_NEED_INPUT && !input_over)
+ {
+ void *p_buf = (void *) comp_info.buf;
+ int size = comp_info.length;
+
+ XF_CHK_API(read_input(p_buf, size, &read_length, p_input[i]));
+
+ if (read_length)
+ XF_CHK_API(xaf_comp_process(p_adev, p_decoder[i], p_buf, read_length, XAF_INPUT_READY_FLAG));
+ else
+ break;
+ }
+ }
+
+ if (dec_status != XAF_INIT_DONE)
+ {
+ TRACE(ERROR, _x("Failed to init"));
+ exit(-1);
+ }
+
+ XF_CHK_API(xaf_connect(p_decoder[i], p_mixer, 4));
+ }
+
+ XF_CHK_API(xaf_comp_process(p_adev, p_mixer, NULL, 0, XAF_START_FLAG));
+ XF_CHK_API(xaf_comp_get_status(p_adev, p_mixer, &dec_status, &comp_info));
+
+ if (dec_status != XAF_INIT_DONE)
+ {
+ TRACE(ERROR, _x("Failed to init"));
+ exit(-1);
+ }
+
+ /* ...open playback device */
+ pb_handle = xa_playback_open(card, device, pb_format.channels, pb_format.sample_rate,
+ pb_format.pcm_width, period_size, period_count);
+ if (!pb_handle) {
+ TRACE(ERROR, _x("Playback open error\n"));
+ return -1;
+ }
+
+ for (i=0; i<num_strms; i++)
+ {
+ dec_thread_args[i][0] = p_decoder[i];
+ dec_thread_args[i][1] = p_input[i];
+ dec_thread_args[i][2] = p_output;
+ pthread_create(&dec_thread[i], 0, (void *(*)(void*))&comp_process_entry, dec_thread_args[i]);
+ }
+
+ mixer_thread_args[0] = p_mixer;
+ mixer_thread_args[1] = NULL;
+ mixer_thread_args[2] = p_output;
+ pthread_create(&mixer_thread, 0, (void *(*)(void*))comp_process_entry, &mixer_thread_args[0]);
+
+ for (i=0; i<num_strms; i++)
+ {
+ pthread_error = pthread_join(dec_thread[i], (void **) &pthread_exit_code[i]);
+ if(pthread_error)
+ {
+ TRACE(ERROR, _b("decode thread %d join error:%x\n"), i, pthread_error);
+ }
+ }
+ pthread_error = pthread_join(mixer_thread, (void **) &pthread_exit_code[i]);
+ if(pthread_error)
+ {
+ TRACE(ERROR, _b("mixer thread join error:%x\n"), pthread_error);
+ }
+
+ for (i=0; i<num_strms; i++)
+ {
+ XF_CHK_API(xaf_comp_delete(p_decoder[i]));
+ if (p_input[i]) fclose(p_input[i]);
+ }
+ XF_CHK_API(xaf_comp_delete(p_mixer));
+
+ /* ...exec done, clean-up */
+ xa_playback_close(pb_handle);
+
+ XF_CHK_API(xaf_adev_close(p_adev, 0 /*unused*/));
+ if (p_output) fclose(p_output);
+
+ mem_exit();
+ XF_CHK_API(print_mem_mcps_info(mem_handle, num_comp));
+
+ return 0;
+}
+
diff --git a/hifi/xaf/host-apf/utest/xaf-dec-test.c b/hifi/xaf/host-apf/utest/xaf-dec-test.c
new file mode 100644
index 00000000..7e5d050a
--- /dev/null
+++ b/hifi/xaf/host-apf/utest/xaf-dec-test.c
@@ -0,0 +1,344 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+
+#define MODULE_TAG UTEST
+
+#include "xaf-utils-test.h"
+
+#include "audio/xa_vorbis_dec_api.h"
+#include "audio/xa-audio-decoder-api.h"
+
+#include "xa_playback.h"
+
+#define PRINT_USAGE do { fprintf(stderr, "\nUsage: %s <input-file>\n", argv[0]); \
+ fprintf(stderr, " Only .ogg and .pcm files are supported. \n"); \
+ fprintf(stderr, " Playback is configured @ 48kHz, 2 ch, 16 bits pcm. \n"); \
+ fprintf(stderr, " pcm output is written to dec-out.pcm, by default. \n\n"); \
+ } while(0)
+
+
+#define NUM_COMP_IN_GRAPH 1
+
+void *p_input, *p_output;
+pthread_t dec_thread;
+
+FILE *fp, *ofp=NULL;
+xaf_info_t comp_info;
+void *pb_handle = NULL;
+unsigned int card = 0;
+unsigned int device = 0;
+unsigned int period_size = 1024;
+unsigned int period_count = 4;
+
+/* ...playback format */
+xaf_format_t pb_format;
+
+int g_pthread_exit_code=0x12345678;
+
+void thread_exit_handler(int sig)
+{
+ /* ...unused arg */
+ (void) sig;
+
+ pthread_exit(0);
+}
+
+static int vorbis_setup(void *p_decoder)
+{
+ int param[2];
+
+ /* 1: Raw decode, 0: Ogg decode */
+ param[0] = XA_VORBISDEC_CONFIG_PARAM_RAW_VORBIS_FILE_MODE;
+ param[1] = 0;
+
+ XF_CHK_API(xaf_comp_set_config(p_decoder, 1, &param[0]));
+
+ return 0;
+}
+
+static int pcm_setup(void *p_pcm)
+{
+ int param[6];
+
+ param[0] = XA_CODEC_CONFIG_PARAM_SAMPLE_RATE;
+ param[1] = pb_format.sample_rate;
+ param[2] = XA_CODEC_CONFIG_PARAM_CHANNELS;
+ param[3] = pb_format.channels;
+ param[4] = XA_CODEC_CONFIG_PARAM_PCM_WIDTH;
+ param[5] = pb_format.pcm_width;
+
+ XF_CHK_API(xaf_comp_set_config(p_pcm, 3, &param[0]));
+
+ return 0;
+}
+
+static int consume_output(void *p_buf, int buf_length, void *p_output)
+{
+ XAF_CHK_PTR(p_buf);
+ XAF_CHK_PTR(p_output);
+
+#if !defined BOARD
+ FILE *fp = p_output;
+ fwrite(p_buf, 1, buf_length, fp);
+
+ if (xa_playback_buf(pb_handle, p_buf, buf_length)) {
+ TRACE(ERROR, _b("Playback Failed \n"));
+ return -1;
+ }
+#else
+#endif
+ return 0;
+}
+
+static int read_input(void *p_buf, int buf_length, int *read_length, void *p_input)
+{
+ XAF_CHK_PTR(p_buf);
+ XAF_CHK_PTR(read_length);
+ XAF_CHK_PTR(p_input);
+
+#if !defined BOARD
+ FILE *fp = p_input;
+ *read_length = fread(p_buf, 1, buf_length, fp);
+#else
+#endif
+ return 0;
+}
+
+static int comp_process_entry(void *arg)
+{
+ void *p_comp;
+ xaf_comp_status comp_status;
+ int input_over, read_length;
+ void *pg_pthread_exit_code = (void*)&g_pthread_exit_code;
+
+ XAF_CHK_PTR(arg);
+ XAF_CHK_PTR(p_input);
+ XAF_CHK_PTR(p_output);
+
+ p_comp = arg;
+ input_over = 0;
+
+ XF_CHK_API(xaf_comp_process(NULL, p_comp, NULL, 0, XAF_EXEC_FLAG));
+
+ while (1)
+ {
+
+ XF_CHK_API(xaf_comp_get_status(NULL, p_comp, &comp_status, &comp_info));
+
+ if (comp_status == XAF_EXEC_DONE) break;
+
+ if (comp_status == XAF_NEED_INPUT && !input_over)
+ {
+ void *p_buf = (void *)comp_info.buf;
+ int size = comp_info.length;
+
+ XF_CHK_API(read_input(p_buf, size, &read_length, p_input));
+
+ if (read_length)
+ XF_CHK_API(xaf_comp_process(NULL, p_comp, (void *)comp_info.buf, read_length, XAF_INPUT_READY_FLAG));
+ else
+ {
+ XF_CHK_API(xaf_comp_process(NULL, p_comp, NULL, 0, XAF_INPUT_OVER_FLAG));
+ input_over = 1;
+ }
+ }
+
+ if (comp_status == XAF_OUTPUT_READY)
+ {
+ void *p_buf = (void *)comp_info.buf;
+ int size = comp_info.length;
+
+ XF_CHK_API(consume_output(p_buf, size, p_output));
+ XF_CHK_API(xaf_comp_process(NULL, p_comp, (void *)comp_info.buf, comp_info.length, XAF_NEED_OUTPUT_FLAG));
+ }
+ }
+ pthread_exit(pg_pthread_exit_code);
+
+ return 0;
+}
+
+
+int main(int argc, const char **argv)
+{
+ void *p_adev = NULL;
+ void *p_decoder;
+ mem_obj_t* mem_handle;
+ int num_comp = NUM_COMP_IN_GRAPH;
+
+ xaf_comp_status dec_status;
+ void *dec_inbuf[2];
+ int buf_length = XAF_INBUF_SIZE;
+ int read_length;
+ int i;
+
+ xf_id_t dec_id;
+ int (*dec_setup)(void *p_comp);
+ const char *ext;
+ int pthread_error;
+ void *pthread_exit_code;
+
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_exit_handler;
+ sigaction(SIGUSR1,&actions,NULL);
+
+ /* ...initialize playback format */
+ pb_format.sample_rate = 48000;
+ pb_format.channels = 2;
+ pb_format.pcm_width = 16;
+
+ audio_frmwk_buf_size = 0; //unused
+ audio_comp_buf_size = 0; //unused
+
+ print_banner("\'Audio decoder(PCM/Ogg-Vorbis)\'");
+
+ /* ...initialize tracing facility */
+ TRACE_INIT("Xtensa Audio Framework - Sample Application");
+
+#if !defined BOARD
+ /* ...check input arguments */
+ if (argc != 2)
+ {
+ TRACE(ERROR, _b("Usage: ./xaf-test <input-file-.ogg/.pcm>\n"));
+ PRINT_USAGE;
+ return 0;
+ }
+
+
+ ext = strrchr(argv[1], '.');
+ if (!ext)
+ {
+ PRINT_USAGE;
+ return 0;
+ }
+ ext++;
+ if (!strcmp(ext, "pcm")) {
+ dec_id = "audio-decoder/pcm";
+ dec_setup = pcm_setup;
+ }
+ else if (!strcmp(ext, "ogg")) {
+ dec_id = "audio-decoder/vorbis";
+ dec_setup = vorbis_setup;
+ }
+ else {
+ TRACE(ERROR, _x("Unknown Decoder Extension '%s'"), ext);
+ PRINT_USAGE;
+ exit(-1);
+ }
+
+ /* ...open file */
+ if ((fp = fopen(argv[1], "rb")) == NULL)
+ {
+ TRACE(ERROR, _x("Failed to open '%s': %d"), argv[1], errno);
+ exit(-1);
+ }
+ if ((ofp = fopen("dec-out.pcm", "wb")) == NULL)
+ {
+ TRACE(ERROR, _x("Failed to open '%s': %d"), "dec-out.pcm", errno);
+ exit(-1);
+ }
+ p_input = fp;
+ p_output = ofp;
+#endif
+
+ mem_handle = mem_init(); //initialize memory handler
+
+ XF_CHK_API(xaf_adev_open(&p_adev, audio_frmwk_buf_size, audio_comp_buf_size, mem_malloc, mem_free));
+
+ /* ...create decoder component */
+ XF_CHK_API(xaf_comp_create(p_adev, &p_decoder, dec_id, 2, 1, &dec_inbuf[0], XAF_DECODER));
+ XF_CHK_API(dec_setup(p_decoder));
+
+ /* ...start decoder component */
+ XF_CHK_API(xaf_comp_process(p_adev, p_decoder, NULL, 0, XAF_START_FLAG));
+
+ /* ...feed input to decoder component */
+ for (i=0; i<2; i++)
+ {
+ XF_CHK_API(read_input(dec_inbuf[i], buf_length, &read_length, p_input));
+
+ if (read_length)
+ XF_CHK_API(xaf_comp_process(p_adev, p_decoder, dec_inbuf[i], read_length, XAF_INPUT_READY_FLAG));
+ else
+ break;
+ }
+
+ /* ...initialization loop */
+ while (1)
+ {
+ XF_CHK_API(xaf_comp_get_status(p_adev, p_decoder, &dec_status, &comp_info));
+
+ if (dec_status == XAF_INIT_DONE || dec_status == XAF_EXEC_DONE)
+ {
+ pb_handle = xa_playback_open(card, device, pb_format.channels, pb_format.sample_rate,
+ pb_format.pcm_width, period_size, period_count);
+ if (!pb_handle) {
+ TRACE(ERROR, _x("Playback open error\n"));
+ return -1;
+ }
+
+ break;
+ }
+
+ if (dec_status == XAF_NEED_INPUT)
+ {
+ void *p_buf = (void *) comp_info.buf;
+ int size = comp_info.length;
+
+ XF_CHK_API(read_input(p_buf, size, &read_length, p_input));
+
+ if (read_length)
+ XF_CHK_API(xaf_comp_process(p_adev, p_decoder, p_buf, read_length, XAF_INPUT_READY_FLAG));
+ else
+ break;
+ }
+ }
+
+ if (dec_status != XAF_INIT_DONE)
+ {
+ TRACE(ERROR, _x("Failed to init"));
+ exit(-1);
+ }
+
+ pthread_create(&dec_thread, 0, (void *(*)(void *))&comp_process_entry, p_decoder);
+
+ pthread_error = pthread_join(dec_thread, (void **) &pthread_exit_code);
+ if(pthread_error)
+ {
+ TRACE(ERROR, _b("decode thread join error:%x\n"), pthread_error);
+ }
+
+ /* ...exec done, clean-up */
+ XF_CHK_API(xaf_comp_delete(p_decoder));
+ xa_playback_close(pb_handle);
+ XF_CHK_API(xaf_adev_close(p_adev, 0 /*unused*/));
+ if (fp) fclose(fp);
+ if (ofp) fclose(ofp);
+
+ mem_exit();
+ XF_CHK_API(print_mem_mcps_info(mem_handle, num_comp));
+
+ return 0;
+}
+
diff --git a/hifi/xaf/host-apf/utest/xaf-mem-test.c b/hifi/xaf/host-apf/utest/xaf-mem-test.c
new file mode 100644
index 00000000..1343c904
--- /dev/null
+++ b/hifi/xaf/host-apf/utest/xaf-mem-test.c
@@ -0,0 +1,150 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "xa_type_def.h"
+
+/* ...debugging facility */
+#include "xaf-utils-test.h"
+
+mem_obj_t g_mem_obj;
+
+void* mem_malloc(int size, int id)
+{
+ int index;
+ void* heap_ptr = NULL;
+
+ if(id == XAF_MEM_ID_DEV)
+ {
+ index = g_mem_obj.num_malloc_dev;
+ if(index >= MEM_NUM_MEM_ALLOC-1)
+ {
+ heap_ptr = NULL;
+ }
+ else
+ {
+ heap_ptr = malloc(size);
+ g_mem_obj.num_malloc_dev++;
+ g_mem_obj.mem_dev[index].heap_ptr = heap_ptr;
+ g_mem_obj.mem_dev[index].size = size;
+ g_mem_obj.persi_mem_dev += size;
+ }
+ }
+ else if(id == XAF_MEM_ID_COMP)
+ {
+ index = g_mem_obj.num_malloc_comp;
+ if(index >= MEM_NUM_MEM_ALLOC-1)
+ {
+ heap_ptr = NULL;
+ }
+ else
+ {
+ heap_ptr = malloc(size);
+ g_mem_obj.num_malloc_comp++;
+ g_mem_obj.mem_comp[index].heap_ptr = heap_ptr;
+ g_mem_obj.mem_comp[index].size = size;
+ g_mem_obj.persi_mem_comp += size;
+ }
+ }
+ return heap_ptr;
+}
+
+int get_heap_ptr_index(void* p_heap, int id)
+{
+ int idx;
+
+ idx = -1;
+ if(id == XAF_MEM_ID_DEV)
+ {
+ for(idx = 0; idx < MEM_NUM_MEM_ALLOC; idx++)
+ {
+ if(g_mem_obj.mem_dev[idx].heap_ptr == p_heap)
+ break;
+ }
+ }
+
+ else if(id == XAF_MEM_ID_COMP)
+ {
+ for(idx = 0; idx < MEM_NUM_MEM_ALLOC; idx++)
+ {
+ if(g_mem_obj.mem_comp[idx].heap_ptr == p_heap)
+ break;
+ }
+ }
+ return idx;
+}
+
+void mem_free(void * heap_ptr, int id)
+{
+ int index;
+ int size;
+
+ index = get_heap_ptr_index(heap_ptr, id);
+
+ if (index != -1)
+ {
+ if(id == XAF_MEM_ID_DEV)
+ {
+ size=g_mem_obj.mem_dev[index].size;
+ g_mem_obj.mem_dev[index].size = 0;
+ g_mem_obj.num_malloc_dev--;
+ free(heap_ptr);
+ g_mem_obj.mem_dev[index].heap_ptr = NULL;
+ }
+ else if(id == XAF_MEM_ID_COMP)
+ {
+ size=g_mem_obj.mem_comp[index].size;
+ g_mem_obj.mem_comp[index].size = 0;
+ g_mem_obj.num_malloc_comp--;
+ free(heap_ptr);
+ g_mem_obj.mem_comp[index].heap_ptr = NULL;
+ }
+ }
+ return;
+}
+
+int mem_get_alloc_size(mem_obj_t* pmem_handle, int id)
+{
+ int mem_size = 0;
+ if(id == XAF_MEM_ID_DEV)
+ mem_size = pmem_handle->persi_mem_dev;
+ else if(id == XAF_MEM_ID_COMP)
+ mem_size = pmem_handle->persi_mem_comp;
+ return mem_size;
+}
+
+void* mem_init()
+{
+ void* ptr;
+ ptr = &g_mem_obj;
+ return ptr;
+}
+
+void mem_exit()
+{
+ if((g_mem_obj.num_malloc_dev != 0)||(g_mem_obj.num_malloc_comp != 0))
+ {
+ fprintf(stdout,"Memory leaks\n");
+ }
+ return;
+}
diff --git a/hifi/xaf/host-apf/utest/xaf-utils-test.c b/hifi/xaf/host-apf/utest/xaf-utils-test.c
new file mode 100644
index 00000000..79c6710d
--- /dev/null
+++ b/hifi/xaf/host-apf/utest/xaf-utils-test.c
@@ -0,0 +1,69 @@
+/*******************************************************************************
+* Copyright (C) 2018 Cadence Design Systems, Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining
+* a copy of this software and associated documentation files (the
+* "Software"), to use this Software with Cadence processor cores only and
+* not with any other processors and platforms, 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.
+
+******************************************************************************/
+#include <stdio.h>
+#include <string.h>
+
+#include "xaf-utils-test.h"
+
+int audio_frmwk_buf_size;
+int audio_comp_buf_size;
+
+int print_banner(char *app_name)
+{
+ /*
+ XAF_CHK_PTR(ver_info[0], "print_verinfo");
+ XAF_CHK_PTR(ver_info[1], "print_verinfo");
+ XAF_CHK_PTR(ver_info[2], "print_verinfo");
+ */
+
+ fprintf(stdout, "******************************************************************************\n");
+ fprintf(stdout, "Cadence Audio Framework (Hosted) : %s \n",app_name);
+ fprintf(stdout, "Copyright (c) 2018 Cadence Design Systems, Inc.\n");
+ /*fprintf(stdout, "Lib Name : %s\n", ver_info[0]);
+ fprintf(stdout, "Lib Version : %s\n", ver_info[1]);
+ fprintf(stdout, "API Version : %s\n", ver_info[2]);*/
+ fprintf(stdout, "******************************************************************************\n");
+
+ return 0;
+}
+
+int print_mem_mcps_info(mem_obj_t* mem_handle, int num_comp)
+{
+ int tot_dev_mem_size, tot_comp_mem_size, tot_size;
+
+ /* ...unused arg */
+ (void) num_comp;
+
+ /* ...printing memory info*/
+
+ tot_dev_mem_size = mem_get_alloc_size(mem_handle, XAF_MEM_ID_DEV);
+ tot_comp_mem_size = mem_get_alloc_size(mem_handle, XAF_MEM_ID_COMP);
+ tot_size = tot_dev_mem_size + tot_comp_mem_size;
+
+ fprintf(stdout,"Shared Memory between AP and DSP for IPC: %8d \n", XF_CFG_REMOTE_IPC_POOL_SIZE);
+ fprintf(stdout,"Memory allocated on AP for Device : %8d \n", tot_dev_mem_size);
+ fprintf(stdout,"Memory allocated on AP for Components : %8d \n", tot_comp_mem_size);
+ fprintf(stdout,"Memory allocated on DSP for Components : %8d \n", XF_CFG_LOCAL_POOL_SIZE);
+
+ return 0;
+}
+
diff --git a/hifi/xaf/release.txt b/hifi/xaf/release.txt
new file mode 100755
index 00000000..cebd1e24
--- /dev/null
+++ b/hifi/xaf/release.txt
@@ -0,0 +1,24 @@
+======================================================================
+Xtensa Audio Framework (XAF) - Hosted solution
+======================================================================
+
+======================================================================
+Revision History
+======================================================================
+
+Version 0.7_Alpha API 1.1 : April 17, 2018
+
++ Alpha Release
++ Built with RG.5 tools
+
++ Added copyrights for makefiles and assembly files.
++ Added float-print (%f) support in DSP trace logs.
+
+----------------------------------------------------------------------
+
+Version 0.6_Alpha API 1.1 : February 15, 2018
+
++ Alpha Release
++ Built with RG.5 tools
+
+----------------------------------------------------------------------
diff --git a/hikey-common.mk b/hikey-common.mk
index 2212f6c4..1927fcf6 100644
--- a/hikey-common.mk
+++ b/hikey-common.mk
@@ -4,7 +4,7 @@ TARGET_KERNEL_USE=4.9
endif
ifndef TARGET_COMPRESSED_KERNEL
-TARGET_COMPRESSED_KERNEL=false
+TARGET_COMPRESSED_KERNEL=true
endif
ifeq ($(TARGET_COMPRESSED_KERNEL), false)
@@ -15,6 +15,8 @@ endif
TARGET_PREBUILT_DTB := device/linaro/hikey-kernel/hi6220-hikey.dtb-$(TARGET_KERNEL_USE)
+PRODUCT_ENFORCE_VINTF_MANIFEST_OVERRIDE := true
+
ifeq ($(TARGET_KERNEL_USE), 3.18)
TARGET_FSTAB := fstab.hikey-$(TARGET_KERNEL_USE)
HIKEY_USE_LEGACY_TI_BLUETOOTH := true
diff --git a/hikey.mk b/hikey.mk
index 0b32845c..14a2e928 100644
--- a/hikey.mk
+++ b/hikey.mk
@@ -1,6 +1,13 @@
$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
$(call inherit-product, device/linaro/hikey/hikey-common.mk)
+#setup dm-verity configs
+PRODUCT_SYSTEM_VERITY_PARTITION := /dev/block/platform/soc/f723d000.dwmmc0/by-name/system
+PRODUCT_VENDOR_VERITY_PARTITION := /dev/block/platform/soc/f723d000.dwmmc0/by-name/vendor
+$(call inherit-product, build/target/product/verity.mk)
+PRODUCT_SUPPORTS_BOOT_SIGNER := false
+PRODUCT_SUPPORTS_VERITY_FEC := false
+
PRODUCT_NAME := hikey
PRODUCT_DEVICE := hikey
PRODUCT_BRAND := Android
diff --git a/hikey/BoardConfig.mk b/hikey/BoardConfig.mk
index 26389c10..c76ad35a 100644
--- a/hikey/BoardConfig.mk
+++ b/hikey/BoardConfig.mk
@@ -7,11 +7,14 @@ TARGET_CPU_VARIANT := cortex-a53
TARGET_2ND_CPU_VARIANT := cortex-a53
ifeq ($(TARGET_KERNEL_USE), 3.18)
-BOARD_KERNEL_CMDLINE := console=ttyAMA3,115200 androidboot.console=ttyAMA3 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime
+BOARD_KERNEL_CMDLINE := console=ttyAMA3,115200 androidboot.console=ttyAMA3 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime
else
-BOARD_KERNEL_CMDLINE := console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime
+BOARD_KERNEL_CMDLINE := console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime
endif
+#Enable dtb fstab for treble
+BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab
+
ifneq ($(TARGET_SENSOR_MEZZANINE),)
BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_$(TARGET_SENSOR_MEZZANINE)
endif
@@ -34,3 +37,10 @@ endif
endif
BOARD_CACHEIMAGE_PARTITION_SIZE := 268435456
BOARD_FLASH_BLOCK_SIZE := 131072
+
+# Vendor partition definitions
+TARGET_COPY_OUT_VENDOR := vendor
+BOARD_VENDORIMAGE_PARTITION_SIZE := 268435456 # 256MB
+BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_VENDORIMAGE_JOURNAL_SIZE := 0
+BOARD_VENDORIMAGE_EXTFS_INODE_COUNT := 2048
diff --git a/hikey/README b/hikey/README
index 9652e20a..25c1df3f 100644
--- a/hikey/README
+++ b/hikey/README
@@ -4,11 +4,6 @@ Running Android on hikey board:
Pull AOSP source:
$ repo init -u https://android.googlesource.com/platform/manifest -b master & repo sync -j24
-Download and extract HDMI binaries:
-$ wget https://dl.google.com/dl/android/aosp/linaro-hikey-20170523-4b9ebaff.tgz
-$ tar xzf linaro-hikey-20170523-4b9ebaff.tgz
-$ ./extract-linaro-hikey.sh
-
Install mcopy utility:
$ apt-get install mtools
@@ -32,6 +27,7 @@ Remove link 3-4 and power the board
Enter fastboot mode by linking J15 1-2 and 5-6 pins
$ fastboot flash boot out/target/product/hikey/boot.img
$ fastboot flash system out/target/product/hikey/system.img
+$ fastboot flash vendor out/target/product/hikey/vendor.img
$ fastboot flash cache out/target/product/hikey/cache.img
$ fastboot flash userdata out/target/product/hikey/userdata.img
Remove jumper 5-6 and power the board
@@ -47,10 +43,8 @@ Output: arch/arm64/boot/Image & arch/arm64/boot/dts/hisilicon/hi6220-hikey.dtb
Image-dtb-4.9 and hi6220-hikey.dtb-4.9
* Setting monitor resolution
-Add to BOARD_KERNEL_CMDLINE in BoardConfig.mk or
-if you are setting TARGET_BOOTIMAGE_USE_FAT=true edit
-device/linaro/hikey/bootloader/EFI/BOOT/grub.cfg
-Set video= (for example for 24” monitor): video=HDMI-A-1:1280x800@60
+Add to BOARD_KERNEL_CMDLINE in BoardConfig.mk:
+ video= (for example for 24” monitor): video=HDMI-A-1:1280x800@60
* Kernel serial output (uart3):
J2 (LS Expansion): 1 - Gnd, 11 - Rx, 13 - Tx
@@ -58,4 +52,4 @@ J2 (LS Expansion): 1 - Gnd, 11 - Rx, 13 - Tx
External links:
Board: https://www.96boards.org/products/ce/hikey/
Howto: https://github.com/96boards/documentation/wiki/LatestSnapshots
-Schematics: https://www.96boards.org/wp-content/uploads/2015/02/96Boards-Hikey-Rev-A1.pdf
+Schematics: https://github.com/96boards/documentation/blob/master/consumer/hikey/hardware-docs/HiKey_schematics_LeMaker_version_Rev_A1.pdf
diff --git a/hikey/device-hikey.mk b/hikey/device-hikey.mk
index fe6b6b6b..f04561d0 100644
--- a/hikey/device-hikey.mk
+++ b/hikey/device-hikey.mk
@@ -16,12 +16,21 @@
PRODUCT_COPY_FILES += $(TARGET_PREBUILT_KERNEL):kernel \
$(TARGET_PREBUILT_DTB):hi6220-hikey.dtb \
- $(LOCAL_PATH)/$(TARGET_FSTAB):root/fstab.hikey \
- device/linaro/hikey/init.common.rc:root/init.hikey.rc \
- device/linaro/hikey/init.hikey.power.rc:root/init.hikey.power.rc \
- device/linaro/hikey/init.common.usb.rc:root/init.hikey.usb.rc \
- device/linaro/hikey/ueventd.common.rc:root/ueventd.hikey.rc \
- device/linaro/hikey/common.kl:system/usr/keylayout/hikey.kl
+ $(LOCAL_PATH)/$(TARGET_FSTAB):$(TARGET_COPY_OUT_VENDOR)/etc/fstab.hikey \
+ device/linaro/hikey/init.common.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey.rc \
+ device/linaro/hikey/init.hikey.power.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey.power.rc \
+ device/linaro/hikey/init.common.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey.usb.rc \
+ device/linaro/hikey/ueventd.common.rc:$(TARGET_COPY_OUT_VENDOR)/ueventd.rc \
+ device/linaro/hikey/common.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/hikey.kl
+
+# Copy BT firmware
+PRODUCT_COPY_FILES += \
+ device/linaro/hikey/bt-wifi-firmware-util/TIInit_11.8.32.bts:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/TIInit_11.8.32.bts
+
+# Copy wlan firmware
+PRODUCT_COPY_FILES += \
+ device/linaro/hikey/bt-wifi-firmware-util/wl18xx-fw-4.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/wl18xx-fw-4.bin \
+ device/linaro/hikey/bt-wifi-firmware-util/wl18xx-conf.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/wl18xx-conf.bin
# Build HiKey HDMI audio HAL
PRODUCT_PACKAGES += audio.primary.hikey
@@ -41,5 +50,5 @@ PRODUCT_PACKAGES += power.hikey
# Sensors HAL
PRODUCT_PACKAGES += sensors.hikey
-# Include vendor binaries
-$(call inherit-product-if-exists, vendor/linaro/hikey/device-vendor.mk)
+# Include mali blobs from ARM
+PRODUCT_PACKAGES += libGLES_mali.so END_USER_LICENCE_AGREEMENT.txt
diff --git a/hikey/fstab.hikey b/hikey/fstab.hikey
index def00f6d..a1ccdac1 100644
--- a/hikey/fstab.hikey
+++ b/hikey/fstab.hikey
@@ -3,10 +3,8 @@
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
-/dev/block/platform/soc/f723d000.dwmmc0/by-name/system /system ext4 ro wait
-/dev/block/platform/soc/f723d000.dwmmc0/by-name/system /system squashfs ro wait
-/dev/block/platform/soc/f723d000.dwmmc0/by-name/cache /cache ext4 discard,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait
+/dev/block/platform/soc/f723d000.dwmmc0/by-name/cache /cache ext4 discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait
/dev/block/platform/soc/f723d000.dwmmc0/by-name/userdata /data f2fs discard,noatime,nosuid,nodev wait,check,fileencryption=software,quota
-/dev/block/platform/soc/f723d000.dwmmc0/by-name/userdata /data ext4 discard,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait
+/dev/block/platform/soc/f723d000.dwmmc0/by-name/userdata /data ext4 discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait,formattable
/devices/platform/soc/f723e000.dwmmc1/mmc_host/mmc* auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata
/devices/platform/soc/f72c0000.usb/usb* auto auto defaults voldmanaged=usbdisk:auto,encryptable=userdata
diff --git a/hikey/fstab.hikey-3.18 b/hikey/fstab.hikey-3.18
index b652d752..05f427f4 100644
--- a/hikey/fstab.hikey-3.18
+++ b/hikey/fstab.hikey-3.18
@@ -3,10 +3,11 @@
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
-/dev/block/platform/f723d000.dwmmc0/by-name/system /system ext4 ro wait
-/dev/block/platform/f723d000.dwmmc0/by-name/system /system squashfs ro wait
-/dev/block/platform/f723d000.dwmmc0/by-name/cache /cache ext4 discard,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait
+#/dev/block/platform/f723d000.dwmmc0/by-name/system /system ext4 ro wait
+#/dev/block/platform/f723d000.dwmmc0/by-name/system /system squashfs ro wait
+#/dev/block/platform/f723d000.dwmmc0/by-name/vendor /vendor ext4 ro wait
+/dev/block/platform/f723d000.dwmmc0/by-name/cache /cache ext4 discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait
/dev/block/platform/f723d000.dwmmc0/by-name/userdata /data f2fs discard,noatime,nosuid,nodev wait,check,fileencryption=software,quota
-/dev/block/platform/f723d000.dwmmc0/by-name/userdata /data ext4 discard,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait
+/dev/block/platform/f723d000.dwmmc0/by-name/userdata /data ext4 discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait,formattable
/devices/platform/f723e000.dwmmc1/mmc_host/mmc* auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata
/devices/platform/f72c0000.usb/usb* auto auto defaults voldmanaged=usbdisk:auto,encryptable=userdata
diff --git a/hikey960.mk b/hikey960.mk
index 06124476..1b9799b9 100644
--- a/hikey960.mk
+++ b/hikey960.mk
@@ -1,7 +1,7 @@
ifndef TARGET_KERNEL_USE
TARGET_KERNEL_USE=4.9
endif
-TARGET_PREBUILT_KERNEL := device/linaro/hikey-kernel/Image.gz-hikey960-$(TARGET_KERNEL_USE)
+TARGET_PREBUILT_KERNEL := device/linaro/hikey-kernel/Image.gz-dtb-hikey960-$(TARGET_KERNEL_USE)
TARGET_PREBUILT_DTB := device/linaro/hikey-kernel/hi3660-hikey960.dtb-$(TARGET_KERNEL_USE)
ifeq ($(TARGET_KERNEL_USE), 4.4)
diff --git a/hikey960/BoardConfig.mk b/hikey960/BoardConfig.mk
index 02531418..1ba08dbf 100644
--- a/hikey960/BoardConfig.mk
+++ b/hikey960/BoardConfig.mk
@@ -9,7 +9,11 @@ TARGET_2ND_CPU_VARIANT := cortex-a73
TARGET_NO_DTIMAGE := false
BOARD_KERNEL_CMDLINE := androidboot.hardware=hikey960 console=ttyFIQ0 androidboot.console=ttyFIQ0
-BOARD_KERNEL_CMDLINE += firmware_class.path=/system/etc/firmware loglevel=15
+BOARD_KERNEL_CMDLINE += firmware_class.path=/vendor/firmware loglevel=15 efi=noruntime
+
+#Enable dtb fstab for treble
+BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab
+
ifneq ($(TARGET_SENSOR_MEZZANINE),)
BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_$(TARGET_SENSOR_MEZZANINE)
endif
@@ -19,3 +23,10 @@ BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2768240640 # 2640MB
BOARD_USERDATAIMAGE_PARTITION_SIZE := 25769803776 # 24GB
BOARD_CACHEIMAGE_PARTITION_SIZE := 8388608 # 8MB
BOARD_FLASH_BLOCK_SIZE := 512
+
+# Vendor partition definitions
+TARGET_COPY_OUT_VENDOR := vendor
+BOARD_VENDORIMAGE_PARTITION_SIZE := 822083584 # 784MB
+BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_VENDORIMAGE_JOURNAL_SIZE := 0
+BOARD_VENDORIMAGE_EXTFS_INODE_COUNT := 2048
diff --git a/hikey960/README b/hikey960/README
index 8c6b199a..0418d46a 100644
--- a/hikey960/README
+++ b/hikey960/README
@@ -22,6 +22,7 @@ $ ./flash-all.sh
$ fastboot flash boot out/target/product/hikey960/boot.img
$ fastboot flash dts out/target/product/hikey960/dt.img
$ fastboot flash system out/target/product/hikey960/system.img
+$ fastboot flash vendor out/target/product/hikey960/vendor.img
$ fastboot flash cache out/target/product/hikey960/cache.img
$ fastboot flash userdata out/target/product/hikey960/userdata.img
Turn OFF switch 3 and power cycle the board.
diff --git a/hikey960/device-hikey960.mk b/hikey960/device-hikey960.mk
index 49ed2636..d59b3f3d 100644
--- a/hikey960/device-hikey960.mk
+++ b/hikey960/device-hikey960.mk
@@ -17,18 +17,27 @@
PRODUCT_COPY_FILES += $(TARGET_PREBUILT_KERNEL):kernel \
$(TARGET_PREBUILT_DTB):hi3660-hikey960.dtb
-PRODUCT_COPY_FILES += $(LOCAL_PATH)/fstab.hikey960:root/fstab.hikey960 \
- device/linaro/hikey/init.common.rc:root/init.hikey960.rc \
- device/linaro/hikey/init.hikey960.power.rc:root/init.hikey960.power.rc \
- device/linaro/hikey/init.common.usb.rc:root/init.hikey960.usb.rc \
- device/linaro/hikey/ueventd.common.rc:root/ueventd.hikey960.rc \
- device/linaro/hikey/common.kl:system/usr/keylayout/hikey960.kl \
- frameworks/native/data/etc/android.hardware.vulkan.level-0.xml:system/etc/permissions/android.hardware.vulkan.level.xml \
- frameworks/native/data/etc/android.hardware.vulkan.version-1_0_3.xml:system/etc/permissions/android.hardware.vulkan.version.xml
+PRODUCT_COPY_FILES += $(LOCAL_PATH)/fstab.hikey960:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.hikey960 \
+ device/linaro/hikey/init.common.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey960.rc \
+ device/linaro/hikey/init.hikey960.power.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey960.power.rc \
+ device/linaro/hikey/init.common.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey960.usb.rc \
+ device/linaro/hikey/ueventd.common.rc:$(TARGET_COPY_OUT_VENDOR)/ueventd.rc \
+ device/linaro/hikey/common.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/hikey960.kl \
+ frameworks/native/data/etc/android.hardware.vulkan.level-1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \
+ frameworks/native/data/etc/android.hardware.vulkan.version-1_0_3.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml
+
+# Copy BT firmware
+PRODUCT_COPY_FILES += \
+ device/linaro/hikey/bt-wifi-firmware-util/TIInit_11.8.32-pcm-960.bts:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/TIInit_11.8.32.bts
+
+# Copy wlan firmware
+PRODUCT_COPY_FILES += \
+ device/linaro/hikey/bt-wifi-firmware-util/wl18xx-fw-4.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/wl18xx-fw-4.bin \
+ device/linaro/hikey/bt-wifi-firmware-util/wl18xx-conf-wl1837mod.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/wl18xx-conf.bin
# Copy hifi firmware
PRODUCT_COPY_FILES += \
- device/linaro/hikey/hifi/firmware/hifi-hikey960.img:system/etc/firmware/hifi/hifi.img
+ device/linaro/hikey/hifi/firmware/hifi-hikey960.img:$(TARGET_COPY_OUT_VENDOR)/firmware/hifi/hifi.img
# Build HiKey960 HDMI audio HAL. Experimental only may not work. FIXME
@@ -36,9 +45,13 @@ PRODUCT_PACKAGES += audio.primary.hikey960
PRODUCT_PACKAGES += gralloc.hikey960
+#binary blobs from ARM
+PRODUCT_PACKAGES += libGLES_mali.so \
+ vulkan.hikey960.so \
+ END_USER_LICENCE_AGREEMENT.txt
+
PRODUCT_PACKAGES += power.hikey960
PRODUCT_PACKAGES += sensors.hikey960
-# Include vendor binaries
$(call inherit-product-if-exists, vendor/linaro/hikey960/device-vendor.mk)
diff --git a/hikey960/fstab.hikey960 b/hikey960/fstab.hikey960
index e456dac7..9f183905 100644
--- a/hikey960/fstab.hikey960
+++ b/hikey960/fstab.hikey960
@@ -4,11 +4,11 @@
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#/dev/block/platform/soc/ff3b0000.ufs/by-name/system_a /system ext4 ro wait
-/dev/block/sdd10 /system ext4 ro wait
#/dev/block/platform/soc/ff3b0000.ufs/by-name/cache /cache ext4 discard,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait
-/dev/block/sdd5 /cache ext4 discard,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait
+/dev/block/sdd5 /cache ext4 discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait
#/dev/block/platform/soc/ff3b0000.ufs/by-name/userdata /data ext4 discard,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait
/dev/block/sdd13 /data f2fs discard,noatime,nosuid,nodev wait,check,fileencryption=software,quota
-/dev/block/sdd13 /data ext4 discard,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait
+/dev/block/sdd13 /data ext4 discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1 wait,formattable
/devices/platform/soc/ff37f000.dwmmc1/mmc_host/mmc* auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata
/devices/platform/soc/ff200000.hisi_usb/ff100000.dwc3/xhci-hcd.*.auto/usb* auto auto defaults voldmanaged=usbdisk:auto,encryptable=userdata
+/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/nvme/nvme* auto auto defaults voldmanaged=nvmedisk:auto,encryptable=userdata
diff --git a/init.common.rc b/init.common.rc
index 00852152..770ee0fb 100644
--- a/init.common.rc
+++ b/init.common.rc
@@ -27,7 +27,7 @@ on init
start watchdogd
on fs
- mount_all /fstab.${ro.hardware}
+ mount_all /vendor/etc/fstab.${ro.hardware}
setprop ro.crypto.fuse_sdcard false
on post-fs
@@ -120,3 +120,9 @@ service watchdogd /sbin/watchdogd 10 20
class core
oneshot
seclabel u:r:watchdogd:s0
+
+service bugreport /system/bin/dumpstate -d -p -B -z \
+ -o /data/user_de/0/com.android.shell/files/bugreports/bugreport
+ class main
+ disabled
+ oneshot
diff --git a/init.hikey960.power.rc b/init.hikey960.power.rc
index 429a174e..8386b76b 100644
--- a/init.hikey960.power.rc
+++ b/init.hikey960.power.rc
@@ -16,8 +16,6 @@ on post-fs
chown system system /dev/stune/foreground/schedtune.boost
chown system system /dev/stune/foreground/schedtune.prefer_idle
chown system system /dev/stune/schedtune.boost
- chown system system /sys/class/devfreq/ddr_devfreq/min_freq
- chown system system /sys/class/devfreq/e82c0000.mali/min_freq
write /dev/stune/top-app/schedtune.boost 20
write /dev/stune/top-app/schedtune.prefer_idle 1
diff --git a/installer/hikey/flash-all.sh b/installer/hikey/flash-all.sh
index 87465a42..be909fe6 100755
--- a/installer/hikey/flash-all.sh
+++ b/installer/hikey/flash-all.sh
@@ -71,10 +71,12 @@ else
fastboot oem serialno
fi
fi
+fastboot getvar partition-size:ptable
fastboot flash ptable "${INSTALLER_DIR}"/"${PTABLE}"
fastboot flash fastboot "${FIRMWARE_DIR}"/fip.bin
fastboot flash nvme "${INSTALLER_DIR}"/nvme.img
fastboot flash boot "${OUT_IMGDIR}"/boot.img
fastboot flash system "${OUT_IMGDIR}"/system.img
+fastboot flash vendor "${OUT_IMGDIR}"/vendor.img
fastboot flash cache "${OUT_IMGDIR}"/cache.img
fastboot flash userdata "${OUT_IMGDIR}"/userdata.img
diff --git a/installer/hikey/ptable-aosp-4g.img b/installer/hikey/ptable-aosp-4g.img
index cb7904db..43bf8a94 100644
--- a/installer/hikey/ptable-aosp-4g.img
+++ b/installer/hikey/ptable-aosp-4g.img
Binary files differ
diff --git a/installer/hikey/ptable-aosp-8g.img b/installer/hikey/ptable-aosp-8g.img
index 72817829..631fd8a9 100644
--- a/installer/hikey/ptable-aosp-8g.img
+++ b/installer/hikey/ptable-aosp-8g.img
Binary files differ
diff --git a/installer/hikey960/README b/installer/hikey960/README
index 6ef3074c..22dea180 100644
--- a/installer/hikey960/README
+++ b/installer/hikey960/README
@@ -29,6 +29,18 @@ $ ./flash-all.sh
After that completes, power the board off, and set the switches back
to normal mode and boot the device.
+Known Issues:
+-------------
+When flashing ontop of the HiSi bootloader, you may see the following
+failure:
+ sending 'xloader' (151 KB)...
+ OKAY [ 0.006s]
+ writing 'xloader'...
+ FAILED (remote: flash write back vrl failure)
+
+This is a transient error and can be ignored.
+
+
Trouble shooting:
-----------------
If you have any trouble booting the device after running ./flash-all.sh
diff --git a/installer/hikey960/fip.bin b/installer/hikey960/fip.bin
new file mode 100644
index 00000000..6e72bb22
--- /dev/null
+++ b/installer/hikey960/fip.bin
Binary files differ
diff --git a/installer/hikey960/flash-all.sh b/installer/hikey960/flash-all.sh
index 62256b8a..70a95508 100755
--- a/installer/hikey960/flash-all.sh
+++ b/installer/hikey960/flash-all.sh
@@ -19,12 +19,13 @@ fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img
fastboot flash ptable "${INSTALLER_DIR}"/hisi-ptable.img
fastboot flash fastboot "${INSTALLER_DIR}"/hisi-fastboot.img
fastboot reboot-bootloader
-fastboot flash nvme "${INSTALLER_DIR}"/nvme.img
-fastboot flash fw_lpm3 "${INSTALLER_DIR}"/lpm3.img
-fastboot flash trustfirmware "${INSTALLER_DIR}"/bl31.bin
+fastboot flash nvme "${INSTALLER_DIR}"/hisi-nvme.img
+fastboot flash fw_lpm3 "${INSTALLER_DIR}"/hisi-lpm3.img
+fastboot flash trustfirmware "${INSTALLER_DIR}"/hisi-bl31.bin
fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img
fastboot flash dts "${ANDROID_PRODUCT_OUT}"/dt.img
fastboot flash system "${ANDROID_PRODUCT_OUT}"/system.img
+fastboot flash vendor "${ANDROID_PRODUCT_OUT}"/vendor.img
fastboot flash cache "${ANDROID_PRODUCT_OUT}"/cache.img
fastboot flash userdata "${ANDROID_PRODUCT_OUT}"/userdata.img
fastboot reboot
diff --git a/installer/hikey960/bl31.bin b/installer/hikey960/hisi-bl31.bin
index abebea6d..abebea6d 100644
--- a/installer/hikey960/bl31.bin
+++ b/installer/hikey960/hisi-bl31.bin
Binary files differ
diff --git a/installer/hikey960/lpm3.img b/installer/hikey960/hisi-lpm3.img
index bd0243bf..bd0243bf 100644
--- a/installer/hikey960/lpm3.img
+++ b/installer/hikey960/hisi-lpm3.img
Binary files differ
diff --git a/installer/hikey960/nvme.img b/installer/hikey960/hisi-nvme.img
index ca5bc7c1..ca5bc7c1 100644
--- a/installer/hikey960/nvme.img
+++ b/installer/hikey960/hisi-nvme.img
Binary files differ
diff --git a/installer/hikey960/hisi-sec_xloader.img b/installer/hikey960/hisi-sec_xloader.img
index 359de549..47c353b8 100644
--- a/installer/hikey960/hisi-sec_xloader.img
+++ b/installer/hikey960/hisi-sec_xloader.img
Binary files differ
diff --git a/installer/hikey960/l-loader.bin b/installer/hikey960/l-loader.bin
new file mode 100644
index 00000000..b4a1d480
--- /dev/null
+++ b/installer/hikey960/l-loader.bin
Binary files differ
diff --git a/installer/hikey960/prm_ptable.img b/installer/hikey960/prm_ptable.img
new file mode 100644
index 00000000..c81ffcfa
--- /dev/null
+++ b/installer/hikey960/prm_ptable.img
Binary files differ
diff --git a/installer/hikey960/uefi-flash-all.sh b/installer/hikey960/uefi-flash-all.sh
new file mode 100755
index 00000000..fe42486c
--- /dev/null
+++ b/installer/hikey960/uefi-flash-all.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+INSTALLER_DIR="`dirname ${0}`"
+ECHO_PREFIX="=== "
+
+# for cases that don't run "lunch hikey960-userdebug"
+if [ -z "${ANDROID_BUILD_TOP}" ]; then
+ ANDROID_BUILD_TOP=${INSTALLER_DIR}/../../../../../
+ ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/hikey960"
+fi
+
+if [ ! -d "${ANDROID_PRODUCT_OUT}" ]; then
+ echo ${ECHO_PREFIX}"error in locating out directory, check if it exist"
+ exit
+fi
+
+echo ${ECHO_PREFIX}"android out dir:${ANDROID_PRODUCT_OUT}"
+
+function check_partition_table_version () {
+ fastboot erase reserved
+ if [ $? -eq 0 ]
+ then
+ IS_PTABLE_1MB_ALIGNED=true
+ else
+ IS_PTABLE_1MB_ALIGNED=false
+ fi
+}
+
+function flashing_atf_uefi () {
+ fastboot flash ptable "${INSTALLER_DIR}"/prm_ptable.img
+ fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img
+ fastboot reboot-bootloader
+
+ fastboot flash fastboot "${INSTALLER_DIR}"/l-loader.bin
+ fastboot flash fip "${INSTALLER_DIR}"/fip.bin
+ fastboot flash nvme "${INSTALLER_DIR}"/hisi-nvme.img
+ fastboot flash fw_lpm3 "${INSTALLER_DIR}"/hisi-lpm3.img
+ fastboot flash trustfirmware "${INSTALLER_DIR}"/hisi-bl31.bin
+ fastboot reboot-bootloader
+
+ fastboot flash ptable "${INSTALLER_DIR}"/prm_ptable.img
+ fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img
+ fastboot flash fastboot "${INSTALLER_DIR}"/l-loader.bin
+ fastboot flash fip "${INSTALLER_DIR}"/fip.bin
+
+ fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img
+ fastboot flash system "${ANDROID_PRODUCT_OUT}"/system.img
+ fastboot flash vendor "${ANDROID_PRODUCT_OUT}"/vendor.img
+ fastboot flash cache "${ANDROID_PRODUCT_OUT}"/cache.img
+ fastboot flash userdata "${ANDROID_PRODUCT_OUT}"/userdata.img
+}
+
+function upgrading_ptable_1mb_aligned () {
+ fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img
+ fastboot flash ptable "${INSTALLER_DIR}"/hisi-ptable.img
+ fastboot flash fastboot "${INSTALLER_DIR}"/hisi-fastboot.img
+ fastboot reboot-bootloader
+}
+
+echo ${ECHO_PREFIX}"Checking partition table version..."
+check_partition_table_version
+
+if [ "${IS_PTABLE_1MB_ALIGNED}" == "true" ]
+then
+ echo ${ECHO_PREFIX}"Partition table is 1MB aligned. Flashing ATF/UEFI..."
+ flashing_atf_uefi
+else
+ echo ${ECHO_PREFIX}"Partition table is 512KB aligned."
+ echo ${ECHO_PREFIX}"Upgrading to 1MB aligned version..."
+ upgrading_ptable_1mb_aligned
+ echo ${ECHO_PREFIX}"Flasing ATF/UEFI..."
+ flashing_atf_uefi
+ echo ${ECHO_PREFIX}"Done"
+fi
+
+fastboot reboot
diff --git a/l-loader/generate_ptable.sh b/l-loader/generate_ptable.sh
index 432873db..f8a6a207 100755
--- a/l-loader/generate_ptable.sh
+++ b/l-loader/generate_ptable.sh
@@ -61,8 +61,8 @@ case ${PTABLE} in
fakeroot ${SGDISK} -n 5:0:+2M -t 5:0700 -u 5:00354BCD-BBCB-4CB3-B5AE-CDEFCB5DAC43 -c 5:"nvme" ${TEMP_FILE}
#[6: boot: 14M-78M]
fakeroot ${SGDISK} -n 6:0:+64M -t 6:EF00 -u 6:5C0F213C-17E1-4149-88C8-8B50FB4EC70E -c 6:"boot" ${TEMP_FILE}
- #[7: reserved: 78M-334M]
- fakeroot ${SGDISK} -n 7:0:+256M -t 7:0700 -u 7:BED8EBDC-298E-4A7A-B1F1-2500D98453B7 -c 7:"reserved" ${TEMP_FILE}
+ #[7: vendor: 78M-334M]
+ fakeroot ${SGDISK} -n 7:0:+256M -t 7:0700 -u 7:BED8EBDC-298E-4A7A-B1F1-2500D98453B7 -c 7:"vendor" ${TEMP_FILE}
#[8: cache: 334M-590M]
fakeroot ${SGDISK} -n 8:0:+256M -t 8:8301 -u 8:A092C620-D178-4CA7-B540-C4E26BD6D2E2 -c 8:"cache" ${TEMP_FILE}
#[9: system: 590M-2126M]
diff --git a/libmemtrack/Android.mk b/libmemtrack/Android.mk
index 0ca76cff..629a5d6e 100644
--- a/libmemtrack/Android.mk
+++ b/libmemtrack/Android.mk
@@ -23,7 +23,7 @@ LOCAL_PROPRIETARY_MODULE := true
LOCAL_C_INCLUDES += hardware/libhardware/include
LOCAL_CFLAGS := -Wconversion -Wall -Werror -Wno-sign-conversion
LOCAL_CLANG := true
-LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_SHARED_LIBRARIES := liblog libhardware
LOCAL_SRC_FILES := memtrack_hikey.c
LOCAL_MODULE := memtrack.default
#LOCAL_MODULE := memtrack.$(TARGET_BOARD_PLATFORM)
diff --git a/mali/Android.mk b/mali/Android.mk
new file mode 100644
index 00000000..40604835
--- /dev/null
+++ b/mali/Android.mk
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 2015 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.
+#
+
+# WARNING: Everything listed here will be built on ALL platforms,
+# including x86, the emulator, and the SDK. Modules must be uniquely
+# named (liblights.panda), and must build everywhere, or limit themselves
+# to only building on ARM if they include assembly. Individual makefiles
+# are responsible for having their own logic, for fine-grained control.
+
+ifneq ($(filter hikey%, $(TARGET_DEVICE)),)
+
+LOCAL_PATH := $(call my-dir)
+
+# if some modules are built directly from this directory (not subdirectories),
+# their rules should be written here.
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
+endif
diff --git a/mali/bifrost/Android.mk b/mali/bifrost/Android.mk
new file mode 100644
index 00000000..9fccbe86
--- /dev/null
+++ b/mali/bifrost/Android.mk
@@ -0,0 +1,37 @@
+ifneq ($(filter hikey960, $(TARGET_DEVICE)),)
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := END_USER_LICENCE_AGREEMENT.txt
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_STRIP_MODULE := false
+LOCAL_SRC_FILES_arm := $(LOCAL_MODULE)
+LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)
+LOCAL_MULTILIB := 32
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libGLES_mali.so
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_STRIP_MODULE := false
+LOCAL_SRC_FILES_arm := lib/egl/$(LOCAL_MODULE)
+LOCAL_SRC_FILES_arm64 := lib64/egl/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/egl/
+LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/egl/
+LOCAL_MULTILIB := both
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := vulkan.hikey960.so
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_STRIP_MODULE := false
+LOCAL_SRC_FILES_arm := lib/hw/$(LOCAL_MODULE)
+LOCAL_SRC_FILES_arm64 := lib64/hw/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/hw
+LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/hw
+LOCAL_MULTILIB := both
+include $(BUILD_PREBUILT)
+
+endif
+
+
diff --git a/mali/bifrost/END_USER_LICENCE_AGREEMENT.txt b/mali/bifrost/END_USER_LICENCE_AGREEMENT.txt
new file mode 100644
index 00000000..34da5f85
--- /dev/null
+++ b/mali/bifrost/END_USER_LICENCE_AGREEMENT.txt
@@ -0,0 +1,194 @@
+LES-PRE-20769
+SP-Version: 1.0
+25 November 2015
+
+END USER LICENCE AGREEMENT FOR THE MALI USERSPACE DRIVER ("Mali DRIVER")
+
+THIS END USER LICENCE AGREEMENT ("LICENCE") IS A LEGAL AGREEMENT
+BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND
+ARM LIMITED ("ARM") FOR THE USE OF THE SOFTWARE ACCOMPANYING THIS
+LICENCE. ARM IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON
+CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS LICENCE. BY
+INSTALLING OR OTHERWISE USING OR COPYING THE SOFTWARE YOU INDICATE
+THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS OF THIS LICENCE. IF YOU
+DO NOT AGREE TO THE TERMS OF THIS LICENCE, ARM IS UNWILLING TO LICENSE
+THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL, USE OR COPY THE SOFTWARE,
+AND YOU SHOULD PROMPTLY RETURN THE SOFTWARE TO YOUR SUPPLIER.
+
+"Applications" means applications for use solely in conjunction with
+Mali-based products manufactured under licence from ARM.
+
+"Output" means data resulting from your use of the Software and all
+direct and indirect derivatives thereof.
+
+"Software" means any software, firmware and data accompanying this
+Licence, any printed, electronic or online documentation supplied with
+it under the terms of this Licence for the Mali Driver.
+
+1. LICENCE GRANTS TO YOU.
+
+1.1 ARM hereby grants to you, subject to the terms and conditions of
+this Licence, a non-exclusive, non-transferable, revocable, worldwide
+licence to:
+
+(i) use and copy the Software or certain components or optional
+ functionality in the Software, as applicable, solely for the
+ purposes of running, designing or developing Applications; and
+
+(ii) subject to Clause 1.2, distribute the whole of the Software;
+ and/or (b) the whole or any part of the Software together
+ with, or as incorporated into, Applications; and
+
+1.2 If you choose to redistribute the whole or any part of the
+Software pursuant to the licences granted in Clause 1.1(ii), you
+agree: (i) not to use ARM's or any of its licensors names, logos or
+trademarks to market Applications; (ii) to retain any and all
+copyright notices and other notices (whether ARM's or its licensor's)
+which are included with the Software; and (iii) include a copy of this
+Licence with such redistribution.
+
+2. RESTRICTIONS ON USE OF THE SOFTWARE.
+
+BENCHMARKING: This Licence does not prevent you from using the
+Software for benchmarking purposes. However, you shall ensure that any
+and all benchmarking data relating to the Software, and any other
+results of your use or testing of the Software which are indicative of
+its performance, efficacy, reliability or quality, shall not be used
+to disparage ARM, its products or services, or in a manner that, in
+ARM's reasonable judgment, may diminish or otherwise damage the
+reputation of ARM.
+
+COPYRIGHT AND RESERVATION OF RIGHTS: The Software is owned by ARM or
+its licensors and is protected by copyright and other intellectual
+property laws and international treaties. The Software is licensed not
+sold. You acquire no rights to the Software other than as expressly
+provided by this Licence. You shall not remove from the Software any
+copyright notice or other notice and shall ensure that any such notice
+is reproduced in any copies of the whole or any part of the Software
+made by you or other permitted users.
+
+REVERSE ENGINEERING: Except to the extent that such activity is
+permitted by applicable law you shall not reverse engineer, decompile
+or disassemble any of the Software. If the Software was provided to
+you in Europe you shall not reverse engineer, decompile or disassemble
+any of the Software for the purposes of error correction.
+
+RESTRICTED USE: You agree that you shall not use the Software or the
+Output other than pursuant to and in accordance with the exercise of
+any of the licences granted under this Licence. Without limiting the
+generality of the foregoing, you shall not use the Software or any
+Output: (a) for determining if any features, functions or processes
+provided by the Software are covered by any patents or patent
+applications owned by you or a third party; or (b) for developing
+technology, applications or products which avoid any of ARM's
+intellectual property in the Software licensed hereunder; or (c) as a
+reference for modifying existing patents or patent applications or
+creating any continuation, continuation in part, or extension of
+existing patents or patent applications.
+
+3. SUPPORT.
+
+ARM is not under an obligation to provide support, but it may do so at
+its own discretion, and if it does, it will only be in respect of the
+Software as delivered.
+
+4. NO WARRANTIES.
+
+YOU AGREE THAT THE SOFTWARE IS LICENSED "AS IS", AND THAT ARM
+EXPRESSLY DISCLAIMS ALL REPRESENTATIONS, WARRANTIES, CONDITIONS OR
+OTHER TERMS, EXPRESS OR IMPLIED OR STATUTORY, INCLUDING WITHOUT
+LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, SATISFACTORY
+QUALITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+
+YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION
+OF APPLICATIONS, INCLUDING WITHOUT LIMITATION, APPLICATIONS DESIGNED
+OR INTENDED FOR MISSION CRITICAL APPLICATIONS, SUCH AS PACEMAKERS,
+WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL SYSTEMS, ETC. SHOULD
+THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL
+NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+5. LIMITATION OF LIABILITY.
+
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
+ARM BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
+DAMAGES (INCLUDING LOSS OF PROFITS) ARISING OUT OF THE USE OR
+INABILITY TO USE THE SOFTWARE WHETHER BASED ON A CLAIM UNDER CONTRACT,
+TORT OR OTHER LEGAL THEORY, EVEN IF ARM WAS ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGES.
+
+ARM does not seek to limit or exclude liability for death or personal
+injury arising from ARM's negligence or ARM's fraud and because some
+jurisdictions do not permit the exclusion or limitation of liability
+for consequential or incidental damages the above limitation relating
+to liability for consequential damages may not apply to you.
+
+NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS LICENCE,
+THE MAXIMUM LIABILITY OF ARM TO YOU IN AGGREGATE FOR ALL CLAIMS MADE
+AGAINST ARM IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH
+THE SUBJECT MATTER OF THIS LICENCE SHALL NOT EXCEED THE GREATER OF:
+(I) THE TOTAL OF SUMS PAID BY YOU TO ARM (IF ANY) FOR THIS LICENCE;
+AND (II) $10.00 USD. THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT
+ENLARGE OR EXTEND THE LIMIT.
+
+6. U.S. GOVERNMENT END USERS.
+
+US Government Restrictions: Use, duplication, reproduction, release,
+modification, disclosure or transfer of the Software is restricted in
+accordance with the terms of this Licence.
+
+7. TERM AND TERMINATION.
+
+This Licence shall remain in force until terminated by you or by ARM.
+Without prejudice to any of its other rights if you are in breach of
+any of the terms and conditions of this Licence then ARM may terminate
+this Licence immediately upon giving written notice to you or on
+thirty (30) days written notice without cause. You may terminate this
+Licence at any time. Upon termination of this Licence by you or by ARM
+, you shall stop using the Software and destroy all copies of the
+Software in your possession, together with all documentation and
+related materials. The provisions of clauses 2, 3, 4, 5, 6, 7, and 8
+shall survive termination of this Licence.
+
+8. GENERAL.
+
+This Licence is governed by English Law. Except where ARM agrees
+otherwise in: (i) a written contract signed by you and ARM; or (ii) a
+written contract provided by ARM and accepted by you, this is the only
+agreement between you and ARM relating to the Software and it may only
+be modified by written agreement between you and ARM. Except as
+expressly agreed in writing, this Licence may not be modified by
+purchase orders, advertising or other representation by any person. If
+any clause or sentence in this Licence is held by a court of law to be
+illegal or unenforceable the remaining provisions of this Licence
+shall not be affected thereby. The failure by ARM to enforce any of
+the provisions of this Licence, unless waived in writing, shall not
+constitute a waiver of ARM's rights to enforce such provision or any
+other provision of this Licence in the future.
+
+At ARM's request, you agree to check your computers for installations
+of the Software and any other information requested by ARM relating to
+Software installation and to provide this information to ARM. You
+agree that auditors nominated by ARM may also perform such checking
+and reporting on behalf of ARM by prior appointment during your normal
+business hours on seven (7) days' notice. ARM shall bear the auditors'
+costs for that audit unless it reveals unlicensed usage in which case
+you shall promptly reimburse ARM for all reasonable costs and
+expenses, including professional fees, relating to such audit. Any
+information which is disclosed to ARM or such auditors during checking
+or audit shall be treated as your confidential information and shall
+only be used by ARM for licence management, compliance and enforcement
+purposes.
+
+The Software provided under this Agreement is subject to U.K.,
+European Union, and U.S. export control laws and regulations,
+including the U.S. Export Administration Act and its associated
+regulations (hereafter collectively referred to as "Export
+Regulations"). LICENSEE agrees to comply fully with all such Export
+Regulations and LICENSEE agrees that it shall not, either directly or
+indirectly, export in breach of the Export Regulations, any Software
+received under this Agreement, nor any direct products thereof; (i) to
+any country, company or person subject to export restrictions or
+sanctions under the Export Regulations; or (ii) for any prohibited end
+use, which at the time of export requires an export license or other
+governmental approval, without first obtaining such license or
+approval.
diff --git a/mali/bifrost/lib/egl/libGLES_mali.so b/mali/bifrost/lib/egl/libGLES_mali.so
new file mode 100755
index 00000000..e43c584a
--- /dev/null
+++ b/mali/bifrost/lib/egl/libGLES_mali.so
Binary files differ
diff --git a/mali/bifrost/lib/hw/android.hardware.renderscript@1.0-impl.so b/mali/bifrost/lib/hw/android.hardware.renderscript@1.0-impl.so
new file mode 100755
index 00000000..d0edb823
--- /dev/null
+++ b/mali/bifrost/lib/hw/android.hardware.renderscript@1.0-impl.so
Binary files differ
diff --git a/mali/bifrost/lib/hw/gralloc.hikey960.so b/mali/bifrost/lib/hw/gralloc.hikey960.so
new file mode 100755
index 00000000..860df66b
--- /dev/null
+++ b/mali/bifrost/lib/hw/gralloc.hikey960.so
Binary files differ
diff --git a/mali/bifrost/lib/hw/vulkan.hikey960.so b/mali/bifrost/lib/hw/vulkan.hikey960.so
new file mode 120000
index 00000000..57c186c5
--- /dev/null
+++ b/mali/bifrost/lib/hw/vulkan.hikey960.so
@@ -0,0 +1 @@
+../egl/libGLES_mali.so \ No newline at end of file
diff --git a/mali/bifrost/lib/libRSDriverArm.so b/mali/bifrost/lib/libRSDriverArm.so
new file mode 100755
index 00000000..6185d3d3
--- /dev/null
+++ b/mali/bifrost/lib/libRSDriverArm.so
Binary files differ
diff --git a/mali/bifrost/lib/libmalicore.bc b/mali/bifrost/lib/libmalicore.bc
new file mode 100644
index 00000000..86bb619d
--- /dev/null
+++ b/mali/bifrost/lib/libmalicore.bc
Binary files differ
diff --git a/mali/bifrost/lib64/egl/libGLES_mali.so b/mali/bifrost/lib64/egl/libGLES_mali.so
new file mode 100755
index 00000000..fc60d293
--- /dev/null
+++ b/mali/bifrost/lib64/egl/libGLES_mali.so
Binary files differ
diff --git a/mali/bifrost/lib64/hw/android.hardware.renderscript@1.0-impl.so b/mali/bifrost/lib64/hw/android.hardware.renderscript@1.0-impl.so
new file mode 100755
index 00000000..fc20123d
--- /dev/null
+++ b/mali/bifrost/lib64/hw/android.hardware.renderscript@1.0-impl.so
Binary files differ
diff --git a/mali/bifrost/lib64/hw/gralloc.hikey960.so b/mali/bifrost/lib64/hw/gralloc.hikey960.so
new file mode 100755
index 00000000..bc960d6b
--- /dev/null
+++ b/mali/bifrost/lib64/hw/gralloc.hikey960.so
Binary files differ
diff --git a/mali/bifrost/lib64/hw/vulkan.hikey960.so b/mali/bifrost/lib64/hw/vulkan.hikey960.so
new file mode 120000
index 00000000..57c186c5
--- /dev/null
+++ b/mali/bifrost/lib64/hw/vulkan.hikey960.so
@@ -0,0 +1 @@
+../egl/libGLES_mali.so \ No newline at end of file
diff --git a/mali/bifrost/lib64/libRSDriverArm.so b/mali/bifrost/lib64/libRSDriverArm.so
new file mode 100755
index 00000000..e6f02364
--- /dev/null
+++ b/mali/bifrost/lib64/libRSDriverArm.so
Binary files differ
diff --git a/mali/bifrost/lib64/libbccArm.so b/mali/bifrost/lib64/libbccArm.so
new file mode 100755
index 00000000..ff74da2a
--- /dev/null
+++ b/mali/bifrost/lib64/libbccArm.so
Binary files differ
diff --git a/mali/bifrost/lib64/libmalicore.bc b/mali/bifrost/lib64/libmalicore.bc
new file mode 100644
index 00000000..5fe75abd
--- /dev/null
+++ b/mali/bifrost/lib64/libmalicore.bc
Binary files differ
diff --git a/mali/utgard/Android.mk b/mali/utgard/Android.mk
new file mode 100644
index 00000000..071cdd24
--- /dev/null
+++ b/mali/utgard/Android.mk
@@ -0,0 +1,26 @@
+ifneq ($(filter hikey hikey64 hikey32, $(TARGET_DEVICE)),)
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := END_USER_LICENCE_AGREEMENT.txt
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_STRIP_MODULE := false
+LOCAL_SRC_FILES_arm := $(LOCAL_MODULE)
+LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)
+LOCAL_MULTILIB := 32
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libGLES_mali.so
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_STRIP_MODULE := false
+LOCAL_SRC_FILES_arm := lib/egl/$(LOCAL_MODULE)
+LOCAL_SRC_FILES_arm64 := lib64/egl/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/egl/
+LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/egl/
+LOCAL_MULTILIB := both
+include $(BUILD_PREBUILT)
+
+endif
+
+
diff --git a/mali/utgard/END_USER_LICENCE_AGREEMENT.txt b/mali/utgard/END_USER_LICENCE_AGREEMENT.txt
new file mode 100644
index 00000000..34da5f85
--- /dev/null
+++ b/mali/utgard/END_USER_LICENCE_AGREEMENT.txt
@@ -0,0 +1,194 @@
+LES-PRE-20769
+SP-Version: 1.0
+25 November 2015
+
+END USER LICENCE AGREEMENT FOR THE MALI USERSPACE DRIVER ("Mali DRIVER")
+
+THIS END USER LICENCE AGREEMENT ("LICENCE") IS A LEGAL AGREEMENT
+BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND
+ARM LIMITED ("ARM") FOR THE USE OF THE SOFTWARE ACCOMPANYING THIS
+LICENCE. ARM IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON
+CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS LICENCE. BY
+INSTALLING OR OTHERWISE USING OR COPYING THE SOFTWARE YOU INDICATE
+THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS OF THIS LICENCE. IF YOU
+DO NOT AGREE TO THE TERMS OF THIS LICENCE, ARM IS UNWILLING TO LICENSE
+THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL, USE OR COPY THE SOFTWARE,
+AND YOU SHOULD PROMPTLY RETURN THE SOFTWARE TO YOUR SUPPLIER.
+
+"Applications" means applications for use solely in conjunction with
+Mali-based products manufactured under licence from ARM.
+
+"Output" means data resulting from your use of the Software and all
+direct and indirect derivatives thereof.
+
+"Software" means any software, firmware and data accompanying this
+Licence, any printed, electronic or online documentation supplied with
+it under the terms of this Licence for the Mali Driver.
+
+1. LICENCE GRANTS TO YOU.
+
+1.1 ARM hereby grants to you, subject to the terms and conditions of
+this Licence, a non-exclusive, non-transferable, revocable, worldwide
+licence to:
+
+(i) use and copy the Software or certain components or optional
+ functionality in the Software, as applicable, solely for the
+ purposes of running, designing or developing Applications; and
+
+(ii) subject to Clause 1.2, distribute the whole of the Software;
+ and/or (b) the whole or any part of the Software together
+ with, or as incorporated into, Applications; and
+
+1.2 If you choose to redistribute the whole or any part of the
+Software pursuant to the licences granted in Clause 1.1(ii), you
+agree: (i) not to use ARM's or any of its licensors names, logos or
+trademarks to market Applications; (ii) to retain any and all
+copyright notices and other notices (whether ARM's or its licensor's)
+which are included with the Software; and (iii) include a copy of this
+Licence with such redistribution.
+
+2. RESTRICTIONS ON USE OF THE SOFTWARE.
+
+BENCHMARKING: This Licence does not prevent you from using the
+Software for benchmarking purposes. However, you shall ensure that any
+and all benchmarking data relating to the Software, and any other
+results of your use or testing of the Software which are indicative of
+its performance, efficacy, reliability or quality, shall not be used
+to disparage ARM, its products or services, or in a manner that, in
+ARM's reasonable judgment, may diminish or otherwise damage the
+reputation of ARM.
+
+COPYRIGHT AND RESERVATION OF RIGHTS: The Software is owned by ARM or
+its licensors and is protected by copyright and other intellectual
+property laws and international treaties. The Software is licensed not
+sold. You acquire no rights to the Software other than as expressly
+provided by this Licence. You shall not remove from the Software any
+copyright notice or other notice and shall ensure that any such notice
+is reproduced in any copies of the whole or any part of the Software
+made by you or other permitted users.
+
+REVERSE ENGINEERING: Except to the extent that such activity is
+permitted by applicable law you shall not reverse engineer, decompile
+or disassemble any of the Software. If the Software was provided to
+you in Europe you shall not reverse engineer, decompile or disassemble
+any of the Software for the purposes of error correction.
+
+RESTRICTED USE: You agree that you shall not use the Software or the
+Output other than pursuant to and in accordance with the exercise of
+any of the licences granted under this Licence. Without limiting the
+generality of the foregoing, you shall not use the Software or any
+Output: (a) for determining if any features, functions or processes
+provided by the Software are covered by any patents or patent
+applications owned by you or a third party; or (b) for developing
+technology, applications or products which avoid any of ARM's
+intellectual property in the Software licensed hereunder; or (c) as a
+reference for modifying existing patents or patent applications or
+creating any continuation, continuation in part, or extension of
+existing patents or patent applications.
+
+3. SUPPORT.
+
+ARM is not under an obligation to provide support, but it may do so at
+its own discretion, and if it does, it will only be in respect of the
+Software as delivered.
+
+4. NO WARRANTIES.
+
+YOU AGREE THAT THE SOFTWARE IS LICENSED "AS IS", AND THAT ARM
+EXPRESSLY DISCLAIMS ALL REPRESENTATIONS, WARRANTIES, CONDITIONS OR
+OTHER TERMS, EXPRESS OR IMPLIED OR STATUTORY, INCLUDING WITHOUT
+LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, SATISFACTORY
+QUALITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+
+YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION
+OF APPLICATIONS, INCLUDING WITHOUT LIMITATION, APPLICATIONS DESIGNED
+OR INTENDED FOR MISSION CRITICAL APPLICATIONS, SUCH AS PACEMAKERS,
+WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL SYSTEMS, ETC. SHOULD
+THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL
+NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+5. LIMITATION OF LIABILITY.
+
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
+ARM BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
+DAMAGES (INCLUDING LOSS OF PROFITS) ARISING OUT OF THE USE OR
+INABILITY TO USE THE SOFTWARE WHETHER BASED ON A CLAIM UNDER CONTRACT,
+TORT OR OTHER LEGAL THEORY, EVEN IF ARM WAS ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGES.
+
+ARM does not seek to limit or exclude liability for death or personal
+injury arising from ARM's negligence or ARM's fraud and because some
+jurisdictions do not permit the exclusion or limitation of liability
+for consequential or incidental damages the above limitation relating
+to liability for consequential damages may not apply to you.
+
+NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS LICENCE,
+THE MAXIMUM LIABILITY OF ARM TO YOU IN AGGREGATE FOR ALL CLAIMS MADE
+AGAINST ARM IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH
+THE SUBJECT MATTER OF THIS LICENCE SHALL NOT EXCEED THE GREATER OF:
+(I) THE TOTAL OF SUMS PAID BY YOU TO ARM (IF ANY) FOR THIS LICENCE;
+AND (II) $10.00 USD. THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT
+ENLARGE OR EXTEND THE LIMIT.
+
+6. U.S. GOVERNMENT END USERS.
+
+US Government Restrictions: Use, duplication, reproduction, release,
+modification, disclosure or transfer of the Software is restricted in
+accordance with the terms of this Licence.
+
+7. TERM AND TERMINATION.
+
+This Licence shall remain in force until terminated by you or by ARM.
+Without prejudice to any of its other rights if you are in breach of
+any of the terms and conditions of this Licence then ARM may terminate
+this Licence immediately upon giving written notice to you or on
+thirty (30) days written notice without cause. You may terminate this
+Licence at any time. Upon termination of this Licence by you or by ARM
+, you shall stop using the Software and destroy all copies of the
+Software in your possession, together with all documentation and
+related materials. The provisions of clauses 2, 3, 4, 5, 6, 7, and 8
+shall survive termination of this Licence.
+
+8. GENERAL.
+
+This Licence is governed by English Law. Except where ARM agrees
+otherwise in: (i) a written contract signed by you and ARM; or (ii) a
+written contract provided by ARM and accepted by you, this is the only
+agreement between you and ARM relating to the Software and it may only
+be modified by written agreement between you and ARM. Except as
+expressly agreed in writing, this Licence may not be modified by
+purchase orders, advertising or other representation by any person. If
+any clause or sentence in this Licence is held by a court of law to be
+illegal or unenforceable the remaining provisions of this Licence
+shall not be affected thereby. The failure by ARM to enforce any of
+the provisions of this Licence, unless waived in writing, shall not
+constitute a waiver of ARM's rights to enforce such provision or any
+other provision of this Licence in the future.
+
+At ARM's request, you agree to check your computers for installations
+of the Software and any other information requested by ARM relating to
+Software installation and to provide this information to ARM. You
+agree that auditors nominated by ARM may also perform such checking
+and reporting on behalf of ARM by prior appointment during your normal
+business hours on seven (7) days' notice. ARM shall bear the auditors'
+costs for that audit unless it reveals unlicensed usage in which case
+you shall promptly reimburse ARM for all reasonable costs and
+expenses, including professional fees, relating to such audit. Any
+information which is disclosed to ARM or such auditors during checking
+or audit shall be treated as your confidential information and shall
+only be used by ARM for licence management, compliance and enforcement
+purposes.
+
+The Software provided under this Agreement is subject to U.K.,
+European Union, and U.S. export control laws and regulations,
+including the U.S. Export Administration Act and its associated
+regulations (hereafter collectively referred to as "Export
+Regulations"). LICENSEE agrees to comply fully with all such Export
+Regulations and LICENSEE agrees that it shall not, either directly or
+indirectly, export in breach of the Export Regulations, any Software
+received under this Agreement, nor any direct products thereof; (i) to
+any country, company or person subject to export restrictions or
+sanctions under the Export Regulations; or (ii) for any prohibited end
+use, which at the time of export requires an export license or other
+governmental approval, without first obtaining such license or
+approval.
diff --git a/mali/utgard/lib/egl/libGLES_mali.so b/mali/utgard/lib/egl/libGLES_mali.so
new file mode 100755
index 00000000..f86da7e5
--- /dev/null
+++ b/mali/utgard/lib/egl/libGLES_mali.so
Binary files differ
diff --git a/mali/utgard/lib64/egl/libGLES_mali.so b/mali/utgard/lib64/egl/libGLES_mali.so
new file mode 100755
index 00000000..5c0af47c
--- /dev/null
+++ b/mali/utgard/lib64/egl/libGLES_mali.so
Binary files differ
diff --git a/manifest.xml b/manifest.xml
index 0971a191..b90111d4 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -1,5 +1,23 @@
<manifest version="1.0" type="device">
<hal format="hidl">
+ <name>android.hardware.audio</name>
+ <transport>hwbinder</transport>
+ <version>2.0</version>
+ <interface>
+ <name>IDevicesFactory</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.audio.effect</name>
+ <transport>hwbinder</transport>
+ <version>2.0</version>
+ <interface>
+ <name>IEffectsFactory</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
<name>android.hardware.bluetooth</name>
<transport>hwbinder</transport>
<version>1.0</version>
@@ -9,6 +27,51 @@
</interface>
</hal>
<hal format="hidl">
+ <name>android.hardware.broadcastradio</name>
+ <transport arch="32+64">passthrough</transport>
+ <version>1.0</version>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.cas</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>IMediaCasService</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.configstore</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>ISurfaceFlingerConfigs</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.drm</name>
+ <transport arch="32">passthrough</transport>
+ <version>1.0</version>
+ <interface>
+ <name>ICryptoFactory</name>
+ <instance>default</instance>
+ </interface>
+ <interface>
+ <name>IDrmFactory</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.gnss</name>
+ <transport arch="32+64">passthrough</transport>
+ <version>1.0</version>
+ <interface>
+ <name>IGnss</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
<name>android.hardware.graphics.allocator</name>
<transport>hwbinder</transport>
<version>2.0</version>
@@ -19,7 +82,7 @@
</hal>
<hal format="hidl">
<name>android.hardware.graphics.composer</name>
- <transport arch="32+64">passthrough</transport>
+ <transport>hwbinder</transport>
<version>2.1</version>
<interface>
<name>IComposer</name>
@@ -36,6 +99,28 @@
</interface>
</hal>
<hal format="hidl">
+ <name>android.hardware.keymaster</name>
+ <transport>hwbinder</transport>
+ <version>3.0</version>
+ <interface>
+ <name>IKeymasterDevice</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.media.omx</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>IOmx</name>
+ <instance>default</instance>
+ </interface>
+ <interface>
+ <name>IOmxStore</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
<name>android.hardware.memtrack</name>
<transport>hwbinder</transport>
<version>1.0</version>
@@ -45,6 +130,24 @@
</interface>
</hal>
<hal format="hidl">
+ <name>android.hardware.power</name>
+ <transport arch="32+64">passthrough</transport>
+ <version>1.0</version>
+ <interface>
+ <name>IPower</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
+ <name>android.hardware.soundtrigger</name>
+ <transport arch="32">passthrough</transport>
+ <version>2.0</version>
+ <interface>
+ <name>ISoundTriggerHw</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="hidl">
<name>android.hardware.wifi.hostapd</name>
<transport>hwbinder</transport>
<version>1.0</version>
diff --git a/power/Android.mk b/power/Android.mk
index 187d56eb..53e464ec 100644
--- a/power/Android.mk
+++ b/power/Android.mk
@@ -19,9 +19,13 @@ LOCAL_PATH := $(call my-dir)
# hw/<POWERS_HARDWARE_MODULE_ID>.<ro.hardware>.so
include $(CLEAR_VARS)
-LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_SHARED_LIBRARIES := liblog libcutils
LOCAL_SRC_FILES := power_hikey.c
+
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_VENDOR_MODULE := true
+
+LOCAL_HEADER_LIBRARIES += libhardware_headers
LOCAL_MODULE := power.$(TARGET_BOARD_PLATFORM)
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/power/power_hikey.c b/power/power_hikey.c
index 34264d8a..f9a3ddb6 100644
--- a/power/power_hikey.c
+++ b/power/power_hikey.c
@@ -31,7 +31,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "HiKeyPowerHAL"
-#include <utils/Log.h>
+#include <log/log.h>
#include <hardware/hardware.h>
#include <hardware/power.h>
diff --git a/self-extractors/PART1 b/self-extractors/PART1
deleted file mode 100644
index 935267e0..00000000
--- a/self-extractors/PART1
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# 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
deleted file mode 100644
index 30e8d435..00000000
--- a/self-extractors/PART2
+++ /dev/null
@@ -1,22 +0,0 @@
-__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
deleted file mode 100644
index 6847be5b..00000000
--- a/self-extractors/PART3
+++ /dev/null
@@ -1,12 +0,0 @@
-
-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
deleted file mode 100644
index c856ef19..00000000
--- a/self-extractors/PROLOGUE
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-#
diff --git a/self-extractors/extract-lists.txt b/self-extractors/extract-lists.txt
deleted file mode 100644
index 8f6344e5..00000000
--- a/self-extractors/extract-lists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
- linaro)
- TO_EXTRACT="\
- SYSTEM/vendor/lib64/egl/libGLES_mali.so \
- SYSTEM/vendor/lib/egl/libGLES_mali.so \
- "
- ;;
diff --git a/self-extractors/linaro/COPYRIGHT b/self-extractors/linaro/COPYRIGHT
deleted file mode 100644
index 4e017c21..00000000
--- a/self-extractors/linaro/COPYRIGHT
+++ /dev/null
@@ -1 +0,0 @@
-# (C) HiSilicon Co. Ltd.
diff --git a/self-extractors/linaro/LICENSE b/self-extractors/linaro/LICENSE
deleted file mode 100644
index 4a8cdd56..00000000
--- a/self-extractors/linaro/LICENSE
+++ /dev/null
@@ -1,177 +0,0 @@
-THIS END USER LICENCE AGREEMENT ("LICENCE") IS A LEGAL AGREEMENT
-BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND
-ARM LIMITED ("ARM") FOR THE USE OF THE SOFTWARE ACCOMPANYING THIS
-LICENCE. ARM IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON
-CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS LICENCE. BY
-CLICKING "I AGREE" OR BY INSTALLING OR OTHERWISE USING OR COPYING THE
-SOFTWARE YOU INDICATE THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS
-OF THIS LICENCE. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENCE, ARM
-IS UNWILLING TO LICENSE THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL,
-USE OR COPY THE SOFTWARE, AND YOU SHOULD PROMPTLY RETURN THE SOFTWARE
-TO YOUR SUPPLIER.
-
-"Software" means any software, firmware and data accompanying this
-Licence, any printed, electronic or online documentation supplied with
-it under the terms of this Licence for the MALI GPU Driver.
-
- 1. LICENCE GRANTS TO YOU.
-
- 1.1 ARM hereby grants to you, subject to the terms and conditions of
- this Licence, a non-exclusive, non-transferable, revocable, worldwide
- licence to: (i) use the Software or certain components or optional
- functionality in the Software, as applicable, solely for the purposes
- of designing or developing applications for use in conjunction with
- MALI GPU based products manufactured under licence from ARM; and (ii)
- modify the Software or certain components or optional functionality in
- the Software for the purposes of porting the Software to your target;
-
- 2. RESTRICTIONS ON USE OF THE SOFTWARE.
-
- COPYING: You shall not use or copy the Software except as expressly
- authorised in this Licence. You may make one additional copy of the
- delivered Software for backup or archival purposes.
-
- BENCHMARKING: This Licence does not prevent you from using the
- Software for internal benchmarking purposes. However, you shall treat
- any and all benchmarking data relating to the Software, and any other
- results of your use or testing of the Software which are indicative of
- its performance, efficacy, reliability or quality, as confidential
- information and you shall not disclose such information to any third
- party without the express written permission of ARM.
-
- COPYRIGHT AND RESERVATION OF RIGHTS: The Software is owned by ARM or
- its licensors and is protected by copyright and other intellectual
- property laws and international treaties. The Software is licensed not
- sold. You acquire no rights to the Software other than as expressly
- provided by this Licence. You shall not remove from the Software any
- copyright notice or other notice and shall ensure that any such notice
- is reproduced in any copies of the whole or any part of the Software
- made by you or other permitted users.
-
- REVERSE ENGINEERING: Except to the extent that such activity is
- permitted by applicable law you shall not reverse engineer, decompile
- or disassemble any of the Software. If the Software was provided to
- you in Europe you shall not reverse engineer, decompile or disassemble
- any of the Software for the purposes of error correction.
-
- 3. SUPPORT.
-
- ARM is not under an obligation to provide support, but it may do so at
- its own discretion, and if it does, it will only be in respect of the
- Software as delivered and not any modifications thereto.
-
- 4. NO WARRANTIES.
-
- YOU AGREE THAT THE SOFTWARE IS LICENSED "AS IS", AND THAT ARM
- EXPRESSLY DISCLAIMS ALL REPRESENTATIONS, WARRANTIES, CONDITIONS OR
- OTHER TERMS, EXPRESS OR IMPLIED OR STATUTORY, INCLUDING WITHOUT
- LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, SATISFACTORY
- QUALITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-
- YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION
- OF SOFTWARE APPLICATIONS, INCLUDING WITHOUT LIMITATION, SOFTWARE
- APPLICATIONS DESIGNED OR INTENDED FOR MISSION CRITICAL APPLICATIONS,
- SUCH AS PACEMAKERS, WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL
- SYSTEMS, ETC. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE
- ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 5. LIMITATION OF LIABILITY.
-
- TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
- ARM BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
- DAMAGES (INCLUDING LOSS OF PROFITS) ARISING OUT OF THE USE OR
- INABILITY TO USE THE SOFTWARE WHETHER BASED ON A CLAIM UNDER CONTRACT,
- TORT OR OTHER LEGAL THEORY, EVEN IF ARM WAS ADVISED OF THE POSSIBILITY
- OF SUCH DAMAGES.
-
- ARM does not seek to limit or exclude liability for death or personal
- injury arising from ARM's negligence or ARM's fraud and because some
- jurisdictions do not permit the exclusion or limitation of liability
- for consequential or incidental damages the above limitation relating
- to liability for consequential damages may not apply to you.
-
- NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS LICENCE,
- THE MAXIMUM LIABILITY OF ARM TO YOU IN AGGREGATE FOR ALL CLAIMS MADE
- AGAINST ARM IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH
- THE SUBJECT MATTER OF THIS LICENCE SHALL NOT EXCEED THE GREATER OF:
- (I) THE TOTAL OF SUMS PAID BY YOU TO ARM (IF ANY) FOR THIS LICENCE;
- AND (II) $10.00 USD. THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT
- ENLARGE OR EXTEND THE LIMIT.
-
- 6. CONFIDENTIALITY.
-
- You acknowledge that the Software and any benchmarking data and
- related information mentioned in Clause 2 may contain trade secrets
- and confidential material and you agree to maintain all such
- information in confidence and apply security measures no less
- stringent than the measures which you apply to protect your own like
- information, but not less than a reasonable degree of care, to prevent
- their unauthorised disclosure and use. Subject to any restrictions
- imposed by applicable law, the period of confidentiality shall be
- indefinite. You agree not to use any such information other than in
- normal use of the Software under the licences granted in this Licence.
-
- 7. U.S. GOVERNMENT END USERS.
-
- US Government Restrictions: Use, duplication, reproduction, release,
- modification, disclosure or transfer of the Software is restricted in
- accordance with the terms of this Licence.
-
- 8. TERM AND TERMINATION.
-
- This Licence shall remain in force until terminated by you or by
- ARM. Without prejudice to any of its other rights if you are in breach
- of any of the terms and conditions of this Licence then ARM may
- terminate this Licence immediately upon giving written notice to you
- or on thirty (30) days written notice without cause. You may terminate
- this Licence at any time. Upon termination of this Licence by you or
- by ARM , you shall stop using the Software and confidential
- information and destroy all copies of the Software and confidential
- information in your possession, together with all documentation and
- related materials. The provisions of clauses 4, 5, 6, 7, 8 and 9 shall
- survive termination of this Licence.
-
- 9. GENERAL.
-
- This Licence is governed by English Law. Except where ARM agrees
- otherwise in: (i) a written contract signed by you and ARM; or (ii) a
- written contract provided by ARM and accepted by you, this is the only
- agreement between you and ARM relating to the Software and it may only
- be modified by written agreement between you and ARM. Except as
- expressly agreed in writing, this Licence may not be modified by
- purchase orders, advertising or other representation by any person. If
- any clause or sentence in this Licence is held by a court of law to be
- illegal or unenforceable the remaining provisions of this Licence
- shall not be affected thereby. The failure by ARM to enforce any of
- the provisions of this Licence, unless waived in writing, shall not
- constitute a waiver of ARM's rights to enforce such provision or any
- other provision of this Licence in the future.
-
- At ARM's request, you agree to check your computers for installations
- of the Software and any other information requested by ARM relating to
- Software installation and to provide this information to ARM. You
- agree that auditors nominated by ARM may also perform such checking
- and reporting on behalf of ARM by prior appointment during your normal
- business hours on seven (7) days' notice. ARM shall bear the auditors'
- costs for that audit unless it reveals unlicensed usage in which case
- you shall promptly reimburse ARM for all reasonable costs and
- expenses, including professional fees, relating to such audit. Any
- information which is disclosed to ARM or such auditors during checking
- or audit shall be treated as your confidential information and shall
- only be used by ARM for licence management, compliance and enforcement
- purposes.
-
- The Software provided under this Licence is subject to U.S. export
- control laws, including the U.S. Export Administration Act and its
- associated regulations, and may be subject to export or import
- regulations in other countries. You agree to comply fully with all
- laws and regulations of the United States and other countries ("Export
- Laws") to assure that the Software, is not (1) exported, directly or
- indirectly, in violation of Export Laws, either to any countries that
- are subject to U.S.A. export restrictions or to any end user who has
- been prohibited from participating in the U.S.A. export transactions
- by any federal agency of the U.S.A. government; or (2) intended to be
- used for any purpose prohibited by Export Laws, including, without
- limitation, nuclear, chemical, or biological weapons proliferation.
-
-Mali GPU Userspace LES-PRE-20376
diff --git a/self-extractors/linaro/staging/device-partial.mk b/self-extractors/linaro/staging/device-partial.mk
deleted file mode 100644
index 1b38a18c..00000000
--- a/self-extractors/linaro/staging/device-partial.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2016 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.
-
-# Linaro blob(s) necessary for Hikey hardware
-PRODUCT_COPY_FILES := \
- vendor/linaro/hikey/proprietary/lib64/libGLES_mali.so:system/vendor/lib64/egl/libGLES_mali.so:linaro \
- vendor/linaro/hikey/proprietary/libGLES_mali.so:system/vendor/lib/egl/libGLES_mali.so:linaro \
-
diff --git a/self-extractors/root/BoardConfigVendor.mk b/self-extractors/root/BoardConfigVendor.mk
deleted file mode 100644
index af30aa1f..00000000
--- a/self-extractors/root/BoardConfigVendor.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2016 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 := hikey/BoardConfigPartial.mk
-
--include vendor/linaro/$(LOCAL_STEM)
diff --git a/self-extractors/root/device-vendor.mk b/self-extractors/root/device-vendor.mk
deleted file mode 100644
index d555b9fb..00000000
--- a/self-extractors/root/device-vendor.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Copyright 2016 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 := hikey/device-partial.mk
-
-$(call inherit-product-if-exists, vendor/linaro/$(LOCAL_STEM))
diff --git a/self-extractors_hikey960/arm/COPYRIGHT b/self-extractors_hikey960/arm/COPYRIGHT
deleted file mode 100644
index c627c1a1..00000000
--- a/self-extractors_hikey960/arm/COPYRIGHT
+++ /dev/null
@@ -1 +0,0 @@
-# (C) ARM Limited.
diff --git a/self-extractors_hikey960/arm/LICENSE b/self-extractors_hikey960/arm/LICENSE
deleted file mode 100644
index 4a8cdd56..00000000
--- a/self-extractors_hikey960/arm/LICENSE
+++ /dev/null
@@ -1,177 +0,0 @@
-THIS END USER LICENCE AGREEMENT ("LICENCE") IS A LEGAL AGREEMENT
-BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND
-ARM LIMITED ("ARM") FOR THE USE OF THE SOFTWARE ACCOMPANYING THIS
-LICENCE. ARM IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON
-CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS LICENCE. BY
-CLICKING "I AGREE" OR BY INSTALLING OR OTHERWISE USING OR COPYING THE
-SOFTWARE YOU INDICATE THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS
-OF THIS LICENCE. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENCE, ARM
-IS UNWILLING TO LICENSE THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL,
-USE OR COPY THE SOFTWARE, AND YOU SHOULD PROMPTLY RETURN THE SOFTWARE
-TO YOUR SUPPLIER.
-
-"Software" means any software, firmware and data accompanying this
-Licence, any printed, electronic or online documentation supplied with
-it under the terms of this Licence for the MALI GPU Driver.
-
- 1. LICENCE GRANTS TO YOU.
-
- 1.1 ARM hereby grants to you, subject to the terms and conditions of
- this Licence, a non-exclusive, non-transferable, revocable, worldwide
- licence to: (i) use the Software or certain components or optional
- functionality in the Software, as applicable, solely for the purposes
- of designing or developing applications for use in conjunction with
- MALI GPU based products manufactured under licence from ARM; and (ii)
- modify the Software or certain components or optional functionality in
- the Software for the purposes of porting the Software to your target;
-
- 2. RESTRICTIONS ON USE OF THE SOFTWARE.
-
- COPYING: You shall not use or copy the Software except as expressly
- authorised in this Licence. You may make one additional copy of the
- delivered Software for backup or archival purposes.
-
- BENCHMARKING: This Licence does not prevent you from using the
- Software for internal benchmarking purposes. However, you shall treat
- any and all benchmarking data relating to the Software, and any other
- results of your use or testing of the Software which are indicative of
- its performance, efficacy, reliability or quality, as confidential
- information and you shall not disclose such information to any third
- party without the express written permission of ARM.
-
- COPYRIGHT AND RESERVATION OF RIGHTS: The Software is owned by ARM or
- its licensors and is protected by copyright and other intellectual
- property laws and international treaties. The Software is licensed not
- sold. You acquire no rights to the Software other than as expressly
- provided by this Licence. You shall not remove from the Software any
- copyright notice or other notice and shall ensure that any such notice
- is reproduced in any copies of the whole or any part of the Software
- made by you or other permitted users.
-
- REVERSE ENGINEERING: Except to the extent that such activity is
- permitted by applicable law you shall not reverse engineer, decompile
- or disassemble any of the Software. If the Software was provided to
- you in Europe you shall not reverse engineer, decompile or disassemble
- any of the Software for the purposes of error correction.
-
- 3. SUPPORT.
-
- ARM is not under an obligation to provide support, but it may do so at
- its own discretion, and if it does, it will only be in respect of the
- Software as delivered and not any modifications thereto.
-
- 4. NO WARRANTIES.
-
- YOU AGREE THAT THE SOFTWARE IS LICENSED "AS IS", AND THAT ARM
- EXPRESSLY DISCLAIMS ALL REPRESENTATIONS, WARRANTIES, CONDITIONS OR
- OTHER TERMS, EXPRESS OR IMPLIED OR STATUTORY, INCLUDING WITHOUT
- LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, SATISFACTORY
- QUALITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-
- YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION
- OF SOFTWARE APPLICATIONS, INCLUDING WITHOUT LIMITATION, SOFTWARE
- APPLICATIONS DESIGNED OR INTENDED FOR MISSION CRITICAL APPLICATIONS,
- SUCH AS PACEMAKERS, WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL
- SYSTEMS, ETC. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE
- ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 5. LIMITATION OF LIABILITY.
-
- TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
- ARM BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
- DAMAGES (INCLUDING LOSS OF PROFITS) ARISING OUT OF THE USE OR
- INABILITY TO USE THE SOFTWARE WHETHER BASED ON A CLAIM UNDER CONTRACT,
- TORT OR OTHER LEGAL THEORY, EVEN IF ARM WAS ADVISED OF THE POSSIBILITY
- OF SUCH DAMAGES.
-
- ARM does not seek to limit or exclude liability for death or personal
- injury arising from ARM's negligence or ARM's fraud and because some
- jurisdictions do not permit the exclusion or limitation of liability
- for consequential or incidental damages the above limitation relating
- to liability for consequential damages may not apply to you.
-
- NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS LICENCE,
- THE MAXIMUM LIABILITY OF ARM TO YOU IN AGGREGATE FOR ALL CLAIMS MADE
- AGAINST ARM IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH
- THE SUBJECT MATTER OF THIS LICENCE SHALL NOT EXCEED THE GREATER OF:
- (I) THE TOTAL OF SUMS PAID BY YOU TO ARM (IF ANY) FOR THIS LICENCE;
- AND (II) $10.00 USD. THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT
- ENLARGE OR EXTEND THE LIMIT.
-
- 6. CONFIDENTIALITY.
-
- You acknowledge that the Software and any benchmarking data and
- related information mentioned in Clause 2 may contain trade secrets
- and confidential material and you agree to maintain all such
- information in confidence and apply security measures no less
- stringent than the measures which you apply to protect your own like
- information, but not less than a reasonable degree of care, to prevent
- their unauthorised disclosure and use. Subject to any restrictions
- imposed by applicable law, the period of confidentiality shall be
- indefinite. You agree not to use any such information other than in
- normal use of the Software under the licences granted in this Licence.
-
- 7. U.S. GOVERNMENT END USERS.
-
- US Government Restrictions: Use, duplication, reproduction, release,
- modification, disclosure or transfer of the Software is restricted in
- accordance with the terms of this Licence.
-
- 8. TERM AND TERMINATION.
-
- This Licence shall remain in force until terminated by you or by
- ARM. Without prejudice to any of its other rights if you are in breach
- of any of the terms and conditions of this Licence then ARM may
- terminate this Licence immediately upon giving written notice to you
- or on thirty (30) days written notice without cause. You may terminate
- this Licence at any time. Upon termination of this Licence by you or
- by ARM , you shall stop using the Software and confidential
- information and destroy all copies of the Software and confidential
- information in your possession, together with all documentation and
- related materials. The provisions of clauses 4, 5, 6, 7, 8 and 9 shall
- survive termination of this Licence.
-
- 9. GENERAL.
-
- This Licence is governed by English Law. Except where ARM agrees
- otherwise in: (i) a written contract signed by you and ARM; or (ii) a
- written contract provided by ARM and accepted by you, this is the only
- agreement between you and ARM relating to the Software and it may only
- be modified by written agreement between you and ARM. Except as
- expressly agreed in writing, this Licence may not be modified by
- purchase orders, advertising or other representation by any person. If
- any clause or sentence in this Licence is held by a court of law to be
- illegal or unenforceable the remaining provisions of this Licence
- shall not be affected thereby. The failure by ARM to enforce any of
- the provisions of this Licence, unless waived in writing, shall not
- constitute a waiver of ARM's rights to enforce such provision or any
- other provision of this Licence in the future.
-
- At ARM's request, you agree to check your computers for installations
- of the Software and any other information requested by ARM relating to
- Software installation and to provide this information to ARM. You
- agree that auditors nominated by ARM may also perform such checking
- and reporting on behalf of ARM by prior appointment during your normal
- business hours on seven (7) days' notice. ARM shall bear the auditors'
- costs for that audit unless it reveals unlicensed usage in which case
- you shall promptly reimburse ARM for all reasonable costs and
- expenses, including professional fees, relating to such audit. Any
- information which is disclosed to ARM or such auditors during checking
- or audit shall be treated as your confidential information and shall
- only be used by ARM for licence management, compliance and enforcement
- purposes.
-
- The Software provided under this Licence is subject to U.S. export
- control laws, including the U.S. Export Administration Act and its
- associated regulations, and may be subject to export or import
- regulations in other countries. You agree to comply fully with all
- laws and regulations of the United States and other countries ("Export
- Laws") to assure that the Software, is not (1) exported, directly or
- indirectly, in violation of Export Laws, either to any countries that
- are subject to U.S.A. export restrictions or to any end user who has
- been prohibited from participating in the U.S.A. export transactions
- by any federal agency of the U.S.A. government; or (2) intended to be
- used for any purpose prohibited by Export Laws, including, without
- limitation, nuclear, chemical, or biological weapons proliferation.
-
-Mali GPU Userspace LES-PRE-20376
diff --git a/self-extractors_hikey960/arm/staging/device-partial.mk b/self-extractors_hikey960/arm/staging/device-partial.mk
deleted file mode 100644
index 8af8e9c9..00000000
--- a/self-extractors_hikey960/arm/staging/device-partial.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2016 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.
-
-# Linaro blob(s) necessary for Hikey hardware
-PRODUCT_COPY_FILES := \
- vendor/linaro/hikey960/arm/proprietary/lib64/libGLES_mali.so:system/lib64/egl/libGLES_mali.so:linaro \
- vendor/linaro/hikey960/arm/proprietary/libGLES_mali.so:system/lib/egl/libGLES_mali.so:linaro \
- vendor/linaro/hikey960/arm/proprietary/lib64/libGLES_mali.so:system/vendor/lib64/hw/vulkan.hikey960.so:linaro \
- vendor/linaro/hikey960/arm/proprietary/libGLES_mali.so:system/vendor/lib/hw/vulkan.hikey960.so:linaro
diff --git a/self-extractors_hikey960/extract-lists.txt b/self-extractors_hikey960/extract-lists.txt
index ad4df6bd..932ca9b6 100644
--- a/self-extractors_hikey960/extract-lists.txt
+++ b/self-extractors_hikey960/extract-lists.txt
@@ -1,6 +1,18 @@
- arm)
+ hisilicon)
TO_EXTRACT="\
- SYSTEM/lib/egl/libGLES_mali.so \
- SYSTEM/lib64/egl/libGLES_mali.so \
+ SYSTEM/lib/libc_secshared.so \
+ SYSTEM/lib/libhiion.so \
+ SYSTEM/lib/libhilog.so \
+ SYSTEM/lib/libOMX.hisi.vdec.core.so \
+ SYSTEM/lib/libOMX.hisi.video.decoder.so \
+ SYSTEM/lib/libOMX_Core.so \
+ SYSTEM/lib/libstagefrighthw.so \
+ SYSTEM/lib64/libc_secshared.so \
+ SYSTEM/lib64/libhiion.so \
+ SYSTEM/lib64/libhilog.so \
+ SYSTEM/lib64/libOMX.hisi.vdec.core.so \
+ SYSTEM/lib64/libOMX.hisi.video.decoder.so \
+ SYSTEM/lib64/libOMX_Core.so \
+ SYSTEM/lib64/libstagefrighthw.so \
"
;;
diff --git a/self-extractors_hikey960/hisilicon/COPYRIGHT b/self-extractors_hikey960/hisilicon/COPYRIGHT
new file mode 100644
index 00000000..8e57b9d8
--- /dev/null
+++ b/self-extractors_hikey960/hisilicon/COPYRIGHT
@@ -0,0 +1 @@
+# (C) HiSilicon Limited.
diff --git a/self-extractors_hikey960/hisilicon/LICENSE b/self-extractors_hikey960/hisilicon/LICENSE
new file mode 100644
index 00000000..4746d431
--- /dev/null
+++ b/self-extractors_hikey960/hisilicon/LICENSE
@@ -0,0 +1,126 @@
+End User License Agreement for Software related to Hisilicon HiKey960 Board
+
+THIS END USER LICENSE AGREEMENT (“AGREEMENT”) IS A LEGAL AGREEMENT BETWEEN
+YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND HISILICON
+TECHNOLOGIES CO., LTD. (&quot;HISILICON&quot;) FOR THE USE OF THE SOFTWARE ACCOMPANYING
+THIS AGREEMENT. HISILICON IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON
+CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS AGREEMENT. BY CLICKING “I
+AGREE” OR BY INSTALLING OR OTHERWISE USING OR COPYING THE SOFTWARE YOU
+INDICATE THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS OF THIS AGREEMENT. IF
+YOU DO NOT AGREE TO THE TERMS OF THIS AGREEMENT, HISILICON IS UNWILLING
+TO LICENSE THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL, USE OR COPY THE
+SOFTWARE, AND YOU SHALL PROMPTLY DESTROY, DELETE, OR RETURN THE SOFTWARE TO
+YOUR SUPPLIER.
+
+“SOFTWARE” means the software in object code provided under the terms of this Agreement related
+to Hisilicon HiKey960 Board.
+
+1. GRANT OF LICENSE
+In consideration of your agreement to abide by the following terms, and subject to the terms and conditions of
+this Agreement, HISILICON hereby grants YOU, a non-transferable, non-exclusive, royalty-free, revocable,
+worldwide copyright license (without the right to sublicense) to use and copy the SOFTWARE solely for the
+purpose of designing or developing applications for use in conjunction with Hisilicon HiKey960 Board.
+All rights to the SOFTWARE and all intellectual property rights contained therein shall remain the sole and
+exclusive property of HISILICON. The SOFTWARE is licensed not sold. Except as expressly licensed in
+Clause 1, in no event shall the license granted in this Clause 1 be construed as granting YOU expressly or by
+implication, estoppels or otherwise, licenses to any intellectual property rights, including but not limited to
+patent rights, copyrights, trademark or trade secret in the SOFTWARE.
+No right is granted to YOU under this Agreement to manufacture, have manufactured, or sell, supply or
+distribute any products which have taken into use or which embody any of the SOFTWARE or any of the
+intellectual property rights embodied therein.
+
+2. RESTRICTIONS
+This Agreement does not prevent YOU from using the SOFTWARE for internal benchmarking purposes.
+However, YOU shall treat any and all benchmarking data relating to the SOFTWARE, and any other results of
+your use or testing of the SOFTWARE which are indicative of its performance, efficacy, reliability or quality,
+as confidential information and YOU shall not disclose such information to any third party without the express
+written permission of HISILICON.
+
+YOU shall reproduce and not remove or obscure any notice incorporated by HISILICON in the SOFTWARE to
+protect HISILICON’s intellectual property rights embodied therein.
+YOU shall not decompile, disassemble, or reverse engineer the SOFTWARE.
+
+3. FEEDBACK
+YOU may choose to provide suggestions, comments, feedback, ideas, modifications or know-how (whether in
+oral or written form) relating to the use of the SOFTWARE (&quot;Feedback&quot;) to HISILICON under the terms of this
+Agreement. YOU hereby grants to HISILICON and its affiliates, under all of your and your affiliates’ (as applicable)
+intellectual property rights, a perpetual, irrevocable, royalty free, non-exclusive, worldwide license
+to (i) use, copy and modify the Feedback; (ii) sell, supply, or otherwise distribute the Feedback; (iii) design,
+have designed, manufacture, have manufactured, use, import, sell, and otherwise distribute and dispose of
+products that incorporate the Feedback; and (iv) sublicense (together with the rights to further sublicense) the
+rights granted in this paragraph to any third party.
+
+4. NO WARRANTY
+YOU AGREE THAT THE SOFTWARE IS PROVIDED BY HISILICON ON AN &quot;AS IS&quot; BASIS.
+HISILICON MAKES NO WARRANTY, EXPRESSED OR IMPLIED OR STATUTORY, WITH RESPECT
+TO ANY OF THE SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES
+OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NON-INFRINGEMENT.
+YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION OF THE
+SOFTWARE, INCLUDING WITHOUT LIMITATION, SOFTWARE APPLICATIONS DESIGNED OR
+INTENDED FOR MISSION CRITICAL APPLICATIONS, SUCH AS PACEMAKERS, WEAPONRY,
+AIRCRAFT NAVIGATION, FACTORY CONTROL SYSTEMS, ETC. SHOULD THE SOFTWARE
+PROVE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+5. NO LIABILITY
+PLEASE READ THE INSTRUCTIONS COMPLETELY, AND PLEASE NOTE THAT YOU SHOULD USE
+THE SOFTWARE AT YOUR OWN RISK.
+IN NO EVENT SHALL HISILICON BE LIABLE FOR ANY DIRECT OR INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE OF OR INABILITY TO USE
+THE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+(INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHER LEGAL THEORY, EVEN IF HISILICON
+HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EVEN IF THE SOFTWARE HAS
+ANY MATERIAL, VERIFIABLE, AND REPRODUCIBLE PROGRAM ERRORS, HISILICON SHALL
+HAVE NO LIABILITY TO MODIFY SUCH ERRORS.
+NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS AGREEMENT, THE
+MAXIMUM LIABILITY OF HISILICON TO YOU IN AGGREGATE FOR ALL CLAIMS MADE AGAINST
+HISILICON IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH THE
+SUBJECT MATTER OF THIS AGREEMENT SHALL NOT EXCEED THE TOTAL OF SUMS
+RECEIVED BY HISILICON FROM YOU FOR THIS AGREEMENT. THE EXISTENCE OF MORE
+THAN ONE CLAIM WILL NOT ENLARGE OR EXTEND THE LIMIT.
+
+6. CONFIDENTIALITY
+YOU acknowledge and agree that the SOFTWARE and any benchmarking data and related information
+provided under this Agreement contain trade secrets and confidential material of HISILICON and YOU agree
+to maintain all such information in confidence and apply security measures no less stringent than the measures
+which YOU apply to protect your own like information, but not less than a reasonable degree of care, to prevent
+their unauthorized disclosure and use. The period of confidentiality shall be indefinite. YOU agree not to use
+any such information other than in normal use of the SOFTWARE under the license granted in this Agreement.
+
+7. TERM AND TERMINATION
+This Agreement shall remain in force until terminated. HISILICON may terminate this Agreement at any time
+with or without any cause. Upon termination of this Agreement, YOU shall immediately stop using the
+SOFTWARE and confidential information and destroy all copies of the SOFTWARE and confidential
+information in your possession, together with all documentation and related materials. The provisions
+of clauses 3, 4, 5, 6, 7 and 8 shall survive termination of this Agreement.
+
+8. GENERAL
+Any provision of this Agreement which is prohibited or unenforceable in any jurisdiction shall be ineffective to
+the extent of such prohibition or unenforceability without affecting, impairing or invalidating the remaining
+provisions hereof.
+The failure by HISILICON to enforce any of the provisions of this Agreement, unless waived in writing,
+shall not constitute a waiver of HISILICON&#39;s rights to enforce such provision or any other provision of
+this Agreement in the future.
+At HISILICON’s request, YOU agree to check your computers for installations of the SOFTWARE and any
+other information requested by HISILICON relating to SOFTWARE installation and to provide this
+information to HISILICON. YOU agree that employees or auditors nominated by HISILICON may also
+perform such checking and reporting on behalf of HISILICON by prior appointment during your normal
+business hours on seven (7) days’ notice. HISILICON shall bear the auditors’ costs for that audit unless it
+reveals unlicensed usage in which case YOU shall promptly reimburse HISILICON for all reasonable costs and
+expenses, including professional fees, relating to such audit.
+The SOFTWARE provided under this Agreement is subject to U.S. export control laws, including the
+U.S. Export Administration Act and its associated regulations, and may be subject to export or import
+regulations in other countries. YOU agree to comply fully with all laws and regulations of the United
+States and other countries (&quot;Export Laws&quot;) to assure that the SOFTWARE, is not (1) exported, directly
+or indirectly, in violation of Export Laws, either to any countries that are subject to U.S.A. export
+restrictions or to any end user who has been prohibited from participating in the U.S.A. export
+transactions by any federal agency of the U.S.A. government; or (2) intended to be used for any
+purpose prohibited by Export Laws, including, without limitation, nuclear, chemical, or biological
+weapons proliferation.
+This Agreement shall be governed by and construed in accordance with the laws of People’s Republic of China,
+without reference to the principles of conflicts of laws. Any dispute arising out of or relating to this Agreement
+shall be submitted to Shenzhen Longgang District People’s court and parties waive all objections to that
+jurisdiction and venue.
diff --git a/self-extractors/linaro/staging/BoardConfigPartial.mk b/self-extractors_hikey960/hisilicon/staging/BoardConfigPartial.mk
index c0aab8ba..c0aab8ba 100644
--- a/self-extractors/linaro/staging/BoardConfigPartial.mk
+++ b/self-extractors_hikey960/hisilicon/staging/BoardConfigPartial.mk
diff --git a/self-extractors_hikey960/hisilicon/staging/device-partial.mk b/self-extractors_hikey960/hisilicon/staging/device-partial.mk
new file mode 100644
index 00000000..c76663af
--- /dev/null
+++ b/self-extractors_hikey960/hisilicon/staging/device-partial.mk
@@ -0,0 +1,32 @@
+# Copyright 2016 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.
+
+# Blobs needed for HiKey960 video decoding hardware
+TARGET_HISI_CODEC_VERSION := 1
+
+PRODUCT_COPY_FILES += vendor/linaro/hikey960/hisilicon/proprietary/libOMX.hisi.video.decoder.so:$(TARGET_COPY_OUT_VENDOR)/lib/libOMX.hisi.video.decoder.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/lib64/libOMX.hisi.video.decoder.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libOMX.hisi.video.decoder.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/libOMX.hisi.vdec.core.so:$(TARGET_COPY_OUT_VENDOR)/lib/libOMX.hisi.vdec.core.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/lib64/libOMX.hisi.vdec.core.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libOMX.hisi.vdec.core.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/libOMX_Core.so:$(TARGET_COPY_OUT_VENDOR)/lib/libOMX_Core.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/lib64/libOMX_Core.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libOMX_Core.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/libstagefrighthw.so:$(TARGET_COPY_OUT_VENDOR)/lib/libstagefrighthw.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/lib64/libstagefrighthw.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libstagefrighthw.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/libc_secshared.so:$(TARGET_COPY_OUT_VENDOR)/lib/libc_secshared.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/lib64/libc_secshared.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libc_secshared.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/lib64/libhilog.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libhilog.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/libhilog.so:$(TARGET_COPY_OUT_VENDOR)/lib/libhilog.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/lib64/libhiion.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libhiion.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/libhiion.so:$(TARGET_COPY_OUT_VENDOR)/lib/libhiion.so
+
diff --git a/self-extractors_hikey960/root/device-vendor.mk b/self-extractors_hikey960/root/device-vendor.mk
index 0dd71234..31f5c3a3 100644
--- a/self-extractors_hikey960/root/device-vendor.mk
+++ b/self-extractors_hikey960/root/device-vendor.mk
@@ -16,4 +16,4 @@
LOCAL_STEM := device-partial.mk
-$(call inherit-product-if-exists, vendor/linaro/hikey960/arm/$(LOCAL_STEM))
+$(call inherit-product-if-exists, vendor/linaro/hikey960/hisilicon/$(LOCAL_STEM))
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index c5edebbd..a356e0b0 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -11,11 +11,24 @@
/dev/ttyAMA1 u:object_r:hci_attach_dev:s0
/dev/ttyAMA4 u:object_r:hci_attach_dev:s0
/dev/hifi_misc u:object_r:audio_device:s0
+/dev/hi_vdec u:object_r:video_device:s0
+/dev/hi_venc u:object_r:video_device:s0
+
+/dev/graphics/fb0 u:object_r:graphics_device:s0
# files in /vendor
/(vendor|system/vendor)/bin/uim u:object_r:hci_attach_exec:s0
/(vendor|system/vendor)/bin/hw/android\.hardware\.bluetooth@1\.0-service\.hikey u:object_r:hal_bluetooth_hikey_exec:s0
/(vendor|system/vendor)/bin/nanoapp_cmd u:object_r:nanoapp_cmd_exec:s0
+/(vendor|system/vendor)/lib(64)?/hw/gralloc\.hikey960\.so u:object_r:same_process_hal_file:s0
+/(vendor|system/vendor)/lib(64)?/hw/gralloc\.hikey\.so u:object_r:same_process_hal_file:s0
+
# /data
/data/vendor/sensor(/.*)? u:object_r:sensor_vendor_data_file:s0
+
+/sys/devices/platform/ddr_devfreq/devfreq/ddr_devfreq/min_freq u:object_r:sysfs_power:s0
+/sys/devices/platform/e82c0000\.mali/devfreq/e82c0000\.mali/min_freq u:object_r:sysfs_power:s0
+
+/dev/block/platform/soc/f723d000\.dwmmc0/by-name/cache u:object_r:cache_block_device:s0
+/dev/block/platform/soc/f723d000\.dwmmc0/by-name/userdata u:object_r:userdata_block_device:s0
diff --git a/sepolicy/hal_graphics_allocator_default.te b/sepolicy/hal_graphics_allocator_default.te
new file mode 100644
index 00000000..b17dc7d4
--- /dev/null
+++ b/sepolicy/hal_graphics_allocator_default.te
@@ -0,0 +1,2 @@
+allow hal_graphics_allocator_default graphics_device:dir search;
+allow hal_graphics_allocator_default graphics_device:chr_file { open read write ioctl map rw_file_perms};
diff --git a/sepolicy/hal_graphics_composer_default.te b/sepolicy/hal_graphics_composer_default.te
new file mode 100644
index 00000000..d7715de2
--- /dev/null
+++ b/sepolicy/hal_graphics_composer_default.te
@@ -0,0 +1,2 @@
+vndbinder_use(hal_graphics_composer_default)
+
diff --git a/sepolicy/healthd.te b/sepolicy/healthd.te
new file mode 100644
index 00000000..d4f839d0
--- /dev/null
+++ b/sepolicy/healthd.te
@@ -0,0 +1 @@
+allow healthd self:capability2 wake_alarm;
diff --git a/sepolicy/init.te b/sepolicy/init.te
index 16d3a3e1..7f18b9b2 100644
--- a/sepolicy/init.te
+++ b/sepolicy/init.te
@@ -4,3 +4,6 @@ allow init configfs:file write;
allow init configfs:lnk_file { create unlink };
# for symlink /sdcard /mnt/sdcard
allow init tmpfs:lnk_file create;
+allow init configfs:lnk_file create;
+
+dontaudit init kernel:system module_request;
diff --git a/sepolicy/netd.te b/sepolicy/netd.te
index 86fe1088..54290ce6 100644
--- a/sepolicy/netd.te
+++ b/sepolicy/netd.te
@@ -1,2 +1,3 @@
# Triggers a sys_module denial, but kernel has CONFIG_MODULES=n.
dontaudit netd self:capability sys_module;
+dontaudit netd kernel:system module_request;
diff --git a/sepolicy/surfaceflinger.te b/sepolicy/surfaceflinger.te
deleted file mode 100644
index f53f2b46..00000000
--- a/sepolicy/surfaceflinger.te
+++ /dev/null
@@ -1 +0,0 @@
-hal_server_domain(surfaceflinger, hal_graphics_allocator)
diff --git a/sepolicy/system_server.te b/sepolicy/system_server.te
new file mode 100644
index 00000000..335bfe33
--- /dev/null
+++ b/sepolicy/system_server.te
@@ -0,0 +1,5 @@
+# TODO(b/73123675): BatterySaver needs access to cpufreq. Remove this access
+# once cpufreq functionality is hidden behind a HAL.
+allow system_server sysfs_devices_system_cpu:file w_file_perms;
+
+dontaudit system_server self:capability sys_module;
diff --git a/ueventd.common.rc b/ueventd.common.rc
index 0a3c7e4b..ff82f70c 100644
--- a/ueventd.common.rc
+++ b/ueventd.common.rc
@@ -9,3 +9,10 @@ subsystem usbmisc
/dev/nanohub 0660 system system
/dev/nanohub_comms 0660 system system
/dev/hifi_misc 0666 system audio
+/dev/hi_vdec 0660 system camera
+/dev/hi_venc 0660 system camera
+/dev/ion 0666 system graphics
+/dev/graphics/fb0 0666 system graphics
+
+/sys/devices/platform/ddr_devfreq/devfreq/ddr_devfreq min_freq 0644 system system
+/sys/devices/platform/e82c0000.mali/devfreq/e82c0000.mali min_freq 0644 system system
diff --git a/vendorsetup.sh b/vendorsetup.sh
deleted file mode 100755
index cef0a194..00000000
--- a/vendorsetup.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Copyright (C) 2013 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 executed by build/envsetup.sh, and can use anything
-# defined in envsetup.sh.
-#
-# In particular, you can add lunch options with the add_lunch_combo
-# function: add_lunch_combo generic-eng
-
-add_lunch_combo hikey-userdebug
-add_lunch_combo hikey64_only-userdebug
-add_lunch_combo hikey960-userdebug
diff --git a/vndk/Android.mk b/vndk/Android.mk
new file mode 100644
index 00000000..b6a4f74d
--- /dev/null
+++ b/vndk/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+
+define add-vndk-sp-lib
+include $$(CLEAR_VARS)
+LOCAL_MODULE := $1.vndk-sp
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_PREBUILT_MODULE_FILE := $$(TARGET_OUT)/lib/$1.so
+LOCAL_MULTILIB := 32
+LOCAL_MODULE_TAGS := optional
+LOCAL_INSTALLED_MODULE_STEM := $1.so
+LOCAL_MODULE_SUFFIX := .so
+LOCAL_MODULE_RELATIVE_PATH := vndk-sp
+include $$(BUILD_PREBUILT)
+
+include $$(CLEAR_VARS)
+LOCAL_MODULE := $1.vndk-sp
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_PREBUILT_MODULE_FILE := $$(TARGET_OUT)/lib64/$1.so
+LOCAL_MULTILIB := 64
+LOCAL_MODULE_TAGS := optional
+LOCAL_INSTALLED_MODULE_STEM := $1.so
+LOCAL_MODULE_SUFFIX := .so
+LOCAL_MODULE_RELATIVE_PATH := vndk-sp
+include $$(BUILD_PREBUILT)
+endef
+
+$(foreach lib,$(VNDK_SP_LIBRARIES),\
+ $(eval $(call add-vndk-sp-lib,$(lib))))