1
2
3
4
5
6
7
8
9
10
11#define DEBUG_DSP_CTRL 0x0001
12#define DEBUG_DSP_CORE 0x0002
13#define DEBUG_DSP_DTMF 0x0004
14#define DEBUG_DSP_CMX 0x0010
15#define DEBUG_DSP_TONE 0x0020
16#define DEBUG_DSP_BLOWFISH 0x0040
17#define DEBUG_DSP_DELAY 0x0100
18#define DEBUG_DSP_CLOCK 0x0200
19#define DEBUG_DSP_DTMFCOEFF 0x8000
20
21
22
23
24
25
26
27#define DSP_OPT_ULAW (1 << 0)
28#define DSP_OPT_NOHARDWARE (1 << 1)
29
30#include <linux/timer.h>
31#include <linux/workqueue.h>
32
33#include "dsp_ecdis.h"
34
35extern int dsp_options;
36extern int dsp_debug;
37extern int dsp_poll;
38extern int dsp_tics;
39extern spinlock_t dsp_lock;
40extern struct work_struct dsp_workq;
41extern u32 dsp_poll_diff;
42
43
44
45
46
47extern s32 dsp_audio_alaw_to_s32[256];
48extern s32 dsp_audio_ulaw_to_s32[256];
49extern s32 *dsp_audio_law_to_s32;
50extern u8 dsp_audio_s16_to_law[65536];
51extern u8 dsp_audio_alaw_to_ulaw[256];
52extern u8 dsp_audio_mix_law[65536];
53extern u8 dsp_audio_seven2law[128];
54extern u8 dsp_audio_law2seven[256];
55extern void dsp_audio_generate_law_tables(void);
56extern void dsp_audio_generate_s2law_table(void);
57extern void dsp_audio_generate_seven(void);
58extern void dsp_audio_generate_mix_table(void);
59extern void dsp_audio_generate_ulaw_samples(void);
60extern void dsp_audio_generate_volume_changes(void);
61extern u8 dsp_silence;
62
63
64
65
66
67
68#define MAX_POLL 256
69
70#define CMX_BUFF_SIZE 0x8000
71#define CMX_BUFF_HALF 0x4000
72#define CMX_BUFF_MASK 0x7fff
73
74
75
76#define MAX_SECONDS_JITTER_CHECK 5
77
78extern struct timer_list dsp_spl_tl;
79
80
81extern unsigned long dsp_spl_jiffies;
82
83
84
85
86
87
88
89
90
91
92struct dsp;
93struct dsp_conf_member {
94 struct list_head list;
95 struct dsp *dsp;
96};
97
98
99struct dsp_conf {
100 struct list_head list;
101 u32 id;
102
103
104 struct list_head mlist;
105 int software;
106 int hardware;
107
108};
109
110
111
112
113
114
115#define DSP_DTMF_NPOINTS 102
116
117#define ECHOCAN_BUFF_SIZE 0x400
118#define ECHOCAN_BUFF_MASK 0x3ff
119
120struct dsp_dtmf {
121 int enable;
122 int treshold;
123 int software;
124 int hardware;
125 int size;
126 signed short buffer[DSP_DTMF_NPOINTS];
127
128 u8 lastwhat, lastdigit;
129 int count;
130 u8 digits[16];
131};
132
133
134
135
136
137struct dsp_pipeline {
138 rwlock_t lock;
139 struct list_head list;
140 int inuse;
141};
142
143
144
145
146
147struct dsp_tone {
148 int software;
149 int hardware;
150 int tone;
151 void *pattern;
152 int count;
153 int index;
154 struct timer_list tl;
155};
156
157
158
159
160
161struct dsp_echo {
162 int software;
163 int hardware;
164};
165
166
167
168
169
170struct dsp {
171 struct list_head list;
172 struct mISDNchannel ch;
173 struct mISDNchannel *up;
174 unsigned char name[64];
175 int b_active;
176 struct dsp_echo echo;
177 int rx_disabled;
178 int rx_is_off;
179 int tx_mix;
180 struct dsp_tone tone;
181 struct dsp_dtmf dtmf;
182 int tx_volume, rx_volume;
183
184
185 struct work_struct workq;
186 struct sk_buff_head sendq;
187 int hdlc;
188 int data_pending;
189
190
191 u32 conf_id;
192 struct dsp_conf *conf;
193 struct dsp_conf_member
194 *member;
195
196
197 int rx_W;
198 int rx_R;
199 int rx_init;
200 int tx_W;
201 int tx_R;
202 int rx_delay[MAX_SECONDS_JITTER_CHECK];
203 int tx_delay[MAX_SECONDS_JITTER_CHECK];
204 u8 tx_buff[CMX_BUFF_SIZE];
205 u8 rx_buff[CMX_BUFF_SIZE];
206 int last_tx;
207 int cmx_delay;
208
209 int tx_dejitter;
210 int tx_data;
211
212
213 struct dsp_features features;
214 int features_rx_off;
215 int features_fill_empty;
216 int pcm_slot_rx;
217 int pcm_bank_rx;
218 int pcm_slot_tx;
219 int pcm_bank_tx;
220 int hfc_conf;
221
222
223 int bf_enable;
224 u32 bf_p[18];
225 u32 bf_s[1024];
226 int bf_crypt_pos;
227 u8 bf_data_in[9];
228 u8 bf_crypt_out[9];
229 int bf_decrypt_in_pos;
230 int bf_decrypt_out_pos;
231 u8 bf_crypt_inring[16];
232 u8 bf_data_out[9];
233 int bf_sync;
234
235 struct dsp_pipeline
236 pipeline;
237};
238
239
240
241extern void dsp_change_volume(struct sk_buff *skb, int volume);
242
243extern struct list_head dsp_ilist;
244extern struct list_head conf_ilist;
245extern void dsp_cmx_debug(struct dsp *dsp);
246extern void dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp);
247extern int dsp_cmx_conf(struct dsp *dsp, u32 conf_id);
248extern void dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb);
249extern void dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb);
250extern void dsp_cmx_send(void *arg);
251extern void dsp_cmx_transmit(struct dsp *dsp, struct sk_buff *skb);
252extern int dsp_cmx_del_conf_member(struct dsp *dsp);
253extern int dsp_cmx_del_conf(struct dsp_conf *conf);
254
255extern void dsp_dtmf_goertzel_init(struct dsp *dsp);
256extern void dsp_dtmf_hardware(struct dsp *dsp);
257extern u8 *dsp_dtmf_goertzel_decode(struct dsp *dsp, u8 *data, int len,
258 int fmt);
259
260extern int dsp_tone(struct dsp *dsp, int tone);
261extern void dsp_tone_copy(struct dsp *dsp, u8 *data, int len);
262extern void dsp_tone_timeout(struct timer_list *t);
263
264extern void dsp_bf_encrypt(struct dsp *dsp, u8 *data, int len);
265extern void dsp_bf_decrypt(struct dsp *dsp, u8 *data, int len);
266extern int dsp_bf_init(struct dsp *dsp, const u8 *key, unsigned int keylen);
267extern void dsp_bf_cleanup(struct dsp *dsp);
268
269extern int dsp_pipeline_module_init(void);
270extern void dsp_pipeline_module_exit(void);
271extern int dsp_pipeline_init(struct dsp_pipeline *pipeline);
272extern void dsp_pipeline_destroy(struct dsp_pipeline *pipeline);
273extern int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg);
274extern void dsp_pipeline_process_tx(struct dsp_pipeline *pipeline, u8 *data,
275 int len);
276extern void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data,
277 int len, unsigned int txlen);
278