]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
prepwork for zt hardware interface.
authorMichael Jerris <mike@jerris.com>
Tue, 29 May 2007 06:53:39 +0000 (06:53 +0000)
committerMichael Jerris <mike@jerris.com>
Tue, 29 May 2007 06:53:39 +0000 (06:53 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@177 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/msvc/openzap.vcproj
libs/openzap/src/include/zap_zt.h
libs/openzap/src/zap_zt.c

index 1a60eded4554d96fffa60fd06f1a504d9ca3ee11..9e936194cf84e9f4d86ddde1bb6d95db663a2aa9 100644 (file)
                                        >\r
                                        <FileConfiguration\r
                                                Name="Debug|Win32"\r
-                                               ExcludedFromBuild="true"\r
                                                >\r
                                                <Tool\r
                                                        Name="VCCLCompilerTool"\r
                                        </FileConfiguration>\r
                                        <FileConfiguration\r
                                                Name="Release|Win32"\r
-                                               ExcludedFromBuild="true"\r
                                                >\r
                                                <Tool\r
                                                        Name="VCCLCompilerTool"\r
index f9c2f59e0a4f466976ed8725bf393b6e265ae2bb..ce52c3eae8c96b7a5c13f243300d5e20f9de7fc3 100644 (file)
 #define ZAP_ZT_H
 #include "openzap.h"
 
-zap_status_t zt_init(zap_software_interface_t **zint);
+/* Hardware interface structures and defines */
+/* Based on documentation of the structures required for the hardware interface */
+/* from http://wiki.freeswitch.org/wiki/Zapata_zaptel_interface */
+
+/* Structures */
+
+/* Used with ioctl: ZT_GET_PARAMS and ZT_SET_PARAMS */
+struct zt_params {
+       int chan_no;                    /* Channel Number                                                       */
+       int span_no;                    /* Span Number                                                          */
+       int chan_position;              /* Channel Position                                                     */
+       int sig_type;                   /* Signal Type (read-only)                                      */
+       int sig_cap;                    /* Signal Cap (read-only)                                       */
+       int receive_offhook;    /* Receive is offhook (read-only)                       */
+       int receive_bits;               /* Number of bits in receive (read-only)        */
+       int transmit_bits;              /* Number of bits in transmit (read-only)       */
+       int transmit_hook_sig;  /* Transmit Hook Signal (read-only)                     */
+       int receive_hook_sig;   /* Receive Hook Signal (read-only)                      */
+       int g711_type;                  /* Member of zt_g711_t (read-only)                      */
+       int idlebits;                   /* bits for the idle state (read-only)          */
+       char chan_name[40];             /* Channel Name                                                         */
+       int prewink_time;
+       int preflash_time;
+       int wink_time;
+       int flash_time;
+       int start_time;
+       int receive_wink_time;
+       int receive_flash_time;
+       int debounce_time;
+       int pulse_break_time;
+       int pulse_make_time;
+       int pulse_after_time;
+};
+
+/* Used with ioctl: ZT_CONFLINK, ZT_GETCONF and ZT_SETCONF */
+struct zt_confinfo {
+       int chan_no;                    /* Channel Number, 0 for current */
+       int conference_number;
+       int conference_mode;
+};
+
+/* Used with ioctl: ZT_GETGAINS and ZT_SETGAINS */
+struct zt_gains {
+       int chan_no;                                            /* Channel Number, 0 for current        */
+       unsigned char receive_gain[256];        /* Receive gain table                           */\r
+       unsigned char transmit_gain[256];       /* Transmit gain table                          */
+};
+
+/* Enumerations */
+
+/* Values in zt_params structure for member g711_type */
+typedef enum {
+       ZT_G711_DEFAULT         = 0,    /* Default mulaw/alaw from the span */
+       ZT_G711_MULAW           = 1,
+       ZT_G711_ALAW            = 2
+} zt_g711_t;
+
+typedef enum {
+       ZT_EVENT_NONE                   = 0,\r
+       ZT_EVENT_ONHOOK                 = 1,\r
+       ZT_EVENT_RINGOFFHOOK    = 2,\r
+       ZT_EVENT_WINKFLASH              = 3,\r
+       ZT_EVENT_ALARM                  = 4,\r
+       ZT_EVENT_NOALARM                = 5,\r
+       ZT_EVENT_ABORT                  = 6,\r
+       ZT_EVENT_OVERRUN                = 7,\r
+       ZT_EVENT_BADFCS                 = 8,\r
+       ZT_EVENT_DIALCOMPLETE   = 9, \r
+       ZT_EVENT_RINGERON               = 10,\r
+       ZT_EVENT_RINGEROFF              = 11,\r
+       ZT_EVENT_HOOKCOMPLETE   = 12,\r
+       ZT_EVENT_BITSCHANGED    = 13,\r
+       ZT_EVENT_PULSE_START    = 14,\r
+       ZT_EVENT_TIMER_EXPIRED  = 15,\r
+       ZT_EVENT_TIMER_PING             = 16,\r
+       ZT_EVENT_POLARITY               = 17,\r
+       ZT_EVENT_RINGBEGIN              = 18\r
+} zt_event_t;
+
+typedef enum {
+       ZT_FLUSH_READ                   = 1,\r
+       ZT_FLUSH_WRITE                  = 2,\r
+       ZT_FLUSH_BOTH                   = (ZT_FLUSH_READ | ZT_FLUSH_WRITE),\r
+       ZT_FLUSH_EVENT                  = 4,\r
+       ZT_FLUSH_ALL                    = (ZT_FLUSH_READ | ZT_FLUSH_WRITE | ZT_FLUSH_EVENT)\r
+} zt_flush_t;
+
+typedef enum {
+       ZT_IOMUX_READ                   = 1,\r
+       ZT_IOMUX_WRITE                  = 2,\r
+       ZT_IOMUX_WRITEEMPTY             = 4,\r
+       ZT_IOMUX_SIGEVENT               = 8,\r
+       ZT_IOMUX_NOWAIT                 = 256\r
+} zt_iomux_t;
+
+typedef enum {
+       ZT_ONHOOK                               = 0,\r
+       ZT_OFFHOOK                              = 1,\r
+       ZT_WINK                                 = 2,\r
+       ZT_FLASH                                = 3,\r
+       ZT_START                                = 4,\r
+       ZT_RING                                 = 5,\r
+       ZT_RINGOFF                              = 6\r
+} zt_hookstate_t;
+
+
+/* Defines */
+
+#define                ZT_MAX_BLOCKSIZE        8192\r
+#define                ZT_DEFAULT_MTU_MRU      2048\r
+
+/* ioctl defines */
+
+#define                ZT_CODE                         'J'
+
+#define                ZT_GET_BLOCKSIZE        _IOW  (ZT_CODE, 1, int)                                 /* Get Transfer Block Size. */\r
+#define                ZT_SET_BLOCKSIZE        _IOW  (ZT_CODE, 2, int)                                 /* Set Transfer Block Size. */\r
+#define                ZT_FLUSH                        _IOW  (ZT_CODE, 3, int)                                 /* Flush Buffer(s) and stop I/O */\r
+#define                ZT_SYNC                         _IOW  (ZT_CODE, 4, int)                                 /* Wait for Write to Finish */\r
+#define                ZT_GET_PARAMS           _IOR  (ZT_CODE, 5, struct zt_params)    /* Get channel parameters */\r
+#define                ZT_SET_PARAMS           _IOW  (ZT_CODE, 6, struct zt_params)    /* Set channel parameters */\r
+#define                ZT_HOOK                         _IOW  (ZT_CODE, 7, int)                                 /* Set Hookswitch Status */\r
+#define                ZT_GETEVENT                     _IOR  (ZT_CODE, 8, int)                                 /* Get Signalling Event */\r
+#define                ZT_IOMUX                        _IOWR (ZT_CODE, 9, int)                                 /* Wait for something to happen (IO Mux) */\r
+\r
+#define                ZT_GETCONF                      _IOWR (ZT_CODE, 12, struct zt_confinfo) /* Get Conference Mode */\r
+#define                ZT_SETCONF                      _IOWR (ZT_CODE, 13, struct zt_confinfo) /* Set Conference Mode */\r
+#define                ZT_CONFLINK                     _IOW  (ZT_CODE, 14, struct zt_confinfo) /* Setup or Remove Conference Link */\r
+#define                ZT_CONFDIAG                     _IOR  (ZT_CODE, 15, int)                                /* Display Conference Diagnostic Information on Console */\r
+\r
+#define                ZT_GETGAINS                     _IOWR (ZT_CODE, 16, struct zt_gains)    /* Get Channel audio gains */\r
+#define                ZT_SETGAINS                     _IOWR (ZT_CODE, 17, struct zt_gains)    /* Set Channel audio gains */\r
+\r
+#define                ZT_AUDIOMODE            _IOW  (ZT_CODE, 32, int)                                /* Set a clear channel into audio mode */\r
+\r
+#define                ZT_HDLCRAWMODE          _IOW  (ZT_CODE, 36, int)                                /* Set a clear channel into HDLC w/out FCS checking/calculation mode */\r
+#define                ZT_HDLCFCSMODE          _IOW  (ZT_CODE, 37, int)                                /* Set a clear channel into HDLC w/ FCS mode */\r
+\r
+/* Specify a channel on /dev/zap/chan -- must be done before any other ioctl's and is only valid on /dev/zap/chan */\r
+#define                ZT_SPECIFY                      _IOW  (ZT_CODE, 38, int)\r
+\r
+/* Temporarily set the law on a channel to ZT_LAW_DEFAULT, ZT_LAW_ALAW, or ZT_LAW_MULAW. Is reset on close. */\r
+#define                ZT_SETLAW                       _IOW  (ZT_CODE, 39, int)\r
+\r
+/* Temporarily set the channel to operate in linear mode when non-zero or default law if 0 */\r
+#define                ZT_SETLINEAR            _IOW  (ZT_CODE, 40, int)\r
+\r
+#define                ZT_GETCONFMUTE          _IOR  (ZT_CODE, 49, int)                                /* Get Conference to mute mode */\r
+\r
+
+
+/* Openzap ZT hardware interface functions */
+zap_status_t zt_init(zap_io_interface_t **zint);
 zap_status_t zt_destroy(void);
 
 #endif
index 802523d393f6e59648eb9347643304f31ea89c96..57d006e8d3715719199c56de66b8a7c77f5dd097 100644 (file)
 #include "openzap.h"
 #include "zap_zt.h"
 
-static ZINT_CONFIGURE_FUNCTION(zt_configure)
+static ZIO_CONFIGURE_SPAN_FUNCTION(zt_configure_span)
 {
-       ZINT_CONFIGURE_MUZZLE;
        return ZAP_FAIL;
 }
 
-static ZINT_OPEN_FUNCTION(zt_open) 
+static ZIO_CONFIGURE_FUNCTION(zt_configure)
 {
-       ZINT_OPEN_MUZZLE;
        return ZAP_FAIL;
 }
 
-static ZINT_CLOSE_FUNCTION(zt_close)
+static ZIO_OPEN_FUNCTION(zt_open) 
 {
-       ZINT_CLOSE_MUZZLE;
+       ZIO_OPEN_MUZZLE;
        return ZAP_FAIL;
 }
 
-static ZINT_SET_CODEC_FUNCTION(zt_set_codec)
+static ZIO_CLOSE_FUNCTION(zt_close)
 {
-       ZINT_SET_CODEC_MUZZLE;
+       ZIO_CLOSE_MUZZLE;
        return ZAP_FAIL;
 }
 
-static ZINT_SET_INTERVAL_FUNCTION(zt_set_interval)
+static ZIO_COMMAND_FUNCTION(zt_command)
 {
-       ZINT_SET_INTERVAL_MUZZLE;
        return ZAP_FAIL;
 }
 
-static ZINT_WAIT_FUNCTION(zt_wait)
+static ZIO_WAIT_FUNCTION(zt_wait)
 {
-       ZINT_WAIT_MUZZLE;
        return ZAP_FAIL;
 }
 
-static ZINT_READ_FUNCTION(zt_read)
+static ZIO_READ_FUNCTION(zt_read)
 {
-       ZINT_READ_MUZZLE;
        return ZAP_FAIL;
 }
 
-static ZINT_WRITE_FUNCTION(zt_write)
+static ZIO_WRITE_FUNCTION(zt_write)
 {
-       ZINT_WRITE_MUZZLE;
        return ZAP_FAIL;
 }
 
-static zap_software_interface_t zt_interface;
+static zap_io_interface_t zt_interface;
 
-zap_status_t zt_init(zap_software_interface_t **zint)
+zap_status_t zt_init(zap_io_interface_t **zio)
 {
-       assert(zint != NULL);
+       assert(zio != NULL);
        memset(&zt_interface, 0, sizeof(zt_interface));
 
        zt_interface.name = "zt";
        zt_interface.configure =  zt_configure;
        zt_interface.open = zt_open;
        zt_interface.close = zt_close;
-       zt_interface.set_codec = zt_set_codec;
-       zt_interface.set_interval = zt_set_interval;
        zt_interface.wait = zt_wait;
        zt_interface.read = zt_read;
        zt_interface.write = zt_write;
-       *zint = &zt_interface;
+       *zio = &zt_interface;
 
        return ZAP_FAIL;
 }