diff options
Diffstat (limited to 'kernel/zaptel.h')
-rw-r--r-- | kernel/zaptel.h | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/kernel/zaptel.h b/kernel/zaptel.h index ab5b491..81f7946 100644 --- a/kernel/zaptel.h +++ b/kernel/zaptel.h @@ -768,6 +768,11 @@ struct zt_hwgain{ #define ZT_SETPOLARITY _IOW (ZT_CODE, 92, int) /* + * Transcoder operations + */ +#define ZT_TRANSCODE_OP _IOWR(ZT_CODE, 93, int) + +/* * VoiceMail Waiting Indication (WMWI) -- implemented by low-level driver. * Value: number of waiting messages (hence 0: switch messages off). */ @@ -888,6 +893,57 @@ enum { #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/reset 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 */ +typedef struct zt_transcode_info { + unsigned int op; + unsigned int tcnum; + char name[80]; + int numchannels; + unsigned int srcfmts; + unsigned int dstfmts; +} ZT_TRANSCODE_INFO; + +#define ZT_TCCONF_USETS (1 << 0) /* Use/update timestamp field */ +#define ZT_TCCONF_USESEQ (1 << 1) /* Use/update seqno field */ + +#define ZT_TCSTAT_DSTRDY (1 << 0) /* Destination data is ready */ +#define ZT_TCSTAT_DSTBUSY (1 << 1) /* Destination data is outstanding */ + +#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) + +typedef struct zt_transcode_header { + unsigned int srcfmt; /* See formats.h -- use TCOP_RESET when you change */ + unsigned int srcoffset; /* In bytes -- written by user */ + unsigned int srclen; /* In bytes -- written by user */ + unsigned int srctimestamp; /* In samples -- written by user (only used if ZT_TCCONF_USETS is set) */ + unsigned int srcseqno; /* In units -- written by user (only used if ZT_TCCONF_USESEQ is set) */ + + unsigned int dstfmt; /* See formats.h -- use TCOP_RESET when you change */ + unsigned int dstoffset; /* In bytes -- written by user */ + unsigned int dsttimestamp; /* In samples -- read by user */ + unsigned int dstseqno; /* In units -- read by user (only used if ZT_TCCONF_USESEQ is set) */ + unsigned int dstlen; /* In bytes -- read by user */ + unsigned int dstsamples; /* In timestamp units -- read by user */ + + unsigned int magic; /* Magic value -- ZT_TRANSCODE_MAGIC, read by user */ + unsigned int config; /* Read/write by user */ + unsigned int status; /* Read/write by user */ + unsigned char userhdr[ZT_TRANSCODE_HDRLEN - (sizeof(unsigned int) * 14)]; /* Storage for user parameters */ + unsigned char srcdata[ZT_TRANSCODE_BUFSIZ / 2]; /* Storage of source data */ + unsigned char dstdata[ZT_TRANSCODE_BUFSIZ / 2]; /* Storage of destination data */ +} ZT_TRANSCODE_HEADER; + struct zt_ring_cadence { int ringcadence[ZT_MAX_CADENCE]; }; @@ -1644,6 +1700,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; + unsigned int built_fmts; + unsigned int flags; + unsigned int srcfmt; + unsigned int dstfmt; + struct zt_transcode_header *tch; +}; + +#define ZT_TC_FLAG_BUSY (1 << 0) +#define ZT_TC_FLAG_TRANSIENT (1 << 1) + + +struct zt_transcoder { + struct zt_transcoder *next; + 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 @@ -1711,6 +1796,19 @@ int zt_hdlc_getbuf(struct zt_chan *ss, unsigned char *bufptr, unsigned int *size we should have preference in being the master device */ 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); + +/* 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 */ int zt_unregister(struct zt_span *span); @@ -1750,6 +1848,8 @@ struct zt_tone *zt_mf_tone(const struct zt_chan *chan, char digit, int digitmode void zt_ec_chunk(struct zt_chan *chan, unsigned char *rxchunk, const unsigned char *txchunk); 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]; |