]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/audio-preprocessing.git/blob - file_demo_bios/am572x/components/sys.h
update the demo directory path
[processor-sdk/audio-preprocessing.git] / file_demo_bios / am572x / components / sys.h
1 /* \r
2   sys.h: System constants, data types, prototypes.\r
3 */\r
4 #ifndef _SYS_H\r
5 #define _SYS_H\r
6 \r
7 #include <xdc/std.h>                /* required for types.h */\r
8 #include <ti/mas/types/types.h>\r
9 #include <ti/mas/util/ecomem.h>\r
10 \r
11 /*======================================================================\r
12  * Static system configuration parameters\r
13  *======================================================================*/\r
14 \r
15 #define SYS_MICS_MAX          8       /* Maximum number of microphones in the system */\r
16 #define SYS_VMICS_MAX         12      /* Maximum number of virtual microphones in the system */\r
17 #define SYS_FS_HZ             16000   /* Sampling rate in Hz */\r
18 #define SYS_FRAME_DURATION_MS 10      /* Frame duration in ms */\r
19 #define SYS_FRAME_LENGTH      (1L*SYS_FS_HZ*SYS_FRAME_DURATION_MS/1000)             /* Frame length in samples */\r
20 #define SYS_FRAME_SIZE        (TYP_LINSAMPLE_SIZE*SYS_FRAME_LENGTH/TYP_TWORD_SIZE)  /* Frame size in bytes */\r
21 #define SYS_IN_LENGTH         (2L*SYS_FRAME_LENGTH*SYS_MICS_MAX)                    /* Input buffer length (dual) */\r
22 #define SYS_IN_SIZE           (TYP_LINSAMPLE_SIZE*SYS_IN_LENGTH/TYP_TWORD_SIZE)     /* # of words in input buffer */\r
23 \r
24 /*======================================================================\r
25  * Bit masks, bit-mask handling macros, error codes\r
26  *======================================================================*/\r
27 \r
28 /* Bit masks for sysPrintConfig */\r
29 #define SYSM_SCOPE_STATIC   0x1     /* Static system information */\r
30 #define SYSM_SCOPE_DYNAMIC  0x2     /* Dynamic system onfirmation */\r
31 \r
32 /* Macros for bit-mask manipulations */\r
33 #define SYS_MASK_GET(value,mask)    ((value)&(mask))\r
34 #define SYS_MASK_SET(value,mask)    ((value)|(mask))\r
35 #define SYS_MASK_TEST(value,mask)   (SYS_MASK_GET(value,mask)!=0)\r
36 \r
37 /* System error codes */\r
38 #define SYS_ERR_SUCCESS       0\r
39 #define SYS_ERR_BADCONFIG     (-1)\r
40 #define SYS_INV_HANDLE        (-2)\r
41 #define SYS_INV_LOGIC         (-3)\r
42 #define SYS_ERR_BUFLENGTH     (-4)\r
43 #define SYS_ERR_FOPEN         (-5)\r
44 #define SYS_ERR_FLOAD         (-6)\r
45 #define SYS_ERR_FMAXBUF       (-7)\r
46 #define SYS_ERR_FREAD         (-8)\r
47 #define SYS_ERR_HEAPINIT      (-9)\r
48 #define SYS_ERR_INVHEAPCLASS  (-10)\r
49 #define SYS_ERR_BFERROR       (-11)\r
50 #define SYS_ERR_EOF           (-12)\r
51 #define SYS_ERR_ASNRERROR     (-13)\r
52 #define SYS_ERR_MSSERROR      (-14)\r
53 #define SYS_ERR_MSSDEBUG      (-15)\r
54 #define SYS_ERR_ANGLECONFIG   (-16)\r
55 #define SYS_ERR_VAUERROR      (-17)\r
56 \r
57 /*======================================================================\r
58  * System Data Types\r
59  *======================================================================*/\r
60 \r
61 /* System Configuration Structure */\r
62 struct sysConfig_stc {\r
63   tint  nmics;        /* The actual number of microphones in ths system */\r
64   tint  nvmics;       /* The acutal number of virtual microphones in the system */\r
65   tbool use_fileio;   /* Use file I/O to load microphone files */\r
66   tbool use_default;  /* Use default angles for virtual microphones */\r
67 };\r
68 typedef struct sysConfig_stc sysConfig_t;\r
69 \r
70 /* System Context Structure */\r
71 struct sysContext_stc {\r
72   tint  nmics;    /* The actual number of microphones in ths system */\r
73   tint  nvmics;   /* The acutal number of virtual microphones in the system */\r
74 \r
75   /* heap handles (point to head header) */\r
76   void *heapEP;\r
77   void *heapES;\r
78   void *heapIP;\r
79   void *heapIS;\r
80 \r
81   /* used heap */\r
82   tulong heapEP_used;     /* how many used in words */\r
83   tulong heapES_used;\r
84   tulong heapIP_used;\r
85   tulong heapIS_used;\r
86 \r
87   /* Mic input buffer */\r
88   /* This is a dual buffer. Each part has SYS_FRAME_LENGTH*SYS_MICS_MAX samples\r
89    * to accomodate all microphone inputs. The samples are written contiguously\r
90    * without any gaps. Channel after channel.\r
91    */\r
92   void *in_w;     /* Mic input buffer being written to */\r
93   void *in_r;     /* Mic input buffer being read from */\r
94   void *in_lo;    /* Low part of mic input buffer */\r
95   void *in_hi;    /* High part of mic input buffer */\r
96 \r
97   linSample *vmicfrm[SYS_VMICS_MAX];  /* Virtual mic frames */\r
98 \r
99   /* Instance pointers */\r
100   void *bfInst_p[SYS_VMICS_MAX];      /* beamformer instance pointers */\r
101   void *asnrInst_p[SYS_VMICS_MAX];    /* ASNR instance pointers */\r
102   void *mssInst_p;                    /* MSS instance pointer */\r
103   void *vauInst_p;                    /* VAU instance pointer */\r
104 \r
105   tint vmicangles[SYS_VMICS_MAX];     /* use SYS_BF_ANGLE_xxx from sysbfflt.h */\r
106 \r
107   tbool use_fileio;   /* Use file I/O to load microphone files */\r
108   tbool eof;          /* End of file reached */\r
109   tbool use_default;  /* Use default vmic angles (4,6,8,12 vmics supported only) */\r
110 };\r
111 typedef struct sysContext_stc  sysContext_t;\r
112 \r
113 /*======================================================================\r
114  * Global variable declarations\r
115  *======================================================================*/\r
116 \r
117 extern sysContext_t sysContext;         /* Defined in sys.c */\r
118 extern tint         sysBfVMicAngles[];  /* Defined in sys.c */\r
119 \r
120 /* Buffer descriptor array for memory allocations */\r
121 #define SYS_COMP_MAXBUFS    10\r
122 extern ecomemBuffer_t sysCompBufs[];\r
123 \r
124 /*======================================================================\r
125  * Additional Macros\r
126  *======================================================================*/\r
127 \r
128 /* Misc macros */\r
129 #define SYS_CHECK_ERROR(err)    if((err)<0){sysError(err);}\r
130 \r
131 /*======================================================================\r
132  * API Prototypes\r
133  *======================================================================*/\r
134 \r
135 /* sys.c */\r
136 extern int  sysCreate(sysConfig_t*);              /* Initialize system context */\r
137 extern void sysError(int);                        /* Printf error code and exit */\r
138 extern int  sysHeapAlloc(void*, tint);            /* Allocate from appropriate heap */\r
139 extern int  sysHeapAllocAll(tint, void*, const void*);  /* Allocate ALL buffers */\r
140 extern int  sysPrintConfig(tuint);                /* Print system configuration */\r
141 \r
142 /* sysbf.c */\r
143 extern void sysBfCreate(void);        /* Create all active beamformers */\r
144 \r
145 /* sysasnr.c */\r
146 extern void sysAsnrCreate(void);      /* Create all active ASNR's */\r
147 \r
148 /* sysmss.c */\r
149 extern void sysMssCreate(void);       /* Create the MSS module */\r
150 \r
151 /* sysvau.c */\r
152 extern void sysVauCreate(void);       /* Create the VAU module */\r
153 \r
154 #endif\r
155 /* nothing past this point */\r
156 \r