summaryrefslogtreecommitdiff
path: root/wcusb.h
blob: 63d174a830b5b3ddafa64368abb0d32c038aaaed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119

#ifndef _WCUSB_H
#define _WCUSB_H

#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/usb.h>
#include "zaptel.h"

#define WC_MAX_IFACES           128

#define POWERSAVE_TIME 4000 /* Powersaving timeout for devices with a proslic */

/* Various registers and data ports on the tigerjet part */
#define WCUSB_SPORT0				0x26
#define WCUSB_SPORT1				0x27
#define WCUSB_SPORT2				0x28
#define WCUSB_SPORT_CTRL			0x29

#define WC_AUX0 0x1
#define WC_AUX1 0x2
#define WC_AUX2 0x4
#define WC_AUX3 0x8

#define CONTROL_TIMEOUT_MS              (500)           /* msec */
#define CONTROL_TIMEOUT_JIFFIES ((CONTROL_TIMEOUT_MS * HZ) / 1000)

#define REQUEST_NORMAL 4

#define FLAG_RUNNING    (1 << 0)
 
/* Important data structures and data types */


/* States for the Proslic read state machine */
typedef enum {
        STATE_WCREAD_WRITEREG,
        STATE_WCREAD_READRES,
        STATE_WCWRITE_WRITEREG,
        STATE_WCWRITE_WRITERES,
} proslic_state_t;

/* Used for current stream state */
typedef enum {
        STREAM_NORMAL, /* Sends normal (unmodified) audio data */
        STREAM_DTMF, /* (For keypad device) Sends dtmf data */
} stream_t;

/* States for the Keypad state machine */
typedef enum {
        STATE_FOR_LOOP_1_OUT,
        STATE_FOR_LOOP_2_IN,
        STATE_FOR_LOOP_PROC_DATA,
        STATE_FOR_LOOP_CLEAR_DIGIT,
} keypad_state_t;

/* Device types.  For radical changes in a new device, use a switch based on the device type */
typedef enum {
        WC_KEYPAD,  /* The tigerjet phone with the keypad.  That was a bugger to implement */
        WC_PROSLIC, /* For various devices with a proslic */
} dev_type_t;

struct wc_keypad_data {
        keypad_state_t state; /* Current state in the keypad detect routine */
        urb_t urb;  /* urb used for the keypad data transport ... can't remember whether it is used or not */
	int running;
        char data;
        char data12;
        char tmp;
        int scanned_event;
        int i;
        int count;
        /* DTMF tone generation stuff for zaptel */
        struct zt_tone_state ts;
        struct zt_tone *tone;
};

struct stinky_urb {
        urb_t urb;
        iso_packet_descriptor_t isoframe[1];
};

struct wc_usb_pvt {
        struct usb_device *dev;
        dev_type_t devclass;
        int usecount;
        int dead;
        struct zt_span span;
        struct zt_chan chan;
        struct stinky_urb dataread[2];
        struct stinky_urb datawrite[2];
        urb_t           control;
        devrequest      dr;
        proslic_state_t controlstate;
        int urbcount;
        int flags;
        int timer;
        int lowpowertimer;
        int idletxhookstate;
        int hookstate;
        __u8 newtxhook;
        __u8 txhook;
        int pos;
        unsigned char auxstatus;
        unsigned char wcregindex;
        unsigned char wcregbuf[4];
        unsigned char wcregval;
        short readchunk[ZT_MAX_CHUNKSIZE * 2];
        short writechunk[ZT_MAX_CHUNKSIZE * 2];
        stream_t sample;
        void *pvt_data;
};

struct wc_usb_desc {
        char *name;
        int flags;
};
#endif