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