Merge tag 'asoc-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound...
[pandora-kernel.git] / drivers / staging / ozwpan / ozprotocol.h
1 /* -----------------------------------------------------------------------------
2  * Copyright (c) 2011 Ozmo Inc
3  * Released under the GNU General Public License Version 2 (GPLv2).
4  * -----------------------------------------------------------------------------
5  */
6 #ifndef _OZPROTOCOL_H
7 #define _OZPROTOCOL_H
8
9 #define PACKED __packed
10
11 #define OZ_ETHERTYPE 0x892e
12
13 /* Status codes
14  */
15 #define OZ_STATUS_SUCCESS               0
16 #define OZ_STATUS_INVALID_PARAM         1
17 #define OZ_STATUS_TOO_MANY_PDS          2
18 #define OZ_STATUS_NOT_ALLOWED           4
19 #define OZ_STATUS_SESSION_MISMATCH      5
20 #define OZ_STATUS_SESSION_TEARDOWN      6
21
22 /* This is the generic element header.
23    Every element starts with this.
24  */
25 struct oz_elt {
26         u8 type;
27         u8 length;
28 } PACKED;
29
30 #define oz_next_elt(__elt)      \
31         (struct oz_elt *)((u8 *)((__elt) + 1) + (__elt)->length)
32
33 /* Protocol element IDs.
34  */
35 #define OZ_ELT_CONNECT_REQ      0x06
36 #define OZ_ELT_CONNECT_RSP      0x07
37 #define OZ_ELT_DISCONNECT       0x08
38 #define OZ_ELT_UPDATE_PARAM_REQ 0x11
39 #define OZ_ELT_FAREWELL_REQ     0x12
40 #define OZ_ELT_APP_DATA         0x31
41
42 /* This is the Ozmo header which is the first Ozmo specific part
43  * of a frame and comes after the MAC header.
44  */
45 struct oz_hdr {
46         u8      control;
47         u8      last_pkt_num;
48         u32     pkt_num;
49 } PACKED;
50
51 #define OZ_PROTOCOL_VERSION     0x1
52 /* Bits in the control field. */
53 #define OZ_VERSION_MASK         0xc
54 #define OZ_VERSION_SHIFT        2
55 #define OZ_F_ACK                0x10
56 #define OZ_F_ISOC               0x20
57 #define OZ_F_MORE_DATA          0x40
58 #define OZ_F_ACK_REQUESTED      0x80
59
60 #define oz_get_prot_ver(__x)    (((__x) & OZ_VERSION_MASK) >> OZ_VERSION_SHIFT)
61
62 /* Used to select the bits of packet number to put in the last_pkt_num.
63  */
64 #define OZ_LAST_PN_MASK         0x00ff
65
66 #define OZ_LAST_PN_HALF_CYCLE   127
67
68 /* Connect request data structure.
69  */
70 struct oz_elt_connect_req {
71         u8      mode;
72         u8      resv1[16];
73         u8      pd_info;
74         u8      session_id;
75         u8      presleep;
76         u8      resv2;
77         u8      host_vendor;
78         u8      keep_alive;
79         u16     apps;
80         u8      max_len_div16;
81         u8      ms_per_isoc;
82         u8      resv3[2];
83 } PACKED;
84
85 /* mode field bits.
86  */
87 #define OZ_MODE_POLLED          0x0
88 #define OZ_MODE_TRIGGERED       0x1
89 #define OZ_MODE_MASK            0xf
90 #define OZ_F_ISOC_NO_ELTS       0x40
91 #define OZ_F_ISOC_ANYTIME       0x80
92 #define OZ_NO_ELTS_ANYTIME      0xc0
93
94 /* Keep alive field.
95  */
96 #define OZ_KALIVE_TYPE_MASK     0xc0
97 #define OZ_KALIVE_VALUE_MASK    0x3f
98 #define OZ_KALIVE_SPECIAL       0x00
99 #define OZ_KALIVE_SECS          0x40
100 #define OZ_KALIVE_MINS          0x80
101 #define OZ_KALIVE_HOURS         0xc0
102
103 /* Connect response data structure.
104  */
105 struct oz_elt_connect_rsp {
106         u8      mode;
107         u8      status;
108         u8      resv1[3];
109         u8      session_id;
110         u16     apps;
111         u32     resv2;
112 } PACKED;
113
114 struct oz_elt_farewell {
115         u8      ep_num;
116         u8      index;
117         u8      report[1];
118 } PACKED;
119
120 struct oz_elt_update_param {
121         u8      resv1[16];
122         u8      presleep;
123         u8      resv2;
124         u8      host_vendor;
125         u8      keepalive;
126 } PACKED;
127
128 /* Header common to all application elements.
129  */
130 struct oz_app_hdr {
131         u8      app_id;
132         u8      elt_seq_num;
133 } PACKED;
134
135 /* Values for app_id.
136  */
137 #define OZ_APPID_USB                            0x1
138 #define OZ_APPID_UNUSED1                        0x2
139 #define OZ_APPID_UNUSED2                        0x3
140 #define OZ_APPID_SERIAL                         0x4
141 #define OZ_APPID_MAX                            OZ_APPID_SERIAL
142 #define OZ_NB_APPS                              (OZ_APPID_MAX+1)
143
144 /* USB header common to all elements for the  USB application.
145  * This header extends the oz_app_hdr and comes directly after
146  * the element header in a USB application.
147  */
148 struct oz_usb_hdr {
149         u8      app_id;
150         u8      elt_seq_num;
151         u8      type;
152 } PACKED;
153
154
155
156 /* USB requests element subtypes (type field of hs_usb_hdr).
157  */
158 #define OZ_GET_DESC_REQ                 1
159 #define OZ_GET_DESC_RSP                 2
160 #define OZ_SET_CONFIG_REQ               3
161 #define OZ_SET_CONFIG_RSP               4
162 #define OZ_SET_INTERFACE_REQ            5
163 #define OZ_SET_INTERFACE_RSP            6
164 #define OZ_VENDOR_CLASS_REQ             7
165 #define OZ_VENDOR_CLASS_RSP             8
166 #define OZ_GET_STATUS_REQ               9
167 #define OZ_GET_STATUS_RSP               10
168 #define OZ_CLEAR_FEATURE_REQ            11
169 #define OZ_CLEAR_FEATURE_RSP            12
170 #define OZ_SET_FEATURE_REQ              13
171 #define OZ_SET_FEATURE_RSP              14
172 #define OZ_GET_CONFIGURATION_REQ        15
173 #define OZ_GET_CONFIGURATION_RSP        16
174 #define OZ_GET_INTERFACE_REQ            17
175 #define OZ_GET_INTERFACE_RSP            18
176 #define OZ_SYNCH_FRAME_REQ              19
177 #define OZ_SYNCH_FRAME_RSP              20
178 #define OZ_USB_ENDPOINT_DATA            23
179
180 #define OZ_REQD_D2H                     0x80
181
182 struct oz_get_desc_req {
183         u8      app_id;
184         u8      elt_seq_num;
185         u8      type;
186         u8      req_id;
187         u16     offset;
188         u16     size;
189         u8      req_type;
190         u8      desc_type;
191         u16     w_index;
192         u8      index;
193 } PACKED;
194
195 /* Values for desc_type field.
196 */
197 #define OZ_DESC_DEVICE                  0x01
198 #define OZ_DESC_CONFIG                  0x02
199 #define OZ_DESC_STRING                  0x03
200
201 /* Values for req_type field.
202  */
203 #define OZ_RECP_MASK                    0x1F
204 #define OZ_RECP_DEVICE                  0x00
205 #define OZ_RECP_INTERFACE               0x01
206 #define OZ_RECP_ENDPOINT                0x02
207
208 #define OZ_REQT_MASK                    0x60
209 #define OZ_REQT_STD                     0x00
210 #define OZ_REQT_CLASS                   0x20
211 #define OZ_REQT_VENDOR                  0x40
212
213 struct oz_get_desc_rsp {
214         u8      app_id;
215         u8      elt_seq_num;
216         u8      type;
217         u8      req_id;
218         u16     offset;
219         u16     total_size;
220         u8      rcode;
221         u8      data[1];
222 } PACKED;
223
224 struct oz_feature_req {
225         u8      app_id;
226         u8      elt_seq_num;
227         u8      type;
228         u8      req_id;
229         u8      recipient;
230         u8      index;
231         u16     feature;
232 } PACKED;
233
234 struct oz_feature_rsp {
235         u8      app_id;
236         u8      elt_seq_num;
237         u8      type;
238         u8      req_id;
239         u8      rcode;
240 } PACKED;
241
242 struct oz_set_config_req {
243         u8      app_id;
244         u8      elt_seq_num;
245         u8      type;
246         u8      req_id;
247         u8      index;
248 } PACKED;
249
250 struct oz_set_config_rsp {
251         u8      app_id;
252         u8      elt_seq_num;
253         u8      type;
254         u8      req_id;
255         u8      rcode;
256 } PACKED;
257
258 struct oz_set_interface_req {
259         u8      app_id;
260         u8      elt_seq_num;
261         u8      type;
262         u8      req_id;
263         u8      index;
264         u8      alternative;
265 } PACKED;
266
267 struct oz_set_interface_rsp {
268         u8      app_id;
269         u8      elt_seq_num;
270         u8      type;
271         u8      req_id;
272         u8      rcode;
273 } PACKED;
274
275 struct oz_get_interface_req {
276         u8      app_id;
277         u8      elt_seq_num;
278         u8      type;
279         u8      req_id;
280         u8      index;
281 } PACKED;
282
283 struct oz_get_interface_rsp {
284         u8      app_id;
285         u8      elt_seq_num;
286         u8      type;
287         u8      req_id;
288         u8      rcode;
289         u8      alternative;
290 } PACKED;
291
292 struct oz_vendor_class_req {
293         u8      app_id;
294         u8      elt_seq_num;
295         u8      type;
296         u8      req_id;
297         u8      req_type;
298         u8      request;
299         u16     value;
300         u16     index;
301         u8      data[1];
302 } PACKED;
303
304 struct oz_vendor_class_rsp {
305         u8      app_id;
306         u8      elt_seq_num;
307         u8      type;
308         u8      req_id;
309         u8      rcode;
310         u8      data[1];
311 } PACKED;
312
313 struct oz_data {
314         u8      app_id;
315         u8      elt_seq_num;
316         u8      type;
317         u8      endpoint;
318         u8      format;
319 } PACKED;
320
321 struct oz_isoc_fixed {
322         u8      app_id;
323         u8      elt_seq_num;
324         u8      type;
325         u8      endpoint;
326         u8      format;
327         u8      unit_size;
328         u8      frame_number;
329         u8      data[1];
330 } PACKED;
331
332 struct oz_multiple_fixed {
333         u8      app_id;
334         u8      elt_seq_num;
335         u8      type;
336         u8      endpoint;
337         u8      format;
338         u8      unit_size;
339         u8      data[1];
340 } PACKED;
341
342 struct oz_fragmented {
343         u8      app_id;
344         u8      elt_seq_num;
345         u8      type;
346         u8      endpoint;
347         u8      format;
348         u16     total_size;
349         u16     offset;
350         u8      data[1];
351 } PACKED;
352
353 /* Note: the following does not get packaged in an element in the same way
354  * that other data formats are packaged. Instead the data is put in a frame
355  * directly after the oz_header and is the only permitted data in such a
356  * frame. The length of the data is directly determined from the frame size.
357  */
358 struct oz_isoc_large {
359         u8      endpoint;
360         u8      format;
361         u8      ms_data;
362         u8      frame_number;
363 } PACKED;
364
365 #define OZ_DATA_F_TYPE_MASK             0xF
366 #define OZ_DATA_F_MULTIPLE_FIXED        0x1
367 #define OZ_DATA_F_MULTIPLE_VAR          0x2
368 #define OZ_DATA_F_ISOC_FIXED            0x3
369 #define OZ_DATA_F_ISOC_VAR              0x4
370 #define OZ_DATA_F_FRAGMENTED            0x5
371 #define OZ_DATA_F_ISOC_LARGE            0x7
372
373 #endif /* _OZPROTOCOL_H */