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