0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #define DEBUG_DSP_CTRL 0x0001
0012 #define DEBUG_DSP_CORE 0x0002
0013 #define DEBUG_DSP_DTMF 0x0004
0014 #define DEBUG_DSP_CMX 0x0010
0015 #define DEBUG_DSP_TONE 0x0020
0016 #define DEBUG_DSP_BLOWFISH 0x0040
0017 #define DEBUG_DSP_DELAY 0x0100
0018 #define DEBUG_DSP_CLOCK 0x0200
0019 #define DEBUG_DSP_DTMFCOEFF 0x8000
0020
0021
0022
0023
0024
0025
0026
0027 #define DSP_OPT_ULAW (1 << 0)
0028 #define DSP_OPT_NOHARDWARE (1 << 1)
0029
0030 #include <linux/timer.h>
0031 #include <linux/workqueue.h>
0032
0033 #include "dsp_ecdis.h"
0034
0035 extern int dsp_options;
0036 extern int dsp_debug;
0037 extern int dsp_poll;
0038 extern int dsp_tics;
0039 extern spinlock_t dsp_lock;
0040 extern struct work_struct dsp_workq;
0041 extern u32 dsp_poll_diff;
0042
0043
0044
0045
0046
0047 extern s32 dsp_audio_alaw_to_s32[256];
0048 extern s32 dsp_audio_ulaw_to_s32[256];
0049 extern s32 *dsp_audio_law_to_s32;
0050 extern u8 dsp_audio_s16_to_law[65536];
0051 extern u8 dsp_audio_alaw_to_ulaw[256];
0052 extern u8 dsp_audio_mix_law[65536];
0053 extern u8 dsp_audio_seven2law[128];
0054 extern u8 dsp_audio_law2seven[256];
0055 extern void dsp_audio_generate_law_tables(void);
0056 extern void dsp_audio_generate_s2law_table(void);
0057 extern void dsp_audio_generate_seven(void);
0058 extern void dsp_audio_generate_mix_table(void);
0059 extern void dsp_audio_generate_ulaw_samples(void);
0060 extern void dsp_audio_generate_volume_changes(void);
0061 extern u8 dsp_silence;
0062
0063
0064
0065
0066
0067
0068 #define MAX_POLL 256
0069
0070 #define CMX_BUFF_SIZE 0x8000
0071 #define CMX_BUFF_HALF 0x4000
0072 #define CMX_BUFF_MASK 0x7fff
0073
0074
0075
0076 #define MAX_SECONDS_JITTER_CHECK 5
0077
0078 extern struct timer_list dsp_spl_tl;
0079
0080
0081 extern unsigned long dsp_spl_jiffies;
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092 struct dsp;
0093 struct dsp_conf_member {
0094 struct list_head list;
0095 struct dsp *dsp;
0096 };
0097
0098
0099 struct dsp_conf {
0100 struct list_head list;
0101 u32 id;
0102
0103
0104 struct list_head mlist;
0105 int software;
0106 int hardware;
0107
0108 };
0109
0110
0111
0112
0113
0114
0115 #define DSP_DTMF_NPOINTS 102
0116
0117 #define ECHOCAN_BUFF_SIZE 0x400
0118 #define ECHOCAN_BUFF_MASK 0x3ff
0119
0120 struct dsp_dtmf {
0121 int enable;
0122 int treshold;
0123 int software;
0124 int hardware;
0125 int size;
0126 signed short buffer[DSP_DTMF_NPOINTS];
0127
0128 u8 lastwhat, lastdigit;
0129 int count;
0130 u8 digits[16];
0131 };
0132
0133
0134
0135
0136
0137 struct dsp_pipeline {
0138 rwlock_t lock;
0139 struct list_head list;
0140 int inuse;
0141 };
0142
0143
0144
0145
0146
0147 struct dsp_tone {
0148 int software;
0149 int hardware;
0150 int tone;
0151 void *pattern;
0152 int count;
0153 int index;
0154 struct timer_list tl;
0155 };
0156
0157
0158
0159
0160
0161 struct dsp_echo {
0162 int software;
0163 int hardware;
0164 };
0165
0166
0167
0168
0169
0170 struct dsp {
0171 struct list_head list;
0172 struct mISDNchannel ch;
0173 struct mISDNchannel *up;
0174 unsigned char name[64];
0175 int b_active;
0176 struct dsp_echo echo;
0177 int rx_disabled;
0178 int rx_is_off;
0179 int tx_mix;
0180 struct dsp_tone tone;
0181 struct dsp_dtmf dtmf;
0182 int tx_volume, rx_volume;
0183
0184
0185 struct work_struct workq;
0186 struct sk_buff_head sendq;
0187 int hdlc;
0188 int data_pending;
0189
0190
0191 u32 conf_id;
0192 struct dsp_conf *conf;
0193 struct dsp_conf_member
0194 *member;
0195
0196
0197 int rx_W;
0198 int rx_R;
0199 int rx_init;
0200 int tx_W;
0201 int tx_R;
0202 int rx_delay[MAX_SECONDS_JITTER_CHECK];
0203 int tx_delay[MAX_SECONDS_JITTER_CHECK];
0204 u8 tx_buff[CMX_BUFF_SIZE];
0205 u8 rx_buff[CMX_BUFF_SIZE];
0206 int last_tx;
0207 int cmx_delay;
0208
0209 int tx_dejitter;
0210 int tx_data;
0211
0212
0213 struct dsp_features features;
0214 int features_rx_off;
0215 int features_fill_empty;
0216 int pcm_slot_rx;
0217 int pcm_bank_rx;
0218 int pcm_slot_tx;
0219 int pcm_bank_tx;
0220 int hfc_conf;
0221
0222
0223 int bf_enable;
0224 u32 bf_p[18];
0225 u32 bf_s[1024];
0226 int bf_crypt_pos;
0227 u8 bf_data_in[9];
0228 u8 bf_crypt_out[9];
0229 int bf_decrypt_in_pos;
0230 int bf_decrypt_out_pos;
0231 u8 bf_crypt_inring[16];
0232 u8 bf_data_out[9];
0233 int bf_sync;
0234
0235 struct dsp_pipeline
0236 pipeline;
0237 };
0238
0239
0240
0241 extern void dsp_change_volume(struct sk_buff *skb, int volume);
0242
0243 extern struct list_head dsp_ilist;
0244 extern struct list_head conf_ilist;
0245 extern void dsp_cmx_debug(struct dsp *dsp);
0246 extern void dsp_cmx_hardware(struct dsp_conf *conf, struct dsp *dsp);
0247 extern int dsp_cmx_conf(struct dsp *dsp, u32 conf_id);
0248 extern void dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb);
0249 extern void dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb);
0250 extern void dsp_cmx_send(void *arg);
0251 extern void dsp_cmx_transmit(struct dsp *dsp, struct sk_buff *skb);
0252 extern int dsp_cmx_del_conf_member(struct dsp *dsp);
0253 extern int dsp_cmx_del_conf(struct dsp_conf *conf);
0254
0255 extern void dsp_dtmf_goertzel_init(struct dsp *dsp);
0256 extern void dsp_dtmf_hardware(struct dsp *dsp);
0257 extern u8 *dsp_dtmf_goertzel_decode(struct dsp *dsp, u8 *data, int len,
0258 int fmt);
0259
0260 extern int dsp_tone(struct dsp *dsp, int tone);
0261 extern void dsp_tone_copy(struct dsp *dsp, u8 *data, int len);
0262 extern void dsp_tone_timeout(struct timer_list *t);
0263
0264 extern void dsp_bf_encrypt(struct dsp *dsp, u8 *data, int len);
0265 extern void dsp_bf_decrypt(struct dsp *dsp, u8 *data, int len);
0266 extern int dsp_bf_init(struct dsp *dsp, const u8 *key, unsigned int keylen);
0267 extern void dsp_bf_cleanup(struct dsp *dsp);
0268
0269 extern int dsp_pipeline_module_init(void);
0270 extern void dsp_pipeline_module_exit(void);
0271 extern int dsp_pipeline_init(struct dsp_pipeline *pipeline);
0272 extern void dsp_pipeline_destroy(struct dsp_pipeline *pipeline);
0273 extern int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg);
0274 extern void dsp_pipeline_process_tx(struct dsp_pipeline *pipeline, u8 *data,
0275 int len);
0276 extern void dsp_pipeline_process_rx(struct dsp_pipeline *pipeline, u8 *data,
0277 int len, unsigned int txlen);