hikey960: HiFi3 host side XAF framework
Xtensa Audio Framework in user space to offload audio tasks to HiFi3 DSP.
It provides few API's to invoke DSP and to perform ogg audio decoding,
post processing (PCM Gain) as well it provides adb shell-based
"xaf-dec-test" and "xaf-dec-mix-test" binaries to perform pcm and ogg
file playback
Change-Id: I77ac3b56d4141f41e06f0d0eac4ac3a8ee567e8d
Signed-off-by: Niranjan Yadla <nyadla@cadence.com>
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 0000000..fb90267
--- /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 */