Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelv...
[deliverable/linux.git] / drivers / isdn / mISDN / dsp.h
CommitLineData
960366cf
KK
1/*
2 * Audio support data for ISDN4Linux.
3 *
4 * Copyright 2002/2003 by Andreas Eversberg (jolly@eversberg.eu)
5 *
6 * This software may be used and distributed according to the terms
7 * of the GNU General Public License, incorporated herein by reference.
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
190f71d9 18#define DEBUG_DSP_CLOCK 0x0200
960366cf
KK
19#define DEBUG_DSP_DTMFCOEFF 0x8000 /* heavy output */
20
21/* options may be:
22 *
23 * bit 0 = use ulaw instead of alaw
24 * bit 1 = enable hfc hardware accelleration for all channels
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; /* calculated fix-comma corrected poll value */
42
43/***************
44 * audio stuff *
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 * cmx stuff *
66 *************/
67
68#define MAX_POLL 256 /* maximum number of send-chunks */
69
70#define CMX_BUFF_SIZE 0x8000 /* must be 2**n (0x1000 about 1/2 second) */
71#define CMX_BUFF_HALF 0x4000 /* CMX_BUFF_SIZE / 2 */
72#define CMX_BUFF_MASK 0x7fff /* CMX_BUFF_SIZE - 1 */
73
74/* how many seconds will we check the lowest delay until the jitter buffer
75 is reduced by that delay */
76#define MAX_SECONDS_JITTER_CHECK 5
77
78extern struct timer_list dsp_spl_tl;
79extern u32 dsp_spl_jiffies;
80
81/* the structure of conferences:
82 *
83 * each conference has a unique number, given by user space.
84 * the conferences are linked in a chain.
85 * each conference has members linked in a chain.
86 * each dsplayer points to a member, each member points to a dsplayer.
87 */
88
89/* all members within a conference (this is linked 1:1 with the dsp) */
90struct dsp;
91struct dsp_conf_member {
92 struct list_head list;
93 struct dsp *dsp;
94};
95
96/* the list of all conferences */
97struct dsp_conf {
98 struct list_head list;
99 u32 id;
100 /* all cmx stacks with the same ID are
101 connected */
102 struct list_head mlist;
103 int software; /* conf is processed by software */
104 int hardware; /* conf is processed by hardware */
105 /* note: if both unset, has only one member */
106};
107
108
109/**************
110 * DTMF stuff *
111 **************/
112
113#define DSP_DTMF_NPOINTS 102
114
a5355c27
AE
115#define ECHOCAN_BUFF_SIZE 0x400 /* must be 2**n */
116#define ECHOCAN_BUFF_MASK 0x3ff /* -1 */
960366cf
KK
117
118struct dsp_dtmf {
b0579d74 119 int enable; /* dtmf is enabled */
960366cf
KK
120 int treshold; /* above this is dtmf (square of) */
121 int software; /* dtmf uses software decoding */
122 int hardware; /* dtmf uses hardware decoding */
123 int size; /* number of bytes in buffer */
124 signed short buffer[DSP_DTMF_NPOINTS];
125 /* buffers one full dtmf frame */
126 u8 lastwhat, lastdigit;
127 int count;
b5df5a5c 128 u8 digits[16]; /* dtmf result */
960366cf
KK
129};
130
131
132/******************
133 * pipeline stuff *
134 ******************/
135struct dsp_pipeline {
136 rwlock_t lock;
137 struct list_head list;
138 int inuse;
139};
140
141/***************
142 * tones stuff *
143 ***************/
144
145struct dsp_tone {
146 int software; /* tones are generated by software */
147 int hardware; /* tones are generated by hardware */
148 int tone;
149 void *pattern;
150 int count;
151 int index;
152 struct timer_list tl;
153};
154
bc138ec4
AE
155/***************
156 * echo stuff *
157 ***************/
158
159struct dsp_echo {
160 int software; /* echo is generated by software */
161 int hardware; /* echo is generated by hardware */
162};
163
960366cf
KK
164/*****************
165 * general stuff *
166 *****************/
167
168struct dsp {
169 struct list_head list;
170 struct mISDNchannel ch;
171 struct mISDNchannel *up;
172 unsigned char name[64];
173 int b_active;
bc138ec4 174 struct dsp_echo echo;
960366cf
KK
175 int rx_disabled; /* what the user wants */
176 int rx_is_off; /* what the card is */
177 int tx_mix;
178 struct dsp_tone tone;
179 struct dsp_dtmf dtmf;
180 int tx_volume, rx_volume;
181
182 /* queue for sending frames */
183 struct work_struct workq;
184 struct sk_buff_head sendq;
185 int hdlc; /* if mode is hdlc */
186 int data_pending; /* currently an unconfirmed frame */
187
188 /* conference stuff */
189 u32 conf_id;
190 struct dsp_conf *conf;
191 struct dsp_conf_member
192 *member;
193
194 /* buffer stuff */
195 int rx_W; /* current write pos for data without timestamp */
196 int rx_R; /* current read pos for transmit clock */
197 int rx_init; /* if set, pointers will be adjusted first */
198 int tx_W; /* current write pos for transmit data */
199 int tx_R; /* current read pos for transmit clock */
200 int rx_delay[MAX_SECONDS_JITTER_CHECK];
201 int tx_delay[MAX_SECONDS_JITTER_CHECK];
202 u8 tx_buff[CMX_BUFF_SIZE];
203 u8 rx_buff[CMX_BUFF_SIZE];
204 int last_tx; /* if set, we transmitted last poll interval */
205 int cmx_delay; /* initial delay of buffers,
206 or 0 for dynamic jitter buffer */
207 int tx_dejitter; /* if set, dejitter tx buffer */
208 int tx_data; /* enables tx-data of CMX to upper layer */
209
210 /* hardware stuff */
211 struct dsp_features features;
212 int features_rx_off; /* set if rx_off is featured */
8dd2f36f 213 int features_fill_empty; /* set if fill_empty is featured */
960366cf
KK
214 int pcm_slot_rx; /* current PCM slot (or -1) */
215 int pcm_bank_rx;
216 int pcm_slot_tx;
217 int pcm_bank_tx;
218 int hfc_conf; /* unique id of current conference (or -1) */
219
220 /* encryption stuff */
221 int bf_enable;
222 u32 bf_p[18];
223 u32 bf_s[1024];
224 int bf_crypt_pos;
225 u8 bf_data_in[9];
226 u8 bf_crypt_out[9];
227 int bf_decrypt_in_pos;
228 int bf_decrypt_out_pos;
229 u8 bf_crypt_inring[16];
230 u8 bf_data_out[9];
231 int bf_sync;
232
233 struct dsp_pipeline
234 pipeline;
235};
236
237/* functions */
238
239extern void dsp_change_volume(struct sk_buff *skb, int volume);
240
241extern struct list_head dsp_ilist;
242extern struct list_head conf_ilist;
243extern void dsp_cmx_debug(struct dsp *dsp);
244extern void dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp);
245extern int dsp_cmx_conf(struct dsp *dsp, u32 conf_id);
246extern void dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb);
247extern void dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb);
248extern void dsp_cmx_send(void *arg);
249extern void dsp_cmx_transmit(struct dsp *dsp, struct sk_buff *skb);
250extern int dsp_cmx_del_conf_member(struct dsp *dsp);
251extern int dsp_cmx_del_conf(struct dsp_conf *conf);
252
253extern void dsp_dtmf_goertzel_init(struct dsp *dsp);
254extern void dsp_dtmf_hardware(struct dsp *dsp);
255extern u8 *dsp_dtmf_goertzel_decode(struct dsp *dsp, u8 *data, int len,
256 int fmt);
257
258extern int dsp_tone(struct dsp *dsp, int tone);
259extern void dsp_tone_copy(struct dsp *dsp, u8 *data, int len);
260extern void dsp_tone_timeout(void *arg);
261
262extern void dsp_bf_encrypt(struct dsp *dsp, u8 *data, int len);
263extern void dsp_bf_decrypt(struct dsp *dsp, u8 *data, int len);
264extern int dsp_bf_init(struct dsp *dsp, const u8 *key, unsigned int keylen);
265extern void dsp_bf_cleanup(struct dsp *dsp);
266
267extern int dsp_pipeline_module_init(void);
268extern void dsp_pipeline_module_exit(void);
269extern int dsp_pipeline_init(struct dsp_pipeline *pipeline);
270extern void dsp_pipeline_destroy(struct dsp_pipeline *pipeline);
271extern int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg);
272extern void dsp_pipeline_process_tx(struct dsp_pipeline *pipeline, u8 *data,
273 int len);
274extern void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data,
7cfa153d 275 int len, unsigned int txlen);
960366cf 276
This page took 0.107694 seconds and 5 git commands to generate.