PASDK-218: Added comments to mark unused members of the device extension structure.
[processor-sdk/performance-audio-sr.git] / pasdk / test_dsp / sap / sap.h
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 //
37 //
38 // Header file for sap SIO driver.
39 //
40 //
41 //
42 #define SAP_DMA_EDMA
43 #define SAP_PORT_MCASP
45 #ifndef SAP_H
46 #define SAP_H
48 #include <ti/xdais/xdas.h>
49 #include <xdc/std.h>
50 #include <xdc/cfg/global.h>
51 #include <xdc/runtime/Memory.h>
52 #include <xdc/runtime/IHeap.h>
53 #include <ti/sysbios/heaps/HeapMem.h>
54 #include <ti/sysbios/hal/Cache.h>
56 #include <xdc/runtime/Log.h>
57 #include <xdc/runtime/System.h>
59 #include <ti/sysbios/knl/Clock.h>
60 #include <ti/sysbios/knl/Task.h>
61 #include <ti/sysbios/knl/Semaphore.h>
62 #include <ti/sysbios/knl/Queue.h>
63 #include <ti/sysbios/hal/Hwi.h>
64 #include <xdc/runtime/Error.h>
66 #include <dev2.h>
68 // include sap_mcasp here although not needed locally, but allows user code
69 // (i.e. sap_xx.c) to include just sap.h and not require other includes; like csl.
70 #ifdef SAP_PORT_MCASP
71 #include "sap_csl_mcasp.h"
72 #endif
74 #include <pafsio.h>
76 #define SAP_NAME "/DAP"
77 //#define SAP_NAME "/SAP"
79 #define MAX_SAP_DEVICES     32  // Must be >= total number input and output devices
80                                 // For example, from project *io_a.h file:
81                                 //     total devices = DEVINP_N + DEVOUT_N
83 // ..........................................................................
84 // Global context for the SAP layer
86 typedef struct SAP_DriverObject
87 {
88     DEV2_Handle    device[MAX_SAP_DEVICES];
90     Uint16         numDevices;
91     Uint16         unused[3];
93 } SAP_DriverObject;
95 extern SAP_DriverObject sapDrv;
97 // ..........................................................................
98 // device configuration structure -- used as argument to SIO_ctrl
100 struct SAP_Params_
102     XDAS_Int32  pinMask;
103 };
105 typedef struct SAP_Params
107     Int                 size;   // Type-specific size
108     struct DXX_Params_  sio;    // Common parameters
109     struct SAP_Params_  sap;    // Driver parameters
110 } SAP_Params;
112 // .............................................................................
113 // DMA Function table defs
115 typedef Int  (*SAP_DMA_TsetupParam)(DEV2_Handle, XDAS_UInt32, XDAS_UInt32, unsigned int, unsigned int);
116 typedef Int  (*SAP_DMA_TsetupXfer)(DEV2_Handle, XDAS_UInt32, XDAS_UInt32, XDAS_UInt32, DEV2_Frame *);
118 typedef struct SAP_DMA_Fxns {
119     SAP_DMA_TsetupParam     setupParam;
120     SAP_DMA_TsetupXfer      setupXfer;
121 } SAP_DMA_Fxns;
123 #define SAP_DMA_FTABLE_setupParam(_a,_b,_c,_d,_e)      (*pDevExt->pFxns->pDmaFxns->setupParam)(_a,_b,_c,_d,_e)
124 #define SAP_DMA_FTABLE_setupXfer(_a,_b,_c,_d,_e)        (*pDevExt->pFxns->pDmaFxns->setupXfer(_a,_b,_c,_d,_e)
126 // .............................................................................
127 // PORT Function table defs
129 typedef Int      (*SAP_PORT_Talloc)(DEV2_Handle);
130 typedef Int      (*SAP_PORT_Tclose)(DEV2_Handle);
131 typedef Int      (*SAP_PORT_Tenable)(DEV2_Handle);
132 typedef Void     (*SAP_PORT_Tinit)(Void);
133 typedef Int      (*SAP_PORT_Topen)(DEV2_Handle);
134 typedef Int      (*SAP_PORT_Treset)(DEV2_Handle);
135 typedef Int      (*SAP_PORT_TwatchDog)(DEV2_Handle);
137 typedef struct SAP_PORT_Fxns {    
138     SAP_PORT_Talloc      alloc;
139     SAP_PORT_Tclose      close;
140     SAP_PORT_Tenable     enable;
141     SAP_PORT_Tinit       init;
142     SAP_PORT_Topen       open;
143     SAP_PORT_Treset      reset;
144     SAP_PORT_TwatchDog   watchDog;
145 } SAP_PORT_Fxns;
147 #define SAP_PORT_FTABLE_alloc(_a)        (*pDevExt->pFxns->pPortFxns->alloc)(_a)
148 #define SAP_PORT_FTABLE_close(_a)        (*pDevExt->pFxns->pPortFxns->close)(_a)
149 #define SAP_PORT_FTABLE_enable(_a)       (*pDevExt->pFxns->pPortFxns->enable)(_a)
150 #define SAP_PORT_FTABLE_init()           (*pFxns->pPortFxns->init)()
151 #define SAP_PORT_FTABLE_open(_a)         (*pDevExt->pFxns->pPortFxns->open)(_a)
152 #define SAP_PORT_FTABLE_reset(_a)        (*pDevExt->pFxns->pPortFxns->reset)(_a)
153 #define SAP_PORT_FTABLE_watchDog(_a)     (*pDevExt->pFxns->pPortFxns->watchDog)(_a)
155 // .............................................................................
156 // SAP Function table defs
158 typedef Int     (*SAP_Tshutdown)(DEV2_Handle);
159 typedef Int     (*SAP_Tstart)(DEV2_Handle);
160 typedef Int     (*SAP_Tconfig)(DEV2_Handle, const SAP_Params *);
162 typedef struct SAP_Fxns {
163     //common (must be same as DEV_Fxns)
164     DEV2_Tclose         close;
165     DEV2_Tctrl          ctrl;
166     DEV2_Tidle          idle;
167     DEV2_Tissue         issue;
168     DEV2_Topen          open;
169     DEV2_Tready         ready;
170     DEV2_Treclaim       reclaim; //optional
172     //SAP specific
173     SAP_Tshutdown       shutdown;
174     SAP_Tstart          start;
175     SAP_Tconfig         config;
177     SAP_PORT_Fxns       *pPortFxns;
178     SAP_DMA_Fxns        *pDmaFxns;
180 } SAP_Fxns;
182 extern SAP_Fxns SAP_FXNS;
183 extern Void SAP_init (void);     
184 extern Void SAP_watchDog (void); 
186 // macros assume pDevExt is available and pDevExt->pFxns is valid
187 #define SAP_FTABLE_shutdown(_a)          (*pDevExt->pFxns->shutdown)(_a)
188 #define SAP_FTABLE_start(_a)             (*pDevExt->pFxns->start)(_a)
189 #define SAP_FTABLE_config(_a,_b)         (*pDevExt->pFxns->config)(_a,_b)
190 #define SAP_FTABLE_ctrl(_a,_b,_c)        (*pDevExt->pFxns->ctrl)(_a,_b,_c)
192 // .............................................................................
194 typedef struct SAP_EDMA_Param
196         Queue_Elem              link;    // queue link
197     XDAS_UInt32         hEdmaParam;  // parameter table handle
198 } SAP_EDMA_Param;
200 // .............................................................................
202 #define MAX_EDMA_PARAM_ENTRIES 16 /* minimum is 2 */
204 // device extension (device specific context).
206 typedef struct SAP_DeviceExtension
208     DEV2_Handle   device;
210     XDAS_Int8    numQueued;
211     XDAS_Int8    errorState;
212     XDAS_Int8    runState;
213     XDAS_Int8    deviceNum;
215     Semaphore_Handle   sync;
216     Queue_Struct      xferQue;
218     SAP_Fxns     *pFxns;
219     const SAP_Params   *pParams;
221     XDAS_UInt32 firstTCC;
223     Queue_Struct      paramQue;
224     Semaphore_Handle  ready;            //unused - remove me
225     XDAS_Int8   numEdmaParams;
227     XDAS_Int32          edmaWordSize;
228     XDAS_UInt32         shortTCC;       //unused - remove me
229     XDAS_UInt32         shortEdma;      //unused - remove me
230     XDAS_Int8                   shutDown;
232     XDAS_UInt32         activeEdma;
233     XDAS_UInt32         errorEdma;
235     Uint16  numSers;
236     Uint16  numSlots;
238     Void  *pPortExt; // unused for now
239     Void  *pDmaExt;
241     SAP_EDMA_Param    edmaParams[MAX_EDMA_PARAM_ENTRIES];
243     Int    optLevel;
244     Int    numParamSetup;
246 } SAP_DeviceExtension;
248 // .............................................................................
250 #endif // SAP_H