diff options
author | kpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-01-31 17:27:30 +0000 |
---|---|---|
committer | kpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-01-31 17:27:30 +0000 |
commit | 92e6d005b1107055cdd62f41fc06bda8e98b14b3 (patch) | |
tree | 530476168181ed67fa632f008cca8ac1040eef0a /zaptel.h | |
parent | ec54d1fb2b09fc3a4027a58317d190a403b148eb (diff) |
merge support for the Digium TC400B hardware transcoder
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2057 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'zaptel.h')
-rw-r--r-- | zaptel.h | 120 |
1 files changed, 119 insertions, 1 deletions
@@ -45,6 +45,7 @@ #include <linux/interrupt.h> #endif #include <linux/fs.h> +#include <linux/list.h> #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) #define LINUX26 @@ -666,6 +667,11 @@ void *data; */ #define ZT_SETPOLARITY _IOW (ZT_CODE, 92, int) +/* +* Transcoder operations +*/ +#define ZT_TRANSCODE_OP _IOWR(ZT_CODE, 93, int) + /* * Startup or Shutdown a span */ @@ -695,6 +701,47 @@ void *data; #define ZT_TONEDETECT_ON (1 << 0) /* Detect tones */ #define ZT_TONEDETECT_MUTE (1 << 1) /* Mute audio in received channel */ +#define ZT_TRANSCODE_MAGIC 0x74a9c0de + +/* Operations */ +#define ZT_TCOP_ALLOCATE 1 /* Allocate DTE channel */ +#define ZT_TCOP_TRANSCODE 2 /* Begin transcoding a block */ +#define ZT_TCOP_GETINFO 3 /* Get information (use zt_transcode_info) */ +#define ZT_TCOP_RELEASE 4 /* Release DTE channel */ +#define ZT_TCOP_TEST 5 /* test DTE device */ +struct zt_transcode_info { + __u32 op; + __u32 tcnum; + __u8 name[80]; + __u32 numchannels; + __u32 srcfmts; + __u32 dstfmts; +}; + +#define __ZT_TRANSCODE_BUFSIZ 16384 +#define ZT_TRANSCODE_HDRLEN 256 +#define ZT_TRANSCODE_BUFSIZ ((__ZT_TRANSCODE_BUFSIZ) - (ZT_TRANSCODE_HDRLEN)) +#define ZT_TRANSCODE_DSTOFFSET (((ZT_TRANSCODE_BUFSIZ) / 2) + ZT_TRANSCODE_HDRLEN) +#define ZT_TRANSCODE_SRCOFFSET (((ZT_TRANSCODE_BUFSIZ) / 2) + ZT_TRANSCODE_HDRLEN) + +struct zt_transcode_header { + __u32 srcfmt; /* See formats.h -- use TCOP_RESET when you change */ + __u32 srcoffset; /* In bytes -- written by user */ + __u32 srclen; /* In bytes -- written by user */ + + __u32 dstfmt; /* See formats.h -- use TCOP_RESET when you change */ + __u32 dstoffset; /* In bytes -- written by user */ + __u32 dstlen; /* In bytes -- read by user */ + __u32 dstsamples; /* In timestamp units -- read by user */ + + __u32 magic; /* Magic value -- ZT_TRANSCODE_MAGIC, read by user */ + __u32 config; /* Read/write by user */ + __u32 busy:1; /* Read/write by user */ + __u8 userhdr[ZT_TRANSCODE_HDRLEN - (sizeof(__u32) * 14)]; /* Storage for user parameters */ + __u8 srcdata[ZT_TRANSCODE_BUFSIZ / 2]; /* Storage of source data */ + __u8 dstdata[ZT_TRANSCODE_BUFSIZ / 2]; /* Storage of destination data */ +}; + struct zt_ring_cadence { int ringcadence [ZT_MAX_CADENCE]; }; @@ -1345,6 +1392,35 @@ struct zt_span { #endif }; +struct zt_transcoder_channel { + void *pvt; + struct zt_transcoder *parent; + wait_queue_head_t ready; + int errorstatus; + int offset; + unsigned int chan_built:1; + unsigned int have_reference:1; + unsigned int busy:1; + unsigned int transient:1; + unsigned int built_fmts; + unsigned int flags; + unsigned int srcfmt; + unsigned int dstfmt; + struct zt_transcode_header *tch; +}; + +struct zt_transcoder { + struct list_head list; + struct module *owner; + char name[80]; + int numchannels; + unsigned int srcfmts; + unsigned int dstfmts; + int (*operation)(struct zt_transcoder_channel *channel, int op); + /* Transcoder channels */ + struct zt_transcoder_channel channels[0]; +}; + #define ZT_WATCHDOG_NOINTS (1 << 0) #define ZT_WATCHDOG_INIT 1000 @@ -1390,10 +1466,23 @@ extern int zt_receive(struct zt_span *span); /* Prepare writechunk buffers on all channels for this span */ extern int zt_transmit(struct zt_span *span); - /* Register a span. Returns 0 on success, -1 on failure. Pref-master is non-zero if we should have preference in being the master device */ extern int zt_register(struct zt_span *span, int prefmaster); + +/* Allocate / free memory for a transcoder */ +struct zt_transcoder *zt_transcoder_alloc(int numchans); +void zt_transcoder_free(struct zt_transcoder *ztc); + +/* Register a transcoder */ +int zt_transcoder_register(struct zt_transcoder *tc, struct module *owner); + +/* Unregister a transcoder */ +int zt_transcoder_unregister(struct zt_transcoder *tc); + +/* Alert a transcoder */ +int zt_transcoder_alert(struct zt_transcoder_channel *ztc); + /* Unregister a span */ extern int zt_unregister(struct zt_span *span); @@ -1432,6 +1521,8 @@ extern struct zt_tone *zt_dtmf_tone(char digit, int mf); extern void zt_ec_chunk(struct zt_chan *chan, unsigned char *rxchunk, const unsigned char *txchunk); extern void zt_ec_span(struct zt_span *span); +extern struct file_operations *zt_transcode_fops; + /* Don't use these directly -- they're not guaranteed to be there. */ extern short __zt_mulaw[256]; @@ -1611,5 +1702,32 @@ struct zt_radio_param { #define ZT_RADPAR_REMCOMMAND 17 /* Remote conrtol write data block & do cmd */ +/* Data formats for capabilities and frames alike (from Asterisk) */ +/*! G.723.1 compression */ +#define ZT_FORMAT_G723_1 (1 << 0) +/*! GSM compression */ +#define ZT_FORMAT_GSM (1 << 1) +/*! Raw mu-law data (G.711) */ +#define ZT_FORMAT_ULAW (1 << 2) +/*! Raw A-law data (G.711) */ +#define ZT_FORMAT_ALAW (1 << 3) +/*! ADPCM (G.726, 32kbps) */ +#define ZT_FORMAT_G726 (1 << 4) +/*! ADPCM (IMA) */ +#define ZT_FORMAT_ADPCM (1 << 5) +/*! Raw 16-bit Signed Linear (8000 Hz) PCM */ +#define ZT_FORMAT_SLINEAR (1 << 6) +/*! LPC10, 180 samples/frame */ +#define ZT_FORMAT_LPC10 (1 << 7) +/*! G.729A audio */ +#define ZT_FORMAT_G729A (1 << 8) +/*! SpeeX Free Compression */ +#define ZT_FORMAT_SPEEX (1 << 9) +/*! iLBC Free Compression */ +#define ZT_FORMAT_ILBC (1 << 10) +/*! Maximum audio format */ +#define ZT_FORMAT_MAX_AUDIO (1 << 15) +/*! Maximum audio mask */ +#define ZT_FORMAT_AUDIO_MASK ((1 << 16) - 1) #endif /* _LINUX_ZAPTEL_H */ |