PASDK69: Created task for idleAudioStream(). Added MAT-THD alpha header file.
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / framework / itopo / system.c
2 /*
3 Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without 
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 #include <xdc/std.h>
37 #include <xdc/cfg/global.h>
38 #include <xdc/runtime/Log.h>
39 #include <xdc/runtime/System.h>
40 #include <ti/sysbios/knl/Clock.h>
42 #include <paftyp.h>
43 #include <pafsys_a.h> 
44 #include "noasp.h"
45 #include "systemStream.h"
47 #define SYSTEM_STREAM_PROC_INTERVAL 1000
49 const struct {
50     PAF_SST_FxnsMain *main;
51     Int count;
52     struct {
53         PAF_SST_FxnsCompute  *compute;
54         PAF_SST_FxnsTransmit *transmit;
55     } sub[5];
56 } systemStreamPrimaryFxns =
57 {
58     &systemStreamMain,
59     5,
60     {
61         { &systemStream1Compute, &systemStream1Transmit, },
62 #ifndef NOBM
63         { &systemStream2Compute, &systemStream2Transmit, },
64 #endif        
65 #ifndef NODEM
66         { &systemStream3Compute, &systemStream3Transmit, },
67 #endif        
68 #ifdef THX
69         { &systemStream4Compute, &systemStream4Transmit, },
70 #else
71         { NULL, NULL, },
72 #endif
73         { &systemStream5Compute, &systemStream5Transmit, },
74     },
75 };
77 const PAF_SST_Params systemStreamParams_PA[1] =
78 {
79     {
80         1, 0, 1, 1,
81         (const PAF_SST_Fxns *)&systemStreamPrimaryFxns,
82     },
83 };
85 #define systemStreamParams systemStreamParams_PA
87 PAF_SystemStatus systemStreamStatus[1] = {
88     {
89         sizeof (PAF_SystemStatus),
90         PAF_SYS_MODE_ALL,
91         0,
92         PAF_SYS_RECREATIONMODE_AUTO,
93         2 + PAF_SYS_SPEAKERSIZE_SMALL,
94         1 + PAF_SYS_SPEAKERSIZE_SMALL,
95         2 + PAF_SYS_SPEAKERSIZE_SMALL,
96         2 + PAF_SYS_SPEAKERSIZE_SMALL,
97         1 + PAF_SYS_SPEAKERSIZE_BASS,
98         PAF_SYS_CCRTYPE_STANDARD,       // channelConfigurationRequestType
99         0, 0, 0,                        // switchImage, imageNum, imageNumMax
100         0,                              // Unused
101         0, 0,                           // cpuLoad, peakCpuLoad
102         0, 0, 0, 0,                     // speakerWide, speakerHead, unused[2]
103         0, 0, 0, 0,                     //unused2[4]
104         PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,
105     },
106 };
108 PAF_SST_Config systemStreamConfig[1] =
110     {
111         NULL,
112         &systemStreamStatus[0],
113     },
114 };
117 extern Int gSysInit;
119 /*
120  *  ======== taskSystemStreamFxn ========
121  *  IDLE function for audio stream
122  */
123 Void taskSystemStreamFxn()
125     Int32 i;
126     Uns time, interval, elapsed, now, then;
128     //System_printf("Enter idleAudioStream()\n");    
129     //Log_info0("Enter idleAudioStream()");
131     time = SYSTEM_STREAM_PROC_INTERVAL;
133     while (1)
134     {
135         // Compute interval in system clock ticks,
136         // interval time expressed in msec.
137         interval = time * USEC_PER_MSEC / Clock_tickPeriod;
139         // Compute elapsed time
140         now = Clock_getTicks();
141         elapsed = now - then;
142         then = now;
144         if (interval > elapsed)
145         {
146             Task_sleep(interval - elapsed);
147         }
149         //if (gSysInit == 0)
150         //  return;
152         for (i=0; i < lengthof(systemStreamConfig); i++)
153             systemStreamParams[i].fxns->main
154                 (&systemStreamParams[i], &systemStreamConfig[i]);
156         gSysInit = 1;  // Indicate system Init to resume
158     }