gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / isdn / capi / kcapi.h
blob479623e1db2a449d3404f291c550dfe2b5a933a4
1 /*
2 * Kernel CAPI 2.0 Module
4 * Copyright 1999 by Carsten Paeth <calle@calle.de>
5 * Copyright 2002 by Kai Germaschewski <kai@germaschewski.name>
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
13 #include <linux/kernel.h>
14 #include <linux/spinlock.h>
15 #include <linux/list.h>
16 #include <linux/isdn/capilli.h>
18 #ifdef KCAPI_DEBUG
19 #define DBG(format, arg...) do { \
20 printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \
21 } while (0)
22 #else
23 #define DBG(format, arg...) /* */
24 #endif
26 enum {
27 CAPI_CTR_DETACHED = 0,
28 CAPI_CTR_DETECTED = 1,
29 CAPI_CTR_LOADING = 2,
30 CAPI_CTR_RUNNING = 3,
33 extern struct capi_ctr *capi_controller[CAPI_MAXCONTR];
34 extern struct mutex capi_controller_lock;
36 extern struct capi20_appl *capi_applications[CAPI_MAXAPPL];
38 void kcapi_proc_init(void);
39 void kcapi_proc_exit(void);
41 struct capi20_appl {
42 u16 applid;
43 capi_register_params rparam;
44 void (*recv_message)(struct capi20_appl *ap, struct sk_buff *skb);
45 void *private;
47 /* internal to kernelcapi.o */
48 unsigned long nrecvctlpkt;
49 unsigned long nrecvdatapkt;
50 unsigned long nsentctlpkt;
51 unsigned long nsentdatapkt;
52 struct mutex recv_mtx;
53 struct sk_buff_head recv_queue;
54 struct work_struct recv_work;
55 int release_in_progress;
58 u16 capi20_isinstalled(void);
59 u16 capi20_register(struct capi20_appl *ap);
60 u16 capi20_release(struct capi20_appl *ap);
61 u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb);
62 u16 capi20_get_manufacturer(u32 contr, u8 buf[CAPI_MANUFACTURER_LEN]);
63 u16 capi20_get_version(u32 contr, struct capi_version *verp);
64 u16 capi20_get_serial(u32 contr, u8 serial[CAPI_SERIAL_LEN]);
65 u16 capi20_get_profile(u32 contr, struct capi_profile *profp);
66 int capi20_manufacturer(unsigned long cmd, void __user *data);
68 #define CAPICTR_UP 0
69 #define CAPICTR_DOWN 1
71 int kcapi_init(void);
72 void kcapi_exit(void);
74 /*----- basic-type definitions -----*/
76 typedef __u8 *_cstruct;
78 typedef enum {
79 CAPI_COMPOSE,
80 CAPI_DEFAULT
81 } _cmstruct;
84 The _cmsg structure contains all possible CAPI 2.0 parameter.
85 All parameters are stored here first. The function CAPI_CMSG_2_MESSAGE
86 assembles the parameter and builds CAPI2.0 conform messages.
87 CAPI_MESSAGE_2_CMSG disassembles CAPI 2.0 messages and stores the
88 parameter in the _cmsg structure
91 typedef struct {
92 /* Header */
93 __u16 ApplId;
94 __u8 Command;
95 __u8 Subcommand;
96 __u16 Messagenumber;
98 /* Parameter */
99 union {
100 __u32 adrController;
101 __u32 adrPLCI;
102 __u32 adrNCCI;
103 } adr;
105 _cmstruct AdditionalInfo;
106 _cstruct B1configuration;
107 __u16 B1protocol;
108 _cstruct B2configuration;
109 __u16 B2protocol;
110 _cstruct B3configuration;
111 __u16 B3protocol;
112 _cstruct BC;
113 _cstruct BChannelinformation;
114 _cmstruct BProtocol;
115 _cstruct CalledPartyNumber;
116 _cstruct CalledPartySubaddress;
117 _cstruct CallingPartyNumber;
118 _cstruct CallingPartySubaddress;
119 __u32 CIPmask;
120 __u32 CIPmask2;
121 __u16 CIPValue;
122 __u32 Class;
123 _cstruct ConnectedNumber;
124 _cstruct ConnectedSubaddress;
125 __u32 Data;
126 __u16 DataHandle;
127 __u16 DataLength;
128 _cstruct FacilityConfirmationParameter;
129 _cstruct Facilitydataarray;
130 _cstruct FacilityIndicationParameter;
131 _cstruct FacilityRequestParameter;
132 __u16 FacilitySelector;
133 __u16 Flags;
134 __u32 Function;
135 _cstruct HLC;
136 __u16 Info;
137 _cstruct InfoElement;
138 __u32 InfoMask;
139 __u16 InfoNumber;
140 _cstruct Keypadfacility;
141 _cstruct LLC;
142 _cstruct ManuData;
143 __u32 ManuID;
144 _cstruct NCPI;
145 __u16 Reason;
146 __u16 Reason_B3;
147 __u16 Reject;
148 _cstruct Useruserdata;
150 /* intern */
151 unsigned l, p;
152 unsigned char *par;
153 __u8 *m;
155 /* buffer to construct message */
156 __u8 buf[180];
158 } _cmsg;
160 /*-----------------------------------------------------------------------*/
163 * Debugging / Tracing functions
166 char *capi_cmd2str(__u8 cmd, __u8 subcmd);
168 typedef struct {
169 u_char *buf;
170 u_char *p;
171 size_t size;
172 size_t pos;
173 } _cdebbuf;
175 #define CDEBUG_SIZE 1024
176 #define CDEBUG_GSIZE 4096
178 void cdebbuf_free(_cdebbuf *cdb);
179 int cdebug_init(void);
180 void cdebug_exit(void);
182 _cdebbuf *capi_message2str(__u8 *msg);