Debian Codegraph @

drivers/dahdi/voicebus/GpakCust.h

raw symbols SCIP
1 /*
2 * Copyright (c) 2005, Adaptive Digital Technologies, Inc.
3 *
4 * File Name: GpakCust.h
5 *
6 * Description:
7 * This file contains host system dependent definitions and prototypes of
8 * functions to support generic G.PAK API functions. The file is used when
9 * integrating G.PAK API functions in a specific host processor environment.
10 *
11 * Note: This file may need to be modified by the G.PAK system integrator.
12 *
13 * Version: 1.0
14 *
15 * Revision History:
16 * 06/15/05 - Initial release.
17 *
18 * This program has been released under the terms of the GPL version 2 by
19 * permission of Adaptive Digital Technologies, Inc.
20 *
21 */
22
23 /*
24 * See http://www.asterisk.org for more information about
25 * the Asterisk project. Please do not directly contact
26 * any of the maintainers of this project for assistance;
27 * the project provides a web site, mailing lists and IRC
28 * channels for your use.
29 *
30 * This program is free software, distributed under the terms of
31 * the GNU General Public License Version 2 as published by the
32 * Free Software Foundation. See the LICENSE file included with
33 * this program for more details.
34 */
35
36 #ifndef _GPAKCUST_H /* prevent multiple inclusion */
37 #define _GPAKCUST_H
38
39 #include <linux/module.h>
40 #include <linux/device.h>
41 #include <linux/completion.h>
42 #include <linux/workqueue.h>
43 #include <linux/delay.h>
44 #include <linux/version.h>
45 #include <linux/semaphore.h>
46
47 #include "gpakenum.h"
48 #include "adt_lec.h"
49
50 #define DEBUG_VPMADT032_ECHOCAN (1 << 4)
51
52 /* Host and DSP system dependent related definitions. */
53 #define MAX_DSP_CORES 128 /* maximum number of DSP cores */
54 #define MAX_CHANNELS 32 /* maximum number of channels */
55 #define MAX_WAIT_LOOPS 50 /* max number of wait delay loops */
56 #define DSP_IFBLK_ADDRESS 0x0100 /* DSP address of I/F block pointer */
57 #define DOWNLOAD_BLOCK_SIZE 512 /* download block size (DSP words) */
58
59 #define VPM150M_MAX_COMMANDS 8
60
61 #define __VPM150M_RWPAGE (1 << 4)
62 #define __VPM150M_RD (1 << 3)
63 #define __VPM150M_WR (1 << 2)
64 #define __VPM150M_FIN (1 << 1)
65 #define __VPM150M_TX (1 << 0)
66 #define __VPM150M_RWPAGE (1 << 4)
67 #define __VPM150M_RD (1 << 3)
68 #define __VPM150M_WR (1 << 2)
69 #define __VPM150M_FIN (1 << 1)
70 #define __VPM150M_TX (1 << 0)
71
72 /* Some Bit ops for different operations */
73 #define VPM150M_HPIRESET 1
74 #define VPM150M_SWRESET 2
75 #define VPM150M_ACTIVE 4
76
77 #define NLPTYPE_NONE 0
78 #define NLPTYPE_MUTE 1
79 #define NLPTYPE_RANDOM_NOISE 2
80 #define HOTH_NOISE_NLPTYPE 3
81 #define NLPTYPE_SUPPRESS 4
82 #define NLPTYPE_RESERVED 5
83 #define NLPTYPE_AUTOSUPPRESS 6
84 #define DEFAULT_NLPTYPE NLPTYPE_AUTOSUPPRESS
85
86 /* This is the threshold (in dB) for enabling and disabling of the NLP */
87 #define DEFAULT_NLPTHRESH 22
88 #define DEFAULT_NLPMAXSUPP 10
89
90 struct vpmadt032_cmd {
91 struct list_head node;
92 __le32 address;
93 __le16 data;
94 u8 desc;
95 u8 txident;
96 struct completion complete;
97 };
98
99 /* Contains the options used when initializing the vpmadt032 module */
100 struct vpmadt032_options {
101 int vpmnlptype;
102 int vpmnlpthresh;
103 int vpmnlpmaxsupp;
104 u32 debug;
105 u32 channels;
106 };
107
108 struct GpakChannelConfig;
109
110 struct vpmadt032 {
111 struct voicebus *vb;
112 struct work_struct work;
113 struct workqueue_struct *wq;
114 int dspid;
115 struct semaphore sem;
116 unsigned long control;
117 unsigned char curpage;
118 unsigned short version;
119 struct adt_lec_params curecstate[MAX_CHANNELS];
120 spinlock_t change_list_lock;
121 struct list_head change_list;
122 spinlock_t list_lock;
123 /* Commands that are waiting to be processed. */
124 struct list_head pending_cmds;
125 /* Commands that are currently in progress by the VPM module */
126 struct list_head active_cmds;
127 struct vpmadt032_options options;
128 void (*setchanconfig_from_state)(struct vpmadt032 *vpm, int channel, struct GpakChannelConfig *chanconfig);
129 };
130
131 struct voicebus;
132 struct dahdi_chan;
133 struct dahdi_echocanparams;
134 struct dahdi_echocanparam;
135 struct dahdi_echocan_state;
136
137 char vpmadt032tone_to_zaptone(GpakToneCodes_t tone);
138 int vpmadt032_test(struct vpmadt032 *vpm, struct voicebus *vb);
139 int vpmadt032_init(struct vpmadt032 *vpm);
140 int vpmadt032_reset(struct vpmadt032 *vpm);
141 struct vpmadt032 *vpmadt032_alloc(struct vpmadt032_options *options);
142 void vpmadt032_free(struct vpmadt032 *vpm);
143 int vpmadt032_echocan_create(struct vpmadt032 *vpm, int channo,
144 enum adt_companding companding,
145 struct dahdi_echocanparams *ecp,
146 struct dahdi_echocanparam *p);
147 void vpmadt032_echocan_free(struct vpmadt032 *vpm, int channo,
148 struct dahdi_echocan_state *ec);
149
150 struct GpakEcanParms;
151 void vpmadt032_get_default_parameters(struct GpakEcanParms *p);
152
153 /* If there is a command ready to go to the VPMADT032, return it, otherwise
154 * NULL. Call with local interrupts disabled. */
155 static inline struct vpmadt032_cmd *vpmadt032_get_ready_cmd(struct vpmadt032 *vpm)
156 {
157 struct vpmadt032_cmd *cmd;
158
159 spin_lock(&vpm->list_lock);
160 if (list_empty(&vpm->pending_cmds)) {
161 spin_unlock(&vpm->list_lock);
162 return NULL;
163 }
164 cmd = list_entry(vpm->pending_cmds.next, struct vpmadt032_cmd, node);
165 list_move_tail(&cmd->node, &vpm->active_cmds);
166 spin_unlock(&vpm->list_lock);
167 return cmd;
168 }
169
170 /**
171 * call with local interrupts disabled.
172 */
173 static inline void vpmadt032_resend(struct vpmadt032 *vpm)
174 {
175 struct vpmadt032_cmd *cmd, *temp;
176
177 /* By moving the commands back to the pending list, they will be
178 * transmitted when room is available */
179 spin_lock(&vpm->list_lock);
180 list_for_each_entry_safe(cmd, temp, &vpm->active_cmds, node) {
181 cmd->desc &= ~(__VPM150M_TX);
182 list_move_tail(&cmd->node, &vpm->pending_cmds);
183 }
184 spin_unlock(&vpm->list_lock);
185 }
186
187
188 typedef __u16 DSP_WORD; /* 16 bit DSP word */
189 typedef __u32 DSP_ADDRESS; /* 32 bit DSP address */
190 typedef __u32 GPAK_FILE_ID; /* G.PAK Download file identifier */
191
192 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
193 * gpakReadDspMemory - Read DSP memory.
194 *
195 * FUNCTION
196 * This function reads a contiguous block of words from DSP memory starting at
197 * the specified address.
198 *
199 * RETURNS
200 * nothing
201 *
202 */
203 extern void gpakReadDspMemory(
204 unsigned short int DspId, /* DSP Identifier (0 to MAX_DSP_CORES-1) */
205 DSP_ADDRESS DspAddress, /* DSP's memory address of first word */
206 unsigned int NumWords, /* number of contiguous words to read */
207 DSP_WORD *pWordValues /* pointer to array of word values variable */
208 );
209
210
211 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
212 * gpakWriteDspMemory - Write DSP memory.
213 *
214 * FUNCTION
215 * This function writes a contiguous block of words to DSP memory starting at
216 * the specified address.
217 *
218 * RETURNS
219 * nothing
220 *
221 */
222 extern void gpakWriteDspMemory(
223 unsigned short int DspId, /* DSP Identifier (0 to MAX_DSP_CORES-1) */
224 DSP_ADDRESS DspAddress, /* DSP's memory address of first word */
225 unsigned int NumWords, /* number of contiguous words to write */
226 DSP_WORD *pWordValues /* pointer to array of word values to write */
227 );
228
229
230 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
231 * gpakHostDelay - Delay for a fixed time interval.
232 *
233 * FUNCTION
234 * This function delays for a fixed time interval before returning. The time
235 * interval is the Host Port Interface sampling period when polling a DSP for
236 * replies to command messages.
237 *
238 * RETURNS
239 * nothing
240 *
241 */
242 extern void gpakHostDelay(void);
243
244
245 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
246 * gpakLockAccess - Lock access to the specified DSP.
247 *
248 * FUNCTION
249 * This function aquires exclusive access to the specified DSP.
250 *
251 * RETURNS
252 * nothing
253 *
254 */
255 extern void gpakLockAccess(
256 unsigned short int DspId /* DSP Identifier (0 to MAX_DSP_CORES-1) */
257 );
258
259 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
260 * gpakUnlockAccess - Unlock access to the specified DSP.
261 *
262 * FUNCTION
263 * This function releases exclusive access to the specified DSP.
264 *
265 * RETURNS
266 * nothing
267 *
268 */
269 extern void gpakUnlockAccess(
270 unsigned short int DspId /* DSP Identifier (0 to MAX_DSP_CORES-1) */
271 );
272
273 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
274 * gpakReadFile - Read a block of bytes from a G.PAK Download file.
275 *
276 * FUNCTION
277 * This function reads a contiguous block of bytes from a G.PAK Download file
278 * starting at the current file position.
279 *
280 * RETURNS
281 * The number of bytes read from the file.
282 * -1 indicates an error occurred.
283 * 0 indicates all bytes have been read (end of file)
284 *
285 */
286 extern int gpakReadFile(
287 GPAK_FILE_ID FileId, /* G.PAK Download File Identifier */
288 unsigned char *pBuffer, /* pointer to buffer for storing bytes */
289 unsigned int NumBytes /* number of bytes to read */
290 );
291
292
293 #endif /* prevent multiple inclusion */
294
295